mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-29 15:51:17 +00:00
Added a dialog to suggest a compatible open-source file-manager app if none is found. Updated translations
This commit is contained in:
parent
78b1af9d02
commit
5fbd99619e
25 changed files with 83 additions and 68 deletions
|
@ -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<Folder> {
|
|||
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<Folder> {
|
|||
/**
|
||||
* 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<Folder> {
|
|||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,8 +66,6 @@ Ens podeu informar dels problemes que trobeu a través de Github.</string>
|
|||
|
||||
<string name="open_file_manager">Obre l\'administrador d\'arxius</string>
|
||||
|
||||
<string name="toast_no_file_manager">No s\'ha trobat cap gestor de fitxers compatible</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -67,8 +67,6 @@ Všechny zaznamenané chyby prosím hlašte přes Github.</string>
|
|||
<item quantity="other">%1$d / %2$d souborů</item>
|
||||
</plurals>
|
||||
|
||||
<string name="toast_no_file_manager">Nenalezen žádný kompatibilní manažer souborů</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -63,8 +63,6 @@ Vær venlig at rapportere ethvert problem, du støder på, via Github. </string>
|
|||
<item quantity="other">%1$d/%2$d Filer</item>
|
||||
</plurals>
|
||||
|
||||
<string name="toast_no_file_manager">Ingen kompatibel file manager fundet</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -106,7 +106,9 @@ Bitte melden Sie auftretende Probleme via GitHub.</string>
|
|||
|
||||
<string name="open_file_manager">Dateimanager öffnen</string>
|
||||
|
||||
<string name="toast_no_file_manager">Kein kompatibler Dateimanager gefunden</string>
|
||||
<!-- Suggest File Manager App Dialog -->
|
||||
<string name="suggest_file_manager_app_dialog_title">Kein kompatibler Dateimanager gefunden</string>
|
||||
<string name="suggest_file_manager_app_dialog_text">Wir empfehlen Dir, die Open-Source App \"Simple File Manager\" aus F-Droid zu installieren. Möchtest Du ihre Seite im App-Store aufrufen?</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
|
|
@ -63,8 +63,6 @@
|
|||
<item quantity="other">%1$d / %2$d αρχεία</item>
|
||||
</plurals>
|
||||
|
||||
<string name="toast_no_file_manager">Δεν βρέθηκε συμβατός διαχειριστής αρχείων</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -53,8 +53,6 @@
|
|||
<!-- Shown if no folders exist -->
|
||||
<string name="folder_list_empty">No se encontraron carpetas</string>
|
||||
|
||||
<string name="toast_no_file_manager">No se ha encontrado un gestor de ficheros compatible</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -66,8 +66,6 @@ Ilmoitathan ystävällisesti kaikista havaitsemistasi ongelmista Githubin kautta
|
|||
|
||||
<string name="open_file_manager">Avaa tiedostonhallinta</string>
|
||||
|
||||
<string name="toast_no_file_manager">Yhteensopivaa tiedostonhallintaa ei löydy</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -68,8 +68,6 @@ S\'il vous plaît, soumettez les problèmes que vous rencontrez via Github.</str
|
|||
|
||||
<string name="open_file_manager">Ouvrir le gestionnaire de fichiers</string>
|
||||
|
||||
<string name="toast_no_file_manager">Aucun gestionnaire de fichiers compatible n\'a été trouvé</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -72,8 +72,6 @@ Néhány eszközön extra alkalmazás-leállító alkalmazást telepített fel a
|
|||
|
||||
<string name="open_file_manager">Fájlkezelő megnyitása</string>
|
||||
|
||||
<string name="toast_no_file_manager">Nem található kompatibilis fájlkezelő</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -60,8 +60,6 @@ Jika ada masalah silakan laporkan lewat Github.</string>
|
|||
<item quantity="other">%1$d / %2$d Berkas</item>
|
||||
</plurals>
|
||||
|
||||
<string name="toast_no_file_manager">Tidak ada file manager yang kompatibel yang ditemukan</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -68,8 +68,6 @@ Si prega di segnalare eventuali problemi che si incontrano via Github.</string>
|
|||
|
||||
<string name="open_file_manager">Apri il file manager</string>
|
||||
|
||||
<string name="toast_no_file_manager">Nessun gestore file compatibile rilevato</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -64,8 +64,6 @@
|
|||
<item quantity="other">%1$d / %2$d ファイル</item>
|
||||
</plurals>
|
||||
|
||||
<string name="toast_no_file_manager">互換性のあるファイルマネージャーが見つかりません</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -62,8 +62,6 @@
|
|||
<item quantity="other">%1$d / %2$d 파일</item>
|
||||
</plurals>
|
||||
|
||||
<string name="toast_no_file_manager">호환되는 파일 매니저를 찾을 수 없습니다</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -68,8 +68,6 @@ Als je problemen tegenkomt, meld ze dan via GitHub.</string>
|
|||
|
||||
<string name="open_file_manager">Bestandsbeheerder openen</string>
|
||||
|
||||
<string name="toast_no_file_manager">Geen compatibele bestandsbeheerder gevonden</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -67,8 +67,6 @@ Proszę zgłaszać napotkane błędy programu za pośrednictwem serwisu Github.<
|
|||
<item quantity="other">%1$d / %2$d</item>
|
||||
</plurals>
|
||||
|
||||
<string name="toast_no_file_manager">Nie znaleziono kompatybilnego menadżera plików</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -68,8 +68,6 @@ Por favor, nos avise sobre quaisquer problemas que você encontrar via Github.</
|
|||
|
||||
<string name="open_file_manager">Abrir gerenciador de arquivos</string>
|
||||
|
||||
<string name="toast_no_file_manager">Nenhum gerenciador de arquivos compatível foi encontrado</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -55,8 +55,6 @@ Reporte, através do Github, quaisquer problemas que encontre, por favor.</strin
|
|||
<!-- Shown if no folders exist -->
|
||||
<string name="folder_list_empty">Não foram encontradas quaisquer pastas</string>
|
||||
|
||||
<string name="toast_no_file_manager">Não foi encontrado um gestor de ficheiros compatível</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -77,8 +77,6 @@ Vă rugăm să raportați orice problemă întâlniți, prin intermediul GitHub.
|
|||
|
||||
<string name="open_file_manager">Deschide managerul de fișiere</string>
|
||||
|
||||
<string name="toast_no_file_manager">Nici un manager de fișiere compatibil găsit</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -70,8 +70,6 @@
|
|||
|
||||
<string name="open_file_manager">Открыть файловый менеджер</string>
|
||||
|
||||
<string name="toast_no_file_manager">Не найдено совместимого файлового менеджера</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -76,8 +76,6 @@ Vänligen rapportera eventuella problem du stöter på via Github.</string>
|
|||
|
||||
<string name="open_file_manager">Öppna filhanteraren</string>
|
||||
|
||||
<string name="toast_no_file_manager">Ingen kompatibel filhanterare hittad</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -55,8 +55,6 @@ Eğer herhangi bir sorunla karşılaşırsan Github aracılığıyla bildir.</st
|
|||
<!-- Shown if no folders exist -->
|
||||
<string name="folder_list_empty">Klasör bulunamadı</string>
|
||||
|
||||
<string name="toast_no_file_manager">Uyumlu dosya yöneticisi bulunamadı</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -66,8 +66,6 @@
|
|||
<item quantity="other">%1$d / %2$d 个文件</item>
|
||||
</plurals>
|
||||
|
||||
<string name="toast_no_file_manager">未找到兼容的文件管理器</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -62,8 +62,6 @@
|
|||
<item quantity="other">%1$d / %2$d 檔案</item>
|
||||
</plurals>
|
||||
|
||||
<string name="toast_no_file_manager">沒有找到相容的檔案管理員。</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
||||
|
|
|
@ -106,7 +106,9 @@ Please report any problems you encounter via Github.</string>
|
|||
|
||||
<string name="open_file_manager">Open file manager</string>
|
||||
|
||||
<string name="toast_no_file_manager">No compatible file manager found</string>
|
||||
<!-- Suggest File Manager App Dialog -->
|
||||
<string name="suggest_file_manager_app_dialog_title">No compatible file manager app found</string>
|
||||
<string name="suggest_file_manager_app_dialog_text">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?</string>
|
||||
|
||||
<!-- DevicesFragment -->
|
||||
|
||||
|
|
Loading…
Reference in a new issue