Merge "Make advanced storage option sticky..." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
361ccf5eef
@@ -215,9 +215,12 @@ public abstract class BaseActivity extends Activity
|
|||||||
includeState(state);
|
includeState(state);
|
||||||
|
|
||||||
// Advanced roots are shown by default without menu option if forced by config or intent.
|
// Advanced roots are shown by default without menu option if forced by config or intent.
|
||||||
state.showAdvanced = Shared.shouldShowDeviceRoot(this, intent);
|
boolean forceAdvanced = Shared.shouldShowDeviceRoot(this, intent);
|
||||||
|
boolean chosenAdvanced = LocalPreferences.getShowDeviceRoot(this, state.action);
|
||||||
|
state.showAdvanced = forceAdvanced || chosenAdvanced;
|
||||||
|
|
||||||
// Menu option is shown for whitelisted intents if advanced roots are not shown by default.
|
// Menu option is shown for whitelisted intents if advanced roots are not shown by default.
|
||||||
state.showAdvancedOption = !state.showAdvanced && (
|
state.showAdvancedOption = !forceAdvanced && (
|
||||||
Shared.shouldShowFancyFeatures(this)
|
Shared.shouldShowFancyFeatures(this)
|
||||||
|| state.action == ACTION_OPEN
|
|| state.action == ACTION_OPEN
|
||||||
|| state.action == ACTION_CREATE
|
|| state.action == ACTION_CREATE
|
||||||
@@ -483,6 +486,7 @@ public abstract class BaseActivity extends Activity
|
|||||||
Metrics.logUserAction(this,
|
Metrics.logUserAction(this,
|
||||||
display ? Metrics.USER_ACTION_SHOW_ADVANCED : Metrics.USER_ACTION_HIDE_ADVANCED);
|
display ? Metrics.USER_ACTION_SHOW_ADVANCED : Metrics.USER_ACTION_HIDE_ADVANCED);
|
||||||
|
|
||||||
|
LocalPreferences.setShowDeviceRoot(this, mState.action, display);
|
||||||
mState.showAdvanced = display;
|
mState.showAdvanced = display;
|
||||||
RootsFragment.get(getFragmentManager()).onDisplayStateChanged();
|
RootsFragment.get(getFragmentManager()).onDisplayStateChanged();
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ package com.android.documentsui;
|
|||||||
|
|
||||||
import static com.android.documentsui.State.MODE_UNKNOWN;
|
import static com.android.documentsui.State.MODE_UNKNOWN;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -28,11 +25,16 @@ import android.content.SharedPreferences;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import com.android.documentsui.State.ActionType;
|
||||||
import com.android.documentsui.State.ViewMode;
|
import com.android.documentsui.State.ViewMode;
|
||||||
import com.android.documentsui.model.RootInfo;
|
import com.android.documentsui.model.RootInfo;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
public class LocalPreferences {
|
public class LocalPreferences {
|
||||||
private static final String KEY_FILE_SIZE = "fileSize";
|
private static final String KEY_FILE_SIZE = "fileSize";
|
||||||
|
private static final String INCLUDE_DEVICE_ROOT = "includeDeviceRoot-";
|
||||||
private static final String ROOT_VIEW_MODE_PREFIX = "rootViewMode-";
|
private static final String ROOT_VIEW_MODE_PREFIX = "rootViewMode-";
|
||||||
|
|
||||||
public static boolean getDisplayFileSize(Context context) {
|
public static boolean getDisplayFileSize(Context context) {
|
||||||
@@ -48,9 +50,17 @@ public class LocalPreferences {
|
|||||||
getPrefs(context).edit().putBoolean(KEY_FILE_SIZE, display).apply();
|
getPrefs(context).edit().putBoolean(KEY_FILE_SIZE, display).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getShowDeviceRoot(Context context, @ActionType int action) {
|
||||||
|
return getPrefs(context).getBoolean(INCLUDE_DEVICE_ROOT + action, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setShowDeviceRoot(
|
||||||
|
Context context, @ActionType int action, boolean display) {
|
||||||
|
getPrefs(context).edit().putBoolean(INCLUDE_DEVICE_ROOT + action, display).apply();
|
||||||
|
}
|
||||||
|
|
||||||
public static void setViewMode(Context context, RootInfo root, @ViewMode int viewMode) {
|
public static void setViewMode(Context context, RootInfo root, @ViewMode int viewMode) {
|
||||||
assert(viewMode != MODE_UNKNOWN);
|
assert(viewMode != MODE_UNKNOWN);
|
||||||
|
|
||||||
getPrefs(context).edit().putInt(createKey(root), viewMode).apply();
|
getPrefs(context).edit().putInt(createKey(root), viewMode).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user