Added default folder option

This commit is contained in:
Roland Kister 2020-10-26 09:15:53 +01:00
parent 53c855f252
commit 70d68d1a4a
43 changed files with 135 additions and 0 deletions

View File

@ -93,6 +93,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
appLaunched(BuildConfig.APPLICATION_ID)
if (savedInstanceState == null) {
openDefaultFolder()
config.temporarilyShowHidden = false
config.tempSkipDeleteConfirmation = false
removeTempFolder()
@ -290,6 +292,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
findItem(R.id.reduce_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt > 1
findItem(R.id.hide_the_recycle_bin).isVisible = useBin && config.showRecycleBinAtFolders
findItem(R.id.show_the_recycle_bin).isVisible = useBin && !config.showRecycleBinAtFolders
findItem(R.id.set_as_default_folder).isVisible = config.defaultFolder != null
setupSearch(this)
}
}
@ -315,6 +318,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
R.id.hide_the_recycle_bin -> toggleRecycleBin(false)
R.id.increase_column_count -> increaseColumnCount()
R.id.reduce_column_count -> reduceColumnCount()
R.id.set_as_default_folder -> setAsDefaultFolder()
R.id.settings -> launchSettings()
R.id.about -> launchAbout()
else -> return super.onOptionsItemSelected(item)
@ -1393,4 +1397,27 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
checkWhatsNew(this, BuildConfig.VERSION_CODE)
}
}
private fun setAsDefaultFolder() {
config.defaultFolder = null
invalidateOptionsMenu()
}
private fun openDefaultFolder() {
if (config.defaultFolder == null) {
return;
}
val defaultDir = File(config.defaultFolder!!)
if (!defaultDir.exists() || !defaultDir.isDirectory) {
config.defaultFolder = null
return;
}
Intent(this, MediaActivity::class.java).apply {
putExtra(DIRECTORY, defaultDir.path)
handleMediaIntent(this)
}
}
}

View File

@ -219,6 +219,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_media, menu)
val isDefaultFolder = config.defaultFolder != null && File(config.defaultFolder!!).compareTo(File(mPath)) == 0
menu.apply {
findItem(R.id.group).isVisible = !config.scrollHorizontally
@ -234,6 +236,9 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden
findItem(R.id.set_as_default_folder).isVisible = !isDefaultFolder
findItem(R.id.unset_as_default_folder).isVisible = isDefaultFolder
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
findItem(R.id.increase_column_count).isVisible = viewType == VIEW_TYPE_GRID && config.mediaColumnCnt < MAX_COLUMN_COUNT
findItem(R.id.reduce_column_count).isVisible = viewType == VIEW_TYPE_GRID && config.mediaColumnCnt > 1
@ -262,6 +267,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
R.id.increase_column_count -> increaseColumnCount()
R.id.reduce_column_count -> reduceColumnCount()
R.id.set_as_default_folder -> setAsDefaultFolder()
R.id.unset_as_default_folder -> unsetAsDefaultFolder()
R.id.slideshow -> startSlideshow()
R.id.settings -> launchSettings()
R.id.about -> launchAbout()
@ -937,4 +944,14 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
}
finish()
}
private fun setAsDefaultFolder() {
config.defaultFolder = mPath
invalidateOptionsMenu()
}
private fun unsetAsDefaultFolder() {
config.defaultFolder = null
invalidateOptionsMenu()
}
}

View File

@ -198,6 +198,10 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getInt(getDirectoryColumnsField(), getDefaultDirectoryColumnCount())
set(dirColumnCnt) = prefs.edit().putInt(getDirectoryColumnsField(), dirColumnCnt).apply()
var defaultFolder: String?
get() = prefs.getString(DEFAULT_FOLDER, null)
set(defaultFolder) = prefs.edit().putString(DEFAULT_FOLDER, defaultFolder).apply()
var allowInstantChange: Boolean
get() = prefs.getBoolean(ALLOW_INSTANT_CHANGE, false)
set(allowInstantChange) = prefs.edit().putBoolean(ALLOW_INSTANT_CHANGE, allowInstantChange).apply()

View File

@ -23,6 +23,7 @@ const val DISPLAY_FILE_NAMES = "display_file_names"
const val BLACK_BACKGROUND = "dark_background"
const val PINNED_FOLDERS = "pinned_folders"
const val FILTER_MEDIA = "filter_media"
const val DEFAULT_FOLDER = "default_folder"
const val DIR_COLUMN_CNT = "dir_column_cnt"
const val DIR_LANDSCAPE_COLUMN_CNT = "dir_landscape_column_cnt"
const val DIR_HORIZONTAL_COLUMN_CNT = "dir_horizontal_column_cnt"

View File

@ -58,6 +58,10 @@
android:id="@+id/reduce_column_count"
android:title="@string/reduce_column_count"
app:showAsAction="never"/>
<item
android:id="@+id/set_as_default_folder"
android:title="@string/set_as_default_folder"
app:showAsAction="never"/>
<item
android:id="@+id/settings"
android:title="@string/settings"

View File

@ -71,6 +71,14 @@
android:id="@+id/reduce_column_count"
android:title="@string/reduce_column_count"
app:showAsAction="never"/>
<item
android:id="@+id/set_as_default_folder"
android:title="@string/set_as_default_folder"
app:showAsAction="never"/>
<item
android:id="@+id/unset_as_default_folder"
android:title="@string/unset_as_default_folder"
app:showAsAction="never"/>
<item
android:id="@+id/slideshow"
android:title="@string/slideshow"

View File

@ -17,6 +17,7 @@
<string name="unknown_location">موقع غير معروف</string>
<string name="increase_column_count">زيادة عدد الأعمدة</string>
<string name="reduce_column_count">تقليل عدد الأعمدة</string>
<string name="set_as_default_folder">تعيين كمجلد افتراضي</string>
<string name="change_cover_image">تغيير صورة الغلاف</string>
<string name="select_photo">تحديد صورة</string>
<string name="volume">الصوت</string>
@ -375,6 +376,7 @@
<b>موقع رديت:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="unset_as_default_folder">غير محدد كمجلد افتراضي</string>
<!--
Haven't found some strings? There's more at

View File

@ -17,6 +17,7 @@
<string name="unknown_location">Unknown location</string>
<string name="increase_column_count">Increase column count</string>
<string name="reduce_column_count">Reduce column count</string>
<string name="set_as_default_folder">Varsayılan qovluq olaraq təyin edin</string>
<string name="change_cover_image">Change cover image</string>
<string name="select_photo">Select photo</string>
<string name="volume">Volume</string>
@ -376,6 +377,7 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="unset_as_default_folder">Varsayılan qovluq kimi silin</string>
<!--
Haven't found some strings? There's more at

View File

@ -17,6 +17,7 @@
<string name="unknown_location">Ubicació desconeguda</string>
<string name="increase_column_count">Augmentar el número de columnes</string>
<string name="reduce_column_count">Reduir el número de columnes</string>
<string name="set_as_default_folder">Estableix com a carpeta predeterminada</string>
<string name="change_cover_image">Canviar imatge de portada</string>
<string name="select_photo">Sel·leccionar imatge</string>
<string name="volume">Volum</string>
@ -376,6 +377,7 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="unset_as_default_folder">Desactiva com a carpeta predeterminada</string>
<!--
Haven't found some strings? There's more at

View File

@ -17,6 +17,7 @@
<string name="unknown_location">Neznámá poloha</string>
<string name="increase_column_count">Zvýšit počet sloupců</string>
<string name="reduce_column_count">Snížit počet sloupců</string>
<string name="set_as_default_folder">Nastavit jako výchozí složku</string>
<string name="change_cover_image">Změnit obal alba</string>
<string name="select_photo">Vybrat fotografii</string>
<string name="volume">Hlasitost</string>
@ -376,6 +377,7 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="unset_as_default_folder">Zrušit nastavení jako výchozí složku</string>
<!--
Haven't found some strings? There's more at

View File

@ -17,6 +17,7 @@
<string name="unknown_location">Ukendt placering</string>
<string name="increase_column_count">Flere kolonner</string>
<string name="reduce_column_count">Færre kolonner</string>
<string name="set_as_default_folder">Indstil som standardmappe</string>
<string name="change_cover_image">Skift cover-billede</string>
<string name="select_photo">Vælg billede</string>
<string name="volume">Lydstyrke</string>
@ -376,6 +377,7 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="unset_as_default_folder">Frakoblet som standardmappe</string>
<!--
Haven't found some strings? There's more at

View File

@ -17,6 +17,7 @@
<string name="unknown_location">Unbekannter Pfad</string>
<string name="increase_column_count">Kacheln verkleinern</string>
<string name="reduce_column_count">Kacheln vergrößern</string>
<string name="set_as_default_folder">Als Standardordner festlegen</string>
<string name="change_cover_image">Coverbild ändern</string>
<string name="select_photo">Auswählen</string>
<string name="volume">Lautstärke</string>
@ -375,6 +376,7 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="unset_as_default_folder">Als Standardordner deaktivieren</string>
<!--
Haven't found some strings? There's more at

View File

@ -17,6 +17,7 @@
<string name="unknown_location">Άγνωστη τοποθεσία</string>
<string name="increase_column_count">Αύξηση αριθμού στηλών</string>
<string name="reduce_column_count">Μείωση αριθμού στηλών</string>
<string name="set_as_default_folder">Set as default folder</string>
<string name="change_cover_image">Αλλαγή εξώφυλλου φακέλου</string>
<string name="select_photo">Επιλογή φωτογραφίας</string>
<string name="volume">Ένταση</string>
@ -377,6 +378,7 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="unset_as_default_folder">Unset default folder</string>
<!--
Haven't found some strings? There's more at

View File

@ -17,6 +17,7 @@
<string name="unknown_location">Ubicación desconocida</string>
<string name="increase_column_count">Aumentar el número de columnas</string>
<string name="reduce_column_count">Reducir el número de columnas</string>
<string name="set_as_default_folder">Establecer como carpeta predeterminada</string>
<string name="change_cover_image">Cambiar imagen de portada</string>
<string name="select_photo">Seleccionar imagen</string>
<string name="volume">Volumen</string>
@ -376,6 +377,7 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="unset_as_default_folder">Desmarcar como carpeta predeterminada</string>
<!--
Haven't found some strings? There's more at

View File

@ -17,6 +17,7 @@
<string name="unknown_location">Tuntematon sijainti</string>
<string name="increase_column_count">Lisää sarakkeita</string>
<string name="reduce_column_count">Vähennä sarakkeita</string>
<string name="set_as_default_folder">Aseta oletuskansioksi</string>
<string name="change_cover_image">Vaihda kansikuva</string>
<string name="select_photo">Valitse kuva</string>
<string name="volume">Äänenvoimakkuus</string>
@ -376,6 +377,7 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="unset_as_default_folder">Määritä oletuskansioksi</string>
<!--
Haven't found some strings? There's more at

View File

@ -374,6 +374,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Définir comme dossier par défaut</string>
<string name="unset_as_default_folder">Non défini comme dossier par défaut</string>
<!--
Haven't found some strings? There's more at

View File

@ -375,6 +375,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Establecer como cartafol predeterminado</string>
<string name="unset_as_default_folder">Desfín como cartafol predeterminado</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Postavi kao zadanu mapu</string>
<string name="unset_as_default_folder">Poništi kao zadanu mapu</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@ Ezzel csak a kiválasztott mappák láthatók, mivel a kizárás és a befoglal
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset default folder</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Tetapkan sebagai folder default</string>
<string name="unset_as_default_folder">Batalkan pengaturan sebagai folder default</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Tetapkan sebagai folder default</string>
<string name="unset_as_default_folder">Batalkan pengaturan sebagai folder default</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Batalkan pengaturan sebagai folder default</string>
<string name="unset_as_default_folder">Disimpostato come cartella predefinita</string>
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">デフォルトフォルダとして設定</string>
<string name="unset_as_default_folder">デフォルトフォルダとして設定解除</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">기본 폴더로 설정</string>
<string name="unset_as_default_folder">기본 폴더로 설정 해제</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Angi som standardmappe</string>
<string name="unset_as_default_folder">Ikke angitt som standardmappe</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">पूर्वनिर्धारित फोल्डरको रूपमा सेट गर्नुहोस्</string>
<string name="unset_as_default_folder">पूर्वनिर्धारित फोल्डरको रूपमा अनसेट गर्नुहोस्</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Stel in als standaardmap</string>
<string name="unset_as_default_folder">Niet ingesteld als standaardmap</string>
<!--
Haven't found some strings? There's more at

View File

@ -374,6 +374,8 @@
<b>... i/lub naszego subreddita:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Ustaw jako folder domyślny</string>
<string name="unset_as_default_folder">Nie ustawiono jako domyślnego folderu</string>
<!--
Haven't found some strings? There's more at

View File

@ -375,6 +375,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Definir como pasta padrão</string>
<string name="unset_as_default_folder">Desativar como pasta padrão</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Definir como pasta padrão</string>
<string name="unset_as_default_folder">Desativar como pasta padrão</string>
<!--
Não encontrou todas as cadeias a traduzir? Existem mais algumas em:

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Установить как папку по умолчанию</string>
<string name="unset_as_default_folder">Отключить как папку по умолчанию</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Nastaviť ako predvolený priečinok</string>
<string name="unset_as_default_folder">Zrušiť nastavenie ako predvolený priečinok</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Nastavi kot privzeto mapo</string>
<string name="unset_as_default_folder">Ponastavi kot privzeto mapo</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Постави као подразумевани фолдер</string>
<string name="unset_as_default_folder">Поништи као подразумевани директоријум</string>
<!--
haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Ange som standardmapp</string>
<string name="unset_as_default_folder">Avmarkerad som standardmapp</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Varsayılan klasör olarak ayarla</string>
<string name="unset_as_default_folder">Varsayılan klasör olarak ayarlanmadı</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Встановити як папку за замовчуванням</string>
<string name="unset_as_default_folder">Скасувати як папку за замовчуванням</string>
<!--
Haven't found some strings? There's more at

View File

@ -393,6 +393,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">Đặt làm thư mục mặc định</string>
<string name="unset_as_default_folder">Bỏ đặt làm thư mục mặc định</string>
<!--
Haven't found some strings? There's more at

View File

@ -374,6 +374,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">設置為默認文件夾</string>
<string name="unset_as_default_folder">取消設為默認文件夾</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">設置為默認文件夾</string>
<string name="unset_as_default_folder">取消設為默認文件夾</string>
<!--
Haven't found some strings? There's more at

View File

@ -376,6 +376,8 @@
<b>Reddit:</b>
https://www.reddit.com/r/SimpleMobileTools
</string>
<string name="set_as_default_folder">設置為默認文件夾</string>
<string name="unset_as_default_folder">取消設為默認文件夾</string>
<!--
Haven't found some strings? There's more at

View File

@ -17,6 +17,8 @@
<string name="unknown_location">Unknown location</string>
<string name="increase_column_count">Increase column count</string>
<string name="reduce_column_count">Reduce column count</string>
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="change_cover_image">Change cover image</string>
<string name="select_photo">Select photo</string>
<string name="volume">Volume</string>