Skip to content

Commit

Permalink
Merge pull request #455 from Iterable/MOB-4537-Remove-OfflineMode-bet…
Browse files Browse the repository at this point in the history
…a-flag

[MOB-4537] - Change from beta to SDKOfflineMode
  • Loading branch information
Ayyanchira authored Jul 12, 2022
2 parents 5782d97 + b0e3f88 commit dce1f4a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public static void setContext(Context context) {

static void loadLastSavedConfiguration(Context context) {
SharedPreferences sharedPref = context.getSharedPreferences(IterableConstants.SHARED_PREFS_SAVED_CONFIGURATION, Context.MODE_PRIVATE);
boolean offlineMode = sharedPref.getBoolean(IterableConstants.SHARED_PREFS_OFFLINE_MODE_BETA_KEY, false);
boolean offlineMode = sharedPref.getBoolean(IterableConstants.SHARED_PREFS_OFFLINE_MODE_KEY, false);
sharedInstance.apiClient.setOfflineProcessingEnabled(offlineMode);
}

Expand All @@ -326,11 +326,11 @@ public void execute(@Nullable String data) {
}
try {
JSONObject jsonData = new JSONObject(data);
boolean offlineConfiguration = jsonData.getBoolean(IterableConstants.SHARED_PREFS_OFFLINE_MODE_BETA_KEY);
boolean offlineConfiguration = jsonData.getBoolean(IterableConstants.KEY_OFFLINE_MODE);
sharedInstance.apiClient.setOfflineProcessingEnabled(offlineConfiguration);
SharedPreferences sharedPref = sharedInstance.getMainActivityContext().getSharedPreferences(IterableConstants.SHARED_PREFS_SAVED_CONFIGURATION, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putBoolean(IterableConstants.SHARED_PREFS_OFFLINE_MODE_BETA_KEY, offlineConfiguration);
editor.putBoolean(IterableConstants.SHARED_PREFS_OFFLINE_MODE_KEY, offlineConfiguration);
editor.apply();
} catch (JSONException e) {
IterableLogger.e(TAG, "Failed to read remote configuration");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public final class IterableConstants {
public static final String KEY_USER = "user";
public static final String KEY_USER_TEXT = "userText";
public static final String KEY_INBOX_SESSION_ID = "inboxSessionId";
public static final String KEY_OFFLINE_MODE = "offlineMode";

//API Endpoint Key Constants
public static final String ENDPOINT_DISABLE_DEVICE = "users/disableDevice";
Expand Down Expand Up @@ -110,8 +111,7 @@ public final class IterableConstants {
public static final int SHARED_PREFS_ATTRIBUTION_INFO_EXPIRATION_HOURS = 24;
public static final String SHARED_PREFS_FCM_MIGRATION_DONE_KEY = "itbl_fcm_migration_done";
public static final String SHARED_PREFS_SAVED_CONFIGURATION = "itbl_saved_configuration";
public static final String SHARED_PREFS_OFFLINE_MODE_BETA_KEY = "offlineModeBeta";
public static final String SHARED_PREFS_OFFLINE_MODE_KEY = "offlineMode";
public static final String SHARED_PREFS_OFFLINE_MODE_KEY = "itbl_offline_mode";

//Action buttons
public static final String ITBL_BUTTON_IDENTIFIER = "identifier";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public void testFetchRemoteConfigurationCalledWhenInForeground() throws Exceptio

server.enqueue(new MockResponse().setResponseCode(200).setBody("{\n" +
" \"offlineMode\": false,\n" +
" \"" + IterableConstants.SHARED_PREFS_OFFLINE_MODE_BETA_KEY + "\": true,\n" +
" \"" + IterableConstants.KEY_OFFLINE_MODE + "\": true,\n" +
" \"someOtherKey1\": \"someOtherValue1\"\n" +
" }"));
IterableActivityMonitor.getInstance().unregisterLifecycleCallbacks(getContext());
Expand Down

0 comments on commit dce1f4a

Please sign in to comment.