Merge commit 'refs/merge-requests/32' of git://gitorious.org/f-droid/fdroidclient into merge-requests/32
Conflicts: res/values/strings.xml
This commit is contained in:
commit
7904db43ea
@ -28,5 +28,19 @@
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="false" />
|
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:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/permissions_list"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:singleLine="false" />
|
||||||
|
|
||||||
</LinearLayout>
|
</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_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_connecting_to_repo">Connecting to\n%1$s</string>
|
||||||
<string name="status_checking_compatibility">Checking apps compatibility with your device…</string>
|
<string name="status_checking_compatibility">Checking apps compatibility with your device…</string>
|
||||||
|
<string name="permissions">Permissions for v%s</string>
|
||||||
|
<string name="showPermissions">Show permissions</string>
|
||||||
|
<string name="showPermissions_long">Display a list of permissions an app needs</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
<CheckBoxPreference android:title="@string/ignoreTouch"
|
<CheckBoxPreference android:title="@string/ignoreTouch"
|
||||||
android:defaultValue="false" android:summary="@string/ignoreTouch_long"
|
android:defaultValue="false" android:summary="@string/ignoreTouch_long"
|
||||||
android:key="ignoreTouchscreen" />
|
android:key="ignoreTouchscreen" />
|
||||||
|
<CheckBoxPreference android:key="showPermissions" android:summary="@string/showPermissions_long" android:title="@string/showPermissions" android:defaultValue="true"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/maintenance">
|
<PreferenceCategory android:title="@string/maintenance">
|
||||||
<Preference android:title="@string/reset" android:summary="@string/clear_all_cached_data"
|
<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) 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
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@ -21,10 +22,13 @@ package org.fdroid.fdroid;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.content.pm.PermissionInfo;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import org.fdroid.fdroid.compat.MenuManager;
|
import org.fdroid.fdroid.compat.MenuManager;
|
||||||
|
import org.fdroid.fdroid.DB.CommaSeparatedList;
|
||||||
import org.xml.sax.XMLReader;
|
import org.xml.sax.XMLReader;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@ -205,6 +209,7 @@ public class AppDetails extends ListActivity {
|
|||||||
|
|
||||||
private boolean pref_cacheDownloaded;
|
private boolean pref_cacheDownloaded;
|
||||||
private boolean pref_expert;
|
private boolean pref_expert;
|
||||||
|
private boolean pref_permissions;
|
||||||
private boolean resetRequired;
|
private boolean resetRequired;
|
||||||
|
|
||||||
// The signature of the installed version.
|
// The signature of the installed version.
|
||||||
@ -220,6 +225,7 @@ public class AppDetails extends ListActivity {
|
|||||||
.getDefaultSharedPreferences(getBaseContext());
|
.getDefaultSharedPreferences(getBaseContext());
|
||||||
pref_cacheDownloaded = prefs.getBoolean("cacheDownloaded", false);
|
pref_cacheDownloaded = prefs.getBoolean("cacheDownloaded", false);
|
||||||
pref_expert = prefs.getBoolean("expert", false);
|
pref_expert = prefs.getBoolean("expert", false);
|
||||||
|
pref_permissions = prefs.getBoolean("showPermissions", false);
|
||||||
AppDetails old = (AppDetails) getLastNonConfigurationInstance();
|
AppDetails old = (AppDetails) getLastNonConfigurationInstance();
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
copyState(old);
|
copyState(old);
|
||||||
@ -434,6 +440,37 @@ public class AppDetails extends ListActivity {
|
|||||||
tv.setVisibility(View.GONE);
|
tv.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tv = (TextView) infoView.findViewById(R.id.permissions_list);
|
||||||
|
if (pref_permissions) {
|
||||||
|
CommaSeparatedList permsList = app.apks.get(0).detail_permissions;
|
||||||
|
Iterator<String> permissions = permsList != null ? permsList.iterator() : null;
|
||||||
|
if (null != permissions && permissions.hasNext()) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
while(permissions.hasNext()) {
|
||||||
|
String permissionName = permissions.next();
|
||||||
|
try {
|
||||||
|
Permission permission = new Permission(this, permissionName);
|
||||||
|
sb.append(permission.getName());
|
||||||
|
if (permissions.hasNext()) {
|
||||||
|
sb.append('\n');
|
||||||
|
}
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
Log.d( "FDroid",
|
||||||
|
"Can't find permsission '" + permissionName + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tv.setText(sb.toString());
|
||||||
|
} else {
|
||||||
|
tv.setText("NONE");
|
||||||
|
}
|
||||||
|
tv = (TextView) infoView.findViewById(R.id.permissions);
|
||||||
|
tv.setText(getResources().getString(
|
||||||
|
R.string.permissions, app.apks.get(0).version));
|
||||||
|
} else {
|
||||||
|
tv.setVisibility(View.GONE);
|
||||||
|
tv = (TextView) infoView.findViewById(R.id.permissions);
|
||||||
|
tv.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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