bede's changes for adding permissions to app details.
This commit is contained in:
parent
d5a52dcf46
commit
688142c83e
res
src/org/fdroid/fdroid
@ -28,5 +28,19 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="false" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/permissions"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textSize="14sp"
|
||||
android:text="@string/permissions" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/permissions_list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="false" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -163,5 +163,8 @@
|
||||
<string name="status_processing_xml">Processing application\n%2$d of %3$d from\n%1$s</string>
|
||||
<string name="status_connecting_to_repo">Connecting to\n%1$s</string>
|
||||
<string name="status_checking_compatibility">Checking all apps compatibility with your device…</string>
|
||||
<string name="permissions">Permissions</string>
|
||||
<string name="showPermissions">Show permissions</string>
|
||||
<string name="showPermissions_long">Display a list of permissions an app needs</string>
|
||||
|
||||
</resources>
|
||||
|
@ -53,6 +53,7 @@
|
||||
<CheckBoxPreference android:title="@string/ignoreTouch"
|
||||
android:defaultValue="false" android:summary="@string/ignoreTouch_long"
|
||||
android:key="ignoreTouchscreen" />
|
||||
<CheckBoxPreference android:key="showPermissions" android:summary="@string/showPermissions_long" android:title="@string/showPermissions" android:defaultValue="true"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/maintenance">
|
||||
<Preference android:title="@string/reset" android:summary="@string/clear_all_cached_data"
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2010-12 Ciaran Gultnieks, ciaran@ciarang.com
|
||||
* Copyright (C) 2013 Stefan Völkel, bd@bc-bd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -25,6 +26,7 @@ import java.util.List;
|
||||
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import org.fdroid.fdroid.compat.MenuManager;
|
||||
import org.fdroid.fdroid.DB.CommaSeparatedList;
|
||||
import org.xml.sax.XMLReader;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
@ -205,6 +207,7 @@ public class AppDetails extends ListActivity {
|
||||
|
||||
private boolean pref_cacheDownloaded;
|
||||
private boolean pref_expert;
|
||||
private boolean pref_permissions;
|
||||
private boolean resetRequired;
|
||||
|
||||
// The signature of the installed version.
|
||||
@ -220,6 +223,7 @@ public class AppDetails extends ListActivity {
|
||||
.getDefaultSharedPreferences(getBaseContext());
|
||||
pref_cacheDownloaded = prefs.getBoolean("cacheDownloaded", false);
|
||||
pref_expert = prefs.getBoolean("expert", false);
|
||||
pref_permissions = prefs.getBoolean("showPermissions", true);
|
||||
AppDetails old = (AppDetails) getLastNonConfigurationInstance();
|
||||
if (old != null) {
|
||||
copyState(old);
|
||||
@ -434,6 +438,19 @@ public class AppDetails extends ListActivity {
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
tv = (TextView) infoView.findViewById(R.id.permissions_list);
|
||||
if (pref_permissions) {
|
||||
CommaSeparatedList permissions = app.apks.get(0).detail_permissions;
|
||||
if (null != permissions)
|
||||
tv.setText(permissions.toString());
|
||||
else {
|
||||
tv.setText("NONE");
|
||||
}
|
||||
} else {
|
||||
tv.setVisibility(View.GONE);
|
||||
tv = (TextView) infoView.findViewById(R.id.permissions);
|
||||
tv.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
42
src/org/fdroid/fdroid/Permission.java
Normal file
42
src/org/fdroid/fdroid/Permission.java
Normal file
@ -0,0 +1,42 @@
|
||||
package org.fdroid.fdroid;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PermissionInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public class Permission {
|
||||
|
||||
private final PackageManager packageManager;
|
||||
private final PermissionInfo permissionInfo;
|
||||
|
||||
public Permission(Context context, String permission)
|
||||
throws PackageManager.NameNotFoundException {
|
||||
this.packageManager = context.getPackageManager();
|
||||
this.permissionInfo = this.packageManager.getPermissionInfo(
|
||||
fdroidToAndroid(permission), PackageManager.GET_META_DATA);
|
||||
}
|
||||
|
||||
/**
|
||||
* It appears that all of the permissions in android.Manifest.permissions
|
||||
* are prefixed with "android.permission." and then the constant name.
|
||||
* FDroid just includes the constant name in the apk list, so we prefix it
|
||||
* with "android.permission."
|
||||
*/
|
||||
private static String fdroidToAndroid(String permission) {
|
||||
return "android.permission." + permission;
|
||||
}
|
||||
|
||||
public CharSequence getName() {
|
||||
return this.permissionInfo.loadLabel(this.packageManager);
|
||||
}
|
||||
|
||||
public CharSequence getDescription() {
|
||||
return this.permissionInfo.loadDescription(this.packageManager);
|
||||
}
|
||||
|
||||
public Drawable getIcon() {
|
||||
return this.permissionInfo.loadIcon(this.packageManager);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user