add the dialogs for changing the view type

This commit is contained in:
tibbi 2017-09-28 21:04:24 +02:00
parent 33a4b81279
commit fc3565129d
24 changed files with 138 additions and 0 deletions

View file

@ -18,9 +18,11 @@ import android.widget.FrameLayout
import com.google.gson.Gson import com.google.gson.Gson
import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog
import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.models.Release import com.simplemobiletools.commons.models.Release
import com.simplemobiletools.commons.views.MyScalableRecyclerView import com.simplemobiletools.commons.views.MyScalableRecyclerView
import com.simplemobiletools.gallery.BuildConfig import com.simplemobiletools.gallery.BuildConfig
@ -107,6 +109,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
R.id.filter -> showFilterMediaDialog() R.id.filter -> showFilterMediaDialog()
R.id.open_camera -> launchCamera() R.id.open_camera -> launchCamera()
R.id.show_all -> showAllMedia() R.id.show_all -> showAllMedia()
R.id.change_view_type -> changeViewType()
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden() R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden() R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
R.id.create_new_folder -> createNewFolder() R.id.create_new_folder -> createNewFolder()
@ -245,6 +248,16 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
finish() finish()
} }
private fun changeViewType() {
val items = arrayListOf(
RadioItem(VIEW_TYPE_GRID, getString(R.string.grid)),
RadioItem(VIEW_TYPE_LIST, getString(R.string.list)))
RadioGroupDialog(this, items, config.viewTypeFolders) {
config.viewTypeFolders = it as Int
}
}
private fun tryToggleTemporarilyShowHidden() { private fun tryToggleTemporarilyShowHidden() {
if (config.temporarilyShowHidden) { if (config.temporarilyShowHidden) {
toggleTemporarilyShowHidden(false) toggleTemporarilyShowHidden(false)

View file

@ -20,7 +20,9 @@ import com.bumptech.glide.request.transition.Transition
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.views.MyScalableRecyclerView import com.simplemobiletools.commons.views.MyScalableRecyclerView
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.adapters.MediaAdapter import com.simplemobiletools.gallery.adapters.MediaAdapter
@ -223,6 +225,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
R.id.toggle_filename -> toggleFilenameVisibility() R.id.toggle_filename -> toggleFilenameVisibility()
R.id.open_camera -> launchCamera() R.id.open_camera -> launchCamera()
R.id.folder_view -> switchToFolderView() R.id.folder_view -> switchToFolderView()
R.id.change_view_type -> changeViewType()
R.id.hide_folder -> tryHideFolder() R.id.hide_folder -> tryHideFolder()
R.id.unhide_folder -> unhideFolder() R.id.unhide_folder -> unhideFolder()
R.id.exclude_folder -> tryExcludeFolder() R.id.exclude_folder -> tryExcludeFolder()
@ -262,6 +265,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
finish() finish()
} }
private fun changeViewType() {
val items = arrayListOf(
RadioItem(VIEW_TYPE_GRID, getString(R.string.grid)),
RadioItem(VIEW_TYPE_LIST, getString(R.string.list)))
RadioGroupDialog(this, items, config.viewTypeFiles) {
config.viewTypeFiles = it as Int
}
}
private fun tryHideFolder() { private fun tryHideFolder() {
if (config.wasHideFolderTooltipShown) { if (config.wasHideFolderTooltipShown) {
hideFolder() hideFolder()

View file

@ -280,4 +280,12 @@ class Config(context: Context) : BaseConfig(context) {
var tempFolderPath: String var tempFolderPath: String
get() = prefs.getString(TEMP_FOLDER_PATH, "") get() = prefs.getString(TEMP_FOLDER_PATH, "")
set(tempFolderPath) = prefs.edit().putString(TEMP_FOLDER_PATH, tempFolderPath).apply() set(tempFolderPath) = prefs.edit().putString(TEMP_FOLDER_PATH, tempFolderPath).apply()
var viewTypeFolders: Int
get() = prefs.getInt(VIEW_TYPE_FOLDERS, VIEW_TYPE_GRID)
set(viewTypeFolders) = prefs.edit().putInt(VIEW_TYPE_FOLDERS, viewTypeFolders).apply()
var viewTypeFiles: Int
get() = prefs.getInt(VIEW_TYPE_FILES, VIEW_TYPE_GRID)
set(viewTypeFiles) = prefs.edit().putInt(VIEW_TYPE_FILES, viewTypeFiles).apply()
} }

View file

@ -37,6 +37,8 @@ val REPLACE_SHARE_WITH_ROTATE = "replace_share_with_rotate"
val DELETE_EMPTY_FOLDERS = "delete_empty_folders" val DELETE_EMPTY_FOLDERS = "delete_empty_folders"
val ALLOW_VIDEO_GESTURES = "allow_video_gestures" val ALLOW_VIDEO_GESTURES = "allow_video_gestures"
val TEMP_FOLDER_PATH = "temp_folder_path" val TEMP_FOLDER_PATH = "temp_folder_path"
val VIEW_TYPE_FOLDERS = "view_type_folders"
val VIEW_TYPE_FILES = "view_type_files"
// slideshow // slideshow
val SLIDESHOW_INTERVAL = "slideshow_interval" val SLIDESHOW_INTERVAL = "slideshow_interval"
@ -77,3 +79,7 @@ val ORIENT_LANDSCAPE_RIGHT = 2
val IMAGES = 1 val IMAGES = 1
val VIDEOS = 2 val VIDEOS = 2
val GIFS = 4 val GIFS = 4
// view types
val VIEW_TYPE_GRID = 1
val VIEW_TYPE_LIST = 2

View file

@ -16,6 +16,10 @@
android:icon="@drawable/ic_filter" android:icon="@drawable/ic_filter"
android:title="@string/filter_media" android:title="@string/filter_media"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
<item
android:id="@+id/change_view_type"
android:title="@string/change_view_type"
app:showAsAction="never"/>
<item <item
android:id="@+id/show_all" android:id="@+id/show_all"
android:title="@string/show_all" android:title="@string/show_all"

View file

@ -25,6 +25,10 @@
android:icon="@drawable/ic_camera" android:icon="@drawable/ic_camera"
android:title="@string/open_camera" android:title="@string/open_camera"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
<item
android:id="@+id/change_view_type"
android:title="@string/change_view_type"
app:showAsAction="never"/>
<item <item
android:id="@+id/hide_folder" android:id="@+id/hide_folder"
android:title="@string/hide_folder" android:title="@string/hide_folder"

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">The slideshow ended</string> <string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string> <string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Show hidden media</string> <string name="show_hidden_media">Show hidden media</string>
<string name="autoplay_videos">Play videos automatically</string> <string name="autoplay_videos">Play videos automatically</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">The slideshow ended</string> <string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string> <string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Zobrazit skryté média</string> <string name="show_hidden_media">Zobrazit skryté média</string>
<string name="autoplay_videos">Automaticky přehrávat videa</string> <string name="autoplay_videos">Automaticky přehrávat videa</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">Diashow beendet</string> <string name="slideshow_ended">Diashow beendet</string>
<string name="no_media_for_slideshow">Keine Medien für Diashow gefunden</string> <string name="no_media_for_slideshow">Keine Medien für Diashow gefunden</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Versteckte Ordner zeigen</string> <string name="show_hidden_media">Versteckte Ordner zeigen</string>
<string name="autoplay_videos">Videos automatisch abspielen</string> <string name="autoplay_videos">Videos automatisch abspielen</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">The slideshow ended</string> <string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string> <string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Mostrar carpetas ocultas</string> <string name="show_hidden_media">Mostrar carpetas ocultas</string>
<string name="autoplay_videos">Reproducir vídeos automáticamente</string> <string name="autoplay_videos">Reproducir vídeos automáticamente</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">Diaporama terminé</string> <string name="slideshow_ended">Diaporama terminé</string>
<string name="no_media_for_slideshow">Aucun média trouvé pour le diaporama</string> <string name="no_media_for_slideshow">Aucun média trouvé pour le diaporama</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Afficher les dossiers cachés</string> <string name="show_hidden_media">Afficher les dossiers cachés</string>
<string name="autoplay_videos">Lecture automatique des vidéos</string> <string name="autoplay_videos">Lecture automatique des vidéos</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">The slideshow ended</string> <string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string> <string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Show hidden media</string> <string name="show_hidden_media">Show hidden media</string>
<string name="autoplay_videos">Play videos automatically</string> <string name="autoplay_videos">Play videos automatically</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">La presentazione è terminata</string> <string name="slideshow_ended">La presentazione è terminata</string>
<string name="no_media_for_slideshow">Nessun media trovato per la presentazione</string> <string name="no_media_for_slideshow">Nessun media trovato per la presentazione</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Mostra cartelle nascoste</string> <string name="show_hidden_media">Mostra cartelle nascoste</string>
<string name="autoplay_videos">Riproduci video automaticamente</string> <string name="autoplay_videos">Riproduci video automaticamente</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">スライドショーが終了しました</string> <string name="slideshow_ended">スライドショーが終了しました</string>
<string name="no_media_for_slideshow">スライドショーに表示するメディアがありません</string> <string name="no_media_for_slideshow">スライドショーに表示するメディアがありません</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">非表示フォルダーを表示</string> <string name="show_hidden_media">非表示フォルダーを表示</string>
<string name="autoplay_videos">ビデオを自動再生する</string> <string name="autoplay_videos">ビデオを自動再生する</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">Pokaz slajdów zakończony</string> <string name="slideshow_ended">Pokaz slajdów zakończony</string>
<string name="no_media_for_slideshow">Nie znalazłem multimediów do pokazu slajdów</string> <string name="no_media_for_slideshow">Nie znalazłem multimediów do pokazu slajdów</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Pokazuj ukryte foldery</string> <string name="show_hidden_media">Pokazuj ukryte foldery</string>
<string name="autoplay_videos">Odtwarzaj filmy automatycznie</string> <string name="autoplay_videos">Odtwarzaj filmy automatycznie</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">The slideshow ended</string> <string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string> <string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Mostrar pastas ocultas</string> <string name="show_hidden_media">Mostrar pastas ocultas</string>
<string name="autoplay_videos">Reproduzir vídeos automaticamente</string> <string name="autoplay_videos">Reproduzir vídeos automaticamente</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">Apresentação terminada</string> <string name="slideshow_ended">Apresentação terminada</string>
<string name="no_media_for_slideshow">Não foram encontrados ficheiros para a apresentação</string> <string name="no_media_for_slideshow">Não foram encontrados ficheiros para a apresentação</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Mostrar pastas ocultas</string> <string name="show_hidden_media">Mostrar pastas ocultas</string>
<string name="autoplay_videos">Reproduzir vídeos automaticamente</string> <string name="autoplay_videos">Reproduzir vídeos automaticamente</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">Слайдшоу завершилось</string> <string name="slideshow_ended">Слайдшоу завершилось</string>
<string name="no_media_for_slideshow">Никаких медиафайлов для слайдшоу не было найдено.</string> <string name="no_media_for_slideshow">Никаких медиафайлов для слайдшоу не было найдено.</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Показать скрытые папки</string> <string name="show_hidden_media">Показать скрытые папки</string>
<string name="autoplay_videos">Воспроизводить видео автоматически</string> <string name="autoplay_videos">Воспроизводить видео автоматически</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">Prezentácia skončila</string> <string name="slideshow_ended">Prezentácia skončila</string>
<string name="no_media_for_slideshow">Pre prezentáciu sa nenašli žiadne vhodné súbory</string> <string name="no_media_for_slideshow">Pre prezentáciu sa nenašli žiadne vhodné súbory</string>
<!-- View types -->
<string name="change_view_type">Zmeniť typ zobrazenia</string>
<string name="grid">Mriežka</string>
<string name="list">Zoznam</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Zobraziť skryté médiá</string> <string name="show_hidden_media">Zobraziť skryté médiá</string>
<string name="autoplay_videos">Spúšťať videá automaticky</string> <string name="autoplay_videos">Spúšťať videá automaticky</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">Bildspelet har avslutats</string> <string name="slideshow_ended">Bildspelet har avslutats</string>
<string name="no_media_for_slideshow">Ingen media hittades för bildspelet</string> <string name="no_media_for_slideshow">Ingen media hittades för bildspelet</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Visa dolda mappar</string> <string name="show_hidden_media">Visa dolda mappar</string>
<string name="autoplay_videos">Spela upp videos automatiskt</string> <string name="autoplay_videos">Spela upp videos automatiskt</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">The slideshow ended</string> <string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string> <string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Gizli klasörleri göster</string> <string name="show_hidden_media">Gizli klasörleri göster</string>
<string name="autoplay_videos">Videoları otomatik olarak oynat</string> <string name="autoplay_videos">Videoları otomatik olarak oynat</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">幻灯片结束</string> <string name="slideshow_ended">幻灯片结束</string>
<string name="no_media_for_slideshow">未发现可用媒体</string> <string name="no_media_for_slideshow">未发现可用媒体</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">显示所有</string> <string name="show_hidden_media">显示所有</string>
<string name="autoplay_videos">自动播放</string> <string name="autoplay_videos">自动播放</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">投影片結束</string> <string name="slideshow_ended">投影片結束</string>
<string name="no_media_for_slideshow">找不到投影片的媒體檔案</string> <string name="no_media_for_slideshow">找不到投影片的媒體檔案</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">顯示隱藏的媒體檔案</string> <string name="show_hidden_media">顯示隱藏的媒體檔案</string>
<string name="autoplay_videos">自動播放影片</string> <string name="autoplay_videos">自動播放影片</string>

View file

@ -102,6 +102,11 @@
<string name="slideshow_ended">The slideshow ended</string> <string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string> <string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- View types -->
<string name="change_view_type">Change view type</string>
<string name="grid">Grid</string>
<string name="list">List</string>
<!-- Settings --> <!-- Settings -->
<string name="show_hidden_media">Show hidden media</string> <string name="show_hidden_media">Show hidden media</string>
<string name="autoplay_videos">Play videos automatically</string> <string name="autoplay_videos">Play videos automatically</string>