diff --git a/app/build.gradle b/app/build.gradle index f5f8ff9..bdb9ee0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,10 +10,10 @@ android { compileSdkVersion 28 defaultConfig { applicationId "org.mosad.seil0.projectlaogai" - minSdkVersion 21 + minSdkVersion 23 targetSdkVersion 28 - versionCode 13 - versionName "0.4.90" + versionCode 14 + versionName "0.4.91" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" resValue "string", "build_time", buildTime() setProperty("archivesBaseName", "projectlaogai-$versionName") @@ -37,7 +37,7 @@ dependencies { implementation 'org.jetbrains.anko:anko-commons:0.10.8' implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1' + implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' implementation 'com.google.android.material:material:1.0.0' implementation 'com.google.code.gson:gson:2.8.5' diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt index 6741da6..e0ad511 100644 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt +++ b/app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt @@ -61,26 +61,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte // load mensa, timetable and color load() - - // If we haven't set any defaults, do that now - if (Aesthetic.isFirstTime) { - // this is executed on the first app start, use this to show tutorial etc. - Aesthetic.config { - colorPrimary(Color.BLACK) - colorPrimaryDark(Color.BLACK) - colorAccent(Color.parseColor("#3F51B5")) - apply() - } - - SettingsFragment().selectCourse(this) - } else { - Aesthetic.config { - colorPrimary(cColorPrimary) - colorPrimaryDark(cColorPrimary) - colorAccent(cColorAccent) - apply() - } - } + initAesthetic() //init home fragment val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction() @@ -146,6 +127,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte fragmentTransaction.commit() drawer_layout.closeDrawer(GravityCompat.START) + return true } @@ -208,4 +190,28 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte println("startup completed in $startupTime ms") } + private fun initAesthetic() { + // If we haven't set any defaults, do that now + if (Aesthetic.isFirstTime) { + // this is executed on the first app start, use this to show tutorial etc. + Aesthetic.config { + activityTheme(R.style.AppTheme) + colorPrimary(Color.BLACK) + colorPrimaryDark(Color.BLACK) + colorAccent(Color.parseColor("#3f51b5")) + apply() + } + + SettingsFragment().selectCourse(this) + } else { + Aesthetic.config { +// activityTheme(R.style.AppTheme_Light) + colorPrimary(cColorPrimary) + colorPrimaryDark(cColorPrimary) + colorAccent(cColorAccent) + apply() + } + } + } + } diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/controller/CacheController.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/controller/CacheController.kt index 2bed4e2..109e8a4 100644 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/controller/CacheController.kt +++ b/app/src/main/java/org/mosad/seil0/projectlaogai/controller/CacheController.kt @@ -37,6 +37,10 @@ class CacheController(cont: Context) { private val context = cont + init { + // TODO move cache check here + } + companion object { var coursesList = ArrayList() var timetables = ArrayList() 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 e8b2212..68ad76f 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 @@ -60,7 +60,7 @@ class HomeFragment : Fragment() { val view: View = inflater.inflate(R.layout.fragment_home, container, false) addMensaMenu().get() - addTimeTable() + addTimeTable().get() // Inflate the layout for this fragment return view @@ -75,42 +75,48 @@ class HomeFragment : Fragment() { val cal = Calendar.getInstance() val mensaCardView = DayCardView(context!!) + + uiThread { - if (cal.get(Calendar.HOUR_OF_DAY) < 15) { - dayMeals = mensaMenu.currentWeek.days[NotRetardedCalendar().getDayOfWeekIndex()].meals - mensaCardView.setDayHeading(resources.getString(R.string.today_date, formatter.format(cal.time))) - } else { - dayMeals = mensaMenu.currentWeek.days[NotRetardedCalendar().getTomorrowWeekIndex()].meals - cal.add(Calendar.DATE, 1) - mensaCardView.setDayHeading(resources.getString(R.string.tomorrow_date, formatter.format(cal.time))) - } - - if (dayMeals.size >= 2) { - // get the index of the first meal, not a "Schneller Teller" - loop@ for ((i, meal) in dayMeals.withIndex()) { - if (meal.heading.contains("Essen")) { - - val meal1Layout = MealLinearLayout(context) - meal1Layout.setMeal(dayMeals[i]) - mensaCardView.getLinLayoutDay().addView(meal1Layout) - - val meal2Layout = MealLinearLayout(context) - meal2Layout.setMeal(dayMeals[i + 1]) - meal2Layout.disableDivider() - mensaCardView.getLinLayoutDay().addView(meal2Layout) - - break@loop - } + if (isAdded) { + if (cal.get(Calendar.HOUR_OF_DAY) < 15) { + dayMeals = mensaMenu.currentWeek.days[NotRetardedCalendar().getDayOfWeekIndex()].meals + mensaCardView.setDayHeading(activity!!.resources.getString(R.string.today_date, formatter.format(cal.time))) + } else { + dayMeals = mensaMenu.currentWeek.days[NotRetardedCalendar().getTomorrowWeekIndex()].meals + cal.add(Calendar.DATE, 1) + mensaCardView.setDayHeading(activity!!.resources.getString(R.string.tomorrow_date, formatter.format(cal.time))) } - } else { - mensaCardView.getLinLayoutDay().addView(getNoCard(resources.getString(R.string.mensa_closed))) + if (dayMeals.size >= 2) { + // get the index of the first meal, not a "Schneller Teller" + loop@ for ((i, meal) in dayMeals.withIndex()) { + if (meal.heading.contains("Essen")) { + + val meal1Layout = MealLinearLayout(context) + meal1Layout.setMeal(dayMeals[i]) + mensaCardView.getLinLayoutDay().addView(meal1Layout) + + val meal2Layout = MealLinearLayout(context) + meal2Layout.setMeal(dayMeals[i + 1]) + meal2Layout.disableDivider() + mensaCardView.getLinLayoutDay().addView(meal2Layout) + + break@loop + } + } + + } else { + mensaCardView.getLinLayoutDay().addView(getNoCard(resources.getString(R.string.mensa_closed))) + } + + linLayout_Home.addView(mensaCardView) } - linLayout_Home.addView(mensaCardView) } + } /** @@ -123,29 +129,30 @@ class HomeFragment : Fragment() { uiThread { - if (timetables.isNotEmpty() && dayIndex < 6) { + if (isAdded) { + if (timetables.isNotEmpty() && dayIndex < 6) { - // first check the current day - dayCardView = addDayTimetable(timetables[0].days[dayIndex]) - dayCardView.setDayHeading(resources.getString(R.string.today_date, formatter.format(cal.time))) + // first check the current day + dayCardView = addDayTimetable(timetables[0].days[dayIndex]) + dayCardView.setDayHeading(resources.getString(R.string.today_date, formatter.format(cal.time))) - // if there are no lessons try to find the next day with a lesson - if (dayCardView.getLinLayoutDay().childCount <= 1) - dayCardView = findNextDay(0, dayIndex + 1) + // if there are no lessons try to find the next day with a lesson + if (dayCardView.getLinLayoutDay().childCount <= 1) + dayCardView = findNextDay(0, dayIndex + 1) - linLayout_Home.addView(dayCardView) - } else if (dayIndex == 6) { - // if that's the case it's sunday - dayCardView = findNextDay(1, 0) - linLayout_Home.addView(dayCardView) - } else { - MaterialDialog(context!!) - .title(R.string.error) - .message(R.string.timetable_error) - .show() - // TODO log the error and send feedback + linLayout_Home.addView(dayCardView) + } else if (dayIndex == 6) { + // if that's the case it's sunday + dayCardView = findNextDay(1, 0) + linLayout_Home.addView(dayCardView) + } else { + MaterialDialog(context!!) + .title(R.string.error) + .message(R.string.timetable_error) + .show() + // TODO log the error and send feedback + } } - } } diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt index 972e243..365e87b 100644 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt +++ b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt @@ -50,6 +50,7 @@ import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.course import org.mosad.seil0.projectlaogai.controller.TCoRAPIController import org.mosad.seil0.projectlaogai.hsoparser.DataTypes import java.util.* +import android.util.TypedValue /** * The settings controller class @@ -87,6 +88,14 @@ class SettingsFragment : Fragment() { txtView_Course.text = cCourse.courseName txtView_AboutDesc.text = resources.getString(R.string.about_version, BuildConfig.VERSION_NAME, getString(R.string.build_time)) switch_buffet.isChecked = cShowBuffet // init switch + + val outValue = TypedValue() + activity!!.theme.resolveAttribute(R.attr.themeName, outValue, true) + if (outValue.string == "dark") { + switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryDark, activity!!.theme)) + } else { + switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryLight, activity!!.theme)) + } } /** @@ -95,6 +104,19 @@ class SettingsFragment : Fragment() { private fun initActions() { linLayoutUser.setOnClickListener { // open a new dialog + // TODO move and save +// val outValue = TypedValue() +// activity!!.theme.resolveAttribute(R.attr.themeName, outValue, true) +// if (outValue.string == "dark") { +// Aesthetic.config { +// activityTheme(R.style.AppTheme_Light) +// } +// } else { +// Aesthetic.config { +// activityTheme(R.style.AppTheme_Dark) +// } +// } + } linLayoutCourse.setOnClickListener { diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt index 5fdd17b..90482dd 100644 --- a/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt +++ b/app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt @@ -22,7 +22,6 @@ package org.mosad.seil0.projectlaogai.fragments -import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -94,17 +93,15 @@ class TimeTableFragment : Fragment() { .show() } - // TODO only works with android m(23) or higher // hide the btnCardValue if the user is scrolling down - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - scrollViewTimetable.setOnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY -> - if (scrollY > oldScrollY) { - faBtnAddLesson.hide() - } else { - faBtnAddLesson.show() - } + scrollViewTimetable.setOnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY -> + if (scrollY > oldScrollY) { + faBtnAddLesson.hide() + } else { + faBtnAddLesson.show() } } + } } diff --git a/app/src/main/res/drawable/background_splash.xml b/app/src/main/res/drawable/background_splash.xml index f9df9fc..9de6881 100644 --- a/app/src/main/res/drawable/background_splash.xml +++ b/app/src/main/res/drawable/background_splash.xml @@ -3,9 +3,7 @@ - - - + diff --git a/app/src/main/res/layout/cardview_day.xml b/app/src/main/res/layout/cardview_day.xml index 8c27625..4ce5d7a 100644 --- a/app/src/main/res/layout/cardview_day.xml +++ b/app/src/main/res/layout/cardview_day.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" app:cardUseCompatPadding="true" - app:cardElevation="5dp" app:cardBackgroundColor="@color/themeSecondary" + app:cardElevation="5dp" app:cardBackgroundColor="?themeSecondary" > + tools:context=".fragments.HomeFragment" + android:background="?themePrimary"> + tools:context=".fragments.MensaFragment" + android:background="?themePrimary"> + android:layout_height="match_parent" + android:id="@+id/scrollView_Mensa"> diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml index 6429411..7890591 100644 --- a/app/src/main/res/layout/fragment_settings.xml +++ b/app/src/main/res/layout/fragment_settings.xml @@ -1,9 +1,11 @@ + tools:context=".fragments.SettingsFragment" + android:background="?themePrimary"> + android:layout_height="match_parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + > + android:layout_marginTop="9dp" + android:id="@+id/cardView_Info" + app:cardElevation="5dp" + app:cardUseCompatPadding="true" + app:cardBackgroundColor="?themeSecondary"> + android:textSize="18sp" + android:textStyle="bold" + android:fontFamily="sans-serif" + android:layout_margin="7dp" + android:textColor="?colorAccent"/> + android:layout_height="wrap_content" + android:padding="7dp" + android:id="@+id/linLayout_User"> + android:layout_height="wrap_content" + android:id="@+id/txtView_User" + android:textSize="16sp" + android:textStyle="bold" + /> + android:layout_height="wrap_content" + android:id="@+id/txtView_UserDesc"/> + android:layout_height="wrap_content" + android:id="@+id/txtView_CourseDesc"/> + android:layout_height="wrap_content" + android:id="@+id/txtView_About" + android:textStyle="bold" + android:textSize="16sp" + /> + android:layout_height="wrap_content" + android:id="@+id/txtView_AboutDesc"/> + + android:id="@+id/cardView_Settings" + app:cardElevation="5dp" + app:cardUseCompatPadding="true" + app:cardBackgroundColor="?themeSecondary"> + android:layout_height="wrap_content" + android:id="@+id/linLayout_Settings" + android:padding="7dp"> + android:textSize="18sp" + android:textColor="?colorAccent" + android:textStyle="bold" + android:paddingTop="3dp"/> + android:clickable="true" + android:id="@+id/linLayout_PrimaryColor" + android:focusable="true"> + android:layout_height="wrap_content" + android:id="@+id/txtView_PrimaryColor" + android:textSize="16sp" + android:textStyle="bold" + /> + android:layout_height="wrap_content" + android:id="@+id/txtView_PrimaryColorDesc"/> @@ -145,7 +183,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical|end" - android:clickable="true" android:id="@+id/linLayout_AccentColor" android:focusable="true"> + android:clickable="true" + android:id="@+id/linLayout_AccentColor" + android:focusable="true"> + android:layout_height="wrap_content" + android:id="@+id/txtView_AccentColor" + android:textSize="16sp" + android:textStyle="bold" + /> + android:layout_height="wrap_content" + android:id="@+id/txtView_AccentColorDesc"/> + android:textStyle="bold" + android:text="@string/show_buffet" + /> diff --git a/app/src/main/res/layout/fragment_timetable.xml b/app/src/main/res/layout/fragment_timetable.xml index ea2f788..812720e 100644 --- a/app/src/main/res/layout/fragment_timetable.xml +++ b/app/src/main/res/layout/fragment_timetable.xml @@ -1,9 +1,10 @@ + tools:context=".fragments.TimeTableFragment" + android:background="?themePrimary"> diff --git a/app/src/main/res/layout/linearlayout_lesson.xml b/app/src/main/res/layout/linearlayout_lesson.xml index 4012441..d51021a 100644 --- a/app/src/main/res/layout/linearlayout_lesson.xml +++ b/app/src/main/res/layout/linearlayout_lesson.xml @@ -11,7 +11,7 @@ + android:textSize="15sp"/> + /> + /> \ No newline at end of file diff --git a/app/src/main/res/layout/linearlayout_meal.xml b/app/src/main/res/layout/linearlayout_meal.xml index 15752aa..61d7a32 100644 --- a/app/src/main/res/layout/linearlayout_meal.xml +++ b/app/src/main/res/layout/linearlayout_meal.xml @@ -8,16 +8,16 @@ android:text="@string/meal" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/txtView_MealHeading" android:textSize="18sp" - android:textColor="@color/textPrimary" android:textAlignment="center" android:paddingBottom="5dp" + android:textAlignment="center" android:paddingBottom="5dp" android:textStyle="bold"/> + android:textAlignment="center"/> \ No newline at end of file diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml new file mode 100644 index 0000000..da9cee6 --- /dev/null +++ b/app/src/main/res/values/attrs.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 7f52220..92bab79 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -2,28 +2,27 @@ #000000 #000000 - #3F51B5 - #FFFFFF - - #FFFFFF - #FFFFFF - #FAFAFA + #3f51b5 + #ffffff + #ffffff + #ffffff #000000 #818181 - #FFFFFF - #E0E0E0 - #000000 - #818181 - #000000 #303030 #424242 + #ffffff + #e0e0e0 + #232323 + + #ffffff + #ffffff + #000000 + #818181 + #e0e0e0 - #FFFFFF - #FFFFFF - #424242 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index a27a731..1bd2b68 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,13 +1,30 @@ - + + + +