From e8627800fef6525bc4ed3324c03178d7ac8850cd Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 13 Dec 2020 12:42:10 -0500 Subject: [PATCH] Remove bundled fallback file picker --- app/build.gradle | 1 - app/src/main/AndroidManifest.xml | 4 -- .../tachiyomi/data/backup/BackupNotifier.kt | 2 +- .../data/library/LibraryUpdateNotifier.kt | 2 +- .../ui/setting/SettingsBackupController.kt | 8 +--- .../ui/setting/SettingsDownloadController.kt | 8 ++-- .../util/system/ContextExtensions.kt | 15 -------- .../tachiyomi/widget/CustomLayoutPicker.kt | 33 ---------------- app/src/main/res/drawable/ic_folder_24dp.xml | 9 +++++ .../main/res/layout/common_listitem_dir.xml | 38 ------------------- app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 18 --------- 12 files changed, 18 insertions(+), 121 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/widget/CustomLayoutPicker.kt create mode 100644 app/src/main/res/drawable/ic_folder_24dp.xml delete mode 100644 app/src/main/res/layout/common_listitem_dir.xml diff --git a/app/build.gradle b/app/build.gradle index 92e65f37d..7d0209476 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -239,7 +239,6 @@ dependencies { implementation 'com.github.dmytrodanylyk.android-process-button:library:1.0.4' implementation 'eu.davidea:flexible-adapter:5.1.0' implementation 'eu.davidea:flexible-adapter-ui:1.0.0' - implementation 'com.nononsenseapps:filepicker:2.5.2' implementation 'com.nightlynexus.viewstatepageradapter:viewstatepageradapter:1.1.0' implementation 'com.github.chrisbanes:PhotoView:2.3.0' implementation 'com.github.carlosesco:DirectionalViewPager:a844dbca0a' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 860bedd4e..19800e17c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -80,10 +80,6 @@ - diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt index 7354c685f..252f3c798 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt @@ -146,7 +146,7 @@ class BackupNotifier(private val context: Context) { val uri = destFile.getUriCompat(context) addAction( - R.drawable.nnf_ic_file_folder, + R.drawable.ic_folder_24dp, context.getString(R.string.action_open_log), NotificationReceiver.openErrorLogPendingActivity(context, uri) ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt index 26fb7e6e1..83ea5fa59 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt @@ -109,7 +109,7 @@ class LibraryUpdateNotifier(private val context: Context) { setContentIntent(errorLogIntent) addAction( - R.drawable.nnf_ic_file_folder, + R.drawable.ic_folder_24dp, context.getString(R.string.action_open_log), errorLogIntent ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt index 3fcd1b819..9d703461c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsBackupController.kt @@ -39,7 +39,6 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.summaryRes import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes -import eu.kanade.tachiyomi.util.system.getFilePicker import eu.kanade.tachiyomi.util.system.toast import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach @@ -125,13 +124,11 @@ class SettingsBackupController : SettingsController() { titleRes = R.string.pref_backup_directory onClick { - val currentDir = preferences.backupsDirectory().get() try { val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) startActivityForResult(intent, CODE_BACKUP_DIR) } catch (e: ActivityNotFoundException) { - // Fall back to custom picker on error - startActivityForResult(preferences.context.getFilePicker(currentDir), CODE_BACKUP_DIR) + activity?.toast(R.string.file_picker_error) } } @@ -277,8 +274,7 @@ class SettingsBackupController : SettingsController() { startActivityForResult(intent, code) } catch (e: ActivityNotFoundException) { - // Handle errors where the Android ROM doesn't support the built in picker - startActivityForResult(preferences.context.getFilePicker(currentDir), code) + activity?.toast(R.string.file_picker_error) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt index d11d8dea8..02201b1b9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt @@ -27,7 +27,7 @@ import eu.kanade.tachiyomi.util.preference.preference import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes -import eu.kanade.tachiyomi.util.system.getFilePicker +import eu.kanade.tachiyomi.util.system.toast import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import uy.kohesive.injekt.Injekt @@ -155,12 +155,12 @@ class SettingsDownloadController : SettingsController() { preferences.downloadsDirectory().set(path.toString()) } - fun customDirectorySelected(currentDir: String) { + fun customDirectorySelected() { val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) try { startActivityForResult(intent, DOWNLOAD_DIR) } catch (e: ActivityNotFoundException) { - startActivityForResult(preferences.context.getFilePicker(currentDir), DOWNLOAD_DIR) + activity?.toast(R.string.file_picker_error) } } @@ -181,7 +181,7 @@ class SettingsDownloadController : SettingsController() { ) { _, position, text -> val target = targetController as? SettingsDownloadController if (position == externalDirs.lastIndex) { - target?.customDirectorySelected(currentDir) + target?.customDirectorySelected() } else { target?.predefinedDirectorySelected(text.toString()) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt index 2a541c4b0..6d2ff415e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt @@ -29,10 +29,8 @@ import androidx.core.graphics.green import androidx.core.graphics.red import androidx.core.net.toUri import androidx.localbroadcastmanager.content.LocalBroadcastManager -import com.nononsenseapps.filepicker.FilePickerActivity import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.lang.truncateCenter -import eu.kanade.tachiyomi.widget.CustomLayoutPickerActivity import kotlin.math.roundToInt /** @@ -98,19 +96,6 @@ fun Context.notification(channelId: String, block: (NotificationCompat.Builder.( return builder.build() } -/** - * Helper method to construct an Intent to use a custom file picker. - * @param currentDir the path the file picker will open with. - * @return an Intent to start the file picker activity. - */ -fun Context.getFilePicker(currentDir: String): Intent { - return Intent(this, CustomLayoutPickerActivity::class.java) - .putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false) - .putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, true) - .putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR) - .putExtra(FilePickerActivity.EXTRA_START_PATH, currentDir) -} - /** * Checks if the give permission is granted. * diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/CustomLayoutPicker.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/CustomLayoutPicker.kt deleted file mode 100644 index 40f7b8ba8..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/CustomLayoutPicker.kt +++ /dev/null @@ -1,33 +0,0 @@ -package eu.kanade.tachiyomi.widget - -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import com.nononsenseapps.filepicker.AbstractFilePickerFragment -import com.nononsenseapps.filepicker.FilePickerActivity -import com.nononsenseapps.filepicker.FilePickerFragment -import com.nononsenseapps.filepicker.LogicHandler -import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.util.view.inflate -import java.io.File - -class CustomLayoutPickerActivity : FilePickerActivity() { - - override fun getFragment(startPath: String?, mode: Int, allowMultiple: Boolean, allowCreateDir: Boolean): - AbstractFilePickerFragment { - val fragment = CustomLayoutFilePickerFragment() - fragment.setArgs(startPath, mode, allowMultiple, allowCreateDir) - return fragment - } -} - -class CustomLayoutFilePickerFragment : FilePickerFragment() { - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { - return when (viewType) { - LogicHandler.VIEWTYPE_DIR -> { - val view = parent.inflate(R.layout.common_listitem_dir) - DirViewHolder(view) - } - else -> super.onCreateViewHolder(parent, viewType) - } - } -} diff --git a/app/src/main/res/drawable/ic_folder_24dp.xml b/app/src/main/res/drawable/ic_folder_24dp.xml new file mode 100644 index 000000000..4cb57e91c --- /dev/null +++ b/app/src/main/res/drawable/ic_folder_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/common_listitem_dir.xml b/app/src/main/res/layout/common_listitem_dir.xml deleted file mode 100644 index 5618118f4..000000000 --- a/app/src/main/res/layout/common_listitem_dir.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 483beb8a7..0bd26debf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -665,6 +665,7 @@ Select cover image Select backup file + No file picker app found Download diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 857cbe9e4..9208db915 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -325,22 +325,4 @@ 15sp - - - - - - -