Merge "Change filter options from being menu items to tabbed views. Remove unused strings."
This commit is contained in:
committed by
Android (Google) Code Review
commit
e751e555f7
@@ -1545,10 +1545,6 @@
|
|||||||
<string name="sort_order_size">Sort by size</string>
|
<string name="sort_order_size">Sort by size</string>
|
||||||
<!-- Manage applications screen, individual app screen, button label when the user wants to manage the space taken up by an app. -->
|
<!-- Manage applications screen, individual app screen, button label when the user wants to manage the space taken up by an app. -->
|
||||||
<string name="manage_space_text">Manage space</string>
|
<string name="manage_space_text">Manage space</string>
|
||||||
<!-- Text for menu option in ManageApps screen to present various menu options -->
|
|
||||||
<string name="filter">Filter</string>
|
|
||||||
<!-- Title of dialog for presenting filter options -->
|
|
||||||
<string name="filter_dlg_title">Select filter options</string>
|
|
||||||
<!-- Text for filter option in ManageApps screen to display all installed
|
<!-- Text for filter option in ManageApps screen to display all installed
|
||||||
applications -->
|
applications -->
|
||||||
<string name="filter_apps_all">All</string>
|
<string name="filter_apps_all">All</string>
|
||||||
|
@@ -17,11 +17,12 @@
|
|||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.ListActivity;
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.app.TabActivity;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@@ -42,8 +43,8 @@ import android.os.Handler;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.Config;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.SparseArray;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -56,6 +57,7 @@ import android.widget.Filter;
|
|||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.TabHost;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
|
||||||
@@ -100,23 +102,23 @@ import java.util.concurrent.CountDownLatch;
|
|||||||
* If the user selects an application, extended info(like size, uninstall/clear data options,
|
* If the user selects an application, extended info(like size, uninstall/clear data options,
|
||||||
* permissions info etc.,) is displayed via the InstalledAppDetails activity.
|
* permissions info etc.,) is displayed via the InstalledAppDetails activity.
|
||||||
*/
|
*/
|
||||||
public class ManageApplications extends ListActivity implements
|
public class ManageApplications extends TabActivity implements
|
||||||
OnItemClickListener, DialogInterface.OnCancelListener,
|
OnItemClickListener, DialogInterface.OnCancelListener,
|
||||||
DialogInterface.OnClickListener {
|
TabHost.TabContentFactory,
|
||||||
|
TabHost.OnTabChangeListener {
|
||||||
// TAG for this activity
|
// TAG for this activity
|
||||||
private static final String TAG = "ManageApplications";
|
private static final String TAG = "ManageApplications";
|
||||||
private static final String PREFS_NAME = "ManageAppsInfo.prefs";
|
private static final String PREFS_NAME = "ManageAppsInfo.prefs";
|
||||||
private static final String PREF_DISABLE_CACHE = "disableCache";
|
private static final String PREF_DISABLE_CACHE = "disableCache";
|
||||||
|
|
||||||
// Log information boolean
|
// Log information boolean
|
||||||
private boolean localLOGV = Config.LOGV || false;
|
private boolean localLOGV = false;
|
||||||
private static final boolean DEBUG_SIZE = false;
|
private static final boolean DEBUG_SIZE = false;
|
||||||
private static final boolean DEBUG_TIME = false;
|
private static final boolean DEBUG_TIME = false;
|
||||||
|
|
||||||
// attributes used as keys when passing values to InstalledAppDetails activity
|
// attributes used as keys when passing values to InstalledAppDetails activity
|
||||||
public static final String APP_PKG_PREFIX = "com.android.settings.";
|
public static final String APP_PKG_NAME = "pkg";
|
||||||
public static final String APP_PKG_NAME = APP_PKG_PREFIX+"ApplicationPkgName";
|
public static final String APP_CHG = "chg";
|
||||||
public static final String APP_CHG = APP_PKG_PREFIX+"changed";
|
|
||||||
|
|
||||||
// attribute name used in receiver for tagging names of added/deleted packages
|
// attribute name used in receiver for tagging names of added/deleted packages
|
||||||
private static final String ATTR_PKG_NAME="p";
|
private static final String ATTR_PKG_NAME="p";
|
||||||
@@ -141,8 +143,6 @@ public class ManageApplications extends ListActivity implements
|
|||||||
public static final int FILTER_OPTIONS = MENU_OPTIONS_BASE + 3;
|
public static final int FILTER_OPTIONS = MENU_OPTIONS_BASE + 3;
|
||||||
public static final int SORT_ORDER_ALPHA = MENU_OPTIONS_BASE + 4;
|
public static final int SORT_ORDER_ALPHA = MENU_OPTIONS_BASE + 4;
|
||||||
public static final int SORT_ORDER_SIZE = MENU_OPTIONS_BASE + 5;
|
public static final int SORT_ORDER_SIZE = MENU_OPTIONS_BASE + 5;
|
||||||
// Alert Dialog presented to user to find out the filter option
|
|
||||||
private AlertDialog mAlertDlg;
|
|
||||||
// sort order
|
// sort order
|
||||||
private int mSortOrder = SORT_ORDER_ALPHA;
|
private int mSortOrder = SORT_ORDER_ALPHA;
|
||||||
// Filter value
|
// Filter value
|
||||||
@@ -1554,6 +1554,10 @@ public class ManageApplications extends ListActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final String TAB_DOWNLOADED = "Downloaded";
|
||||||
|
static final String TAB_RUNNING = "Running";
|
||||||
|
static final String TAB_ALL = "All";
|
||||||
|
private View mRootView;
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -1564,9 +1568,11 @@ public class ManageApplications extends ListActivity implements
|
|||||||
}
|
}
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
String defaultTabTag = TAB_DOWNLOADED;
|
||||||
if (action.equals(Intent.ACTION_MANAGE_PACKAGE_STORAGE)) {
|
if (action.equals(Intent.ACTION_MANAGE_PACKAGE_STORAGE)) {
|
||||||
mSortOrder = SORT_ORDER_SIZE;
|
mSortOrder = SORT_ORDER_SIZE;
|
||||||
mFilterApps = FILTER_APPS_ALL;
|
mFilterApps = FILTER_APPS_ALL;
|
||||||
|
defaultTabTag = TAB_ALL;
|
||||||
mSizesFirst = true;
|
mSizesFirst = true;
|
||||||
}
|
}
|
||||||
mPm = getPackageManager();
|
mPm = getPackageManager();
|
||||||
@@ -1574,20 +1580,20 @@ public class ManageApplications extends ListActivity implements
|
|||||||
requestWindowFeature(Window.FEATURE_RIGHT_ICON);
|
requestWindowFeature(Window.FEATURE_RIGHT_ICON);
|
||||||
requestWindowFeature(Window.FEATURE_PROGRESS);
|
requestWindowFeature(Window.FEATURE_PROGRESS);
|
||||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||||
setContentView(R.layout.compute_sizes);
|
|
||||||
showLoadingMsg();
|
showLoadingMsg();
|
||||||
mDefaultAppIcon =Resources.getSystem().getDrawable(
|
mDefaultAppIcon = Resources.getSystem().getDrawable(
|
||||||
com.android.internal.R.drawable.sym_def_app_icon);
|
com.android.internal.R.drawable.sym_def_app_icon);
|
||||||
mInvalidSizeStr = getText(R.string.invalid_size_value);
|
mInvalidSizeStr = getText(R.string.invalid_size_value);
|
||||||
mComputingSizeStr = getText(R.string.computing_size);
|
mComputingSizeStr = getText(R.string.computing_size);
|
||||||
// initialize the inflater
|
// initialize the inflater
|
||||||
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
mRootView = mInflater.inflate(R.layout.compute_sizes, null);
|
||||||
mReceiver = new PackageIntentReceiver();
|
mReceiver = new PackageIntentReceiver();
|
||||||
mObserver = new PkgSizeObserver();
|
mObserver = new PkgSizeObserver();
|
||||||
// Create adapter and list view here
|
// Create adapter and list view here
|
||||||
List<ApplicationInfo> appList = getInstalledApps(mSortOrder);
|
List<ApplicationInfo> appList = getInstalledApps(mSortOrder);
|
||||||
mAppInfoAdapter = new AppInfoAdapter(this, appList);
|
mAppInfoAdapter = new AppInfoAdapter(this, appList);
|
||||||
ListView lv= (ListView) findViewById(android.R.id.list);
|
ListView lv = (ListView) mRootView.findViewById(android.R.id.list);
|
||||||
lv.setOnItemClickListener(this);
|
lv.setOnItemClickListener(this);
|
||||||
lv.setSaveEnabled(true);
|
lv.setSaveEnabled(true);
|
||||||
lv.setItemsCanFocus(true);
|
lv.setItemsCanFocus(true);
|
||||||
@@ -1607,6 +1613,18 @@ public class ManageApplications extends ListActivity implements
|
|||||||
if (DEBUG_TIME) {
|
if (DEBUG_TIME) {
|
||||||
Log.i(TAG, "Took " + (SystemClock.elapsedRealtime()-sStart) + " ms to init cache");
|
Log.i(TAG, "Took " + (SystemClock.elapsedRealtime()-sStart) + " ms to init cache");
|
||||||
}
|
}
|
||||||
|
final TabHost tabHost = getTabHost();
|
||||||
|
tabHost.addTab(tabHost.newTabSpec(TAB_DOWNLOADED)
|
||||||
|
.setIndicator(getString(R.string.filter_apps_third_party))
|
||||||
|
.setContent(this));
|
||||||
|
tabHost.addTab(tabHost.newTabSpec(TAB_RUNNING)
|
||||||
|
.setIndicator(getString(R.string.filter_apps_running))
|
||||||
|
.setContent(this));
|
||||||
|
tabHost.addTab(tabHost.newTabSpec(TAB_ALL)
|
||||||
|
.setIndicator(getString(R.string.filter_apps_all))
|
||||||
|
.setContent(this));
|
||||||
|
tabHost.setCurrentTabByTag(defaultTabTag);
|
||||||
|
tabHost.setOnTabChangedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
@@ -1922,8 +1940,6 @@ public class ManageApplications extends ListActivity implements
|
|||||||
.setIcon(android.R.drawable.ic_menu_sort_alphabetically);
|
.setIcon(android.R.drawable.ic_menu_sort_alphabetically);
|
||||||
menu.add(0, SORT_ORDER_SIZE, 2, R.string.sort_order_size)
|
menu.add(0, SORT_ORDER_SIZE, 2, R.string.sort_order_size)
|
||||||
.setIcon(android.R.drawable.ic_menu_sort_by_size);
|
.setIcon(android.R.drawable.ic_menu_sort_by_size);
|
||||||
menu.add(0, FILTER_OPTIONS, 3, R.string.filter)
|
|
||||||
.setIcon(R.drawable.ic_menu_filter_settings);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1932,7 +1948,6 @@ public class ManageApplications extends ListActivity implements
|
|||||||
if (mFirst) {
|
if (mFirst) {
|
||||||
menu.findItem(SORT_ORDER_ALPHA).setVisible(mSortOrder != SORT_ORDER_ALPHA);
|
menu.findItem(SORT_ORDER_ALPHA).setVisible(mSortOrder != SORT_ORDER_ALPHA);
|
||||||
menu.findItem(SORT_ORDER_SIZE).setVisible(mSortOrder != SORT_ORDER_SIZE);
|
menu.findItem(SORT_ORDER_SIZE).setVisible(mSortOrder != SORT_ORDER_SIZE);
|
||||||
menu.findItem(FILTER_OPTIONS).setVisible(true);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -1943,20 +1958,6 @@ public class ManageApplications extends ListActivity implements
|
|||||||
int menuId = item.getItemId();
|
int menuId = item.getItemId();
|
||||||
if ((menuId == SORT_ORDER_ALPHA) || (menuId == SORT_ORDER_SIZE)) {
|
if ((menuId == SORT_ORDER_ALPHA) || (menuId == SORT_ORDER_SIZE)) {
|
||||||
sendMessageToHandler(REORDER_LIST, menuId);
|
sendMessageToHandler(REORDER_LIST, menuId);
|
||||||
} else if (menuId == FILTER_OPTIONS) {
|
|
||||||
// Pick up the selection value from the list of added choice items.
|
|
||||||
int selection = mFilterApps - MENU_OPTIONS_BASE;
|
|
||||||
if (mAlertDlg == null) {
|
|
||||||
mAlertDlg = new AlertDialog.Builder(this).
|
|
||||||
setTitle(R.string.filter_dlg_title).
|
|
||||||
setNeutralButton(R.string.cancel, this).
|
|
||||||
setSingleChoiceItems(new CharSequence[] {getText(R.string.filter_apps_all),
|
|
||||||
getText(R.string.filter_apps_running),
|
|
||||||
getText(R.string.filter_apps_third_party)},
|
|
||||||
selection, this).
|
|
||||||
create();
|
|
||||||
}
|
|
||||||
mAlertDlg.show();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1973,22 +1974,22 @@ public class ManageApplications extends ListActivity implements
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public View createTabContent(String tag) {
|
||||||
|
return mRootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTabChanged(String tabId) {
|
||||||
int newOption;
|
int newOption;
|
||||||
switch (which) {
|
if (TAB_DOWNLOADED.equalsIgnoreCase(tabId)) {
|
||||||
// Make sure that values of 0, 1, 2 match options all, running, third_party when
|
newOption = FILTER_APPS_THIRD_PARTY;
|
||||||
// created via the AlertDialog.Builder
|
} else if (TAB_RUNNING.equalsIgnoreCase(tabId)) {
|
||||||
case FILTER_APPS_ALL:
|
newOption = FILTER_APPS_RUNNING;
|
||||||
break;
|
} else if (TAB_ALL.equalsIgnoreCase(tabId)) {
|
||||||
case FILTER_APPS_RUNNING:
|
newOption = FILTER_APPS_ALL;
|
||||||
break;
|
} else {
|
||||||
case FILTER_APPS_THIRD_PARTY:
|
// Invalid option. Do nothing
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newOption = which;
|
|
||||||
mAlertDlg.dismiss();
|
|
||||||
sendMessageToHandler(REORDER_LIST, newOption);
|
sendMessageToHandler(REORDER_LIST, newOption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user