新增display和app弹框,修改电池布局
This commit is contained in:
parent
4e15482b7d
commit
e3ef108511
@ -1,6 +1,7 @@
|
||||
package com.xyzshell.myphoneinfo.dashboard
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@ -10,10 +11,14 @@ import com.xyzshell.myphoneinfo.R
|
||||
import com.xyzshell.myphoneinfo.adapter.AppListAdapter
|
||||
import com.xyzshell.myphoneinfo.databinding.FragmentAppsBinding
|
||||
import com.xyzshell.myphoneinfo.dialog.AppDialogFragment
|
||||
import com.xyzshell.myphoneinfo.dialog.BottomDialogFragment
|
||||
import com.xyzshell.myphoneinfo.main.MainScrollActivity
|
||||
|
||||
class AppsFragment : Fragment(),AppListAdapter.OnShowDialogListener {
|
||||
private lateinit var binding: FragmentAppsBinding
|
||||
private lateinit var dialogFragment: AppDialogFragment
|
||||
private lateinit var bottomDialog: BottomDialogFragment
|
||||
private var sel: Int? = 0
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
@ -28,6 +33,14 @@ class AppsFragment : Fragment(),AppListAdapter.OnShowDialogListener {
|
||||
adapter.setOnclickListener(this)
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.llTitle.setOnClickListener {
|
||||
bottomDialog= BottomDialogFragment(type = "apps", sel = sel, invoke = {item->
|
||||
sel = item
|
||||
})
|
||||
Log.d("sel", sel.toString())
|
||||
bottomDialog.show(requireActivity().supportFragmentManager, "BottomDialogFragment")
|
||||
}
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
||||
@ -6,8 +6,10 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.xyzshell.myphoneinfo.R
|
||||
import com.xyzshell.myphoneinfo.databinding.FragmentBatteryBinding
|
||||
|
||||
class BatteryFragment : Fragment() {
|
||||
private lateinit var binding: FragmentBatteryBinding
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
@ -17,7 +19,13 @@ class BatteryFragment : Fragment() {
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_battery, container, false)
|
||||
binding = FragmentBatteryBinding.inflate(inflater, container, false)
|
||||
initView()
|
||||
return binding.root
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@ -14,6 +14,7 @@ import com.xyzshell.myphoneinfo.dialog.DialogBlueTooth
|
||||
import com.xyzshell.myphoneinfo.dialog.DialogDiskPart
|
||||
import com.xyzshell.myphoneinfo.dialog.DialogExtension
|
||||
import com.xyzshell.myphoneinfo.dialog.DialogInput
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class HardWareFragment : Fragment() {
|
||||
private lateinit var binding: FragmentHardWareBinding
|
||||
@ -115,14 +116,24 @@ class HardWareFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
//display
|
||||
val defaultDisplayInfo = AndInfo.instance.display.getDefaultDisplayInfo()
|
||||
if(defaultDisplayInfo!=null){
|
||||
binding.disText1.textContent.text=defaultDisplayInfo.widthPixels.toString()+"x"+defaultDisplayInfo.heightPixels.toString()
|
||||
}
|
||||
binding.disText1.textTitle.text=getString(R.string.resolution)
|
||||
binding.disText2.textTitle.text=getString(R.string.screen_density)
|
||||
|
||||
binding.disText2.textTitle.text=getString(R.string.screen_density)//这个是px
|
||||
binding.disText3.textTitle.text=getString(R.string.screen_density_d)
|
||||
val dpiStr=defaultDisplayInfo?.densityDpi.toString()+"(xxhdpi)\n"+defaultDisplayInfo?.xdpi?.roundToInt()+"dp"+defaultDisplayInfo?.ydpi?.roundToInt()+"dp"
|
||||
binding.disText3.textContent.text=dpiStr
|
||||
binding.disText4.textTitle.text=getString(R.string.screen_size_e)
|
||||
binding.disText5.textTitle.text=getString(R.string.aspect_ratio)
|
||||
binding.disText6.textTitle.text=getString(R.string.refresh_rate)
|
||||
binding.disText6.textContent.text=defaultDisplayInfo?.refreshRate.toString()+"HZ"
|
||||
binding.disText7.textTitle.text=getString(R.string.wide_color_gamut)
|
||||
binding.disText7.textContent.text=defaultDisplayInfo?.isWideColorGamut.toString()
|
||||
binding.disText8.textTitle.text=getString(R.string.hdr_support)
|
||||
binding.disText8.textContent.text=defaultDisplayInfo?.isHdr.toString()
|
||||
|
||||
//memory
|
||||
val storageInfo = AndInfo.instance.storage//存储信息
|
||||
|
||||
@ -0,0 +1,125 @@
|
||||
package com.xyzshell.myphoneinfo.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import com.xyzshell.myphoneinfo.R
|
||||
import com.xyzshell.myphoneinfo.databinding.FragmentBottomDialogBinding
|
||||
|
||||
|
||||
class BottomDialogFragment(val type:String, sel:Int? = null,val invoke:(Int)->Unit) : DialogFragment() {
|
||||
private lateinit var vb: FragmentBottomDialogBinding
|
||||
private var select=sel?:0
|
||||
private var appType=type
|
||||
companion object {
|
||||
const val FROMAPP = "app"
|
||||
const val USER = 0
|
||||
const val SYSTEM = 1
|
||||
const val ALL = 2
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
vb = FragmentBottomDialogBinding.inflate(layoutInflater)
|
||||
init()
|
||||
return vb.root
|
||||
}
|
||||
|
||||
private fun showUI(select: Int) {
|
||||
when (select) {
|
||||
USER->{
|
||||
vb.user.nameText.setTextColor(Color.parseColor("#3B948A"))
|
||||
vb.user.check.visibility=View.VISIBLE
|
||||
vb.system.nameText.setTextColor(Color.parseColor("#C1C5C2"))
|
||||
vb.system.check.visibility=View.GONE
|
||||
vb.all.nameText.setTextColor(Color.parseColor("#C1C5C2"))
|
||||
vb.all.check.visibility=View.GONE
|
||||
}
|
||||
SYSTEM->{
|
||||
vb.user.nameText.setTextColor(Color.parseColor("#C1C5C2"))
|
||||
vb.user.check.visibility=View.GONE
|
||||
vb.system.nameText.setTextColor(Color.parseColor("#3B948A"))
|
||||
vb.system.check.visibility=View.VISIBLE
|
||||
vb.all.nameText.setTextColor(Color.parseColor("#C1C5C2"))
|
||||
vb.all.check.visibility=View.GONE
|
||||
}
|
||||
ALL->{
|
||||
vb.user.nameText.setTextColor(Color.parseColor("#C1C5C2"))
|
||||
vb.user.check.visibility=View.GONE
|
||||
vb.system.nameText.setTextColor(Color.parseColor("#C1C5C2"))
|
||||
vb.system.check.visibility=View.GONE
|
||||
vb.all.nameText.setTextColor(Color.parseColor("#3B948A"))
|
||||
vb.all.check.visibility=View.VISIBLE
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = super.onCreateDialog(savedInstanceState)
|
||||
|
||||
dialog.window?.apply {
|
||||
requestFeature(Window.FEATURE_NO_TITLE)
|
||||
setWindowAnimations(R.style.BottomSheetDialogStyle)
|
||||
setLayout(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
setGravity(Gravity.BOTTOM)
|
||||
}
|
||||
|
||||
return dialog
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
dialog?.apply {
|
||||
setCanceledOnTouchOutside(true)
|
||||
window?.apply {
|
||||
setBackgroundDrawable(Color.TRANSPARENT.toDrawable())
|
||||
setLayout(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun init() {
|
||||
vb.user.nameText.text=getString(R.string.user)
|
||||
vb.system.nameText.text=getString(R.string.system)
|
||||
vb.all.nameText.text=getString(R.string.all)
|
||||
showUI(select)
|
||||
if(appType == FROMAPP){
|
||||
showUI(select)
|
||||
}
|
||||
vb.user.root.setOnClickListener {
|
||||
showUI(USER)
|
||||
invoke(USER)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
vb.system.root.setOnClickListener {
|
||||
showUI(SYSTEM)
|
||||
invoke(SYSTEM)
|
||||
dismiss()
|
||||
}
|
||||
vb.all.root.setOnClickListener {
|
||||
showUI(ALL)
|
||||
invoke(ALL)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/forground_color"/>
|
||||
<corners android:topLeftRadius="10dp" android:topRightRadius="10dp"/>
|
||||
|
||||
</shape>
|
||||
@ -23,16 +23,30 @@
|
||||
android:background="@drawable/dashboard_model_background"
|
||||
android:paddingVertical="15sp"
|
||||
android:orientation="vertical">
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/tvTitle"
|
||||
<LinearLayout
|
||||
android:id="@+id/llTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="User apps (23)"
|
||||
style="@style/TextDialogSubTitle"
|
||||
android:textSize="23sp"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
/>
|
||||
android:gravity="center_vertical"
|
||||
android:paddingHorizontal="20dp"
|
||||
android:paddingVertical="10dp"
|
||||
android:orientation="horizontal">
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/tvTitle"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="User apps (23)"
|
||||
style="@style/TextHeavy20"
|
||||
android:textSize="16sp"
|
||||
/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:src="@mipmap/app_more"/>
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
38
myphoneinfo/src/main/res/layout/fragment_bottom_dialog.xml
Normal file
38
myphoneinfo/src/main/res/layout/fragment_bottom_dialog.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/dialog_top_background"
|
||||
android:gravity="center"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@mipmap/user_bottom"
|
||||
android:layout_margin="10dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/appLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="20dp">
|
||||
<include
|
||||
android:id="@+id/user"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
layout="@layout/item_bottom_dialog"/>
|
||||
<include
|
||||
android:id="@+id/system"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
layout="@layout/item_bottom_dialog"/>
|
||||
<include
|
||||
android:id="@+id/all"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
layout="@layout/item_bottom_dialog"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
28
myphoneinfo/src/main/res/layout/item_bottom_dialog.xml
Normal file
28
myphoneinfo/src/main/res/layout/item_bottom_dialog.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingHorizontal="20dp"
|
||||
android:paddingVertical="10dp"
|
||||
android:orientation="horizontal">
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/name_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/apps"
|
||||
style="@style/TextHeavy20"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@color/right_color"/>
|
||||
<ImageView
|
||||
android:id="@+id/check"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:src="@mipmap/select"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
BIN
myphoneinfo/src/main/res/mipmap-xhdpi/app_more.png
Normal file
BIN
myphoneinfo/src/main/res/mipmap-xhdpi/app_more.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 430 B |
BIN
myphoneinfo/src/main/res/mipmap-xhdpi/select.png
Normal file
BIN
myphoneinfo/src/main/res/mipmap-xhdpi/select.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 444 B |
BIN
myphoneinfo/src/main/res/mipmap-xhdpi/user_bottom.png
Normal file
BIN
myphoneinfo/src/main/res/mipmap-xhdpi/user_bottom.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 256 B |
Loading…
Reference in New Issue
Block a user