Skip to content

Commit 9945231

Browse files
committed
Lint
1 parent d534a7d commit 9945231

File tree

8 files changed

+57
-130
lines changed

8 files changed

+57
-130
lines changed

library/multipicker/src/main/java/im/vector/lib/multipicker/MultiPicker.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MultiPicker<T> private constructor() {
2727
val CONTACT by lazy { MultiPicker<ContactPicker>() }
2828
val CAMERA by lazy { MultiPicker<CameraPicker>() }
2929
val CAMERA_VIDEO by lazy { MultiPicker<CameraVideoPicker>() }
30-
val VECTOR_CAMERA by lazy { MultiPicker<VectorCameraPicker>()}
30+
val VECTOR_CAMERA by lazy { MultiPicker<VectorCameraPicker>() }
3131

3232
@Suppress("UNCHECKED_CAST")
3333
fun <T> get(type: MultiPicker<T>): T {

vector/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<!-- Adding CAMERA permission prevents Chromebooks to see the application on the PlayStore -->
5353
<!-- Tell that the Camera is not mandatory to install the application -->
5454
<uses-feature
55-
android:name="android.hardware.camera.any"
55+
android:name="android.hardware.camera"
5656
android:required="false" />
5757
<uses-feature
5858
android:name="android.hardware.camera.autofocus"

vector/src/main/java/im/vector/app/features/attachments/camera/AttachmentsCameraFragment.kt

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class AttachmentsCameraFragment :
6666

6767
@Inject lateinit var clock: Clock
6868

69-
private lateinit var authority : String
70-
private lateinit var storageDir : File
69+
private lateinit var authority: String
70+
private lateinit var storageDir: File
7171

7272
private var imageCapture: ImageCapture? = null
7373
private var videoCapture: VideoCapture<Recorder>? = null
@@ -240,41 +240,41 @@ class AttachmentsCameraFragment :
240240
private fun takePhoto() {
241241
Timber.d("Taking a photo")
242242
context?.let { context ->
243-
// Get a stable reference of the modifiable image capture use case
244-
val imageCapture = imageCapture ?: return
245-
246-
imageCapture.flashMode = flashMode
247-
248-
val file = createTempFile(MediaType.IMAGE)
249-
val outputUri = getUri(context, file)
250-
251-
// Create output options object which contains file + metadata
252-
val outputOptions = ImageCapture.OutputFileOptions
253-
.Builder(file)
254-
.build()
255-
256-
// Set up image capture listener, which is triggered after photo has
257-
// been taken
258-
imageCapture.takePicture(
259-
outputOptions,
260-
ContextCompat.getMainExecutor(context),
261-
object : ImageCapture.OnImageSavedCallback {
262-
override fun onError(exc: ImageCaptureException) {
263-
Timber.e("Photo capture failed: ${exc.message}", exc)
264-
Toast.makeText(context, "An error occurred", Toast.LENGTH_SHORT).show()
265-
(activity as? AttachmentsCameraActivity)?.setErrorAndFinish()
266-
}
243+
// Get a stable reference of the modifiable image capture use case
244+
val imageCapture = imageCapture ?: return
267245

268-
override fun onImageSaved(output: ImageCapture.OutputFileResults){
269-
(activity as? AttachmentsCameraActivity)?.setResultAndFinish(
270-
VectorCameraOutput(
271-
type = MediaType.IMAGE,
272-
uri = outputUri
273-
)
274-
)
246+
imageCapture.flashMode = flashMode
247+
248+
val file = createTempFile(MediaType.IMAGE)
249+
val outputUri = getUri(context, file)
250+
251+
// Create output options object which contains file + metadata
252+
val outputOptions = ImageCapture.OutputFileOptions
253+
.Builder(file)
254+
.build()
255+
256+
// Set up image capture listener, which is triggered after photo has
257+
// been taken
258+
imageCapture.takePicture(
259+
outputOptions,
260+
ContextCompat.getMainExecutor(context),
261+
object : ImageCapture.OnImageSavedCallback {
262+
override fun onError(exc: ImageCaptureException) {
263+
Timber.e("Photo capture failed: ${exc.message}", exc)
264+
Toast.makeText(context, "An error occurred", Toast.LENGTH_SHORT).show()
265+
(activity as? AttachmentsCameraActivity)?.setErrorAndFinish()
266+
}
267+
268+
override fun onImageSaved(output: ImageCapture.OutputFileResults) {
269+
(activity as? AttachmentsCameraActivity)?.setResultAndFinish(
270+
VectorCameraOutput(
271+
type = MediaType.IMAGE,
272+
uri = outputUri
273+
)
274+
)
275+
}
275276
}
276-
}
277-
)
277+
)
278278
}
279279
}
280280

@@ -304,15 +304,15 @@ class AttachmentsCameraFragment :
304304
recording = videoCapture.output
305305
.prepareRecording(context, options)
306306
.apply {
307-
if (PermissionChecker.checkSelfPermission(context,
308-
Manifest.permission.RECORD_AUDIO) ==
309-
PermissionChecker.PERMISSION_GRANTED)
310-
{
307+
if (PermissionChecker.checkSelfPermission(
308+
context,
309+
Manifest.permission.RECORD_AUDIO
310+
) == PermissionChecker.PERMISSION_GRANTED) {
311311
withAudioEnabled()
312312
}
313313
}
314314
.start(ContextCompat.getMainExecutor(context)) { recordEvent ->
315-
when(recordEvent) {
315+
when (recordEvent) {
316316
is VideoRecordEvent.Start -> {
317317
views.attachmentsCameraCaptureAction.setImageDrawable(
318318
context.getDrawable(R.drawable.ic_video_off)
@@ -429,14 +429,13 @@ class AttachmentsCameraFragment :
429429
private var cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
430430
private var flashMode = ImageCapture.FLASH_MODE_AUTO
431431
private val REQUIRED_PERMISSIONS =
432-
mutableListOf (
432+
mutableListOf(
433433
Manifest.permission.CAMERA,
434434
Manifest.permission.RECORD_AUDIO
435435
).apply {
436436
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
437437
add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
438438
}
439439
}.toTypedArray()
440-
441440
}
442441
}

vector/src/main/java/im/vector/app/features/attachments/camera/VectorCameraOutput.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import android.net.Uri
2020
import android.os.Parcelable
2121
import kotlinx.parcelize.Parcelize
2222

23-
enum class MediaType{
23+
enum class MediaType {
2424
IMAGE,
2525
VIDEO
2626
}
2727

2828
@Parcelize
29-
data class VectorCameraOutput (
29+
data class VectorCameraOutput(
3030
val type: MediaType,
3131
val uri: Uri,
3232
) : Parcelable

vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ class VectorSettingsPreferencesFragment :
157157
false
158158
}
159159
}
160-
161160
}
162161

163162
// ==============================================================================================================

vector/src/main/res/layout/dialog_photo_or_video.xml

Lines changed: 0 additions & 52 deletions
This file was deleted.

vector/src/main/res/layout/fragment_attachments_camera.xml

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4-
xmlns:tools="http://schemas.android.com/tools"
54
android:layout_width="match_parent"
65
android:layout_height="match_parent">
76

@@ -21,8 +20,8 @@
2120
android:scaleY="0.7"
2221
android:src="@drawable/ic_video"
2322
app:layout_constraintBottom_toBottomOf="parent"
24-
app:layout_constraintEnd_toStartOf="@+id/vertical_leftline"
25-
app:layout_constraintStart_toStartOf="@+id/vertical_leftline" />
23+
app:layout_constraintEnd_toStartOf="@id/attachmentsCameraCaptureAction"
24+
app:layout_constraintStart_toStartOf="parent" />
2625

2726
<com.google.android.material.floatingactionbutton.FloatingActionButton
2827
android:id="@+id/attachmentsCameraCaptureAction"
@@ -34,8 +33,8 @@
3433
android:scaleY="1.3"
3534
android:src="@drawable/ic_camera_plain"
3635
app:layout_constraintBottom_toBottomOf="parent"
37-
app:layout_constraintStart_toStartOf="@id/vertical_centerline"
38-
app:layout_constraintEnd_toStartOf="@id/vertical_centerline"
36+
app:layout_constraintStart_toStartOf="parent"
37+
app:layout_constraintEnd_toEndOf="parent"
3938
android:contentDescription="@string/attachment_camera_capture" />
4039

4140
<com.google.android.material.floatingactionbutton.FloatingActionButton
@@ -48,8 +47,8 @@
4847
android:scaleY="0.7"
4948
android:src="@drawable/ic_video_flip"
5049
app:layout_constraintBottom_toBottomOf="parent"
51-
app:layout_constraintStart_toStartOf="@id/vertical_rightline"
52-
app:layout_constraintEnd_toStartOf="@id/vertical_rightline"
50+
app:layout_constraintStart_toEndOf="@id/attachmentsCameraCaptureAction"
51+
app:layout_constraintEnd_toEndOf="parent"
5352
android:contentDescription="@string/attachment_camera_flip" />
5453

5554
<com.google.android.material.floatingactionbutton.FloatingActionButton
@@ -66,25 +65,4 @@
6665
app:layout_constraintEnd_toEndOf="parent"
6766
android:contentDescription="@string/attachment_camera_disable_flash" />
6867

69-
<androidx.constraintlayout.widget.Guideline
70-
android:id="@+id/vertical_leftline"
71-
android:layout_width="wrap_content"
72-
android:layout_height="wrap_content"
73-
android:orientation="vertical"
74-
app:layout_constraintGuide_percent=".2" />
75-
76-
<androidx.constraintlayout.widget.Guideline
77-
android:id="@+id/vertical_centerline"
78-
android:layout_width="wrap_content"
79-
android:layout_height="wrap_content"
80-
android:orientation="vertical"
81-
app:layout_constraintGuide_percent=".50" />
82-
83-
<androidx.constraintlayout.widget.Guideline
84-
android:id="@+id/vertical_rightline"
85-
android:layout_width="wrap_content"
86-
android:layout_height="wrap_content"
87-
android:orientation="vertical"
88-
app:layout_constraintGuide_percent=".8" />
89-
9068
</androidx.constraintlayout.widget.ConstraintLayout>

vector/src/main/res/values/strings.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,12 +511,15 @@
511511

512512
<string name="option_send_files">Send files</string>
513513
<string name="option_send_sticker">Send sticker</string>
514-
<string name="option_take_photo_video">Take photo or video</string>
514+
<!-- TODO TO BE REMOVED -->
515+
<string tools:ignore="UnusedResources" name="option_take_photo_video">Take photo or video</string>
515516
<string name="option_take_photo">Take photo</string>
516517
<string name="option_take_video">Take video</string>
517-
<string name="option_always_ask">Always ask</string>
518+
<!-- TODO TO BE REMOVED -->
519+
<string tools:ignore="UnusedResources" name="option_always_ask">Always ask</string>
518520

519-
<string name="use_as_default_and_do_not_ask_again">Use as default and do not ask again</string>
521+
<!-- TODO TO BE REMOVED -->
522+
<string tools:ignore="UnusedResources" name="use_as_default_and_do_not_ask_again">Use as default and do not ask again</string>
520523

521524
<!-- No sticker application dialog -->
522525
<string name="no_sticker_application_dialog_content">You don’t currently have any stickerpacks enabled.\n\nAdd some now?</string>

0 commit comments

Comments
 (0)