<LinearLayout
android:orientation="vertical"
- android:layout_width="match_parent"
+ android:layout_width="0px"
+ android:layout_weight="1"
android:layout_height="wrap_content" >
<TextView android:id="@+id/app_name"
android:layout_width="wrap_content"
android:text="@string/disabled" />
</LinearLayout>
</LinearLayout>
+
+ <CheckBox android:id="@+id/app_on_sdcard"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="5dip"
+ android:layout_gravity="center_vertical"
+ android:visibility="gone"
+ android:clickable="false"
+ android:focusable="false" />
</LinearLayout>
-
}
public static interface AppFilter {
+ public void init();
public boolean filterApp(ApplicationInfo info);
}
};
public static final AppFilter THIRD_PARTY_FILTER = new AppFilter() {
+ public void init() {
+ }
+
@Override
public boolean filterApp(ApplicationInfo info) {
if ((info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
};
public static final AppFilter ON_SD_CARD_FILTER = new AppFilter() {
+ final CanBeOnSdCardChecker mCanBeOnSdCardChecker
+ = new CanBeOnSdCardChecker();
+
+ public void init() {
+ mCanBeOnSdCardChecker.init();
+ }
+
@Override
public boolean filterApp(ApplicationInfo info) {
- if ((info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
- return true;
- }
- return false;
+ return mCanBeOnSdCardChecker.check(info);
}
};
Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
+ if (filter != null) {
+ filter.init();
+ }
+
List<ApplicationInfo> apps;
synchronized (mEntriesMap) {
apps = new ArrayList<ApplicationInfo>(mApplications);
private ApplicationsState mState;
private ApplicationsState.AppEntry mAppEntry;
private PackageInfo mPackageInfo;
+ private CanBeOnSdCardChecker mCanBeOnSdCardChecker;
private Button mUninstallButton;
private boolean mMoveInProgress = false;
private boolean mUpdatedSysApp = false;
moveDisable = false;
} else {
mMoveAppButton.setText(R.string.move_app_to_sdcard);
- if ((mAppEntry.info.flags & ApplicationInfo.FLAG_FORWARD_LOCK) == 0 &&
- (mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) == 0 &&
- mPackageInfo != null) {
- if (mPackageInfo.installLocation == PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL ||
- mPackageInfo.installLocation == PackageInfo.INSTALL_LOCATION_AUTO) {
- moveDisable = false;
- } else if (mPackageInfo.installLocation
- == PackageInfo.INSTALL_LOCATION_UNSPECIFIED) {
- IPackageManager ipm = IPackageManager.Stub.asInterface(
- ServiceManager.getService("package"));
- int loc;
- try {
- loc = ipm.getInstallLocation();
- } catch (RemoteException e) {
- Log.e(TAG, "Is Pakage Manager running?");
- return;
- }
- if (loc == PackageHelper.APP_INSTALL_EXTERNAL) {
- // For apps with no preference and the default value set
- // to install on sdcard.
- moveDisable = false;
- }
- }
- }
+ mCanBeOnSdCardChecker.init();
+ moveDisable = !mCanBeOnSdCardChecker.check(mAppEntry.info);
}
if (moveDisable) {
mMoveAppButton.setEnabled(false);
mState = ApplicationsState.getInstance(getApplication());
mPm = getPackageManager();
+ mCanBeOnSdCardChecker = new CanBeOnSdCardChecker();
+
setContentView(R.layout.installed_app_details);
mComputingStr = getText(R.string.computing_size);
package com.android.settings.applications;
+import com.android.internal.content.PackageHelper;
import com.android.settings.R;
import com.android.settings.applications.ApplicationsState.AppEntry;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
+import android.content.pm.PackageInfo;
import android.net.Uri;
import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
import android.provider.Settings;
import android.util.Log;
import android.view.LayoutInflater;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
+import android.widget.CheckBox;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView;
import java.util.Comparator;
import java.util.List;
+final class CanBeOnSdCardChecker {
+ final IPackageManager mPm;
+ int mInstallLocation;
+
+ CanBeOnSdCardChecker() {
+ mPm = IPackageManager.Stub.asInterface(
+ ServiceManager.getService("package"));
+ }
+
+ void init() {
+ try {
+ mInstallLocation = mPm.getInstallLocation();
+ } catch (RemoteException e) {
+ Log.e("CanBeOnSdCardChecker", "Is Package Manager running?");
+ return;
+ }
+ }
+
+ boolean check(ApplicationInfo info) {
+ boolean canBe = false;
+ if ((info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
+ canBe = true;
+ } else {
+ if ((info.flags & ApplicationInfo.FLAG_FORWARD_LOCK) == 0 &&
+ (info.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
+ if (info.installLocation == PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL ||
+ info.installLocation == PackageInfo.INSTALL_LOCATION_AUTO) {
+ canBe = true;
+ } else if (info.installLocation
+ == PackageInfo.INSTALL_LOCATION_UNSPECIFIED) {
+ if (mInstallLocation == PackageHelper.APP_INSTALL_EXTERNAL) {
+ // For apps with no preference and the default value set
+ // to install on sdcard.
+ canBe = true;
+ }
+ }
+ }
+ }
+ return canBe;
+ }
+}
+
/**
* Activity to pick an application that will be used to display installation information and
* options to uninstall/delete user data for system applications. This activity
ImageView appIcon;
TextView appSize;
TextView disabled;
+ CheckBox checkBox;
void updateSizeText(ManageApplications ma) {
if (DEBUG) Log.i(TAG, "updateSizeText of " + entry.label + " " + entry
holder.appIcon = (ImageView) convertView.findViewById(R.id.app_icon);
holder.appSize = (TextView) convertView.findViewById(R.id.app_size);
holder.disabled = (TextView) convertView.findViewById(R.id.app_disabled);
+ holder.checkBox = (CheckBox) convertView.findViewById(R.id.app_on_sdcard);
convertView.setTag(holder);
} else {
// Get the ViewHolder back to get fast access to the TextView
} else {
holder.disabled.setVisibility(View.GONE);
}
+ if (mLastFilterMode == FILTER_APPS_SDCARD) {
+ holder.checkBox.setVisibility(View.VISIBLE);
+ holder.checkBox.setChecked((entry.info.flags
+ & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0);
+ } else {
+ holder.checkBox.setVisibility(View.GONE);
+ }
}
mActive.remove(convertView);
mActive.add(convertView);