txa-settings-permission 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/android/src/main/java/online/txa/settingspermission/TxaSettingsPermissionPlugin.java
CHANGED
|
@@ -902,6 +902,19 @@ public class TxaSettingsPermissionPlugin extends Plugin {
|
|
|
902
902
|
if (path.startsWith("/")) {
|
|
903
903
|
return new File(path);
|
|
904
904
|
}
|
|
905
|
+
|
|
906
|
+
// Ưu tiên ghi ra Root của SDCard nếu đã có quyền "Manage All Files" hoặc "Write External"
|
|
907
|
+
// Điều này giúp người dùng dễ dàng tìm thấy file trong trình quản lý tệp.
|
|
908
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
909
|
+
if (Environment.isExternalStorageManager()) {
|
|
910
|
+
return new File(Environment.getExternalStorageDirectory(), path);
|
|
911
|
+
}
|
|
912
|
+
} else {
|
|
913
|
+
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
|
914
|
+
return new File(Environment.getExternalStorageDirectory(), path);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
905
918
|
return new File(getContext().getExternalFilesDir(null), path);
|
|
906
919
|
}
|
|
907
920
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "txa-settings-permission",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Capacitor plugin by TXA — Mở tất cả màn hình Settings cấp quyền trên Android, tự tương thích theo Android version",
|
|
5
6
|
"main": "dist/plugin.cjs.js",
|
|
6
7
|
"module": "dist/esm/index.js",
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
"compile:bundle": "rollup -c rollup.config.js",
|
|
62
63
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
63
64
|
"prepublishOnly": "npm run build",
|
|
64
|
-
"postinstall": "node scripts/check-capacitor.
|
|
65
|
+
"postinstall": "node scripts/check-capacitor.cjs"
|
|
65
66
|
},
|
|
66
67
|
"peerDependencies": {
|
|
67
68
|
"@capacitor/core": ">=4.0.0"
|
|
@@ -139,10 +139,17 @@ function printError(msg) {
|
|
|
139
139
|
console.error('\x1b[31m%s\x1b[0m', msg);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
//
|
|
142
|
+
// Tự động phát hiện nếu đang chạy trong node_modules của một project khác
|
|
143
|
+
const pluginRoot = path.dirname(__dirname);
|
|
143
144
|
const isCI = process.env.CI === 'true';
|
|
144
|
-
const isSelfBuild = process.env.npm_package_name === 'txa-settings-permission';
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
// Nếu plugin nằm trong node_modules → Chắc chắn là đang được cài vào project khác
|
|
147
|
+
const isDependency = pluginRoot.includes('node_modules');
|
|
148
|
+
|
|
149
|
+
// Hoặc nếu INIT_CWD (thư mục chạy npm install) khác với thư mục của plugin
|
|
150
|
+
const initCwd = process.env.INIT_CWD;
|
|
151
|
+
const isBeingInstalled = initCwd && initCwd !== pluginRoot;
|
|
152
|
+
|
|
153
|
+
if (!isCI && (isDependency || isBeingInstalled)) {
|
|
147
154
|
checkCapacitorInstalled();
|
|
148
155
|
}
|