Merge pull request #349 from KryptKode/feat/camera-x-fixes

Feat/camera x fixes
This commit is contained in:
Tibor Kaputa 2022-10-07 18:45:51 +02:00 committed by GitHub
commit 0e40faf303
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 34 deletions

View File

@ -14,7 +14,6 @@ import android.provider.MediaStore
import android.view.*
import android.widget.LinearLayout
import androidx.appcompat.content.res.AppCompatResources
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.view.*
import androidx.transition.*
@ -38,10 +37,16 @@ import com.simplemobiletools.camera.views.FocusCircleView
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.Release
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.layout_flash.*
import kotlinx.android.synthetic.main.layout_top.*
import java.util.concurrent.TimeUnit
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.layout_flash.flash_auto
import kotlinx.android.synthetic.main.layout_flash.flash_off
import kotlinx.android.synthetic.main.layout_flash.flash_on
import kotlinx.android.synthetic.main.layout_flash.flash_toggle_group
import kotlinx.android.synthetic.main.layout_top.change_resolution
import kotlinx.android.synthetic.main.layout_top.default_icons
import kotlinx.android.synthetic.main.layout_top.settings
import kotlinx.android.synthetic.main.layout_top.toggle_flash
class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, CameraXPreviewListener {
private companion object {
@ -300,9 +305,8 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
}
val marginBottom = safeInsetBottom + navigationBarHeight + resources.getDimensionPixelSize(R.dimen.bigger_margin)
(shutter.layoutParams as ConstraintLayout.LayoutParams).goneBottomMargin = marginBottom
video_rec_curr_timer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
shutter.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = marginBottom
}
@ -342,7 +346,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
mTimerHandler = Handler(Looper.getMainLooper())
setupPreviewImage(true)
val initialFlashlightState = FLASH_OFF
val initialFlashlightState = if (mIsInPhotoMode) config.flashlightState else FLASH_OFF
mPreview!!.setFlashlightState(initialFlashlightState)
updateFlashlightState(initialFlashlightState)
initFlashModeTransitionNames()
@ -395,7 +399,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
}
}
fun updateFlashlightState(state: Int) {
private fun updateFlashlightState(state: Int) {
config.flashlightState = state
val flashDrawable = when (state) {
FLASH_OFF -> R.drawable.ic_flash_off_vector
@ -687,6 +691,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
shutter.isSelected = true
toggle_camera.beInvisible()
change_resolution.isEnabled = false
settings.isEnabled = false
video_rec_curr_timer.beVisible()
}
@ -696,6 +701,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
video_rec_curr_timer.text = 0.getFormattedDuration()
video_rec_curr_timer.beGone()
change_resolution.isEnabled = true
settings.isEnabled = true
toggle_camera.beVisible()
}

View File

@ -64,6 +64,7 @@ class ImageQualityManager(
.flatMap { it.qualities }
.sortedByDescending { it.pixels }
.distinctBy { it.getAspectRatio(activity) }
.sortedByDescending { it.getAspectRatio(activity).split(":").firstOrNull()?.toIntOrNull() }
.filter { it.isSupported(fullScreenSize.isSixteenToNine()) }
}

View File

@ -1,3 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:fillColor="#FFFFFFFF" android:pathData="M21 15h2v2h-2v-2zm0-4h2v2h-2v-2zm2 8h-2v2c1 0 2-1 2-2zM13 3h2v2h-2V3zm8 4h2v2h-2V7zm0-4v2h2c0-1-1-2-2-2zM1 7h2v2H1V7zm16-4h2v2h-2V3zm0 16h2v2h-2v-2zM3 3C2 3 1 4 1 5h2V3zm6 0h2v2H9V3zM5 3h2v2H5V3zm-4 8v8c0 1.1 0.9 2 2 2h12V11H1zm2 8l2.5-3.21 1.79 2.15 2.5-3.22L13 19H3z"/>
</vector>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/camera_option_color"
android:pathData="M19.5 12c0-0.23-0.01-0.45-0.03-0.68l1.86-1.41c0.4-0.3 0.51-0.86 0.26-1.3l-1.87-3.23c-0.25-0.44-0.79-0.62-1.25-0.42l-2.15 0.91c-0.37-0.26-0.76-0.49-1.17-0.68l-0.29-2.31C14.8 2.38 14.37 2 13.87 2h-3.73c-0.51 0-0.94 0.38-1 0.88L8.85 5.19c-0.41 0.19-0.8 0.42-1.17 0.68L5.53 4.96c-0.46-0.2-1-0.02-1.25 0.42L2.41 8.62c-0.25 0.44-0.14 0.99 0.26 1.3l1.86 1.41C4.51 11.55 4.5 11.77 4.5 12s0.01 0.45 0.03 0.68l-1.86 1.41c-0.4 0.3-0.51 0.86-0.26 1.3l1.87 3.23c0.25 0.44 0.79 0.62 1.25 0.42l2.15-0.91c0.37 0.26 0.76 0.49 1.17 0.68l0.29 2.31C9.2 21.62 9.63 22 10.13 22h3.73c0.5 0 0.93-0.38 0.99-0.88l0.29-2.31c0.41-0.19 0.8-0.42 1.17-0.68l2.15 0.91c0.46 0.2 1 0.02 1.25-0.42l1.87-3.23c0.25-0.44 0.14-0.99-0.26-1.3l-1.86-1.41c0.03-0.23 0.04-0.45 0.04-0.68zm-7.46 3.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z" />
</vector>

View File

@ -1,3 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:fillColor="#FFFFFFFF" android:pathData="M17 10.5V7c0-0.55-0.45-1-1-1H4C3.45 6 3 6.45 3 7v10c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1v-3.5l4 4v-11l-4 4z"/>
</vector>

View File

@ -75,6 +75,21 @@
</com.google.android.material.tabs.TabLayout>
<TextView
android:id="@+id/video_rec_curr_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/smaller_margin"
android:textColor="@android:color/white"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/shutter"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="00:00"
tools:visibility="visible" />
<ImageView
android:id="@+id/toggle_camera"
android:layout_width="@dimen/icon_size"
@ -92,14 +107,13 @@
android:id="@+id/shutter"
android:layout_width="@dimen/large_icon_size"
android:layout_height="@dimen/large_icon_size"
android:layout_marginBottom="@dimen/small_margin"
android:layout_marginBottom="@dimen/big_margin"
android:contentDescription="@string/shutter"
android:src="@drawable/ic_shutter_animated"
app:layout_constraintBottom_toTopOf="@id/video_rec_curr_timer"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/last_photo_video_preview"
app:layout_constraintStart_toEndOf="@id/toggle_camera"
app:layout_constraintVertical_bias="1"
app:layout_goneMarginBottom="@dimen/big_margin" />
app:layout_constraintVertical_bias="1" />
<ImageView
android:id="@+id/last_photo_video_preview"
@ -113,19 +127,4 @@
app:layout_constraintTop_toTopOf="@id/shutter"
tools:src="@tools:sample/backgrounds/scenic" />
<TextView
android:id="@+id/video_rec_curr_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/small_margin"
android:layout_marginBottom="@dimen/big_margin"
android:textColor="@android:color/white"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="00:00"
tools:visibility="gone" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -43,7 +43,7 @@
android:layout_weight="1"
android:contentDescription="@string/settings"
android:padding="@dimen/normal_margin"
app:icon="@drawable/ic_settings_cog_vector"
app:icon="@drawable/ic_settings"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/change_resolution"
app:layout_constraintTop_toTopOf="@id/toggle_flash" />