Skip to content

Commit 90e922b

Browse files
committed
Set the built-in camera as a lab preference
1 parent f56a8fe commit 90e922b

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,9 @@ class TimelineFragment :
15821582
attachmentTypeSelector.setAttachmentVisibility(
15831583
AttachmentTypeSelectorView.Type.POLL, !isThreadTimeLine()
15841584
)
1585+
attachmentTypeSelector.setAttachmentVisibility(
1586+
AttachmentTypeSelectorView.Type.VIDEO_CAMERA, !vectorPreferences.builtinCameraIsEnabled()
1587+
)
15851588
}
15861589
attachmentTypeSelector.show(views.composerLayout.views.attachmentButton)
15871590
}
@@ -2626,7 +2629,13 @@ class TimelineFragment :
26262629

26272630
private fun launchAttachmentProcess(type: AttachmentTypeSelectorView.Type) {
26282631
when (type) {
2629-
AttachmentTypeSelectorView.Type.PHOTO_CAMERA -> attachmentsHelper.openVectorCamera(attachmentVectorCameraActivityResultLauncher)
2632+
AttachmentTypeSelectorView.Type.PHOTO_CAMERA -> {
2633+
if (vectorPreferences.builtinCameraIsEnabled()) {
2634+
attachmentsHelper.openVectorCamera(attachmentVectorCameraActivityResultLauncher)
2635+
} else {
2636+
attachmentsHelper.openPhotoCamera(attachmentCameraActivityResultLauncher)
2637+
}
2638+
}
26302639
AttachmentTypeSelectorView.Type.VIDEO_CAMERA -> attachmentsHelper.openVideoCamera(attachmentCameraVideoActivityResultLauncher)
26312640
AttachmentTypeSelectorView.Type.FILE -> attachmentsHelper.selectFile(attachmentFileActivityResultLauncher)
26322641
AttachmentTypeSelectorView.Type.GALLERY -> attachmentsHelper.selectGallery(attachmentMediaActivityResultLauncher)

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ class VectorPreferences @Inject constructor(
158158
const val SETTINGS_USER_REFUSED_LAZY_LOADING_PREFERENCE_KEY = "SETTINGS_USER_REFUSED_LAZY_LOADING_PREFERENCE_KEY"
159159
const val SETTINGS_DATA_SAVE_MODE_PREFERENCE_KEY = "SETTINGS_DATA_SAVE_MODE_PREFERENCE_KEY"
160160
private const val SETTINGS_USE_JITSI_CONF_PREFERENCE_KEY = "SETTINGS_USE_JITSI_CONF_PREFERENCE_KEY"
161-
private const val SETTINGS_USE_NATIVE_CAMERA_PREFERENCE_KEY = "SETTINGS_USE_NATIVE_CAMERA_PREFERENCE_KEY"
162161
private const val SETTINGS_ENABLE_SEND_VOICE_FEATURE_PREFERENCE_KEY = "SETTINGS_ENABLE_SEND_VOICE_FEATURE_PREFERENCE_KEY"
163162

164163
const val SETTINGS_LABS_ALLOW_EXTENDED_LOGS = "SETTINGS_LABS_ALLOW_EXTENDED_LOGS"
165164
const val SETTINGS_LABS_AUTO_REPORT_UISI = "SETTINGS_LABS_AUTO_REPORT_UISI"
165+
const val SETTINGS_LABS_ENABLE_BUILTIN_CAMERA = "SETTINGS_LABS_ENABLE_BUILTIN_CAMERA"
166166
const val SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME = "SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME"
167167

168168
private const val SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY = "SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY"
@@ -361,6 +361,10 @@ class VectorPreferences @Inject constructor(
361361
return defaultPrefs.getBoolean(SETTINGS_LABS_ENABLE_LATEX_MATHS, false)
362362
}
363363

364+
fun builtinCameraIsEnabled(): Boolean {
365+
return defaultPrefs.getBoolean(SETTINGS_LABS_ENABLE_BUILTIN_CAMERA, false)
366+
}
367+
364368
fun failFast(): Boolean {
365369
return buildMeta.isDebug || (developerMode() && defaultPrefs.getBoolean(SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY, false))
366370
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3201,6 +3201,7 @@
32013201
<string name="attachment_camera_video">Take a video</string>
32023202
<string name="attachment_camera_capture">Capture</string>
32033203
<string name="attachment_camera_flip">Change camera</string>
3204+
<string name="labs_enable_builtin_camera">Enable Built-in Camera</string>
32043205

32053206
<plurals name="room_removed_messages">
32063207
<item quantity="one">%d message removed</item>

vector/src/main/res/xml/vector_settings_labs.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959
android:title="@string/labs_enable_latex_maths" />
6060
<!--</im.vector.app.core.preference.VectorPreferenceCategory>-->
6161

62+
<im.vector.app.core.preference.VectorSwitchPreference
63+
android:defaultValue="false"
64+
android:key="SETTINGS_LABS_ENABLE_BUILTIN_CAMERA"
65+
android:title="@string/labs_enable_builtin_camera" />
66+
6267
<im.vector.app.core.preference.VectorSwitchPreference
6368
android:defaultValue="@bool/settings_labs_thread_messages_default"
6469
android:key="SETTINGS_LABS_ENABLE_THREAD_MESSAGES_FINAL"

0 commit comments

Comments
 (0)