Merge "Only show 2 buttons in app info screen"
This commit is contained in:
@@ -49,11 +49,6 @@
|
|||||||
layout="@layout/two_buttons_panel"
|
layout="@layout/two_buttons_panel"
|
||||||
android:id="@+id/control_buttons_panel"/>
|
android:id="@+id/control_buttons_panel"/>
|
||||||
|
|
||||||
<!-- Force stop and uninstall buttons -->
|
|
||||||
<include
|
|
||||||
layout="@layout/two_buttons_panel"
|
|
||||||
android:id="@+id/more_control_buttons_panel"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@@ -47,6 +47,7 @@ public class HeaderPreference extends Preference {
|
|||||||
final ViewGroup allDetails = (ViewGroup) view.findViewById(R.id.all_details);
|
final ViewGroup allDetails = (ViewGroup) view.findViewById(R.id.all_details);
|
||||||
Utils.forceCustomPadding(allDetails, true /* additive padding */);
|
Utils.forceCustomPadding(allDetails, true /* additive padding */);
|
||||||
mRootView = view;
|
mRootView = view;
|
||||||
|
setShouldDisableView(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -85,6 +85,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
|
|
||||||
// Menu identifiers
|
// Menu identifiers
|
||||||
public static final int UNINSTALL_ALL_USERS_MENU = 1;
|
public static final int UNINSTALL_ALL_USERS_MENU = 1;
|
||||||
|
public static final int UNINSTALL_UPDATES = 2;
|
||||||
|
|
||||||
// Result code identifiers
|
// Result code identifiers
|
||||||
public static final int REQUEST_UNINSTALL = 0;
|
public static final int REQUEST_UNINSTALL = 0;
|
||||||
@@ -110,8 +111,6 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
private boolean mShowUninstalled;
|
private boolean mShowUninstalled;
|
||||||
private HeaderPreference mHeader;
|
private HeaderPreference mHeader;
|
||||||
private Button mUninstallButton;
|
private Button mUninstallButton;
|
||||||
private View mMoreControlButtons;
|
|
||||||
private Button mSpecialDisableButton;
|
|
||||||
private boolean mUpdatedSysApp = false;
|
private boolean mUpdatedSysApp = false;
|
||||||
private TextView mAppVersion;
|
private TextView mAppVersion;
|
||||||
private Button mForceStopButton;
|
private Button mForceStopButton;
|
||||||
@@ -149,34 +148,18 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initUninstallButtons() {
|
private void initUninstallButtons() {
|
||||||
mUpdatedSysApp = (mAppEntry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
|
|
||||||
final boolean isBundled = (mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
|
final boolean isBundled = (mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
|
||||||
boolean enabled = true;
|
boolean enabled = true;
|
||||||
if (mUpdatedSysApp) {
|
|
||||||
mUninstallButton.setText(R.string.app_factory_reset);
|
|
||||||
boolean showSpecialDisable = false;
|
|
||||||
if (isBundled) {
|
|
||||||
showSpecialDisable = handleDisableable(mSpecialDisableButton);
|
|
||||||
mSpecialDisableButton.setOnClickListener(this);
|
|
||||||
}
|
|
||||||
if (mAppControlRestricted) {
|
|
||||||
showSpecialDisable = false;
|
|
||||||
}
|
|
||||||
mMoreControlButtons.setVisibility(showSpecialDisable ? View.VISIBLE : View.GONE);
|
|
||||||
} else {
|
|
||||||
mMoreControlButtons.setVisibility(View.GONE);
|
|
||||||
if (isBundled) {
|
if (isBundled) {
|
||||||
enabled = handleDisableable(mUninstallButton);
|
enabled = handleDisableable(mUninstallButton);
|
||||||
} else if ((mPackageInfo.applicationInfo.flags
|
} else {
|
||||||
& ApplicationInfo.FLAG_INSTALLED) == 0
|
if ((mPackageInfo.applicationInfo.flags & ApplicationInfo.FLAG_INSTALLED) == 0
|
||||||
&& mUserManager.getUsers().size() >= 2) {
|
&& mUserManager.getUsers().size() >= 2) {
|
||||||
// When we have multiple users, there is a separate menu
|
// When we have multiple users, there is a separate menu
|
||||||
// to uninstall for all users.
|
// to uninstall for all users.
|
||||||
mUninstallButton.setText(R.string.uninstall_text);
|
|
||||||
enabled = false;
|
enabled = false;
|
||||||
} else {
|
|
||||||
mUninstallButton.setText(R.string.uninstall_text);
|
|
||||||
}
|
}
|
||||||
|
mUninstallButton.setText(R.string.uninstall_text);
|
||||||
}
|
}
|
||||||
// If this is a device admin, it can't be uninstalled or disabled.
|
// If this is a device admin, it can't be uninstalled or disabled.
|
||||||
// We do this here so the text of the button is still set correctly.
|
// We do this here so the text of the button is still set correctly.
|
||||||
@@ -284,16 +267,12 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
mForceStopButton.setText(R.string.force_stop);
|
mForceStopButton.setText(R.string.force_stop);
|
||||||
mUninstallButton = (Button) btnPanel.findViewById(R.id.left_button);
|
mUninstallButton = (Button) btnPanel.findViewById(R.id.left_button);
|
||||||
mForceStopButton.setEnabled(false);
|
mForceStopButton.setEnabled(false);
|
||||||
|
|
||||||
// Get More Control button panel
|
|
||||||
mMoreControlButtons = mHeader.findViewById(R.id.more_control_buttons_panel);
|
|
||||||
mMoreControlButtons.findViewById(R.id.right_button).setVisibility(View.INVISIBLE);
|
|
||||||
mSpecialDisableButton = (Button) mMoreControlButtons.findViewById(R.id.left_button);
|
|
||||||
mMoreControlButtons.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
menu.add(0, UNINSTALL_UPDATES, 0, R.string.app_factory_reset)
|
||||||
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||||
menu.add(0, UNINSTALL_ALL_USERS_MENU, 1, R.string.uninstall_all_users_text)
|
menu.add(0, UNINSTALL_ALL_USERS_MENU, 1, R.string.uninstall_all_users_text)
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||||
}
|
}
|
||||||
@@ -315,14 +294,19 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
showIt = false;
|
showIt = false;
|
||||||
}
|
}
|
||||||
menu.findItem(UNINSTALL_ALL_USERS_MENU).setVisible(showIt);
|
menu.findItem(UNINSTALL_ALL_USERS_MENU).setVisible(showIt);
|
||||||
|
mUpdatedSysApp = (mAppEntry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
|
||||||
|
menu.findItem(UNINSTALL_UPDATES).setVisible(mUpdatedSysApp && !mAppControlRestricted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
int menuId = item.getItemId();
|
switch (item.getItemId()) {
|
||||||
if (menuId == UNINSTALL_ALL_USERS_MENU) {
|
case UNINSTALL_ALL_USERS_MENU:
|
||||||
uninstallPkg(mAppEntry.info.packageName, true, false);
|
uninstallPkg(mAppEntry.info.packageName, true, false);
|
||||||
return true;
|
return true;
|
||||||
|
case UNINSTALL_UPDATES:
|
||||||
|
showDialogInner(DLG_FACTORY_RESET, 0);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -604,25 +588,23 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
String packageName = mAppEntry.info.packageName;
|
String packageName = mAppEntry.info.packageName;
|
||||||
if(v == mUninstallButton) {
|
if(v == mUninstallButton) {
|
||||||
if (mUpdatedSysApp) {
|
|
||||||
showDialogInner(DLG_FACTORY_RESET, 0);
|
|
||||||
} else {
|
|
||||||
if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
||||||
if (mAppEntry.info.enabled) {
|
if (mAppEntry.info.enabled) {
|
||||||
|
if (mUpdatedSysApp) {
|
||||||
|
showDialogInner(DLG_SPECIAL_DISABLE, 0);
|
||||||
|
} else {
|
||||||
showDialogInner(DLG_DISABLE, 0);
|
showDialogInner(DLG_DISABLE, 0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
new DisableChanger(this, mAppEntry.info,
|
new DisableChanger(this, mAppEntry.info,
|
||||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT)
|
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT)
|
||||||
.execute((Object)null);
|
.execute((Object) null);
|
||||||
}
|
}
|
||||||
} else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
|
} else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
|
||||||
uninstallPkg(packageName, true, false);
|
uninstallPkg(packageName, true, false);
|
||||||
} else {
|
} else {
|
||||||
uninstallPkg(packageName, false, false);
|
uninstallPkg(packageName, false, false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if(v == mSpecialDisableButton) {
|
|
||||||
showDialogInner(DLG_SPECIAL_DISABLE, 0);
|
|
||||||
} else if (v == mForceStopButton) {
|
} else if (v == mForceStopButton) {
|
||||||
showDialogInner(DLG_FORCE_STOP, 0);
|
showDialogInner(DLG_FORCE_STOP, 0);
|
||||||
//forceStopPackage(mAppInfo.packageName);
|
//forceStopPackage(mAppInfo.packageName);
|
||||||
|
Reference in New Issue
Block a user