diff options
author | Dmitry Yunitsky <yunik@mapswithme.com> | 2015-01-13 14:09:18 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:36:04 +0300 |
commit | 5f09ba278b9b860f44cf528f133d817dca234bdc (patch) | |
tree | 001d8eb7116199a258ab6d5c217852d80fad41b0 | |
parent | 55c36e7e044f715f2efa404fc4811adf52e67bb6 (diff) |
Changed facebook share dialog display rules.
-rw-r--r-- | android/src/com/mapswithme/maps/MWMActivity.java | 26 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/MWMApplication.java | 21 |
2 files changed, 30 insertions, 17 deletions
diff --git a/android/src/com/mapswithme/maps/MWMActivity.java b/android/src/com/mapswithme/maps/MWMActivity.java index 6d90362345..b0518c6339 100644 --- a/android/src/com/mapswithme/maps/MWMActivity.java +++ b/android/src/com/mapswithme/maps/MWMActivity.java @@ -91,6 +91,7 @@ import com.nineoldandroids.view.ViewHelper; import com.nvidia.devtech.NvEventQueueActivity; import java.io.Serializable; +import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.Stack; @@ -532,6 +533,7 @@ public class MWMActivity extends NvEventQueueActivity private void showDialogImpl(final int dlgID, int resMsg, DialogInterface.OnClickListener okListener) { + final MWMApplication application = MWMApplication.get(); new AlertDialog.Builder(this) .setCancelable(false) .setMessage(getString(resMsg)) @@ -542,7 +544,7 @@ public class MWMActivity extends NvEventQueueActivity public void onClick(DialogInterface dlg, int which) { dlg.dismiss(); - MWMApplication.get().submitDialogResult(dlgID, MWMApplication.NEVER); + application.submitDialogResult(dlgID, MWMApplication.NEVER); } }) .setNegativeButton(getString(R.string.later), new DialogInterface.OnClickListener() @@ -551,7 +553,9 @@ public class MWMActivity extends NvEventQueueActivity public void onClick(DialogInterface dlg, int which) { dlg.dismiss(); - MWMApplication.get().submitDialogResult(dlgID, MWMApplication.LATER); + application.submitDialogResult(dlgID, MWMApplication.LATER); + // FIXME hack to deal with native & java FACEBOOK dialog views conflict + application.nativeSetInt(MWMApplication.LAUNCH_NUMBER_SETTING, application.nativeGetInt(MWMApplication.LAUNCH_NUMBER_SETTING, 0) + 1); } }) .create() @@ -597,8 +601,18 @@ public class MWMActivity extends NvEventQueueActivity private void checkFacebookDialog() { if (ConnectionState.isConnected() && - MWMApplication.get().shouldShowDialog(MWMApplication.FACEBOOK) && + // TODO If new dialog display logic will be fine - move it to core and uncomment the following line + // MWMApplication.get().shouldShowDialog(MWMApplication.FACEBOOK) && + Arrays.asList(MWMApplication.FACEBOOK_RATE_LAUNCHES).contains(MWMApplication.get().getLaunchesNumber()) && + MWMApplication.get().nativeGetBoolean("ShouldShowFacebookDialog", true) && !isChinaRegion()) + mInfoView.postDelayed(mShareFacebookRunnable, 30 * 1000); + } + + private Runnable mShareFacebookRunnable = new Runnable() + { + @Override + public void run() { showDialogImpl(MWMApplication.FACEBOOK, R.string.share_on_facebook_text, new DialogInterface.OnClickListener() @@ -614,7 +628,7 @@ public class MWMActivity extends NvEventQueueActivity } ); } - } + }; private void checkBuyProDialog() { @@ -1281,13 +1295,11 @@ public class MWMActivity extends NvEventQueueActivity protected void onPause() { pauseLocation(); - stopWatchingExternalStorage(); - stopWatchingCompassStatusUpdate(); - super.onPause(); mLocationPredictor.pause(); + mInfoView.removeCallbacks(mShareFacebookRunnable); } @Override diff --git a/android/src/com/mapswithme/maps/MWMApplication.java b/android/src/com/mapswithme/maps/MWMApplication.java index f1826533bc..5e7d2f508c 100644 --- a/android/src/com/mapswithme/maps/MWMApplication.java +++ b/android/src/com/mapswithme/maps/MWMApplication.java @@ -38,7 +38,7 @@ public class MWMApplication extends android.app.Application implements ActiveCou { private final static String TAG = "MWMApplication"; private static final String FOREGROUND_TIME_SETTING = "AllForegroundTime"; - private static final String LAUNCH_NUMBER_SETTING = "LaunchNumber"; + public static final String LAUNCH_NUMBER_SETTING = "LaunchNumber"; public static final String IS_PREINSTALLED = "IsPreinstalled"; private static MWMApplication mSelf; @@ -107,8 +107,8 @@ public class MWMApplication extends android.app.Application implements ActiveCou // init native framework nativeInit(getApkPath(), extStoragePath, extTmpPath, getOBBGooglePath(), - BuildConfig.FLAVOR, BuildConfig.BUILD_TYPE, BuildConfig.IS_PRO, - mIsYota, getResources().getBoolean(R.bool.isTablet)); + BuildConfig.FLAVOR, BuildConfig.BUILD_TYPE, BuildConfig.IS_PRO, + mIsYota, getResources().getBoolean(R.bool.isTablet)); ActiveCountryTree.addListener(this); @@ -226,12 +226,13 @@ public class MWMApplication extends android.app.Application implements ActiveCou public native boolean nativeIsBenchmarking(); - /// @name Dealing with dialogs. - /// @note Constants should be equal with map/dialog_settings.hpp - /// @{ - static public final int FACEBOOK = 0; - static public final int BUYPRO = 1; - static public final int ROUTING = 3; + // Dealing with dialogs. + // Constants should be equal with map/dialog_settings.hpp + public static final int FACEBOOK = 0; + public static final int BUYPRO = 1; + public static final int ROUTING = 3; + + public static final Integer[] FACEBOOK_RATE_LAUNCHES = new Integer[]{3, 7, 10, 15, 21}; public native boolean shouldShowDialog(int dlg); @@ -240,7 +241,7 @@ public class MWMApplication extends android.app.Application implements ActiveCou static public final int NEVER = 2; public native void submitDialogResult(int dlg, int res); - /// @} + // private native void nativeAddLocalization(String name, String value); |