From 3dc387602dd27fc82bc624016f8972bf22f59a32 Mon Sep 17 00:00:00 2001 From: osodebailar Date: Tue, 15 Mar 2022 13:24:51 +0100 Subject: [PATCH 1/4] set night mode as default and all color in xml fragments by attribute - additional preparation for switching light dark mode --- app/src/main/AndroidManifest.xml | 23 +- .../nightscout/androidaps/MainActivity.kt | 3 + .../info/nightscout/androidaps/MainApp.kt | 12 + .../setupwizard/SetupWizardActivity.kt | 2 + app/src/main/res/layout/actions_fragment.xml | 1 + .../res/layout/activity_historybrowse.xml | 2 +- .../main/res/layout/activity_logsetting.xml | 2 +- app/src/main/res/layout/activity_main.xml | 18 +- .../main/res/layout/activity_preferences.xml | 4 +- .../res/layout/activity_profilehelper.xml | 12 +- .../main/res/layout/activity_setupwizard.xml | 10 +- .../layout/activity_smscommunicator_otp.xml | 2 +- app/src/main/res/layout/activity_stats.xml | 2 +- app/src/main/res/layout/bgsource_item.xml | 7 +- .../res/layout/careportal_stats_fragment.xml | 8 - .../careportal_stats_fragment_lowres.xml | 8 - .../layout/dialog_alert_import_summary.xml | 2 +- .../res/layout/dialog_alert_two_messages.xml | 2 +- .../main/res/layout/dialog_calibration.xml | 2 +- app/src/main/res/layout/dialog_carbs.xml | 2 +- app/src/main/res/layout/dialog_care.xml | 2 +- .../main/res/layout/dialog_extendedbolus.xml | 2 +- app/src/main/res/layout/dialog_fill.xml | 2 +- app/src/main/res/layout/dialog_insulin.xml | 2 +- app/src/main/res/layout/dialog_loop.xml | 2 +- .../main/res/layout/dialog_profileswitch.xml | 2 +- app/src/main/res/layout/dialog_tempbasal.xml | 2 +- app/src/main/res/layout/dialog_temptarget.xml | 10 +- app/src/main/res/layout/dialog_treatment.xml | 2 +- app/src/main/res/layout/dialog_wizard.xml | 6 +- app/src/main/res/layout/dialog_wizardinfo.xml | 2 +- app/src/main/res/layout/food_item.xml | 2 +- .../main/res/layout/localprofile_fragment.xml | 2 - app/src/main/res/layout/logsettings_item.xml | 1 - app/src/main/res/layout/loop_fragment.xml | 11 - .../main/res/layout/maintenance_fragment.xml | 14 +- .../main/res/layout/ns_client_fragment.xml | 8 +- .../layout/number_picker_layout_vertical.xml | 21 +- .../res/layout/objectives_exam_fragment.xml | 6 +- app/src/main/res/layout/objectives_item.xml | 6 +- .../main/res/layout/openapsama_fragment.xml | 13 - .../res/layout/overview_buttons_layout.xml | 16 +- .../overview_editquickwizard_dialog.xml | 2 +- app/src/main/res/layout/overview_fragment.xml | 4 - .../res/layout/overview_notification_item.xml | 2 +- .../layout/overview_quickwizardlist_item.xml | 6 +- .../layout/treatments_bolus_carbs_item.xml | 10 +- .../res/layout/treatments_careportal_item.xml | 4 +- .../layout/treatments_extendedbolus_item.xml | 6 +- .../main/res/layout/treatments_fragment.xml | 5 +- .../layout/treatments_profileswitch_item.xml | 4 +- .../res/layout/treatments_tempbasals_item.xml | 14 +- .../res/layout/treatments_temptarget_item.xml | 4 +- app/src/main/res/layout/wear_fragment.xml | 4 +- .../main/res/menu/menu_delete_selection.xml | 2 +- app/src/main/res/values/colors.xml | 50 ---- app/src/main/res/values/strings.xml | 9 + app/src/main/res/values/styles.xml | 30 --- .../res/layout/automation_action_item.xml | 2 +- .../res/layout/automation_dialog_action.xml | 2 +- .../automation_dialog_choose_action.xml | 2 +- .../automation_dialog_choose_operation.xml | 2 +- .../automation_dialog_choose_trigger.xml | 2 +- .../layout/automation_dialog_edit_trigger.xml | 2 +- .../res/layout/automation_dialog_event.xml | 6 +- .../main/res/layout/automation_event_item.xml | 2 +- .../main/res/layout/combopump_fragment.xml | 11 - .../activities/NoSplashAppCompatActivity.kt | 2 + .../activities/PrefImportListActivity.kt | 1 + .../utils/alertDialogs/AlertDialogHelper.kt | 3 +- .../res/drawable-hdpi/background_total.xml | 8 + .../main/res/drawable-hdpi/border_gray.xml | 14 +- .../src/main/res/drawable/launch_screen.xml | 2 +- .../src/main/res/drawable/splash_icon.png | Bin .../main/res/layout/activity_tdd_stats.xml | 17 +- .../main/res/layout/dialog_bolusprogress.xml | 2 +- core/src/main/res/layout/dialog_error.xml | 2 +- .../main/res/layout/dialog_profileviewer.xml | 14 +- .../layout/maintenance_import_list_item.xml | 20 +- .../main/res/layout/number_picker_layout.xml | 9 +- core/src/main/res/layout/spinner_centered.xml | 3 +- core/src/main/res/layout/toast.xml | 2 +- core/src/main/res/values-night/colors.xml | 216 ++++++++++++++++ core/src/main/res/values-night/styles.xml | 238 ++++++++++++++++++ core/src/main/res/values/attrs.xml | 82 +++++- core/src/main/res/values/colors.xml | 78 +++++- core/src/main/res/values/strings.xml | 1 + core/src/main/res/values/styles.xml | 128 +++++++++- dana/src/main/res/layout/danar_fragment.xml | 16 +- .../res/layout/danar_history_activity.xml | 2 +- .../layout/danar_user_options_activity.xml | 2 +- .../res/layout/danars_blescanner_activity.xml | 2 +- .../res/layout/danars_blescanner_item.xml | 1 - .../res/layout/danars_enter_pin_activity.xml | 2 +- .../layout/danars_pairing_progress_dialog.xml | 2 +- .../layout/diaconn_g8_blescanner_activity.xml | 2 +- .../main/res/layout/diaconn_g8_fragment.xml | 13 - .../layout/diaconn_g8_history_activity.xml | 2 +- .../res/layout/diaconn_g8_history_item.xml | 2 +- .../diaconn_g8_user_options_activity.xml | 2 +- .../activity_insight_pairing_information.xml | 9 - .../main/res/layout/medtronic_fragment.xml | 12 +- .../omnipod_common_overview_pod_info.xml | 15 -- ...mnipod_eros_overview_riley_link_status.xml | 1 - .../src/main/res/layout/rileylink_status.xml | 6 +- 105 files changed, 943 insertions(+), 435 deletions(-) delete mode 100644 app/src/main/res/values/colors.xml delete mode 100644 app/src/main/res/values/styles.xml create mode 100644 core/src/main/res/drawable-hdpi/background_total.xml rename {app => core}/src/main/res/drawable/launch_screen.xml (90%) rename {app => core}/src/main/res/drawable/splash_icon.png (100%) create mode 100644 core/src/main/res/values-night/colors.xml create mode 100644 core/src/main/res/values-night/styles.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a163b3729c..54c7295df1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -55,6 +55,7 @@ android:resource="@xml/automotive_app_desc" /> @@ -62,7 +63,8 @@ - + @@ -72,12 +74,18 @@ - - - - - - + + + + + + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); + sp.getString(R.string.value_light_theme, "light") -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); + else -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); + } + // temp while switch is not public + setTheme(R.style.AppTheme) + } + private fun setRxErrorHandler() { RxJavaPlugins.setErrorHandler { t: Throwable -> var e = t diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt index 090b9ae07d..4e9d5539b2 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt @@ -50,6 +50,8 @@ class SetupWizardActivity : NoSplashAppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + // temp while switch is not public + setTheme(R.style.AppTheme) update(applicationContext) binding = ActivitySetupwizardBinding.inflate(layoutInflater) setContentView(binding.root) diff --git a/app/src/main/res/layout/actions_fragment.xml b/app/src/main/res/layout/actions_fragment.xml index e8362b0524..d7b04c933f 100644 --- a/app/src/main/res/layout/actions_fragment.xml +++ b/app/src/main/res/layout/actions_fragment.xml @@ -3,6 +3,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="?attr/fragmentbackground" tools:context=".plugins.general.actions.ActionsFragment"> diff --git a/app/src/main/res/layout/activity_logsetting.xml b/app/src/main/res/layout/activity_logsetting.xml index 303a9fd6df..cb1573ecf8 100644 --- a/app/src/main/res/layout/activity_logsetting.xml +++ b/app/src/main/res/layout/activity_logsetting.xml @@ -16,7 +16,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" - android:background="@color/activity_title_background" + android:background="?attr/activity_title_backgroundColor" android:orientation="horizontal" android:padding="5dp"> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 6edf1fa105..cf57888fd5 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -11,7 +11,7 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" - android:background="@color/colorPrimary" + android:background="?attr/colorPrimary" app:contentInsetEndWithActions="48dp" app:contentInsetStartWithNavigation="48dp" android:elevation="4dp"> @@ -21,9 +21,9 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/transparent" - app:tabIndicatorColor="@color/tabSelectedTextColor" - app:tabTextColor="@color/tabTextColor" - app:tabSelectedTextColor="@color/tabSelectedTextColor" + app:tabIndicatorColor="?attr/tabSelectedTextColor" + app:tabTextColor="?attr/tabTextColor" + app:tabSelectedTextColor="?attr/tabSelectedTextColor" app:tabMode="scrollable" /> @@ -58,8 +58,8 @@ app:itemBackground="?attr/selectableItemBackground" android:fitsSystemWindows="true" android:layout_gravity="start" - app:itemIconTint="@android:color/white" - app:itemTextColor="@android:color/white"/> + app:itemIconTint="?android:textColorPrimary" + app:itemTextColor="?android:textColorPrimary"/> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_preferences.xml b/app/src/main/res/layout/activity_preferences.xml index eef88c7bad..d4a7c61fc7 100644 --- a/app/src/main/res/layout/activity_preferences.xml +++ b/app/src/main/res/layout/activity_preferences.xml @@ -9,6 +9,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/filter" + android:textColorHint="?attr/colorOnPrimary" app:endIconMode="clear_text"> + android:inputType="text" + android:background="@color/transparent"/> diff --git a/app/src/main/res/layout/activity_profilehelper.xml b/app/src/main/res/layout/activity_profilehelper.xml index d87aca5296..09f11c0ff2 100644 --- a/app/src/main/res/layout/activity_profilehelper.xml +++ b/app/src/main/res/layout/activity_profilehelper.xml @@ -16,7 +16,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" - android:background="@color/defaultbackground" + android:background="?attr/defaultbackground" android:orientation="horizontal"> + android:textColorHint="?attr/tabBgColorSelected" + app:boxStrokeColor="?attr/tabBgColorSelected"> + app:boxStrokeColor="?attr/boxStrokeColor"> + app:boxStrokeColor="?attr/boxStrokeColor"> @@ -74,8 +73,7 @@ android:layout_height="wrap_content" android:background="@android:color/transparent" android:onClick="showPreviousPage" - android:text="@string/previous_button" - android:textColor="#FFFFFF" /> + android:text="@string/previous_button" /> + android:text="@string/next_button" />