convert Constants to kotlin
This commit is contained in:
parent
f2e1d559ae
commit
bdfc472f84
5 changed files with 28 additions and 29 deletions
|
@ -1,15 +0,0 @@
|
|||
package com.simplemobiletools.filemanager;
|
||||
|
||||
public class Constants {
|
||||
public static final String PATH = "path";
|
||||
|
||||
// shared preferences
|
||||
public static final String PREFS_KEY = "File Manager";
|
||||
public static final String IS_FIRST_RUN = "is_first_run";
|
||||
public static final String IS_DARK_THEME = "is_dark_theme";
|
||||
public static final String SHOW_HIDDEN = "show_hidden";
|
||||
public static final String TREE_URI = "tree_uri";
|
||||
|
||||
// global intents
|
||||
public static final int OPEN_DOCUMENT_TREE = 1000;
|
||||
}
|
|
@ -107,7 +107,7 @@ public class ItemsFragment extends android.support.v4.app.Fragment
|
|||
}
|
||||
|
||||
private void fillItems() {
|
||||
mPath = getArguments().getString(Constants.PATH);
|
||||
mPath = getArguments().getString(Constants.INSTANCE.getPATH());
|
||||
final List<FileDirItem> newItems = getItems(mPath);
|
||||
Collections.sort(newItems);
|
||||
if (mItems != null && newItems.toString().equals(mItems.toString())) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue