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

Commit

Permalink
Added XPrivacy version and device name to export file name
Browse files Browse the repository at this point in the history
Closes #1116
  • Loading branch information
M66B committed Jan 29, 2014
1 parent 8cf3418 commit 09a98e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Test and beta releases will have experimental functions enabled by default.
* Added application sort, thanks @[jpeg729](https://github.com/jpeg729)
* Saving tab state (category, filters, none), thanks @[jpeg729](https://github.com/jpeg729) ([issue](https://github.com/M66B/XPrivacy/issues/1035))
* Restrict access to Gmail information ([issue](https://github.com/M66B/XPrivacy/issues/1080))
* Added XPrivacy version and device name to export file name ([issue](https://github.com/M66B/XPrivacy/issues/1116))
* Updated Dutch translation
* Updated Lithuanian translation
* Updated Polish translation
Expand Down
22 changes: 16 additions & 6 deletions src/biz/bokhorst/xprivacy/ActivityShare.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
import android.graphics.Color;
Expand Down Expand Up @@ -212,9 +213,9 @@ protected void onCreate(Bundle savedInstanceState) {

// Get file name
if (action.equals(ACTION_EXPORT))
mFileName = getFileName(hasIntent);
mFileName = getFileName(this, hasIntent);
else
mFileName = (hasIntent ? null : getFileName(false));
mFileName = (hasIntent ? null : getFileName(this, false));
if (mFileName == null)
fileChooser();
else
Expand Down Expand Up @@ -305,7 +306,7 @@ public void onClick(View v) {

// Get on with exporting
String fileName = (extras != null && extras.containsKey(cFileName) ? extras.getString(cFileName)
: getFileName(false));
: getFileName(this, false));
new ExportTask().executeOnExecutor(mExecutor, new File(fileName), listUid);
}
}
Expand Down Expand Up @@ -1246,7 +1247,8 @@ protected Throwable doInBackground(int[]... params) {
Integer.toString(ActivityMain.STATE_ATTENTION));

// Change app modification time
PrivacyManager.setSetting(null, appInfo.getUid(), PrivacyManager.cSettingModifyTime,
PrivacyManager.setSetting(null, appInfo.getUid(),
PrivacyManager.cSettingModifyTime,
Long.toString(System.currentTimeMillis()));

mAppAdapter.setState(appInfo.getUid(), STATE_SUCCESS,
Expand Down Expand Up @@ -1705,14 +1707,22 @@ public static String getBaseURL(Context context) {
return HTTP_BASE_URL;
}

public static String getFileName(boolean multiple) {
public static String getFileName(Context context, boolean multiple) {
File folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator
+ ".xprivacy");
folder.mkdir();
String fileName;
if (multiple) {
String versionName;
try {
PackageManager pm = context.getPackageManager();
PackageInfo pInfo = pm.getPackageInfo(context.getPackageName(), 0);
versionName = pInfo.versionName;
} catch (NameNotFoundException ex) {
versionName = "";
}
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.ROOT);
fileName = String.format("XPrivacy_%s.xml", format.format(new Date()));
fileName = String.format("XPrivacy_%s_%s_%s.xml", versionName, format.format(new Date()), Build.DEVICE);
} else
fileName = "XPrivacy.xml";
return new File(folder + File.separator + fileName).getAbsolutePath();
Expand Down

0 comments on commit 09a98e4

Please sign in to comment.