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:
		| @@ -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() { |     private void fillItems() { | ||||||
|         mPath = getArguments().getString(Constants.PATH); |         mPath = getArguments().getString(Constants.INSTANCE.getPATH()); | ||||||
|         final List<FileDirItem> newItems = getItems(mPath); |         final List<FileDirItem> newItems = getItems(mPath); | ||||||
|         Collections.sort(newItems); |         Collections.sort(newItems); | ||||||
|         if (mItems != null && newItems.toString().equals(mItems.toString())) { |         if (mItems != null && newItems.toString().equals(mItems.toString())) { | ||||||
|   | |||||||
| @@ -13,22 +13,22 @@ class Config(context: Context) { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     init { |     init { | ||||||
|         mPrefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE) |         mPrefs = context.getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     var isFirstRun: Boolean |     var isFirstRun: Boolean | ||||||
|         get() = mPrefs.getBoolean(Constants.IS_FIRST_RUN, true) |         get() = mPrefs.getBoolean(IS_FIRST_RUN, true) | ||||||
|         set(firstRun) = mPrefs.edit().putBoolean(Constants.IS_FIRST_RUN, firstRun).apply() |         set(firstRun) = mPrefs.edit().putBoolean(IS_FIRST_RUN, firstRun).apply() | ||||||
|  |  | ||||||
|     var isDarkTheme: Boolean |     var isDarkTheme: Boolean | ||||||
|         get() = mPrefs.getBoolean(Constants.IS_DARK_THEME, false) |         get() = mPrefs.getBoolean(IS_DARK_THEME, false) | ||||||
|         set(isDarkTheme) = mPrefs.edit().putBoolean(Constants.IS_DARK_THEME, isDarkTheme).apply() |         set(isDarkTheme) = mPrefs.edit().putBoolean(IS_DARK_THEME, isDarkTheme).apply() | ||||||
|  |  | ||||||
|     var showHidden: Boolean |     var showHidden: Boolean | ||||||
|         get() = mPrefs.getBoolean(Constants.SHOW_HIDDEN, false) |         get() = mPrefs.getBoolean(SHOW_HIDDEN, false) | ||||||
|         set(show) = mPrefs.edit().putBoolean(Constants.SHOW_HIDDEN, show).apply() |         set(show) = mPrefs.edit().putBoolean(SHOW_HIDDEN, show).apply() | ||||||
|  |  | ||||||
|     var treeUri: String |     var treeUri: String | ||||||
|         get() = mPrefs.getString(Constants.TREE_URI, "") |         get() = mPrefs.getString(TREE_URI, "") | ||||||
|         set(uri) = mPrefs.edit().putString(Constants.TREE_URI, uri).apply() |         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.os.Bundle | ||||||
| import android.support.v7.app.AppCompatActivity | import android.support.v7.app.AppCompatActivity | ||||||
| import android.view.MenuItem | import android.view.MenuItem | ||||||
|  |  | ||||||
| import com.simplemobiletools.filemanager.Config | 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.filemanager.R | ||||||
| import com.simplemobiletools.filepicker.extensions.isShowingWritePermissions | import com.simplemobiletools.filepicker.extensions.isShowingWritePermissions | ||||||
| import java.io.File | import java.io.File | ||||||
| @@ -35,7 +34,7 @@ open class SimpleActivity : AppCompatActivity() { | |||||||
|  |  | ||||||
|     override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { |     override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { | ||||||
|         super.onActivityResult(requestCode, resultCode, resultData) |         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) |             saveTreeUri(resultData) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -49,5 +48,5 @@ open class SimpleActivity : AppCompatActivity() { | |||||||
|         contentResolver.takePersistableUriPermission(treeUri, takeFlags) |         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