InstalledApp: show link to Google Play

Shows a Google Play store icon in the App Info actionbar of apps
Excludes aosp built ones, but still works for apps generally found in /system, like SuperSU
The openPlayStore() code was created by @nicholaschum for Substratum, thank you!

BenzoEdit: fixed it for pie and updated drawable
Change-Id: Ic55e572405d97b1f8ae3f8e3b5aceaa38b6a991e
Signed-off-by: mydongistiny <jaysonedson@gmail.com>
Signed-off-by: SagarMakhar <sagarmakhar@gmail.com>
This commit is contained in:
George G
2016-07-02 22:01:03 +03:00
committed by Joey
parent 6a8e2bad20
commit 9b683aec85
3 changed files with 40 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M3,20.5V3.5C3,2.91 3.34,2.39 3.84,2.15L13.69,12L3.84,21.85C3.34,21.6 3,21.09
3,20.5M16.81,15.12L6.05,21.34L14.54,12.85L16.81,15.12M20.16,10.81C20.5,11.08 20.75,11.5 20.75,12C20.75,12.5 20.53,12.9 20.18,13.18L17.89,14.5L15.39,12L17.89,9.5L20.16,10.81M6.05,2.66L16.81,8.88L14.54,11.15L6.05,2.66Z" />
</vector>

View File

@@ -126,4 +126,7 @@
<!-- USB configuration -->
<string name="usb_default_config_title">USB configuration</string>
<string name="usb_default_config_summary">Choose the default behavior when connected to a device via USB</string>
<!-- App details: open play store link if app is user installed -->
<string name="app_play_store">Google Play</string>
</resources>

View File

@@ -37,6 +37,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.UserInfo;
import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.BiometricPrompt;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.CancellationSignal;
@@ -56,6 +57,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesDetailsPreferenceController;
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetailPreferenceController;
@@ -94,6 +96,7 @@ public class AppInfoDashboardFragment extends DashboardFragment
static final int UNINSTALL_UPDATES = 2;
static final int INSTALL_INSTANT_APP_MENU = 3;
static final int ACCESS_RESTRICTED_SETTINGS = 4;
public static final int PLAY_STORE = 5;
// Result code identifiers
@VisibleForTesting
@@ -402,6 +405,9 @@ public class AppInfoDashboardFragment extends DashboardFragment
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
menu.add(0, PLAY_STORE, 0, R.string.app_play_store)
.setIcon(R.drawable.ic_menu_play_store)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
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)
@@ -437,6 +443,10 @@ public class AppInfoDashboardFragment extends DashboardFragment
RestrictedLockUtilsInternal.setMenuItemAsDisabledByAdmin(getActivity(),
uninstallUpdatesItem, mAppsControlDisallowedAdmin);
}
// Utils.isSystemPackage doesn't include all aosp built apps, like Contacts etc. Add them
// and grab the Google Play Store itself (com.android.vending) in the process
menu.findItem(PLAY_STORE).setVisible(!Utils.isSystemPackage(getContext().getResources(), mPm, mPackageInfo)
&& !isAospOrStore(mAppEntry.info.packageName));
}
/** Shows the lock screen if the keyguard is secured. */
@@ -490,6 +500,9 @@ public class AppInfoDashboardFragment extends DashboardFragment
case UNINSTALL_UPDATES:
uninstallPkg(mAppEntry.info.packageName, false, false);
return true;
case PLAY_STORE:
openPlayStore(mAppEntry.info.packageName);
return true;
case ACCESS_RESTRICTED_SETTINGS:
showLockScreen(getContext(), () -> {
if (android.permission.flags.Flags.enhancedConfirmationModeApisEnabled()
@@ -515,7 +528,6 @@ public class AppInfoDashboardFragment extends DashboardFragment
mAppEntry.label);
Toast.makeText(getContext(), toastString, Toast.LENGTH_LONG).show();
});
return true;
}
return super.onOptionsItemSelected(item);
}
@@ -638,6 +650,17 @@ public class AppInfoDashboardFragment extends DashboardFragment
return true;
}
private void openPlayStore(String packageName) {
// Launch an intent to the play store entry
String playURL = "https://play.google.com/store/apps/details?id=" + packageName;
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(playURL));
startActivity(i);
}
private boolean isAospOrStore(String packageName) {
return packageName.contains("com.android");
}
private void uninstallPkg(String packageName, boolean allUsers, boolean andDisable) {
stopListeningToPackageRemove();
// Create new intent to launch Uninstaller activity