forked from organicmaps/organicmaps
[android] Added saving the backup widget state
This commit is contained in:
parent
4830de9d16
commit
6fe042044c
3 changed files with 35 additions and 8 deletions
|
@ -19,6 +19,7 @@ import com.mapswithme.util.ConnectionState;
|
|||
import com.mapswithme.util.DateUtils;
|
||||
import com.mapswithme.util.DialogUtils;
|
||||
import com.mapswithme.util.NetworkPolicy;
|
||||
import com.mapswithme.util.SharedPropertiesUtils;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.LoggerFactory;
|
||||
|
@ -186,6 +187,7 @@ public class BookmarkBackupController implements Authorizer.Callback,
|
|||
{
|
||||
mAuthorizer.attach(this);
|
||||
BookmarkManager.INSTANCE.addCloudListener(this);
|
||||
mBackupView.setExpanded(SharedPropertiesUtils.getBackupWidgetExpanded());
|
||||
updateWidget();
|
||||
}
|
||||
|
||||
|
@ -193,6 +195,7 @@ public class BookmarkBackupController implements Authorizer.Callback,
|
|||
{
|
||||
mAuthorizer.detach();
|
||||
BookmarkManager.INSTANCE.removeCloudListener(this);
|
||||
SharedPropertiesUtils.setBackupWidgetExpanded(mBackupView.getExpanded());
|
||||
}
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data)
|
||||
|
|
|
@ -127,6 +127,21 @@ public class BookmarkBackupView extends LinearLayout
|
|||
R.attr.secondary);
|
||||
}
|
||||
|
||||
public void setExpanded(boolean expanded)
|
||||
{
|
||||
if (mExpanded == expanded)
|
||||
return;
|
||||
|
||||
mExpanded = expanded;
|
||||
UiUtils.showIf(mExpanded, mContentLayout);
|
||||
mTitle.setCompoundDrawablesWithIntrinsicBounds(null, null, getToggle(), null);
|
||||
}
|
||||
|
||||
public boolean getExpanded()
|
||||
{
|
||||
return mExpanded;
|
||||
}
|
||||
|
||||
public void setMessage(@NonNull String msg)
|
||||
{
|
||||
TextView message = mContentLayout.findViewById(R.id.message);
|
||||
|
|
|
@ -11,6 +11,9 @@ import static com.mapswithme.util.Config.KEY_PREF_STATISTICS;
|
|||
public final class SharedPropertiesUtils
|
||||
{
|
||||
private static final String PREFS_SHOW_EMULATE_BAD_STORAGE_SETTING = "ShowEmulateBadStorageSetting";
|
||||
private static final String PREFS_BACKUP_WIDGET_EXPANDED = "BackupWidgetExpanded";
|
||||
private static final SharedPreferences PREFS
|
||||
= PreferenceManager.getDefaultSharedPreferences(MwmApplication.get());
|
||||
|
||||
public static boolean isShowcaseSwitchedOnLocal()
|
||||
{
|
||||
|
@ -30,22 +33,28 @@ public final class SharedPropertiesUtils
|
|||
|
||||
public static void setShouldShowEmulateBadStorageSetting(boolean show)
|
||||
{
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MwmApplication.get());
|
||||
sp.edit().putBoolean(PREFS_SHOW_EMULATE_BAD_STORAGE_SETTING, show).apply();
|
||||
PREFS.edit().putBoolean(PREFS_SHOW_EMULATE_BAD_STORAGE_SETTING, show).apply();
|
||||
}
|
||||
|
||||
public static boolean shouldShowEmulateBadStorageSetting()
|
||||
{
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MwmApplication.get());
|
||||
return sp.getBoolean(PREFS_SHOW_EMULATE_BAD_STORAGE_SETTING, false);
|
||||
return PREFS.getBoolean(PREFS_SHOW_EMULATE_BAD_STORAGE_SETTING, false);
|
||||
}
|
||||
|
||||
public static boolean shouldEmulateBadExternalStorage()
|
||||
{
|
||||
String key = MwmApplication.get()
|
||||
.getString(R.string.pref_emulate_bad_external_storage);
|
||||
return PreferenceManager.getDefaultSharedPreferences(MwmApplication.get())
|
||||
.getBoolean(key, false);
|
||||
String key = MwmApplication.get().getString(R.string.pref_emulate_bad_external_storage);
|
||||
return PREFS.getBoolean(key, false);
|
||||
}
|
||||
|
||||
public static void setBackupWidgetExpanded(boolean expanded)
|
||||
{
|
||||
PREFS.edit().putBoolean(PREFS_BACKUP_WIDGET_EXPANDED, expanded).apply();
|
||||
}
|
||||
|
||||
public static boolean getBackupWidgetExpanded()
|
||||
{
|
||||
return PREFS.getBoolean(PREFS_BACKUP_WIDGET_EXPANDED, true);
|
||||
}
|
||||
|
||||
//Utils class
|
||||
|
|
Loading…
Add table
Reference in a new issue