Merge "Fix again bug #15940103 ACTION_SYNC_SETTINGS shows the non-functional ...left arrow button at the top (the back button works)"

This commit is contained in:
Fabrice Di Meglio
2014-07-02 00:25:43 +00:00
committed by Android (Google) Code Review

View File

@@ -285,6 +285,11 @@ public class SettingsActivity extends Activity
BatterySaverSettings.class.getName(), BatterySaverSettings.class.getName(),
}; };
private static final String[] LIKE_SHORTCUT_INTENT_ACTION_ARRAY = {
"android.settings.APPLICATION_DETAILS_SETTINGS"
};
private SharedPreferences mDevelopmentPreferences; private SharedPreferences mDevelopmentPreferences;
private SharedPreferences.OnSharedPreferenceChangeListener mDevelopmentPreferencesListener; private SharedPreferences.OnSharedPreferenceChangeListener mDevelopmentPreferencesListener;
@@ -453,9 +458,13 @@ public class SettingsActivity extends Activity
private static boolean isLikeShortCutIntent(final Intent intent) { private static boolean isLikeShortCutIntent(final Intent intent) {
String action = intent.getAction(); String action = intent.getAction();
return (action != null) && if (action == null) {
(action.equals("android.settings.APPLICATION_DETAILS_SETTINGS") || return false;
action.equals("android.settings.SYNC_SETTINGS")) ; }
for (int i = 0; i < LIKE_SHORTCUT_INTENT_ACTION_ARRAY.length; i++) {
if (LIKE_SHORTCUT_INTENT_ACTION_ARRAY[i].equals(action)) return true;
}
return false;
} }
@Override @Override
@@ -486,14 +495,16 @@ public class SettingsActivity extends Activity
mIsShortcut = isShortCutIntent(intent) || isLikeShortCutIntent(intent) || mIsShortcut = isShortCutIntent(intent) || isLikeShortCutIntent(intent) ||
intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false); intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false);
mIsShowingDashboard = (initialFragmentName == null) && !mIsShortcut;
final ComponentName cn = getIntent().getComponent(); final ComponentName cn = getIntent().getComponent();
final boolean isSubSettings = cn.getClassName().equals(SubSettings.class.getName()); final String className = cn.getClassName();
// If this is a sub settings or not the main Dashboard and not a Shortcut then apply the mIsShowingDashboard = className.equals(Settings.class.getName());
// correct theme for the ActionBar content inset final boolean isSubSettings = className.equals(SubSettings.class.getName());
if (isSubSettings || (!mIsShowingDashboard && !mIsShortcut)) {
// If this is a sub settings or not the main Dashboard and not a Shortcut and not initial
// Fragment then apply the correct theme for the ActionBar content inset
if (isSubSettings ||
(!mIsShowingDashboard && !mIsShortcut && (initialFragmentName == null))) {
setTheme(R.style.Theme_SubSettings); setTheme(R.style.Theme_SubSettings);
} }
@@ -503,9 +514,6 @@ public class SettingsActivity extends Activity
getFragmentManager().addOnBackStackChangedListener(this); getFragmentManager().addOnBackStackChangedListener(this);
mDisplayHomeAsUpEnabled = true;
mDisplaySearch = true;
if (mIsShowingDashboard) { if (mIsShowingDashboard) {
Index.getInstance(getApplicationContext()).update(); Index.getInstance(getApplicationContext()).update();
} }
@@ -535,6 +543,9 @@ public class SettingsActivity extends Activity
if (mIsShortcut) { if (mIsShortcut) {
mDisplayHomeAsUpEnabled = isSubSettings; mDisplayHomeAsUpEnabled = isSubSettings;
mDisplaySearch = false; mDisplaySearch = false;
} else if (isSubSettings) {
mDisplayHomeAsUpEnabled = true;
mDisplaySearch = true;
} }
setTitleFromIntent(intent); setTitleFromIntent(intent);
@@ -542,8 +553,10 @@ public class SettingsActivity extends Activity
switchToFragment(initialFragmentName, initialArguments, true, false, switchToFragment(initialFragmentName, initialArguments, true, false,
mInitialTitleResId, mInitialTitle, false); mInitialTitleResId, mInitialTitle, false);
} else { } else {
// No UP if we are displaying the main Dashboard // No UP affordance if we are displaying the main Dashboard
mDisplayHomeAsUpEnabled = false; mDisplayHomeAsUpEnabled = false;
// Show Search affordance
mDisplaySearch = true;
mInitialTitleResId = R.string.dashboard_title; mInitialTitleResId = R.string.dashboard_title;
switchToFragment(DashboardSummary.class.getName(), null, false, false, switchToFragment(DashboardSummary.class.getName(), null, false, false,
mInitialTitleResId, mInitialTitle, false); mInitialTitleResId, mInitialTitle, false);