diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-01-31 22:01:15 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-01-31 22:01:15 +0100 |
commit | a5dc9c11fa1b0f198c0e8f886fa8ee1553dd2e17 (patch) | |
tree | 35c2f269e23a6276124caf9b8514aef897d78b4e /src/main/java | |
parent | 63a5dcbaf849490259152e1b43b5cddc048bfc89 (diff) |
get app name and version from apk
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index e5daf53f0..460d3337c 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -3,6 +3,7 @@ package de.pixart.messenger.ui.adapter; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; @@ -596,6 +597,23 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_account_card_details_grey600_48dp, 0, 0, 0); } else if (message.getMimeType().contains("calendar")) { viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_calendar_grey600_48dp, 0, 0, 0); + } else if (message.getMimeType().equals("application/vnd.android.package-archive")) { + String file = activity.xmppConnectionService.getFileBackend().getFile(message).toString(); + Log.d(Config.LOGTAG, "APK path: " + file); + try { + PackageManager pm = getContext().getPackageManager(); + PackageInfo pi = pm.getPackageArchiveInfo(file, 0); + pi.applicationInfo.sourceDir = file; + pi.applicationInfo.publicSourceDir = file; + Drawable APKicon = pi.applicationInfo.loadIcon(pm); + String AppName = (String) pi.applicationInfo.loadLabel(pm); + String AppVersion = (String) pi.versionName; + Log.d(Config.LOGTAG, "APK name: " + AppName); + fullName = " (" + AppName + " " + AppVersion + ")"; + } catch (Exception e) { + //ignored + } + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_file_grey600_48dp, 0, 0, 0); } else { viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_file_grey600_48dp, 0, 0, 0); } |