mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
convert Constants to kotlin
This commit is contained in:
@ -13,22 +13,22 @@ class Config(context: Context) {
|
||||
}
|
||||
|
||||
init {
|
||||
mPrefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE)
|
||||
mPrefs = context.getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
var isFirstRun: Boolean
|
||||
get() = mPrefs.getBoolean(Constants.IS_FIRST_RUN, true)
|
||||
set(firstRun) = mPrefs.edit().putBoolean(Constants.IS_FIRST_RUN, firstRun).apply()
|
||||
get() = mPrefs.getBoolean(IS_FIRST_RUN, true)
|
||||
set(firstRun) = mPrefs.edit().putBoolean(IS_FIRST_RUN, firstRun).apply()
|
||||
|
||||
var isDarkTheme: Boolean
|
||||
get() = mPrefs.getBoolean(Constants.IS_DARK_THEME, false)
|
||||
set(isDarkTheme) = mPrefs.edit().putBoolean(Constants.IS_DARK_THEME, isDarkTheme).apply()
|
||||
get() = mPrefs.getBoolean(IS_DARK_THEME, false)
|
||||
set(isDarkTheme) = mPrefs.edit().putBoolean(IS_DARK_THEME, isDarkTheme).apply()
|
||||
|
||||
var showHidden: Boolean
|
||||
get() = mPrefs.getBoolean(Constants.SHOW_HIDDEN, false)
|
||||
set(show) = mPrefs.edit().putBoolean(Constants.SHOW_HIDDEN, show).apply()
|
||||
get() = mPrefs.getBoolean(SHOW_HIDDEN, false)
|
||||
set(show) = mPrefs.edit().putBoolean(SHOW_HIDDEN, show).apply()
|
||||
|
||||
var treeUri: String
|
||||
get() = mPrefs.getString(Constants.TREE_URI, "")
|
||||
set(uri) = mPrefs.edit().putString(Constants.TREE_URI, uri).apply()
|
||||
get() = mPrefs.getString(TREE_URI, "")
|
||||
set(uri) = mPrefs.edit().putString(TREE_URI, uri).apply()
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.simplemobiletools.filemanager
|
||||
|
||||
// shared preferences
|
||||
val PREFS_KEY = "File Manager"
|
||||
val IS_FIRST_RUN = "is_first_run"
|
||||
val IS_DARK_THEME = "is_dark_theme"
|
||||
val SHOW_HIDDEN = "show_hidden"
|
||||
val TREE_URI = "tree_uri"
|
||||
|
||||
// global intents
|
||||
val OPEN_DOCUMENT_TREE = 1000
|
||||
|
||||
object Constants {
|
||||
val PATH = "path"
|
||||
}
|
@ -7,9 +7,8 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.view.MenuItem
|
||||
|
||||
import com.simplemobiletools.filemanager.Config
|
||||
import com.simplemobiletools.filemanager.Constants
|
||||
import com.simplemobiletools.filemanager.OPEN_DOCUMENT_TREE
|
||||
import com.simplemobiletools.filemanager.R
|
||||
import com.simplemobiletools.filepicker.extensions.isShowingWritePermissions
|
||||
import java.io.File
|
||||
@ -35,7 +34,7 @@ open class SimpleActivity : AppCompatActivity() {
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, resultData)
|
||||
if (requestCode == Constants.OPEN_DOCUMENT_TREE && resultCode == Activity.RESULT_OK && resultData != null) {
|
||||
if (requestCode == OPEN_DOCUMENT_TREE && resultCode == Activity.RESULT_OK && resultData != null) {
|
||||
saveTreeUri(resultData)
|
||||
}
|
||||
}
|
||||
@ -49,5 +48,5 @@ open class SimpleActivity : AppCompatActivity() {
|
||||
contentResolver.takePersistableUriPermission(treeUri, takeFlags)
|
||||
}
|
||||
|
||||
fun isShowingPermDialog(file: File) = isShowingWritePermissions(file, mConfig.treeUri, Constants.OPEN_DOCUMENT_TREE)
|
||||
fun isShowingPermDialog(file: File) = isShowingWritePermissions(file, mConfig.treeUri, OPEN_DOCUMENT_TREE)
|
||||
}
|
||||
|
Reference in New Issue
Block a user