Skip to content

Commit

Permalink
Added list of permissions into the app detailed page for listing of a…
Browse files Browse the repository at this point in the history
…pplications

One of the todos of #8
  • Loading branch information
itachi1706 committed Sep 3, 2016
1 parent 3950914 commit 91a35cf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,30 @@ protected Void doInBackground(Boolean... params) {
if (!system) continue;
}
String version = "Unknown";
String[] requestedPermissions = null;
try {
PackageInfo pInfo = getPackageManager().getPackageInfo(i.packageName, 0);
PackageInfo pInfo = getPackageManager().getPackageInfo(i.packageName, PackageManager.GET_PERMISSIONS);
requestedPermissions = pInfo.requestedPermissions;
version = pInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}

String permissionList = "";
if (requestedPermissions != null) {
for (String s : requestedPermissions) {
permissionList += s + "\n";
}
}

AppsItem item = new AppsItem(getApplicationContext());
item.setApiVersion(i.targetSdkVersion);
item.setAppName(i.loadLabel(pm).toString());
item.setAppPath(i.sourceDir);
item.setPackageName(i.packageName);
item.setIcon(i.loadIcon(pm));
item.setVersion(version);
item.setPermissions(permissionList);
finalStr.add(item);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,31 @@
* for com.itachi1706.cheesecakeutilities.Modules.ListApplications.Objects in CheesecakeUtilities
*/
public class AppsItem {
private String appName, appPath, packageName, version;
private String appName, appPath, packageName, version, permissions;
private int apiVersion;
private Drawable icon;

public AppsItem(Context context) {
this.icon = ContextCompat.getDrawable(context, R.mipmap.ic_launcher);
}

public AppsItem(Context context, String appName, String appPath, int apiVersion, String packageName, String version) {
public AppsItem(Context context, String appName, String appPath, int apiVersion, String packageName, String version, String permissions) {
this.appName = appName;
this.appPath = appPath;
this.apiVersion = apiVersion;
this.packageName = packageName;
this.version = version;
this.permissions = permissions;
this.icon = ContextCompat.getDrawable(context, R.mipmap.ic_launcher);
}

public AppsItem(String appName, String appPath, int apiVersion, String packageName, Drawable icon, String version) {
public AppsItem(String appName, String appPath, int apiVersion, String packageName, Drawable icon, String version, String permissions) {
this.appName = appName;
this.appPath = appPath;
this.apiVersion = apiVersion;
this.packageName = packageName;
this.version = version;
this.permissions = permissions;
this.icon = icon;
}

Expand Down Expand Up @@ -84,4 +86,12 @@ public String getVersion() {
public void setVersion(String version) {
this.version = version;
}

public String getPermissions() {
return permissions;
}

public void setPermissions(String permissions) {
this.permissions = permissions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public void onBindViewHolder(AppsViewHolder appsViewHolder, int i)
appsViewHolder.appLocation = s.getAppPath();
appsViewHolder.version = s.getVersion();
appsViewHolder.appVersion.setText("Version: " + s.getVersion());
appsViewHolder.permissions = (s.getPermissions().equals("") ? "No Permissions Requested" : s.getPermissions());
}

@Override
Expand All @@ -111,7 +112,7 @@ public class AppsViewHolder extends RecyclerView.ViewHolder implements View.OnCl

protected TextView appName, appPackageName, appApiVersion, appVersion;
protected ImageView appIcon;
protected String appLocation, version;
protected String appLocation, version, permissions;

public AppsViewHolder(View v)
{
Expand All @@ -131,7 +132,8 @@ public void onClick(View v) {
.setMessage("Package Name: " + appPackageName.getText().toString() +
"\n\nApp Version: " + version +
"\n\nAPI Version: " + appApiVersion.getText().toString() +
"\n\nApp Location: " + appLocation)
"\n\nApp Location: " + appLocation +
"\n\nPermissions List\n" + permissions)
.setIcon(appIcon.getDrawable())
.setNeutralButton("App Settings", new DialogInterface.OnClickListener() {
@Override
Expand Down

0 comments on commit 91a35cf

Please sign in to comment.