From 86a704f3b682e79a197313d89df84040a1c94eb0 Mon Sep 17 00:00:00 2001 From: Joshua Quick Date: Sat, 19 Dec 2020 01:15:36 -0800 Subject: [PATCH] feat(android): default to material DayNight theme Fixes TIMOB-28301 --- android/app/src/main/AndroidManifest.xml | 2 +- android/cli/commands/_build.js | 21 ++++--- .../titanium_ui_date_picker_spinner.xml | 1 - .../ui/res/layout/titanium_ui_edittext.xml | 1 - .../ui/res/layout/titanium_ui_spinner.xml | 1 - .../titanium_ui_time_picker_spinner.xml | 1 - .../widget/tabgroup/TiUIAbstractTabGroup.java | 22 +++---- android/templates/build/AndroidManifest.xml | 2 +- android/titanium/res/values-night/values.xml | 10 ++++ android/titanium/res/values/values.xml | 57 ++++++++++++++++--- .../appcelerator/titanium/TiBaseActivity.java | 47 +++++++++++++-- .../titanium/TiExceptionHandler.java | 39 ++++++++++--- .../titanium/proxy/TiWindowProxy.java | 7 +-- 13 files changed, 158 insertions(+), 53 deletions(-) create mode 100644 android/titanium/res/values-night/values.xml diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 8f2261a4e50..36495a20247 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -29,7 +29,7 @@ - + diff --git a/android/cli/commands/_build.js b/android/cli/commands/_build.js index 916fdb20c60..5640c6f846b 100644 --- a/android/cli/commands/_build.js +++ b/android/cli/commands/_build.js @@ -1648,14 +1648,6 @@ AndroidBuilder.prototype.initialize = async function initialize() { const loadFromSDCardProp = this.tiapp.properties['ti.android.loadfromsdcard']; this.loadFromSDCard = loadFromSDCardProp && loadFromSDCardProp.value === true; - // Set default theme to be used in "AndroidManifest.xml" and style resources. - this.defaultAppThemeName = 'Theme.MaterialComponents.Bridge'; - if (this.tiapp.fullscreen || this.tiapp['statusbar-hidden']) { - this.defaultAppThemeName = 'Theme.MaterialComponents.Fullscreen.Bridge'; - } else if (this.tiapp['navbar-hidden']) { - this.defaultAppThemeName = 'Theme.MaterialComponents.NoActionBar.Bridge'; - } - // Array of gradle/maven compatible library reference names the app project depends on. // Formatted as: "::" // Example: "com.google.android.gms:play-services-base:11.0.4" @@ -3257,9 +3249,17 @@ AndroidBuilder.prototype.generateTheme = async function generateTheme() { const xmlFilePath = path.join(valuesDirPath, 'ti_styles.xml'); this.logger.info(__('Generating theme file: %s', xmlFilePath.cyan)); + // Set default theme to be used in "AndroidManifest.xml" and style resources. + let defaultAppThemeName = 'Theme.MaterialComponents.DayNight.DarkActionBar'; + if (this.tiapp.fullscreen || this.tiapp['statusbar-hidden']) { + defaultAppThemeName = 'Theme.MaterialComponents.DayNight.Fullscreen'; + } else if (this.tiapp['navbar-hidden']) { + defaultAppThemeName = 'Theme.MaterialComponents.DayNight.NoActionBar'; + } + // Set up "Base.Theme.Titanium.Customizable" inherited themes to use defined theme, if provided. // Note: Do not assign it if set to a Titanium theme, which would cause a circular reference. - let customizableParentThemeName = this.defaultAppThemeName; + let customizableParentThemeName = 'Base.Theme.Titanium'; if (this.customAndroidManifest) { const appTheme = this.customAndroidManifest.getAppAttribute('android:theme'); if (appTheme && !appTheme.startsWith('@style/Theme.Titanium') && !appTheme.startsWith('@style/Base.Theme.Titanium')) { @@ -3272,7 +3272,7 @@ AndroidBuilder.prototype.generateTheme = async function generateTheme() { let xmlLines = [ '', '', - ` + + + + + + + + + + + +