diff --git a/app/src/main/java/com/nutomic/syncthingandroid/views/FoldersAdapter.java b/app/src/main/java/com/nutomic/syncthingandroid/views/FoldersAdapter.java index 99757a34..d8cb4a9f 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/views/FoldersAdapter.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/views/FoldersAdapter.java @@ -1,7 +1,9 @@ package com.nutomic.syncthingandroid.views; +import android.app.AlertDialog; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.databinding.DataBindingUtil; import android.net.Uri; import android.support.annotation.NonNull; @@ -63,26 +65,7 @@ public class FoldersAdapter extends ArrayAdapter { intent.setAction(SyncthingService.ACTION_OVERRIDE_CHANGES); mContext.startService(intent); }); - binding.openFolder.setOnClickListener(v -> { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.fromFile(new File(folder.path)), "resource/folder"); - intent.putExtra("org.openintents.extra.ABSOLUTE_PATH", folder.path); - intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK); - if (intent.resolveActivity(mContext.getPackageManager()) != null) { - mContext.startActivity(intent); - } else { - // Try a second way to find a compatible file explorer app. - Log.v(TAG, "openFolder: Fallback to application chooser to open folder."); - intent.setDataAndType(Uri.parse(folder.path), "application/*"); - Intent chooserIntent = Intent.createChooser(intent, mContext.getString(R.string.open_file_manager)); - if (chooserIntent != null) { - mContext.startActivity(chooserIntent); - } else { - Toast.makeText(mContext, R.string.toast_no_file_manager, Toast.LENGTH_SHORT).show(); - } - } - }); - + binding.openFolder.setOnClickListener(view -> { onOpenFolderClick(view, folder); } ); updateFolderStatusView(binding, folder); return binding.getRoot(); } @@ -163,9 +146,17 @@ public class FoldersAdapter extends ArrayAdapter { /** * Requests updated folder status from the api for all visible items. */ - public void updateFolderStatus(RestApi api) { + public void updateFolderStatus(RestApi restApi) { + if (restApi == null) { + Log.e(TAG, "updateFolderStatus: restApi == null"); + return; + } + for (int i = 0; i < getCount(); i++) { - api.getFolderStatus(getItem(i).id, this::onReceiveFolderStatus); + Folder folder = getItem(i); + if (folder != null) { + restApi.getFolderStatus(folder.id, this::onReceiveFolderStatus); + } } } @@ -183,4 +174,68 @@ public class FoldersAdapter extends ArrayAdapter { } } + private void onOpenFolderClick(View view, Folder folder) { + PackageManager pm = mContext.getPackageManager(); + + // Try to find a compatible file manager app supporting the "resource/folder" Uri type. + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType(Uri.fromFile(new File(folder.path)), "resource/folder"); + intent.putExtra("org.openintents.extra.ABSOLUTE_PATH", folder.path); + intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK); + if (intent.resolveActivity(pm) != null) { + // Launch file manager. + mContext.startActivity(intent); + return; + } + Log.w(TAG, "No compatible file manager app not found (stage #1)"); + + // Try to open the folder with "Root Explorer" if it is installed. + intent = pm.getLaunchIntentForPackage("com.speedsoftware.rootexplorer"); + if (intent != null) { + intent.setAction(Intent.ACTION_VIEW); + intent.setData(Uri.parse(folder.path)); + try { + mContext.startActivity(intent); + return; + } catch (android.content.ActivityNotFoundException anfe) { + Log.w(TAG, "Failed to launch Root Explorer (stage #2)"); + } + } + Log.w(TAG, "Root Explorer file manager app not found (stage #2)"); + + // No compatible file manager app found. + suggestFileManagerApp(); + + /** + * Fallback: Let the user choose from all Uri handling apps. + * This allows the use of third-party file manager apps which + * provide non-standardized Uri handlers. + */ + /* + Log.v(TAG, "Fallback to application chooser to open folder."); + intent.setDataAndType(Uri.parse(folder.path), "application/*"); + Intent chooserIntent = Intent.createChooser(intent, mContext.getString(R.string.open_file_manager)); + if (chooserIntent != null) { + // Launch potential file manager app. + mContext.startActivity(chooserIntent); + return; + } + */ + } + + private void suggestFileManagerApp() { + AlertDialog mSuggestFileManagerAppDialog = new AlertDialog.Builder(mContext) + .setTitle(R.string.suggest_file_manager_app_dialog_title) + .setMessage(R.string.suggest_file_manager_app_dialog_text) + .setPositiveButton(R.string.yes, (d, i) -> { + final String appPackageName = "com.simplemobiletools.filemanager"; + try { + mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); + } catch (android.content.ActivityNotFoundException anfe) { + mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); + } + }) + .setNegativeButton(R.string.no, (d, i) -> {}) + .show(); + } } diff --git a/app/src/main/res/values-ca-rES/strings.xml b/app/src/main/res/values-ca-rES/strings.xml index bf3fc0d3..5721d69c 100644 --- a/app/src/main/res/values-ca-rES/strings.xml +++ b/app/src/main/res/values-ca-rES/strings.xml @@ -66,8 +66,6 @@ Ens podeu informar dels problemes que trobeu a través de Github. Obre l\'administrador d\'arxius - No s\'ha trobat cap gestor de fitxers compatible - diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 767d6a50..308e2597 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -67,8 +67,6 @@ Všechny zaznamenané chyby prosím hlašte přes Github. %1$d / %2$d souborů - Nenalezen žádný kompatibilní manažer souborů - diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index b1b58158..76b4ef77 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -63,8 +63,6 @@ Vær venlig at rapportere ethvert problem, du støder på, via Github. %1$d/%2$d Filer - Ingen kompatibel file manager fundet - diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 5cb9d289..98b482d6 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -106,7 +106,9 @@ Bitte melden Sie auftretende Probleme via GitHub. Dateimanager öffnen - Kein kompatibler Dateimanager gefunden + + Kein kompatibler Dateimanager gefunden + Wir empfehlen Dir, die Open-Source App \"Simple File Manager\" aus F-Droid zu installieren. Möchtest Du ihre Seite im App-Store aufrufen? diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index ecc1ab2b..11608bf9 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -63,8 +63,6 @@ %1$d / %2$d αρχεία - Δεν βρέθηκε συμβατός διαχειριστής αρχείων - diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 2e2dcc97..d8caef4f 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -53,8 +53,6 @@ No se encontraron carpetas - No se ha encontrado un gestor de ficheros compatible - diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 80eaf8e0..a0381eb7 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -66,8 +66,6 @@ Ilmoitathan ystävällisesti kaikista havaitsemistasi ongelmista Githubin kautta Avaa tiedostonhallinta - Yhteensopivaa tiedostonhallintaa ei löydy - diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index f6cc4c5d..3a2218a9 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -68,8 +68,6 @@ S\'il vous plaît, soumettez les problèmes que vous rencontrez via Github.Ouvrir le gestionnaire de fichiers - Aucun gestionnaire de fichiers compatible n\'a été trouvé - diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index ca801d20..0dbf12ad 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -72,8 +72,6 @@ Néhány eszközön extra alkalmazás-leállító alkalmazást telepített fel a Fájlkezelő megnyitása - Nem található kompatibilis fájlkezelő - diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index b288c2d2..3233482c 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -60,8 +60,6 @@ Jika ada masalah silakan laporkan lewat Github. %1$d / %2$d Berkas - Tidak ada file manager yang kompatibel yang ditemukan - diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d4b14cb3..63316f88 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -68,8 +68,6 @@ Si prega di segnalare eventuali problemi che si incontrano via Github. Apri il file manager - Nessun gestore file compatibile rilevato - diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 7ea3aa50..dfb03e5b 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -64,8 +64,6 @@ %1$d / %2$d ファイル - 互換性のあるファイルマネージャーが見つかりません - diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index b276a269..0142160d 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -62,8 +62,6 @@ %1$d / %2$d 파일 - 호환되는 파일 매니저를 찾을 수 없습니다 - diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 77163c4e..13d8a5d1 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -68,8 +68,6 @@ Als je problemen tegenkomt, meld ze dan via GitHub. Bestandsbeheerder openen - Geen compatibele bestandsbeheerder gevonden - diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index a336f31d..9003374f 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -67,8 +67,6 @@ Proszę zgłaszać napotkane błędy programu za pośrednictwem serwisu Github.< %1$d / %2$d - Nie znaleziono kompatybilnego menadżera plików - diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 241de990..0b811507 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -68,8 +68,6 @@ Por favor, nos avise sobre quaisquer problemas que você encontrar via Github.Abrir gerenciador de arquivos - Nenhum gerenciador de arquivos compatível foi encontrado - diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 4062f761..73709901 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -55,8 +55,6 @@ Reporte, através do Github, quaisquer problemas que encontre, por favor. Não foram encontradas quaisquer pastas - Não foi encontrado um gestor de ficheiros compatível - diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 23d0b61a..7da8e0f2 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -77,8 +77,6 @@ Vă rugăm să raportați orice problemă întâlniți, prin intermediul GitHub. Deschide managerul de fișiere - Nici un manager de fișiere compatibil găsit - diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 332c1254..f338e027 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -70,8 +70,6 @@ Открыть файловый менеджер - Не найдено совместимого файлового менеджера - diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 90ed9c04..af1b9a0d 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -76,8 +76,6 @@ Vänligen rapportera eventuella problem du stöter på via Github. Öppna filhanteraren - Ingen kompatibel filhanterare hittad - diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index fd84cf68..d8e83335 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -55,8 +55,6 @@ Eğer herhangi bir sorunla karşılaşırsan Github aracılığıyla bildir. Klasör bulunamadı - Uyumlu dosya yöneticisi bulunamadı - diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index cf993e9d..4987e846 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -66,8 +66,6 @@ %1$d / %2$d 个文件 - 未找到兼容的文件管理器 - diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 2f38d887..6a57380d 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -62,8 +62,6 @@ %1$d / %2$d 檔案 - 沒有找到相容的檔案管理員。 - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5f0c75a9..48fad3e4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -106,7 +106,9 @@ Please report any problems you encounter via Github. Open file manager - No compatible file manager found + + No compatible file manager app found + We recommend you to install the open-source file manager app \'Simple File Manager\' from F-Droid. Would you like to open its app store page?