Skip to content

Commit

Permalink
Access to all files in order to read/write repos from external storage
Browse files Browse the repository at this point in the history
  • Loading branch information
prattpratt committed Apr 4, 2022
1 parent 6574cbf commit 51f58f3
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

<application
android:name=".MGitApplication"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
import android.app.Activity;
import android.app.AlertDialog;
import androidx.lifecycle.ViewModelProviders;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import androidx.databinding.DataBindingUtil;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.Settings;
import androidx.core.view.MenuItemCompat;
import android.view.Menu;
import android.view.MenuItem;
Expand Down Expand Up @@ -153,6 +158,21 @@ public boolean onOptionsItemSelected(MenuItem item) {
showCloneView();
return true;
case R.id.action_import_repo:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {
showMessageDialog(
R.string.dialog_access_all_files_title,
R.string.dialog_access_all_files_msg,
R.string.label_ok, (dialogInterface, i) -> {
try {
Uri uri = Uri.fromParts("package", getPackageName(), null);
startActivity(new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, uri));
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION));
}
}
);
return true;
}
intent = new Intent(this, ImportRepositoryActivity.class);
startActivityForResult(intent, REQUEST_IMPORT_REPO);
forwardTransition();
Expand All @@ -177,6 +197,7 @@ public void configSearchAction(MenuItem searchItem) {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode != Activity.RESULT_OK)
return;
switch (requestCode) {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,6 @@
<string name="error_no_worktree">This is a bare repository!</string>
<string name="error_invalid_index">The Git index is invalid!</string>
<string name="error_file_not_found">File not found!</string>
<string name="dialog_access_all_files_title">Zugriff auf alle Dateien</string>
<string name="dialog_access_all_files_msg">Bitte erlauben Sie den Zugriff auf alle Dateien, um Repositories von einem externen Speicher lesen/schreiben zu können.</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,6 @@
<string name="error_no_worktree">This is a bare repository!</string>
<string name="error_invalid_index">The Git index is invalid!</string>
<string name="error_file_not_found">File not found!</string>
<string name="dialog_access_all_files_title">Acceso a todos los archivos</string>
<string name="dialog_access_all_files_msg">Permita el acceso a todos los archivos para leer/escribir repositorios desde almacenamiento externo.</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,6 @@
<string name="error_no_worktree">This is a bare repository!</string>
<string name="error_invalid_index">The Git index is invalid!</string>
<string name="error_file_not_found">File not found!</string>
<string name="dialog_access_all_files_title">Accès à tous les fichiers</string>
<string name="dialog_access_all_files_msg">Veuillez autoriser l\'accès à tous les fichiers afin de lire/écrire des référentiels à partir d\'un stockage externe.</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-iw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,6 @@
<string name="error_no_worktree">This is a bare repository!</string>
<string name="error_invalid_index">The Git index is invalid!</string>
<string name="error_file_not_found">File not found!</string>
<string name="dialog_access_all_files_title">גישה לכל הקבצים</string>
<string name="dialog_access_all_files_msg">אנא אפשר גישה לכל הקבצים כדי לקרוא/לכתוב מאגרים מאחסון חיצוני.</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,6 @@
<string name="error_no_worktree">This is a bare repository!</string>
<string name="error_invalid_index">The Git index is invalid!</string>
<string name="error_file_not_found">File not found!</string>
<string name="dialog_access_all_files_title">すべてのファイルへのアクセス</string>
<string name="dialog_access_all_files_msg">外部ストレージからリポジトリを読み書きするには、すべてのファイルへのアクセスを許可してください。</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,6 @@
<string name="error_no_worktree">This is a bare repository!</string>
<string name="error_invalid_index">The Git index is invalid!</string>
<string name="error_file_not_found">File not found!</string>
<string name="dialog_access_all_files_title">모든 파일에 대한 액세스</string>
<string name="dialog_access_all_files_msg">외부 저장소에서 리포지토리를 읽고 쓰려면 모든 파일에 대한 액세스를 허용하세요.</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,6 @@
<string name="error_no_worktree">This is a bare repository!</string>
<string name="error_invalid_index">The Git index is invalid!</string>
<string name="error_file_not_found">File not found!</string>
<string name="dialog_access_all_files_title">Доступ ко всем файлам</string>
<string name="dialog_access_all_files_msg">Разрешите доступ ко всем файлам для чтения/записи репозиториев с внешнего хранилища.</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,6 @@
<string name="error_no_worktree">This is a bare repository!</string>
<string name="error_invalid_index">The Git index is invalid!</string>
<string name="error_file_not_found">File not found!</string>
<string name="dialog_access_all_files_title">所有文件的访问</string>
<string name="dialog_access_all_files_msg">请允许访问所有文件以从外部存储读取/写入存储库。</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,6 @@
<string name="preference_eng_lang">English Language</string>
<string name="preference_eng_lang_summary">Use English instead of the default language</string>
<string name="pref_key_use_english" translatable="false">use.english</string>
<string name="dialog_access_all_files_title">Access to all files</string>
<string name="dialog_access_all_files_msg">Please allow access to all files in order to read/write repositories from external storage.</string>
</resources>

0 comments on commit 51f58f3

Please sign in to comment.