Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Add package name to export file name when exporting one application
Browse files Browse the repository at this point in the history
Fixes #1465
  • Loading branch information
M66B committed Feb 28, 2014
1 parent beae884 commit ae6a866
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Changelog
* The loop back address will be restricted too, see [this commit](https://github.com/M66B/XPrivacy/commit/4aad9cecc15cc040a0b9c4104dabb65332e4f63e)
* Fixed negative GSF ID ([issue](/../../issues/1473))
* Select visible applications for fetch ([issue](/../../issues/1477))
* Add package name to export file name when exporting one application ([issue](/../../issues/1465))
* Lower case entry for Android ID (reported on XDA)
* Updated German translation
* Updated Polish translation
Expand Down
22 changes: 15 additions & 7 deletions src/biz/bokhorst/xprivacy/ActivityShare.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,18 @@ protected void onCreate(Bundle savedInstanceState) {
boolean hasIntent = Util.isIntentAvailable(ActivityShare.this, file);

// Get file name
if (action.equals(ACTION_EXPORT))
mFileName = getFileName(this, hasIntent);
else
mFileName = (hasIntent ? null : getFileName(this, false));
if (action.equals(ACTION_EXPORT)) {
String packageName = null;
if (uids.length == 1)
try {
ApplicationInfoEx appInfo = new ApplicationInfoEx(this, uids[0]);
packageName = appInfo.getPackageName().get(0);
} catch (Throwable ex) {
Util.bug(null, ex);
}
mFileName = getFileName(this, hasIntent, packageName);
} else
mFileName = (hasIntent ? null : getFileName(this, false, null));

if (mFileName == null)
fileChooser();
Expand Down Expand Up @@ -1691,15 +1699,15 @@ public static String getBaseURL(Context context) {
return HTTP_BASE_URL;
}

public static String getFileName(Context context, boolean multiple) {
public static String getFileName(Context context, boolean multiple, String packageName) {
File folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator
+ ".xprivacy");
folder.mkdir();
String fileName;
if (multiple) {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.ROOT);
fileName = String.format("XPrivacy_%s_%s_%s.xml", Util.getSelfVersionName(context),
format.format(new Date()), Build.DEVICE);
fileName = String.format("XPrivacy_%s_%s_%s%s.xml", Util.getSelfVersionName(context),
format.format(new Date()), Build.DEVICE, (packageName == null ? "" : "_" + packageName));
} else
fileName = "XPrivacy.xml";
return new File(folder + File.separator + fileName).getAbsolutePath();
Expand Down

0 comments on commit ae6a866

Please sign in to comment.