Bug fixes, UI flow improvements.

Bug: 3173067 - Auto timezone checkbox out of sync with dependency
Bug: 3175116 - Crash when launching Manage Accounts screen
Move "Add Account" to a menu item from a button at the bottom.
This commit is contained in:
Amith Yamasani
2010-11-08 14:28:05 -08:00
parent 38f8a1d0fa
commit ea07165ef2
4 changed files with 34 additions and 36 deletions

View File

@@ -36,28 +36,4 @@
android:layout_height="wrap_content"
android:text="@string/sync_is_failing" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@android:drawable/bottom_bar">
<View
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"/>
<Button android:id="@+id/add_account_button"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_marginTop="5dip"
android:text="@string/add_account_label" />
<View
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>

View File

@@ -86,6 +86,9 @@ public class DateTimeSettings extends SettingsPreferenceFragment
mAutoTimePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME);
mAutoTimePref.setChecked(autoTimeEnabled);
mAutoTimeZonePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME_ZONE);
mAutoTimeZonePref.setChecked(autoTimeZoneEnabled);
mTimePref = findPreference("time");
mTime24Pref = findPreference("24 hour");
mTimeZone = findPreference("timezone");
@@ -313,7 +316,7 @@ public class DateTimeSettings extends SettingsPreferenceFragment
try {
return Settings.System.getInt(getContentResolver(), name) > 0;
} catch (SettingNotFoundException snfe) {
return true;
return false;
}
}

View File

@@ -16,9 +16,8 @@
package com.android.settings;
import com.google.android.collect.Maps;
import com.android.settings.SettingsPreferenceFragment.SettingsDialogFragment;
import com.google.android.collect.Maps;
import android.accounts.Account;
import android.accounts.AccountManager;
@@ -45,6 +44,9 @@ import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
@@ -56,7 +58,8 @@ import java.util.HashSet;
import java.util.Map;
public class ManageAccountsSettings extends PreferenceFragment
implements View.OnClickListener, OnAccountsUpdateListener, DialogCreatable {
implements OnAccountsUpdateListener,
DialogCreatable {
private static final String TAG = ManageAccountsSettings.class.getSimpleName();
private static final String AUTHORITIES_FILTER_KEY = "authorities";
@@ -67,6 +70,8 @@ public class ManageAccountsSettings extends PreferenceFragment
private static final String BACKGROUND_DATA_CHECKBOX_KEY = "backgroundDataCheckBox";
private static final int DIALOG_DISABLE_BACKGROUND_DATA = 1;
private static final int MENU_ADD_ACCOUNT = Menu.FIRST;
private CheckBoxPreference mBackgroundDataCheckBox;
private PreferenceCategory mManageAccountsCategory;
private String[] mAuthorities;
@@ -84,6 +89,8 @@ public class ManageAccountsSettings extends PreferenceFragment
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setHasOptionsMenu(true);
}
@Override
@@ -118,8 +125,6 @@ public class ManageAccountsSettings extends PreferenceFragment
mManageAccountsCategory = (PreferenceCategory)findPreference(MANAGE_ACCOUNTS_CATEGORY_KEY);
mAuthorities = activity.getIntent().getStringArrayExtra(AUTHORITIES_FILTER_KEY);
mAddAccountButton = (Button)view.findViewById(R.id.add_account_button);
mAddAccountButton.setOnClickListener(this);
AccountManager.get(activity).addOnAccountsUpdatedListener(this, null, true);
updateAuthDescriptions(activity);
@@ -190,6 +195,21 @@ public class ManageAccountsSettings extends PreferenceFragment
mDialogFragment.show(getActivity().getFragmentManager(), Integer.toString(dialogId));
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuItem actionItem =
menu.add(0, MENU_ADD_ACCOUNT, 0, R.string.add_account_label)
.setIcon(R.drawable.ic_menu_add);
actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
onAddAccountClicked();
return true;
}
private void setBackgroundDataInt(boolean enabled) {
final ConnectivityManager connManager = (ConnectivityManager)
getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
@@ -309,12 +329,10 @@ public class ManageAccountsSettings extends PreferenceFragment
}
}
public void onClick(View v) {
if (v == mAddAccountButton) {
Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS");
intent.putExtra(AUTHORITIES_FILTER_KEY, mAuthorities);
startActivity(intent);
}
public void onAddAccountClicked() {
Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS");
intent.putExtra(AUTHORITIES_FILTER_KEY, mAuthorities);
startActivity(intent);
}
/* The logic below is copied from AcountPrefernceBase */

View File

@@ -192,4 +192,5 @@ public class Settings extends PreferenceActivity {
public static class DockSettingsActivity extends Settings { }
public static class RunningServicesActivity extends Settings { }
public static class VoiceInputOutputSettingsActivity extends Settings { }
public static class ManageAccountsSettingsActivity extends Settings { }
}