diff --git a/V2rayNG/app/src/main/AndroidManifest.xml b/V2rayNG/app/src/main/AndroidManifest.xml
index bc4f6566..d5f54419 100644
--- a/V2rayNG/app/src/main/AndroidManifest.xml
+++ b/V2rayNG/app/src/main/AndroidManifest.xml
@@ -227,6 +227,16 @@
+
+
+
+
diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/AboutActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/AboutActivity.kt
index 6c1637cc..f3bb37b3 100644
--- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/AboutActivity.kt
+++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/AboutActivity.kt
@@ -5,6 +5,7 @@ import android.content.Intent
import android.os.Build
import android.os.Bundle
import androidx.activity.result.contract.ActivityResultContracts
+import androidx.core.content.FileProvider
import com.tbruyelle.rxpermissions.RxPermissions
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
@@ -33,7 +34,31 @@ class AboutActivity : BaseActivity() {
binding.tvBackupSummary.text = this.getString(R.string.summary_configuration_backup, extDir)
binding.layoutBackup.setOnClickListener {
- backupMMKV()
+ val ret = backupConfiguration(extDir.absolutePath)
+ if (ret.first) {
+ toast(R.string.toast_success)
+ } else {
+ toast(R.string.toast_failure)
+ }
+ }
+
+ binding.layoutShare.setOnClickListener {
+ val ret = backupConfiguration(cacheDir.absolutePath)
+ if (ret.first) {
+ startActivity(
+ Intent.createChooser(
+ Intent(Intent.ACTION_SEND).setType("application/zip")
+ .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
+ .putExtra(
+ Intent.EXTRA_STREAM, FileProvider.getUriForFile(
+ this, BuildConfig.APPLICATION_ID + ".cache", File(ret.second)
+ )
+ ), getString(R.string.title_configuration_share)
+ )
+ )
+ } else {
+ toast(R.string.toast_failure)
+ }
}
binding.layoutRestore.setOnClickListener {
@@ -77,40 +102,36 @@ class AboutActivity : BaseActivity() {
}
}
- fun backupMMKV() {
+ fun backupConfiguration(outputZipFilePos: String): Pair {
val dateFormated = SimpleDateFormat(
"yyyy-MM-dd-HH-mm-ss",
Locale.getDefault()
).format(System.currentTimeMillis())
val folderName = "${getString(R.string.app_name)}_${dateFormated}"
val backupDir = this.cacheDir.absolutePath + "/$folderName"
- val outputZipFilePath = extDir.absolutePath + "/$folderName.zip"
+ val outputZipFilePath = "$outputZipFilePos/$folderName.zip"
val count = MMKV.backupAllToDirectory(backupDir)
if (count <= 0) {
- toast(R.string.toast_failure)
+ return Pair(false, "")
}
if (ZipUtil.zipFromFolder(backupDir, outputZipFilePath)) {
- toast(R.string.toast_success)
+ return Pair(true, outputZipFilePath)
} else {
- toast(R.string.toast_failure)
+ return Pair(false, "")
}
}
- fun restoreMMKV(zipFile: File) {
+ fun restoreConfiguration(zipFile: File): Boolean {
val backupDir = this.cacheDir.absolutePath + "/${System.currentTimeMillis()}"
if (!ZipUtil.unzipToFolder(zipFile, backupDir)) {
- toast(R.string.toast_failure)
+ return false
}
val count = MMKV.restoreAllFromDirectory(backupDir)
- if (count > 0) {
- toast(R.string.toast_success)
- } else {
- toast(R.string.toast_failure)
- }
+ return count > 0
}
private fun showFileChooser() {
@@ -138,8 +159,11 @@ class AboutActivity : BaseActivity() {
input?.copyTo(fileOut)
}
}
-
- restoreMMKV(targetFile)
+ if (restoreConfiguration(targetFile)) {
+ toast(R.string.toast_success)
+ } else {
+ toast(R.string.toast_failure)
+ }
} catch (e: Exception) {
e.printStackTrace()
}
diff --git a/V2rayNG/app/src/main/res/layout/activity_about.xml b/V2rayNG/app/src/main/res/layout/activity_about.xml
index a8fd8399..adb1602e 100644
--- a/V2rayNG/app/src/main/res/layout/activity_about.xml
+++ b/V2rayNG/app/src/main/res/layout/activity_about.xml
@@ -51,6 +51,30 @@
+
+
+
+
+
+
+
إعدادات النسخ الاحتياطي
مكان التخزين: [%s]، سيتم مسح النسخة الاحتياطية بعد إلغاء تثبيت التطبيق أو مسح مساحة التخزين
استعادة الاعدادات
+ Share configuration
ترقية
ترقية، انقر للحصول على التفاصيل (يمكن إزالة التبرع)
diff --git a/V2rayNG/app/src/main/res/values-fa/strings.xml b/V2rayNG/app/src/main/res/values-fa/strings.xml
index 8056fe4e..47179f25 100644
--- a/V2rayNG/app/src/main/res/values-fa/strings.xml
+++ b/V2rayNG/app/src/main/res/values-fa/strings.xml
@@ -177,6 +177,7 @@
Backup configuration
Storage location: [%s], The backup will be cleared after uninstalling the app or clearing the storage
Restore configuration
+ Share configuration
تبلیغات
تبلیغات، برای جزئیات بیشتر کلیک کنید (کمک مالی کنید تا حذف شود)
diff --git a/V2rayNG/app/src/main/res/values-ru/strings.xml b/V2rayNG/app/src/main/res/values-ru/strings.xml
index 17d255e4..8d7aa6fc 100644
--- a/V2rayNG/app/src/main/res/values-ru/strings.xml
+++ b/V2rayNG/app/src/main/res/values-ru/strings.xml
@@ -179,6 +179,7 @@
Резервирование
Путь: [%s]. Резервная копия будет стёрта при удалении приложения или очистке хранилища.
Восстановление
+ Share configuration
Содействие
Содействие, нажмите для получения подробной информации (пожертвование может быть удалено)
diff --git a/V2rayNG/app/src/main/res/values-vi/strings.xml b/V2rayNG/app/src/main/res/values-vi/strings.xml
index eaa8f37a..76a32e53 100644
--- a/V2rayNG/app/src/main/res/values-vi/strings.xml
+++ b/V2rayNG/app/src/main/res/values-vi/strings.xml
@@ -179,6 +179,7 @@
Backup configuration
Storage location: [%s], The backup will be cleared after uninstalling the app or clearing the storage
Restore configuration
+ Share configuration
Quảng bá server
Quảng cáo, nhấn để biết thêm (Ủng hộ có thể được gỡ bỏ)
diff --git a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml
index b7627d46..c8006d91 100644
--- a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml
+++ b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml
@@ -177,6 +177,7 @@
备份配置
存储位置: [%s], 卸载App或清除存储后备份将被清除
还原配置
+ 分享配置
推广
一些推广,点击查看详情(捐赠可去除)
diff --git a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml
index c0a69c31..a6bf1ec9 100644
--- a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml
+++ b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml
@@ -177,6 +177,7 @@
備份配置
儲存位置: [%s], 卸載App或清除儲存後備份將被清除
還原配置
+ 分享配置
推廣
一些推廣,輕觸以檢視 (捐贈可去除)
diff --git a/V2rayNG/app/src/main/res/values/strings.xml b/V2rayNG/app/src/main/res/values/strings.xml
index be8cdcb9..63659138 100644
--- a/V2rayNG/app/src/main/res/values/strings.xml
+++ b/V2rayNG/app/src/main/res/values/strings.xml
@@ -190,6 +190,7 @@
Backup configuration
Storage location: [%s], The backup will be cleared after uninstalling the app or clearing the storage
Restore configuration
+ Share configuration
Promotion
Promotion,click for details(Donation can be removed)
diff --git a/V2rayNG/app/src/main/res/xml/cache_paths.xml b/V2rayNG/app/src/main/res/xml/cache_paths.xml
new file mode 100644
index 00000000..f9649fc7
--- /dev/null
+++ b/V2rayNG/app/src/main/res/xml/cache_paths.xml
@@ -0,0 +1,4 @@
+
+
+
+