Skip to content

Commit 5d04527

Browse files
committed
Lint
1 parent 02ab8dd commit 5d04527

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
@@ -62,8 +62,8 @@ class AttachmentsCameraFragment @Inject constructor(
6262
val clock: Clock
6363
) : VectorBaseFragment<FragmentAttachmentsCameraBinding>(), VectorMenuProvider {
6464

65-
private lateinit var authority : String
66-
private lateinit var storageDir : File
65+
private lateinit var authority: String
66+
private lateinit var storageDir: File
6767

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

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

@@ -300,15 +300,15 @@ class AttachmentsCameraFragment @Inject constructor(
300300
recording = videoCapture.output
301301
.prepareRecording(context, options)
302302
.apply {
303-
if (PermissionChecker.checkSelfPermission(context,
304-
Manifest.permission.RECORD_AUDIO) ==
305-
PermissionChecker.PERMISSION_GRANTED)
306-
{
303+
if (PermissionChecker.checkSelfPermission(
304+
context,
305+
Manifest.permission.RECORD_AUDIO
306+
) == PermissionChecker.PERMISSION_GRANTED) {
307307
withAudioEnabled()
308308
}
309309
}
310310
.start(ContextCompat.getMainExecutor(context)) { recordEvent ->
311-
when(recordEvent) {
311+
when (recordEvent) {
312312
is VideoRecordEvent.Start -> {
313313
views.attachmentsCameraCaptureAction.setImageDrawable(
314314
context.getDrawable(R.drawable.ic_video_off)
@@ -425,14 +425,13 @@ class AttachmentsCameraFragment @Inject constructor(
425425
private var cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
426426
private var flashMode = ImageCapture.FLASH_MODE_AUTO
427427
private val REQUIRED_PERMISSIONS =
428-
mutableListOf (
428+
mutableListOf(
429429
Manifest.permission.CAMERA,
430430
Manifest.permission.RECORD_AUDIO
431431
).apply {
432432
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
433433
add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
434434
}
435435
}.toTypedArray()
436-
437436
}
438437
}

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 @Inject constructor(
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
@@ -497,12 +497,15 @@
497497

498498
<string name="option_send_files">Send files</string>
499499
<string name="option_send_sticker">Send sticker</string>
500-
<string name="option_take_photo_video">Take photo or video</string>
500+
<!-- TODO TO BE REMOVED -->
501+
<string tools:ignore="UnusedResources" name="option_take_photo_video">Take photo or video</string>
501502
<string name="option_take_photo">Take photo</string>
502503
<string name="option_take_video">Take video</string>
503-
<string name="option_always_ask">Always ask</string>
504+
<!-- TODO TO BE REMOVED -->
505+
<string tools:ignore="UnusedResources" name="option_always_ask">Always ask</string>
504506

505-
<string name="use_as_default_and_do_not_ask_again">Use as default and do not ask again</string>
507+
<!-- TODO TO BE REMOVED -->
508+
<string tools:ignore="UnusedResources" name="use_as_default_and_do_not_ask_again">Use as default and do not ask again</string>
506509

507510
<!-- No sticker application dialog -->
508511
<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)