From 659b46fd4e6fc937a0381c9fb75c95df4cdb8307 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Tue, 27 May 2014 06:30:09 +0930 Subject: [PATCH] Fix to sdkLoc in build. Added light (without dark action bar) theme. NOTE: I don't know how android will go with adding a new property to a string-array resource, but not having it translated everywhere. Will it struggle because the EN version has three values for "theme", but other translations only have two? --- build.gradle | 17 ++++++++++++++++- res/values/array.xml | 1 + res/values/no_trans.xml | 1 + res/values/styles.xml | 10 +++++++++- src/org/fdroid/fdroid/FDroidApp.java | 5 ++++- 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index d8aebcd23..18ba173d6 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { apply plugin: 'android' def toolVersion = "19.1" -sdkLoc = android.plugin.sdkDirectory +sdkLoc = getSdkPath() FileCollection getAndroidPrebuilt(String apiLevel) { files("$sdkLoc/platforms/android-$apiLevel/android.jar") @@ -142,3 +142,18 @@ subprojects { } } } + +/** + * Currently a bit hacky, because android.plugin is protected. + * The end goal is to find something in the android BaseExtension class found here: + * https://android.googlesource.com/platform/tools/build/+/master/gradle/src/main/groovy/com/android/build/gradle/BaseExtension.groovy + * which ends up asking their Sdk class for it's location. That class knows about + * both ANDROID_HOME env variables, and also local.properties sdk.loc properties. + * + * If in the future, the android.adbExe is found to be inappropriate, deprecated, + * or a better way of finding the sdk path exists, we can change the implementation + * of this method to reflect that. + */ +def getSdkPath() { + new File( "$android.adbExe/../../" ).canonicalPath +} diff --git a/res/values/array.xml b/res/values/array.xml index bea7d606e..7aed61a82 100644 --- a/res/values/array.xml +++ b/res/values/array.xml @@ -11,5 +11,6 @@ Dark Light + Light (with dark action bar) diff --git a/res/values/no_trans.xml b/res/values/no_trans.xml index 102cdab50..0f8e66e48 100644 --- a/res/values/no_trans.xml +++ b/res/values/no_trans.xml @@ -25,6 +25,7 @@ dark light + lightWithDarkActionBar diff --git a/res/values/styles.xml b/res/values/styles.xml index 3bd939192..dfd911baa 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -4,7 +4,11 @@ - + + @@ -25,4 +29,8 @@ + + diff --git a/src/org/fdroid/fdroid/FDroidApp.java b/src/org/fdroid/fdroid/FDroidApp.java index d96a7e7c2..54111e958 100644 --- a/src/org/fdroid/fdroid/FDroidApp.java +++ b/src/org/fdroid/fdroid/FDroidApp.java @@ -76,7 +76,7 @@ public class FDroidApp extends Application { BluetoothAdapter bluetoothAdapter = null; private static enum Theme { - dark, light + dark, light, lightWithDarkActionBar } private static Theme curTheme = Theme.dark; @@ -95,6 +95,9 @@ public class FDroidApp extends Application { case light: activity.setTheme(R.style.AppThemeLight); break; + case lightWithDarkActionBar: + activity.setTheme(R.style.AppThemeLightWithDarkActionBar); + break; } }