diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 20f754d63..23edd0705 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -66,14 +66,14 @@
+ android:parentActivityName="com.simplemobiletools.commons.activities.AboutActivity"/>
$email"
- about_email.text = Html.fromHtml(href)
- about_email.movementMethod = LinkMovementMethod.getInstance()
- }
-
- private fun setupMoreApps() {
- about_more_apps.setOnClickListener {
- startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/dev?id=9070296388022589266")))
- }
- }
-
- private fun setupCopyright() {
- val versionName = BuildConfig.VERSION_NAME
- val year = Calendar.getInstance().get(Calendar.YEAR)
- val copyrightText = String.format(getString(R.string.copyright), versionName, year)
- about_copyright.text = copyrightText
- }
-
- private fun setupRateUs() {
- if (mConfig.isFirstRun) {
- about_rate_us.visibility = View.GONE
- } else {
- about_rate_us.setOnClickListener {
- val uri = Uri.parse("market://details?id=$packageName")
- try {
- startActivity(Intent(Intent.ACTION_VIEW, uri))
- } catch (ignored: ActivityNotFoundException) {
- startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getStoreUrl())))
- }
- }
- }
- }
-
- fun setupInvite() {
- about_invite.setOnClickListener {
- val text = String.format(getString(R.string.share_text), getString(R.string.app_name), getStoreUrl())
- Intent().apply {
- action = Intent.ACTION_SEND
- putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name))
- putExtra(Intent.EXTRA_TEXT, text)
- type = "text/plain"
- startActivity(Intent.createChooser(this, getString(R.string.invite_via)))
- }
- }
- }
-
- fun setupLicense() {
- about_license.setOnClickListener {
- val intent = Intent(applicationContext, LicenseActivity::class.java)
- startActivity(intent)
- }
- }
-
- fun setupDonate() {
- about_donate.setOnClickListener {
- startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("http://simplemobiletools.github.io/donate")))
- }
- }
-
- fun setupFacebook() {
- about_facebook.setOnClickListener {
- var link = "https://www.facebook.com/simplemobiletools"
- try {
- packageManager.getPackageInfo("com.facebook.katana", 0)
- link = "fb://page/150270895341774"
- } catch (ignored: Exception) {
- }
-
- startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(link)))
- }
- }
-
- fun setupGPlus() {
- about_gplus.setOnClickListener {
- val link = "https://plus.google.com/communities/104880861558693868382"
- startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(link)))
- }
- }
-
- private fun getStoreUrl() = "https://play.google.com/store/apps/details?id=$packageName"
-}
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt
index 1f09e6c52..f4d587aaf 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt
@@ -129,7 +129,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
if (isShowingPermDialog(file))
return
- var document = getFileDocument(path, mConfig.treeUri)
+ var document = getFileDocument(path, config.treeUri)
if (!file.exists()) {
document = document.createFile("", file.name)
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt
index 4ca04cf25..c95b4a952 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt
@@ -19,6 +19,9 @@ import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.adapters.DirectoryAdapter
import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask
import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog
+import com.simplemobiletools.gallery.extensions.launchAbout
+import com.simplemobiletools.gallery.extensions.launchCamera
+import com.simplemobiletools.gallery.extensions.launchSettings
import com.simplemobiletools.gallery.helpers.*
import com.simplemobiletools.gallery.models.Directory
import com.simplemobiletools.gallery.views.MyScalableRecyclerView
@@ -110,12 +113,12 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
override fun onDestroy() {
super.onDestroy()
- mConfig.isFirstRun = false
+ config.isFirstRun = false
}
private fun tryloadGallery() {
if (hasStoragePermission()) {
- if (mConfig.showAll)
+ if (config.showAll)
showAllMedia()
else
getDirectories()
@@ -155,7 +158,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
}
private fun showAllMedia() {
- mConfig.showAll = true
+ config.showAll = true
Intent(this, MediaActivity::class.java).apply {
putExtra(DIRECTORY, "/")
startActivity(this)
@@ -215,7 +218,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private fun deleteItem(file: File) {
if (needsStupidWritePermissions(file.absolutePath)) {
if (!isShowingPermDialog(file)) {
- val document = getFileDocument(file.absolutePath, mConfig.treeUri)
+ val document = getFileDocument(file.absolutePath, config.treeUri)
// double check we have the uri to the proper file path, not some parent folder
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory)
@@ -234,18 +237,18 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private fun handleZooming() {
val layoutManager = directories_grid.layoutManager as GridLayoutManager
- layoutManager.spanCount = mConfig.dirColumnCnt
+ layoutManager.spanCount = config.dirColumnCnt
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.ZoomListener {
override fun zoomIn() {
if (layoutManager.spanCount > 1) {
- mConfig.dirColumnCnt = --layoutManager.spanCount
+ config.dirColumnCnt = --layoutManager.spanCount
DirectoryAdapter.actMode?.finish()
}
}
override fun zoomOut() {
if (layoutManager.spanCount < 10) {
- mConfig.dirColumnCnt = ++layoutManager.spanCount
+ config.dirColumnCnt = ++layoutManager.spanCount
DirectoryAdapter.actMode?.finish()
}
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt
index 28671a4be..982a75c75 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt
@@ -19,6 +19,9 @@ import com.simplemobiletools.gallery.adapters.MediaAdapter
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog
import com.simplemobiletools.gallery.extensions.getHumanizedFilename
+import com.simplemobiletools.gallery.extensions.launchAbout
+import com.simplemobiletools.gallery.extensions.launchCamera
+import com.simplemobiletools.gallery.extensions.launchSettings
import com.simplemobiletools.gallery.helpers.*
import com.simplemobiletools.gallery.models.Medium
import com.simplemobiletools.gallery.views.MyScalableRecyclerView
@@ -53,7 +56,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
media_holder.setOnRefreshListener({ getMedia() })
mPath = intent.getStringExtra(DIRECTORY)
mMedia = ArrayList()
- mShowAll = mConfig.showAll
+ mShowAll = config.showAll
if (mShowAll)
supportActionBar?.setDisplayHomeAsUpEnabled(false)
}
@@ -93,14 +96,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_media, menu)
- val isFolderHidden = mConfig.getIsFolderHidden(mPath)
- menu.findItem(R.id.hide_folder).isVisible = !isFolderHidden && !mShowAll
- menu.findItem(R.id.unhide_folder).isVisible = isFolderHidden && !mShowAll
+ val isFolderHidden = config.getIsFolderHidden(mPath)
+ menu.apply {
+ findItem(R.id.hide_folder).isVisible = !isFolderHidden && !mShowAll
+ findItem(R.id.unhide_folder).isVisible = isFolderHidden && !mShowAll
- menu.findItem(R.id.folder_view).isVisible = mShowAll
- menu.findItem(R.id.open_camera).isVisible = mShowAll
- menu.findItem(R.id.settings).isVisible = mShowAll
- menu.findItem(R.id.about).isVisible = mShowAll
+ findItem(R.id.folder_view).isVisible = mShowAll
+ findItem(R.id.open_camera).isVisible = mShowAll
+ findItem(R.id.settings).isVisible = mShowAll
+ findItem(R.id.about).isVisible = mShowAll
+ }
return true
}
@@ -144,9 +149,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
}
private fun toggleFilenameVisibility() {
- mConfig.displayFileNames = !mConfig.displayFileNames
+ config.displayFileNames = !config.displayFileNames
if (media_grid.adapter != null)
- (media_grid.adapter as MediaAdapter).updateDisplayFilenames(mConfig.displayFileNames)
+ (media_grid.adapter as MediaAdapter).updateDisplayFilenames(config.displayFileNames)
}
private fun showSortingDialog() {
@@ -156,22 +161,22 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
}
private fun switchToFolderView() {
- mConfig.showAll = false
+ config.showAll = false
startActivity(Intent(this, MainActivity::class.java))
finish()
}
private fun hideFolder() {
- mConfig.addHiddenFolder(mPath)
+ config.addHiddenFolder(mPath)
- if (!mConfig.showHiddenFolders)
+ if (!config.showHiddenFolders)
finish()
else
invalidateOptionsMenu()
}
private fun unhideFolder() {
- mConfig.removeHiddenFolder(mPath)
+ config.removeHiddenFolder(mPath)
invalidateOptionsMenu()
}
@@ -203,18 +208,18 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
private fun handleZooming() {
val layoutManager = media_grid.layoutManager as GridLayoutManager
- layoutManager.spanCount = mConfig.mediaColumnCnt
+ layoutManager.spanCount = config.mediaColumnCnt
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.ZoomListener {
override fun zoomIn() {
if (layoutManager.spanCount > 1) {
- mConfig.mediaColumnCnt = --layoutManager.spanCount
+ config.mediaColumnCnt = --layoutManager.spanCount
MediaAdapter.actMode?.finish()
}
}
override fun zoomOut() {
if (layoutManager.spanCount < 10) {
- mConfig.mediaColumnCnt = ++layoutManager.spanCount
+ config.mediaColumnCnt = ++layoutManager.spanCount
MediaAdapter.actMode?.finish()
}
}
@@ -228,7 +233,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
if (isShowingPermDialog(it))
return
- val document = getFileDocument(it.absolutePath, mConfig.treeUri)
+ val document = getFileDocument(it.absolutePath, config.treeUri)
// double check we have the uri to the proper file path, not some parent folder
if (document.uri.toString().endsWith(it.absolutePath.getFilenameFromPath()) && !document.isDirectory) {
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt
index b5a23356b..3c1d012d3 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt
@@ -20,42 +20,42 @@ class SettingsActivity : SimpleActivity() {
}
private fun setupDarkTheme() {
- settings_dark_theme.isChecked = mConfig.isDarkTheme
+ settings_dark_theme.isChecked = config.isDarkTheme
settings_dark_theme_holder.setOnClickListener {
settings_dark_theme.toggle()
- mConfig.isDarkTheme = settings_dark_theme.isChecked
+ config.isDarkTheme = settings_dark_theme.isChecked
restartActivity()
}
}
private fun setupSameSorting() {
- settings_same_sorting.isChecked = mConfig.isSameSorting
+ settings_same_sorting.isChecked = config.isSameSorting
settings_same_sorting_holder.setOnClickListener {
settings_same_sorting.toggle()
- mConfig.isSameSorting = settings_same_sorting.isChecked
+ config.isSameSorting = settings_same_sorting.isChecked
}
}
private fun setupShowHiddenFolders() {
- settings_show_hidden_folders.isChecked = mConfig.showHiddenFolders
+ settings_show_hidden_folders.isChecked = config.showHiddenFolders
settings_show_hidden_folders_holder.setOnClickListener {
settings_show_hidden_folders.toggle()
- mConfig.showHiddenFolders = settings_show_hidden_folders.isChecked
+ config.showHiddenFolders = settings_show_hidden_folders.isChecked
}
}
private fun setupAutoplayVideos() {
settings_autoplay_videos_holder.setOnClickListener {
settings_autoplay_videos.toggle()
- mConfig.autoplayVideos = settings_autoplay_videos.isChecked
+ config.autoplayVideos = settings_autoplay_videos.isChecked
}
}
private fun setupShowMedia() {
- settings_show_media.setSelection(mConfig.showMedia)
+ settings_show_media.setSelection(config.showMedia)
settings_show_media.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
- mConfig.showMedia = settings_show_media.selectedItemPosition
+ config.showMedia = settings_show_media.selectedItemPosition
}
override fun onNothingSelected(parent: AdapterView<*>?) {
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt
index c7585dd98..c281a17fe 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt
@@ -1,88 +1,14 @@
package com.simplemobiletools.gallery.activities
-import android.annotation.TargetApi
-import android.app.Activity
-import android.content.Intent
-import android.os.Build
import android.os.Bundle
-import android.provider.MediaStore
-import android.support.v7.app.AppCompatActivity
-import android.view.MenuItem
-import android.view.View
-import com.simplemobiletools.filepicker.extensions.isShowingWritePermissions
-import com.simplemobiletools.gallery.R
+import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.gallery.helpers.Config
-import com.simplemobiletools.gallery.helpers.OPEN_DOCUMENT_TREE
-import java.io.File
-open class SimpleActivity : AppCompatActivity() {
- lateinit var mConfig: Config
+open class SimpleActivity : BaseSimpleActivity() {
+ lateinit var config: Config
override fun onCreate(savedInstanceState: Bundle?) {
- mConfig = Config.newInstance(applicationContext)
- var theme = if (mConfig.isDarkTheme) R.style.AppTheme_Dark else R.style.AppTheme
- if (this is ViewPagerActivity || this is PhotoActivity || this is VideoActivity) {
- theme = if (mConfig.isDarkTheme) R.style.FullScreenTheme_Dark else R.style.FullScreenTheme
- }
- setTheme(theme)
+ config = Config.newInstance(applicationContext)
super.onCreate(savedInstanceState)
}
-
- override fun onOptionsItemSelected(item: MenuItem): Boolean {
- return when (item.itemId) {
- android.R.id.home -> {
- finish()
- true
- }
- else -> super.onOptionsItemSelected(item)
- }
- }
-
- override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
- super.onActivityResult(requestCode, resultCode, resultData)
- if (requestCode == OPEN_DOCUMENT_TREE && resultCode == Activity.RESULT_OK && resultData != null) {
- saveTreeUri(resultData)
- }
- }
-
- @TargetApi(Build.VERSION_CODES.KITKAT)
- fun saveTreeUri(resultData: Intent) {
- val treeUri = resultData.data
- mConfig.treeUri = treeUri.toString()
-
- val takeFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
- contentResolver.takePersistableUriPermission(treeUri, takeFlags)
- }
-
- fun launchCamera() {
- startActivity(Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA))
- }
-
- fun launchSettings() {
- startActivity(Intent(applicationContext, SettingsActivity::class.java))
- }
-
- fun launchAbout() {
- startActivity(Intent(applicationContext, AboutActivity::class.java))
- }
-
- fun isShowingPermDialog(file: File) = isShowingWritePermissions(file, mConfig.treeUri, OPEN_DOCUMENT_TREE)
-
- fun showSystemUI() {
- supportActionBar?.show()
- window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
- View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- }
-
- fun hideSystemUI() {
- supportActionBar?.hide()
- window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
- View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
- View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
- View.SYSTEM_UI_FLAG_LOW_PROFILE or
- View.SYSTEM_UI_FLAG_FULLSCREEN or
- View.SYSTEM_UI_FLAG_IMMERSIVE
- }
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt
index 457d08458..4646915aa 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt
@@ -19,10 +19,7 @@ import com.simplemobiletools.gallery.adapters.MyPagerAdapter
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
import com.simplemobiletools.gallery.dialogs.CopyDialog
import com.simplemobiletools.gallery.dialogs.RenameFileDialog
-import com.simplemobiletools.gallery.extensions.openEditor
-import com.simplemobiletools.gallery.extensions.openWith
-import com.simplemobiletools.gallery.extensions.setAsWallpaper
-import com.simplemobiletools.gallery.extensions.shareMedium
+import com.simplemobiletools.gallery.extensions.*
import com.simplemobiletools.gallery.fragments.ViewPagerFragment
import com.simplemobiletools.gallery.helpers.MEDIUM
import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE
@@ -66,7 +63,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
}
} else {
mPath = intent.getStringExtra(MEDIUM)
- mShowAll = mConfig.showAll
+ mShowAll = config.showAll
}
if (mPath.isEmpty()) {
@@ -204,7 +201,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
if (needsStupidWritePermissions(mPath)) {
if (!isShowingPermDialog(file)) {
- val document = getFileDocument(mPath, mConfig.treeUri)
+ val document = getFileDocument(mPath, config.treeUri)
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory)
document.delete()
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt
index f502bec37..f96a43764 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt
@@ -4,9 +4,11 @@ import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.os.Build
+import android.support.v7.app.AppCompatActivity
import android.util.DisplayMetrics
import android.view.KeyCharacterMap
import android.view.KeyEvent
+import android.view.View
import android.view.ViewConfiguration
import com.simplemobiletools.filepicker.extensions.getMimeType
import com.simplemobiletools.filepicker.extensions.toast
@@ -104,3 +106,21 @@ fun Activity.hasNavBar(): Boolean {
!hasMenuKey && !hasBackKey
}
}
+
+fun AppCompatActivity.showSystemUI() {
+ supportActionBar?.show()
+ window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
+ View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+}
+
+fun AppCompatActivity.hideSystemUI() {
+ supportActionBar?.hide()
+ window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
+ View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
+ View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
+ View.SYSTEM_UI_FLAG_LOW_PROFILE or
+ View.SYSTEM_UI_FLAG_FULLSCREEN or
+ View.SYSTEM_UI_FLAG_IMMERSIVE
+}
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt
index a723dc0ff..aafb8d58c 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt
@@ -1,10 +1,13 @@
package com.simplemobiletools.gallery.extensions
import android.content.Context
+import android.content.Intent
import android.database.Cursor
import android.net.Uri
import android.provider.MediaStore
+import com.simplemobiletools.commons.activities.AboutActivity
import com.simplemobiletools.filepicker.extensions.humanizePath
+import com.simplemobiletools.gallery.activities.SettingsActivity
fun Context.getRealPathFromURI(uri: Uri): String? {
var cursor: Cursor? = null
@@ -25,3 +28,15 @@ fun Context.getHumanizedFilename(path: String): String {
val humanized = humanizePath(path)
return humanized.substring(humanized.lastIndexOf("/") + 1)
}
+
+fun Context.launchCamera() {
+ startActivity(Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA))
+}
+
+fun Context.launchSettings() {
+ startActivity(Intent(this, SettingsActivity::class.java))
+}
+
+fun Context.launchAbout() {
+ startActivity(Intent(this, AboutActivity::class.java))
+}
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt
index 8e30adf37..bb0eecdad 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt
@@ -2,10 +2,11 @@ package com.simplemobiletools.gallery.helpers
import android.content.Context
import android.content.SharedPreferences
+import com.simplemobiletools.commons.helpers.BaseConfig
import com.simplemobiletools.gallery.R
import java.util.*
-class Config private constructor(val context: Context) {
+class Config(val context: Context) : BaseConfig(context) {
private val mPrefs: SharedPreferences
companion object {
@@ -16,14 +17,6 @@ class Config private constructor(val context: Context) {
mPrefs = context.getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE)
}
- var isFirstRun: Boolean
- get() = mPrefs.getBoolean(IS_FIRST_RUN, true)
- set(isFirstRun) = mPrefs.edit().putBoolean(IS_FIRST_RUN, isFirstRun).apply()
-
- var isDarkTheme: Boolean
- get() = mPrefs.getBoolean(IS_DARK_THEME, true)
- set(isDarkTheme) = mPrefs.edit().putBoolean(IS_DARK_THEME, isDarkTheme).apply()
-
var isSameSorting: Boolean
get() = mPrefs.getBoolean(IS_SAME_SORTING, true)
set(isSameSorting) = mPrefs.edit().putBoolean(IS_SAME_SORTING, isSameSorting).apply()
@@ -90,10 +83,6 @@ class Config private constructor(val context: Context) {
get() = mPrefs.getBoolean(AUTOPLAY_VIDEOS, false)
set(autoplay) = mPrefs.edit().putBoolean(AUTOPLAY_VIDEOS, autoplay).apply()
- var treeUri: String
- get() = mPrefs.getString(TREE_URI, "")
- set(uri) = mPrefs.edit().putString(TREE_URI, uri).apply()
-
var displayFileNames: Boolean
get() = mPrefs.getBoolean(DISPLAY_FILE_NAMES, false)
set(display) = mPrefs.edit().putBoolean(DISPLAY_FILE_NAMES, display).apply()
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt
index 8650e7d06..1feeb9607 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt
@@ -2,15 +2,12 @@ package com.simplemobiletools.gallery.helpers
// shared preferences
val PREFS_KEY = "Gallery"
-val IS_FIRST_RUN = "is_first_run"
-val IS_DARK_THEME = "is_dark_theme"
val IS_SAME_SORTING = "is_same_sorting"
val SORT_ORDER = "sort_order"
val DIRECTORY_SORT_ORDER = "directory_sort_order"
val HIDDEN_FOLDERS = "hidden_folders"
val SHOW_HIDDEN_FOLDERS = "show_hidden_folders"
val AUTOPLAY_VIDEOS = "autoplay_videos"
-val TREE_URI = "tree_uri"
val DISPLAY_FILE_NAMES = "display_file_names"
val PINNED_FOLDERS = "pinned_folders"
val DIR_COLUMN_CNT = "dir_column_cnt"
@@ -23,11 +20,8 @@ val SORT_BY_NAME = 1
val SORT_BY_DATE_MODIFIED = 2
val SORT_BY_SIZE = 4
val SORT_BY_DATE_TAKEN = 8
-
val SORT_DESCENDING = 1024
-// global intents
-val OPEN_DOCUMENT_TREE = 1000
val DIRECTORY = "directory"
val MEDIUM = "medium"
diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml
deleted file mode 100644
index c8c3c607b..000000000
--- a/app/src/main/res/layout/activity_about.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-