camera相关接口完成
This commit is contained in:
parent
a7a0d45d9b
commit
38f87df5c9
@ -0,0 +1,32 @@
|
||||
package com.xyzshell.myphoneinfo.custom
|
||||
|
||||
object SetNumberOrWordUtils {
|
||||
fun setDecimal1(double: Double): String{
|
||||
return "%.1f".format(double)
|
||||
}
|
||||
fun setDecimal0(double: Double): String{
|
||||
return double.toInt().toString()
|
||||
}
|
||||
|
||||
fun toTitleCase(sentence: String): String {
|
||||
if (sentence.isEmpty()) return ""
|
||||
|
||||
val words = sentence.trim().split("\\s+".toRegex()) // 按一个或多个空格分割
|
||||
|
||||
return if (words.isNotEmpty()) {
|
||||
// 第一个单词首字母大写
|
||||
val firstWord = words[0].lowercase().replaceFirstChar { it.uppercase() }
|
||||
|
||||
// 其余单词保持小写
|
||||
val remainingWords = words.drop(1).joinToString(" ") { it.lowercase() }
|
||||
|
||||
if (remainingWords.isNotEmpty()) {
|
||||
"$firstWord $remainingWords"
|
||||
} else {
|
||||
firstWord
|
||||
}
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package com.xyzshell.myphoneinfo.custom
|
||||
|
||||
object SetNumberUtils {
|
||||
fun setDecimal1(double: Double): String{
|
||||
return "%.1f".format(double)
|
||||
}
|
||||
fun setDecimal0(double: Double): String{
|
||||
return double.toInt().toString()
|
||||
}
|
||||
}
|
||||
@ -1,23 +1,22 @@
|
||||
package com.xyzshell.myphoneinfo.dashboard
|
||||
|
||||
import android.hardware.camera2.CameraCharacteristics
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.fragment.app.FragmentContainer
|
||||
import com.google.android.material.textview.MaterialTextView
|
||||
import com.xyzshell.andinfo.AndInfo
|
||||
import com.xyzshell.myphoneinfo.R
|
||||
import com.xyzshell.myphoneinfo.custom.SetNumberUtils.setDecimal0
|
||||
import com.xyzshell.myphoneinfo.custom.SetNumberUtils.setDecimal1
|
||||
import com.xyzshell.myphoneinfo.custom.SetNumberOrWordUtils.setDecimal0
|
||||
import com.xyzshell.myphoneinfo.custom.SetNumberOrWordUtils.setDecimal1
|
||||
import com.xyzshell.myphoneinfo.databinding.FragmentCameraBinding
|
||||
import com.xyzshell.myphoneinfo.databinding.ItemCameraTypeBinding
|
||||
import com.xyzshell.myphoneinfo.dialog.DialogCameraMore
|
||||
|
||||
class CameraFragment : Fragment() {
|
||||
private lateinit var binding:FragmentCameraBinding;
|
||||
private lateinit var binding:FragmentCameraBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -66,6 +65,20 @@ class CameraFragment : Fragment() {
|
||||
}
|
||||
itemBinding.titleCon.text = cameraName
|
||||
|
||||
//取第一个相机的视频帧率
|
||||
if(index==0){
|
||||
cameraInfo.getMaxFrameRate(it).let { maxFrameRate->
|
||||
binding.video.textTitle.text=getString(R.string.max_frequency)
|
||||
binding.video.textContent.text=maxFrameRate.toString()+"HZ"
|
||||
}
|
||||
cameraInfo.supportsHighSpeedVideo(it).let { hasHighSpeedVideo ->
|
||||
binding.videoCheck1.image.isSelected=hasHighSpeedVideo
|
||||
}
|
||||
cameraInfo.hasVideoStabilization(it).let { hasVideoStabilization ->
|
||||
binding.videoCheck2.image.isSelected=hasVideoStabilization
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 4. 设置详细信息(使用 include 的文本)
|
||||
|
||||
@ -125,6 +138,7 @@ class CameraFragment : Fragment() {
|
||||
itemBinding.rearCheck2.image.isSelected=hasFlash
|
||||
}
|
||||
|
||||
|
||||
// 6. 设置"更多"按钮点击事件
|
||||
itemBinding.rearMore.setOnClickListener {
|
||||
var dialogCamera0: DialogCameraMore? = null
|
||||
@ -142,6 +156,7 @@ class CameraFragment : Fragment() {
|
||||
binding.videoCheck1.content.text=getString(R.string.hight_speed_video)
|
||||
binding.videoCheck2.content.text=getString(R.string.video_stabilization)
|
||||
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
package com.xyzshell.myphoneinfo.dialog
|
||||
|
||||
import android.graphics.Typeface
|
||||
import android.os.Bundle
|
||||
import android.text.SpannableString
|
||||
import android.text.style.StyleSpan
|
||||
import android.view.View
|
||||
import com.xyzshell.andinfo.AndInfo
|
||||
import com.xyzshell.myphoneinfo.R
|
||||
import com.xyzshell.myphoneinfo.base.BaseDialogFragment
|
||||
import com.xyzshell.myphoneinfo.custom.SetNumberOrWordUtils.setDecimal0
|
||||
import com.xyzshell.myphoneinfo.custom.SetNumberOrWordUtils.setDecimal1
|
||||
import com.xyzshell.myphoneinfo.custom.SetNumberOrWordUtils.toTitleCase
|
||||
import com.xyzshell.myphoneinfo.databinding.DialogCameraMoreBinding
|
||||
import com.xyzshell.myphoneinfo.databinding.DialogCpuInfoBinding
|
||||
|
||||
class DialogCameraMore(private val name:String,private val id:String) :BaseDialogFragment<DialogCameraMoreBinding>(DialogCameraMoreBinding::inflate){
|
||||
override fun getTitle(): String = name
|
||||
@ -19,6 +19,128 @@ class DialogCameraMore(private val name:String,private val id:String) :BaseDialo
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val cameraInfo = AndInfo.instance.camera
|
||||
if(!id.isEmpty()){
|
||||
id.forEachIndexed { index, cameraId ->
|
||||
val characteristics = cameraInfo.getCameraCharacteristics(id)
|
||||
characteristics?.let {
|
||||
// 设置详细信息(使用 include 的文本)
|
||||
// 设置百万像素
|
||||
|
||||
cameraInfo.getMegaPixels(it)?.let { size ->
|
||||
binding.tv1.setValue("${setDecimal1(size)} MP")
|
||||
}
|
||||
//像素阵列大小
|
||||
cameraInfo.getPixelArraySize(it)?.let { size ->
|
||||
binding.tv2.setValue(size)
|
||||
|
||||
}
|
||||
// 传感器物理尺寸
|
||||
cameraInfo.getSensorPhysicalSize(it)?.let { size ->
|
||||
binding.tv3.setValue(size)
|
||||
}
|
||||
// 传感器px尺寸
|
||||
cameraInfo.getPixelSize(it)?.let { size ->
|
||||
binding.tv4.setValue("${setDecimal0(size)}μm")
|
||||
}
|
||||
// 颜色排列
|
||||
cameraInfo.getColorFilterArrangement(it)?.let { size ->
|
||||
binding.tv5.setValue(size)
|
||||
}
|
||||
//光圈值
|
||||
cameraInfo.getAvailableApertures(it)?.let { apertures ->
|
||||
if (apertures.isNotEmpty()) {
|
||||
binding.tv6.setValue("f/${apertures[0]}")
|
||||
}
|
||||
}
|
||||
//焦距
|
||||
cameraInfo.getFocalLength(it)?.let { apertures ->
|
||||
if (apertures.isNotEmpty()) {
|
||||
binding.tv7.setValue(apertures[0].toString())
|
||||
}
|
||||
}
|
||||
|
||||
// 35mm等效焦距
|
||||
cameraInfo.getFocal35mmEquivalent(it)?.let { size ->
|
||||
binding.tv8.setValue("${size.toInt()}mm")
|
||||
}
|
||||
// 裁切系数
|
||||
cameraInfo.getFocal35mmEquivalent(it)?.let { size ->
|
||||
binding.tv9.setValue("${size.toInt()}x")
|
||||
}
|
||||
// 快门速度
|
||||
cameraInfo.getShutterSpeedRange(it)?.let { size ->
|
||||
binding.tv11.setValue(size)
|
||||
}
|
||||
|
||||
// ISO感光范围
|
||||
cameraInfo.getIsoRange(it)?.let { size ->
|
||||
binding.tv12.setValue(size.lower.toString() + " - " + size.upper.toString())
|
||||
}
|
||||
|
||||
// 闪光灯
|
||||
binding.check1.content.text=getString(R.string.flash)
|
||||
cameraInfo.hasFlashUnit(it)?.let { hasFlash ->
|
||||
binding.check1.image.isSelected=hasFlash
|
||||
}
|
||||
// 视频防抖
|
||||
binding.check2.content.text=getString(R.string.video_stabilization)
|
||||
cameraInfo.hasVideoStabilization(it)?.let { hasVideoStabilization ->
|
||||
binding.check2.image.isSelected=hasVideoStabilization
|
||||
}
|
||||
// 光学防抖
|
||||
binding.check3.content.text=getString(R.string.optical_image_stabilization)
|
||||
cameraInfo.hasOpticalStabilization(it).let { hasOpticalStabilization ->
|
||||
binding.check3.image.isSelected = hasOpticalStabilization
|
||||
}
|
||||
// 曝光锁定
|
||||
// 曝光模式
|
||||
binding.check4.content.text=getString(R.string.ae_lock)
|
||||
cameraInfo.getAutoExposureModes(it)?.let { list ->
|
||||
val allInfo=list.joinToString(" , ") { mode -> mode}
|
||||
binding.check4.image.isSelected=list.size>2
|
||||
binding.more2.text=allInfo
|
||||
}
|
||||
// 白平衡锁定
|
||||
// 白平衡模式
|
||||
binding.check5.content.text=getString(R.string.wb_lock)
|
||||
cameraInfo.getWhiteBalanceModes(it)?.let { list ->
|
||||
binding.check5.image.isSelected=list.size>2
|
||||
val allInfo=list.joinToString(" , ") { mode -> mode}
|
||||
binding.more4.text=allInfo
|
||||
}
|
||||
|
||||
|
||||
//功能
|
||||
cameraInfo.getAvailableCapabilities(it).let{ capabilities ->
|
||||
val allCapabilities = capabilities.joinToString(",") { capability ->
|
||||
toTitleCase(capability.name.replace("_", " "))
|
||||
}
|
||||
binding.more1.text=allCapabilities
|
||||
}
|
||||
//自动对焦模式
|
||||
cameraInfo.getAvailableCapabilities(it).let{ capabilities ->
|
||||
val allInfo=capabilities.joinToString(" , ") { capability ->
|
||||
toTitleCase(capability.name.replace("_", " "))
|
||||
}
|
||||
binding.more3.text=allInfo
|
||||
}
|
||||
|
||||
//场景模式
|
||||
cameraInfo.getSceneModes(it).let{ capabilities ->
|
||||
val allInfo=capabilities?.joinToString(" , ") { capability ->
|
||||
toTitleCase(capability.replace("_", " "))
|
||||
}
|
||||
binding.more5.text=allInfo
|
||||
binding.tv10.setValue(capabilities?.get(0) ?: "")
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNegativeClick() {
|
||||
|
||||
@ -18,17 +18,17 @@
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/tv_label"
|
||||
style="@style/TextDialogLabel"
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tv_sub_title"
|
||||
android:gravity="start"
|
||||
android:textSize="15sp"
|
||||
android:textSize="14sp"
|
||||
android:text="sppppppppppppppppppppp" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/tv_value"
|
||||
style="@style/TextDialogContent"
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/tv_label"
|
||||
@ -36,6 +36,7 @@
|
||||
android:layout_toEndOf="@id/tv_label"
|
||||
android:gravity="center"
|
||||
android:textSize="15sp"
|
||||
android:textColor="#C1C5C2"
|
||||
android:text="sppppppppppppppppppppp" />
|
||||
|
||||
</RelativeLayout>
|
||||
@ -4,7 +4,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:paddingHorizontal="18dp"
|
||||
android:paddingVertical="15dp"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:layout_marginVertical="5dp"
|
||||
android:background="@drawable/dashboard_model_background"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout
|
||||
@ -16,18 +16,19 @@
|
||||
>
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/sensor_name"
|
||||
style="@style/TextTool25"
|
||||
style="@style/TextHeavy20"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textStyle="normal"
|
||||
android:textSize="18sp"
|
||||
android:gravity="start"
|
||||
android:text="spppppppeee" />
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/sensor_value"
|
||||
style="@style/TextContentRight"
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start"
|
||||
android:textColor="@color/right_color"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="spppppppeee" />
|
||||
</LinearLayout>
|
||||
|
||||
@ -94,16 +94,14 @@
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Capabilities"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
android:text="@string/capabilities" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
style="@style/TextContentRight"
|
||||
android:id="@+id/more1"
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="High speed video"
|
||||
android:textSize="15sp" />
|
||||
android:textColor="@color/right_color" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -115,16 +113,14 @@
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Exposure modes"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
android:text="@string/exposure_modes" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
style="@style/TextContentRight"
|
||||
android:id="@+id/more2"
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Manual, Auto, Flash"
|
||||
android:textSize="15sp" />
|
||||
android:textColor="@color/right_color" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -136,18 +132,15 @@
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Autofocus modes"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
android:text="@string/autofocus_modes" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
style="@style/TextContentRight"
|
||||
android:id="@+id/more3"
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Manual, Auto, Macro,
|
||||
Continuous video, Continuous
|
||||
picture"
|
||||
android:textSize="15sp" />
|
||||
android:textColor="@color/right_color"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -159,16 +152,16 @@ picture"
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="White balance modes"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
android:text="@string/white_balance_modes"
|
||||
/>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
style="@style/TextContentRight"
|
||||
android:id="@+id/more4"
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Auto, Off, Incandescent,Fluorescent, Daylight, Cloudy"
|
||||
android:textSize="15sp" />
|
||||
android:textColor="@color/right_color"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -180,16 +173,16 @@ picture"
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Scene modes"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
android:text="@string/scene_modes"
|
||||
/>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
style="@style/TextContentRight"
|
||||
android:id="@+id/more5"
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Face priority, Action, Portrait,Landscape, Night, Nightportrait, Theatre, Beach,Snow, Fireworks, Candlelight,High speed video"
|
||||
android:textSize="15sp" />
|
||||
android:textColor="@color/right_color"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@ -85,10 +85,11 @@
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/open2"
|
||||
style="@style/TextContentRight"
|
||||
style="@style/LeftContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/apps"
|
||||
android:textColor="@color/right_color"
|
||||
tools:ignore="RelativeOverlap" />
|
||||
</LinearLayout>
|
||||
<include layout="@layout/common_text_style" android:id="@+id/video"/>
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="visible"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical">
|
||||
<include layout="@layout/common_sensor_style" android:id="@+id/sensor1"/>
|
||||
<include layout="@layout/common_sensor_style" android:id="@+id/sensor2"/>
|
||||
|
||||
@ -293,4 +293,11 @@
|
||||
<string name="toybox">Toybox</string>
|
||||
<string name="java_VM">Java VM</string>
|
||||
<string name="current">current</string>
|
||||
<string name="ae_lock">AE lock</string>
|
||||
<string name="wb_lock">WB lock</string>
|
||||
<string name="white_balance_modes">White balance modes</string>
|
||||
<string name="capabilities">Capabilities</string>
|
||||
<string name="exposure_modes">Exposure modes</string>
|
||||
<string name="autofocus_modes">Autofocus modes</string>
|
||||
<string name="scene_modes">Scene modes</string>
|
||||
</resources>
|
||||
Loading…
Reference in New Issue
Block a user