diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
index 07a169bee6..b036ee2bb0 100644
--- a/android/AndroidManifest.xml
+++ b/android/AndroidManifest.xml
@@ -170,7 +170,7 @@
@@ -200,7 +200,7 @@
-
+ android:exported="false"/>
-
-
+
+
-
-
-
-
-
-
-
-
diff --git a/android/build.gradle b/android/build.gradle
index 43c953f8de..70e05e3613 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -62,6 +62,7 @@ android {
buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"'
buildConfigField 'String', 'REVIEW_URL', '"market://details?id=com.mapswithme.maps.pro"'
buildConfigField 'int', 'RATING_THRESHOLD', '5'
+ buildConfigField 'boolean', 'ALLOW_PREF_MAP_STYLE', 'false'
}
sourceSets.main {
@@ -224,6 +225,7 @@ android {
zipAlignEnabled true
signingConfig signingConfigs.mapswithmeDebug
android.sourceSets.debug.setRoot('flavors/debug')
+ buildConfigField 'boolean', 'ALLOW_PREF_MAP_STYLE', 'true'
}
release {
@@ -238,6 +240,7 @@ android {
versionNameSuffix '-beta'
signingConfig signingConfigs.mapswithme
android.sourceSets.beta.setRoot('flavors/beta')
+ buildConfigField 'boolean', 'ALLOW_PREF_MAP_STYLE', 'true'
}
}
diff --git a/android/jni/Android.mk b/android/jni/Android.mk
index b14fc439f0..67ec496d72 100644
--- a/android/jni/Android.mk
+++ b/android/jni/Android.mk
@@ -98,7 +98,8 @@ LOCAL_SRC_FILES := \
com/mapswithme/platform/HttpThread.cpp \
com/mapswithme/platform/Language.cpp \
com/mapswithme/platform/PThreadImpl.cpp \
- com/mapswithme/utils/StringUtils.cpp \
+ com/mapswithme/util/StringUtils.cpp \
+ com/mapswithme/util/Config.cpp \
nv_thread/nv_thread.cpp \
nv_event/nv_event_queue.cpp \
nv_event/nv_event.cpp \
diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp
index c9cc7c2601..162084f5df 100644
--- a/android/jni/com/mapswithme/maps/Framework.cpp
+++ b/android/jni/com/mapswithme/maps/Framework.cpp
@@ -235,6 +235,11 @@ namespace android
}
}
+ MapStyle Framework::GetMapStyle() const
+ {
+ return m_work.GetMapStyle();
+ }
+
Storage & Framework::Storage()
{
return m_work.Storage();
@@ -1459,6 +1464,12 @@ extern "C"
android::Platform::RunOnGuiThreadImpl(bind(&android::Framework::SetMapStyle, g_framework, val));
}
+ JNIEXPORT jint JNICALL
+ Java_com_mapswithme_maps_Framework_getMapStyle(JNIEnv * env, jclass thiz)
+ {
+ return static_cast(g_framework->GetMapStyle());
+ }
+
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_Framework_setRouter(JNIEnv * env, jclass thiz, jint routerType)
{
diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp
index 548176d25a..493b39bf6d 100644
--- a/android/jni/com/mapswithme/maps/Framework.hpp
+++ b/android/jni/com/mapswithme/maps/Framework.hpp
@@ -103,6 +103,7 @@ namespace android
void DeleteRenderPolicy();
void SetMapStyle(MapStyle mapStyle);
+ MapStyle GetMapStyle() const;
void SetRouter(routing::RouterType type) { m_work.SetRouter(type); }
routing::RouterType GetRouter() const { return m_work.GetRouter(); }
diff --git a/android/jni/com/mapswithme/maps/MwmApplication.cpp b/android/jni/com/mapswithme/maps/MwmApplication.cpp
index 42f91ad9d3..f3de753999 100644
--- a/android/jni/com/mapswithme/maps/MwmApplication.cpp
+++ b/android/jni/com/mapswithme/maps/MwmApplication.cpp
@@ -7,8 +7,6 @@
#include "map/information_display.hpp"
#include "map/location_state.hpp"
-#include "platform/settings.hpp"
-
extern "C"
{
@@ -35,27 +33,6 @@ extern "C"
return static_cast(g_framework->NativeFramework()->IsBenchmarking());
}
- JNIEXPORT jboolean JNICALL
- Java_com_mapswithme_maps_MwmApplication_nativeGetBoolean(JNIEnv * env,
- jobject thiz,
- jstring name,
- jboolean defaultVal)
- {
- bool val = defaultVal;
- Settings::Get(jni::ToNativeString(env, name), val);
- return val;
- }
-
- JNIEXPORT void JNICALL
- Java_com_mapswithme_maps_MwmApplication_nativeSetBoolean(JNIEnv * env,
- jobject thiz,
- jstring name,
- jboolean val)
- {
- bool flag = val;
- (void)Settings::Set(jni::ToNativeString(env, name), flag);
- }
-
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_MwmApplication_hasFreeSpace(JNIEnv * env, jobject thiz, jlong size)
{
@@ -68,68 +45,4 @@ extern "C"
g_framework->AddString(jni::ToNativeString(env, name),
jni::ToNativeString(env, value));
}
-
- JNIEXPORT jint JNICALL
- Java_com_mapswithme_maps_MwmApplication_nativeGetInt(JNIEnv * env, jobject thiz, jstring name, jint defaultValue)
- {
- jint value;
- if (Settings::Get(jni::ToNativeString(env, name), value))
- return value;
-
- return defaultValue;
- }
-
- JNIEXPORT void JNICALL
- Java_com_mapswithme_maps_MwmApplication_nativeSetInt(JNIEnv * env, jobject thiz, jstring name, jint value)
- {
- (void)Settings::Set(jni::ToNativeString(env, name), value);
- }
-
- JNIEXPORT jlong JNICALL
- Java_com_mapswithme_maps_MwmApplication_nativeGetLong(JNIEnv * env, jobject thiz, jstring name, jlong defaultValue)
- {
- jlong value;
- if (Settings::Get(jni::ToNativeString(env, name), value))
- return value;
-
- return defaultValue;
- }
-
- JNIEXPORT void JNICALL
- Java_com_mapswithme_maps_MwmApplication_nativeSetLong(JNIEnv * env, jobject thiz, jstring name, jlong value)
- {
- (void)Settings::Set(jni::ToNativeString(env, name), value);
- }
-
- JNIEXPORT jdouble JNICALL
- Java_com_mapswithme_maps_MwmApplication_nativeGetDouble(JNIEnv * env, jobject thiz, jstring name, jdouble defaultValue)
- {
- jdouble value;
- if (Settings::Get(jni::ToNativeString(env, name), value))
- return value;
-
- return defaultValue;
- }
-
- JNIEXPORT void JNICALL
- Java_com_mapswithme_maps_MwmApplication_nativeSetDouble(JNIEnv * env, jobject thiz, jstring name, jdouble value)
- {
- (void)Settings::Set(jni::ToNativeString(env, name), value);
- }
-
- JNIEXPORT void JNICALL
- Java_com_mapswithme_maps_MwmApplication_nativeSetString(JNIEnv * env, jobject thiz, jstring name, jstring value)
- {
- (void)Settings::Set(jni::ToNativeString(env, name), jni::ToNativeString(env, value));
- }
-
- JNIEXPORT jstring JNICALL
- Java_com_mapswithme_maps_MwmApplication_nativeGetString(JNIEnv * env, jobject thiz, jstring name, jstring defaultValue)
- {
- string value;
- if (Settings::Get(jni::ToNativeString(env, name), value))
- return jni::ToJavaString(env, value);
-
- return defaultValue;
- }
}
diff --git a/android/jni/com/mapswithme/util/Config.cpp b/android/jni/com/mapswithme/util/Config.cpp
new file mode 100644
index 0000000000..88937c0665
--- /dev/null
+++ b/android/jni/com/mapswithme/util/Config.cpp
@@ -0,0 +1,85 @@
+#include "../core/jni_helper.hpp"
+#include "platform/settings.hpp"
+
+
+extern "C"
+{
+ JNIEXPORT jboolean JNICALL
+ Java_com_mapswithme_util_Config_nativeGetBoolean(JNIEnv * env, jclass thiz, jstring name, jboolean defaultVal)
+ {
+ bool val = defaultVal;
+ Settings::Get(jni::ToNativeString(env, name), val);
+ return val;
+ }
+
+ JNIEXPORT void JNICALL
+ Java_com_mapswithme_util_Config_nativeSetBoolean(JNIEnv * env, jclass thiz, jstring name, jboolean val)
+ {
+ bool flag = val;
+ (void)Settings::Set(jni::ToNativeString(env, name), flag);
+ }
+
+ JNIEXPORT jint JNICALL
+ Java_com_mapswithme_util_Config_nativeGetInt(JNIEnv * env, jclass thiz, jstring name, jint defaultValue)
+ {
+ jint value;
+ if (Settings::Get(jni::ToNativeString(env, name), value))
+ return value;
+
+ return defaultValue;
+ }
+
+ JNIEXPORT void JNICALL
+ Java_com_mapswithme_util_Config_nativeSetInt(JNIEnv * env, jclass thiz, jstring name, jint value)
+ {
+ (void)Settings::Set(jni::ToNativeString(env, name), value);
+ }
+
+ JNIEXPORT jlong JNICALL
+ Java_com_mapswithme_util_Config_nativeGetLong(JNIEnv * env, jclass thiz, jstring name, jlong defaultValue)
+ {
+ jlong value;
+ if (Settings::Get(jni::ToNativeString(env, name), value))
+ return value;
+
+ return defaultValue;
+ }
+
+ JNIEXPORT void JNICALL
+ Java_com_mapswithme_util_Config_nativeSetLong(JNIEnv * env, jclass thiz, jstring name, jlong value)
+ {
+ (void)Settings::Set(jni::ToNativeString(env, name), value);
+ }
+
+ JNIEXPORT jdouble JNICALL
+ Java_com_mapswithme_util_Config_nativeGetDouble(JNIEnv * env, jclass thiz, jstring name, jdouble defaultValue)
+ {
+ jdouble value;
+ if (Settings::Get(jni::ToNativeString(env, name), value))
+ return value;
+
+ return defaultValue;
+ }
+
+ JNIEXPORT void JNICALL
+ Java_com_mapswithme_util_Config_nativeSetDouble(JNIEnv * env, jclass thiz, jstring name, jdouble value)
+ {
+ (void)Settings::Set(jni::ToNativeString(env, name), value);
+ }
+
+ JNIEXPORT void JNICALL
+ Java_com_mapswithme_util_Config_nativeSetString(JNIEnv * env, jclass thiz, jstring name, jstring value)
+ {
+ (void)Settings::Set(jni::ToNativeString(env, name), jni::ToNativeString(env, value));
+ }
+
+ JNIEXPORT jstring JNICALL
+ Java_com_mapswithme_util_Config_nativeGetString(JNIEnv * env, jclass thiz, jstring name, jstring defaultValue)
+ {
+ string value;
+ if (Settings::Get(jni::ToNativeString(env, name), value))
+ return jni::ToJavaString(env, value);
+
+ return defaultValue;
+ }
+} // extern "C"
diff --git a/android/jni/com/mapswithme/utils/StringUtils.cpp b/android/jni/com/mapswithme/util/StringUtils.cpp
similarity index 100%
rename from android/jni/com/mapswithme/utils/StringUtils.cpp
rename to android/jni/com/mapswithme/util/StringUtils.cpp
diff --git a/android/res/drawable-hdpi/about_logo.png b/android/res/drawable-hdpi/about_logo.png
new file mode 100644
index 0000000000..3a1bc1ebcf
Binary files /dev/null and b/android/res/drawable-hdpi/about_logo.png differ
diff --git a/android/res/drawable-hdpi/ic_blog.png b/android/res/drawable-hdpi/ic_blog.png
new file mode 100644
index 0000000000..a6f2e167e9
Binary files /dev/null and b/android/res/drawable-hdpi/ic_blog.png differ
diff --git a/android/res/drawable-hdpi/ic_facebook.png b/android/res/drawable-hdpi/ic_facebook.png
index 056b37407a..39f95cd486 100644
Binary files a/android/res/drawable-hdpi/ic_facebook.png and b/android/res/drawable-hdpi/ic_facebook.png differ
diff --git a/android/res/drawable-hdpi/ic_help.png b/android/res/drawable-hdpi/ic_help.png
deleted file mode 100644
index d145a0e304..0000000000
Binary files a/android/res/drawable-hdpi/ic_help.png and /dev/null differ
diff --git a/android/res/drawable-hdpi/ic_rate.png b/android/res/drawable-hdpi/ic_rate.png
index 62f41b3b4a..72ca38aeed 100644
Binary files a/android/res/drawable-hdpi/ic_rate.png and b/android/res/drawable-hdpi/ic_rate.png differ
diff --git a/android/res/drawable-hdpi/ic_report_a_bug.png b/android/res/drawable-hdpi/ic_report_a_bug.png
deleted file mode 100644
index 8e9f69a435..0000000000
Binary files a/android/res/drawable-hdpi/ic_report_a_bug.png and /dev/null differ
diff --git a/android/res/drawable-hdpi/ic_social.png b/android/res/drawable-hdpi/ic_social.png
deleted file mode 100644
index 7c3d804955..0000000000
Binary files a/android/res/drawable-hdpi/ic_social.png and /dev/null differ
diff --git a/android/res/drawable-hdpi/ic_subscribe.png b/android/res/drawable-hdpi/ic_subscribe.png
index e7fe1448cb..883519cbdb 100644
Binary files a/android/res/drawable-hdpi/ic_subscribe.png and b/android/res/drawable-hdpi/ic_subscribe.png differ
diff --git a/android/res/drawable-hdpi/ic_twitter.png b/android/res/drawable-hdpi/ic_twitter.png
index 89c8d95eed..63ece531ad 100644
Binary files a/android/res/drawable-hdpi/ic_twitter.png and b/android/res/drawable-hdpi/ic_twitter.png differ
diff --git a/android/res/drawable-hdpi/ic_website.png b/android/res/drawable-hdpi/ic_website.png
new file mode 100644
index 0000000000..48a0f48785
Binary files /dev/null and b/android/res/drawable-hdpi/ic_website.png differ
diff --git a/android/res/drawable-ldpi/ic_help.png b/android/res/drawable-ldpi/ic_help.png
deleted file mode 100644
index 840f5be847..0000000000
Binary files a/android/res/drawable-ldpi/ic_help.png and /dev/null differ
diff --git a/android/res/drawable-ldpi/ic_rate.png b/android/res/drawable-ldpi/ic_rate.png
deleted file mode 100644
index 1ae90f2bec..0000000000
Binary files a/android/res/drawable-ldpi/ic_rate.png and /dev/null differ
diff --git a/android/res/drawable-ldpi/ic_report_a_bug.png b/android/res/drawable-ldpi/ic_report_a_bug.png
deleted file mode 100644
index 93ab3b1bc3..0000000000
Binary files a/android/res/drawable-ldpi/ic_report_a_bug.png and /dev/null differ
diff --git a/android/res/drawable-ldpi/ic_social.png b/android/res/drawable-ldpi/ic_social.png
deleted file mode 100644
index 06b4ceac95..0000000000
Binary files a/android/res/drawable-ldpi/ic_social.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/about_logo.png b/android/res/drawable-mdpi/about_logo.png
new file mode 100644
index 0000000000..c8c94a3d86
Binary files /dev/null and b/android/res/drawable-mdpi/about_logo.png differ
diff --git a/android/res/drawable-mdpi/ic_blog.png b/android/res/drawable-mdpi/ic_blog.png
new file mode 100644
index 0000000000..fb744a3685
Binary files /dev/null and b/android/res/drawable-mdpi/ic_blog.png differ
diff --git a/android/res/drawable-mdpi/ic_facebook.png b/android/res/drawable-mdpi/ic_facebook.png
index 2e19123e5f..01280a7773 100644
Binary files a/android/res/drawable-mdpi/ic_facebook.png and b/android/res/drawable-mdpi/ic_facebook.png differ
diff --git a/android/res/drawable-mdpi/ic_help.png b/android/res/drawable-mdpi/ic_help.png
deleted file mode 100644
index f2a731aeb2..0000000000
Binary files a/android/res/drawable-mdpi/ic_help.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/ic_rate.png b/android/res/drawable-mdpi/ic_rate.png
index 27a6941df6..3706ca93e7 100644
Binary files a/android/res/drawable-mdpi/ic_rate.png and b/android/res/drawable-mdpi/ic_rate.png differ
diff --git a/android/res/drawable-mdpi/ic_report_a_bug.png b/android/res/drawable-mdpi/ic_report_a_bug.png
deleted file mode 100644
index 719997f200..0000000000
Binary files a/android/res/drawable-mdpi/ic_report_a_bug.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/ic_social.png b/android/res/drawable-mdpi/ic_social.png
deleted file mode 100644
index e80eb29217..0000000000
Binary files a/android/res/drawable-mdpi/ic_social.png and /dev/null differ
diff --git a/android/res/drawable-mdpi/ic_subscribe.png b/android/res/drawable-mdpi/ic_subscribe.png
index c5f0b5592f..a2a27ff3d7 100644
Binary files a/android/res/drawable-mdpi/ic_subscribe.png and b/android/res/drawable-mdpi/ic_subscribe.png differ
diff --git a/android/res/drawable-mdpi/ic_twitter.png b/android/res/drawable-mdpi/ic_twitter.png
index 2718f04521..6ceed230ec 100644
Binary files a/android/res/drawable-mdpi/ic_twitter.png and b/android/res/drawable-mdpi/ic_twitter.png differ
diff --git a/android/res/drawable-mdpi/ic_website.png b/android/res/drawable-mdpi/ic_website.png
new file mode 100644
index 0000000000..b3d0febf27
Binary files /dev/null and b/android/res/drawable-mdpi/ic_website.png differ
diff --git a/android/res/drawable-xhdpi/about_logo.png b/android/res/drawable-xhdpi/about_logo.png
new file mode 100644
index 0000000000..60597a7644
Binary files /dev/null and b/android/res/drawable-xhdpi/about_logo.png differ
diff --git a/android/res/drawable-xhdpi/ic_blog.png b/android/res/drawable-xhdpi/ic_blog.png
new file mode 100644
index 0000000000..c46dd0ac3c
Binary files /dev/null and b/android/res/drawable-xhdpi/ic_blog.png differ
diff --git a/android/res/drawable-xhdpi/ic_facebook.png b/android/res/drawable-xhdpi/ic_facebook.png
index f25ed61b08..e11ca3c64a 100644
Binary files a/android/res/drawable-xhdpi/ic_facebook.png and b/android/res/drawable-xhdpi/ic_facebook.png differ
diff --git a/android/res/drawable-xhdpi/ic_help.png b/android/res/drawable-xhdpi/ic_help.png
deleted file mode 100644
index 0574daa091..0000000000
Binary files a/android/res/drawable-xhdpi/ic_help.png and /dev/null differ
diff --git a/android/res/drawable-xhdpi/ic_rate.png b/android/res/drawable-xhdpi/ic_rate.png
index 0fe69ec278..c6a897445d 100644
Binary files a/android/res/drawable-xhdpi/ic_rate.png and b/android/res/drawable-xhdpi/ic_rate.png differ
diff --git a/android/res/drawable-xhdpi/ic_report_a_bug.png b/android/res/drawable-xhdpi/ic_report_a_bug.png
deleted file mode 100644
index 2123bef772..0000000000
Binary files a/android/res/drawable-xhdpi/ic_report_a_bug.png and /dev/null differ
diff --git a/android/res/drawable-xhdpi/ic_social.png b/android/res/drawable-xhdpi/ic_social.png
deleted file mode 100644
index 84ecf1a737..0000000000
Binary files a/android/res/drawable-xhdpi/ic_social.png and /dev/null differ
diff --git a/android/res/drawable-xhdpi/ic_subscribe.png b/android/res/drawable-xhdpi/ic_subscribe.png
index 42e5f4368a..007fbdfd55 100644
Binary files a/android/res/drawable-xhdpi/ic_subscribe.png and b/android/res/drawable-xhdpi/ic_subscribe.png differ
diff --git a/android/res/drawable-xhdpi/ic_twitter.png b/android/res/drawable-xhdpi/ic_twitter.png
index 6ea54534cb..c1caa35c60 100644
Binary files a/android/res/drawable-xhdpi/ic_twitter.png and b/android/res/drawable-xhdpi/ic_twitter.png differ
diff --git a/android/res/drawable-xhdpi/ic_website.png b/android/res/drawable-xhdpi/ic_website.png
new file mode 100644
index 0000000000..529563456e
Binary files /dev/null and b/android/res/drawable-xhdpi/ic_website.png differ
diff --git a/android/res/drawable-xxhdpi/about_logo.png b/android/res/drawable-xxhdpi/about_logo.png
new file mode 100644
index 0000000000..62b00bf5a5
Binary files /dev/null and b/android/res/drawable-xxhdpi/about_logo.png differ
diff --git a/android/res/drawable-xxhdpi/ic_blog.png b/android/res/drawable-xxhdpi/ic_blog.png
new file mode 100644
index 0000000000..c2d46d64e4
Binary files /dev/null and b/android/res/drawable-xxhdpi/ic_blog.png differ
diff --git a/android/res/drawable-xxhdpi/ic_facebook.png b/android/res/drawable-xxhdpi/ic_facebook.png
index 32fa0a9c99..cf3b4681bc 100644
Binary files a/android/res/drawable-xxhdpi/ic_facebook.png and b/android/res/drawable-xxhdpi/ic_facebook.png differ
diff --git a/android/res/drawable-xxhdpi/ic_help.png b/android/res/drawable-xxhdpi/ic_help.png
deleted file mode 100644
index 9ea29fa43f..0000000000
Binary files a/android/res/drawable-xxhdpi/ic_help.png and /dev/null differ
diff --git a/android/res/drawable-xxhdpi/ic_rate.png b/android/res/drawable-xxhdpi/ic_rate.png
index 5859de60c0..c605bfbb74 100644
Binary files a/android/res/drawable-xxhdpi/ic_rate.png and b/android/res/drawable-xxhdpi/ic_rate.png differ
diff --git a/android/res/drawable-xxhdpi/ic_report_a_bug.png b/android/res/drawable-xxhdpi/ic_report_a_bug.png
deleted file mode 100644
index cc033255d5..0000000000
Binary files a/android/res/drawable-xxhdpi/ic_report_a_bug.png and /dev/null differ
diff --git a/android/res/drawable-xxhdpi/ic_social.png b/android/res/drawable-xxhdpi/ic_social.png
deleted file mode 100644
index 45718f9516..0000000000
Binary files a/android/res/drawable-xxhdpi/ic_social.png and /dev/null differ
diff --git a/android/res/drawable-xxhdpi/ic_subscribe.png b/android/res/drawable-xxhdpi/ic_subscribe.png
index 8ed7536c5e..adbeb2d5c1 100644
Binary files a/android/res/drawable-xxhdpi/ic_subscribe.png and b/android/res/drawable-xxhdpi/ic_subscribe.png differ
diff --git a/android/res/drawable-xxhdpi/ic_twitter.png b/android/res/drawable-xxhdpi/ic_twitter.png
index 4e8d4dca84..2e150b1f4b 100644
Binary files a/android/res/drawable-xxhdpi/ic_twitter.png and b/android/res/drawable-xxhdpi/ic_twitter.png differ
diff --git a/android/res/drawable-xxhdpi/ic_website.png b/android/res/drawable-xxhdpi/ic_website.png
new file mode 100644
index 0000000000..1a97620f44
Binary files /dev/null and b/android/res/drawable-xxhdpi/ic_website.png differ
diff --git a/android/res/drawable-xxxhdpi/about_logo.png b/android/res/drawable-xxxhdpi/about_logo.png
new file mode 100644
index 0000000000..2819441c55
Binary files /dev/null and b/android/res/drawable-xxxhdpi/about_logo.png differ
diff --git a/android/res/drawable-xxxhdpi/ic_blog.png b/android/res/drawable-xxxhdpi/ic_blog.png
new file mode 100644
index 0000000000..82040ab6ed
Binary files /dev/null and b/android/res/drawable-xxxhdpi/ic_blog.png differ
diff --git a/android/res/drawable-xxxhdpi/ic_facebook.png b/android/res/drawable-xxxhdpi/ic_facebook.png
new file mode 100644
index 0000000000..a199628956
Binary files /dev/null and b/android/res/drawable-xxxhdpi/ic_facebook.png differ
diff --git a/android/res/drawable-xxxhdpi/ic_rate.png b/android/res/drawable-xxxhdpi/ic_rate.png
new file mode 100644
index 0000000000..31fe2e5702
Binary files /dev/null and b/android/res/drawable-xxxhdpi/ic_rate.png differ
diff --git a/android/res/drawable-xxxhdpi/ic_subscribe.png b/android/res/drawable-xxxhdpi/ic_subscribe.png
new file mode 100644
index 0000000000..3d23223375
Binary files /dev/null and b/android/res/drawable-xxxhdpi/ic_subscribe.png differ
diff --git a/android/res/drawable-xxxhdpi/ic_twitter.png b/android/res/drawable-xxxhdpi/ic_twitter.png
new file mode 100644
index 0000000000..947c337ab0
Binary files /dev/null and b/android/res/drawable-xxxhdpi/ic_twitter.png differ
diff --git a/android/res/drawable-xxxhdpi/ic_website.png b/android/res/drawable-xxxhdpi/ic_website.png
new file mode 100644
index 0000000000..1db8f57913
Binary files /dev/null and b/android/res/drawable-xxxhdpi/ic_website.png differ
diff --git a/android/res/layout-w600dp-port/place_page_details.xml b/android/res/layout-w600dp-port/place_page_details.xml
index e8e544b46c..ea88fa7fc0 100644
--- a/android/res/layout-w600dp-port/place_page_details.xml
+++ b/android/res/layout-w600dp-port/place_page_details.xml
@@ -87,8 +87,5 @@
-
+
\ No newline at end of file
diff --git a/android/res/layout/about.xml b/android/res/layout/about.xml
new file mode 100644
index 0000000000..c54c8f9429
--- /dev/null
+++ b/android/res/layout/about.xml
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/res/layout/activity_fragment_and_toolbar.xml b/android/res/layout/activity_fragment_and_toolbar.xml
index 5df16b93e9..afab22a373 100644
--- a/android/res/layout/activity_fragment_and_toolbar.xml
+++ b/android/res/layout/activity_fragment_and_toolbar.xml
@@ -11,6 +11,6 @@
android:id="@+id/fragment_container"
style="@style/MwmWidget.FrameLayout.Elevation"
android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
+ android:layout_height="match_parent"/>
\ No newline at end of file
diff --git a/android/res/layout/dialog_about.xml b/android/res/layout/dialog_about.xml
deleted file mode 100644
index e2cc0f3b98..0000000000
--- a/android/res/layout/dialog_about.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
diff --git a/android/res/layout/fragment_prefs_copyright.xml b/android/res/layout/fragment_prefs_copyright.xml
new file mode 100644
index 0000000000..7cdc504fbe
--- /dev/null
+++ b/android/res/layout/fragment_prefs_copyright.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
diff --git a/android/res/layout/fragment_prefs_help.xml b/android/res/layout/fragment_prefs_help.xml
new file mode 100644
index 0000000000..df40755cb7
--- /dev/null
+++ b/android/res/layout/fragment_prefs_help.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/res/layout/item_storage.xml b/android/res/layout/item_storage.xml
index 22869604d0..30ee480ef5 100644
--- a/android/res/layout/item_storage.xml
+++ b/android/res/layout/item_storage.xml
@@ -1,12 +1,6 @@
diff --git a/android/res/layout/item_storage_title.xml b/android/res/layout/item_storage_title.xml
index 8d7e08d612..8d27e7d107 100644
--- a/android/res/layout/item_storage_title.xml
+++ b/android/res/layout/item_storage_title.xml
@@ -1,11 +1,3 @@
-
+
diff --git a/android/res/layout/place_page_details.xml b/android/res/layout/place_page_details.xml
index 7edb66a64b..61fe73d053 100644
--- a/android/res/layout/place_page_details.xml
+++ b/android/res/layout/place_page_details.xml
@@ -53,8 +53,5 @@
-
+
diff --git a/android/res/layout/shadow_bottom.xml b/android/res/layout/shadow_bottom.xml
index f33c9c0012..bae1ae3b04 100644
--- a/android/res/layout/shadow_bottom.xml
+++ b/android/res/layout/shadow_bottom.xml
@@ -4,6 +4,7 @@
android:id="@+id/shadow_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
android:src="@drawable/shadow_bottom"
android:scaleType="fitXY"
android:visibility="gone"
diff --git a/android/res/layout/toolbar_default.xml b/android/res/layout/toolbar_default.xml
index 198828d961..89a92e06d3 100644
--- a/android/res/layout/toolbar_default.xml
+++ b/android/res/layout/toolbar_default.xml
@@ -1,8 +1,8 @@
\ No newline at end of file
diff --git a/android/res/layout/toolbar_elevated.xml b/android/res/layout/toolbar_elevated.xml
index 730027dba1..a1a47ad9ea 100644
--- a/android/res/layout/toolbar_elevated.xml
+++ b/android/res/layout/toolbar_elevated.xml
@@ -3,7 +3,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
-
diff --git a/android/res/values-v12/version-checks.xml b/android/res/values-v12/version-checks.xml
deleted file mode 100644
index 8d8db2740f..0000000000
--- a/android/res/values-v12/version-checks.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- true
- false
-
\ No newline at end of file
diff --git a/android/res/values-v21/styles.xml b/android/res/values-v21/styles.xml
deleted file mode 100644
index fc909f703e..0000000000
--- a/android/res/values-v21/styles.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/values/donottranslate.xml b/android/res/values/donottranslate.xml
index 313b154f5b..6a24024b4f 100644
--- a/android/res/values/donottranslate.xml
+++ b/android/res/values/donottranslate.xml
@@ -5,6 +5,10 @@
185237551520383
+
+ Facebook
+ Twitter
+
sans-serif-light
sans-serif
@@ -15,11 +19,11 @@
sans-serif-medium
- AllowStat
+ AllowStat
MeasurementUnits
- StorageActivity
+ Storage
Yota
- ZoomButtonsEnabled
+ ZoomButtonsEnabled
PlayServicesEnabled
AboutMapsWithMe
RateApp
@@ -33,6 +37,7 @@
Subscribe
Settings
MapsMePrefs
+ MapStyle
%1$s: %2$s
%2$s :%1$s
diff --git a/android/res/values/string-arrays.xml b/android/res/values/string-arrays.xml
index 6801ce5abd..9abcb1c00e 100644
--- a/android/res/values/string-arrays.xml
+++ b/android/res/values/string-arrays.xml
@@ -1,13 +1,26 @@
-
- @string/kilometres
- @string/miles
-
+
+
- 0
- 1
+
+ - @string/pref_map_style_classic_light
+ - @string/pref_map_style_classic_dark
+ - @string/pref_map_style_modern_light
+
+
+
+ - 0
+ - 1
+ - 2
+
\ No newline at end of file
diff --git a/android/res/values/styles-text.xml b/android/res/values/styles-text.xml
new file mode 100644
index 0000000000..0907292b49
--- /dev/null
+++ b/android/res/values/styles-text.xml
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/res/values/styles.xml b/android/res/values/styles.xml
index 16d969801b..6453cc1793 100644
--- a/android/res/values/styles.xml
+++ b/android/res/values/styles.xml
@@ -1,29 +1,10 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -110,7 +28,9 @@
- @drawable/ripple_blue
-
+
+
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/android/res/values/themes.xml b/android/res/values/themes.xml
new file mode 100644
index 0000000000..17b84cc0cd
--- /dev/null
+++ b/android/res/values/themes.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/res/values/version-checks.xml b/android/res/values/version-checks.xml
deleted file mode 100644
index 75c5263dcb..0000000000
--- a/android/res/values/version-checks.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- false
- true
-
\ No newline at end of file
diff --git a/android/res/xml/preferences.xml b/android/res/xml/preferences.xml
deleted file mode 100644
index 84c6f82b16..0000000000
--- a/android/res/xml/preferences.xml
+++ /dev/null
@@ -1,134 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/res/xml/prefs_headers.xml b/android/res/xml/prefs_headers.xml
new file mode 100644
index 0000000000..bbb02672c6
--- /dev/null
+++ b/android/res/xml/prefs_headers.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/res/xml/prefs_map.xml b/android/res/xml/prefs_map.xml
new file mode 100644
index 0000000000..232d1edce7
--- /dev/null
+++ b/android/res/xml/prefs_map.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/res/xml/prefs_misc.xml b/android/res/xml/prefs_misc.xml
new file mode 100644
index 0000000000..b99596872d
--- /dev/null
+++ b/android/res/xml/prefs_misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java
index 6ec47c89ba..726d606824 100644
--- a/android/src/com/mapswithme/maps/Framework.java
+++ b/android/src/com/mapswithme/maps/Framework.java
@@ -171,6 +171,8 @@ public class Framework
public native static void setMapStyle(int mapStyle);
+ public native static int getMapStyle();
+
public native static void setRouter(int routerType);
public native static int getRouter();
diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java
index c528702666..bb8607bf7e 100644
--- a/android/src/com/mapswithme/maps/MwmActivity.java
+++ b/android/src/com/mapswithme/maps/MwmActivity.java
@@ -776,7 +776,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
private void adjustZoomButtons(boolean routingActive)
{
- boolean show = (routingActive || MwmApplication.get().nativeGetBoolean(SettingsActivity.ZOOM_BUTTON_ENABLED, true));
+ boolean show = (routingActive || Config.getShowZoomButtons());
UiUtils.showIf(show, mBtnZoomIn, mBtnZoomOut);
if (!show)
diff --git a/android/src/com/mapswithme/maps/MwmApplication.java b/android/src/com/mapswithme/maps/MwmApplication.java
index df5f148a49..52dfc07e8a 100644
--- a/android/src/com/mapswithme/maps/MwmApplication.java
+++ b/android/src/com/mapswithme/maps/MwmApplication.java
@@ -4,16 +4,14 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Environment;
import android.preference.PreferenceManager;
-import android.text.TextUtils;
-import android.text.format.DateUtils;
import android.util.Log;
import com.google.gson.Gson;
import com.mapswithme.country.ActiveCountryTree;
import com.mapswithme.country.CountryItem;
-import com.mapswithme.maps.ads.LikesManager;
import com.mapswithme.maps.background.Notifier;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
+import com.mapswithme.util.Config;
import com.mapswithme.util.Constants;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Yota;
@@ -29,11 +27,7 @@ import java.io.File;
public class MwmApplication extends android.app.Application implements ActiveCountryTree.ActiveCountryListener
{
private final static String TAG = "MwmApplication";
- private static final String LAUNCH_NUMBER_SETTING = "LaunchNumber"; // total number of app launches
- private static final String SESSION_NUMBER_SETTING = "SessionNumber"; // session = number of days, when app was launched
- private static final String LAST_SESSION_TIMESTAMP_SETTING = "LastSessionTimestamp"; // timestamp of last session
- private static final String FIRST_INSTALL_VERSION = "FirstInstallVersion";
- private static final String FIRST_INSTALL_FLAVOR = "FirstInstallFlavor";
+
// Parse
private static final String PREF_PARSE_DEVICE_TOKEN = "ParseDeviceToken";
private static final String PREF_PARSE_INSTALLATION_ID = "ParseInstallationId";
@@ -196,27 +190,6 @@ public class MwmApplication extends android.app.Application implements ActiveCou
private native void nativeAddLocalization(String name, String value);
- // Dealing with Settings
- public native boolean nativeGetBoolean(String name, boolean defaultValue);
-
- public native void nativeSetBoolean(String name, boolean value);
-
- public native int nativeGetInt(String name, int defaultValue);
-
- public native void nativeSetInt(String name, int value);
-
- public native long nativeGetLong(String name, long defaultValue);
-
- public native void nativeSetLong(String name, long value);
-
- public native double nativeGetDouble(String name, double defaultValue);
-
- public native void nativeSetDouble(String name, double value);
-
- public native String nativeGetString(String name, String defaultValue);
-
- public native void nativeSetString(String name, String value);
-
/**
* Check if device have at least {@code size} bytes free.
*/
@@ -256,74 +229,13 @@ public class MwmApplication extends android.app.Application implements ActiveCou
if (!mAreCountersInitialised)
{
mAreCountersInitialised = true;
- updateLaunchNumbers();
- updateSessionsNumber();
- PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
+ Config.updateLaunchCounter();
+ PreferenceManager.setDefaultValues(this, R.xml.prefs_misc, false);
}
}
public void onUpgrade()
{
- nativeSetInt(LAUNCH_NUMBER_SETTING, 0);
- nativeSetInt(SESSION_NUMBER_SETTING, 0);
- nativeSetLong(LAST_SESSION_TIMESTAMP_SETTING, 0);
- nativeSetInt(LikesManager.LAST_RATED_SESSION, 0);
- updateSessionsNumber();
- }
-
- private void updateLaunchNumbers()
- {
- final int currentLaunches = nativeGetInt(LAUNCH_NUMBER_SETTING, 0);
- if (currentLaunches == 0)
- {
- final int installedVersion = getFirstInstallVersion();
- if (installedVersion == 0)
- nativeSetInt(FIRST_INSTALL_VERSION, BuildConfig.VERSION_CODE);
-
- final String installedFlavor = getFirstInstallFlavor();
- if (TextUtils.isEmpty(installedFlavor))
- nativeSetString(FIRST_INSTALL_FLAVOR, BuildConfig.FLAVOR);
- }
-
- nativeSetInt(LAUNCH_NUMBER_SETTING, currentLaunches + 1);
- }
-
- private void updateSessionsNumber()
- {
- final int sessionNum = nativeGetInt(SESSION_NUMBER_SETTING, 0);
- final long lastSessionTimestamp = nativeGetLong(LAST_SESSION_TIMESTAMP_SETTING, 0);
- if (!DateUtils.isToday(lastSessionTimestamp))
- {
- nativeSetInt(SESSION_NUMBER_SETTING, sessionNum + 1);
- nativeSetLong(LAST_SESSION_TIMESTAMP_SETTING, System.currentTimeMillis());
- }
- }
-
- /**
- * @return total number of application launches
- */
- public int getLaunchesNumber()
- {
- return nativeGetInt(LAUNCH_NUMBER_SETTING, 0);
- }
-
- /**
- * Session = single day, when app was started any number of times.
- *
- * @return number of sessions.
- */
- public int getSessionsNumber()
- {
- return nativeGetInt(SESSION_NUMBER_SETTING, 0);
- }
-
- public int getFirstInstallVersion()
- {
- return nativeGetInt(FIRST_INSTALL_VERSION, 0);
- }
-
- public String getFirstInstallFlavor()
- {
- return nativeGetString(FIRST_INSTALL_FLAVOR, "");
+ Config.resetAppSessionCounters();
}
}
diff --git a/android/src/com/mapswithme/maps/WebContainerDelegate.java b/android/src/com/mapswithme/maps/WebContainerDelegate.java
new file mode 100644
index 0000000000..91b16b7ba1
--- /dev/null
+++ b/android/src/com/mapswithme/maps/WebContainerDelegate.java
@@ -0,0 +1,80 @@
+package com.mapswithme.maps;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.net.MailTo;
+import android.net.Uri;
+import android.view.View;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+import com.mapswithme.maps.base.OnBackPressListener;
+import com.mapswithme.util.UiUtils;
+
+public abstract class WebContainerDelegate implements OnBackPressListener
+{
+ private WebView mWebView;
+ private View mProgress;
+
+ @SuppressLint("SetJavaScriptEnabled")
+ private void initWebView(String url)
+ {
+ mWebView.setWebViewClient(new WebViewClient()
+ {
+ @Override
+ public void onPageFinished(WebView view, String url)
+ {
+ UiUtils.show(mWebView);
+ UiUtils.hide(mProgress);
+ }
+
+ @Override
+ public boolean shouldOverrideUrlLoading(WebView v, String url)
+ {
+ if (MailTo.isMailTo(url))
+ {
+ MailTo parser = MailTo.parse(url);
+ doStartActivity(new Intent(Intent.ACTION_SEND)
+ .putExtra(Intent.EXTRA_EMAIL, new String[] { parser.getTo() })
+ .putExtra(Intent.EXTRA_TEXT, parser.getBody())
+ .putExtra(Intent.EXTRA_SUBJECT, parser.getSubject())
+ .putExtra(Intent.EXTRA_CC, parser.getCc())
+ .setType("message/rfc822"));
+ v.reload();
+ return true;
+ }
+
+ doStartActivity(new Intent(Intent.ACTION_VIEW)
+ .setData(Uri.parse(url)));
+ return true;
+ }
+ });
+
+ mWebView.getSettings().setJavaScriptEnabled(true);
+ mWebView.getSettings().setDefaultTextEncodingName("utf-8");
+ mWebView.loadUrl(url);
+ }
+
+ public WebContainerDelegate(View frame, String url)
+ {
+ mWebView = (WebView) frame.findViewById(R.id.webview);
+ mProgress = frame.findViewById(R.id.progress);
+ initWebView(url);
+ }
+
+ @Override
+ public boolean onBackPressed()
+ {
+ if (!mWebView.canGoBack())
+ return false;
+
+ mWebView.goBack();
+ return true;
+ }
+
+ public WebView getWebView()
+ {
+ return mWebView;
+ }
+
+ protected abstract void doStartActivity(Intent intent);
+}
diff --git a/android/src/com/mapswithme/maps/ads/GooglePlusDialogFragment.java b/android/src/com/mapswithme/maps/ads/GooglePlusDialogFragment.java
index 6402425c10..4e904a3c21 100644
--- a/android/src/com/mapswithme/maps/ads/GooglePlusDialogFragment.java
+++ b/android/src/com/mapswithme/maps/ads/GooglePlusDialogFragment.java
@@ -8,9 +8,9 @@ import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
-
import com.google.android.gms.plus.PlusOneButton;
import com.mapswithme.maps.R;
+import com.mapswithme.util.Config;
import com.mapswithme.util.Constants;
import com.mapswithme.util.statistics.Statistics;
@@ -30,7 +30,7 @@ public class GooglePlusDialogFragment extends DialogFragment
@Override
public void onPlusOneClick(Intent intent)
{
- LikesManager.setRatingApplied(GooglePlusDialogFragment.class, true);
+ Config.setRatingApplied(GooglePlusDialogFragment.class);
dismiss();
startActivityForResult(intent, 0);
}
diff --git a/android/src/com/mapswithme/maps/ads/LikesManager.java b/android/src/com/mapswithme/maps/ads/LikesManager.java
index e810d23a03..42df223b25 100644
--- a/android/src/com/mapswithme/maps/ads/LikesManager.java
+++ b/android/src/com/mapswithme/maps/ads/LikesManager.java
@@ -3,10 +3,11 @@ package com.mapswithme.maps.ads;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.util.SparseArray;
-
import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.MwmApplication;
+import com.mapswithme.util.Config;
import com.mapswithme.util.ConnectionState;
+import com.mapswithme.util.Config;
import com.mapswithme.util.concurrency.UiThread;
import java.lang.ref.WeakReference;
@@ -15,12 +16,10 @@ public enum LikesManager
{
INSTANCE;
- public static final String LAST_RATED_SESSION = "LastRatedSession";
- public static final String RATED_DIALOG = "RatedDialog";
private static final int DIALOG_DELAY_DEFAULT = 30000;
private static final int DIALOG_DELAY_SHORT = 5000;
- private static final int SESSION_NUM = MwmApplication.get().getSessionsNumber();
+ private static final int SESSION_NUM = Config.getSessionCount();
/*
Maps type of like dialog to the dialog, performing like.
@@ -73,7 +72,7 @@ public enum LikesManager
sNewUsersMapping.put(55, LikeType.FACEBOOK_INVITE_NEW_USERS);
}
- private final boolean mIsNewUser = MwmApplication.get().getFirstInstallVersion() == BuildConfig.VERSION_CODE;
+ private final boolean mIsNewUser = (Config.getFirstInstallVersion() == BuildConfig.VERSION_CODE);
private Runnable mLikeRunnable;
private WeakReference mActivityRef;
@@ -96,9 +95,10 @@ public enum LikesManager
private void displayLikeDialog(final Class extends DialogFragment> dialogFragmentClass, final int delayMillis)
{
- if (isSessionRated(SESSION_NUM) || isRatingApplied(dialogFragmentClass))
+ if (Config.isSessionRated(SESSION_NUM) || Config.isRatingApplied(dialogFragmentClass))
return;
- setSessionRated(SESSION_NUM);
+
+ Config.setRatedSession(SESSION_NUM);
UiThread.cancelDelayedTasks(mLikeRunnable);
mLikeRunnable = new Runnable()
@@ -127,24 +127,4 @@ public enum LikesManager
};
UiThread.runLater(mLikeRunnable, delayMillis);
}
-
- public static boolean isSessionRated(int sessionNum)
- {
- return MwmApplication.get().nativeGetInt(LAST_RATED_SESSION, 0) >= sessionNum;
- }
-
- public static void setSessionRated(int sessionNum)
- {
- MwmApplication.get().nativeSetInt(LAST_RATED_SESSION, sessionNum);
- }
-
- public static boolean isRatingApplied(final Class extends DialogFragment> dialogFragmentClass)
- {
- return MwmApplication.get().nativeGetBoolean(RATED_DIALOG + dialogFragmentClass.getSimpleName(), false);
- }
-
- public static void setRatingApplied(final Class extends DialogFragment> dialogFragmentClass, boolean applied)
- {
- MwmApplication.get().nativeSetBoolean(RATED_DIALOG + dialogFragmentClass.getSimpleName(), applied);
- }
}
diff --git a/android/src/com/mapswithme/maps/ads/RateStoreDialogFragment.java b/android/src/com/mapswithme/maps/ads/RateStoreDialogFragment.java
index 8a475def0a..f6885ac351 100644
--- a/android/src/com/mapswithme/maps/ads/RateStoreDialogFragment.java
+++ b/android/src/com/mapswithme/maps/ads/RateStoreDialogFragment.java
@@ -17,11 +17,11 @@ import android.view.View;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.TextView;
-
import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmDialogFragment;
+import com.mapswithme.util.Config;
import com.mapswithme.util.Constants;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
@@ -62,7 +62,7 @@ public class RateStoreDialogFragment extends BaseMwmDialogFragment implements Vi
mRating = rating;
if (rating >= BuildConfig.RATING_THRESHOLD)
{
- LikesManager.setRatingApplied(RateStoreDialogFragment.class, true);
+ Config.setRatingApplied(RateStoreDialogFragment.class);
dismiss();
Utils.openAppInMarket(getActivity(), BuildConfig.REVIEW_URL);
}
@@ -105,7 +105,7 @@ public class RateStoreDialogFragment extends BaseMwmDialogFragment implements Vi
switch (v.getId())
{
case R.id.btn__explain_bad_rating:
- LikesManager.setRatingApplied(GooglePlusDialogFragment.class, true);
+ Config.setRatingApplied(GooglePlusDialogFragment.class);
dismiss();
final Intent intent = new Intent(Intent.ACTION_SENDTO);
final PackageInfo info;
@@ -118,7 +118,7 @@ public class RateStoreDialogFragment extends BaseMwmDialogFragment implements Vi
{
e.printStackTrace();
}
- intent.setData(Utils.buildMailUri(Constants.Url.MAIL_MAPSME_RATING, getString(R.string.rating_just_rated) + ": " + mRating,
+ intent.setData(Utils.buildMailUri(Constants.Email.RATING, getString(R.string.rating_just_rated) + ": " + mRating,
"OS : " + Build.VERSION.SDK_INT + "\n" + "Version : " + BuildConfig.APPLICATION_ID + " " + BuildConfig.VERSION_NAME + "\n" +
getString(R.string.rating_user_since, DateUtils.formatDateTime(getActivity(), installTime, 0)) + "\n\n"));
try
diff --git a/android/src/com/mapswithme/maps/background/UpgradeReceiverCompat.java b/android/src/com/mapswithme/maps/background/UpgradeReceiverCompat.java
deleted file mode 100644
index ae50a4ce48..0000000000
--- a/android/src/com/mapswithme/maps/background/UpgradeReceiverCompat.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.mapswithme.maps.background;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-import com.mapswithme.maps.MwmApplication;
-
-public class UpgradeReceiverCompat extends BroadcastReceiver
-{
- @Override
- public void onReceive(Context context, Intent intent)
- {
- if (context.getPackageName().equals(intent.getData().getSchemeSpecificPart()))
- MwmApplication.get().onUpgrade();
- }
-}
diff --git a/android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java b/android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java
index 3a8d59c311..8973432fbe 100644
--- a/android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java
+++ b/android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java
@@ -6,11 +6,10 @@ import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
-
-import com.mapswithme.util.ViewServer;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.util.Utils;
+import com.mapswithme.util.ViewServer;
import com.mapswithme.util.statistics.Statistics;
public class BaseMwmFragmentActivity extends AppCompatActivity
diff --git a/android/src/com/mapswithme/maps/base/BaseToolbarActivity.java b/android/src/com/mapswithme/maps/base/BaseToolbarActivity.java
new file mode 100644
index 0000000000..c0de5a6faa
--- /dev/null
+++ b/android/src/com/mapswithme/maps/base/BaseToolbarActivity.java
@@ -0,0 +1,51 @@
+package com.mapswithme.maps.base;
+
+import android.os.Bundle;
+import android.support.annotation.StringRes;
+import android.support.v4.app.Fragment;
+import android.support.v7.widget.Toolbar;
+import com.mapswithme.maps.R;
+import com.mapswithme.util.UiUtils;
+
+public abstract class BaseToolbarActivity extends BaseMwmFragmentActivity
+{
+ @Override
+ protected void onCreate(Bundle state)
+ {
+ super.onCreate(state);
+
+ Toolbar toolbar = getToolbar();
+ int title = getToolbarTitle();
+ if (title == 0)
+ toolbar.setTitle(getTitle());
+ else
+ toolbar.setTitle(title);
+
+ UiUtils.showHomeUpButton(toolbar);
+ displayToolbarAsActionBar();
+ }
+
+ protected @StringRes int getToolbarTitle()
+ {
+ return 0;
+ }
+
+ @Override
+ protected Class extends Fragment> getFragmentClass()
+ {
+ throw new RuntimeException("Must be implemented in child classes!");
+ }
+
+ @Override
+ protected int getContentLayoutResId()
+ {
+ return R.layout.activity_fragment_and_toolbar;
+ }
+
+ @Override
+ protected int getFragmentContentResId()
+ {
+ return R.id.fragment_container;
+ }
+
+}
diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesActivity.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesActivity.java
index 9c162b9a6c..7350df3867 100644
--- a/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesActivity.java
+++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesActivity.java
@@ -1,41 +1,13 @@
package com.mapswithme.maps.bookmarks;
-import android.os.Bundle;
import android.support.v4.app.Fragment;
-import android.support.v7.widget.Toolbar;
+import com.mapswithme.maps.base.BaseToolbarActivity;
-import com.mapswithme.maps.R;
-import com.mapswithme.maps.base.BaseMwmFragmentActivity;
-import com.mapswithme.util.UiUtils;
-
-public class BookmarkCategoriesActivity extends BaseMwmFragmentActivity
+public class BookmarkCategoriesActivity extends BaseToolbarActivity
{
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- final Toolbar toolbar = getToolbar();
- toolbar.setTitle(R.string.bookmark_sets);
- UiUtils.showHomeUpButton(toolbar);
- displayToolbarAsActionBar();
- }
-
- @Override
- protected int getContentLayoutResId()
- {
- return R.layout.activity_fragment_and_toolbar;
- }
-
@Override
protected Class extends Fragment> getFragmentClass()
{
return BookmarkCategoriesFragment.class;
}
-
- @Override
- protected int getFragmentContentResId()
- {
- return R.id.fragment_container;
- }
}
\ No newline at end of file
diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkListActivity.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkListActivity.java
index 5c77a9bcba..67595da0c0 100644
--- a/android/src/com/mapswithme/maps/bookmarks/BookmarkListActivity.java
+++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkListActivity.java
@@ -1,41 +1,13 @@
package com.mapswithme.maps.bookmarks;
-import android.os.Bundle;
import android.support.v4.app.Fragment;
-import android.support.v7.widget.Toolbar;
+import com.mapswithme.maps.base.BaseToolbarActivity;
-import com.mapswithme.maps.R;
-import com.mapswithme.maps.base.BaseMwmFragmentActivity;
-import com.mapswithme.util.UiUtils;
-
-public class BookmarkListActivity extends BaseMwmFragmentActivity
+public class BookmarkListActivity extends BaseToolbarActivity
{
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- final Toolbar toolbar = getToolbar();
- toolbar.setTitle(R.string.bookmarks);
- UiUtils.showHomeUpButton(toolbar);
- displayToolbarAsActionBar();
- }
-
- @Override
- protected int getContentLayoutResId()
- {
- return R.layout.activity_fragment_and_toolbar;
- }
-
@Override
protected Class extends Fragment> getFragmentClass()
{
return BookmarksListFragment.class;
}
-
- @Override
- protected int getFragmentContentResId()
- {
- return R.id.fragment_container;
- }
}
diff --git a/android/src/com/mapswithme/maps/settings/AboutFragment.java b/android/src/com/mapswithme/maps/settings/AboutFragment.java
new file mode 100644
index 0000000000..8748e43180
--- /dev/null
+++ b/android/src/com/mapswithme/maps/settings/AboutFragment.java
@@ -0,0 +1,136 @@
+package com.mapswithme.maps.settings;
+
+
+import android.app.Fragment;
+import android.content.ActivityNotFoundException;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+import android.support.annotation.Nullable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+import com.mapswithme.maps.BuildConfig;
+import com.mapswithme.maps.R;
+import com.mapswithme.maps.widget.BaseShadowController;
+import com.mapswithme.maps.widget.ObservableScrollView;
+import com.mapswithme.maps.widget.ScrollViewShadowController;
+import com.mapswithme.util.Constants;
+import com.mapswithme.util.UiUtils;
+import com.mapswithme.util.Utils;
+import com.mapswithme.util.statistics.AlohaHelper;
+import com.mapswithme.util.statistics.Statistics;
+
+public class AboutFragment extends Fragment
+ implements View.OnClickListener
+{
+ private View mFrame;
+ private BaseShadowController mShadowController;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
+ {
+ mFrame = inflater.inflate(R.layout.about, container, false);
+
+ ((TextView)mFrame.findViewById(R.id.version))
+ .setText(getString(R.string.version, BuildConfig.VERSION_NAME));
+
+ mFrame.findViewById(R.id.web).setOnClickListener(this);
+ mFrame.findViewById(R.id.blog).setOnClickListener(this);
+ mFrame.findViewById(R.id.facebook).setOnClickListener(this);
+ mFrame.findViewById(R.id.twitter).setOnClickListener(this);
+ mFrame.findViewById(R.id.subscribe).setOnClickListener(this);
+ mFrame.findViewById(R.id.rate).setOnClickListener(this);
+ mFrame.findViewById(R.id.copyright).setOnClickListener(this);
+
+ return mFrame;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState)
+ {
+ super.onActivityCreated(savedInstanceState);
+
+ if (((PreferenceActivity)getActivity()).onIsMultiPane())
+ {
+ ((View)mFrame.getParent()).setPadding(0, 0, 0, 0);
+ mShadowController = new ScrollViewShadowController((ObservableScrollView)mFrame.findViewById(R.id.content_frame)).attach();
+ }
+ }
+
+ @Override
+ public void onDestroyView()
+ {
+ super.onDestroyView();
+
+ if (mShadowController != null)
+ mShadowController.detach();
+ }
+
+ @Override
+ public void onClick(View v)
+ {
+ try
+ {
+ switch (v.getId())
+ {
+ case R.id.web:
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.WEB_SITE);
+ AlohaHelper.logClick(AlohaHelper.Settings.WEB_SITE);
+
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.Url.WEB_SITE)));
+ break;
+
+ case R.id.blog:
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.WEB_BLOG);
+ AlohaHelper.logClick(AlohaHelper.Settings.WEB_BLOG);
+
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.Url.WEB_BLOG)));
+ break;
+
+ case R.id.facebook:
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.FACEBOOK);
+ AlohaHelper.logClick(AlohaHelper.Settings.FACEBOOK);
+
+ UiUtils.showFacebookPage(getActivity());
+ break;
+
+ case R.id.twitter:
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.TWITTER);
+ AlohaHelper.logClick(AlohaHelper.Settings.TWITTER);
+
+ UiUtils.showTwitterPage(getActivity());
+ break;
+
+ case R.id.subscribe:
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.SUBSCRIBE);
+ AlohaHelper.logClick(AlohaHelper.Settings.MAIL_SUBSCRIBE);
+
+ startActivity(new Intent(Intent.ACTION_SENDTO)
+ .setData(Utils.buildMailUri(Constants.Email.SUBSCRIBE,
+ getString(R.string.subscribe_me_subject),
+ getString(R.string.subscribe_me_body))));
+ break;
+
+ case R.id.rate:
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.RATE);
+ AlohaHelper.logClick(AlohaHelper.Settings.RATE);
+
+ UiUtils.openAppInMarket(getActivity(), BuildConfig.REVIEW_URL);
+ break;
+
+ case R.id.copyright:
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.COPYRIGHT);
+ AlohaHelper.logClick(AlohaHelper.Settings.COPYRIGHT);
+
+ ((SettingsActivity)getActivity()).switchToFragment(CopyrightFragment.class, R.string.copyright);
+ break;
+ }
+ } catch (ActivityNotFoundException e)
+ {
+ AlohaHelper.logException(e);
+ }
+ }
+}
diff --git a/android/src/com/mapswithme/maps/settings/CopyrightFragment.java b/android/src/com/mapswithme/maps/settings/CopyrightFragment.java
new file mode 100644
index 0000000000..2b2528431d
--- /dev/null
+++ b/android/src/com/mapswithme/maps/settings/CopyrightFragment.java
@@ -0,0 +1,70 @@
+package com.mapswithme.maps.settings;
+
+import android.app.Fragment;
+import android.content.Intent;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+import android.support.annotation.Nullable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import com.mapswithme.maps.R;
+import com.mapswithme.maps.WebContainerDelegate;
+import com.mapswithme.maps.base.OnBackPressListener;
+import com.mapswithme.maps.widget.BaseShadowController;
+import com.mapswithme.maps.widget.ObservableWebView;
+import com.mapswithme.maps.widget.WebViewShadowController;
+import com.mapswithme.util.Constants;
+
+public class CopyrightFragment extends Fragment
+ implements OnBackPressListener
+{
+ private WebContainerDelegate mDelegate;
+ private BaseShadowController mShadowController;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
+ {
+ View frame = inflater.inflate(R.layout.fragment_prefs_copyright, container, false);
+
+ mDelegate = new WebContainerDelegate(frame, Constants.Url.COPYRIGHT)
+ {
+ @Override
+ protected void doStartActivity(Intent intent)
+ {
+ startActivity(intent);
+ }
+ };
+
+ return frame;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState)
+ {
+ super.onActivityCreated(savedInstanceState);
+
+ if (((PreferenceActivity)getActivity()).onIsMultiPane())
+ {
+ HelpFragment.adjustMargins(mDelegate.getWebView());
+ mShadowController = new WebViewShadowController((ObservableWebView)mDelegate.getWebView()).attach();
+ }
+ }
+
+ @Override
+ public void onDestroyView()
+ {
+ super.onDestroyView();
+ if (mShadowController != null)
+ mShadowController.detach();
+ }
+
+ @Override
+ public boolean onBackPressed()
+ {
+ if (!mDelegate.onBackPressed())
+ ((SettingsActivity)getActivity()).switchToFragment(AboutFragment.class, R.string.about_menu_title);
+
+ return true;
+ }
+}
diff --git a/android/src/com/mapswithme/maps/settings/HelpFragment.java b/android/src/com/mapswithme/maps/settings/HelpFragment.java
new file mode 100644
index 0000000000..25efa898f1
--- /dev/null
+++ b/android/src/com/mapswithme/maps/settings/HelpFragment.java
@@ -0,0 +1,123 @@
+package com.mapswithme.maps.settings;
+
+import android.app.AlertDialog;
+import android.app.Fragment;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+import android.support.annotation.Nullable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import com.mapswithme.maps.BuildConfig;
+import com.mapswithme.maps.R;
+import com.mapswithme.maps.WebContainerDelegate;
+import com.mapswithme.maps.widget.BaseShadowController;
+import com.mapswithme.maps.widget.ObservableWebView;
+import com.mapswithme.maps.widget.WebViewShadowController;
+import com.mapswithme.util.Constants;
+import com.mapswithme.util.UiUtils;
+import com.mapswithme.util.Utils;
+import com.mapswithme.util.statistics.AlohaHelper;
+import com.mapswithme.util.statistics.Statistics;
+
+public class HelpFragment extends Fragment
+{
+ private View mFrame;
+ private WebContainerDelegate mDelegate;
+ private BaseShadowController mShadowController;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
+ {
+ mFrame = inflater.inflate(R.layout.fragment_prefs_help, container, false);
+
+ mDelegate = new WebContainerDelegate(mFrame, Constants.Url.FAQ)
+ {
+ @Override
+ protected void doStartActivity(Intent intent)
+ {
+ startActivity(intent);
+ }
+ };
+
+ mFrame.findViewById(R.id.feedback).setOnClickListener(new View.OnClickListener()
+ {
+ @Override
+ public void onClick(View v)
+ {
+ new AlertDialog.Builder(getActivity())
+ .setTitle(R.string.feedback)
+ .setNegativeButton(R.string.cancel, null)
+ .setItems(new CharSequence[] { getString(R.string.feedback_general), getString(R.string.report_a_bug) }, new DialogInterface.OnClickListener()
+ {
+ private void sendGeneralFeedback()
+ {
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.FEEDBACK_GENERAL);
+ AlohaHelper.logClick(AlohaHelper.Settings.FEEDBACK_GENERAL);
+
+ startActivity(new Intent(Intent.ACTION_SENDTO)
+ .setData(Utils.buildMailUri(Constants.Email.FEEDBACK, "[" + BuildConfig.VERSION_NAME + "] Feedback", "")));
+ }
+
+ private void reportBug()
+ {
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.REPORT_BUG);
+ AlohaHelper.logClick(AlohaHelper.Settings.REPORT_BUG);
+ Utils.sendSupportMail(getActivity(), "Bugreport from user");
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ switch (which)
+ {
+ case 0:
+ sendGeneralFeedback();
+ break;
+
+ case 1:
+ reportBug();
+ break;
+ }
+ }
+ }).show();
+ }
+ });
+
+ return mFrame;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState)
+ {
+ super.onActivityCreated(savedInstanceState);
+
+ if (((PreferenceActivity)getActivity()).onIsMultiPane())
+ {
+ ((View)mFrame.getParent()).setPadding(0, 0, 0, 0);
+ adjustMargins(mDelegate.getWebView());
+ mShadowController = new WebViewShadowController((ObservableWebView)mDelegate.getWebView())
+ .addBottomShadow()
+ .attach();
+ }
+ }
+
+ @Override
+ public void onDestroyView()
+ {
+ super.onDestroyView();
+ if (mShadowController != null)
+ mShadowController.detach();
+ }
+
+ static void adjustMargins(View view)
+ {
+ int margin = UiUtils.dimen(R.dimen.margin_half);
+ ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
+ lp.leftMargin = margin;
+ lp.rightMargin = margin;
+ view.setLayoutParams(lp);
+ }
+}
diff --git a/android/src/com/mapswithme/maps/settings/MapPrefsFragment.java b/android/src/com/mapswithme/maps/settings/MapPrefsFragment.java
new file mode 100644
index 0000000000..ebbb572f32
--- /dev/null
+++ b/android/src/com/mapswithme/maps/settings/MapPrefsFragment.java
@@ -0,0 +1,151 @@
+package com.mapswithme.maps.settings;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.preference.*;
+import android.support.v7.app.AlertDialog;
+import com.mapswithme.country.ActiveCountryTree;
+import com.mapswithme.maps.BuildConfig;
+import com.mapswithme.maps.Framework;
+import com.mapswithme.maps.R;
+import com.mapswithme.util.Config;
+import com.mapswithme.util.Yota;
+import com.mapswithme.util.statistics.AlohaHelper;
+
+import java.util.List;
+
+public class MapPrefsFragment extends PreferenceFragment
+{
+ private final StoragePathManager mPathManager = new StoragePathManager();
+ private Preference mStoragePref;
+
+ private boolean singleStorageOnly()
+ {
+ return Yota.isFirstYota() || !mPathManager.hasMoreThanOneStorage();
+ }
+
+ private void updateStoragePrefs()
+ {
+ Preference old = findPreference(getString(R.string.pref_storage));
+
+ if (singleStorageOnly())
+ {
+ if (old != null)
+ getPreferenceScreen().removePreference(old);
+ }
+ else
+ {
+ if (old == null)
+ getPreferenceScreen().addPreference(mStoragePref);
+ }
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.prefs_map);
+
+ mStoragePref = findPreference(getString(R.string.pref_storage));
+ updateStoragePrefs();
+
+ mStoragePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
+ {
+ @Override
+ public boolean onPreferenceClick(Preference preference)
+ {
+ if (ActiveCountryTree.isDownloadingActive())
+ new AlertDialog.Builder(getActivity())
+ .setTitle(getString(R.string.downloading_is_active))
+ .setMessage(getString(R.string.cant_change_this_setting))
+ .setPositiveButton(getString(R.string.ok), null)
+ .show();
+ else
+ startActivity(new Intent(getActivity(), StoragePathActivity.class));
+
+ return true;
+ }
+ });
+
+ Preference pref = findPreference(getString(R.string.pref_munits));
+ ((ListPreference)pref).setValue(String.valueOf(UnitLocale.getUnits()));
+ pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
+ {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue)
+ {
+ UnitLocale.setUnits(Integer.parseInt((String) newValue));
+ AlohaHelper.logClick(AlohaHelper.Settings.CHANGE_UNITS);
+ return true;
+ }
+ });
+
+ pref = findPreference(getString(R.string.pref_show_zoom_buttons));
+ ((SwitchPreference)pref).setChecked(Config.getShowZoomButtons());
+ pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
+ {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue)
+ {
+ Config.setShowZoomButtons((Boolean) newValue);
+ return true;
+ }
+ });
+
+ pref = findPreference(getString(R.string.pref_map_style));
+ if (BuildConfig.ALLOW_PREF_MAP_STYLE)
+ {
+ ((ListPreference) pref).setValue(String.valueOf(Framework.getMapStyle()));
+ pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
+ {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue)
+ {
+ Framework.setMapStyle(Integer.parseInt((String) newValue));
+ return true;
+ }
+ });
+ }
+ else
+ {
+ getPreferenceScreen().removePreference(pref);
+ }
+
+ pref = findPreference(getString(R.string.pref_yota));
+ if (!Yota.isFirstYota())
+ getPreferenceScreen().removePreference(pref);
+ else
+ pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
+ {
+ @Override
+ public boolean onPreferenceClick(Preference preference)
+ {
+ startActivity(new Intent(Yota.ACTION_PREFERENCE));
+ return false;
+ }
+ });
+ }
+
+ @Override
+ public void onAttach(Activity activity)
+ {
+ super.onAttach(activity);
+
+ mPathManager.startExternalStorageWatching(activity, new StoragePathManager.OnStorageListChangedListener()
+ {
+ @Override
+ public void onStorageListChanged(List storageItems, int currentStorageIndex)
+ {
+ updateStoragePrefs();
+ }
+ }, null);
+ }
+
+ @Override
+ public void onDetach()
+ {
+ super.onDetach();
+ mPathManager.stopExternalStorageWatching();
+ }
+}
diff --git a/android/src/com/mapswithme/maps/settings/MiscPrefsFragment.java b/android/src/com/mapswithme/maps/settings/MiscPrefsFragment.java
new file mode 100644
index 0000000000..00e1969aa8
--- /dev/null
+++ b/android/src/com/mapswithme/maps/settings/MiscPrefsFragment.java
@@ -0,0 +1,37 @@
+package com.mapswithme.maps.settings;
+
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
+import android.preference.SwitchPreference;
+import com.google.android.gms.common.ConnectionResult;
+import com.google.android.gms.common.GoogleApiAvailability;
+import com.mapswithme.maps.MwmApplication;
+import com.mapswithme.maps.R;
+import com.mapswithme.util.Config;
+import com.mapswithme.util.statistics.Statistics;
+
+public class MiscPrefsFragment extends PreferenceFragment
+{
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.prefs_misc);
+
+ Preference pref = findPreference(getString(R.string.pref_send_statistics));
+ ((SwitchPreference)pref).setChecked(Config.isStatisticsEnabled());
+ pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
+ {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue)
+ {
+ Statistics.INSTANCE.setStatEnabled((Boolean) newValue);
+ return true;
+ }
+ });
+
+ if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(MwmApplication.get()) != ConnectionResult.SUCCESS)
+ getPreferenceScreen().removePreference(findPreference(getString(R.string.pref_play_services)));
+ }
+}
diff --git a/android/src/com/mapswithme/maps/settings/SettingsActivity.java b/android/src/com/mapswithme/maps/settings/SettingsActivity.java
index bf754752bd..2a6f742994 100644
--- a/android/src/com/mapswithme/maps/settings/SettingsActivity.java
+++ b/android/src/com/mapswithme/maps/settings/SettingsActivity.java
@@ -1,142 +1,162 @@
package com.mapswithme.maps.settings;
-import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.net.MailTo;
-import android.net.Uri;
+import android.app.Fragment;
+import android.content.res.Configuration;
import android.os.Bundle;
-import android.preference.CheckBoxPreference;
-import android.preference.ListPreference;
-import android.preference.Preference;
-import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
-import android.preference.PreferenceScreen;
-import android.support.v7.app.AlertDialog;
-import android.util.AttributeSet;
+import android.support.annotation.NonNull;
+import android.support.annotation.StringRes;
+import android.support.v7.app.AppCompatDelegate;
+import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
-import android.view.animation.AlphaAnimation;
-import android.view.inputmethod.InputMethodManager;
-import android.webkit.WebView;
-import android.webkit.WebViewClient;
-
-import com.google.android.gms.common.ConnectionResult;
-import com.google.android.gms.common.GoogleApiAvailability;
-import com.mapswithme.country.ActiveCountryTree;
-import com.mapswithme.maps.BuildConfig;
+import android.view.ViewGroup;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
-import com.mapswithme.util.Constants;
+import com.mapswithme.maps.base.OnBackPressListener;
+import com.mapswithme.util.FragmentListHelper;
import com.mapswithme.util.UiUtils;
-import com.mapswithme.util.Utils;
import com.mapswithme.util.ViewServer;
-import com.mapswithme.util.Yota;
import com.mapswithme.util.statistics.AlohaHelper;
import com.mapswithme.util.statistics.Statistics;
-public class SettingsActivity extends PreferenceActivity implements OnPreferenceClickListener, Preference.OnPreferenceChangeListener
+import java.util.List;
+
+public class SettingsActivity extends PreferenceActivity
{
- public final static String ZOOM_BUTTON_ENABLED = "ZoomButtonsEnabled";
- private static final String COPYRIGHT_HTML_URL = "file:///android_asset/copyright.html";
- private static final String FAQ_HTML_URL = "file:///android_asset/faq.html";
+ private final FragmentListHelper mFragmentListHelper = new FragmentListHelper();
+ private AppCompatDelegate mDelegate;
+ private String mNextBreadcrumb;
- private Preference mStoragePreference;
- private StoragePathManager mPathManager = new StoragePathManager();
+ private AppCompatDelegate getDelegate()
+ {
+ if (mDelegate == null)
+ mDelegate = AppCompatDelegate.create(this, null);
+
+ return mDelegate;
+ }
+
+ @Override
+ public void onAttachFragment(Fragment fragment)
+ {
+ mFragmentListHelper.onAttachFragment(fragment);
+ }
+
+ @Override
+ public void onBuildHeaders(List target)
+ {
+ loadHeadersFromResource(R.xml.prefs_headers, target);
+ }
+
+ @Override
+ public void onHeaderClick(@NonNull Header header, int position)
+ {
+ if (header.id == R.id.group_map)
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.GROUP_MAP);
+ else if (header.id == R.id.group_misc)
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.GROUP_MISC);
+ else if (header.id == R.id.help)
+ {
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.HELP);
+ AlohaHelper.logClick(AlohaHelper.Settings.HELP);
+ }
+ else if (header.id == R.id.about)
+ {
+ Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.Settings.ABOUT);
+ AlohaHelper.logClick(AlohaHelper.Settings.ABOUT);
+ }
+
+ super.onHeaderClick(header, position);
+ }
- @SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState)
{
+ getDelegate().installViewFactory();
+ getDelegate().onCreate(savedInstanceState);
+
super.onCreate(savedInstanceState);
- // TODO remove after refactoring to fragments
- // this initialisation is necessary hence Activity isn't extended from BaseMwmActivity
- // try to prevent possible crash if this is the only activity in application
- MwmApplication.get().initNativeCore();
+ // Hack to attach Toolbar and make it work on native PreferenceActivity
+ ViewGroup root = (ViewGroup)findViewById(android.R.id.list).getParent().getParent().getParent();
+ View toolbarHolder = LayoutInflater.from(this).inflate(R.layout.toolbar_default, root, false);
+ Toolbar toolbar = (Toolbar) toolbarHolder.findViewById(R.id.toolbar);
+ UiUtils.showHomeUpButton(toolbar);
+
+ // Yes, attach it twice
+ root.addView(toolbarHolder, 0);
+ getDelegate().setSupportActionBar(toolbar);
+
MwmApplication.get().initCounters();
- addPreferencesFromResource(R.xml.preferences);
- initPreferences();
- yotaSetup();
+ MwmApplication.get().initNativeCore();
ViewServer.get(this).addWindow(this);
}
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState)
+ {
+ super.onPostCreate(savedInstanceState);
+ getDelegate().onPostCreate(savedInstanceState);
+ }
+
+ @Override
+ public void setContentView(int layoutResID)
+ {
+ getDelegate().setContentView(layoutResID);
+ }
+
+ @Override
+ public void setContentView(View view)
+ {
+ getDelegate().setContentView(view);
+ }
+
+ @Override
+ public void setContentView(View view, ViewGroup.LayoutParams params)
+ {
+ getDelegate().setContentView(view, params);
+ }
+
+ @Override
+ public void addContentView(View view, ViewGroup.LayoutParams params)
+ {
+ getDelegate().addContentView(view, params);
+ }
+
+ @Override
+ protected void onTitleChanged(CharSequence title, int color)
+ {
+ super.onTitleChanged(title, color);
+ getDelegate().setTitle(title);
+ }
+
+ @Override
+ public void invalidateOptionsMenu()
+ {
+ super.invalidateOptionsMenu();
+ getDelegate().invalidateOptionsMenu();
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig)
+ {
+ super.onConfigurationChanged(newConfig);
+ getDelegate().onConfigurationChanged(newConfig);
+ }
+
@Override
protected void onDestroy()
{
super.onDestroy();
+ getDelegate().onDestroy();
ViewServer.get(this).removeWindow(this);
}
- @SuppressWarnings("deprecation")
- private void initPreferences()
+ @Override
+ protected boolean isValidFragment(String fragmentName)
{
- mStoragePreference = findPreference(getString(R.string.pref_storage_activity));
- mStoragePreference.setOnPreferenceClickListener(this);
-
- final ListPreference lPref = (ListPreference) findPreference(getString(R.string.pref_munits));
- lPref.setValue(String.valueOf(UnitLocale.getUnits()));
- lPref.setOnPreferenceChangeListener(this);
-
- final CheckBoxPreference allowStatsPreference = (CheckBoxPreference) findPreference(getString(R.string.pref_allow_stat));
- allowStatsPreference.setChecked(Statistics.INSTANCE.isStatisticsEnabled());
- allowStatsPreference.setOnPreferenceChangeListener(this);
-
- final CheckBoxPreference enableZoomButtons = (CheckBoxPreference) findPreference(getString(R.string.pref_zoom_btns_enabled));
- enableZoomButtons.setChecked(MwmApplication.get().nativeGetBoolean(ZOOM_BUTTON_ENABLED, true));
- enableZoomButtons.setOnPreferenceChangeListener(this);
-
- if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(MwmApplication.get()) != ConnectionResult.SUCCESS)
- {
- ((PreferenceScreen) findPreference(getString(R.string.pref_settings))).
- removePreference(findPreference(getString(R.string.pref_play_services)));
- }
-
- findPreference(getString(R.string.pref_about)).setOnPreferenceClickListener(this);
- findPreference(getString(R.string.pref_rate_app)).setOnPreferenceClickListener(this);
- findPreference(getString(R.string.pref_contact)).setOnPreferenceClickListener(this);
- findPreference(getString(R.string.pref_copyright)).setOnPreferenceClickListener(this);
- findPreference(getString(R.string.pref_like_fb)).setOnPreferenceClickListener(this);
- findPreference(getString(R.string.pref_follow_twitter)).setOnPreferenceClickListener(this);
- findPreference(getString(R.string.pref_report_bug)).setOnPreferenceClickListener(this);
- findPreference(getString(R.string.pref_subscribe)).setOnPreferenceClickListener(this);
- findPreference(getString(R.string.pref_help)).setOnPreferenceClickListener(this);
- }
-
- @SuppressWarnings("deprecation")
- private void storagePathSetup()
- {
- PreferenceScreen screen = (PreferenceScreen) findPreference(getString(R.string.pref_settings));
- if (Yota.isFirstYota())
- screen.removePreference(mStoragePreference);
- else if (mPathManager.hasMoreThanOneStorage())
- screen.addPreference(mStoragePreference);
- else
- screen.removePreference(mStoragePreference);
- }
-
- @SuppressWarnings("deprecation")
- private void yotaSetup()
- {
- final PreferenceScreen screen = (PreferenceScreen) findPreference(getString(R.string.pref_settings));
- final Preference yopPreference = findPreference(getString(R.string.pref_yota));
- if (!Yota.isFirstYota())
- screen.removePreference(yopPreference);
- else
- {
- yopPreference.setOnPreferenceClickListener(new OnPreferenceClickListener()
- {
- @Override
- public boolean onPreferenceClick(Preference preference)
- {
- SettingsActivity.this.startActivity(new Intent(Yota.ACTION_PREFERENCE));
- return true;
- }
- });
- }
+ return true;
}
@Override
@@ -150,6 +170,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
protected void onStop()
{
super.onStop();
+ getDelegate().onStop();
Statistics.INSTANCE.stopActivity(this);
}
@@ -157,26 +178,22 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
protected void onResume()
{
super.onResume();
- BroadcastReceiver receiver = new BroadcastReceiver()
- {
- @Override
- public void onReceive(Context context, Intent intent)
- {
- storagePathSetup();
- }
- };
- mPathManager.startExternalStorageWatching(this, receiver, null);
- storagePathSetup();
org.alohalytics.Statistics.logEvent("$onResume", this.getClass().getSimpleName());
ViewServer.get(this).setFocusedWindow(this);
}
+ @Override
+ protected void onPostResume()
+ {
+ super.onPostResume();
+ getDelegate().onPostResume();
+ }
+
@Override
protected void onPause()
{
super.onPause();
- mPathManager.stopExternalStorageWatching();
org.alohalytics.Statistics.logEvent("$onPause", this.getClass().getSimpleName());
}
@@ -186,268 +203,38 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
{
if (item.getItemId() == android.R.id.home)
{
- final InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
- imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
- onBackPressed();
+ super.onBackPressed();
return true;
}
- else
- return super.onOptionsItemSelected(item);
- }
- @SuppressWarnings("deprecation")
- @Override
- public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
- {
- super.onPreferenceTreeClick(preferenceScreen, preference);
- if (preference != null && preference instanceof PreferenceScreen &&
- ((PreferenceScreen) preference).getDialog() != null)
- ((PreferenceScreen) preference).getDialog().getWindow().getDecorView().
- setBackgroundDrawable(getWindow().getDecorView().getBackground().getConstantState().newDrawable());
- return false;
- }
-
- private WebView buildWebViewDialog(String dialogTitle)
- {
- final LayoutInflater inflater = LayoutInflater.from(this);
- final View alertDialogView = inflater.inflate(R.layout.dialog_about, (android.view.ViewGroup) findViewById(android.R.id.content), false);
- final WebView myWebView = (WebView) alertDialogView.findViewById(R.id.webview_about);
-
- myWebView.setWebViewClient(new WebViewClient()
- {
- @Override
- public void onPageFinished(WebView view, String url)
- {
- super.onPageFinished(view, url);
- UiUtils.show(myWebView);
-
- final AlphaAnimation aAnim = new AlphaAnimation(0, 1);
- aAnim.setDuration(750);
- myWebView.startAnimation(aAnim);
- }
-
- @Override
- public boolean shouldOverrideUrlLoading(WebView v, String url)
- {
- if (MailTo.isMailTo(url))
- {
- MailTo parser = MailTo.parse(url);
- Context ctx = v.getContext();
- Intent mailIntent = CreateEmailIntent(parser.getTo(),
- parser.getSubject(),
- parser.getBody(),
- parser.getCc());
- ctx.startActivity(mailIntent);
- v.reload();
- }
- else
- {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse(url));
- SettingsActivity.this.startActivity(intent);
- }
- return true;
- }
-
- private Intent CreateEmailIntent(String address,
- String subject,
- String body,
- String cc)
- {
- Intent intent = new Intent(Intent.ACTION_SEND);
- intent.putExtra(Intent.EXTRA_EMAIL, new String[]{address});
- intent.putExtra(Intent.EXTRA_TEXT, body);
- intent.putExtra(Intent.EXTRA_SUBJECT, subject);
- intent.putExtra(Intent.EXTRA_CC, cc);
- intent.setType("message/rfc822");
- return intent;
- }
- });
-
- new AlertDialog.Builder(this)
- .setView(alertDialogView)
- .setTitle(dialogTitle)
- .setPositiveButton(R.string.close, new DialogInterface.OnClickListener()
- {
- @Override
- public void onClick(DialogInterface dialog, int which)
- {
- dialog.dismiss();
- }
- })
- .create()
- .show();
-
- return myWebView;
- }
-
- private void showWebViewDialogWithUrl(String url, String dialogTitle)
- {
- WebView webView = buildWebViewDialog(dialogTitle);
- webView.getSettings().setJavaScriptEnabled(true);
- webView.getSettings().setDefaultTextEncodingName("utf-8");
- webView.loadUrl(url);
- }
-
- private void showDialogWithData(String text, String title)
- {
- new AlertDialog.Builder(this)
- .setTitle(title)
- .setMessage(text)
- .setPositiveButton(R.string.close, new DialogInterface.OnClickListener()
- {
- @Override
- public void onClick(DialogInterface dialog, int which)
- {
- dialog.dismiss();
- }
- })
- .create()
- .show();
+ return super.onOptionsItemSelected(item);
}
@Override
- public boolean onPreferenceClick(Preference preference)
+ public void onBackPressed()
{
- final String key = preference.getKey();
- if (key.equals(getString(R.string.pref_rate_app)))
- {
- Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.SETTINGS_RATE);
- AlohaHelper.logClick(AlohaHelper.SETTINGS_RATE);
- UiUtils.openAppInMarket(this, BuildConfig.REVIEW_URL);
- }
- else if (key.equals(getString(R.string.pref_contact)))
- {
- Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.SETTINGS_CONTACT_US);
- AlohaHelper.logClick(AlohaHelper.SETTINGS_CONTACT_US);
- final Intent intent = new Intent(Intent.ACTION_SENDTO);
- intent.setData(Utils.buildMailUri(Constants.Url.MAIL_MAPSME_INFO, "", ""));
- startActivity(intent);
- }
- else if (key.equals(getString(R.string.pref_subscribe)))
- {
- Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.SETTINGS_MAIL_SUBSCRIBE);
- AlohaHelper.logClick(AlohaHelper.SETTINGS_MAIL_SUBSCRIBE);
- final Intent intent = new Intent(Intent.ACTION_SENDTO);
- intent.setData(Utils.buildMailUri(Constants.Url.MAIL_MAPSME_SUBSCRIBE, getString(R.string.subscribe_me_subject), getString(R.string.subscribe_me_body)));
- startActivity(intent);
- }
- else if (key.equals(getString(R.string.pref_report_bug)))
- {
- Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.SETTINGS_REPORT_BUG);
- AlohaHelper.logClick(AlohaHelper.SETTINGS_REPORT_BUG);
- Utils.sendSupportMail(this, "Bugreport from user");
- }
- else if (key.equals(getString(R.string.pref_like_fb)))
- {
- Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.SETTINGS_FB);
- AlohaHelper.logClick(AlohaHelper.SETTINGS_FB);
- UiUtils.showFacebookPage(this);
- }
- else if (key.equals(getString(R.string.pref_follow_twitter)))
- {
- Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.SETTINGS_TWITTER);
- AlohaHelper.logClick(AlohaHelper.SETTINGS_TWITTER);
- UiUtils.showTwitterPage(this);
- }
- else if (key.equals(getString(R.string.pref_help)))
- {
- Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.SETTINGS_HELP);
- AlohaHelper.logClick(AlohaHelper.SETTINGS_HELP);
- showWebViewDialogWithUrl(FAQ_HTML_URL, getString(R.string.help));
- }
- else if (key.equals(getString(R.string.pref_copyright)))
- {
- Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.SETTINGS_COPYRIGHT);
- AlohaHelper.logClick(AlohaHelper.SETTINGS_COPYRIGHT);
- showWebViewDialogWithUrl(COPYRIGHT_HTML_URL, getString(R.string.copyright));
- }
- else if (key.equals(getString(R.string.pref_about)))
- {
- Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.SETTINGS_ABOUT);
- AlohaHelper.logClick(AlohaHelper.SETTINGS_ABOUT);
- showDialogWithData(getString(R.string.about_text),
- String.format(getString(R.string.version), BuildConfig.VERSION_NAME));
- }
- else if (key.equals(getString(R.string.pref_storage_activity)))
- {
- if (ActiveCountryTree.isDownloadingActive())
- {
- new AlertDialog.Builder(SettingsActivity.this)
- .setTitle(getString(R.string.downloading_is_active))
- .setMessage(getString(R.string.cant_change_this_setting))
- .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener()
- {
- @Override
- public void onClick(DialogInterface dlg, int which)
- {
- dlg.dismiss();
- }
- })
- .create()
- .show();
+ for (Fragment f : mFragmentListHelper.getFragments())
+ if ((f instanceof OnBackPressListener) && ((OnBackPressListener)f).onBackPressed())
+ return;
- return false;
- }
- else
- {
- startActivity(new Intent(this, StoragePathActivity.class));
- return true;
- }
- }
- else if (key.equals(getString(R.string.pref_community)))
- {
- Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.SETTINGS_COMMUNITY);
- AlohaHelper.logClick(AlohaHelper.SETTINGS_COMMUNITY);
- }
- else if (key.equals(getString(R.string.pref_settings)))
- Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.SETTINGS_CHANGE_SETTING);
-
- return false;
+ super.onBackPressed();
}
@Override
- public boolean onPreferenceChange(Preference preference, Object newValue)
+ public void showBreadCrumbs(CharSequence title, CharSequence shortTitle)
{
- final String key = preference.getKey();
- if (key.equals(getString(R.string.pref_munits)))
+ if (mNextBreadcrumb != null)
{
- UnitLocale.setUnits(Integer.parseInt((String) newValue));
- AlohaHelper.logClick(AlohaHelper.SETTINGS_CHANGE_UNITS);
+ title = mNextBreadcrumb;
+ mNextBreadcrumb = null;
}
- else if (key.equals(getString(R.string.pref_allow_stat)))
- Statistics.INSTANCE.setStatEnabled((Boolean) newValue);
- else if (key.equals(getString(R.string.pref_zoom_btns_enabled)))
- MwmApplication.get().nativeSetBoolean(ZOOM_BUTTON_ENABLED, (Boolean) newValue);
- return true;
+ super.showBreadCrumbs(title, shortTitle);
}
-
- // needed for soft keyboard to appear in alertdialog.
- // check https://code.google.com/p/android/issues/detail?id=7189 for details
- public static class MyWebView extends WebView
+ public void switchToFragment(Class extends Fragment> fragmentClass, @StringRes int breadcrumb)
{
-
- public MyWebView(Context context)
- {
- super(context);
- }
-
- public MyWebView(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- }
-
- public MyWebView(Context context, AttributeSet attrs, int defStyle)
- {
- super(context, attrs, defStyle);
- }
-
- @Override
- public boolean onCheckIsTextEditor()
- {
- return true;
- }
+ mNextBreadcrumb = getString(breadcrumb);
+ switchToHeader(fragmentClass.getName(), null);
}
}
diff --git a/android/src/com/mapswithme/maps/settings/StoragePathAdapter.java b/android/src/com/mapswithme/maps/settings/StoragePathAdapter.java
index ff06071025..96caf9fb9e 100644
--- a/android/src/com/mapswithme/maps/settings/StoragePathAdapter.java
+++ b/android/src/com/mapswithme/maps/settings/StoragePathAdapter.java
@@ -8,11 +8,9 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;
import android.widget.TextView;
-
import com.mapswithme.maps.R;
import com.mapswithme.util.Constants;
-import java.util.ArrayList;
import java.util.List;
class StoragePathAdapter extends BaseAdapter
@@ -117,7 +115,7 @@ class StoragePathAdapter extends BaseAdapter
mStoragePathManager.changeStorage(index);
}
- public void updateList(ArrayList items, int currentItemIndex, long dirSize)
+ public void updateList(List items, int currentItemIndex, long dirSize)
{
mSizeNeeded = dirSize;
mItems = items;
diff --git a/android/src/com/mapswithme/maps/settings/StoragePathFragment.java b/android/src/com/mapswithme/maps/settings/StoragePathFragment.java
index 350cc093e5..38e6494ec6 100644
--- a/android/src/com/mapswithme/maps/settings/StoragePathFragment.java
+++ b/android/src/com/mapswithme/maps/settings/StoragePathFragment.java
@@ -1,19 +1,17 @@
package com.mapswithme.maps.settings;
import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.Context;
import android.content.DialogInterface;
-import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.ListView;
-
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmListFragment;
import com.mapswithme.util.Utils;
-public class StoragePathFragment extends BaseMwmListFragment implements StoragePathManager.MoveFilesListener
+import java.util.List;
+
+public class StoragePathFragment extends BaseMwmListFragment
{
private StoragePathManager mPathManager = new StoragePathManager();
private StoragePathAdapter mAdapter;
@@ -33,16 +31,43 @@ public class StoragePathFragment extends BaseMwmListFragment implements StorageP
public void onResume()
{
super.onResume();
- BroadcastReceiver receiver = new BroadcastReceiver()
+ mPathManager.startExternalStorageWatching(getActivity(), new StoragePathManager.OnStorageListChangedListener()
{
@Override
- public void onReceive(Context context, Intent intent)
+ public void onStorageListChanged(List storageItems, int currentStorageIndex)
{
if (mAdapter != null)
- mAdapter.updateList(mPathManager.getStorageItems(), mPathManager.getCurrentStorageIndex(), StorageUtils.getWritableDirSize());
+ mAdapter.updateList(storageItems, currentStorageIndex, StorageUtils.getWritableDirSize());
}
- };
- mPathManager.startExternalStorageWatching(getActivity(), receiver, this);
+ }, new StoragePathManager.MoveFilesListener()
+ {
+ @Override
+ public void moveFilesFinished(String newPath)
+ {
+ mAdapter.updateList(mPathManager.getStorageItems(), mPathManager.getCurrentStorageIndex(), StorageUtils.getWritableDirSize());
+ }
+
+ @Override
+ public void moveFilesFailed(int errorCode)
+ {
+ if (!isAdded())
+ return;
+
+ final String message = "Failed to move maps with internal error: " + errorCode;
+ final Activity activity = getActivity();
+ new AlertDialog.Builder(activity)
+ .setTitle(message)
+ .setPositiveButton(R.string.report_a_bug, new DialogInterface.OnClickListener()
+ {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ Utils.sendSupportMail(activity, message);
+ }
+ }).show();
+ }
+ });
+
initAdapter();
mAdapter.updateList(mPathManager.getStorageItems(), mPathManager.getCurrentStorageIndex(), StorageUtils.getWritableDirSize());
setListAdapter(mAdapter);
@@ -60,31 +85,4 @@ public class StoragePathFragment extends BaseMwmListFragment implements StorageP
if (mAdapter == null)
mAdapter = new StoragePathAdapter(mPathManager, getActivity());
}
-
- @Override
- public void moveFilesFinished(String newPath)
- {
- mAdapter.updateList(mPathManager.getStorageItems(), mPathManager.getCurrentStorageIndex(), StorageUtils.getWritableDirSize());
- }
-
- @Override
- public void moveFilesFailed(int errorCode)
- {
- if (!isAdded())
- return;
-
- final String message = "Failed to move maps with internal error :" + errorCode;
- final Activity activity = getActivity();
- new AlertDialog.Builder(activity)
- .setTitle(message)
- .setPositiveButton(R.string.report_a_bug, new DialogInterface.OnClickListener()
- {
- @Override
- public void onClick(DialogInterface dialog, int which)
- {
- Utils.sendSupportMail(activity, message);
- }
- })
- .show();
- }
}
diff --git a/android/src/com/mapswithme/maps/settings/StoragePathManager.java b/android/src/com/mapswithme/maps/settings/StoragePathManager.java
index 7a319540e7..988faee8d2 100644
--- a/android/src/com/mapswithme/maps/settings/StoragePathManager.java
+++ b/android/src/com/mapswithme/maps/settings/StoragePathManager.java
@@ -2,24 +2,18 @@ package com.mapswithme.maps.settings;
import android.app.Activity;
import android.app.ProgressDialog;
-import android.content.BroadcastReceiver;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.IntentFilter;
+import android.content.*;
import android.os.Build;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.util.Log;
-
import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.MapStorage;
-import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
+import com.mapswithme.util.Config;
import com.mapswithme.util.Constants;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.concurrency.ThreadPool;
@@ -29,11 +23,7 @@ import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
public class StoragePathManager
{
@@ -58,6 +48,11 @@ public class StoragePathManager
void moveFilesFailed(int errorCode);
}
+ public interface OnStorageListChangedListener
+ {
+ void onStorageListChanged(List storageItems, int currentStorageIndex);
+ }
+
public static final int NO_ERROR = 0;
public static final int UNKNOWN_LITE_PRO_ERROR = 1;
public static final int IOEXCEPTION_ERROR = 2;
@@ -67,33 +62,32 @@ public class StoragePathManager
static final String TAG = StoragePathManager.class.getName();
- private static final String IS_KML_PLACED_IN_MAIN_STORAGE = "KmlBeenMoved";
- private static final String IS_KITKAT_MIGRATION_COMPLETED = "KitKatMigrationCompleted";
- private BroadcastReceiver mExternalReceiver;
+ private OnStorageListChangedListener mStoragesChangedListener;
+ private MoveFilesListener mMoveFilesListener;
+
private BroadcastReceiver mInternalReceiver;
private Activity mActivity;
- private ArrayList mItems;
+ private List mItems;
private int mCurrentStorageIndex = -1;
- private MoveFilesListener mStorageListener;
/**
* Observes status of connected media and retrieves list of available external storages.
*/
- public void startExternalStorageWatching(Activity activity, @Nullable BroadcastReceiver receiver, @Nullable MoveFilesListener listener)
+ public void startExternalStorageWatching(Activity activity, final @Nullable OnStorageListChangedListener storagesChangedListener, @Nullable MoveFilesListener moveFilesListener)
{
mActivity = activity;
- mStorageListener = listener;
- mExternalReceiver = receiver;
+ mStoragesChangedListener = storagesChangedListener;
+ mMoveFilesListener = moveFilesListener;
mInternalReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
- if (mExternalReceiver != null)
- mExternalReceiver.onReceive(context, intent);
-
updateExternalStorages();
+
+ if (mStoragesChangedListener != null)
+ mStoragesChangedListener.onStorageListChanged(mItems, mCurrentStorageIndex);
}
};
@@ -124,7 +118,7 @@ public class StoragePathManager
{
mActivity.unregisterReceiver(mInternalReceiver);
mInternalReceiver = null;
- mExternalReceiver = null;
+ mStoragesChangedListener = null;
}
}
@@ -133,7 +127,7 @@ public class StoragePathManager
return mItems.size() > 1;
}
- public ArrayList getStorageItems()
+ public List getStorageItems()
{
return mItems;
}
@@ -296,16 +290,16 @@ public class StoragePathManager
public void moveFilesFinished(String newPath)
{
updateExternalStorages();
- if (mStorageListener != null)
- mStorageListener.moveFilesFinished(newPath);
+ if (mMoveFilesListener != null)
+ mMoveFilesListener.moveFilesFinished(newPath);
}
@Override
public void moveFilesFailed(int errorCode)
{
updateExternalStorages();
- if (mStorageListener != null)
- mStorageListener.moveFilesFailed(errorCode);
+ if (mMoveFilesListener != null)
+ mMoveFilesListener.moveFilesFailed(errorCode);
}
}, item, oldItem, R.string.wait_several_minutes);
@@ -366,7 +360,7 @@ public class StoragePathManager
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
return;
- migrateBookmarks(activity, new MoveFilesListener()
+ migrateBookmarks(new MoveFilesListener()
{
@Override
public void moveFilesFinished(String newPath)
@@ -382,12 +376,11 @@ public class StoragePathManager
});
}
- private void migrateBookmarks(final Activity activity, final MoveFilesListener listener)
+ private void migrateBookmarks(final MoveFilesListener listener)
{
- if (MwmApplication.get().nativeGetBoolean(IS_KML_PLACED_IN_MAIN_STORAGE, false))
+ if (Config.isKmlMoved())
listener.moveFilesFinished("");
else
- {
ThreadPool.getStorage().execute(new Runnable()
{
@Override
@@ -402,7 +395,7 @@ public class StoragePathManager
{
if (res)
{
- MwmApplication.get().nativeSetBoolean(IS_KML_PLACED_IN_MAIN_STORAGE, true);
+ Config.setKmlMoved();
listener.moveFilesFinished("");
}
else
@@ -411,31 +404,28 @@ public class StoragePathManager
});
}
});
- }
}
private void migrateMaps(final Activity activity)
{
- if (MwmApplication.get().nativeGetBoolean(IS_KITKAT_MIGRATION_COMPLETED, false))
+ if (Config.isKitKatMigrationComplete())
return;
- checkExternalStoragePathOnKitkat(activity,
- new MoveFilesListener()
- {
- @Override
- public void moveFilesFinished(String newPath)
- {
- MwmApplication.get().nativeSetBoolean(IS_KITKAT_MIGRATION_COMPLETED, true);
- UiUtils.showAlertDialog(activity, R.string.kitkat_migrate_ok);
- }
+ checkExternalStoragePathOnKitkat(activity, new MoveFilesListener()
+ {
+ @Override
+ public void moveFilesFinished(String newPath)
+ {
+ Config.setKitKatMigrationComplete();
+ UiUtils.showAlertDialog(activity, R.string.kitkat_migrate_ok);
+ }
- @Override
- public void moveFilesFailed(int errorCode)
- {
- UiUtils.showAlertDialog(activity, R.string.kitkat_migrate_failed);
- }
- }
- );
+ @Override
+ public void moveFilesFailed(int errorCode)
+ {
+ UiUtils.showAlertDialog(activity, R.string.kitkat_migrate_failed);
+ }
+ });
}
private void setStoragePath(final Context context, final MoveFilesListener listener, final StorageItem newStorage,
diff --git a/android/src/com/mapswithme/maps/widget/BaseShadowController.java b/android/src/com/mapswithme/maps/widget/BaseShadowController.java
index 7b0ed2388d..bc2da85820 100644
--- a/android/src/com/mapswithme/maps/widget/BaseShadowController.java
+++ b/android/src/com/mapswithme/maps/widget/BaseShadowController.java
@@ -6,17 +6,16 @@ import android.view.View;
import android.view.ViewGroup;
import com.mapswithme.maps.R;
+import com.mapswithme.util.UiUtils;
-public abstract class BaseShadowController
+public abstract class BaseShadowController
{
// Shadow IDs
- public static final int TOP = 0;
- public static final int BOTTOM = 1;
+ protected static final int TOP = 0;
+ protected static final int BOTTOM = 1;
+ private final SparseArray mShadows = new SparseArray<>(1);
protected final V mList;
- protected final SparseArray mShadows = new SparseArray<>(1);
- protected ScrollListener mScrollListener;
-
public BaseShadowController(V list)
{
@@ -29,7 +28,7 @@ public abstract class BaseShadowController
addShadow(TOP, shadowId);
}
- public BaseShadowController addShadow(int id, @IdRes int shadowViewId)
+ protected BaseShadowController addShadow(int id, @IdRes int shadowViewId)
{
View shadow = ((ViewGroup)mList.getParent()).findViewById(shadowViewId);
if (shadow != null)
@@ -37,10 +36,9 @@ public abstract class BaseShadowController
return this;
}
- public BaseShadowController setScrollListener(ScrollListener scrollListener)
+ public BaseShadowController addBottomShadow()
{
- mScrollListener = scrollListener;
- return this;
+ return addShadow(BOTTOM, R.id.shadow_bottom);
}
public void updateShadows()
@@ -48,7 +46,7 @@ public abstract class BaseShadowController
for (int i = 0; i < mShadows.size(); i++)
{
int id = mShadows.keyAt(i);
- mShadows.get(id).setVisibility(shouldShowShadow(id) ? View.VISIBLE : View.GONE);
+ UiUtils.showIf(shouldShowShadow(id), mShadows.get(id));
}
}
diff --git a/android/src/com/mapswithme/maps/widget/ListShadowController.java b/android/src/com/mapswithme/maps/widget/ListShadowController.java
index 783e7d15be..1966954a12 100644
--- a/android/src/com/mapswithme/maps/widget/ListShadowController.java
+++ b/android/src/com/mapswithme/maps/widget/ListShadowController.java
@@ -3,7 +3,7 @@ package com.mapswithme.maps.widget;
import android.view.View;
import android.widget.AbsListView;
-public class ListShadowController extends BaseShadowController
+public class ListShadowController extends BaseShadowController
{
public ListShadowController(AbsListView list)
{
@@ -30,9 +30,10 @@ public class ListShadowController extends BaseShadowController mList.getHeight());
- }
- return false;
+ default:
+ throw new IllegalArgumentException("Invalid shadow id: " + id);
+ }
}
@Override
@@ -43,18 +44,12 @@ public class ListShadowController extends BaseShadowController 0)
+ {
+ mContentReady = true;
+ if (mListener != null)
+ mListener.onContentReady();
+ }
+ }
+}
diff --git a/android/src/com/mapswithme/maps/widget/RoutingLayout.java b/android/src/com/mapswithme/maps/widget/RoutingLayout.java
index c0874ddeed..72c036a2fe 100644
--- a/android/src/com/mapswithme/maps/widget/RoutingLayout.java
+++ b/android/src/com/mapswithme/maps/widget/RoutingLayout.java
@@ -18,16 +18,15 @@ import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
-
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.LocationState;
-import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut;
import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.routing.RoutingInfo;
import com.mapswithme.maps.routing.RoutingResultCodesProcessor;
+import com.mapswithme.util.Config;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.statistics.AlohaHelper;
@@ -39,8 +38,6 @@ import java.util.concurrent.TimeUnit;
*/
public class RoutingLayout extends RelativeLayout implements View.OnClickListener
{
- private static final String IS_ROUTING_DISCLAIMER_APPROVED = "IsDisclaimerApproved";
-
private WheelProgressView mWvProgress;
private TextView mTvPlanning;
private View mIvCancelRouteBuild;
@@ -387,11 +384,12 @@ public class RoutingLayout extends RelativeLayout implements View.OnClickListene
private void buildRoute()
{
- if (!MwmApplication.get().nativeGetBoolean(IS_ROUTING_DISCLAIMER_APPROVED, false))
+ if (!Config.isRoutingDisclaimerAccepted())
{
showRoutingDisclaimer();
return;
}
+
if (!LocationState.isTurnedOn())
{
onMissingLocation();
@@ -435,7 +433,7 @@ public class RoutingLayout extends RelativeLayout implements View.OnClickListene
@Override
public void onClick(DialogInterface dlg, int which)
{
- MwmApplication.get().nativeSetBoolean(IS_ROUTING_DISCLAIMER_APPROVED, true);
+ Config.acceptRoutingDisclaimer();
dlg.dismiss();
buildRoute();
}
diff --git a/android/src/com/mapswithme/maps/widget/ScrollViewShadowController.java b/android/src/com/mapswithme/maps/widget/ScrollViewShadowController.java
index adc4585e84..03b5ccdfd1 100644
--- a/android/src/com/mapswithme/maps/widget/ScrollViewShadowController.java
+++ b/android/src/com/mapswithme/maps/widget/ScrollViewShadowController.java
@@ -2,8 +2,7 @@ package com.mapswithme.maps.widget;
import android.view.View;
-public class ScrollViewShadowController extends BaseShadowController
+public class ScrollViewShadowController extends BaseShadowController
{
public ScrollViewShadowController(ObservableScrollView list)
{
@@ -24,30 +23,22 @@ public class ScrollViewShadowController extends BaseShadowController
+{
+ public WebViewShadowController(ObservableWebView webView)
+ {
+ super(webView);
+ }
+
+ @Override
+ protected boolean shouldShowShadow(int id)
+ {
+ switch (id)
+ {
+ case TOP:
+ return (mList.getScrollY() > 0);
+
+ case BOTTOM:
+ return (mList.getScrollY() + mList.getHeight() < UiUtils.dp(mList.getContentHeight() - 1));
+
+ default:
+ throw new IllegalArgumentException("Invalid shadow id: " + id);
+ }
+ }
+
+ @Override
+ public BaseShadowController attach()
+ {
+ super.attach();
+ mList.setListener(new ObservableWebView.Listener()
+ {
+ @Override
+ public void onScroll(int left, int top)
+ {
+ updateShadows();
+ }
+
+ @Override
+ public void onContentReady()
+ {
+ updateShadows();
+ }
+ });
+
+ return this;
+ }
+
+ @Override
+ public void detach()
+ {
+ super.detach();
+ mList.setListener(null);
+ }
+}
diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
index 8026649d03..1680bc6be5 100644
--- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
+++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
@@ -219,7 +219,7 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
mRoutingButton = ppButtons.findViewById(R.id.ll__route);
mShadowController = new ScrollViewShadowController((ObservableScrollView) mPpDetails)
- .addShadow(BaseShadowController.BOTTOM, R.id.shadow_bottom)
+ .addBottomShadow()
.attach();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
diff --git a/android/src/com/mapswithme/util/Config.java b/android/src/com/mapswithme/util/Config.java
new file mode 100644
index 0000000000..1abeff704a
--- /dev/null
+++ b/android/src/com/mapswithme/util/Config.java
@@ -0,0 +1,249 @@
+package com.mapswithme.util;
+
+import android.support.v4.app.DialogFragment;
+import android.text.TextUtils;
+import android.text.format.DateUtils;
+import com.mapswithme.maps.BuildConfig;
+
+public final class Config
+{
+ private static final String KEY_APP_FIRST_INSTALL_VERSION = "FirstInstallVersion";
+ private static final String KEY_APP_LAUNCH_NUMBER = "LaunchNumber";
+ private static final String KEY_APP_SESSION_NUMBER = "SessionNumber";
+ private static final String KEY_APP_LAST_SESSION_TIMESTAMP = "LastSessionTimestamp";
+ private static final String KEY_APP_FIRST_INSTALL_FLAVOR = "FirstInstallFlavor";
+
+ private static final String KEY_PREF_ZOOM_BUTTONS = "ZoomButtonsEnabled";
+ private static final String KEY_PREF_STATISTICS = "StatisticsEnabled";
+
+ private static final String KEY_LIKES_RATED_DIALOG = "RatedDialog";
+ private static final String KEY_LIKES_LAST_RATED_SESSION = "LastRatedSession";
+
+ private static final String KEY_MISC_DISCLAIMER_ACCEPTED = "IsDisclaimerApproved";
+ private static final String KEY_MISC_KML_MOVED = "KmlBeenMoved";
+ private static final String KEY_MISC_KITKAT_MIGRATED = "KitKatMigrationCompleted";
+
+ private Config() {}
+
+ private static int getInt(String key)
+ {
+ return getInt(key, 0);
+ }
+
+ private static int getInt(String key, int def)
+ {
+ return nativeGetInt(key, def);
+ }
+
+ private static long getLong(String key)
+ {
+ return getLong(key, 0L);
+ }
+
+ private static long getLong(String key, long def)
+ {
+ return nativeGetLong(key, def);
+ }
+
+ private static String getString(String key)
+ {
+ return getString(key, "");
+ }
+
+ private static String getString(String key, String def)
+ {
+ return nativeGetString(key, def);
+ }
+
+ private static boolean getBool(String key)
+ {
+ return getBool(key, false);
+ }
+
+ private static boolean getBool(String key, boolean def)
+ {
+ return nativeGetBoolean(key, def);
+ }
+
+ private static void setInt(String key, int value)
+ {
+ nativeSetInt(key, value);
+ }
+
+ private static void setLong(String key, long value)
+ {
+ nativeSetLong(key, value);
+ }
+
+ private static void setString(String key, String value)
+ {
+ nativeSetString(key, value);
+ }
+
+ private static void setBool(String key)
+ {
+ setBool(key, true);
+ }
+
+ private static void setBool(String key, boolean value)
+ {
+ nativeSetBoolean(key, value);
+ }
+
+ /**
+ * Increments integer value.
+ * @return Previous value before increment.
+ */
+ private static int increment(String key)
+ {
+ int res = getInt(key);
+ setInt(key, res + 1);
+ return res;
+ }
+
+ public static int getFirstInstallVersion()
+ {
+ return getInt(KEY_APP_FIRST_INSTALL_VERSION);
+ }
+
+ /**
+ * Increments counter of app starts.
+ * @return Previous value before increment.
+ */
+ public static int incrementLaunchNumber()
+ {
+ return increment(KEY_APP_LAUNCH_NUMBER);
+ }
+
+ /**
+ * Session = single day, when app was started any number of times.
+ */
+ public static int getSessionCount()
+ {
+ return getInt(KEY_APP_SESSION_NUMBER);
+ }
+
+ private static void incrementSessionNumber()
+ {
+ long lastSessionTimestamp = getLong(KEY_APP_LAST_SESSION_TIMESTAMP);
+ if (!DateUtils.isToday(lastSessionTimestamp))
+ setLong(KEY_APP_LAST_SESSION_TIMESTAMP, System.currentTimeMillis());
+
+ increment(KEY_APP_SESSION_NUMBER);
+ }
+
+ public static void resetAppSessionCounters()
+ {
+ setInt(KEY_APP_LAUNCH_NUMBER, 0);
+ setInt(KEY_APP_SESSION_NUMBER, 0);
+ setLong(KEY_APP_LAST_SESSION_TIMESTAMP, 0L);
+ setInt(KEY_LIKES_LAST_RATED_SESSION, 0);
+ incrementSessionNumber();
+ }
+
+ public static String getInstallFlavor()
+ {
+ return getString(KEY_APP_FIRST_INSTALL_FLAVOR);
+ }
+
+ private static void updateInstallFlavor()
+ {
+ String installedFlavor = getInstallFlavor();
+ if (TextUtils.isEmpty(installedFlavor))
+ setString(KEY_APP_FIRST_INSTALL_FLAVOR, BuildConfig.FLAVOR);
+ }
+
+ public static void updateLaunchCounter()
+ {
+ if (incrementLaunchNumber() == 0)
+ {
+ if (getFirstInstallVersion() == 0)
+ setInt(KEY_APP_FIRST_INSTALL_VERSION, BuildConfig.VERSION_CODE);
+
+ updateInstallFlavor();
+ }
+
+ incrementSessionNumber();
+ }
+
+ public static boolean getShowZoomButtons()
+ {
+ return getBool(KEY_PREF_ZOOM_BUTTONS, true);
+ }
+
+ public static void setShowZoomButtons(boolean show)
+ {
+ setBool(KEY_PREF_ZOOM_BUTTONS, show);
+ }
+
+ public static boolean isStatisticsEnabled()
+ {
+ return getBool(KEY_PREF_STATISTICS, true);
+ }
+
+ public static void setStatisticsEnabled(boolean enabled)
+ {
+ setBool(KEY_PREF_STATISTICS, enabled);
+ }
+
+ public static boolean isRatingApplied(Class extends DialogFragment> dialogFragmentClass)
+ {
+ return getBool(KEY_LIKES_RATED_DIALOG + dialogFragmentClass.getSimpleName());
+ }
+
+ public static void setRatingApplied(Class extends DialogFragment> dialogFragmentClass)
+ {
+ setBool(KEY_LIKES_RATED_DIALOG + dialogFragmentClass.getSimpleName(), true);
+ }
+
+ public static boolean isSessionRated(int session)
+ {
+ return (getInt(KEY_LIKES_LAST_RATED_SESSION) >= session);
+ }
+
+ public static void setRatedSession(int session)
+ {
+ setInt(KEY_LIKES_LAST_RATED_SESSION, session);
+ }
+
+ public static boolean isRoutingDisclaimerAccepted()
+ {
+ return getBool(KEY_MISC_DISCLAIMER_ACCEPTED);
+ }
+
+ public static void acceptRoutingDisclaimer()
+ {
+ setBool(KEY_MISC_DISCLAIMER_ACCEPTED, true);
+ }
+
+ public static boolean isKmlMoved()
+ {
+ return getBool(KEY_MISC_KML_MOVED);
+ }
+
+ public static void setKmlMoved()
+ {
+ setBool(KEY_MISC_KML_MOVED);
+ }
+
+ public static boolean isKitKatMigrationComplete()
+ {
+ return getBool(KEY_MISC_KITKAT_MIGRATED);
+ }
+
+ public static void setKitKatMigrationComplete()
+ {
+ setBool(KEY_MISC_KITKAT_MIGRATED);
+ }
+
+ private static native boolean nativeGetBoolean(String name, boolean defaultValue);
+ private static native void nativeSetBoolean(String name, boolean value);
+ private static native int nativeGetInt(String name, int defaultValue);
+ private static native void nativeSetInt(String name, int value);
+ private static native long nativeGetLong(String name, long defaultValue);
+ private static native void nativeSetLong(String name, long value);
+ private static native double nativeGetDouble(String name, double defaultValue);
+ private static native void nativeSetDouble(String name, double value);
+ private static native String nativeGetString(String name, String defaultValue);
+ private static native void nativeSetString(String name, String value);
+}
diff --git a/android/src/com/mapswithme/util/Constants.java b/android/src/com/mapswithme/util/Constants.java
index 763bbdafa2..0255a078b5 100644
--- a/android/src/com/mapswithme/util/Constants.java
+++ b/android/src/com/mapswithme/util/Constants.java
@@ -1,5 +1,7 @@
package com.mapswithme.util;
+import com.mapswithme.maps.BuildConfig;
+
public final class Constants
{
public static final String STORAGE_PATH = "/Android/data/%s/%s/";
@@ -23,13 +25,25 @@ public final class Constants
public static final String FB_MAPSME_COMMUNITY_NATIVE = "fb://profile/111923085594432";
public static final String TWITTER_MAPSME_HTTP = "https://twitter.com/MAPS_ME";
- public static final String MAIL_MAPSME_INFO = "android@maps.me";
- public static final String MAIL_MAPSME_SUBSCRIBE = "subscribe@maps.me";
- public static final String MAIL_MAPSME_RATING = "rating@maps.me";
+ public static final String WEB_SITE = "http://maps.me";
+ public static final String WEB_BLOG = "http://blog.maps.me";
+
+ public static final String COPYRIGHT = "file:///android_asset/copyright.html";
+ public static final String FAQ = "file:///android_asset/faq.html";
private Url() {}
}
+ public static class Email
+ {
+ public static final String FEEDBACK = "android@maps.me";
+ public static final String SUPPORT = BuildConfig.SUPPORT_MAIL;
+ public static final String SUBSCRIBE = "subscribe@maps.me";
+ public static final String RATING = "rating@maps.me";
+
+ private Email() {}
+ }
+
public static class Package
{
public static final String FB_PACKAGE = "com.facebook.katana";
diff --git a/android/src/com/mapswithme/util/FragmentListHelper.java b/android/src/com/mapswithme/util/FragmentListHelper.java
new file mode 100644
index 0000000000..cc41f61d51
--- /dev/null
+++ b/android/src/com/mapswithme/util/FragmentListHelper.java
@@ -0,0 +1,59 @@
+package com.mapswithme.util;
+
+import android.app.Fragment;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Helper class to track fragments attached to Activity.
+ * Its primary goal is to implement getFragments() that is present in Support Library
+ * but is missed in native FragmentManager.
+ *
+ *
+ * Usage:
+ *
+ * - Create instance of FragmentListHelper in your Activity.
+ * - Override {@link android.app.Activity#onAttachFragment(Fragment)} in your Activity and call {@link FragmentListHelper#onAttachFragment(Fragment)}.
+ * - Call {@link FragmentListHelper#getFragments()} to obtain list of fragments currently added to your Activity.
+ *
+ */
+public class FragmentListHelper
+{
+ private final Map> mFragments = new HashMap<>();
+
+ public void onAttachFragment(Fragment fragment)
+ {
+ mFragments.put(fragment.getClass().getName(), new WeakReference<>(fragment));
+ }
+
+ public List getFragments()
+ {
+ List toRemove = null;
+
+ List res = new ArrayList<>(mFragments.size());
+ for (String key : mFragments.keySet())
+ {
+ Fragment f = mFragments.get(key).get();
+ if (f == null || !f.isAdded())
+ {
+ if (toRemove == null)
+ toRemove = new ArrayList<>();
+
+ toRemove.add(key);
+ continue;
+ }
+
+ res.add(f);
+ }
+
+ if (toRemove != null)
+ for (String key : toRemove)
+ mFragments.remove(key);
+
+ return res;
+ }
+}
diff --git a/android/src/com/mapswithme/util/Utils.java b/android/src/com/mapswithme/util/Utils.java
index 6f13c5a80e..0c09095616 100644
--- a/android/src/com/mapswithme/util/Utils.java
+++ b/android/src/com/mapswithme/util/Utils.java
@@ -268,8 +268,8 @@ public class Utils
{
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(Intent.EXTRA_EMAIL, new String[]{BuildConfig.SUPPORT_MAIL});
- intent.putExtra(Intent.EXTRA_SUBJECT, "[android] " + subject);
+ intent.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.Email.SUPPORT });
+ intent.putExtra(Intent.EXTRA_SUBJECT, "[" + BuildConfig.VERSION_NAME + "] " + subject);
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + Utils.saveLogToFile()));
intent.putExtra(Intent.EXTRA_TEXT, ""); // do this so some email clients don't complain about empty body.
intent.setType("message/rfc822");
diff --git a/android/src/com/mapswithme/util/statistics/AlohaHelper.java b/android/src/com/mapswithme/util/statistics/AlohaHelper.java
index 62ef7035db..b8175d18bd 100644
--- a/android/src/com/mapswithme/util/statistics/AlohaHelper.java
+++ b/android/src/com/mapswithme/util/statistics/AlohaHelper.java
@@ -19,17 +19,22 @@ public class AlohaHelper
org.alohalytics.Statistics.logEvent(ALOHA_EXCEPTION, new String[] {e.getClass().getSimpleName(), e.getMessage()});
}
- public static final String SETTINGS_CONTACT_US = "contactUs";
- public static final String SETTINGS_MAIL_SUBSCRIBE = "subscribeToNews";
- public static final String SETTINGS_REPORT_BUG = "reportABug";
- public static final String SETTINGS_RATE = "rate";
- public static final String SETTINGS_FB = "likeOnFb";
- public static final String SETTINGS_TWITTER = "followOnTwitter";
- public static final String SETTINGS_HELP = "help";
- public static final String SETTINGS_ABOUT = "about";
- public static final String SETTINGS_COPYRIGHT = "copyright";
- public static final String SETTINGS_COMMUNITY = "community";
- public static final String SETTINGS_CHANGE_UNITS = "settingsMiles";
+ public static class Settings
+ {
+ public static final String WEB_SITE = "webSite";
+ public static final String WEB_BLOG = "webBlog";
+ public static final String FEEDBACK_GENERAL = "generalFeedback";
+ public static final String MAIL_SUBSCRIBE = "subscribeToNews";
+ public static final String REPORT_BUG = "reportABug";
+ public static final String RATE = "rate";
+ public static final String FACEBOOK = "likeOnFb";
+ public static final String TWITTER = "followOnTwitter";
+ public static final String HELP = "help";
+ public static final String ABOUT = "about";
+ public static final String COPYRIGHT = "copyright";
+ public static final String CHANGE_UNITS = "settingsMiles";
+ }
+
// for aloha stats
public static final String ALOHA_CLICK = "$onClick";
public static final String ALOHA_LONG_CLICK = "$onLongClick";
diff --git a/android/src/com/mapswithme/util/statistics/Statistics.java b/android/src/com/mapswithme/util/statistics/Statistics.java
index 2af55d82a4..6cedb20d82 100644
--- a/android/src/com/mapswithme/util/statistics/Statistics.java
+++ b/android/src/com/mapswithme/util/statistics/Statistics.java
@@ -10,6 +10,7 @@ import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.PrivateVariables;
import com.mapswithme.maps.api.ParsedMwmRequest;
+import com.mapswithme.util.Config;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.SimpleLogger;
import com.mapswithme.util.log.StubLogger;
@@ -23,8 +24,6 @@ public enum Statistics
{
INSTANCE;
- private final static String KEY_STAT_ENABLED = "StatisticsEnabled";
-
private final Logger mLogger = BuildConfig.DEBUG ? SimpleLogger.get("MwmStatistics") : StubLogger.get();
// Statistics counters
@@ -48,18 +47,24 @@ public enum Statistics
public static final String WIFI_CONNECTED = "Wifi connected";
public static final String DOWNLOAD_COUNTRY_NOTIFICATION_SHOWN = "Download country notification shown";
public static final String DOWNLOAD_COUNTRY_NOTIFICATION_CLICKED = "Download country notification clicked";
- // settings
- public static final String SETTINGS_CONTACT_US = "Send mail at info@maps.me";
- public static final String SETTINGS_MAIL_SUBSCRIBE = "Settings. Subscribed";
- public static final String SETTINGS_REPORT_BUG = "Settings. Bug reported";
- public static final String SETTINGS_RATE = "Settings. Rate app called";
- public static final String SETTINGS_FB = "Settings. Go to FB.";
- public static final String SETTINGS_TWITTER = "Settings. Go to twitter.";
- public static final String SETTINGS_HELP = "Settings. Help.";
- public static final String SETTINGS_ABOUT = "Settings. About.";
- public static final String SETTINGS_COPYRIGHT = "Settings. Copyright.";
- public static final String SETTINGS_COMMUNITY = "Settings. Community.";
- public static final String SETTINGS_CHANGE_SETTING = "Settings. Change settings.";
+
+ public static class Settings
+ {
+ public static final String WEB_SITE = "Setings. Go to website";
+ public static final String WEB_BLOG = "Setings. Go to blog";
+ public static final String FEEDBACK_GENERAL = "Send general feedback to android@maps.me";
+ public static final String SUBSCRIBE = "Settings. Subscribed";
+ public static final String REPORT_BUG = "Settings. Bug reported";
+ public static final String RATE = "Settings. Rate app called";
+ public static final String FACEBOOK = "Settings. Go to FB.";
+ public static final String TWITTER = "Settings. Go to twitter.";
+ public static final String HELP = "Settings. Help.";
+ public static final String ABOUT = "Settings. About.";
+ public static final String COPYRIGHT = "Settings. Copyright.";
+ public static final String GROUP_MAP = "Settings. Group: map.";
+ public static final String GROUP_MISC = "Settings. Group: misc.";
+ }
+
public static final String SEARCH_KEY_CLICKED = "Search key pressed.";
public static final String SEARCH_ON_MAP_CLICKED = "Search on map clicked.";
public static final String STATISTICS_STATUS_CHANGED = "Statistics status changed";
@@ -101,7 +106,7 @@ public enum Statistics
Statistics()
{
- mEnabled = isStatisticsEnabled();
+ mEnabled = Config.isStatisticsEnabled();
final Context context = MwmApplication.get();
// At the moment we need special handling for Alohalytics to enable/disable logging of events in core C++ code.
if (mEnabled)
@@ -292,19 +297,13 @@ public enum Statistics
}
}
- // This method is used to display user setting's preference and initialize
- // actual state of statistics (see mEnabled in constructor).
- public boolean isStatisticsEnabled()
- {
- return MwmApplication.get().nativeGetBoolean(KEY_STAT_ENABLED, !BuildConfig.DEBUG);
- }
-
public void setStatEnabled(boolean isEnabled)
{
- final MwmApplication theApp = MwmApplication.get();
- // We track if user turned on/off statistics to understand data better.
- post(EventName.STATISTICS_STATUS_CHANGED + " " + theApp.getFirstInstallFlavor(),
- new String[]{EventParam.ENABLED, String.valueOf(isEnabled)});
- theApp.nativeSetBoolean(KEY_STAT_ENABLED, isEnabled);
+ Config.setStatisticsEnabled(isEnabled);
+
+ // We track if user turned on/off
+ // statistics to understand data better.
+ post(EventName.STATISTICS_STATUS_CHANGED + " " + Config.getInstallFlavor(),
+ new String[] { EventParam.ENABLED, String.valueOf(isEnabled) });
}
}