forked from organicmaps/organicmaps
[android] Refactoring and fixes.
This commit is contained in:
parent
ccf1aabc90
commit
1a20301cbd
40 changed files with 476 additions and 541 deletions
|
@ -51,7 +51,7 @@
|
|||
android:xlargeScreens="true"/>
|
||||
|
||||
<application
|
||||
android:name="com.mapswithme.maps.MWMApplication"
|
||||
android:name=".MwmApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
|
@ -169,7 +169,7 @@
|
|||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.mapswithme.maps.MWMActivity"
|
||||
android:name="com.mapswithme.maps.MwmActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/MwmTheme.Map"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan">
|
||||
|
@ -179,45 +179,45 @@
|
|||
android:name="com.mapswithme.country.DownloadActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:label="@string/download_maps"
|
||||
android:parentActivityName="com.mapswithme.maps.MWMActivity">
|
||||
android:parentActivityName="com.mapswithme.maps.MwmActivity">
|
||||
<!-- The meta-data element is needed for versions lower than 4.1 -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapswithme.maps.MWMActivity"/>
|
||||
android:value="com.mapswithme.maps.MwmActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.mapswithme.maps.search.SearchActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:label="@string/search_map"
|
||||
android:parentActivityName="com.mapswithme.maps.MWMActivity"
|
||||
android:parentActivityName="com.mapswithme.maps.MwmActivity"
|
||||
android:windowSoftInputMode="stateVisible|adjustResize">
|
||||
<!-- The meta-data element is needed for versions lower than 4.1 -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapswithme.maps.MWMActivity"/>
|
||||
android:value="com.mapswithme.maps.MwmActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.mapswithme.maps.settings.SettingsActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:label="@string/settings_and_more"
|
||||
android:parentActivityName="com.mapswithme.maps.MWMActivity">
|
||||
android:parentActivityName="com.mapswithme.maps.MwmActivity">
|
||||
<!-- The meta-data element is needed for versions lower than 4.1 -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapswithme.maps.MWMActivity"/>
|
||||
android:value="com.mapswithme.maps.MwmActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.mapswithme.maps.settings.StoragePathActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:label="@string/maps_storage"
|
||||
android:parentActivityName="com.mapswithme.maps.MWMActivity">
|
||||
android:parentActivityName="com.mapswithme.maps.MwmActivity">
|
||||
<!-- The meta-data element is needed for versions lower than 4.1 -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapswithme.maps.MWMActivity"/>
|
||||
android:value="com.mapswithme.maps.MwmActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
@ -232,11 +232,11 @@
|
|||
android:name="com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:label="@string/bookmarks"
|
||||
android:parentActivityName="com.mapswithme.maps.MWMActivity">
|
||||
android:parentActivityName="com.mapswithme.maps.MwmActivity">
|
||||
<!-- The meta-data element is needed for versions lower than 4.1 -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapswithme.maps.MWMActivity"/>
|
||||
android:value="com.mapswithme.maps.MwmActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
android:xlargeScreens="true" />
|
||||
|
||||
<application
|
||||
android:name="com.mapswithme.maps.MWMApplication"
|
||||
android:name="com.mapswithme.maps.MwmApplication"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/MwmTheme.Main" >
|
||||
|
@ -140,7 +140,7 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.mapswithme.maps.MWMActivity"
|
||||
android:name="com.mapswithme.maps.MwmActivity"
|
||||
android:configChanges="orientation|screenLayout|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTask"
|
||||
|
|
|
@ -9,8 +9,8 @@ import android.content.Intent;
|
|||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapswithme.maps.MWMActivity;
|
||||
import com.mapswithme.maps.MWMActivity.MapTask;
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.MwmActivity.MapTask;
|
||||
import com.mapswithme.maps.search.SearchActivity;
|
||||
import com.mapswithme.maps.bookmarks.data.Bookmark;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
|
||||
|
@ -32,8 +32,8 @@ public class MonkeyEventsReceiver extends BroadcastReceiver
|
|||
{
|
||||
mapTask = mapTask.extract(intent);
|
||||
sLogger.d(mapTask.toString());
|
||||
intent = new Intent(context, MWMActivity.class);
|
||||
intent.putExtra(MWMActivity.EXTRA_TASK, mapTask);
|
||||
intent = new Intent(context, MwmActivity.class);
|
||||
intent.putExtra(MwmActivity.EXTRA_TASK, mapTask);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class MonkeyEventsReceiver extends BroadcastReceiver
|
|||
int mScope;
|
||||
|
||||
@Override
|
||||
public boolean run(final MWMActivity target)
|
||||
public boolean run(final MwmActivity target)
|
||||
{
|
||||
sLogger.d("Running me!", this, target);
|
||||
target.onMyPositionClicked(null);
|
||||
|
@ -115,7 +115,7 @@ public class MonkeyEventsReceiver extends BroadcastReceiver
|
|||
String mName;
|
||||
|
||||
@Override
|
||||
public boolean run(final MWMActivity target)
|
||||
public boolean run(final MwmActivity target)
|
||||
{
|
||||
final int categoriesCount = BookmarkManager.INSTANCE.getCategoriesCount();
|
||||
|
||||
|
@ -138,12 +138,12 @@ public class MonkeyEventsReceiver extends BroadcastReceiver
|
|||
|
||||
class ShowBmkRunnable implements Runnable
|
||||
{
|
||||
MWMActivity mActivity;
|
||||
MwmActivity mActivity;
|
||||
int mBmkId;
|
||||
int mCatId;
|
||||
int mMaxCount;
|
||||
|
||||
public ShowBmkRunnable(MWMActivity activity, int bmk, int cat, int count)
|
||||
public ShowBmkRunnable(MwmActivity activity, int bmk, int cat, int count)
|
||||
{
|
||||
mActivity = activity;
|
||||
mBmkId = bmk;
|
||||
|
@ -156,7 +156,7 @@ public class MonkeyEventsReceiver extends BroadcastReceiver
|
|||
{
|
||||
sLogger.d("Step!");
|
||||
// bring foreground
|
||||
mActivity.startActivity(new Intent(mActivity, MWMActivity.class));
|
||||
mActivity.startActivity(new Intent(mActivity, MwmActivity.class));
|
||||
|
||||
final Bookmark bookmark = BookmarkManager.INSTANCE.getBookmark(mCatId, mBmkId);
|
||||
final BookmarkCategory category = BookmarkManager.INSTANCE.getCategoryById(mCatId);
|
||||
|
|
|
@ -84,7 +84,7 @@ LOCAL_SRC_FILES := \
|
|||
com/mapswithme/maps/sound/tts.cpp \
|
||||
com/mapswithme/maps/VideoTimer.cpp \
|
||||
com/mapswithme/maps/MapFragment.cpp \
|
||||
com/mapswithme/maps/MWMApplication.cpp \
|
||||
com/mapswithme/maps/MwmApplication.cpp \
|
||||
com/mapswithme/maps/Lifecycle.cpp \
|
||||
com/mapswithme/maps/LocationState.cpp \
|
||||
com/mapswithme/maps/MapStorage.cpp \
|
||||
|
|
|
@ -256,7 +256,7 @@ extern "C"
|
|||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_mapswithme_maps_DownloadResourcesActivity_loadKMZFile(
|
||||
Java_com_mapswithme_maps_DownloadResourcesActivity_loadKmzFile(
|
||||
JNIEnv * env, jobject thiz, jstring path)
|
||||
{
|
||||
return g_framework->NativeFramework()->AddBookmarksFile(jni::ToNativeString(env, path));
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
extern "C"
|
||||
{
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMApplication_nativeInit(
|
||||
Java_com_mapswithme_maps_MwmApplication_nativeInit(
|
||||
JNIEnv * env, jobject thiz,
|
||||
jstring apkPath, jstring storagePath, jstring tmpPath, jstring obbGooglePath,
|
||||
jstring flavorName, jstring buildType, jboolean isYota, jboolean isTablet)
|
||||
|
@ -37,13 +37,13 @@ extern "C"
|
|||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_mapswithme_maps_MWMApplication_nativeIsBenchmarking(JNIEnv * env, jobject thiz)
|
||||
Java_com_mapswithme_maps_MwmApplication_nativeIsBenchmarking(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
return static_cast<jboolean>(g_framework->NativeFramework()->IsBenchmarking());
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_mapswithme_maps_MWMApplication_nativeGetBoolean(JNIEnv * env,
|
||||
Java_com_mapswithme_maps_MwmApplication_nativeGetBoolean(JNIEnv * env,
|
||||
jobject thiz,
|
||||
jstring name,
|
||||
jboolean defaultVal)
|
||||
|
@ -54,7 +54,7 @@ extern "C"
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMApplication_nativeSetBoolean(JNIEnv * env,
|
||||
Java_com_mapswithme_maps_MwmApplication_nativeSetBoolean(JNIEnv * env,
|
||||
jobject thiz,
|
||||
jstring name,
|
||||
jboolean val)
|
||||
|
@ -64,20 +64,20 @@ extern "C"
|
|||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_mapswithme_maps_MWMApplication_hasFreeSpace(JNIEnv * env, jobject thiz, jlong size)
|
||||
Java_com_mapswithme_maps_MwmApplication_hasFreeSpace(JNIEnv * env, jobject thiz, jlong size)
|
||||
{
|
||||
return android::Platform::Instance().HasAvailableSpaceForWriting(size);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMApplication_nativeAddLocalization(JNIEnv * env, jobject thiz, jstring name, jstring value)
|
||||
Java_com_mapswithme_maps_MwmApplication_nativeAddLocalization(JNIEnv * env, jobject thiz, jstring name, jstring value)
|
||||
{
|
||||
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)
|
||||
Java_com_mapswithme_maps_MwmApplication_nativeGetInt(JNIEnv * env, jobject thiz, jstring name, jint defaultValue)
|
||||
{
|
||||
jint value;
|
||||
if (Settings::Get(jni::ToNativeString(env, name), value))
|
||||
|
@ -87,13 +87,13 @@ extern "C"
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMApplication_nativeSetInt(JNIEnv * env, jobject thiz, jstring name, jint value)
|
||||
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)
|
||||
Java_com_mapswithme_maps_MwmApplication_nativeGetLong(JNIEnv * env, jobject thiz, jstring name, jlong defaultValue)
|
||||
{
|
||||
jlong value;
|
||||
if (Settings::Get(jni::ToNativeString(env, name), value))
|
||||
|
@ -103,13 +103,13 @@ extern "C"
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMApplication_nativeSetLong(JNIEnv * env, jobject thiz, jstring name, jlong value)
|
||||
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)
|
||||
Java_com_mapswithme_maps_MwmApplication_nativeGetDouble(JNIEnv * env, jobject thiz, jstring name, jdouble defaultValue)
|
||||
{
|
||||
jdouble value;
|
||||
if (Settings::Get(jni::ToNativeString(env, name), value))
|
||||
|
@ -119,19 +119,19 @@ extern "C"
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMApplication_nativeSetDouble(JNIEnv * env, jobject thiz, jstring name, jdouble value)
|
||||
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)
|
||||
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)
|
||||
Java_com_mapswithme_maps_MwmApplication_nativeGetString(JNIEnv * env, jobject thiz, jstring name, jstring defaultValue)
|
||||
{
|
||||
string value;
|
||||
if (Settings::Get(jni::ToNativeString(env, name), value))
|
62
android/res/layout/activity_download_resources.xml
Normal file
62
android/res/layout/activity_download_resources.xml
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv__download_message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dip"
|
||||
android:drawableLeft="@drawable/ic_launcher"
|
||||
android:drawablePadding="@dimen/margin_base"
|
||||
android:padding="@dimen/margin_half"
|
||||
android:text="@string/download_resources"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body2"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/pb__download_resources"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/margin_base_plus"
|
||||
android:indeterminate="false"
|
||||
android:minWidth="200dip"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn__download_resources"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/margin_base_plus"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body1"
|
||||
tools:text="@string/download"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv__location"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/margin_base_plus"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/getting_position"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body2"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/chb__download_country"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/margin_base_plus"
|
||||
android:text="@string/download_country_ask"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body2"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
|
@ -1,76 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<!--
|
||||
<ImageView
|
||||
android:id="@+id/download_resources_logo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="20dip"
|
||||
android:src="@drawable/ic_launcher" />
|
||||
-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/download_resources_message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="20dip"
|
||||
android:drawableLeft="@drawable/ic_launcher"
|
||||
android:drawablePadding="10dp"
|
||||
android:gravity="center"
|
||||
android:padding="10dp"
|
||||
android:text="@string/download_resources"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/download_resources_progress"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="20dip"
|
||||
android:indeterminate="false"
|
||||
android:minWidth="200dip" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/download_resources_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="20dip"
|
||||
android:gravity="center"
|
||||
android:textSize="12sp"
|
||||
android:width="120dip" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/download_resources_location_message"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="20dip"
|
||||
android:gravity="center"
|
||||
android:text="@string/getting_position"
|
||||
android:textSize="16sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/download_country_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dip"
|
||||
android:text="@string/download_country_ask"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
|
@ -16,22 +16,22 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.mapswithme.country.StorageOptions;
|
||||
import com.mapswithme.maps.MWMActivity.MapTask;
|
||||
import com.mapswithme.maps.MWMActivity.OpenUrlTask;
|
||||
import com.mapswithme.maps.MapStorage.Index;
|
||||
import com.mapswithme.maps.MwmActivity.MapTask;
|
||||
import com.mapswithme.maps.MwmActivity.OpenUrlTask;
|
||||
import com.mapswithme.maps.api.Const;
|
||||
import com.mapswithme.maps.api.ParsedMwmRequest;
|
||||
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
import com.mapswithme.util.Constants;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.Yota;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
|
@ -50,16 +50,14 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
private static final int ERR_NO_MORE_FILES = -5;
|
||||
private static final int ERR_FILE_IN_PROGRESS = -6;
|
||||
|
||||
private MWMApplication mApplication = null;
|
||||
private MapStorage mMapStorage = null;
|
||||
private int mSlotId = 0;
|
||||
private TextView mMsgView = null;
|
||||
private TextView mLocationMsgView = null;
|
||||
private ProgressBar mProgress = null;
|
||||
private Button mButton = null;
|
||||
private CheckBox mDownloadCountryCheckBox = null;
|
||||
private Index mCountryIndex = null;
|
||||
private TextView mTvMessage;
|
||||
private TextView mTvLocation;
|
||||
private ProgressBar mProgress;
|
||||
private Button mBtnDownload;
|
||||
private CheckBox mChbDownloadCountry;
|
||||
|
||||
private int mStorageSlotId;
|
||||
private Index mCountryIndex;
|
||||
private MapTask mMapTaskToForward;
|
||||
|
||||
private static final int DOWNLOAD = 0;
|
||||
|
@ -69,8 +67,8 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
private static final int PROCEED_TO_MAP = 4;
|
||||
private static final int BTN_COUNT = 5;
|
||||
|
||||
private View.OnClickListener mBtnListeners[] = null;
|
||||
private String mBtnNames[] = null;
|
||||
private View.OnClickListener mBtnListeners[];
|
||||
private String mBtnNames[];
|
||||
|
||||
private final IntentProcessor[] mIntentProcessors = {
|
||||
new GeoIntentProcessor(),
|
||||
|
@ -83,18 +81,174 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
};
|
||||
|
||||
public static final String EXTRA_COUNTRY_INDEX = ".extra.index";
|
||||
public static final String EXTRA_AUTODOWNLOAD_CONTRY = ".extra.autodownload";
|
||||
public static final String EXTRA_AUTODOWNLOAD_COUNTRY = ".extra.autodownload";
|
||||
public static final String EXTRA_UPDATE_COUNTRIES = ".extra.update.countries";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Utils.keepScreenOn(true, getWindow());
|
||||
suggestRemoveLiteOrSamsung();
|
||||
|
||||
final boolean dispatched = dispatchIntent();
|
||||
if (!dispatched)
|
||||
parseIntentForKmzFile();
|
||||
|
||||
setContentView(R.layout.activity_download_resources);
|
||||
initViewsAndListeners();
|
||||
mStorageSlotId = MapStorage.INSTANCE.subscribe(this);
|
||||
|
||||
if (prepareFilesDownload())
|
||||
{
|
||||
setAction(DOWNLOAD);
|
||||
|
||||
if (ConnectionState.isWifiConnected())
|
||||
onDownloadClicked(mBtnDownload);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
|
||||
LocationHelper.INSTANCE.addLocationListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
super.onPause();
|
||||
|
||||
LocationHelper.INSTANCE.removeLocationListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy()
|
||||
{
|
||||
super.onDestroy();
|
||||
|
||||
mProgress = null;
|
||||
MapStorage.INSTANCE.unsubscribe(mStorageSlotId);
|
||||
}
|
||||
|
||||
// TODO change communication with native thread so that it does not send us callbacks after activity destroy
|
||||
@SuppressWarnings("unused")
|
||||
public void onDownloadProgress(int currentTotal, int currentProgress, int globalTotal, int globalProgress)
|
||||
{
|
||||
if (mProgress != null)
|
||||
mProgress.setProgress(globalProgress);
|
||||
}
|
||||
|
||||
// TODO change communication with native thread so that it does not send us callbacks after activity destroy
|
||||
@SuppressWarnings("unused")
|
||||
public void onDownloadFinished(int errorCode)
|
||||
{
|
||||
if (errorCode == ERR_DOWNLOAD_SUCCESS)
|
||||
{
|
||||
final int res = startNextFileDownload(this);
|
||||
if (res == ERR_NO_MORE_FILES)
|
||||
finishFilesDownload(res);
|
||||
}
|
||||
else
|
||||
finishFilesDownload(errorCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationUpdated(final Location l)
|
||||
{
|
||||
if (mCountryIndex != null)
|
||||
return;
|
||||
|
||||
final double lat = l.getLatitude();
|
||||
final double lon = l.getLongitude();
|
||||
Log.i(TAG, "Searching for country name at location lat=" + lat + ", lon=" + lon);
|
||||
|
||||
mCountryIndex = Framework.nativeGetCountryIndex(lat, lon);
|
||||
if (mCountryIndex == null)
|
||||
return;
|
||||
|
||||
UiUtils.show(mTvLocation);
|
||||
|
||||
final int countryStatus = MapStorage.INSTANCE.countryStatus(mCountryIndex);
|
||||
final String name = MapStorage.INSTANCE.countryName(mCountryIndex);
|
||||
|
||||
if (countryStatus == MapStorage.ON_DISK)
|
||||
mTvLocation.setText(String.format(getString(R.string.download_location_map_up_to_date), name));
|
||||
else
|
||||
{
|
||||
final CheckBox checkBox = (CheckBox) findViewById(R.id.chb__download_country);
|
||||
UiUtils.show(checkBox);
|
||||
|
||||
String locationText;
|
||||
String checkBoxText;
|
||||
|
||||
if (countryStatus == MapStorage.ON_DISK_OUT_OF_DATE)
|
||||
{
|
||||
locationText = getString(R.string.download_location_update_map_proposal);
|
||||
checkBoxText = String.format(getString(R.string.update_country_ask), name);
|
||||
}
|
||||
else
|
||||
{
|
||||
locationText = getString(R.string.download_location_map_proposal);
|
||||
checkBoxText = String.format(getString(R.string.download_country_ask), name);
|
||||
}
|
||||
|
||||
mTvLocation.setText(locationText);
|
||||
checkBox.setText(checkBoxText);
|
||||
}
|
||||
|
||||
LocationHelper.INSTANCE.removeLocationListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompassUpdated(long time, double magneticNorth, double trueNorth, double accuracy) {}
|
||||
|
||||
@Override
|
||||
public void onLocationError(int errorCode) {}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCountryStatusChanged(MapStorage.Index idx)
|
||||
{
|
||||
final int status = MapStorage.INSTANCE.countryStatus(idx);
|
||||
|
||||
if (status == MapStorage.ON_DISK)
|
||||
showMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCountryProgress(MapStorage.Index idx, long current, long total)
|
||||
{
|
||||
// Important check - activity can be destroyed
|
||||
// but notifications from downloading thread are coming.
|
||||
if (mProgress != null)
|
||||
mProgress.setProgress((int) current);
|
||||
}
|
||||
|
||||
private Intent getPackageIntent(String s)
|
||||
{
|
||||
return getPackageManager().getLaunchIntentForPackage(s);
|
||||
}
|
||||
|
||||
private void suggestRemoveLiteOrSamsung()
|
||||
{
|
||||
if (!Yota.isFirstYota() &&
|
||||
(Utils.isPackageInstalled(Constants.Package.MWM_LITE_PACKAGE) || Utils.isPackageInstalled(Constants.Package.MWM_SAMSUNG_PACKAGE)))
|
||||
Toast.makeText(this, R.string.suggest_uninstall_lite, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void setDownloadMessage(int bytesToDownload)
|
||||
{
|
||||
Log.d(TAG, "prepareFilesDownload, bytesToDownload:" + bytesToDownload);
|
||||
|
||||
if (bytesToDownload < Constants.MB)
|
||||
mMsgView.setText(String.format(getString(R.string.download_resources),
|
||||
mTvMessage.setText(String.format(getString(R.string.download_resources),
|
||||
(float) bytesToDownload / Constants.KB, getString(R.string.kb)));
|
||||
else
|
||||
mMsgView.setText(String.format(getString(R.string.download_resources),
|
||||
mTvMessage.setText(String.format(getString(R.string.download_resources),
|
||||
(float) bytesToDownload / Constants.MB, getString(R.string.mb)));
|
||||
|
||||
}
|
||||
|
@ -103,17 +257,12 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
{
|
||||
final int bytes = getBytesToDownload();
|
||||
|
||||
// Show map if no any downloading needed.
|
||||
if (bytes == 0)
|
||||
{
|
||||
showMapView();
|
||||
showMap();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Do initialization once.
|
||||
if (mMapStorage == null)
|
||||
initDownloading();
|
||||
|
||||
if (bytes > 0)
|
||||
{
|
||||
setDownloadMessage(bytes);
|
||||
|
@ -122,26 +271,19 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
mProgress.setProgress(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
finishFilesDownload(bytes);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void initDownloading()
|
||||
private void initViewsAndListeners()
|
||||
{
|
||||
// Get GUI elements and subscribe to map storage (for country downloading).
|
||||
mMapStorage = MapStorage.INSTANCE;
|
||||
mSlotId = mMapStorage.subscribe(this);
|
||||
mTvMessage = (TextView) findViewById(R.id.tv__download_message);
|
||||
mProgress = (ProgressBar) findViewById(R.id.pb__download_resources);
|
||||
mBtnDownload = (Button) findViewById(R.id.btn__download_resources);
|
||||
mChbDownloadCountry = (CheckBox) findViewById(R.id.chb__download_country);
|
||||
mTvLocation = (TextView) findViewById(R.id.tv__location);
|
||||
|
||||
mMsgView = (TextView) findViewById(R.id.download_resources_message);
|
||||
mProgress = (ProgressBar) findViewById(R.id.download_resources_progress);
|
||||
mButton = (Button) findViewById(R.id.download_resources_button);
|
||||
mDownloadCountryCheckBox = (CheckBox) findViewById(R.id.download_country_checkbox);
|
||||
mLocationMsgView = (TextView) findViewById(R.id.download_resources_location_message);
|
||||
|
||||
// Initialize button states.
|
||||
mBtnListeners = new View.OnClickListener[BTN_COUNT];
|
||||
mBtnNames = new String[BTN_COUNT];
|
||||
|
||||
|
@ -179,15 +321,12 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
public void onClick(View v) { onProceedToMapClicked(v); }
|
||||
};
|
||||
mBtnNames[PROCEED_TO_MAP] = getString(R.string.download_resources_continue);
|
||||
|
||||
// Start listening the location.
|
||||
LocationHelper.INSTANCE.addLocationListener(this);
|
||||
}
|
||||
|
||||
private void setAction(int action)
|
||||
{
|
||||
mButton.setOnClickListener(mBtnListeners[action]);
|
||||
mButton.setText(mBtnNames[action]);
|
||||
mBtnDownload.setOnClickListener(mBtnListeners[action]);
|
||||
mBtnDownload.setText(mBtnNames[action]);
|
||||
}
|
||||
|
||||
private void doDownload()
|
||||
|
@ -196,7 +335,7 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
finishFilesDownload(ERR_NO_MORE_FILES);
|
||||
}
|
||||
|
||||
public void onDownloadClicked(View v)
|
||||
private void onDownloadClicked(View v)
|
||||
{
|
||||
setAction(PAUSE);
|
||||
doDownload();
|
||||
|
@ -216,7 +355,6 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
|
||||
private void onTryAgainClicked(View v)
|
||||
{
|
||||
// Initialize downloading from the beginning.
|
||||
if (prepareFilesDownload())
|
||||
{
|
||||
setAction(PAUSE);
|
||||
|
@ -226,7 +364,7 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
|
||||
private void onProceedToMapClicked(View v)
|
||||
{
|
||||
showMapView();
|
||||
showMap();
|
||||
}
|
||||
|
||||
public String getErrorMessage(int res)
|
||||
|
@ -255,39 +393,36 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
return getString(id);
|
||||
}
|
||||
|
||||
public void showMapView()
|
||||
private void showMap()
|
||||
{
|
||||
// Continue with Main UI initialization (MWMActivity)
|
||||
final Intent mwmActivityIntent = new Intent(this, MWMActivity.class);
|
||||
final Intent intent = new Intent(this, MwmActivity.class);
|
||||
|
||||
// Disable animation because MWMActivity should appear exactly over this one
|
||||
// Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
|
||||
mwmActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
// Disable animation because MwmActivity should appear exactly over this one
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
// Add saved task to forward to map activity.
|
||||
if (mMapTaskToForward != null)
|
||||
{
|
||||
mwmActivityIntent.putExtra(MWMActivity.EXTRA_TASK, mMapTaskToForward);
|
||||
intent.putExtra(MwmActivity.EXTRA_TASK, mMapTaskToForward);
|
||||
mMapTaskToForward = null;
|
||||
}
|
||||
|
||||
startActivity(mwmActivityIntent);
|
||||
startActivity(intent);
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
public void finishFilesDownload(int result)
|
||||
private void finishFilesDownload(int result)
|
||||
{
|
||||
if (result == ERR_NO_MORE_FILES)
|
||||
{
|
||||
if (mCountryIndex != null && mDownloadCountryCheckBox.isChecked())
|
||||
if (mCountryIndex != null && mChbDownloadCountry.isChecked())
|
||||
{
|
||||
mDownloadCountryCheckBox.setVisibility(View.GONE);
|
||||
mLocationMsgView.setVisibility(View.GONE);
|
||||
mMsgView.setText(String.format(getString(R.string.downloading_country_can_proceed),
|
||||
mMapStorage.countryName(mCountryIndex)));
|
||||
UiUtils.hide(mChbDownloadCountry, mTvLocation);
|
||||
mTvMessage.setText(String.format(getString(R.string.downloading_country_can_proceed),
|
||||
MapStorage.INSTANCE.countryName(mCountryIndex)));
|
||||
|
||||
mProgress.setMax((int) mMapStorage.countryRemoteSizeInBytes(mCountryIndex, StorageOptions.MAP_OPTION_MAP_ONLY));
|
||||
mProgress.setMax((int) MapStorage.INSTANCE.countryRemoteSizeInBytes(mCountryIndex, StorageOptions.MAP_OPTION_MAP_ONLY));
|
||||
mProgress.setProgress(0);
|
||||
|
||||
Framework.downloadCountry(mCountryIndex);
|
||||
|
@ -295,78 +430,17 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
setAction(PROCEED_TO_MAP);
|
||||
}
|
||||
else
|
||||
showMapView();
|
||||
showMap();
|
||||
}
|
||||
else
|
||||
{
|
||||
mMsgView.setText(getErrorMessage(result));
|
||||
mMsgView.setTextColor(Color.RED);
|
||||
mTvMessage.setText(getErrorMessage(result));
|
||||
mTvMessage.setTextColor(Color.RED);
|
||||
|
||||
setAction(TRY_AGAIN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCountryStatusChanged(MapStorage.Index idx)
|
||||
{
|
||||
final int status = mMapStorage.countryStatus(idx);
|
||||
|
||||
if (status == MapStorage.ON_DISK)
|
||||
showMapView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCountryProgress(MapStorage.Index idx, long current, long total)
|
||||
{
|
||||
// Important check - activity can be destroyed
|
||||
// but notifications from downloading thread are coming.
|
||||
if (mProgress != null)
|
||||
mProgress.setProgress((int) current);
|
||||
}
|
||||
|
||||
private Intent getPackageIntent(String s)
|
||||
{
|
||||
return getPackageManager().getLaunchIntentForPackage(s);
|
||||
}
|
||||
|
||||
private boolean checkLiteProPackages()
|
||||
{
|
||||
if (!Yota.isFirstYota() &&
|
||||
(getPackageIntent(Constants.Package.MWM_LITE_PACKAGE) != null ||
|
||||
getPackageIntent(Constants.Package.MWM_SAMSUNG_PACKAGE) != null))
|
||||
Toast.makeText(this, R.string.suggest_uninstall_lite, Toast.LENGTH_LONG).show();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Do not turn off the screen while downloading needed resources
|
||||
getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
mApplication = (MWMApplication) getApplication();
|
||||
|
||||
if (checkLiteProPackages())
|
||||
return;
|
||||
|
||||
final boolean dispatched = dispatchIntent();
|
||||
if (!dispatched)
|
||||
parseIntentForKMZFile();
|
||||
|
||||
setContentView(R.layout.download_resources);
|
||||
|
||||
if (prepareFilesDownload())
|
||||
{
|
||||
setAction(DOWNLOAD);
|
||||
|
||||
if (ConnectionState.isWifiConnected())
|
||||
onDownloadClicked(mButton);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean dispatchIntent()
|
||||
{
|
||||
final Intent intent = getIntent();
|
||||
|
@ -400,180 +474,71 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
return null;
|
||||
}
|
||||
|
||||
private void parseIntentForKMZFile()
|
||||
private void parseIntentForKmzFile()
|
||||
{
|
||||
final Intent intent = getIntent();
|
||||
if (intent != null)
|
||||
if (intent == null)
|
||||
return;
|
||||
|
||||
final Uri data = intent.getData();
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
String path = null;
|
||||
File tmpFile = null;
|
||||
final String scheme = data.getScheme();
|
||||
if (scheme != null && !scheme.equalsIgnoreCase(Constants.Url.DATA_SCHEME_FILE))
|
||||
{
|
||||
final Uri data = intent.getData();
|
||||
if (data != null)
|
||||
// scheme is "content" or "http" - need to download file first
|
||||
InputStream input = null;
|
||||
OutputStream output = null;
|
||||
|
||||
try
|
||||
{
|
||||
String path = null;
|
||||
File tmpFile = null;
|
||||
final String scheme = data.getScheme();
|
||||
if (scheme != null && !scheme.equalsIgnoreCase(Constants.Url.DATA_SCHEME_FILE))
|
||||
final ContentResolver resolver = getContentResolver();
|
||||
final String ext = getExtensionFromMime(resolver.getType(data));
|
||||
if (ext != null)
|
||||
{
|
||||
// scheme is "content" or "http" - need to download file first
|
||||
InputStream input = null;
|
||||
OutputStream output = null;
|
||||
final String filePath = MwmApplication.get().getTempPath() + "Attachment" + ext;
|
||||
|
||||
try
|
||||
{
|
||||
final ContentResolver resolver = getContentResolver();
|
||||
final String ext = getExtensionFromMime(resolver.getType(data));
|
||||
if (ext != null)
|
||||
{
|
||||
final String filePath = mApplication.getTempPath() + "Attachment" + ext;
|
||||
tmpFile = new File(filePath);
|
||||
output = new FileOutputStream(tmpFile);
|
||||
input = resolver.openInputStream(data);
|
||||
|
||||
tmpFile = new File(filePath);
|
||||
output = new FileOutputStream(tmpFile);
|
||||
input = resolver.openInputStream(data);
|
||||
final byte buffer[] = new byte[Constants.MB / 2];
|
||||
int read;
|
||||
while ((read = input.read(buffer)) != -1)
|
||||
output.write(buffer, 0, read);
|
||||
output.flush();
|
||||
|
||||
final byte buffer[] = new byte[Constants.MB / 2];
|
||||
int read;
|
||||
while ((read = input.read(buffer)) != -1)
|
||||
output.write(buffer, 0, read);
|
||||
output.flush();
|
||||
|
||||
path = filePath;
|
||||
}
|
||||
} catch (final Exception ex)
|
||||
{
|
||||
Log.w(TAG, "Attachment not found or io error: " + ex);
|
||||
} finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (input != null)
|
||||
input.close();
|
||||
if (output != null)
|
||||
output.close();
|
||||
} catch (final IOException ex)
|
||||
{
|
||||
Log.w(TAG, "Close stream error: " + ex);
|
||||
}
|
||||
}
|
||||
path = filePath;
|
||||
}
|
||||
else
|
||||
path = data.getPath();
|
||||
|
||||
boolean success = false;
|
||||
if (path != null)
|
||||
{
|
||||
Log.d(TAG, "Loading bookmarks file from: " + path);
|
||||
success = loadKMZFile(path);
|
||||
}
|
||||
else
|
||||
Log.w(TAG, "Can't get bookmarks file from URI: " + data);
|
||||
|
||||
if (tmpFile != null)
|
||||
tmpFile.delete();
|
||||
|
||||
Utils.toastShortcut(this, success ? R.string.load_kmz_successful : R.string.load_kmz_failed);
|
||||
} catch (final Exception ex)
|
||||
{
|
||||
Log.w(TAG, "Attachment not found or io error: " + ex);
|
||||
} finally
|
||||
{
|
||||
Utils.closeStream(input);
|
||||
Utils.closeStream(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy()
|
||||
{
|
||||
super.onDestroy();
|
||||
|
||||
LocationHelper.INSTANCE.removeLocationListener(this);
|
||||
|
||||
if (mMapStorage != null)
|
||||
mMapStorage.unsubscribe(mSlotId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
super.onPause();
|
||||
|
||||
LocationHelper.INSTANCE.removeLocationListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
|
||||
LocationHelper.INSTANCE.addLocationListener(this);
|
||||
}
|
||||
|
||||
public void onDownloadProgress(int currentTotal, int currentProgress, int globalTotal, int globalProgress)
|
||||
{
|
||||
if (mProgress != null)
|
||||
mProgress.setProgress(globalProgress);
|
||||
}
|
||||
|
||||
public void onDownloadFinished(int errorCode)
|
||||
{
|
||||
if (errorCode == ERR_DOWNLOAD_SUCCESS)
|
||||
{
|
||||
final int res = startNextFileDownload(this);
|
||||
if (res == ERR_NO_MORE_FILES)
|
||||
finishFilesDownload(res);
|
||||
}
|
||||
else
|
||||
finishFilesDownload(errorCode);
|
||||
}
|
||||
path = data.getPath();
|
||||
|
||||
@Override
|
||||
public void onLocationUpdated(final Location l)
|
||||
{
|
||||
if (mCountryIndex == null)
|
||||
boolean success = false;
|
||||
if (path != null)
|
||||
{
|
||||
final double lat = l.getLatitude();
|
||||
final double lon = l.getLongitude();
|
||||
Log.i(TAG, "Searching for country name at location lat=" + lat + ", lon=" + lon);
|
||||
|
||||
mCountryIndex = Framework.nativeGetCountryIndex(lat, lon);
|
||||
if (mCountryIndex != null)
|
||||
{
|
||||
mLocationMsgView.setVisibility(View.VISIBLE);
|
||||
|
||||
final int countryStatus = mMapStorage.countryStatus(mCountryIndex);
|
||||
final String name = mMapStorage.countryName(mCountryIndex);
|
||||
|
||||
if (countryStatus == MapStorage.ON_DISK)
|
||||
mLocationMsgView.setText(String.format(getString(R.string.download_location_map_up_to_date), name));
|
||||
else
|
||||
{
|
||||
final CheckBox checkBox = (CheckBox) findViewById(R.id.download_country_checkbox);
|
||||
checkBox.setVisibility(View.VISIBLE);
|
||||
|
||||
String msgViewText;
|
||||
String checkBoxText;
|
||||
|
||||
if (countryStatus == MapStorage.ON_DISK_OUT_OF_DATE)
|
||||
{
|
||||
msgViewText = getString(R.string.download_location_update_map_proposal);
|
||||
checkBoxText = String.format(getString(R.string.update_country_ask), name);
|
||||
}
|
||||
else
|
||||
{
|
||||
msgViewText = getString(R.string.download_location_map_proposal);
|
||||
checkBoxText = String.format(getString(R.string.download_country_ask), name);
|
||||
}
|
||||
|
||||
mLocationMsgView.setText(msgViewText);
|
||||
checkBox.setText(checkBoxText);
|
||||
}
|
||||
|
||||
LocationHelper.INSTANCE.removeLocationListener(this);
|
||||
}
|
||||
Log.d(TAG, "Loading bookmarks file from: " + path);
|
||||
success = loadKmzFile(path);
|
||||
}
|
||||
}
|
||||
else
|
||||
Log.w(TAG, "Can't get bookmarks file from URI: " + data);
|
||||
|
||||
@Override
|
||||
public void onCompassUpdated(long time, double magneticNorth, double trueNorth, double accuracy)
|
||||
{
|
||||
}
|
||||
if (tmpFile != null)
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
tmpFile.delete();
|
||||
|
||||
@Override
|
||||
public void onLocationError(int errorCode)
|
||||
{
|
||||
Utils.toastShortcut(this, success ? R.string.load_kmz_successful : R.string.load_kmz_failed);
|
||||
}
|
||||
|
||||
private class GeoIntentProcessor implements IntentProcessor
|
||||
|
@ -666,7 +631,7 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
ParsedMwmRequest.setCurrentRequest(request);
|
||||
Statistics.INSTANCE.trackApiCall(request);
|
||||
|
||||
if (!request.isPickPointMode())
|
||||
if (!ParsedMwmRequest.isPickPointMode())
|
||||
mMapTaskToForward = new OpenUrlTask(apiUrl);
|
||||
return true;
|
||||
}
|
||||
|
@ -707,10 +672,10 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
public boolean processIntent(Intent intent)
|
||||
{
|
||||
final Index index = (Index) intent.getSerializableExtra(EXTRA_COUNTRY_INDEX);
|
||||
final boolean autoDownload = intent.getBooleanExtra(EXTRA_AUTODOWNLOAD_CONTRY, false);
|
||||
final boolean autoDownload = intent.getBooleanExtra(EXTRA_AUTODOWNLOAD_COUNTRY, false);
|
||||
if (autoDownload)
|
||||
Statistics.INSTANCE.trackDownloadCountryNotificationClicked();
|
||||
mMapTaskToForward = new MWMActivity.ShowCountryTask(index, autoDownload);
|
||||
mMapTaskToForward = new MwmActivity.ShowCountryTask(index, autoDownload);
|
||||
org.alohalytics.Statistics.logEvent("OpenCountryTaskProcessor::processIntent", new String[]{"autoDownload", String.valueOf(autoDownload)}, LocationHelper.INSTANCE.getLastLocation());
|
||||
return true;
|
||||
}
|
||||
|
@ -728,7 +693,7 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
public boolean processIntent(Intent intent)
|
||||
{
|
||||
org.alohalytics.Statistics.logEvent("UpdateCountryProcessor::processIntent");
|
||||
mMapTaskToForward = new MWMActivity.UpdateCountryTask();
|
||||
mMapTaskToForward = new MwmActivity.UpdateCountryTask();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -739,5 +704,5 @@ public class DownloadResourcesActivity extends BaseMwmFragmentActivity
|
|||
|
||||
private native void cancelCurrentFile();
|
||||
|
||||
private native boolean loadKMZFile(String path);
|
||||
private native boolean loadKmzFile(String path);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.Intent;
|
|||
|
||||
public interface IntentProcessor
|
||||
{
|
||||
public boolean isIntentSupported(Intent intent);
|
||||
boolean isIntentSupported(Intent intent);
|
||||
|
||||
public boolean processIntent(Intent intent);
|
||||
boolean processIntent(Intent intent);
|
||||
}
|
||||
|
|
|
@ -79,12 +79,12 @@ import com.mapswithme.util.statistics.Statistics;
|
|||
import java.io.Serializable;
|
||||
import java.util.Stack;
|
||||
|
||||
public class MWMActivity extends BaseMwmFragmentActivity
|
||||
public class MwmActivity extends BaseMwmFragmentActivity
|
||||
implements LocationHelper.LocationListener, OnBalloonListener, View.OnTouchListener, BasePlacePageAnimationController.OnVisibilityChangedListener,
|
||||
OnClickListener, Framework.RoutingListener, MapFragment.MapRenderingListener, CustomNavigateUpListener, Framework.RoutingProgressListener
|
||||
{
|
||||
public static final String EXTRA_TASK = "map_task";
|
||||
private final static String TAG = "MWMActivity";
|
||||
private final static String TAG = "MwmActivity";
|
||||
private final static String EXTRA_CONSUMED = "mwm.extra.intent.processed";
|
||||
private final static String EXTRA_SCREENSHOTS_TASK = "screenshots_task";
|
||||
private final static String SCREENSHOTS_TASK_LOCATE = "locate_task";
|
||||
|
@ -115,7 +115,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
private int mLocationStateModeListenerId = LocationState.SLOT_UNDEFINED;
|
||||
// These flags are initialized to the invalid combination to force update on the first check
|
||||
// after launching.
|
||||
// These flags are static because the MWMActivity is recreated while screen orientation changing
|
||||
// These flags are static because the MwmActivity is recreated while screen orientation changing
|
||||
// but they shall not be reinitialized on screen orientation changing.
|
||||
private static boolean mStorageAvailable = false;
|
||||
private static boolean mStorageWritable = true;
|
||||
|
@ -128,9 +128,6 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
private ImageButton mBtnZoomOut;
|
||||
private BottomButtonsLayout mBottomButtons;
|
||||
|
||||
private static final String IS_KML_MOVED = "KmlBeenMoved";
|
||||
private static final String IS_KITKAT_MIGRATION_COMPLETED = "KitKatMigrationCompleted";
|
||||
|
||||
private boolean mIsFragmentContainer;
|
||||
|
||||
private LocationPredictor mLocationPredictor;
|
||||
|
@ -141,12 +138,12 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
{
|
||||
return new Intent(context, DownloadResourcesActivity.class)
|
||||
.putExtra(DownloadResourcesActivity.EXTRA_COUNTRY_INDEX, index)
|
||||
.putExtra(DownloadResourcesActivity.EXTRA_AUTODOWNLOAD_CONTRY, doAutoDownload);
|
||||
.putExtra(DownloadResourcesActivity.EXTRA_AUTODOWNLOAD_COUNTRY, doAutoDownload);
|
||||
}
|
||||
|
||||
public static void setMapStyle(Context context, int mapStyle)
|
||||
{
|
||||
final Intent mapIntent = new Intent(context, MWMActivity.class);
|
||||
final Intent mapIntent = new Intent(context, MwmActivity.class);
|
||||
mapIntent.putExtra(EXTRA_SET_MAP_STYLE, mapStyle);
|
||||
context.startActivity(mapIntent);
|
||||
// Next we need to handle intent
|
||||
|
@ -154,7 +151,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
|
||||
public static void startSearch(Context context, String query)
|
||||
{
|
||||
final MWMActivity activity = (MWMActivity) context;
|
||||
final MwmActivity activity = (MwmActivity) context;
|
||||
if (activity.mIsFragmentContainer)
|
||||
activity.showSearch();
|
||||
else
|
||||
|
@ -163,7 +160,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
|
||||
public static Intent createUpdateMapsIntent()
|
||||
{
|
||||
return new Intent(MWMApplication.get(), DownloadResourcesActivity.class)
|
||||
return new Intent(MwmApplication.get(), DownloadResourcesActivity.class)
|
||||
.putExtra(DownloadResourcesActivity.EXTRA_UPDATE_COUNTRIES, true);
|
||||
}
|
||||
|
||||
|
@ -269,13 +266,13 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
@Override
|
||||
public void moveFilesFinished(String newPath)
|
||||
{
|
||||
UiUtils.showAlertDialog(MWMActivity.this, R.string.move_lite_maps_to_pro_ok);
|
||||
UiUtils.showAlertDialog(MwmActivity.this, R.string.move_lite_maps_to_pro_ok);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveFilesFailed(int errorCode)
|
||||
{
|
||||
UiUtils.showAlertDialog(MWMActivity.this, R.string.move_lite_maps_to_pro_failed);
|
||||
UiUtils.showAlertDialog(MwmActivity.this, R.string.move_lite_maps_to_pro_failed);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -380,7 +377,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
}
|
||||
else
|
||||
{
|
||||
new AlertDialog.Builder(MWMActivity.this)
|
||||
new AlertDialog.Builder(MwmActivity.this)
|
||||
.setMessage(R.string.unknown_current_position)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener()
|
||||
|
@ -426,7 +423,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
|
||||
TtsPlayer.INSTANCE.init();
|
||||
|
||||
if (MWMApplication.get().nativeIsBenchmarking())
|
||||
if (MwmApplication.get().nativeIsBenchmarking())
|
||||
Utils.keepScreenOn(true, getWindow());
|
||||
|
||||
// TODO consider implementing other model of listeners connection, without activities being bound
|
||||
|
@ -803,7 +800,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
|
||||
private void refreshZoomButtonsVisibility()
|
||||
{
|
||||
final boolean showZoomSetting = MWMApplication.get().nativeGetBoolean(SettingsActivity.ZOOM_BUTTON_ENABLED, true) || Framework.nativeIsRoutingActive();
|
||||
final boolean showZoomSetting = MwmApplication.get().nativeGetBoolean(SettingsActivity.ZOOM_BUTTON_ENABLED, true) || Framework.nativeIsRoutingActive();
|
||||
UiUtils.showIf(showZoomSetting &&
|
||||
!UiUtils.areViewsIntersecting(mToolbarSearch, mBtnZoomIn) &&
|
||||
!UiUtils.areViewsIntersecting(mLayoutRouting, mBtnZoomIn),
|
||||
|
@ -984,7 +981,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
final String poiType = ParsedMwmRequest.getCurrentRequest().getCallerName(MWMApplication.get()).toString();
|
||||
final String poiType = ParsedMwmRequest.getCurrentRequest().getCallerName(MwmApplication.get()).toString();
|
||||
activateMapObject(new ApiPoint(name, id, poiType, lat, lon));
|
||||
}
|
||||
});
|
||||
|
@ -1289,7 +1286,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
final Bundle args = new Bundle();
|
||||
args.putInt(RoutingErrorDialogFragment.EXTRA_RESULT_CODE, resultCode);
|
||||
args.putSerializable(RoutingErrorDialogFragment.EXTRA_MISSING_COUNTRIES, missingCountries);
|
||||
final RoutingErrorDialogFragment fragment = (RoutingErrorDialogFragment) Fragment.instantiate(MWMActivity.this, RoutingErrorDialogFragment.class.getName());
|
||||
final RoutingErrorDialogFragment fragment = (RoutingErrorDialogFragment) Fragment.instantiate(MwmActivity.this, RoutingErrorDialogFragment.class.getName());
|
||||
fragment.setArguments(args);
|
||||
fragment.setListener(new RoutingErrorDialogFragment.RoutingDialogListener()
|
||||
{
|
||||
|
@ -1352,7 +1349,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
|
||||
public interface MapTask extends Serializable
|
||||
{
|
||||
boolean run(MWMActivity target);
|
||||
boolean run(MwmActivity target);
|
||||
}
|
||||
|
||||
public static class OpenUrlTask implements MapTask
|
||||
|
@ -1367,7 +1364,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean run(MWMActivity target)
|
||||
public boolean run(MwmActivity target)
|
||||
{
|
||||
return target.mMapFragment.showMapForUrl(mUrl);
|
||||
}
|
||||
|
@ -1386,7 +1383,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean run(MWMActivity target)
|
||||
public boolean run(MwmActivity target)
|
||||
{
|
||||
if (mDoAutoDownload)
|
||||
{
|
||||
|
@ -1404,7 +1401,7 @@ public class MWMActivity extends BaseMwmFragmentActivity
|
|||
public static class UpdateCountryTask implements MapTask
|
||||
{
|
||||
@Override
|
||||
public boolean run(final MWMActivity target)
|
||||
public boolean run(final MwmActivity target)
|
||||
{
|
||||
target.runOnUiThread(new Runnable()
|
||||
{
|
|
@ -29,9 +29,9 @@ import java.util.Map;
|
|||
import ru.mail.android.mytracker.MRMyTracker;
|
||||
import ru.mail.android.mytracker.MRMyTrackerParams;
|
||||
|
||||
public class MWMApplication extends android.app.Application implements ActiveCountryTree.ActiveCountryListener
|
||||
public class MwmApplication extends android.app.Application implements ActiveCountryTree.ActiveCountryListener
|
||||
{
|
||||
private final static String TAG = "MWMApplication";
|
||||
private final static String TAG = "MwmApplication";
|
||||
private static final String FOREGROUND_TIME_SETTING = "AllForegroundTime";
|
||||
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
|
||||
|
@ -46,18 +46,18 @@ public class MWMApplication extends android.app.Application implements ActiveCou
|
|||
private static final String PREF_PARSE_DEVICE_TOKEN = "ParseDeviceToken";
|
||||
private static final String PREF_PARSE_INSTALLATION_ID = "ParseInstallationId";
|
||||
|
||||
private static MWMApplication mSelf;
|
||||
private static MwmApplication mSelf;
|
||||
private final Gson mGson = new Gson();
|
||||
|
||||
private boolean mAreStatsInitialised;
|
||||
|
||||
public MWMApplication()
|
||||
public MwmApplication()
|
||||
{
|
||||
super();
|
||||
mSelf = this;
|
||||
}
|
||||
|
||||
public static MWMApplication get()
|
||||
public static MwmApplication get()
|
||||
{
|
||||
return mSelf;
|
||||
}
|
|
@ -5,7 +5,7 @@ import android.support.v4.app.DialogFragment;
|
|||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
@ -65,7 +65,7 @@ public class LikesManager
|
|||
|
||||
private static final long DIALOG_DELAY_MILLIS = 30000;
|
||||
|
||||
private final boolean mIsNewUser = MWMApplication.get().getFirstInstallVersion() == BuildConfig.VERSION_CODE;
|
||||
private final boolean mIsNewUser = MwmApplication.get().getFirstInstallVersion() == BuildConfig.VERSION_CODE;
|
||||
private final int mSessionNum;
|
||||
|
||||
private Handler mHandler;
|
||||
|
@ -80,7 +80,7 @@ public class LikesManager
|
|||
mHandler = new Handler(activity.getMainLooper());
|
||||
mActivityRef = new WeakReference<>(activity);
|
||||
|
||||
mSessionNum = MWMApplication.get().getSessionsNumber();
|
||||
mSessionNum = MwmApplication.get().getSessionsNumber();
|
||||
}
|
||||
|
||||
public void showLikeDialogForCurrentSession()
|
||||
|
@ -134,21 +134,21 @@ public class LikesManager
|
|||
|
||||
public static boolean isSessionRated(int sessionNum)
|
||||
{
|
||||
return MWMApplication.get().nativeGetInt(LAST_RATED_SESSION, 0) >= sessionNum;
|
||||
return MwmApplication.get().nativeGetInt(LAST_RATED_SESSION, 0) >= sessionNum;
|
||||
}
|
||||
|
||||
public static void setSessionRated(int sessionNum)
|
||||
{
|
||||
MWMApplication.get().nativeSetInt(LAST_RATED_SESSION, 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);
|
||||
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);
|
||||
MwmApplication.get().nativeSetBoolean(RATED_DIALOG + dialogFragmentClass.getSimpleName(), applied);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import android.widget.RatingBar;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmDialogFragment;
|
||||
import com.mapswithme.util.Constants;
|
||||
|
@ -112,7 +112,7 @@ public class RateStoreDialogFragment extends BaseMwmDialogFragment implements Vi
|
|||
long installTime = 0;
|
||||
try
|
||||
{
|
||||
info = MWMApplication.get().getPackageManager().getPackageInfo(BuildConfig.APPLICATION_ID, 0);
|
||||
info = MwmApplication.get().getPackageManager().getPackageInfo(BuildConfig.APPLICATION_ID, 0);
|
||||
installTime = info.firstInstallTime;
|
||||
} catch (PackageManager.NameNotFoundException e)
|
||||
{
|
||||
|
|
|
@ -1,28 +1,19 @@
|
|||
package com.mapswithme.maps.background;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
import com.mapswithme.maps.MWMActivity;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.MapStorage.Index;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class Notifier
|
||||
{
|
||||
private final static int ID_UPDATE_AVAIL = 0x1;
|
||||
|
@ -42,21 +33,21 @@ public class Notifier
|
|||
|
||||
public static NotificationCompat.Builder getBuilder()
|
||||
{
|
||||
return new NotificationCompat.Builder(MWMApplication.get())
|
||||
return new NotificationCompat.Builder(MwmApplication.get())
|
||||
.setAutoCancel(true)
|
||||
.setSmallIcon(R.drawable.ic_notification);
|
||||
}
|
||||
|
||||
private static NotificationManager getNotificationManager()
|
||||
{
|
||||
return (NotificationManager) MWMApplication.get().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
return (NotificationManager) MwmApplication.get().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
}
|
||||
|
||||
public static void placeUpdateAvailable(String forWhat)
|
||||
{
|
||||
final String title = MWMApplication.get().getString(R.string.advise_update_maps);
|
||||
final String title = MwmApplication.get().getString(R.string.advise_update_maps);
|
||||
|
||||
final PendingIntent pi = PendingIntent.getActivity(MWMApplication.get(), 0, MWMActivity.createUpdateMapsIntent(),
|
||||
final PendingIntent pi = PendingIntent.getActivity(MwmApplication.get(), 0, MwmActivity.createUpdateMapsIntent(),
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
final Notification notification = Notifier.getBuilder()
|
||||
|
@ -72,8 +63,8 @@ public class Notifier
|
|||
|
||||
public static void placeDownloadCompleted(Index idx, String name)
|
||||
{
|
||||
final String title = MWMApplication.get().getString(R.string.app_name);
|
||||
final String content = MWMApplication.get().getString(R.string.download_country_success, name);
|
||||
final String title = MwmApplication.get().getString(R.string.app_name);
|
||||
final String content = MwmApplication.get().getString(R.string.download_country_success, name);
|
||||
|
||||
// TODO add complex stacked notification with progress, number of countries and other info.
|
||||
// placeDownloadNotification(title, content, idx);
|
||||
|
@ -81,16 +72,16 @@ public class Notifier
|
|||
|
||||
public static void placeDownloadFailed(Index idx, String name)
|
||||
{
|
||||
final String title = MWMApplication.get().getString(R.string.app_name);
|
||||
final String content = MWMApplication.get().getString(R.string.download_country_failed, name);
|
||||
final String title = MwmApplication.get().getString(R.string.app_name);
|
||||
final String content = MwmApplication.get().getString(R.string.download_country_failed, name);
|
||||
|
||||
placeDownloadNotification(title, content, idx);
|
||||
}
|
||||
|
||||
private static void placeDownloadNotification(String title, String content, Index idx)
|
||||
{
|
||||
final PendingIntent pi = PendingIntent.getActivity(MWMApplication.get(), 0,
|
||||
MWMActivity.createShowMapIntent(MWMApplication.get(), idx, false).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
|
||||
final PendingIntent pi = PendingIntent.getActivity(MwmApplication.get(), 0,
|
||||
MwmActivity.createShowMapIntent(MwmApplication.get(), idx, false).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
final Notification notification = getBuilder()
|
||||
|
@ -105,8 +96,8 @@ public class Notifier
|
|||
|
||||
public static void placeDownloadSuggest(String title, String content, Index countryIndex)
|
||||
{
|
||||
final PendingIntent pi = PendingIntent.getActivity(MWMApplication.get(), 0,
|
||||
MWMActivity.createShowMapIntent(MWMApplication.get(), countryIndex, true).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
|
||||
final PendingIntent pi = PendingIntent.getActivity(MwmApplication.get(), 0,
|
||||
MwmActivity.createShowMapIntent(MwmApplication.get(), countryIndex, true).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
final Notification notification = getBuilder()
|
||||
|
|
|
@ -8,7 +8,7 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.view.MenuItem;
|
||||
|
||||
import com.mapswithme.util.ViewServer;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
@ -32,7 +32,7 @@ public class BaseMwmFragmentActivity extends AppCompatActivity
|
|||
getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||
}
|
||||
|
||||
MWMApplication.get().initStats();
|
||||
MwmApplication.get().initStats();
|
||||
ViewServer.get(this).addWindow(this);
|
||||
|
||||
attachDefaultFragment();
|
||||
|
|
|
@ -17,7 +17,7 @@ import android.widget.ListView;
|
|||
|
||||
import com.cocosw.bottomsheet.BottomSheet;
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MWMActivity;
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmListFragment;
|
||||
import com.mapswithme.maps.bookmarks.data.Bookmark;
|
||||
|
@ -106,7 +106,7 @@ public class BookmarksListFragment extends BaseMwmListFragment
|
|||
break;
|
||||
}
|
||||
|
||||
final Intent i = new Intent(getActivity(), MWMActivity.class);
|
||||
final Intent i = new Intent(getActivity(), MwmActivity.class);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.location.LocationManager;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
import com.mapswithme.util.LocationUtils;
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class AndroidNativeProvider extends BaseLocationProvider implements andro
|
|||
|
||||
public AndroidNativeProvider()
|
||||
{
|
||||
mLocationManager = (LocationManager) MWMApplication.get().getSystemService(Context.LOCATION_SERVICE);
|
||||
mLocationManager = (LocationManager) MwmApplication.get().getSystemService(Context.LOCATION_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.google.android.gms.common.api.GoogleApiClient;
|
|||
import com.google.android.gms.location.LocationListener;
|
||||
import com.google.android.gms.location.LocationRequest;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
|
||||
public class GoogleFusedLocationProvider extends BaseLocationProvider
|
||||
implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener
|
||||
|
@ -22,7 +22,7 @@ public class GoogleFusedLocationProvider extends BaseLocationProvider
|
|||
|
||||
public GoogleFusedLocationProvider()
|
||||
{
|
||||
mGoogleApiClient = new GoogleApiClient.Builder(MWMApplication.get())
|
||||
mGoogleApiClient = new GoogleApiClient.Builder(MwmApplication.get())
|
||||
.addApi(LocationServices.API)
|
||||
.addConnectionCallbacks(this)
|
||||
.addOnConnectionFailedListener(this)
|
||||
|
|
|
@ -16,7 +16,7 @@ import android.text.TextUtils;
|
|||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.LocationUtils;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
|
@ -67,7 +67,7 @@ public enum LocationHelper implements SensorEventListener
|
|||
{
|
||||
mLogger = SimpleLogger.get(LocationHelper.class.getName());
|
||||
initLocationProvider(false);
|
||||
mSensorManager = (SensorManager) MWMApplication.get().getSystemService(Context.SENSOR_SERVICE);
|
||||
mSensorManager = (SensorManager) MwmApplication.get().getSystemService(Context.SENSOR_SERVICE);
|
||||
if (mSensorManager != null)
|
||||
{
|
||||
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
|
@ -80,7 +80,7 @@ public enum LocationHelper implements SensorEventListener
|
|||
{
|
||||
boolean isLocationTurnedOn = false;
|
||||
|
||||
final MWMApplication application = MWMApplication.get();
|
||||
final MwmApplication application = MwmApplication.get();
|
||||
// If location is turned off(by user in system settings), google client( = fused provider) api doesn't work at all
|
||||
// but external gps receivers still can work. In that case we prefer native provider instead of fused - it works.
|
||||
final ContentResolver resolver = application.getContentResolver();
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.res.Resources;
|
|||
import android.util.Pair;
|
||||
|
||||
import com.mapswithme.maps.LocationState;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.MapStorage;
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class RoutingResultCodesProcessor
|
|||
if (missingCountries != null)
|
||||
missingCount = missingCountries.length;
|
||||
|
||||
Resources resources = MWMApplication.get().getResources();
|
||||
Resources resources = MwmApplication.get().getResources();
|
||||
int titleRes = 0;
|
||||
List<String> messages = new ArrayList<>();
|
||||
switch (errorCode)
|
||||
|
|
|
@ -20,7 +20,7 @@ import android.widget.TextView;
|
|||
import com.mapswithme.country.ActiveCountryTree;
|
||||
import com.mapswithme.country.CountrySuggestFragment;
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MWMActivity;
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmRecyclerFragment;
|
||||
import com.mapswithme.maps.base.OnBackPressListener;
|
||||
|
@ -299,7 +299,7 @@ public class SearchFragment extends BaseMwmRecyclerFragment implements View.OnCl
|
|||
|
||||
// change map style for the Map activity
|
||||
final int mapStyle = isDark ? Framework.MAP_STYLE_DARK : Framework.MAP_STYLE_LIGHT;
|
||||
MWMActivity.setMapStyle(getActivity(), mapStyle);
|
||||
MwmActivity.setMapStyle(getActivity(), mapStyle);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import android.view.View.OnClickListener;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MWMActivity;
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.api.ParsedMwmRequest;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
@ -34,7 +34,7 @@ public class SearchToolbarController implements OnClickListener
|
|||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
MWMActivity.startSearch(mActivity, mSearchQuery.getText().toString());
|
||||
MwmActivity.startSearch(mActivity, mSearchQuery.getText().toString());
|
||||
cancelSearchApiAndHide();
|
||||
}
|
||||
});
|
||||
|
@ -73,7 +73,7 @@ public class SearchToolbarController implements OnClickListener
|
|||
if (R.id.search_text_query == id)
|
||||
{
|
||||
final String query = mSearchQuery.getText().toString();
|
||||
MWMActivity.startSearch(mActivity, query);
|
||||
MwmActivity.startSearch(mActivity, query);
|
||||
UiUtils.hide(mSearchToolbar);
|
||||
}
|
||||
else if (R.id.search_image_clear == id)
|
||||
|
|
|
@ -29,7 +29,7 @@ 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 com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.Constants;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
@ -58,7 +58,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
|||
// 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().initStats();
|
||||
MwmApplication.get().initStats();
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
initPreferences();
|
||||
yotaSetup();
|
||||
|
@ -87,10 +87,10 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
|||
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.setChecked(MwmApplication.get().nativeGetBoolean(ZOOM_BUTTON_ENABLED, true));
|
||||
enableZoomButtons.setOnPreferenceChangeListener(this);
|
||||
|
||||
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(MWMApplication.get()) != ConnectionResult.SUCCESS)
|
||||
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(MwmApplication.get()) != ConnectionResult.SUCCESS)
|
||||
{
|
||||
((PreferenceScreen) findPreference(getString(R.string.pref_settings))).
|
||||
removePreference(findPreference(getString(R.string.pref_play_services)));
|
||||
|
@ -430,7 +430,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
|||
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);
|
||||
MwmApplication.get().nativeSetBoolean(ZOOM_BUTTON_ENABLED, (Boolean) newValue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import android.util.Log;
|
|||
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.MapStorage;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
|
@ -199,8 +199,8 @@ public class StoragePathManager
|
|||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
private static void parseKitkatStorages(List<String> paths)
|
||||
{
|
||||
File primaryStorage = MWMApplication.get().getExternalFilesDir(null);
|
||||
File[] storages = MWMApplication.get().getExternalFilesDirs(null);
|
||||
File primaryStorage = MwmApplication.get().getExternalFilesDir(null);
|
||||
File[] storages = MwmApplication.get().getExternalFilesDirs(null);
|
||||
if (storages != null)
|
||||
{
|
||||
for (File f : storages)
|
||||
|
@ -483,7 +483,7 @@ public class StoragePathManager
|
|||
|
||||
private void migrateBookmarks(final Activity activity, final MoveFilesListener listener)
|
||||
{
|
||||
if (MWMApplication.get().nativeGetBoolean(IS_KML_PLACED_IN_MAIN_STORAGE, false))
|
||||
if (MwmApplication.get().nativeGetBoolean(IS_KML_PLACED_IN_MAIN_STORAGE, false))
|
||||
listener.moveFilesFinished("");
|
||||
else
|
||||
{
|
||||
|
@ -501,7 +501,7 @@ public class StoragePathManager
|
|||
{
|
||||
if (res)
|
||||
{
|
||||
MWMApplication.get().nativeSetBoolean(IS_KML_PLACED_IN_MAIN_STORAGE, true);
|
||||
MwmApplication.get().nativeSetBoolean(IS_KML_PLACED_IN_MAIN_STORAGE, true);
|
||||
listener.moveFilesFinished("");
|
||||
}
|
||||
else
|
||||
|
@ -515,7 +515,7 @@ public class StoragePathManager
|
|||
|
||||
private void migrateMaps(final Activity activity)
|
||||
{
|
||||
if (!MWMApplication.get().nativeGetBoolean(IS_KITKAT_MIGRATION_COMPLETED, false))
|
||||
if (!MwmApplication.get().nativeGetBoolean(IS_KITKAT_MIGRATION_COMPLETED, false))
|
||||
{
|
||||
checkExternalStoragePathOnKitkat(activity,
|
||||
new MoveFilesListener()
|
||||
|
@ -523,7 +523,7 @@ public class StoragePathManager
|
|||
@Override
|
||||
public void moveFilesFinished(String newPath)
|
||||
{
|
||||
MWMApplication.get().nativeSetBoolean(IS_KITKAT_MIGRATION_COMPLETED, true);
|
||||
MwmApplication.get().nativeSetBoolean(IS_KITKAT_MIGRATION_COMPLETED, true);
|
||||
UiUtils.showAlertDialog(activity, R.string.kitkat_migrate_ok);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.speech.tts.TextToSpeech;
|
|||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -22,7 +22,7 @@ public enum TtsPlayer
|
|||
|
||||
TtsPlayer()
|
||||
{
|
||||
mContext = MWMApplication.get().getApplicationContext();
|
||||
mContext = MwmApplication.get().getApplicationContext();
|
||||
}
|
||||
|
||||
public void init()
|
||||
|
|
|
@ -20,7 +20,7 @@ import android.widget.RadioButton;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
|
@ -336,7 +336,7 @@ public class RoutingLayout extends FrameLayout implements CompoundButton.OnCheck
|
|||
|
||||
private void buildRoute()
|
||||
{
|
||||
if (!MWMApplication.get().nativeGetBoolean(IS_ROUTING_DISCLAIMER_APPROVED, false))
|
||||
if (!MwmApplication.get().nativeGetBoolean(IS_ROUTING_DISCLAIMER_APPROVED, false))
|
||||
{
|
||||
showRoutingDisclaimer();
|
||||
return;
|
||||
|
@ -361,7 +361,7 @@ public class RoutingLayout extends FrameLayout implements CompoundButton.OnCheck
|
|||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
MWMApplication.get().nativeSetBoolean(IS_ROUTING_DISCLAIMER_APPROVED, true);
|
||||
MwmApplication.get().nativeSetBoolean(IS_ROUTING_DISCLAIMER_APPROVED, true);
|
||||
dlg.dismiss();
|
||||
buildRoute();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import android.view.ViewConfiguration;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.widget.placepage.PlacePageView.State;
|
||||
|
@ -19,7 +19,7 @@ import com.mapswithme.maps.widget.placepage.PlacePageView.State;
|
|||
*/
|
||||
public abstract class BasePlacePageAnimationController
|
||||
{
|
||||
protected static final int DURATION = MWMApplication.get().getResources().getInteger(R.integer.anim_duration_default);
|
||||
protected static final int DURATION = MwmApplication.get().getResources().getInteger(R.integer.anim_duration_default);
|
||||
protected static final boolean NO_ANIMATION = (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB);
|
||||
|
||||
protected State mState = State.HIDDEN;
|
||||
|
|
|
@ -10,7 +10,7 @@ import android.support.annotation.StringRes;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import com.cocosw.bottomsheet.BottomSheet;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.widget.ListShadowController;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
@ -140,7 +140,7 @@ public final class BottomSheetHelper
|
|||
|
||||
public static BottomSheet.Builder sheet(BottomSheet.Builder builder, int id, @DrawableRes int iconRes, CharSequence text)
|
||||
{
|
||||
Drawable icon = ContextCompat.getDrawable(MWMApplication.get(), iconRes);
|
||||
Drawable icon = ContextCompat.getDrawable(MwmApplication.get(), iconRes);
|
||||
return builder.sheet(id, icon, text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.Context;
|
|||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
|
||||
public class ConnectionState
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ public class ConnectionState
|
|||
|
||||
private static boolean isNetworkConnected(int networkType)
|
||||
{
|
||||
final ConnectivityManager manager = (ConnectivityManager) MWMApplication.get().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
final ConnectivityManager manager = (ConnectivityManager) MwmApplication.get().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
final NetworkInfo info = manager.getActiveNetworkInfo();
|
||||
return info != null && info.getType() == networkType && info.isConnected();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.os.Build;
|
|||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class Language
|
|||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
{
|
||||
final InputMethodManager imm = (InputMethodManager) MWMApplication.get().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
final InputMethodManager imm = (InputMethodManager) MwmApplication.get().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null)
|
||||
{
|
||||
final InputMethodSubtype ims = imm.getCurrentInputMethodSubtype();
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.util.statistics.AlohaHelper;
|
||||
|
||||
import ru.mail.android.mytracker.campaign.CampaignReceiver;
|
||||
|
@ -17,7 +17,7 @@ public class MultipleTrackerReferrerReceiver extends BroadcastReceiver
|
|||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
MWMApplication.get().initStats();
|
||||
MwmApplication.get().initStats();
|
||||
// parse & send referrer to Aloha
|
||||
try
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.text.SpannableStringBuilder;
|
|||
import android.text.TextWatcher;
|
||||
import android.text.style.CharacterStyle;
|
||||
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
import java.util.Locale;
|
||||
|
@ -82,9 +82,9 @@ public class StringUtils
|
|||
public static String getFileSizeString(long size)
|
||||
{
|
||||
if (size > Constants.MB)
|
||||
return (size + Constants.MB / 2) / Constants.MB + " " + MWMApplication.get().getString(R.string.mb);
|
||||
return (size + Constants.MB / 2) / Constants.MB + " " + MwmApplication.get().getString(R.string.mb);
|
||||
else
|
||||
return (size + Constants.KB - 1) / Constants.KB + " " + MWMApplication.get().getString(R.string.kb);
|
||||
return (size + Constants.KB - 1) / Constants.KB + " " + MwmApplication.get().getString(R.string.kb);
|
||||
}
|
||||
|
||||
public static class SimpleTextWatcher implements TextWatcher
|
||||
|
|
|
@ -30,7 +30,7 @@ import android.view.animation.AnimationUtils;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.nineoldandroids.animation.Animator;
|
||||
|
||||
|
@ -230,7 +230,7 @@ public final class UiUtils
|
|||
public static String getDisplayDensityString()
|
||||
{
|
||||
final DisplayMetrics metrics = new DisplayMetrics();
|
||||
((WindowManager) MWMApplication.get().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(metrics);
|
||||
((WindowManager) MwmApplication.get().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(metrics);
|
||||
switch (metrics.densityDpi)
|
||||
{
|
||||
case DisplayMetrics.DENSITY_LOW:
|
||||
|
@ -358,12 +358,12 @@ public final class UiUtils
|
|||
|
||||
public static boolean isSmallTablet()
|
||||
{
|
||||
return MWMApplication.get().getResources().getBoolean(R.bool.isSmallTablet);
|
||||
return MwmApplication.get().getResources().getBoolean(R.bool.isSmallTablet);
|
||||
}
|
||||
|
||||
public static boolean isBigTablet()
|
||||
{
|
||||
return MWMApplication.get().getResources().getBoolean(R.bool.isBigTablet);
|
||||
return MwmApplication.get().getResources().getBoolean(R.bool.isBigTablet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@ import android.widget.EditText;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.util.statistics.AlohaHelper;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
@ -59,7 +59,7 @@ public class Utils
|
|||
{
|
||||
final String GooglePlayStorePackageNameOld = "com.google.market";
|
||||
final String GooglePlayStorePackageNameNew = "com.android.vending";
|
||||
final PackageManager pm = MWMApplication.get().getPackageManager();
|
||||
final PackageManager pm = MwmApplication.get().getPackageManager();
|
||||
final List<PackageInfo> packages = pm.getInstalledPackages(0);
|
||||
for (final PackageInfo packageInfo : packages)
|
||||
{
|
||||
|
@ -179,7 +179,7 @@ public class Utils
|
|||
|
||||
public static boolean isPackageInstalled(String packageUri)
|
||||
{
|
||||
PackageManager pm = MWMApplication.get().getPackageManager();
|
||||
PackageManager pm = MwmApplication.get().getPackageManager();
|
||||
boolean installed;
|
||||
try
|
||||
{
|
||||
|
@ -201,7 +201,7 @@ public class Utils
|
|||
|
||||
public static boolean isIntentAvailable(Intent intent)
|
||||
{
|
||||
PackageManager mgr = MWMApplication.get().getPackageManager();
|
||||
PackageManager mgr = MwmApplication.get().getPackageManager();
|
||||
return mgr.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ public class Utils
|
|||
*/
|
||||
public static String saveLogToFile()
|
||||
{
|
||||
String fullName = MWMApplication.get().getDataStoragePath() + "log.txt";
|
||||
String fullName = MwmApplication.get().getDataStoragePath() + "log.txt";
|
||||
File file = new File(fullName);
|
||||
InputStreamReader reader = null;
|
||||
FileWriter writer = null;
|
||||
|
@ -233,7 +233,7 @@ public class Utils
|
|||
writer.write("App version: " + BuildConfig.APPLICATION_ID + " " + BuildConfig.VERSION_NAME + "\n");
|
||||
writer.write("Locale : " + Locale.getDefault());
|
||||
writer.write("\nNetworks : ");
|
||||
final ConnectivityManager manager = (ConnectivityManager) MWMApplication.get().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
final ConnectivityManager manager = (ConnectivityManager) MwmApplication.get().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
for (NetworkInfo info : manager.getAllNetworkInfo())
|
||||
writer.write(info.toString());
|
||||
writer.write("\n\n");
|
||||
|
@ -280,7 +280,7 @@ public class Utils
|
|||
{
|
||||
try
|
||||
{
|
||||
final PackageInfo info = MWMApplication.get().getPackageManager().getPackageInfo(BuildConfig.APPLICATION_ID, 0);
|
||||
final PackageInfo info = MwmApplication.get().getPackageManager().getPackageInfo(BuildConfig.APPLICATION_ID, 0);
|
||||
return info.firstInstallTime > timestamp;
|
||||
} catch (PackageManager.NameNotFoundException e)
|
||||
{
|
||||
|
|
|
@ -4,9 +4,7 @@ import android.app.ActivityManager;
|
|||
import android.content.Context;
|
||||
import android.os.Debug;
|
||||
import android.os.Build;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
|
||||
|
||||
public class MemLogging
|
||||
|
@ -17,7 +15,7 @@ public class MemLogging
|
|||
Debug.getMemoryInfo(debugMI);
|
||||
final ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
|
||||
final ActivityManager activityManager =
|
||||
(ActivityManager) MWMApplication.get().getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
(ActivityManager) MwmApplication.get().getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
activityManager.getMemoryInfo(mi);
|
||||
|
||||
StringBuilder log = new StringBuilder("Memory info: ");
|
||||
|
|
|
@ -12,7 +12,7 @@ import android.support.annotation.StringRes;
|
|||
import android.text.TextUtils;
|
||||
|
||||
import com.cocosw.bottomsheet.BottomSheet;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.util.BottomSheetHelper;
|
||||
|
@ -28,7 +28,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.mapswithme.maps.MWMApplication.gson;
|
||||
import static com.mapswithme.maps.MwmApplication.gson;
|
||||
|
||||
public final class SharingHelper
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ public final class SharingHelper
|
|||
private static final SharingHelper sInstance = new SharingHelper();
|
||||
|
||||
|
||||
private final SharedPreferences mPrefs = MWMApplication.get().getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE);
|
||||
private final SharedPreferences mPrefs = MwmApplication.get().getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE);
|
||||
private final Map<String, SharingTarget> mItems = new HashMap<>();
|
||||
|
||||
|
||||
|
@ -109,7 +109,7 @@ public final class SharingHelper
|
|||
Set<String> missed = new HashSet<>(mItems.keySet());
|
||||
|
||||
Intent it = data.getTargetIntent();
|
||||
PackageManager pm = MWMApplication.get().getPackageManager();
|
||||
PackageManager pm = MwmApplication.get().getPackageManager();
|
||||
List<ResolveInfo> rlist = pm.queryIntentActivities(it, 0);
|
||||
|
||||
|
||||
|
@ -214,7 +214,7 @@ public final class SharingHelper
|
|||
|
||||
public static void shareBookmarksCategory(Activity context, int id)
|
||||
{
|
||||
String path = MWMApplication.get().getTempPath();
|
||||
String path = MwmApplication.get().getTempPath();
|
||||
String name = BookmarkManager.INSTANCE.saveToKmzFile(id, path);
|
||||
if (name == null)
|
||||
// some error occurred
|
||||
|
|
|
@ -4,12 +4,10 @@ import android.app.Activity;
|
|||
|
||||
import com.mapswithme.country.ActiveCountryTree;
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.api.ParsedMwmRequest;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.util.FbUtil;
|
||||
import com.mapswithme.util.MathUtils;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.SimpleLogger;
|
||||
import com.mapswithme.util.log.StubLogger;
|
||||
|
@ -258,11 +256,11 @@ public enum Statistics
|
|||
|
||||
private void configure()
|
||||
{
|
||||
final String key = MWMApplication.get().getResources().getString(R.string.flurry_app_key);
|
||||
final String key = MwmApplication.get().getResources().getString(R.string.flurry_app_key);
|
||||
mStatisticsEngines = new ArrayList<>();
|
||||
|
||||
final StatisticsEngine flurryEngine = new FlurryEngine(BuildConfig.DEBUG, key);
|
||||
flurryEngine.configure(MWMApplication.get(), null);
|
||||
flurryEngine.configure(MwmApplication.get(), null);
|
||||
mStatisticsEngines.add(flurryEngine);
|
||||
|
||||
mEventBuilder = new EventBuilder();
|
||||
|
@ -281,16 +279,16 @@ public enum Statistics
|
|||
|
||||
public boolean isStatisticsEnabled()
|
||||
{
|
||||
return MWMApplication.get().nativeGetBoolean(KEY_STAT_ENABLED, true);
|
||||
return MwmApplication.get().nativeGetBoolean(KEY_STAT_ENABLED, true);
|
||||
}
|
||||
|
||||
public void setStatEnabled(boolean isEnabled)
|
||||
{
|
||||
MWMApplication.get().nativeSetBoolean(KEY_STAT_ENABLED, isEnabled);
|
||||
MwmApplication.get().nativeSetBoolean(KEY_STAT_ENABLED, isEnabled);
|
||||
// We track if user turned on/off
|
||||
// statistics to understand data better.
|
||||
post(mEventBuilder
|
||||
.setName(EventName.STATISTICS_STATUS_CHANGED + " " + MWMApplication.get().getFirstInstallFlavor())
|
||||
.setName(EventName.STATISTICS_STATUS_CHANGED + " " + MwmApplication.get().getFirstInstallFlavor())
|
||||
.addParam(EventParam.ENABLED, String.valueOf(isEnabled))
|
||||
.buildEvent());
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ from com.android.monkeyrunner import MonkeyRunner
|
|||
apkPath = '../MapsWithMeTest/bin/MapsWithMeTest-release.apk'
|
||||
package = 'com.mapswithme.maps.pro'
|
||||
activity = 'com.mapswithme.maps.DownloadResourcesActivity'
|
||||
mapactivity = 'com.mapswithme.maps.MWMActivity'
|
||||
mapactivity = 'com.mapswithme.maps.MwmActivity'
|
||||
|
||||
|
||||
def run_tasks(device, tasks):
|
||||
|
|
|
@ -6,24 +6,24 @@ import android.test.ActivityInstrumentationTestCase2;
|
|||
|
||||
import com.jayway.android.robotium.solo.Solo;
|
||||
import com.mapswithme.maps.DownloadUI;
|
||||
import com.mapswithme.maps.MWMActivity;
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.search.SearchActivity;
|
||||
import com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity;
|
||||
import com.squareup.spoon.Spoon;
|
||||
|
||||
public class MapActivityTest extends ActivityInstrumentationTestCase2<MWMActivity>
|
||||
public class MapActivityTest extends ActivityInstrumentationTestCase2<MwmActivity>
|
||||
{
|
||||
private static final int TIME_OUT = 5*1000;
|
||||
|
||||
public MapActivityTest()
|
||||
{
|
||||
super(MWMActivity.class);
|
||||
super(MwmActivity.class);
|
||||
}
|
||||
|
||||
public void testAllButtons()
|
||||
{
|
||||
final MWMActivity activity = getActivity();
|
||||
final MwmActivity activity = getActivity();
|
||||
final Solo solo = new Solo(getInstrumentation(), activity);
|
||||
|
||||
Spoon.screenshot(activity, "initial_state");
|
||||
|
|
Loading…
Add table
Reference in a new issue