diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 6d9362de0..316041b11 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -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) + } + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index 532af9486..93e394b3d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -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() + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt index 9d70eb98c..b294ef35e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index 34497c889..568971649 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -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" diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index f8b02c0de..b67c649d6 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -58,6 +58,10 @@ android:id="@+id/reduce_column_count" android:title="@string/reduce_column_count" app:showAsAction="never"/> + + + موقع غير معروف زيادة عدد الأعمدة تقليل عدد الأعمدة + تعيين كمجلد افتراضي تغيير صورة الغلاف تحديد صورة الصوت @@ -375,6 +376,7 @@ موقع رديت: https://www.reddit.com/r/SimpleMobileTools + غير محدد كمجلد افتراضي