A01e : multi-wifi camera control
Revisão | 2a23639304b6498c3f76613525b70ddab6c060b9 (tree) |
---|---|
Hora | 2020-09-06 12:56:48 |
Autor | MRSa <mrsa@myad...> |
Commiter | MRSa |
いったんここで。共通フォルダに保存できるようにしたが、ファイル名等の調整が必要。
@@ -3,12 +3,12 @@ apply plugin: 'kotlin-android' | ||
3 | 3 | apply plugin: 'kotlin-android-extensions' |
4 | 4 | |
5 | 5 | android { |
6 | - compileSdkVersion 29 | |
6 | + compileSdkVersion 30 | |
7 | 7 | |
8 | 8 | defaultConfig { |
9 | 9 | applicationId "jp.osdn.gokigen.mangle" |
10 | 10 | minSdkVersion 21 |
11 | - targetSdkVersion 29 | |
11 | + targetSdkVersion 30 | |
12 | 12 | versionCode 1000000 |
13 | 13 | versionName "1.0.0" |
14 | 14 |
@@ -35,7 +35,7 @@ dependencies { | ||
35 | 35 | implementation 'androidx.appcompat:appcompat:1.2.0' |
36 | 36 | implementation 'androidx.constraintlayout:constraintlayout:2.0.1' |
37 | 37 | implementation 'androidx.preference:preference:1.1.1' |
38 | - implementation 'com.google.android.material:material:1.2.0' | |
38 | + implementation 'com.google.android.material:material:1.2.1' | |
39 | 39 | |
40 | 40 | testImplementation 'junit:junit:4.12' |
41 | 41 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' |
@@ -5,6 +5,7 @@ | ||
5 | 5 | <uses-feature android:name="android.hardware.camera.any" /> |
6 | 6 | <uses-permission android:name="android.permission.CAMERA" /> |
7 | 7 | <uses-permission android:name="android.permission.VIBRATE" /> |
8 | + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | |
8 | 9 | |
9 | 10 | <application |
10 | 11 | android:allowBackup="true" |
@@ -1,7 +1,9 @@ | ||
1 | 1 | package jp.osdn.gokigen.mangle |
2 | 2 | |
3 | 3 | import android.Manifest |
4 | +import android.content.Intent | |
4 | 5 | import android.content.pm.PackageManager |
6 | +import android.os.Build | |
5 | 7 | import android.os.Bundle |
6 | 8 | import android.util.Log |
7 | 9 | import android.view.WindowManager |
@@ -10,18 +12,15 @@ import androidx.appcompat.app.AppCompatActivity | ||
10 | 12 | import androidx.core.app.ActivityCompat |
11 | 13 | import androidx.core.content.ContextCompat |
12 | 14 | import jp.osdn.gokigen.mangle.scene.MainButtonHandler |
13 | -import jp.osdn.gokigen.mangle.scene.ShowMessage | |
14 | 15 | import jp.osdn.gokigen.mangle.scene.SceneChanger |
16 | +import jp.osdn.gokigen.mangle.scene.ShowMessage | |
15 | 17 | |
16 | 18 | class MainActivity : AppCompatActivity() |
17 | 19 | { |
18 | 20 | private val TAG = toString() |
19 | 21 | private val mainButtonHandler : MainButtonHandler = MainButtonHandler(this) |
20 | 22 | private val showMessage : ShowMessage = ShowMessage(this) |
21 | - | |
22 | - //private var cameraControl: CameraControl? = null | |
23 | 23 | private val sceneChanger : SceneChanger = SceneChanger(this, showMessage) |
24 | - //private var sceneChanger : SceneChanger? = null // = SceneChanger(this, this) | |
25 | 24 | |
26 | 25 | override fun onCreate(savedInstanceState: Bundle?) |
27 | 26 | { |
@@ -34,11 +33,9 @@ class MainActivity : AppCompatActivity() | ||
34 | 33 | supportActionBar?.hide() |
35 | 34 | window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) |
36 | 35 | |
37 | - //sceneChanger = SceneChanger(this, this) | |
38 | - //cameraControl = CameraControl(this) | |
39 | 36 | if (allPermissionsGranted()) |
40 | 37 | { |
41 | - //cameraControl?.startCamera() | |
38 | + checkMediaWritePermission() | |
42 | 39 | sceneChanger.initializeFragment() |
43 | 40 | mainButtonHandler.initialize() |
44 | 41 | } |
@@ -46,29 +43,33 @@ class MainActivity : AppCompatActivity() | ||
46 | 43 | { |
47 | 44 | ActivityCompat.requestPermissions(this, REQUIRED_PERMISSIONS, REQUEST_CODE_PERMISSIONS) |
48 | 45 | } |
49 | - //cameraControl?.initialize() | |
50 | 46 | } |
51 | 47 | |
52 | 48 | override fun onDestroy() |
53 | 49 | { |
54 | 50 | super.onDestroy() |
55 | 51 | sceneChanger.finish() |
56 | - //cameraControl?.finish() | |
57 | - | |
58 | - //sceneChanger = null | |
59 | 52 | } |
60 | 53 | |
61 | 54 | private fun allPermissionsGranted() = REQUIRED_PERMISSIONS.all { |
62 | 55 | ContextCompat.checkSelfPermission(baseContext, it) == PackageManager.PERMISSION_GRANTED |
63 | 56 | } |
64 | 57 | |
58 | + private fun checkMediaWritePermission() | |
59 | + { | |
60 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) | |
61 | + { | |
62 | + StorageOperationWithPermission(this).requestAndroidRMediaPermission() | |
63 | + } | |
64 | + } | |
65 | + | |
65 | 66 | override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) |
66 | 67 | { |
67 | 68 | if (requestCode == REQUEST_CODE_PERMISSIONS) |
68 | 69 | { |
69 | 70 | if (allPermissionsGranted()) |
70 | 71 | { |
71 | - //cameraControl?.startCamera() | |
72 | + checkMediaWritePermission() | |
72 | 73 | sceneChanger.initializeFragment() |
73 | 74 | mainButtonHandler.initialize() |
74 | 75 | } |
@@ -81,9 +82,22 @@ class MainActivity : AppCompatActivity() | ||
81 | 82 | } |
82 | 83 | } |
83 | 84 | |
85 | + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) | |
86 | + { | |
87 | + super.onActivityResult(requestCode, resultCode, data) | |
88 | + if ((requestCode == REQUEST_CODE_MEDIA_EDIT)&&(resultCode == RESULT_OK)) | |
89 | + { | |
90 | + // | |
91 | + Log.v(TAG, " WRITE PERMISSION GRANTED") | |
92 | + } | |
93 | + } | |
94 | + | |
84 | 95 | companion object |
85 | 96 | { |
86 | 97 | private const val REQUEST_CODE_PERMISSIONS = 10 |
87 | - private val REQUIRED_PERMISSIONS = arrayOf(Manifest.permission.CAMERA) | |
98 | + const val REQUEST_CODE_MEDIA_EDIT = 12 | |
99 | + private val REQUIRED_PERMISSIONS = arrayOf(Manifest.permission.CAMERA, | |
100 | + Manifest.permission.VIBRATE, | |
101 | + Manifest.permission.WRITE_EXTERNAL_STORAGE) | |
88 | 102 | } |
89 | 103 | } |
@@ -0,0 +1,28 @@ | ||
1 | +package jp.osdn.gokigen.mangle | |
2 | + | |
3 | +import android.content.ContentResolver | |
4 | +import android.net.Uri | |
5 | +import android.os.Build | |
6 | +import android.provider.MediaStore | |
7 | +import androidx.annotation.RequiresApi | |
8 | +import androidx.appcompat.app.AppCompatActivity | |
9 | + | |
10 | +/** | |
11 | + * | |
12 | + * | |
13 | + */ | |
14 | +@RequiresApi(api = Build.VERSION_CODES.R) | |
15 | +class StorageOperationWithPermission(val activity: AppCompatActivity) | |
16 | +{ | |
17 | + fun requestAndroidRMediaPermission() | |
18 | + { | |
19 | + val urisToModify: List<Uri> = listOf( | |
20 | + MediaStore.Video.Media.EXTERNAL_CONTENT_URI, | |
21 | + MediaStore.Images.Media.EXTERNAL_CONTENT_URI | |
22 | + ) | |
23 | + val contentResolver : ContentResolver = activity.contentResolver | |
24 | + val editPendingIntent = MediaStore.createWriteRequest(contentResolver, urisToModify) | |
25 | + | |
26 | + activity.startIntentSenderForResult(editPendingIntent.intentSender, MainActivity.REQUEST_CODE_MEDIA_EDIT,null, 0, 0, 0) | |
27 | + } | |
28 | +} |
@@ -1,6 +1,7 @@ | ||
1 | 1 | package jp.osdn.gokigen.mangle.operation |
2 | 2 | |
3 | 3 | import android.util.Log |
4 | +import android.util.Size | |
4 | 5 | import androidx.camera.core.CameraSelector |
5 | 6 | import androidx.camera.core.ImageAnalysis |
6 | 7 | import androidx.camera.core.Preview |
@@ -26,7 +27,6 @@ class CameraControl(val activity : FragmentActivity) | ||
26 | 27 | fun initialize() |
27 | 28 | { |
28 | 29 | Log.v(TAG, " initialize()") |
29 | - fileControl.initialize() | |
30 | 30 | cameraExecutor = Executors.newSingleThreadExecutor() |
31 | 31 | } |
32 | 32 |
@@ -54,6 +54,8 @@ class CameraControl(val activity : FragmentActivity) | ||
54 | 54 | try |
55 | 55 | { |
56 | 56 | val imageAnalyzer = ImageAnalysis.Builder() |
57 | + .setTargetResolution(Size(800, 600)) | |
58 | + .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST) | |
57 | 59 | .build() |
58 | 60 | .also { |
59 | 61 | it.setAnalyzer(cameraExecutor, MyImageAnalyzer { luma -> |
@@ -69,6 +71,7 @@ class CameraControl(val activity : FragmentActivity) | ||
69 | 71 | e.printStackTrace() |
70 | 72 | } |
71 | 73 | }, ContextCompat.getMainExecutor(activity)) |
74 | + | |
72 | 75 | } |
73 | 76 | |
74 | 77 | fun finish() |
@@ -1,6 +1,10 @@ | ||
1 | 1 | package jp.osdn.gokigen.mangle.operation |
2 | 2 | |
3 | +import android.content.ContentValues | |
3 | 4 | import android.net.Uri |
5 | +import android.os.Build | |
6 | +import android.os.Environment | |
7 | +import android.provider.MediaStore | |
4 | 8 | import android.util.Log |
5 | 9 | import android.view.View |
6 | 10 | import android.widget.Button |
@@ -8,10 +12,11 @@ import androidx.camera.core.ImageCapture | ||
8 | 12 | import androidx.camera.core.ImageCaptureException |
9 | 13 | import androidx.core.content.ContextCompat |
10 | 14 | import androidx.fragment.app.FragmentActivity |
15 | +import androidx.preference.PreferenceManager | |
11 | 16 | import com.google.android.material.snackbar.Snackbar |
12 | 17 | import jp.osdn.gokigen.mangle.R |
18 | +import jp.osdn.gokigen.mangle.preference.IPreferencePropertyAccessor | |
13 | 19 | import java.io.File |
14 | -import java.lang.Exception | |
15 | 20 | import java.text.SimpleDateFormat |
16 | 21 | import java.util.* |
17 | 22 |
@@ -19,28 +24,24 @@ class FileControl(private val context: FragmentActivity) : View.OnClickListener | ||
19 | 24 | { |
20 | 25 | private val TAG = toString() |
21 | 26 | private val FILENAME_FORMAT = "yyyy-MM-dd-HH-mm-ss-SSS" |
22 | - | |
23 | - private lateinit var outputDirectory: File | |
24 | 27 | private var imageCapture: ImageCapture? = null |
25 | 28 | |
29 | + //private lateinit var outputDirectory: File | |
30 | + //private var isLocalLocation : Boolean = false | |
31 | + | |
26 | 32 | init |
27 | 33 | { |
28 | 34 | |
29 | 35 | } |
30 | 36 | |
31 | - fun initialize() | |
32 | - { | |
33 | - outputDirectory = getOutputDirectory() | |
34 | - context.findViewById<Button>(R.id.camera_capture_button)?.setOnClickListener( this ) | |
35 | - } | |
36 | - | |
37 | 37 | fun prepare() : ImageCapture? |
38 | 38 | { |
39 | 39 | try |
40 | 40 | { |
41 | + context.findViewById<Button>(R.id.camera_capture_button)?.setOnClickListener(this) | |
41 | 42 | imageCapture = ImageCapture.Builder().build() |
42 | 43 | } |
43 | - catch (e : Exception) | |
44 | + catch (e: Exception) | |
44 | 45 | { |
45 | 46 | e.printStackTrace() |
46 | 47 | } |
@@ -52,46 +53,195 @@ class FileControl(private val context: FragmentActivity) : View.OnClickListener | ||
52 | 53 | |
53 | 54 | } |
54 | 55 | |
55 | - private fun getOutputDirectory(): File | |
56 | + /** | |
57 | + * 保存用ディレクトリを準備する(ダメな場合はアプリ領域のディレクトリを確保する) | |
58 | + * | |
59 | + */ | |
60 | + private fun prepareLocalOutputDirectory(): File | |
56 | 61 | { |
57 | - val mediaDir = context.externalMediaDirs.firstOrNull()?.let { | |
58 | - File(it, context.resources.getString(R.string.app_name)).apply { mkdirs() } | |
59 | - } | |
62 | + val mediaDir = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES) | |
63 | + mediaDir?.mkdirs() | |
60 | 64 | return (if (mediaDir != null && mediaDir.exists()) mediaDir else context.filesDir) |
61 | 65 | } |
62 | 66 | |
63 | - private fun takePhoto() | |
67 | + private fun takePhotoLocal() | |
64 | 68 | { |
65 | - Log.v(TAG, " takePhoto()") | |
66 | - | |
67 | 69 | val imageCapture = imageCapture ?: return |
68 | - val photoFile = File(outputDirectory, SimpleDateFormat(FILENAME_FORMAT, Locale.US).format(System.currentTimeMillis()) + ".jpg") | |
70 | + | |
71 | + Log.v(TAG, " takePhotoLocal()") | |
72 | + val photoFile = File(prepareLocalOutputDirectory(), SimpleDateFormat(FILENAME_FORMAT, Locale.US).format(System.currentTimeMillis()) + ".jpg") | |
69 | 73 | val outputOptions = ImageCapture.OutputFileOptions.Builder(photoFile).build() |
70 | 74 | |
71 | 75 | imageCapture.takePicture( |
72 | - outputOptions, ContextCompat.getMainExecutor(context), object : ImageCapture.OnImageSavedCallback { | |
73 | - override fun onError(exc: ImageCaptureException) { | |
76 | + outputOptions, | |
77 | + ContextCompat.getMainExecutor(context), | |
78 | + object : ImageCapture.OnImageSavedCallback | |
79 | + { | |
80 | + override fun onError(exc: ImageCaptureException) | |
81 | + { | |
74 | 82 | Log.e(TAG, "Photo capture failed: ${exc.message}", exc) |
75 | 83 | } |
76 | 84 | |
77 | - override fun onImageSaved(output: ImageCapture.OutputFileResults) { | |
85 | + override fun onImageSaved(output: ImageCapture.OutputFileResults) | |
86 | + { | |
78 | 87 | val savedUri = Uri.fromFile(photoFile) |
79 | 88 | val msg = context.getString(R.string.capture_success) + " $savedUri" |
80 | 89 | //Toast.makeText(context.baseContext, msg, Toast.LENGTH_SHORT).show() |
81 | - Snackbar.make(context.findViewById<androidx.constraintlayout.widget.ConstraintLayout>( | |
82 | - R.id.main_layout | |
83 | - ), msg, Snackbar.LENGTH_SHORT).show() | |
90 | + Snackbar.make( | |
91 | + context.findViewById<androidx.constraintlayout.widget.ConstraintLayout>( | |
92 | + R.id.main_layout | |
93 | + ), msg, Snackbar.LENGTH_SHORT | |
94 | + ).show() | |
84 | 95 | Log.v(TAG, msg) |
85 | 96 | } |
86 | - }) | |
97 | + } | |
98 | + ) | |
99 | + } | |
100 | + | |
101 | + private fun getExternalOutputDirectory(): File | |
102 | + { | |
103 | + val directoryPath = (Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).path + "/" + context.getString(R.string.app_location) + "/").toLowerCase(Locale.US) | |
104 | + val target = File(directoryPath) | |
105 | + try | |
106 | + { | |
107 | + target.mkdirs() | |
108 | + } | |
109 | + catch (e: Exception) | |
110 | + { | |
111 | + e.printStackTrace() | |
112 | + } | |
113 | + Log.v(TAG, " ----- RECORD Directory PATH : $directoryPath -----") | |
114 | + return (target) | |
115 | + } | |
116 | + | |
117 | + private fun takePhotoExternal() | |
118 | + { | |
119 | + val imageCapture = imageCapture ?: return | |
120 | + if (!isExternalStorageWritable()) | |
121 | + { | |
122 | + takePhotoLocal() | |
123 | + return | |
124 | + } | |
125 | + Log.v(TAG, " takePhotoExternal()") | |
126 | + | |
127 | + val outputDir = getExternalOutputDirectory() | |
128 | + val resolver = context.contentResolver | |
129 | + | |
130 | + val mimeType = "image/jpeg" | |
131 | + val now = System.currentTimeMillis() | |
132 | + val path = "DCIM/aira01a" | |
133 | + val photoFile = SimpleDateFormat(FILENAME_FORMAT, Locale.US).format(now) + ".jpg" | |
134 | + | |
135 | + val extStorageUri : Uri | |
136 | + val values = ContentValues() | |
137 | + values.put(MediaStore.Images.Media.DISPLAY_NAME,photoFile) | |
138 | + values.put(MediaStore.Images.Media.MIME_TYPE, mimeType) | |
139 | + values.put(MediaStore.Images.Media.DATE_ADDED, now) | |
140 | + values.put(MediaStore.Images.Media.DATE_MODIFIED, now) | |
141 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) | |
142 | + { | |
143 | + values.put(MediaStore.Images.Media.DATA, photoFile) | |
144 | + values.put(MediaStore.Images.Media.DATE_TAKEN, now) | |
145 | + values.put(MediaStore.Images.Media.RELATIVE_PATH, path) | |
146 | + values.put(MediaStore.Images.Media.IS_PENDING, true) | |
147 | + extStorageUri = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY + "/" + photoFile) | |
148 | + } | |
149 | + else | |
150 | + { | |
151 | + extStorageUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI | |
152 | + } | |
153 | + | |
154 | + val imageUri = resolver.insert(extStorageUri, values) | |
155 | + if (imageUri != null) | |
156 | + { | |
157 | + val openStream = resolver.openOutputStream(imageUri) | |
158 | + if (openStream != null) | |
159 | + { | |
160 | + val outputOptions = ImageCapture.OutputFileOptions.Builder(openStream).build() | |
161 | + imageCapture.takePicture( | |
162 | + outputOptions, | |
163 | + ContextCompat.getMainExecutor(context), | |
164 | + object : ImageCapture.OnImageSavedCallback | |
165 | + { | |
166 | + override fun onError(exc: ImageCaptureException) | |
167 | + { | |
168 | + Log.e(TAG, "Photo capture failed: ${exc.message}", exc) | |
169 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) | |
170 | + { | |
171 | + values.clear() | |
172 | + values.put(MediaStore.Images.Media.IS_PENDING, false) | |
173 | + resolver.update(imageUri, values, null, null) | |
174 | + } | |
175 | + } | |
176 | + | |
177 | + override fun onImageSaved(output: ImageCapture.OutputFileResults) | |
178 | + { | |
179 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) | |
180 | + { | |
181 | + //values.clear() | |
182 | + values.put(MediaStore.Images.Media.IS_PENDING, false) | |
183 | + resolver.update(imageUri, values, null, null) | |
184 | + } | |
185 | + val msg = context.getString(R.string.capture_success) + " $extStorageUri $path $photoFile" | |
186 | + //Toast.makeText(context.baseContext, msg, Toast.LENGTH_SHORT).show() | |
187 | + Snackbar.make( | |
188 | + context.findViewById<androidx.constraintlayout.widget.ConstraintLayout>( | |
189 | + R.id.main_layout | |
190 | + ), msg, Snackbar.LENGTH_SHORT | |
191 | + ).show() | |
192 | + Log.v(TAG, msg) | |
193 | + } | |
194 | + }) | |
195 | + } | |
196 | + } | |
197 | + } | |
198 | + | |
199 | + private fun takePhoto() | |
200 | + { | |
201 | + Log.v(TAG, " takePhoto()") | |
202 | + try | |
203 | + { | |
204 | + val isLocalLocation = PreferenceManager.getDefaultSharedPreferences(context).getBoolean( | |
205 | + IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION, | |
206 | + IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION_DEFAULT_VALUE | |
207 | + ) | |
208 | + if (isLocalLocation) | |
209 | + { | |
210 | + takePhotoLocal() | |
211 | + } | |
212 | + else | |
213 | + { | |
214 | + takePhotoExternal() | |
215 | + } | |
216 | + } | |
217 | + catch (e: Exception) | |
218 | + { | |
219 | + e.printStackTrace() | |
220 | + } | |
221 | + } | |
222 | + | |
223 | + private fun isExternalStorageWritable(): Boolean | |
224 | + { | |
225 | + return (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) | |
226 | + } | |
227 | + | |
228 | +/* | |
229 | + private fun isExternalStorageReadable(): Boolean | |
230 | + { | |
231 | + return (Environment.getExternalStorageState() in setOf( | |
232 | + Environment.MEDIA_MOUNTED, | |
233 | + Environment.MEDIA_MOUNTED_READ_ONLY | |
234 | + )) | |
87 | 235 | } |
236 | +*/ | |
88 | 237 | |
89 | 238 | override fun onClick(v: View?) |
90 | 239 | { |
240 | + Log.v(TAG, " onClick : $v?.id ") | |
91 | 241 | when (v?.id) |
92 | 242 | { |
93 | 243 | R.id.camera_capture_button -> takePhoto() |
94 | 244 | else -> Log.v(TAG, " Unknown ID : " + v?.id) |
95 | 245 | } |
96 | 246 | } |
97 | -} | |
\ No newline at end of file | ||
247 | +} |
@@ -5,15 +5,18 @@ interface IPreferencePropertyAccessor | ||
5 | 5 | |
6 | 6 | companion object |
7 | 7 | { |
8 | - val PREFERENCE_NOTIFICATIONS = "show_notifications" | |
9 | - val PREFERENCE_NOTIFICATIONS_DEFAULT_VALUE : Boolean = false | |
8 | + // --- PREFERENCE KEY AND DEFAULT VALUE --- | |
9 | + const val PREFERENCE_NOTIFICATIONS = "show_notifications" | |
10 | + const val PREFERENCE_NOTIFICATIONS_DEFAULT_VALUE = false | |
11 | + const val PREFERENCE_SAVE_LOCAL_LOCATION = "save_local_location" | |
12 | + const val PREFERENCE_SAVE_LOCAL_LOCATION_DEFAULT_VALUE = false | |
10 | 13 | |
11 | 14 | // --- SCREEN TRANSACTION LABEL --- |
12 | - val LABEL_EXIT_APPLICATION = "exit_application" | |
13 | - val LABEL_WIFI_SETTINGS = "wifi_settings" | |
14 | - val LABEL_INSTRUCTION_LINK = "instruction_link" | |
15 | - val LABEL_PRIVACY_POLICY = "privacy_policy" | |
16 | - val LABEL_DEBUG_INFO = "debug_info" | |
15 | + const val LABEL_EXIT_APPLICATION = "exit_application" | |
16 | + const val LABEL_WIFI_SETTINGS = "wifi_settings" | |
17 | + const val LABEL_INSTRUCTION_LINK = "instruction_link" | |
18 | + const val LABEL_PRIVACY_POLICY = "privacy_policy" | |
19 | + const val LABEL_DEBUG_INFO = "debug_info" | |
17 | 20 | } |
18 | 21 | |
19 | 22 | } |
@@ -50,28 +50,17 @@ class MainPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceCha | ||
50 | 50 | Log.v(TAG, " onAttach() : ") |
51 | 51 | |
52 | 52 | preferences = PreferenceManager.getDefaultSharedPreferences(context) |
53 | - PreferenceInitializer().initializePreferences(preferences) | |
53 | + PreferenceValueInitializer().initializePreferences(preferences) | |
54 | 54 | preferences.registerOnSharedPreferenceChangeListener(this) |
55 | 55 | } |
56 | 56 | |
57 | - override fun onResume() | |
58 | - { | |
59 | - super.onResume() | |
60 | - Log.v(TAG, " onResume() : ") | |
61 | - } | |
62 | - | |
63 | - override fun onPause() | |
64 | - { | |
65 | - super.onPause() | |
66 | - Log.v(TAG, " onPause() : ") | |
67 | - } | |
68 | - | |
69 | 57 | override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) |
70 | 58 | { |
71 | 59 | var value = false |
72 | 60 | when (key) |
73 | 61 | { |
74 | 62 | IPreferencePropertyAccessor.PREFERENCE_NOTIFICATIONS -> value = preferences.getBoolean(key, IPreferencePropertyAccessor.PREFERENCE_NOTIFICATIONS_DEFAULT_VALUE) |
63 | + IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION -> value = preferences.getBoolean(key, IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION_DEFAULT_VALUE) | |
75 | 64 | // else -> Log.v(TAG, " onSharedPreferenceChanged() : + $key ") |
76 | 65 | } |
77 | 66 | Log.v(TAG, " onSharedPreferenceChanged() : + $key, $value") |
@@ -2,7 +2,7 @@ package jp.osdn.gokigen.mangle.preference | ||
2 | 2 | |
3 | 3 | import android.content.SharedPreferences |
4 | 4 | |
5 | -class PreferenceInitializer | |
5 | +class PreferenceValueInitializer | |
6 | 6 | { |
7 | 7 | fun initializePreferences(preferences : SharedPreferences) |
8 | 8 | { |
@@ -13,6 +13,10 @@ class PreferenceInitializer | ||
13 | 13 | { |
14 | 14 | editor.putBoolean(IPreferencePropertyAccessor.PREFERENCE_NOTIFICATIONS, IPreferencePropertyAccessor.PREFERENCE_NOTIFICATIONS_DEFAULT_VALUE) |
15 | 15 | } |
16 | + if (!items.containsKey(IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION)) | |
17 | + { | |
18 | + editor.putBoolean(IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION, IPreferencePropertyAccessor.PREFERENCE_SAVE_LOCAL_LOCATION_DEFAULT_VALUE) | |
19 | + } | |
16 | 20 | editor.apply() |
17 | 21 | } |
18 | 22 |
@@ -33,7 +33,6 @@ class PreviewFragment(contentLayoutId: Int = R.layout.camera_capture) : Fragment | ||
33 | 33 | return (previewView) |
34 | 34 | } |
35 | 35 | previewView = inflater.inflate(R.layout.camera_capture, null, false) |
36 | - //cameraControl?.initialize() | |
37 | 36 | return (previewView) |
38 | 37 | } |
39 | 38 |
@@ -17,7 +17,7 @@ class SceneChanger(val activity: FragmentActivity, val informationNotify: IInfor | ||
17 | 17 | { |
18 | 18 | private val TAG = toString() |
19 | 19 | private val cameraControl: CameraControl = CameraControl(activity) |
20 | - private var count : Int = 0 | |
20 | + | |
21 | 21 | private lateinit var previewFragment : PreviewFragment |
22 | 22 | private lateinit var logCatFragment : LogCatFragment |
23 | 23 | private lateinit var mainPreferenceFragment : MainPreferenceFragment |
@@ -34,11 +34,8 @@ class SceneChanger(val activity: FragmentActivity, val informationNotify: IInfor | ||
34 | 34 | previewFragment = PreviewFragment.newInstance() |
35 | 35 | previewFragment.setCameraControl(cameraControl) |
36 | 36 | } |
37 | - cameraControl.startCamera() | |
38 | 37 | setDefaultFragment(previewFragment) |
39 | - | |
40 | - count++ | |
41 | - informationNotify.updateMessage(" changeToPreview " + count, false, true, Color.BLUE) | |
38 | + cameraControl.startCamera() | |
42 | 39 | } |
43 | 40 | |
44 | 41 | override fun changeToPreview() |
@@ -1,6 +1,7 @@ | ||
1 | 1 | <resources> |
2 | 2 | <string name="blank"> </string> |
3 | - <string name="app_name">mangle</string> | |
3 | + <string name="app_name">A01e</string> | |
4 | + <string name="app_location">AirA01a</string> | |
4 | 5 | <string name="action_refresh">更新</string> |
5 | 6 | <string name="finish_refresh">更新終了</string> |
6 | 7 | <string name="dialog_positive_execute">OK</string> |
@@ -25,6 +26,9 @@ | ||
25 | 26 | <string name="pref_wifi_settings">WiFi設定</string> |
26 | 27 | <string name="pref_summary_wifi_settings"> </string> |
27 | 28 | |
29 | + <string name="pref_cat_application_settings">アプリ設定</string> | |
30 | + <string name="save_local_location">アプリ固有領域に保存</string> | |
31 | + | |
28 | 32 | <string name="dialog_title_exit_application">アプリケーション終了</string> |
29 | 33 | <string name="dialog_message_exit_application">アプリケーションを終了します。</string> |
30 | 34 |
@@ -1,6 +1,7 @@ | ||
1 | 1 | <resources> |
2 | 2 | <string name="blank"> </string> |
3 | - <string name="app_name">mangle</string> | |
3 | + <string name="app_name">A01e</string> | |
4 | + <string name="app_location">AirA01a</string> | |
4 | 5 | <string name="action_refresh">Refresh</string> |
5 | 6 | <string name="finish_refresh">Finish refresh.</string> |
6 | 7 | <string name="dialog_positive_execute">OK</string> |
@@ -25,6 +26,9 @@ | ||
25 | 26 | <string name="pref_wifi_settings">WIFI Settings</string> |
26 | 27 | <string name="pref_summary_wifi_settings"> </string> |
27 | 28 | |
29 | + <string name="pref_cat_application_settings">App. Settings</string> | |
30 | + <string name="save_local_location">Save local location</string> | |
31 | + | |
28 | 32 | <string name="dialog_title_exit_application">Exit Application</string> |
29 | 33 | <string name="dialog_message_exit_application">Exit Application</string> |
30 | 34 |
@@ -14,9 +14,18 @@ | ||
14 | 14 | android:key="wifi_settings" |
15 | 15 | android:title="@string/pref_wifi_settings" |
16 | 16 | android:summary="@string/pref_summary_wifi_settings" /> |
17 | + </PreferenceCategory> | |
18 | + | |
19 | + <PreferenceCategory | |
20 | + app:title="@string/pref_cat_application_settings"> | |
21 | +<!-- | |
17 | 22 | <SwitchPreferenceCompat |
18 | 23 | android:key="show_notifications" |
19 | 24 | android:title="@string/notification_title"/> |
25 | +--> | |
26 | + <SwitchPreferenceCompat | |
27 | + android:key="save_local_location" | |
28 | + android:title="@string/save_local_location"/> | |
20 | 29 | </PreferenceCategory> |
21 | 30 | |
22 | 31 | <PreferenceCategory |