Merge "Reorganize sync state menu options for accounts settings" into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
aa76283172
@@ -258,7 +258,7 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
|||||||
public void onPrepareOptionsMenu(Menu menu) {
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
super.onPrepareOptionsMenu(menu);
|
super.onPrepareOptionsMenu(menu);
|
||||||
// Note that this also counts accounts that are not currently displayed
|
// Note that this also counts accounts that are not currently displayed
|
||||||
boolean syncActive = ContentResolver.getCurrentSyncsAsUser(
|
boolean syncActive = !ContentResolver.getCurrentSyncsAsUser(
|
||||||
mUserHandle.getIdentifier()).isEmpty();
|
mUserHandle.getIdentifier()).isEmpty();
|
||||||
menu.findItem(MENU_SYNC_NOW_ID).setVisible(!syncActive);
|
menu.findItem(MENU_SYNC_NOW_ID).setVisible(!syncActive);
|
||||||
menu.findItem(MENU_SYNC_CANCEL_ID).setVisible(syncActive);
|
menu.findItem(MENU_SYNC_CANCEL_ID).setVisible(syncActive);
|
||||||
@@ -367,6 +367,7 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
|||||||
protected void onSyncStateUpdated() {
|
protected void onSyncStateUpdated() {
|
||||||
if (!isResumed()) return;
|
if (!isResumed()) return;
|
||||||
setFeedsState();
|
setFeedsState();
|
||||||
|
getActivity().invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFeedsState() {
|
private void setFeedsState() {
|
||||||
|
@@ -28,7 +28,6 @@ import android.content.SyncInfo;
|
|||||||
import android.content.SyncStatusInfo;
|
import android.content.SyncStatusInfo;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
@@ -84,6 +83,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
|||||||
// If an account type is set, then show only accounts of that type
|
// If an account type is set, then show only accounts of that type
|
||||||
private String mAccountType;
|
private String mAccountType;
|
||||||
// Temporary hack, to deal with backward compatibility
|
// Temporary hack, to deal with backward compatibility
|
||||||
|
// mFirstAccount is used for the injected preferences
|
||||||
private Account mFirstAccount;
|
private Account mFirstAccount;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -170,11 +170,9 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
MenuItem syncNow = menu.add(0, MENU_SYNC_NOW_ID, 0,
|
menu.add(0, MENU_SYNC_NOW_ID, 0, getString(R.string.sync_menu_sync_now))
|
||||||
getString(R.string.sync_menu_sync_now))
|
|
||||||
.setIcon(R.drawable.ic_menu_refresh_holo_dark);
|
.setIcon(R.drawable.ic_menu_refresh_holo_dark);
|
||||||
MenuItem syncCancel = menu.add(0, MENU_SYNC_CANCEL_ID, 0,
|
menu.add(0, MENU_SYNC_CANCEL_ID, 0, getString(R.string.sync_menu_sync_cancel))
|
||||||
getString(R.string.sync_menu_sync_cancel))
|
|
||||||
.setIcon(com.android.internal.R.drawable.ic_menu_close_clear_cancel);
|
.setIcon(com.android.internal.R.drawable.ic_menu_close_clear_cancel);
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
@@ -182,10 +180,10 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
|||||||
@Override
|
@Override
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
super.onPrepareOptionsMenu(menu);
|
super.onPrepareOptionsMenu(menu);
|
||||||
boolean syncActive = ContentResolver.getCurrentSyncsAsUser(
|
boolean syncActive = !ContentResolver.getCurrentSyncsAsUser(
|
||||||
mUserHandle.getIdentifier()).isEmpty();
|
mUserHandle.getIdentifier()).isEmpty();
|
||||||
menu.findItem(MENU_SYNC_NOW_ID).setVisible(!syncActive && mFirstAccount != null);
|
menu.findItem(MENU_SYNC_NOW_ID).setVisible(!syncActive);
|
||||||
menu.findItem(MENU_SYNC_CANCEL_ID).setVisible(syncActive && mFirstAccount != null);
|
menu.findItem(MENU_SYNC_CANCEL_ID).setVisible(syncActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -233,6 +231,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
|||||||
@Override
|
@Override
|
||||||
protected void onSyncStateUpdated() {
|
protected void onSyncStateUpdated() {
|
||||||
showSyncState();
|
showSyncState();
|
||||||
|
getActivity().invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -380,7 +379,6 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
|||||||
getPreferenceScreen().addPreference(preference);
|
getPreferenceScreen().addPreference(preference);
|
||||||
if (mFirstAccount == null) {
|
if (mFirstAccount == null) {
|
||||||
mFirstAccount = account;
|
mFirstAccount = account;
|
||||||
getActivity().invalidateOptionsMenu();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user