diff --git a/app/build.gradle b/app/build.gradle index f1d68de..08c11c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.mosad.seil0.projectlaogai" minSdkVersion 21 targetSdkVersion 28 - versionCode 4 - versionName "0.1.3" + versionCode 5 + versionName "0.1.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -27,7 +27,7 @@ android { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'androidx.appcompat:appcompat:1.0.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.google.android.material:material:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 64af04f..90b3833 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,7 +9,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/AppTheme" android:fullBackupContent="@xml/backup_descriptor"> + android:theme="@style/AppTheme"> () private var courseTTLinkList = ArrayList() - private lateinit var timeTableWeek: Array> + private var timeTableWeek = arrayOf>() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -170,7 +170,11 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte } val t2 = doAsync { - timeTableWeek = timeTableParser.getTimeTable("https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0") + try { + timeTableWeek = timeTableParser.getTimeTable("https://www.hs-offenburg.de/index.php?id=6627&class=class&iddV=DA64F6FE-9DDB-429E-A677-05D0D40CB636&week=0") + }catch (e: Exception) { + e.stackTrace + } } t1.get() diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt index 6e75fce..ca56b83 100644 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt +++ b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/HomeFragment.kt @@ -28,6 +28,7 @@ import android.view.View import android.view.ViewGroup import android.widget.LinearLayout import androidx.fragment.app.Fragment +import com.afollestad.materialdialogs.MaterialDialog import kotlinx.android.synthetic.main.fragment_home.* import org.jetbrains.anko.doAsync import org.jetbrains.anko.uiThread @@ -94,26 +95,35 @@ class HomeFragment : Fragment() { * add the current timetable to the home screen */ private fun addCurrentTimeTable() { - val timeTableDay = mainActivity.getCurrentTimeTableWeek()[Calendar.getInstance().get(Calendar.DAY_OF_WEEK) -2] - for (i in 0..5) { - val lessonCardView = LessonCardView(context!!, null) + // TODO this needs to be reworked, currently we display the waring if there is no lecture at all not only if we're unable to load the tt + if (mainActivity.getCurrentTimeTableWeek().isNotEmpty()) { + val timeTableDay = mainActivity.getCurrentTimeTableWeek()[Calendar.getInstance().get(Calendar.DAY_OF_WEEK) -2] - lessonCardView.getTxtViewLesson().text = resources.getString(R.string.string_new_line, timeTableDay[i].lessonSubject) - lessonCardView.getTxtViewLesson().append(timeTableDay[i].lessonTeacher + "\n") - lessonCardView.getTxtViewLesson().append(timeTableDay[i].lessonRoom) - lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i] + for (i in 0..5) { + val lessonCardView = LessonCardView(context!!, null) - if(lessonCardView.getTxtViewLesson().text.length > 2) - linLayoutTimeTable.addView(lessonCardView) - } + lessonCardView.getTxtViewLesson().text = resources.getString(R.string.string_new_line, timeTableDay[i].lessonSubject) + lessonCardView.getTxtViewLesson().append(timeTableDay[i].lessonTeacher + "\n") + lessonCardView.getTxtViewLesson().append(timeTableDay[i].lessonRoom) + lessonCardView.getTxtViewTime().text = DataTypes().getTime()[i] - // add a card if there is no lesson today - if (linLayoutTimeTable.childCount == 0) { - // TODO we could display the next day with a lecture - val noLessonCardView = LessonCardView(context!!, null) - noLessonCardView.getTxtViewLesson().text = resources.getString(R.string.no_lesson_today) - linLayoutTimeTable.addView(noLessonCardView) + if(lessonCardView.getTxtViewLesson().text.length > 2) + linLayoutTimeTable.addView(lessonCardView) + } + + // add a card if there is no lesson today + if (linLayoutTimeTable.childCount == 0) { + // TODO we could display the next day with a lecture + val noLessonCardView = LessonCardView(context!!, null) + noLessonCardView.getTxtViewLesson().text = resources.getString(R.string.no_lesson_today) + linLayoutTimeTable.addView(noLessonCardView) + } + } else { + MaterialDialog(context!!) + .title(R.string.error) + .message(R.string.nott_info) + .show() } } diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml index f94bf0c..a00bede 100644 --- a/app/src/main/res/values-de-rDE/strings.xml +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -11,6 +11,8 @@ heute keine Essensausgabe Diese Woche keine weitere Essensausgabe heute keine Vorlesung + Fehler + Stundenplan konnte nicht geladen werden! Info Benutzer Tippen, um den Kurs zu ändern diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fa09649..3fdc62d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,7 +2,7 @@ Project Laogai Open navigation drawer Close navigation drawer - hso App 0.1.3 + hso App 0.1.4 seil0@mosad.xyz Project Laogai @@ -19,6 +19,8 @@ No more Food this week "no lecture today " + Error + Could not load timetabl!" SampleUser@stud.hs-offenburg.de SampleCourse 3 @@ -32,7 +34,7 @@ primary color The primary color, default is indigo select - version 0.1.3 + version 0.1.4 about hso App by @Seil0 "This software is made by @Seil0 and is published under the terms and conditions of GPL 3. For further information visit \ngit.mosad.xyz/Seil0/ProjectLaogai \n\n© 2018 seil0@mosad.xyz "