forked from organicmaps/organicmaps
[android] Added counters migration from settings.ini to the shared preferences
This commit is contained in:
parent
b9b8cafb07
commit
1f02c93b68
5 changed files with 79 additions and 9 deletions
|
@ -86,6 +86,7 @@ import com.mapswithme.maps.widget.placepage.PlacePageView;
|
|||
import com.mapswithme.maps.widget.placepage.PlacePageView.State;
|
||||
import com.mapswithme.util.Animations;
|
||||
import com.mapswithme.util.BottomSheetHelper;
|
||||
import com.mapswithme.util.Counters;
|
||||
import com.mapswithme.util.InputUtils;
|
||||
import com.mapswithme.util.ThemeSwitcher;
|
||||
import com.mapswithme.util.ThemeUtils;
|
||||
|
@ -1062,7 +1063,15 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (mPlacePage != null)
|
||||
mPlacePage.restore();
|
||||
|
||||
LikesManager.INSTANCE.showDialogs(this);
|
||||
if (!LikesManager.INSTANCE.isNewUser() && Counters.isShowReviewForOldUser())
|
||||
{
|
||||
LikesManager.INSTANCE.showRateDialogForOldUser(this);
|
||||
Counters.setShowReviewForOldUser(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LikesManager.INSTANCE.showDialogs(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.mapswithme.maps.editor.ViralFragment;
|
|||
import com.mapswithme.maps.news.BaseNewsFragment;
|
||||
import com.mapswithme.maps.news.FirstStartFragment;
|
||||
import com.mapswithme.maps.news.NewsFragment;
|
||||
import com.mapswithme.util.Config;
|
||||
import com.mapswithme.util.Counters;
|
||||
import com.mapswithme.util.PermissionsUtils;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
@ -115,6 +116,13 @@ public class SplashActivity extends AppCompatActivity
|
|||
if (!mPermissionsGranted || mCanceled)
|
||||
return;
|
||||
|
||||
if (Counters.isMigrationNeeded())
|
||||
{
|
||||
Config.migrateCountersToSharedPrefs();
|
||||
Counters.setMigrationExecuted();
|
||||
Counters.initCounters(this);
|
||||
}
|
||||
|
||||
sFirstStart = FirstStartFragment.showOn(this, this);
|
||||
if (sFirstStart)
|
||||
{
|
||||
|
|
|
@ -93,6 +93,7 @@ public class NewsFragment extends BaseNewsFragment
|
|||
create(activity, NewsFragment.class, listener);
|
||||
|
||||
Counters.setWhatsNewShown();
|
||||
Counters.setShowReviewForOldUser(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,15 @@ import android.support.annotation.NonNull;
|
|||
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
|
||||
import static com.mapswithme.util.Counters.KEY_APP_FIRST_INSTALL_FLAVOR;
|
||||
import static com.mapswithme.util.Counters.KEY_APP_FIRST_INSTALL_VERSION;
|
||||
import static com.mapswithme.util.Counters.KEY_APP_LAST_SESSION_TIMESTAMP;
|
||||
import static com.mapswithme.util.Counters.KEY_APP_LAUNCH_NUMBER;
|
||||
import static com.mapswithme.util.Counters.KEY_APP_SESSION_NUMBER;
|
||||
import static com.mapswithme.util.Counters.KEY_LIKES_LAST_RATED_SESSION;
|
||||
import static com.mapswithme.util.Counters.KEY_MISC_FIRST_START_DIALOG_SEEN;
|
||||
import static com.mapswithme.util.Counters.KEY_MISC_NEWS_LAST_VERSION;
|
||||
|
||||
public final class Config
|
||||
{
|
||||
private static final String KEY_APP_STORAGE = "StoragePath";
|
||||
|
@ -93,6 +102,21 @@ public final class Config
|
|||
nativeSetBoolean(key, value);
|
||||
}
|
||||
|
||||
public static void migrateCountersToSharedPrefs()
|
||||
{
|
||||
MwmApplication.prefs()
|
||||
.edit()
|
||||
.putInt(KEY_APP_LAUNCH_NUMBER, getInt(KEY_APP_LAUNCH_NUMBER))
|
||||
.putInt(KEY_APP_FIRST_INSTALL_VERSION, getInt(KEY_APP_FIRST_INSTALL_VERSION))
|
||||
.putString(KEY_APP_FIRST_INSTALL_FLAVOR, getString(KEY_APP_FIRST_INSTALL_FLAVOR))
|
||||
.putLong(KEY_APP_LAST_SESSION_TIMESTAMP, getLong(KEY_APP_LAST_SESSION_TIMESTAMP))
|
||||
.putInt(KEY_APP_SESSION_NUMBER, getInt(KEY_APP_SESSION_NUMBER))
|
||||
.putBoolean(KEY_MISC_FIRST_START_DIALOG_SEEN, getBool(KEY_MISC_FIRST_START_DIALOG_SEEN))
|
||||
.putInt(KEY_MISC_NEWS_LAST_VERSION, getInt(KEY_MISC_NEWS_LAST_VERSION))
|
||||
.putInt(KEY_LIKES_LAST_RATED_SESSION, getInt(KEY_LIKES_LAST_RATED_SESSION))
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static String getStoragePath()
|
||||
{
|
||||
return getString(KEY_APP_STORAGE);
|
||||
|
|
|
@ -13,16 +13,18 @@ import com.mapswithme.maps.R;
|
|||
|
||||
public final class Counters
|
||||
{
|
||||
private static final String KEY_APP_LAUNCH_NUMBER = "LaunchNumber";
|
||||
private static final String KEY_APP_FIRST_INSTALL_VERSION = "FirstInstallVersion";
|
||||
private static final String KEY_APP_FIRST_INSTALL_FLAVOR = "FirstInstallFlavor";
|
||||
private static final String KEY_APP_LAST_SESSION_TIMESTAMP = "LastSessionTimestamp";
|
||||
private static final String KEY_APP_SESSION_NUMBER = "SessionNumber";
|
||||
private static final String KEY_MISC_FIRST_START_DIALOG_SEEN = "FirstStartDialogSeen";
|
||||
private static final String KEY_MISC_NEWS_LAST_VERSION = "WhatsNewShownVersion";
|
||||
private static final String KEY_LIKES_LAST_RATED_SESSION = "LastRatedSession";
|
||||
static final String KEY_APP_LAUNCH_NUMBER = "LaunchNumber";
|
||||
static final String KEY_APP_FIRST_INSTALL_VERSION = "FirstInstallVersion";
|
||||
static final String KEY_APP_FIRST_INSTALL_FLAVOR = "FirstInstallFlavor";
|
||||
static final String KEY_APP_LAST_SESSION_TIMESTAMP = "LastSessionTimestamp";
|
||||
static final String KEY_APP_SESSION_NUMBER = "SessionNumber";
|
||||
static final String KEY_MISC_FIRST_START_DIALOG_SEEN = "FirstStartDialogSeen";
|
||||
static final String KEY_MISC_NEWS_LAST_VERSION = "WhatsNewShownVersion";
|
||||
static final String KEY_LIKES_LAST_RATED_SESSION = "LastRatedSession";
|
||||
|
||||
private static final String KEY_LIKES_RATED_DIALOG = "RatedDialog";
|
||||
private static final String KEY_SHOW_REVIEW_FOR_OLD_USER = "ShowReviewForOldUser";
|
||||
private static final String KEY_MIGRATION_EXECUTED = "MigrationExecuted";
|
||||
|
||||
private Counters() {}
|
||||
|
||||
|
@ -173,4 +175,30 @@ public final class Counters
|
|||
.apply();
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void setShowReviewForOldUser(boolean value)
|
||||
{
|
||||
MwmApplication.prefs()
|
||||
.edit()
|
||||
.putBoolean(KEY_SHOW_REVIEW_FOR_OLD_USER, value)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean isShowReviewForOldUser()
|
||||
{
|
||||
return MwmApplication.prefs().getBoolean(KEY_SHOW_REVIEW_FOR_OLD_USER, false);
|
||||
}
|
||||
|
||||
public static boolean isMigrationNeeded()
|
||||
{
|
||||
return !MwmApplication.prefs().getBoolean(KEY_MIGRATION_EXECUTED, false);
|
||||
}
|
||||
|
||||
public static void setMigrationExecuted()
|
||||
{
|
||||
MwmApplication.prefs()
|
||||
.edit()
|
||||
.putBoolean(KEY_MIGRATION_EXECUTED, true)
|
||||
.apply();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue