[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake-mobile/master] Reformated AppPreferenceConstants to AppPreferenceKeys



commit 63ba408df3179e3e22082cf03d52b0e070118626
Author: Hashik Donthineni <HashikDonthineni@xxxxxxxxx>
Date:   Thu Jul 30 20:48:14 2020 +0530

    Reformated AppPreferenceConstants to AppPreferenceKeys
---
 .../org/torproject/snowflake/MyPersistentService.java  | 12 ++++++------
 ...PreferenceConstants.java => AppPreferenceKeys.java} |  2 +-
 .../torproject/snowflake/models/MainActivityModel.java | 18 +++++++++---------
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/app/src/main/java/org/torproject/snowflake/MyPersistentService.java b/app/src/main/java/org/torproject/snowflake/MyPersistentService.java
index 2444255..c23a084 100644
--- a/app/src/main/java/org/torproject/snowflake/MyPersistentService.java
+++ b/app/src/main/java/org/torproject/snowflake/MyPersistentService.java
@@ -16,7 +16,7 @@ import androidx.annotation.Nullable;
 
 import org.jetbrains.annotations.NotNull;
 import org.json.JSONException;
-import org.torproject.snowflake.constants.AppPreferenceConstants;
+import org.torproject.snowflake.constants.AppPreferenceKeys;
 import org.torproject.snowflake.constants.BrokerConstants;
 import org.torproject.snowflake.constants.ForegroundServiceConstants;
 import org.torproject.snowflake.exceptions.EmptySIDException;
@@ -81,7 +81,7 @@ public class MyPersistentService extends Service {
     public int onStartCommand(Intent intent, int flags, int startId) {
         Log.d(TAG, "onStartCommand: executed with startId: " + startId);
         sharedPreferences = getSharedPreferences(getString(R.string.sharedpreference_file), MODE_PRIVATE);
-        isServiceStarted = sharedPreferences.getBoolean(AppPreferenceConstants.IS_SERVICE_RUNNING_KEY, false);
+        isServiceStarted = sharedPreferences.getBoolean(AppPreferenceKeys.IS_SERVICE_RUNNING_KEY, false);
 
         if (intent != null) {
             if (intent.getAction().equals(ForegroundServiceConstants.ACTION_START))
@@ -133,10 +133,10 @@ public class MyPersistentService extends Service {
 
         if (setState == ForegroundServiceConstants.SERVICE_RUNNING) {
             isServiceStarted = true;
-            editor.putBoolean(AppPreferenceConstants.IS_SERVICE_RUNNING_KEY, true);
+            editor.putBoolean(AppPreferenceKeys.IS_SERVICE_RUNNING_KEY, true);
         } else {
             isServiceStarted = false;
-            editor.putBoolean(AppPreferenceConstants.IS_SERVICE_RUNNING_KEY, false);
+            editor.putBoolean(AppPreferenceKeys.IS_SERVICE_RUNNING_KEY, false);
         }
         editor.apply();
     }
@@ -147,8 +147,8 @@ public class MyPersistentService extends Service {
     private void updateServedCount() {
         SharedPreferences sp = GlobalApplication.getAppPreferences();
         sp.edit()
-                .putInt(AppPreferenceConstants.USER_SERVED_KEY,
-                        sp.getInt(AppPreferenceConstants.USER_SERVED_KEY, 0) + 1)
+                .putInt(AppPreferenceKeys.USER_SERVED_KEY,
+                        sp.getInt(AppPreferenceKeys.USER_SERVED_KEY, 0) + 1)
                 .apply();
     }
 
diff --git a/app/src/main/java/org/torproject/snowflake/constants/AppPreferenceConstants.java b/app/src/main/java/org/torproject/snowflake/constants/AppPreferenceKeys.java
similarity index 88%
rename from app/src/main/java/org/torproject/snowflake/constants/AppPreferenceConstants.java
rename to app/src/main/java/org/torproject/snowflake/constants/AppPreferenceKeys.java
index 58400a4..835304e 100644
--- a/app/src/main/java/org/torproject/snowflake/constants/AppPreferenceConstants.java
+++ b/app/src/main/java/org/torproject/snowflake/constants/AppPreferenceKeys.java
@@ -1,6 +1,6 @@
 package org.torproject.snowflake.constants;
 
-public class AppPreferenceConstants {
+public class AppPreferenceKeys {
     public static final String USER_SERVED_KEY = "users_served";
     public static final String DATE_KEY = "date";
     public static final String INITIAL_RUN_KEY = "initial_run";
diff --git a/app/src/main/java/org/torproject/snowflake/models/MainActivityModel.java b/app/src/main/java/org/torproject/snowflake/models/MainActivityModel.java
index 01cdb14..66c5f4c 100644
--- a/app/src/main/java/org/torproject/snowflake/models/MainActivityModel.java
+++ b/app/src/main/java/org/torproject/snowflake/models/MainActivityModel.java
@@ -4,7 +4,7 @@ import android.content.SharedPreferences;
 import android.util.Log;
 
 import org.torproject.snowflake.GlobalApplication;
-import org.torproject.snowflake.constants.AppPreferenceConstants;
+import org.torproject.snowflake.constants.AppPreferenceKeys;
 import org.torproject.snowflake.mvp.MainActivityMVPContract;
 
 import java.text.ParseException;
@@ -44,19 +44,19 @@ public class MainActivityModel implements MainActivityMVPContract.Model {
     }
 
     public int getServedCount() {
-        return sharedPreferences.getInt(AppPreferenceConstants.USER_SERVED_KEY, 0);
+        return sharedPreferences.getInt(AppPreferenceKeys.USER_SERVED_KEY, 0);
     }
 
     public boolean getInitialRunBool() {
-        return sharedPreferences.getBoolean(AppPreferenceConstants.INITIAL_RUN_KEY, true);
+        return sharedPreferences.getBoolean(AppPreferenceKeys.INITIAL_RUN_KEY, true);
     }
 
     public void setInitialRunBool(boolean val) {
-        sharedPreferences.edit().putBoolean(AppPreferenceConstants.INITIAL_RUN_KEY, val).apply();
+        sharedPreferences.edit().putBoolean(AppPreferenceKeys.INITIAL_RUN_KEY, val).apply();
     }
 
     public boolean isServiceRunning() {
-        return sharedPreferences.getBoolean(AppPreferenceConstants.IS_SERVICE_RUNNING_KEY, false);
+        return sharedPreferences.getBoolean(AppPreferenceKeys.IS_SERVICE_RUNNING_KEY, false);
     }
 
     /**
@@ -71,7 +71,7 @@ public class MainActivityModel implements MainActivityMVPContract.Model {
         listener = (prefs, key) -> {
             Log.d(TAG, "setListenerForCount: Listener: Key = " + key);
 
-            if (key.equals(AppPreferenceConstants.USER_SERVED_KEY)) {
+            if (key.equals(AppPreferenceKeys.USER_SERVED_KEY)) {
                 servedCount = sharedPreferences.getInt(key, 0);
                 if (presenter != null)
                     presenter.updateServedCount(servedCount);
@@ -82,7 +82,7 @@ public class MainActivityModel implements MainActivityMVPContract.Model {
     }
 
     public String getDate() {
-        return sharedPreferences.getString(AppPreferenceConstants.DATE_KEY, "");
+        return sharedPreferences.getString(AppPreferenceKeys.DATE_KEY, "");
     }
 
     /**
@@ -90,8 +90,8 @@ public class MainActivityModel implements MainActivityMVPContract.Model {
      */
     public void setDateAndServed(String date, int value) {
         SharedPreferences.Editor editor = sharedPreferences.edit();
-        editor.putString(AppPreferenceConstants.DATE_KEY, date);
-        editor.putInt(AppPreferenceConstants.USER_SERVED_KEY, value);
+        editor.putString(AppPreferenceKeys.DATE_KEY, date);
+        editor.putInt(AppPreferenceKeys.USER_SERVED_KEY, value);
         editor.apply();
     }
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits