diff --git a/wp-fdroid/wp-fdroid.php b/wp-fdroid/wp-fdroid.php index 399251db..6ac7d306 100644 --- a/wp-fdroid/wp-fdroid.php +++ b/wp-fdroid/wp-fdroid.php @@ -12,6 +12,8 @@ Revision history */ +include('android-permissions.php'); + class FDroid { @@ -101,8 +103,9 @@ class FDroid function get_app($query_vars) { + $permissions_data = get_android_permissions_array($this->site_path.'/repo/AndroidManifest.xml', $this->site_path.'/repo/strings.xml'); - $xml = simplexml_load_file($this->site_path."/repo/index.xml"); + $xml = simplexml_load_file($this->site_path.'/repo/index.xml'); foreach($xml->children() as $app) { $attrs=$app->attributes(); @@ -220,8 +223,42 @@ class FDroid $out.='

Permissions
'; $out.='

'; $permissions = explode(',',$apk['permissions']); - foreach($permissions as $permission) - $out.=$permission.'
'; + usort($permissions, + + + function ($a, $b) use (&$permissions_data) { + + $aProtectionLevel = $permissions_data['permission'][$a]['protectionLevel']; + $bProtectionLevel = $permissions_data['permission'][$b]['protectionLevel']; + + if($aProtectionLevel != $bProtectionLevel) { + return strcmp($aProtectionLevel, $bProtectionLevel); + } + + $aGroup = $permissions_data['permission'][$a]['permissionGroup']; + $bGroup = $permissions_data['permission'][$b]['permissionGroup']; + + return strcmp($aGroup, $bGroup); + } + + + + ); + + $permission_group_last = ''; + foreach($permissions as $permission) { + $permission_group = $permissions_data['permission'][$permission]['permissionGroup']; + if($permission_group != $permission_group_last) { + $out.=''.strtoupper($permissions_data['permission-group'][$permission_group]['label']).'
'; + $permission_group_last = $permission_group; + } + + $out.='('.strtoupper(substr($permissions_data['permission'][$permission]['protectionLevel'],0,1)).') - '; + $out.=''.$permissions_data['permission'][$permission]['label'].' ['.$permission.']
'; + $out.=$permissions_data['permission'][$permission]['description'].'
'; + //$out.=$permissions_data['permission'][$permission]['comment'].'
'; + $out.='
'; + } $out.='

'; $out.='

';