implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
+ implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'com.google.android.material:material:1.2.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
- def camerax_version = "1.0.0-beta10"
+ def camerax_version = "1.0.0-rc01"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"
- implementation "androidx.camera:camera-view:1.0.0-alpha17"
+
+ implementation "androidx.camera:camera-view:1.0.0-alpha20"
+ implementation "androidx.datastore:datastore-preferences:1.0.0-alpha05"
}
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
-import androidx.preference.PreferenceManager
import jp.osdn.gokigen.mangle.preference.PreferenceValueInitializer
import jp.osdn.gokigen.mangle.scene.MainButtonHandler
import jp.osdn.gokigen.mangle.scene.SceneChanger
class MainActivity : AppCompatActivity()
{
- private val TAG = toString()
private val mainButtonHandler : MainButtonHandler = MainButtonHandler(this)
private val showMessage : ShowMessage = ShowMessage(this)
private val accessPermission : IScopedStorageAccessPermission? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { StorageOperationWithPermission(this) } else { null }
try
{
- PreferenceValueInitializer().initializeStorageLocationPreferences(
- PreferenceManager.getDefaultSharedPreferences(
- this
- )
- )
+ PreferenceValueInitializer().initializeStorageLocationPreferences(this)
}
catch (e: Exception)
{
companion object
{
+ private val TAG = MainActivity::class.java.simpleName
+
private const val REQUEST_CODE_PERMISSIONS = 10
const val REQUEST_CODE_MEDIA_EDIT = 12
const val REQUEST_CODE_OPEN_DOCUMENT_TREE = 20
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentActivity
-import androidx.preference.PreferenceManager
import jp.osdn.gokigen.mangle.operation.imagefile.IImageStoreGrant
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor
+import jp.osdn.gokigen.mangle.preference.PreferenceAccessWrapper
import jp.osdn.gokigen.mangle.preference.PreferenceValueInitializer
import java.io.File
{
try
{
- val mediaLocation = PreferenceManager.getDefaultSharedPreferences(activity).getString(IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION, "")
- if ((mediaLocation != null)&&(mediaLocation.length > 1))
+ val mediaLocation = PreferenceAccessWrapper(activity).getString(IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION, "")
+ if (mediaLocation.length > 1)
{
return
}
{
e.printStackTrace()
}
-
-/*
-
- try
- {
- val path = Environment.DIRECTORY_DCIM + File.separator + activity.getString(R.string.app_location)
- val extStorageUri = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY)
- val values = ContentValues()
- values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg")
- values.put(MediaStore.Images.Media.RELATIVE_PATH, path)
- values.put(MediaStore.Images.Media.DATA, path + File.separator)
- val imageUri = activity.contentResolver.insert(extStorageUri, values)
- if (imageUri != null)
- {
- val urisToModify: List<Uri> = listOf(imageUri)
- val contentResolver: ContentResolver = activity.contentResolver
- val editPendingIntent = MediaStore.createWriteRequest(contentResolver, urisToModify)
- activity.startIntentSenderForResult(editPendingIntent.intentSender, MainActivity.REQUEST_CODE_MEDIA_EDIT, null, 0, 0, 0)
- }
- }
- catch (e : Exception)
- {
- e.printStackTrace()
- }
-*/
}
override fun responseStorageAccessFrameworkLocation(resultCode: Int, data: Intent?)
val takeFlags: Int =
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
contentResolver.takePersistableUriPermission(uri, takeFlags)
- PreferenceValueInitializer().storeStorageLocationPreference(
- PreferenceManager.getDefaultSharedPreferences(
- activity
- ), uri
- )
+ PreferenceValueInitializer().storeStorageLocationPreference(activity, uri)
}
}
else
{
if (resultCode == AppCompatActivity.RESULT_OK)
{
- Log.v(TAG, " WRITE PERMISSION GRANTED ${data}")
+ Log.v(TAG, " WRITE PERMISSION GRANTED $data")
}
else
{
- Log.v(TAG, " WRITE PERMISSION DENIED ${resultCode}")
+ Log.v(TAG, " WRITE PERMISSION DENIED $resultCode")
}
}
import android.graphics.ImageFormat.NV21
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.ImageProxy
-import androidx.preference.PreferenceManager
import jp.osdn.gokigen.mangle.R
import jp.osdn.gokigen.mangle.liveview.ILiveViewRefresher
import jp.osdn.gokigen.mangle.liveview.bitmapconvert.IPreviewImageConverter
import jp.osdn.gokigen.mangle.liveview.bitmapconvert.ImageConvertFactory
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor
+import jp.osdn.gokigen.mangle.preference.PreferenceAccessWrapper
import java.io.ByteArrayOutputStream
import java.util.*
private fun setupLiveviewCache()
{
- val preference = PreferenceManager.getDefaultSharedPreferences(context)
- if ((preference == null)||(!preference.getBoolean(IPreferencePropertyAccessor.CACHE_LIVE_VIEW_PICTURES, false)))
+ val preference = PreferenceAccessWrapper(context)
+ if (!preference.getBoolean(IPreferencePropertyAccessor.CACHE_LIVE_VIEW_PICTURES, false))
{
return
}
val nofCachePics = preference.getString(IPreferencePropertyAccessor.NUMBER_OF_CACHE_PICTURES, IPreferencePropertyAccessor.NUMBER_OF_CACHE_PICTURES_DEFAULT_VALUE)
try
{
- if (nofCachePics != null)
- {
- maxCachePics = nofCachePics.toInt()
- }
- else
- {
- maxCachePics = 500
- }
+ maxCachePics = nofCachePics.toInt()
}
catch (e: Exception)
{
package jp.osdn.gokigen.mangle.liveview.storeimage
-import android.content.ContentResolver
+
import android.content.ContentValues
import android.database.DatabaseUtils
import android.graphics.Bitmap
import android.os.Environment
import android.provider.MediaStore
import android.util.Log
-import androidx.annotation.RequiresApi
import androidx.fragment.app.FragmentActivity
-import androidx.preference.PreferenceManager
-import jp.osdn.gokigen.mangle.MainActivity
import jp.osdn.gokigen.mangle.R
-import jp.osdn.gokigen.mangle.StorageOperationWithPermission
import jp.osdn.gokigen.mangle.liveview.image.IImageProvider
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor
+import jp.osdn.gokigen.mangle.preference.PreferenceAccessWrapper
import java.io.File
import java.io.FileOutputStream
import java.text.SimpleDateFormat
class StoreImage(private val context: FragmentActivity, private val imageProvider: IImageProvider, private val dumpLog : Boolean = false) : IStoreImage
{
- private val TAG = toString()
- private val FILENAME_FORMAT = "yyyyMMdd_HHmmss"
override fun doStore(target: Bitmap?)
{
// 保存処理(プログレスダイアログ(「保存中...」)を表示
val bitmapToStore = target ?: imageProvider.getImage()
- val preference = PreferenceManager.getDefaultSharedPreferences(context)
- val isLocalLocation = preference.getBoolean(
- IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION,
- IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION_DEFAULT_VALUE
- )
+ val isLocalLocation = PreferenceAccessWrapper(context).getBoolean(IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION, IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION_DEFAULT_VALUE)
if (isLocalLocation)
{
saveImageLocal(bitmapToStore)
*/
try
{
- val preference = PreferenceManager.getDefaultSharedPreferences(context)
- val isLocalLocation = preference.getBoolean(
- IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION,
- IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION_DEFAULT_VALUE
- )
+ val isLocalLocation = PreferenceAccessWrapper(context).getBoolean(IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION, IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION_DEFAULT_VALUE)
if (isLocalLocation)
{
saveImageLocal(target)
return (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED)
}
+ companion object
+ {
+ private val TAG = this.toString()
+ private const val FILENAME_FORMAT = "yyyyMMdd_HHmmss"
+ }
+
}
private lateinit var storeImage : StoreImage
private var cameraIsStarted = false
- init
- {
- //val preference = PreferenceManager.getDefaultSharedPreferences(activity)
- }
-
override fun initialize()
{
Log.v(TAG, " initialize()")
import android.view.View
import androidx.camera.core.ImageCapture
import androidx.fragment.app.FragmentActivity
-import androidx.preference.PreferenceManager
import jp.osdn.gokigen.mangle.IScopedStorageAccessPermission
import jp.osdn.gokigen.mangle.R
import jp.osdn.gokigen.mangle.liveview.storeimage.IStoreImage
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor
+import jp.osdn.gokigen.mangle.preference.PreferenceAccessWrapper
class FileControl(private val context: FragmentActivity, private val storeImage : IStoreImage, accessRequest : IScopedStorageAccessPermission?) : View.OnClickListener
{
try
{
// preferenceから設定を取得する
- val preference = PreferenceManager.getDefaultSharedPreferences(context)
+ val preference = PreferenceAccessWrapper(context)
val isLocalLocation = preference.getBoolean(
IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION,
IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION_DEFAULT_VALUE
import androidx.camera.core.ImageCaptureException
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentActivity
-import androidx.preference.PreferenceManager
import com.google.android.material.snackbar.Snackbar
import jp.osdn.gokigen.mangle.IScopedStorageAccessPermission
import jp.osdn.gokigen.mangle.R
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor
+import jp.osdn.gokigen.mangle.preference.PreferenceAccessWrapper
import java.io.File
import java.io.OutputStream
import java.text.SimpleDateFormat
var prefString : String? = ""
try
{
- prefString = PreferenceManager.getDefaultSharedPreferences(context).getString(
- IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION, IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION_DEFAULT_VALUE)
- if (prefString != null)
- {
- uriString = Uri.decode(prefString)
- }
+ prefString = PreferenceAccessWrapper(context).getString(IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION, IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION_DEFAULT_VALUE)
+ uriString = Uri.decode(prefString)
if (uriString.isEmpty())
{
// 設定がない場合はデフォルトの場所に...
--- /dev/null
+package jp.osdn.gokigen.mangle.preference;
+
+import androidx.annotation.NonNull;
+
+public interface IPreferenceAccessWrapper
+{
+ @NonNull String getString(@NonNull String key, @NonNull String defaultValue);
+ boolean getBoolean(@NonNull String key, boolean defaultValue);
+}
--- /dev/null
+package jp.osdn.gokigen.mangle.preference;
+
+import android.content.Context;
+import android.net.Uri;
+
+import androidx.annotation.NonNull;
+
+public interface IPreferenceValueInitializer
+{
+ void initializePreferences(@NonNull Context context);
+
+ // external Storageを使用するための設定
+ void initializeStorageLocationPreferences(@NonNull Context context);
+ void storeStorageLocationPreference(@NonNull Context context, @NonNull Uri uri);
+}
class MainPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener
{
- private val TAG = toString()
private lateinit var preferences : SharedPreferences
private lateinit var changeScene : IChangeScene
- companion object
- {
- fun newInstance() = MainPreferenceFragment().apply { }
- }
-
fun setSceneChanger(changer : IChangeScene)
{
this.changeScene = changer
Log.v(TAG, " onAttach() : ")
preferences = PreferenceManager.getDefaultSharedPreferences(context)
- PreferenceValueInitializer().initializePreferences(preferences)
+ PreferenceValueInitializer().initializePreferences(context)
preferences.registerOnSharedPreferenceChangeListener(this)
}
}
return (ret)
}
+
+ companion object
+ {
+ fun newInstance() = MainPreferenceFragment().apply { }
+ private val TAG = MainPreferenceFragment::class.java.simpleName
+ }
}
--- /dev/null
+package jp.osdn.gokigen.mangle.preference
+
+import android.content.Context
+import androidx.preference.PreferenceManager
+
+class PreferenceAccessWrapper(context : Context) : IPreferenceAccessWrapper
+{
+ private val preferences = PreferenceManager.getDefaultSharedPreferences(context)
+
+ override fun getString(key : String, defaultValue : String) : String
+ {
+ try
+ {
+ val value = preferences.getString(key, defaultValue)
+ if (value != null)
+ {
+ return (value)
+ }
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ return (defaultValue)
+ }
+
+ override fun getBoolean(key : String, defaultValue : Boolean) : Boolean
+ {
+ try
+ {
+ return (preferences.getBoolean(key, defaultValue))
+ }
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+ return (defaultValue)
+ }
+
+}
package jp.osdn.gokigen.mangle.preference
+import android.content.Context
import android.content.SharedPreferences
import android.net.Uri
+import androidx.preference.PreferenceManager
-class PreferenceValueInitializer
+class PreferenceValueInitializer() : IPreferenceValueInitializer
{
- fun initializePreferences(preferences: SharedPreferences)
+ override fun initializePreferences(context : Context)
{
- val items : Map<String, *> = preferences.all
- val editor : SharedPreferences.Editor = preferences.edit()
-
- if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_NOTIFICATIONS))
- {
- editor.putBoolean(
- IPreferencePropertyAccessor.PREFERENCE_NOTIFICATIONS,
- IPreferencePropertyAccessor.PREFERENCE_NOTIFICATIONS_DEFAULT_VALUE
- )
- }
- if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_USE_CAMERA_X_PREVIEW))
- {
- editor.putBoolean(
- IPreferencePropertyAccessor.PREFERENCE_USE_CAMERA_X_PREVIEW,
- IPreferencePropertyAccessor.PREFERENCE_USE_CAMERA_X_PREVIEW_DEFAULT_VALUE
- )
- }
- if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION))
- {
- editor.putBoolean(
- IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION,
- IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION_DEFAULT_VALUE
- )
- }
- if (!items.containsKey(IPreferencePropertyAccessor.SHOW_GRID_STATUS))
- {
- editor.putBoolean(
- IPreferencePropertyAccessor.SHOW_GRID_STATUS,
- IPreferencePropertyAccessor.SHOW_GRID_STATUS_DEFAULT_VALUE
- )
- }
- if (!items.containsKey(IPreferencePropertyAccessor.CACHE_LIVE_VIEW_PICTURES))
- {
- editor.putBoolean(
- IPreferencePropertyAccessor.CACHE_LIVE_VIEW_PICTURES,
- IPreferencePropertyAccessor.CACHE_LIVE_VIEW_PICTURES_DEFAULT_VALUE
- )
- }
- if (!items.containsKey(IPreferencePropertyAccessor.NUMBER_OF_CACHE_PICTURES))
- {
- editor.putString(
- IPreferencePropertyAccessor.NUMBER_OF_CACHE_PICTURES,
- IPreferencePropertyAccessor.NUMBER_OF_CACHE_PICTURES_DEFAULT_VALUE
- )
- }
- if (!items.containsKey(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW))
- {
- editor.putBoolean(
- IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW,
- IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW_DEFAULT_VALUE
- )
- }
- if (!items.containsKey(IPreferencePropertyAccessor.CAPTURE_ONLY_LIVE_VIEW))
+ try
{
- editor.putBoolean(
- IPreferencePropertyAccessor.CAPTURE_ONLY_LIVE_VIEW,
- IPreferencePropertyAccessor.CAPTURE_ONLY_LIVE_VIEW_DEFAULT_VALUE
- )
+ val preferences = PreferenceManager.getDefaultSharedPreferences(context) ?: return
+ val items : Map<String, *> = preferences.all
+ val editor : SharedPreferences.Editor = preferences.edit()
+
+ if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_NOTIFICATIONS))
+ {
+ editor.putBoolean(
+ IPreferencePropertyAccessor.PREFERENCE_NOTIFICATIONS,
+ IPreferencePropertyAccessor.PREFERENCE_NOTIFICATIONS_DEFAULT_VALUE
+ )
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_USE_CAMERA_X_PREVIEW))
+ {
+ editor.putBoolean(
+ IPreferencePropertyAccessor.PREFERENCE_USE_CAMERA_X_PREVIEW,
+ IPreferencePropertyAccessor.PREFERENCE_USE_CAMERA_X_PREVIEW_DEFAULT_VALUE
+ )
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION))
+ {
+ editor.putBoolean(
+ IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION,
+ IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION_DEFAULT_VALUE
+ )
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.SHOW_GRID_STATUS))
+ {
+ editor.putBoolean(
+ IPreferencePropertyAccessor.SHOW_GRID_STATUS,
+ IPreferencePropertyAccessor.SHOW_GRID_STATUS_DEFAULT_VALUE
+ )
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.CACHE_LIVE_VIEW_PICTURES))
+ {
+ editor.putBoolean(
+ IPreferencePropertyAccessor.CACHE_LIVE_VIEW_PICTURES,
+ IPreferencePropertyAccessor.CACHE_LIVE_VIEW_PICTURES_DEFAULT_VALUE
+ )
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.NUMBER_OF_CACHE_PICTURES))
+ {
+ editor.putString(
+ IPreferencePropertyAccessor.NUMBER_OF_CACHE_PICTURES,
+ IPreferencePropertyAccessor.NUMBER_OF_CACHE_PICTURES_DEFAULT_VALUE
+ )
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW))
+ {
+ editor.putBoolean(
+ IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW,
+ IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW_DEFAULT_VALUE
+ )
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.CAPTURE_ONLY_LIVE_VIEW))
+ {
+ editor.putBoolean(
+ IPreferencePropertyAccessor.CAPTURE_ONLY_LIVE_VIEW,
+ IPreferencePropertyAccessor.CAPTURE_ONLY_LIVE_VIEW_DEFAULT_VALUE
+ )
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION))
+ {
+ editor.putString(IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION, IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION_DEFAULT_VALUE)
+ }
+ editor.apply()
}
- if (!items.containsKey(IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION))
+ catch (e : Exception)
{
- editor.putString(IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION, IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION_DEFAULT_VALUE)
+ e.printStackTrace()
}
- editor.apply()
}
- fun initializeStorageLocationPreferences(preferences: SharedPreferences)
+ override fun initializeStorageLocationPreferences(context : Context)
{
- val items : Map<String, *> = preferences.all
- val editor : SharedPreferences.Editor = preferences.edit()
- if (!items.containsKey(IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION))
+ try
{
- editor.putString(IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION, IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION_DEFAULT_VALUE)
+ val preferences = PreferenceManager.getDefaultSharedPreferences(context) ?: return
+ val items : Map<String, *> = preferences.all
+ val editor : SharedPreferences.Editor = preferences.edit()
+ if (!items.containsKey(IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION))
+ {
+ editor.putString(IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION, IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION_DEFAULT_VALUE)
+ }
+ editor.apply()
}
- editor.apply()
+ catch (e : Exception)
+ {
+ e.printStackTrace()
+ }
+
}
- fun storeStorageLocationPreference(preferences: SharedPreferences, uri : Uri)
+ override fun storeStorageLocationPreference(context : Context, uri : Uri)
{
try
{
+ val preferences = PreferenceManager.getDefaultSharedPreferences(context) ?: return
val editor : SharedPreferences.Editor = preferences.edit()
editor.putString(IPreferencePropertyAccessor.EXTERNAL_STORAGE_LOCATION, uri.toString())
editor.apply()
e.printStackTrace()
}
}
-
}
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentTransaction
-import androidx.preference.PreferenceManager
import jp.osdn.gokigen.mangle.IScopedStorageAccessPermission
import jp.osdn.gokigen.mangle.R
import jp.osdn.gokigen.mangle.liveview.LiveImageViewFragment
import jp.osdn.gokigen.mangle.operation.CameraControl
import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor
import jp.osdn.gokigen.mangle.preference.MainPreferenceFragment
+import jp.osdn.gokigen.mangle.preference.PreferenceAccessWrapper
import jp.osdn.gokigen.mangle.preview.PreviewFragment
import jp.osdn.gokigen.mangle.utils.ConfirmationDialog
import jp.osdn.gokigen.mangle.utils.ConfirmationDialog.Callback
{
try
{
- val isCameraXPreview = PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(
- IPreferencePropertyAccessor.PREFERENCE_USE_CAMERA_X_PREVIEW,
- IPreferencePropertyAccessor.PREFERENCE_USE_CAMERA_X_PREVIEW_DEFAULT_VALUE
- )
+ val isCameraXPreview = PreferenceAccessWrapper(activity).getBoolean(IPreferencePropertyAccessor.PREFERENCE_USE_CAMERA_X_PREVIEW, IPreferencePropertyAccessor.PREFERENCE_USE_CAMERA_X_PREVIEW_DEFAULT_VALUE)
if (isCameraXPreview)
{
initializeFragmentForPreview()
--- /dev/null
+package jp.osdn.gokigen.mangle.utils.preferences
+
+import androidx.preference.PreferenceDataStore
+
+class MyPreferenceDataStore: PreferenceDataStore()
+{
+ override fun putString(key: String, value: String?)
+ {
+ // Save the value somewhere
+ }
+
+ override fun getString(key: String, defValue: String?): String
+ {
+ // Retrieve the value
+
+ return ("")
+ }
+
+}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = "1.4.10"
+ ext.kotlin_version = "1.4.21"
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.1.0'
+ classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong