Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.provider.DocumentsContract
import android.view.ActionMode
import android.view.View
import android.view.ViewGroup
Expand All @@ -30,8 +31,8 @@ import app.opendocument.droid.background.NightModeSetting
import app.opendocument.droid.background.PaginationSetting
import app.opendocument.droid.background.PersistedUriPermissions
import app.opendocument.droid.background.PrintingManager
import app.opendocument.droid.background.RecentDocumentsUtil
import app.opendocument.droid.background.ReviewInvitation
import app.opendocument.droid.background.SupportedDocumentTypes
import app.opendocument.droid.nonfree.AdManager
import app.opendocument.droid.nonfree.AnalyticsConstants
import app.opendocument.droid.nonfree.AnalyticsManager
Expand Down Expand Up @@ -906,34 +907,22 @@ class MainActivity : AppCompatActivity() {
}

/**
* What the picker is told to offer: everything the app can open, plus the type that means
* nothing at all.
*
* This is what makes it a document picker rather than a file picker - with it the image, audio
* and video filters come off the screen, and a phone full of photos does not have to be walked
* past to reach a document. Setting a starting folder was the other way of doing this and is
* the wrong one: documents are wherever the user put them, mostly Downloads, and sending
* everyone to Documents is only right for the people who use that folder.
*
* [GENERIC_MIME_TYPE] is in the list because a filter is worse than no filter when it hides a
* file the app could open. Providers regularly volunteer nothing better than
* application/octet-stream for a real document - the same reason [SupportedDocumentTypes] keeps
* an extension fallback - and a filtered picker does not grey those out, it leaves them out
* altogether. The price is that other unnamed binaries stay listed too, which is the harmless
* half of the trade.
*
* Images are not here, though [CoreLoader] shows them: this is a document reader's file picker,
* and an image reaches it by being shared or opened from a gallery.
* The newest recent document the picker can be pointed at, so it opens in that folder rather
* than in Recent. Only a document uri works; one handed over by ACTION_VIEW does not.
*/
private fun pickableMimeTypes(): Array<String> =
(SupportedDocumentTypes.MIME_TYPES + GENERIC_MIME_TYPE).toTypedArray()
private fun lastPickedDocument(): Uri? =
RecentDocumentsUtil.getRecentDocuments(this)
.map { Uri.parse(it.uri) }
.firstOrNull { DocumentsContract.isDocumentUri(this, it) }

fun findDocument() {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
intent.addCategory(Intent.CATEGORY_OPENABLE)
// no EXTRA_MIME_TYPES: the picker leaves out what fails the filter rather than greying it,
// and providers report types the core's table does not spell, so documents went missing
intent.type = "*/*"

intent.putExtra(Intent.EXTRA_MIME_TYPES, pickableMimeTypes())
lastPickedDocument()?.let { intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, it) }

intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
Expand Down Expand Up @@ -1010,10 +999,6 @@ class MainActivity : AppCompatActivity() {
const val GOOGLE_REQUEST_CODE = 1993
const val DOCUMENT_FRAGMENT_TAG = "document_fragment"

// what a provider volunteers when it has nothing better to say. included in the picker's
// filter on purpose - see pickableMimeTypes
const val GENERIC_MIME_TYPE = "application/octet-stream"

// taken from: https://stackoverflow.com/a/36829889/198996
private fun isTesting(): Boolean =
try {
Expand Down
18 changes: 15 additions & 3 deletions app/src/main/res/layout/item_landing_open.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- The way in, kept at the top of the list whatever the list holds: with documents below it
it sits directly above them, and with nothing below it, it is the only thing to do. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
it sits directly above them, and with nothing below it, it is the only thing to do.
The hint is for the users who never find the picker's drawer. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="20dp"
android:paddingTop="12dp"
android:paddingEnd="20dp"
Expand All @@ -18,4 +20,14 @@
android:layout_gravity="center_horizontal"
android:text="@string/landing_open_file"
app:icon="@drawable/ic_folder_open" />
</FrameLayout>

<TextView
android:id="@+id/landing_open_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center_horizontal"
android:text="@string/landing_open_hint"
android:textAppearance="?attr/textAppearanceBodySmall"
android:textColor="?attr/colorOnSurfaceVariant" />
</LinearLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">S\'ha suprimit dels recents</string>
<string name="landing_undo">Desfés</string>
<string name="landing_open_file">Obre un fitxer</string>
<string name="landing_open_hint">No trobeu el fitxer? Toqueu ☰ al selector o obriu-lo des del gestor de fitxers.</string>
<string name="document_actions_more">Més accions</string>
<string name="document_actions_close">Tanca les accions</string>
<string name="tts_status_reading">S\'està llegint…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Odebráno z nedávných</string>
<string name="landing_undo">Zpět</string>
<string name="landing_open_file">Otevřít soubor</string>
<string name="landing_open_hint">Nemůžete soubor najít? Ve výběru souborů klepněte na ☰, nebo jej otevřete ze správce souborů.</string>
<string name="document_actions_more">Další akce</string>
<string name="document_actions_close">Skrýt akce</string>
<string name="tts_status_reading">Předčítání…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Fjernet fra seneste</string>
<string name="landing_undo">Fortryd</string>
<string name="landing_open_file">Åbn en fil</string>
<string name="landing_open_hint">Kan du ikke finde din fil? Tryk på ☰ i filvælgeren, eller åbn den fra din filhåndtering.</string>
<string name="document_actions_more">Flere handlinger</string>
<string name="document_actions_close">Skjul handlinger</string>
<string name="tts_status_reading">Læser op…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Aus „Zuletzt verwendet“ entfernt</string>
<string name="landing_undo">Rückgängig</string>
<string name="landing_open_file">Datei öffnen</string>
<string name="landing_open_hint">Datei nicht gefunden? Tippen Sie in der Dateiauswahl auf ☰ oder öffnen Sie die Datei über Ihren Dateimanager.</string>
<string name="document_actions_more">Weitere Aktionen</string>
<string name="document_actions_close">Aktionen schließen</string>
<string name="tts_status_reading">Wird vorgelesen…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Eliminado de recientes</string>
<string name="landing_undo">Deshacer</string>
<string name="landing_open_file">Abrir un archivo</string>
<string name="landing_open_hint">¿No encuentra su archivo? Pulse ☰ en el selector o ábralo desde su gestor de archivos.</string>
<string name="document_actions_more">Más acciones</string>
<string name="document_actions_close">Cerrar acciones</string>
<string name="tts_status_reading">Leyendo…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Eemaldatud hiljutiste hulgast</string>
<string name="landing_undo">Võta tagasi</string>
<string name="landing_open_file">Ava fail</string>
<string name="landing_open_hint">Ei leia oma faili? Puuduta failivalijas ☰ või ava fail oma failihaldurist.</string>
<string name="document_actions_more">Rohkem toiminguid</string>
<string name="document_actions_close">Sulge toimingud</string>
<string name="tts_status_reading">Loeb ette…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Retiré des récents</string>
<string name="landing_undo">Annuler</string>
<string name="landing_open_file">Ouvrir un fichier</string>
<string name="landing_open_hint">Vous ne trouvez pas votre fichier ? Appuyez sur ☰ dans le sélecteur, ou ouvrez-le depuis votre gestionnaire de fichiers.</string>
<string name="document_actions_more">Plus d\'actions</string>
<string name="document_actions_close">Fermer les actions</string>
<string name="tts_status_reading">Lecture en cours…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ga/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Baineadh den liosta é</string>
<string name="landing_undo">Cuir ar ais</string>
<string name="landing_open_file">Oscail comhad</string>
<string name="landing_open_hint">Nach bhfuil do chomhad le fáil? Brúigh ☰ sa roghnóir comhad, nó oscail é ó do bhainisteoir comhad.</string>
<string name="document_actions_more">Tuilleadh gníomhartha</string>
<string name="document_actions_close">Dún na gníomhartha</string>
<string name="tts_status_reading">Ag léamh…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">हाल की सूची से हटाया गया</string>
<string name="landing_undo">पूर्ववत करें</string>
<string name="landing_open_file">फ़ाइल खोलें</string>
<string name="landing_open_hint">आपकी फ़ाइल नहीं मिल रही? फ़ाइल चुनने वाली स्क्रीन में ☰ पर टैप करें, या इसे अपने फ़ाइल मैनेजर से खोलें।</string>
<string name="document_actions_more">और विकल्प</string>
<string name="document_actions_close">विकल्प बंद करें</string>
<string name="tts_status_reading">पढ़ा जा रहा है…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Rimosso dai recenti</string>
<string name="landing_undo">Annulla</string>
<string name="landing_open_file">Apri un file</string>
<string name="landing_open_hint">Non trovi il tuo file? Tocca ☰ nel selettore di file oppure aprilo dal tuo file manager.</string>
<string name="document_actions_more">Altre azioni</string>
<string name="document_actions_close">Chiudi le azioni</string>
<string name="tts_status_reading">Lettura in corso…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">最近使用したファイルから削除しました</string>
<string name="landing_undo">元に戻す</string>
<string name="landing_open_file">ファイルを開く</string>
<string name="landing_open_hint">ファイルが見つかりませんか? ファイル選択画面で ☰ をタップするか、ファイル管理アプリから開いてください。</string>
<string name="document_actions_more">その他の操作</string>
<string name="document_actions_close">操作を閉じる</string>
<string name="tts_status_reading">読み上げ中…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">최근 목록에서 삭제됨</string>
<string name="landing_undo">실행 취소</string>
<string name="landing_open_file">파일 열기</string>
<string name="landing_open_hint">파일을 찾을 수 없나요? 파일 선택 화면에서 ☰을 누르거나 파일 관리자 앱에서 열어 보세요.</string>
<string name="document_actions_more">작업 더 보기</string>
<string name="document_actions_close">작업 닫기</string>
<string name="tts_status_reading">읽는 중...</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Usunięto z ostatnio otwieranych</string>
<string name="landing_undo">Cofnij</string>
<string name="landing_open_file">Otwórz plik</string>
<string name="landing_open_hint">Nie możesz znaleźć pliku? Naciśnij ☰ w oknie wyboru plików lub otwórz plik w menedżerze plików.</string>
<string name="document_actions_more">Więcej opcji</string>
<string name="document_actions_close">Ukryj opcje</string>
<string name="tts_status_reading">Czytanie…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Removido dos recentes</string>
<string name="landing_undo">Desfazer</string>
<string name="landing_open_file">Abrir um arquivo</string>
<string name="landing_open_hint">Não encontrou seu arquivo? Toque em ☰ no seletor ou abra-o pelo seu gerenciador de arquivos.</string>
<string name="document_actions_more">Mais ações</string>
<string name="document_actions_close">Fechar ações</string>
<string name="tts_status_reading">Lendo…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Удалено из недавних</string>
<string name="landing_undo">Отменить</string>
<string name="landing_open_file">Открыть файл</string>
<string name="landing_open_hint">Не можете найти файл? Нажмите ☰ в окне выбора файлов или откройте его из файлового менеджера.</string>
<string name="document_actions_more">Ещё действия</string>
<string name="document_actions_close">Скрыть действия</string>
<string name="tts_status_reading">Чтение…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-sl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Odstranjeno iz nedavnih</string>
<string name="landing_undo">Razveljavi</string>
<string name="landing_open_file">Odpri datoteko</string>
<string name="landing_open_hint">Ne najdete datoteke? V izbirniku pritisnite ☰ ali jo odprite v upravitelju datotek.</string>
<string name="document_actions_more">Več dejanj</string>
<string name="document_actions_close">Zapri dejanja</string>
<string name="tts_status_reading">Branje …</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Borttagen från listan</string>
<string name="landing_undo">Ångra</string>
<string name="landing_open_file">Öppna en fil</string>
<string name="landing_open_hint">Hittar du inte filen? Tryck på ☰ i filväljaren, eller öppna den från filhanteraren.</string>
<string name="document_actions_more">Fler åtgärder</string>
<string name="document_actions_close">Stäng åtgärderna</string>
<string name="tts_status_reading">Läser upp…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">Son kullanılanlardan kaldırıldı</string>
<string name="landing_undo">Geri al</string>
<string name="landing_open_file">Dosya aç</string>
<string name="landing_open_hint">Dosyanızı bulamıyor musunuz? Dosya seçicide ☰ simgesine dokunun veya dosyayı dosya yöneticinizden açın.</string>
<string name="document_actions_more">Diğer işlemler</string>
<string name="document_actions_close">İşlemleri kapat</string>
<string name="tts_status_reading">Okunuyor…</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="landing_recent_removed">已从最近列表中移除</string>
<string name="landing_undo">撤销</string>
<string name="landing_open_file">打开文件</string>
<string name="landing_open_hint">找不到文件?请在文件选择器中点按 ☰,或从文件管理器中打开。</string>
<string name="document_actions_more">更多操作</string>
<string name="document_actions_close">收起操作</string>
<string name="tts_status_reading">正在朗读…</string>
Expand Down
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 @@ -78,6 +78,8 @@
<string name="landing_recent_removed">Removed from recent</string>
<string name="landing_undo">Undo</string>
<string name="landing_open_file">Open a file</string>
<!-- under the Open button. ☰ is the menu button at the top left of Android's file picker -->
<string name="landing_open_hint">Can\'t find your file? Tap ☰ in the picker, or open it from your file manager.</string>
<string name="document_actions_more">More actions</string>
<string name="document_actions_close">Close actions</string>
<string name="tts_status_reading">Reading…</string>
Expand Down
Loading