fix #76, add a toggle for always opening the back camera at startup

This commit is contained in:
tibbi 2017-10-21 21:37:13 +02:00
parent e1528e5416
commit 406236cb2e
5 changed files with 37 additions and 0 deletions

View File

@ -77,4 +77,8 @@ class Config(context: Context) : BaseConfig(context) {
var keepSettingsVisible: Boolean
get() = prefs.getBoolean(KEEP_SETTINGS_VISIBLE, false)
set(keepSettingsVisible) = prefs.edit().putBoolean(KEEP_SETTINGS_VISIBLE, keepSettingsVisible).apply()
var alwaysOpenBackCamera: Boolean
get() = prefs.getBoolean(ALWAYS_OPEN_BACK_CAMERA, false)
set(alwaysOpenBackCamera) = prefs.edit().putBoolean(ALWAYS_OPEN_BACK_CAMERA, alwaysOpenBackCamera).apply()
}

View File

@ -20,6 +20,7 @@ val FRONT_PHOTO_RESOLUTION_INDEX = "front_photo_resolution_index"
val FRONT_VIDEO_RESOLUTION_INDEX = "front_video_resolution_index"
val PHOTO_PREVIEW_HINT_SHOWN = "photo_preview_hint_shown"
val KEEP_SETTINGS_VISIBLE = "keep_settings_visible"
val ALWAYS_OPEN_BACK_CAMERA = "always_open_back_camera"
val FLASH_OFF = 0
val FLASH_ON = 1

View File

@ -56,6 +56,9 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
super.onCreate(savedInstanceState)
requestWindowFeature(Window.FEATURE_NO_TITLE)
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
if (config.alwaysOpenBackCamera)
config.lastUsedCamera = Camera.CameraInfo.CAMERA_FACING_BACK
initVariables()
tryInitCamera()
supportActionBar?.hide()

View File

@ -32,6 +32,7 @@ class SettingsActivity : SimpleActivity() {
setupTurnFlashOffAtStartup()
setupFlipPhotos()
setupKeepSettingsVisible()
setupAlwaysOpenBackCamera()
updateTextColors(settings_holder)
}
@ -126,4 +127,12 @@ class SettingsActivity : SimpleActivity() {
config.keepSettingsVisible = settings_keep_settings_visible.isChecked
}
}
private fun setupAlwaysOpenBackCamera() {
settings_always_open_back_camera.isChecked = config.alwaysOpenBackCamera
settings_always_open_back_camera_holder.setOnClickListener {
settings_always_open_back_camera.toggle()
config.alwaysOpenBackCamera = settings_always_open_back_camera.isChecked
}
}
}

View File

@ -204,5 +204,25 @@
android:text="@string/keep_settings_visible"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_always_open_back_camera_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_always_open_back_camera"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingLeft="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin"
android:text="@string/always_open_back_camera"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>