Use Drawer in Settings app

- get rid of PreferenceActivity as much as we can and use fragments instead
- add Drawer widget
- add Dashboard high level entry into the Drawer (but this is work in progress and would be done in another CL)
- add bypass of fragment's Header  validation when launched from the Drawer but *force* validation if external
call thru an Intent

Be aware that WifiPickerActivity should remain for now a PreferenceActivity. It is used by SetupWizard and should
not trigger running the SettingsActivity's header building code. SetupWizard is a Home during the provisionnig process
and then deactivate itself as a Home but would make the Home header to appear in the Drawer (because momentarily we
would have two Home).

Also, verified that:

- the WiFi settings still work when called from SetupWizard
- when you have multiple Launchers, the Home header will appear in the list of Headers in the Drawer

Change-Id: I407a5e0fdd843ad7615d3d511c416a44e3d97c90
This commit is contained in:
Fabrice Di Meglio
2014-01-17 19:17:58 -08:00
parent af79ddb358
commit 263bcc8b73
76 changed files with 2475 additions and 1494 deletions

View File

@@ -33,12 +33,12 @@ import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.provider.Telephony;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;
@@ -49,7 +49,7 @@ import com.android.internal.telephony.TelephonyProperties;
import java.util.ArrayList;
public class ApnSettings extends PreferenceActivity implements
public class ApnSettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener {
static final String TAG = "ApnSettings";
@@ -116,7 +116,7 @@ public class ApnSettings extends PreferenceActivity implements
}
@Override
protected void onCreate(Bundle icicle) {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.apn_settings);
@@ -127,10 +127,10 @@ public class ApnSettings extends PreferenceActivity implements
}
@Override
protected void onResume() {
public void onResume() {
super.onResume();
registerReceiver(mMobileStateReceiver, mMobileStateFilter);
getActivity().registerReceiver(mMobileStateReceiver, mMobileStateFilter);
if (!mRestoreDefaultApnMode) {
fillList();
@@ -140,14 +140,14 @@ public class ApnSettings extends PreferenceActivity implements
}
@Override
protected void onPause() {
public void onPause() {
super.onPause();
unregisterReceiver(mMobileStateReceiver);
getActivity().unregisterReceiver(mMobileStateReceiver);
}
@Override
protected void onDestroy() {
public void onDestroy() {
super.onDestroy();
if (mRestoreDefaultApnThread != null) {
@@ -178,7 +178,7 @@ public class ApnSettings extends PreferenceActivity implements
String key = cursor.getString(ID_INDEX);
String type = cursor.getString(TYPES_INDEX);
ApnPreference pref = new ApnPreference(this);
ApnPreference pref = new ApnPreference(getActivity());
pref.setKey(key);
pref.setTitle(name);
@@ -207,8 +207,8 @@ public class ApnSettings extends PreferenceActivity implements
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
menu.add(0, MENU_NEW, 0,
getResources().getString(R.string.menu_new))
.setIcon(android.R.drawable.ic_menu_add)
@@ -216,7 +216,6 @@ public class ApnSettings extends PreferenceActivity implements
menu.add(0, MENU_RESTORE, 0,
getResources().getString(R.string.menu_restore))
.setIcon(android.R.drawable.ic_menu_upload);
return true;
}
@Override
@@ -308,9 +307,9 @@ public class ApnSettings extends PreferenceActivity implements
fillList();
getPreferenceScreen().setEnabled(true);
mRestoreDefaultApnMode = false;
dismissDialog(DIALOG_RESTORE_DEFAULTAPN);
removeDialog(DIALOG_RESTORE_DEFAULTAPN);
Toast.makeText(
ApnSettings.this,
getActivity(),
getResources().getString(
R.string.restore_default_apn_completed),
Toast.LENGTH_LONG).show();
@@ -341,20 +340,14 @@ public class ApnSettings extends PreferenceActivity implements
}
@Override
protected Dialog onCreateDialog(int id) {
public Dialog onCreateDialog(int id) {
if (id == DIALOG_RESTORE_DEFAULTAPN) {
ProgressDialog dialog = new ProgressDialog(this);
getPreferenceScreen().setEnabled(false);
ProgressDialog dialog = new ProgressDialog(getActivity());
dialog.setMessage(getResources().getString(R.string.restore_default_apn));
dialog.setCancelable(false);
return dialog;
}
return null;
}
@Override
protected void onPrepareDialog(int id, Dialog dialog) {
if (id == DIALOG_RESTORE_DEFAULTAPN) {
getPreferenceScreen().setEnabled(false);
}
}
}