summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormvglasow <michael -at- vonglasow.com>2016-01-18 13:52:45 +0100
committermvglasow <michael -at- vonglasow.com>2016-02-02 09:58:31 +0100
commit97e493aaacf25e4a56cb9c8dae8b4e90615ca2c9 (patch)
tree503723946781499f06cc63f06788cca0e1efe548
parentb5ae2a33d79db5e21f2b7007da03776a1084f2d5 (diff)
downloadnavit-97e493aaacf25e4a56cb9c8dae8b4e90615ca2c9.tar.gz
Add:port_android:Make system bars translucent on API 19+, transparent on API 21+
Signed-off-by: mvglasow <michael -at- vonglasow.com>
-rw-r--r--navit/android/AndroidManifest.xml.cmake5
-rw-r--r--navit/android/res/values-v19/styles.xml31
-rw-r--r--navit/android/res/values-v21/styles.xml31
-rw-r--r--navit/android/res/values/styles.xml11
-rw-r--r--navit/android/src/org/navitproject/navit/Navit.java10
5 files changed, 78 insertions, 10 deletions
diff --git a/navit/android/AndroidManifest.xml.cmake b/navit/android/AndroidManifest.xml.cmake
index 1734101f8..b5bd757cb 100644
--- a/navit/android/AndroidManifest.xml.cmake
+++ b/navit/android/AndroidManifest.xml.cmake
@@ -18,10 +18,11 @@
<application android:label="@string/app_name"
android:icon="@drawable/icon"
android:name=".NavitAppConfig"
- android:theme="@style/NavitTheme">
+ android:theme="@style/NavitBaseTheme">
<activity android:name="Navit"
android:label="@string/app_name"
- android:configChanges="locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|fontScale|screenSize">
+ android:configChanges="locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|fontScale|screenSize"
+ android:theme="@style/NavitTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
diff --git a/navit/android/res/values-v19/styles.xml b/navit/android/res/values-v19/styles.xml
new file mode 100644
index 000000000..b3ea5c14f
--- /dev/null
+++ b/navit/android/res/values-v19/styles.xml
@@ -0,0 +1,31 @@
+<resources>
+
+ <!--
+ Base application theme for API 19+. This theme completely replaces
+ NavitBaseTheme from BOTH res/values/styles.xml and
+ res/values-v19/styles.xml on API 19+ devices.
+ -->
+ <style name="NavitBaseTheme" parent="android:Theme.Holo">
+
+ <!-- Main theme colors -->
+ <!-- your app branding color for the app bar -->
+ <item name="android:colorPrimary">@color/navitYellow500</item>
+ <!-- darker variant for the status bar and contextual app bars -->
+ <item name="android:colorPrimaryDark">@color/navitYellow700</item>
+ <!-- theme UI controls like checkboxes and text fields -->
+ <item name="android:colorAccent">@color/navitBlue500</item>
+ </style>
+
+ <!--
+ Main Activity theme for API 19+. This theme completely replaces
+ NavitTheme from BOTH res/values/styles.xml and
+ res/values-v19/styles.xml on API 19+ devices.
+ -->
+ <style name="NavitTheme" parent="NavitBaseTheme">
+
+ <!-- API 19 theme customizations can go here. -->
+ <item name="android:windowTranslucentNavigation">true</item>
+ <item name="android:windowTranslucentStatus">true</item>
+ </style>
+
+</resources> \ No newline at end of file
diff --git a/navit/android/res/values-v21/styles.xml b/navit/android/res/values-v21/styles.xml
index 960f99faf..a1d66bb3d 100644
--- a/navit/android/res/values-v21/styles.xml
+++ b/navit/android/res/values-v21/styles.xml
@@ -2,13 +2,11 @@
<!--
Base application theme for API 21+. This theme completely replaces
- AppBaseTheme from BOTH res/values/styles.xml and
+ NavitBaseTheme from BOTH res/values/styles.xml and
res/values-v.../styles.xml on API 21+ devices.
-->
<style name="NavitBaseTheme" parent="android:Theme.Material">
- <!-- API 21 theme customizations can go here. -->
-
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/navitYellow500</item>
@@ -18,4 +16,31 @@
<item name="android:colorAccent">@color/navitBlue500</item>
</style>
+ <!--
+ Main Activity theme for API 21+. This theme completely replaces
+ NavitTheme from BOTH res/values/styles.xml and
+ res/values-v21/styles.xml on API 21+ devices.
+ -->
+ <style name="NavitTheme" parent="NavitBaseTheme">
+
+ <!-- API 21 theme customizations can go here. -->
+
+ <!--
+ Don't use translucent system bars on API 21 as they are drawn with a semitransparent
+ black background which can't be changed.
+ -->
+ <item name="android:windowTranslucentNavigation">false</item>
+ <item name="android:windowTranslucentStatus">false</item>
+
+ <!--
+ We could set any semi-transparent color here (or change it in code), but this would not
+ be available on API 19/20. Simply specifying full transparency allows us to implement a
+ separate mechanism that will work on all versions.
+ -->
+ <item name="android:navigationBarColor">@android:color/transparent</item>
+ <item name="android:statusBarColor">@android:color/transparent</item>
+
+ <item name="android:windowDrawsSystemBarBackgrounds">true</item>
+ </style>
+
</resources> \ No newline at end of file
diff --git a/navit/android/res/values/styles.xml b/navit/android/res/values/styles.xml
index 191fe509d..91094e222 100644
--- a/navit/android/res/values/styles.xml
+++ b/navit/android/res/values/styles.xml
@@ -2,7 +2,7 @@
<!--
Base application theme, dependent on API level. This theme is replaced
- by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ by NavitBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="NavitBaseTheme" parent="android:Theme.Holo">
<!--
@@ -12,7 +12,7 @@
-->
</style>
- <!-- Application theme. -->
+ <!-- Theme for Navit's main Activity. -->
<style name="NavitTheme" parent="NavitBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
@@ -22,20 +22,21 @@
Primary color is derived average of icon colors (500 in Android parlance):
213 164 19 #d5a411 hsl 45 92 84
- Primary color is normally the 600 color (i.e. slightly darker than 500)
+ Dark color is normally the 600 color (i.e. slightly darker than 500)
209 155 19 #d19b13 hsl 43 91 82
-->
+
<!-- Yellow from Navit icon background (300 and 700 are the extremes of the gradient, 500 is the average, 900 is the line color) -->
<color name="navitYellow300">#e9cb14</color>
<color name="navitYellow500">#d5a411</color>
<!-- <color name="navitYellow600">#d19b13</color> -->
<color name="navitYellow700">#c17d11</color>
<color name="navitYellow900">#43350f</color>
-
+
<!-- Blue from arrow in Navit icon (500 is the midpoint of the gradient, 300 is the end, 900 is the line color) -->
<color name="navitBlue300">#329eff</color>
<color name="navitBlue500">#1a6cb6</color>
<color name="navitBlue900">#1f3157</color>
-
+
</resources> \ No newline at end of file
diff --git a/navit/android/src/org/navitproject/navit/Navit.java b/navit/android/src/org/navitproject/navit/Navit.java
index f08de4e56..d33425a76 100644
--- a/navit/android/src/org/navitproject/navit/Navit.java
+++ b/navit/android/src/org/navitproject/navit/Navit.java
@@ -25,6 +25,9 @@ import java.io.InputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -63,6 +66,7 @@ import android.util.Log;
import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
@@ -387,6 +391,12 @@ public class Navit extends Activity
{
super.onResume();
Log.d("Navit", "OnResume");
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
+ /* Required to make system bars fully transparent */
+ getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
+ }
//InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// DEBUG
// intent_data = "google.navigation:q=Wien Burggasse 27";