Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(android): use material widgets/styles and default to DayNight theme #12353

Merged
merged 40 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0896b13
feat(android): default to material DayNight theme
jquick-axway Dec 19, 2020
383173c
feat(android): use material themed dialogs
jquick-axway Dec 19, 2020
32ed295
feat(android): use material themed toolbars
jquick-axway Dec 19, 2020
6893d22
feat(android): use material themed CardView
jquick-axway Dec 19, 2020
1458ef0
feat(android): use material based Ti.UI.Switch and add Chip style
jquick-axway Dec 19, 2020
0707f79
feat(android): use material button and add style property
jquick-axway Dec 19, 2020
2dd1af3
feat(android): add TextField/TextArea "borderStyle" property supporti…
jquick-axway Dec 19, 2020
35cf561
feat(macOS): add checkbox style to Ti.UI.Switch
jquick-axway Dec 19, 2020
dc20e5d
doc(ios): deprecate Ti.UI.iOS.SystemButtonStyle
jquick-axway Dec 19, 2020
3f84cab
chore(ios): fix linting issue in TiUISwitch.m
jquick-axway Dec 19, 2020
1e03dcf
chore(android): preserve intent extras after day/night change
jquick-axway Jan 5, 2021
ec9d340
feat(android): change button theme to not all-caps
jquick-axway Jan 5, 2021
f54c07e
feat(android): fetchSemanticColor() support dynamic light/dark change
jquick-axway Jan 6, 2021
a388f5b
chore(android): improved material TextField/TextArea handling
jquick-axway Jan 6, 2021
eb25772
chore(android): change Ti.UI.Label to use MaterialTextView
jquick-axway Jan 7, 2021
517efe9
chore(android): add day/night theme support to ListView/TableView
jquick-axway Jan 8, 2021
7ce40eb
chore(android): update semantic color handling
jquick-axway Feb 10, 2021
3607d4f
chore(android): update AndroidX/Material libraries
jquick-axway Feb 12, 2021
d4b3eaf
chore(android): update splash to use app theme and translucent bars
jquick-axway Feb 12, 2021
92c9084
feat(android): use material based ProgressBar/ActivityIndicator
jquick-axway Feb 12, 2021
3d05193
feat(android): use material based Date/Time picker dialogs
jquick-axway Feb 13, 2021
3125427
chore: rename Ti.UI.SWITCH_STYLE_TOGGLEBUTTON
jquick-axway Feb 16, 2021
12a7604
refactor(android): theme handling for Light/Dark/DayNight and ActionBar
jquick-axway Feb 18, 2021
beaf457
fix(android): warning logged by widgets when needlessly removing back…
jquick-axway Feb 18, 2021
0fac69f
chore(android): reduce TextField size for border style none
jquick-axway Feb 19, 2021
ed4689e
test(android): update to pass snapshot tests
jquick-axway Feb 19, 2021
fd2d9a2
feat(android): add outlined CardView support
jquick-axway Feb 20, 2021
a83b067
feat(android): add "?attr/color" string support
jquick-axway Feb 20, 2021
de1385b
chore(android): support fetching ColorStateList resource color
jquick-axway Feb 20, 2021
2b0caa5
chore(android): update gradle tools
jquick-axway Feb 22, 2021
af31623
chore(ios): change new button styles to "system" style
jquick-axway Feb 23, 2021
983fe13
chore(android): showDatePickerDialog() now throws error if min >= max
jquick-axway Feb 24, 2021
c07e022
chore(android): deprecatd Ti.UI.Android.SWITCH_STYLE_* constants
jquick-axway Feb 24, 2021
6566b87
chore(android): updated ActivityIndicator to use non-deprecated color…
jquick-axway Feb 24, 2021
2438108
feat: add animation support to Ti.UI.ProgressBar
jquick-axway Feb 24, 2021
40166f6
feat: add Ti.UI.overrideUserInterfaceStyle property
jquick-axway Feb 25, 2021
841c55a
feat(android): add title support to Ti.UI.Switch slider style
jquick-axway Feb 25, 2021
1228165
chore(android): remove vertical padding from Ti.UI.Switch slider style
jquick-axway Feb 25, 2021
1852e14
chore(android): color improvements to material TabGroup and TabbedBar
jquick-axway Feb 26, 2021
ba83d74
chore(android): fire "click" when TextField/TextArea was tapped witho…
jquick-axway Feb 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</intent>
</queries>

<application android:name=".TitaniumTestApplication" android:icon="@drawable/appicon" android:label="TitaniumTest" android:theme="@style/Theme.MaterialComponents.Bridge" android:usesCleartextTraffic="true">
<application android:name=".TitaniumTestApplication" android:icon="@drawable/appicon" android:label="TitaniumTest" android:theme="@style/Theme.Titanium.App" android:usesCleartextTraffic="true">
<!-- The root Titanium splash activity which hosts the JS runtime. -->
<activity android:name=".TitaniumTestActivity" android:theme="@style/Theme.Titanium" android:alwaysRetainTaskState="true" android:configChanges="${tiActivityConfigChanges}">
<intent-filter>
Expand Down
8 changes: 4 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
*/

buildscript {
ext.kotlin_version = '1.4.10'
ext.kotlin_version = '1.4.30'

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.google.gms:google-services:4.3.5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -28,7 +28,7 @@ allprojects {
// Load plugin used to enforce our Java coding style guidelines.
project.apply plugin: 'checkstyle'
checkstyle {
toolVersion = '8.36.2'
toolVersion = '8.38'
configFile file("${rootDir}/checkstyle.xml");
ignoreFailures false
showViolations true
Expand Down
32 changes: 15 additions & 17 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<group.id>:<artifact-id>:<version>"
// Example: "com.google.android.gms:play-services-base:11.0.4"
Expand Down Expand Up @@ -3257,13 +3249,20 @@ AndroidBuilder.prototype.generateTheme = async function generateTheme() {
const xmlFilePath = path.join(valuesDirPath, 'ti_styles.xml');
this.logger.info(__('Generating theme file: %s', xmlFilePath.cyan));

// Set up "Base.Theme.Titanium.Customizable" inherited themes to use <application/> 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;
// Set default theme to be used in "AndroidManifest.xml" and style resources.
let defaultAppThemeName = 'Theme.Titanium.DayNight';
if (this.tiapp.fullscreen || this.tiapp['statusbar-hidden']) {
defaultAppThemeName = 'Theme.Titanium.DayNight.Fullscreen';
} else if (this.tiapp['navbar-hidden']) {
defaultAppThemeName = 'Theme.Titanium.DayNight.NoTitleBar';
}

// Set up "Theme.AppDerived" to use the <application/> defined theme, if assigned.
let actualAppTheme = 'Theme.Titanium.App';
if (this.customAndroidManifest) {
const appTheme = this.customAndroidManifest.getAppAttribute('android:theme');
if (appTheme && !appTheme.startsWith('@style/Theme.Titanium') && !appTheme.startsWith('@style/Base.Theme.Titanium')) {
customizableParentThemeName = appTheme;
if (appTheme && !appTheme.startsWith('@style/Theme.AppDerived') && (appTheme !== '@style/Theme.Titanium')) {
actualAppTheme = appTheme;
}
}

Expand All @@ -3272,11 +3271,11 @@ AndroidBuilder.prototype.generateTheme = async function generateTheme() {
let xmlLines = [
'<?xml version="1.0" encoding="utf-8"?>',
'<resources>',
` <style name="Base.Theme.Titanium.Basic" parent="${this.defaultAppThemeName}"/>`,
` <style name="Base.Theme.Titanium.Customizable" parent="${customizableParentThemeName}"/>`,
` <style name="Theme.Titanium.App" parent="${defaultAppThemeName}"/>`,
` <style name="Theme.AppDerived" parent="${actualAppTheme}"/>`,
'',
' <!-- Theme used by "TiRootActivity" derived class which displays the splash screen. -->',
' <style name="Theme.Titanium" parent="@style/Base.Theme.Titanium.Splash">',
' <style name="Theme.Titanium" parent="Base.Theme.Titanium.Splash">',
' <item name="android:windowBackground">@drawable/background</item>',
' </style>',
'</resources>'
Expand Down Expand Up @@ -3513,7 +3512,6 @@ AndroidBuilder.prototype.generateAndroidManifest = async function generateAndroi
appChildXmlLines: appChildXmlLines,
appIcon: '@drawable/' + this.tiapp.icon.replace(/((\.9)?\.(png|jpg))$/, ''),
appLabel: this.tiapp.name,
appTheme: `@style/${this.defaultAppThemeName}`,
classname: this.classname,
storagePermissionMaxSdkVersion: neededManifestSettings.storagePermissionMaxSdkVersion,
packageName: this.appid,
Expand Down
Binary file modified android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
21 changes: 3 additions & 18 deletions android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,29 +64,14 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package ti.modules.titanium.android.quicksettings;

import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.graphics.drawable.Icon;
import android.service.quicksettings.TileService;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollRuntime;
import org.appcelerator.kroll.annotations.Kroll;
Expand All @@ -27,7 +26,7 @@ public class QuickSettingsServiceProxy extends ServiceProxy
private TileService tileService;
//workaround for dealing with Icon class
private Object pathObject = null;
private AlertDialog.Builder builder;
private MaterialAlertDialogBuilder builder;

public QuickSettingsServiceProxy(TileService serviceInstance)
{
Expand Down Expand Up @@ -134,7 +133,7 @@ public void run()

private Dialog createDialogFromDictionary(KrollDict krollDict)
{
builder = new AlertDialog.Builder(tileService.getApplicationContext());
builder = new MaterialAlertDialogBuilder(tileService.getApplicationContext());
String[] buttonText = null;
if (krollDict.containsKey(TiC.PROPERTY_TITLE)) {
builder.setTitle(krollDict.getString(TiC.PROPERTY_TITLE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ public void onCreate(Bundle savedInstanceState)
previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

// set preview overlay
localOverlayProxy = overlayProxy;
this.localOverlayProxy = overlayProxy;
if (this.localOverlayProxy != null) {
this.localOverlayProxy.setActivity(this);
}

// set overall layout - will populate in onResume
previewLayout = new PreviewLayout(this);
Expand Down
6 changes: 0 additions & 6 deletions android/modules/ui/res/layout/titanium_ui_checkbox.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ti.modules.titanium.ui.widget.picker.CustomDatePicker xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/titanium_ui_date_picker_spinner"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:datePickerMode ="spinner"/>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout_toolbar"
android:visibility="gone"
Expand Down
6 changes: 0 additions & 6 deletions android/modules/ui/res/layout/titanium_ui_edittext.xml

This file was deleted.

1 change: 0 additions & 1 deletion android/modules/ui/res/layout/titanium_ui_spinner.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Spinner xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/titanium_ui_spinner"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
6 changes: 0 additions & 6 deletions android/modules/ui/res/layout/titanium_ui_switchcompat.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TimePicker xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/titanium_ui_time_picker_spinner"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:timePickerMode ="spinner"/>
2 changes: 1 addition & 1 deletion android/modules/ui/res/layout/titanium_ui_toolbar.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:visibility="gone"
Expand Down
Loading