From 9ea5b7febadd467dfcfe7aa16033c0ee6485b5fc Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Mon, 8 Feb 2016 21:04:11 +0800 Subject: [PATCH] fixed usage statistics asking all the time updated version --- twidere/build.gradle | 6 ++--- .../activity/UsageStatisticsActivity.java | 26 +++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/twidere/build.gradle b/twidere/build.gradle index d0829c981..ebb548bd6 100644 --- a/twidere/build.gradle +++ b/twidere/build.gradle @@ -23,8 +23,8 @@ android { applicationId "org.mariotaku.twidere" minSdkVersion 14 targetSdkVersion 23 - versionCode 136 - versionName "3.0.1-SNAPSHOT" + versionCode 137 + versionName "3.0.1" multiDexEnabled true buildConfigField 'boolean', 'ENABLE_MEDIA_VIEWER', 'Boolean.parseBoolean("true")' @@ -118,7 +118,7 @@ dependencies { compile 'com.github.mariotaku.MediaViewerLibrary:base:0.9.7' compile 'com.github.mariotaku.MediaViewerLibrary:subsample-image-view:0.9.7' googleCompile 'com.google.android.gms:play-services-maps:8.4.0' -// googleCompile 'com.google.maps.android:android-maps-utils:0.4' + googleCompile 'com.google.maps.android:android-maps-utils:0.4' googleCompile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') { transitive = true } googleCompile ':YouTubeAndroidPlayerApi:1.2.2@jar' fdroidCompile 'org.osmdroid:osmdroid-android:5.1' diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/UsageStatisticsActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/UsageStatisticsActivity.java index 30d39c5d8..d1ea8e0b6 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/UsageStatisticsActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/UsageStatisticsActivity.java @@ -21,15 +21,38 @@ package org.mariotaku.twidere.activity; import android.app.Activity; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceActivity; import org.mariotaku.twidere.Constants; import org.mariotaku.twidere.R; import org.mariotaku.twidere.fragment.SettingsDetailsFragment; +import org.mariotaku.twidere.util.SharedPreferencesWrapper; +import org.mariotaku.twidere.util.dagger.DependencyHolder; public class UsageStatisticsActivity extends Activity implements Constants { + private static final int REQUEST_USAGE_STATISTICS = 201; + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + switch (requestCode) { + case REQUEST_USAGE_STATISTICS: { + DependencyHolder holder = DependencyHolder.get(this); + final SharedPreferencesWrapper prefs = holder.getPreferences(); + if (!prefs.contains(KEY_USAGE_STATISTICS)) { + final SharedPreferences.Editor editor = prefs.edit(); + editor.putBoolean(KEY_USAGE_STATISTICS, prefs.getBoolean(KEY_USAGE_STATISTICS)); + editor.apply(); + } + finish(); + return; + } + } + super.onActivityResult(requestCode, resultCode, data); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -40,8 +63,7 @@ public class UsageStatisticsActivity extends Activity implements Constants { intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsDetailsFragment.class.getName()); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE, R.string.usage_statistics); - startActivity(intent); - finish(); + startActivityForResult(intent, REQUEST_USAGE_STATISTICS); } }