diff --git a/myphoneinfo/build.gradle.kts b/myphoneinfo/build.gradle.kts index 594e8ee..da16ca0 100644 --- a/myphoneinfo/build.gradle.kts +++ b/myphoneinfo/build.gradle.kts @@ -88,4 +88,5 @@ dependencies { implementation ("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") implementation ("androidx.gridlayout:gridlayout:1.0.0") implementation ("com.google.android.material:material:1.12.0") + } diff --git a/myphoneinfo/src/main/AndroidManifest.xml b/myphoneinfo/src/main/AndroidManifest.xml index d2e49f1..0ffb645 100644 --- a/myphoneinfo/src/main/AndroidManifest.xml +++ b/myphoneinfo/src/main/AndroidManifest.xml @@ -4,6 +4,7 @@ + + @@ -57,4 +61,4 @@ - + \ No newline at end of file diff --git a/myphoneinfo/src/main/java/com/xyzshell/myphoneinfo/dashboard/DashboardFragment.kt b/myphoneinfo/src/main/java/com/xyzshell/myphoneinfo/dashboard/DashboardFragment.kt index bdc2132..31bd3ed 100644 --- a/myphoneinfo/src/main/java/com/xyzshell/myphoneinfo/dashboard/DashboardFragment.kt +++ b/myphoneinfo/src/main/java/com/xyzshell/myphoneinfo/dashboard/DashboardFragment.kt @@ -127,6 +127,10 @@ class DashboardFragment : BaseFragment() { dialogStorage?.show(parentFragmentManager, "") } } + binding.layoutTop.root.setOnClickListener { + dialogOperating = dialogOperating ?: DialogOperating() + dialogOperating?.show(parentFragmentManager, "") + } binding.layoutBottom.run { relayoutTools.setOnClickListener { startActivity(Intent(requireContext(), ToolsActivity::class.java)) @@ -134,10 +138,6 @@ class DashboardFragment : BaseFragment() { relayoutTests.setOnClickListener { startActivity(Intent(requireContext(), TestActivity::class.java)) } - relayoutPhoneInfo.setOnClickListener { - dialogOperating = dialogOperating ?: DialogOperating() - dialogOperating?.show(parentFragmentManager, "") - } } } diff --git a/myphoneinfo/src/main/java/com/xyzshell/myphoneinfo/dialog/SlideInPopView.kt b/myphoneinfo/src/main/java/com/xyzshell/myphoneinfo/dialog/SlideInPopView.kt new file mode 100644 index 0000000..a102cce --- /dev/null +++ b/myphoneinfo/src/main/java/com/xyzshell/myphoneinfo/dialog/SlideInPopView.kt @@ -0,0 +1,101 @@ +package com.xyzshell.myphoneinfo.dialog + +import android.animation.Animator +import android.animation.AnimatorListenerAdapter +import android.animation.ObjectAnimator +import android.app.Dialog +import android.content.Context + +import android.os.Bundle +import android.view.Gravity + +import android.view.ViewGroup +import android.view.Window +import com.xyzshell.myphoneinfo.R + +import com.xyzshell.myphoneinfo.databinding.ActivitySlideInPopViewBinding + +class SlideInPopView(context: Context) : Dialog(context) { + + private lateinit var binding: ActivitySlideInPopViewBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + // 设置无标题 + requestWindowFeature(Window.FEATURE_NO_TITLE) + + binding = ActivitySlideInPopViewBinding.inflate(layoutInflater) + setContentView(binding.root) + + // 设置Dialog属性 + window?.apply { + // 设置位置为左侧 + setGravity(Gravity.START) + + // 设置宽高 + val displayMetrics = context.resources.displayMetrics + var width1 = (displayMetrics.widthPixels * 0.7).toInt() // 70%屏幕宽度 + attributes = attributes?.apply { + width = width1 + height = ViewGroup.LayoutParams.MATCH_PARENT + + // 设置动画 + windowAnimations = R.style.SlideInLeftAnimation + } + + // 设置背景透明 + setBackgroundDrawableResource(android.R.color.transparent) + } + + // 设置点击外部可以关闭 + setCanceledOnTouchOutside(true) + + setupViews() + openSidebar() // 打开时显示侧边栏 + } + + private fun setupViews() { + // 侧边栏内的关闭按钮(如果有的话) + // binding.btnClose.setOnClickListener { dismiss() } + + // 初始化侧边栏位置 + binding.root.post { + binding.popupContent.translationX = -binding.popupContent.width.toFloat() + openSidebar() + } + } + + private fun openSidebar() { + val animator = ObjectAnimator.ofFloat( + binding.popupContent, + "translationX", + -binding.popupContent.width.toFloat(), + 0f + ) + animator.duration = 300 + animator.start() + } + + private fun closeSidebar(callback: () -> Unit = {}) { + val animator = ObjectAnimator.ofFloat( + binding.popupContent, + "translationX", + 0f, + -binding.popupContent.width.toFloat() + ) + animator.duration = 300 + animator.addListener(object : AnimatorListenerAdapter() { + override fun onAnimationEnd(animation: Animator) { + callback() + } + }) + animator.start() + } + + override fun dismiss() { + closeSidebar { + super.dismiss() + } + } +} \ No newline at end of file diff --git a/myphoneinfo/src/main/java/com/xyzshell/myphoneinfo/main/MainScrollActivity.kt b/myphoneinfo/src/main/java/com/xyzshell/myphoneinfo/main/MainScrollActivity.kt index 4603124..74721c1 100644 --- a/myphoneinfo/src/main/java/com/xyzshell/myphoneinfo/main/MainScrollActivity.kt +++ b/myphoneinfo/src/main/java/com/xyzshell/myphoneinfo/main/MainScrollActivity.kt @@ -1,7 +1,6 @@ package com.xyzshell.myphoneinfo.main import android.view.LayoutInflater -import android.view.View import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.tabs.TabLayoutMediator import com.xyzshell.myphoneinfo.R @@ -16,12 +15,11 @@ import com.xyzshell.myphoneinfo.dashboard.NetworkFragment import com.xyzshell.myphoneinfo.dashboard.SensorsFragment import com.xyzshell.myphoneinfo.dashboard.SystemShowFragment import com.xyzshell.myphoneinfo.databinding.ActivityMainBinding -import com.xyzshell.myphoneinfo.dialog.CustomPopView +import com.xyzshell.myphoneinfo.dialog.SlideInPopView class MainScrollActivity : BaseActivity() { override fun inflateBinding(inflater: LayoutInflater): ActivityMainBinding = ActivityMainBinding.inflate(inflater) - private lateinit var customPopView: CustomPopView override fun initView() { super.initView() binding.run { @@ -44,7 +42,6 @@ class MainScrollActivity : BaseActivity() { registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { override fun onPageSelected(position: Int) { super.onPageSelected(position) - updateButtonVisibility(position) } }) }) { tab, position -> @@ -57,75 +54,14 @@ class MainScrollActivity : BaseActivity() { // } }.attach() } - customPopView =CustomPopView(this,2,callback = {text-> - }) binding.imageTool.setOnClickListener { - customPopView.show(binding.imageTool) - } - binding.searchIcon.setOnClickListener { - binding.textAppName.visibility= View.GONE - binding.imageTool.visibility= View.GONE - binding.searchIcon.visibility= View.GONE - binding.searchLayout.visibility= View.VISIBLE - } - binding.searchClose.setOnClickListener { - binding.textAppName.visibility= View.VISIBLE - binding.imageTool.visibility= View.VISIBLE - binding.searchIcon.visibility= View.VISIBLE - binding.searchLayout.visibility= View.GONE - } - initButtons() - } - private fun updateButtonVisibility(currentPosition: Int) { - if (currentPosition == 5) { - // 在 AppsFragment 时显示特殊按钮 - binding.searchIcon.visibility = View.VISIBLE - binding.llBottom.visibility= View.VISIBLE - } else { - // 在其他 Fragment 时隐藏特殊按钮 - binding.searchIcon.visibility = View.GONE - binding.llBottom.visibility= View.GONE - } - } - private fun initButtons() { - switchTab(0) - binding.llUser.setOnClickListener { switchTab(0) } - binding.llSystem.setOnClickListener { switchTab(1) } - binding.llAll.setOnClickListener { switchTab(2) } - } - private fun switchTab(n: Int) { - when(n){ - 0->{ - binding.back1.visibility = View.VISIBLE - binding.back2.visibility = View.INVISIBLE - binding.back3.visibility = View.INVISIBLE - binding.imgUser.isSelected = true - binding.imgSystem.isSelected = false - binding.imgAll.isSelected = false -// binding.tvTitle.text=getString(R.string.user_apps)+"("+30+")" - } - 1->{ - binding.back1.visibility = View.INVISIBLE - binding.back2.visibility = View.VISIBLE - binding.back3.visibility = View.INVISIBLE - binding.imgUser.isSelected = false - binding.imgSystem.isSelected = true - binding.imgAll.isSelected = false -// binding.tvTitle.text=getString(R.string.system_apps)+"("+30+")" - } - 2->{ - binding.back1.visibility = View.INVISIBLE - binding.back2.visibility = View.INVISIBLE - binding.back3.visibility = View.VISIBLE - binding.imgUser.isSelected = false - binding.imgSystem.isSelected = false - binding.imgAll.isSelected = true -// binding.tvTitle.text=getString(R.string.installed_apps)+"("+30+")" - } + val sidebarDialog = SlideInPopView(this) + sidebarDialog.show() } } + override fun initData() { super.initData() } diff --git a/myphoneinfo/src/main/res/anim/slide_in_left.xml b/myphoneinfo/src/main/res/anim/slide_in_left.xml new file mode 100644 index 0000000..ca5f5f3 --- /dev/null +++ b/myphoneinfo/src/main/res/anim/slide_in_left.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/myphoneinfo/src/main/res/anim/slide_out_left.xml b/myphoneinfo/src/main/res/anim/slide_out_left.xml new file mode 100644 index 0000000..beba279 --- /dev/null +++ b/myphoneinfo/src/main/res/anim/slide_out_left.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/myphoneinfo/src/main/res/drawable/dashboard_model_background_left_bottom.xml b/myphoneinfo/src/main/res/drawable/dashboard_model_background_left_bottom.xml deleted file mode 100644 index 642fc80..0000000 --- a/myphoneinfo/src/main/res/drawable/dashboard_model_background_left_bottom.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/myphoneinfo/src/main/res/drawable/dashboard_model_background_left_top.xml b/myphoneinfo/src/main/res/drawable/dashboard_model_background_left_top.xml deleted file mode 100644 index f1d9820..0000000 --- a/myphoneinfo/src/main/res/drawable/dashboard_model_background_left_top.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/myphoneinfo/src/main/res/drawable/dashboard_model_background_right_bottom.xml b/myphoneinfo/src/main/res/drawable/dashboard_model_background_right_bottom.xml index 7d13964..66fa06b 100644 --- a/myphoneinfo/src/main/res/drawable/dashboard_model_background_right_bottom.xml +++ b/myphoneinfo/src/main/res/drawable/dashboard_model_background_right_bottom.xml @@ -2,9 +2,6 @@ - + \ No newline at end of file diff --git a/myphoneinfo/src/main/res/drawable/dashboard_model_background_right_top.xml b/myphoneinfo/src/main/res/drawable/dashboard_model_background_right_top.xml deleted file mode 100644 index 8c97946..0000000 --- a/myphoneinfo/src/main/res/drawable/dashboard_model_background_right_top.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/myphoneinfo/src/main/res/drawable/dashboard_model_background_small.xml b/myphoneinfo/src/main/res/drawable/dashboard_model_background_small.xml deleted file mode 100644 index cf3ccd2..0000000 --- a/myphoneinfo/src/main/res/drawable/dashboard_model_background_small.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/myphoneinfo/src/main/res/drawable/dashboard_model_left_both.xml b/myphoneinfo/src/main/res/drawable/dashboard_model_left_both.xml deleted file mode 100644 index 8889cc9..0000000 --- a/myphoneinfo/src/main/res/drawable/dashboard_model_left_both.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/myphoneinfo/src/main/res/drawable/dashboard_tool_background.xml b/myphoneinfo/src/main/res/drawable/dashboard_tool_background.xml deleted file mode 100644 index 64f1258..0000000 --- a/myphoneinfo/src/main/res/drawable/dashboard_tool_background.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/myphoneinfo/src/main/res/drawable/dashboard_top_background.xml b/myphoneinfo/src/main/res/drawable/dashboard_top_background.xml new file mode 100644 index 0000000..9f3a95c --- /dev/null +++ b/myphoneinfo/src/main/res/drawable/dashboard_top_background.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/myphoneinfo/src/main/res/drawable/dashboard_model_background_top.xml b/myphoneinfo/src/main/res/drawable/slide_item_background.xml similarity index 72% rename from myphoneinfo/src/main/res/drawable/dashboard_model_background_top.xml rename to myphoneinfo/src/main/res/drawable/slide_item_background.xml index f30b600..66fa06b 100644 --- a/myphoneinfo/src/main/res/drawable/dashboard_model_background_top.xml +++ b/myphoneinfo/src/main/res/drawable/slide_item_background.xml @@ -2,6 +2,6 @@ - + \ No newline at end of file diff --git a/myphoneinfo/src/main/res/font/alimama_heiti.ttf b/myphoneinfo/src/main/res/font/alimama_heiti.ttf new file mode 100644 index 0000000..854c844 Binary files /dev/null and b/myphoneinfo/src/main/res/font/alimama_heiti.ttf differ diff --git a/myphoneinfo/src/main/res/font/arimo.ttf b/myphoneinfo/src/main/res/font/arimo.ttf deleted file mode 100644 index c14e0a4..0000000 Binary files a/myphoneinfo/src/main/res/font/arimo.ttf and /dev/null differ diff --git a/myphoneinfo/src/main/res/font/bowl_byone.ttf b/myphoneinfo/src/main/res/font/bowl_byone.ttf deleted file mode 100644 index 2a37ce2..0000000 Binary files a/myphoneinfo/src/main/res/font/bowl_byone.ttf and /dev/null differ diff --git a/myphoneinfo/src/main/res/font/candal.ttf b/myphoneinfo/src/main/res/font/candal.ttf deleted file mode 100644 index d16c5d4..0000000 Binary files a/myphoneinfo/src/main/res/font/candal.ttf and /dev/null differ diff --git a/myphoneinfo/src/main/res/font/pingfang_bold.ttf b/myphoneinfo/src/main/res/font/pingfang_bold.ttf new file mode 100644 index 0000000..accaf1f Binary files /dev/null and b/myphoneinfo/src/main/res/font/pingfang_bold.ttf differ diff --git a/myphoneinfo/src/main/res/font/pingfang_heavy_0.ttf b/myphoneinfo/src/main/res/font/pingfang_heavy_0.ttf new file mode 100644 index 0000000..f4cf788 Binary files /dev/null and b/myphoneinfo/src/main/res/font/pingfang_heavy_0.ttf differ diff --git a/myphoneinfo/src/main/res/font/pingfang_regular.ttf b/myphoneinfo/src/main/res/font/pingfang_regular.ttf new file mode 100644 index 0000000..8790adb Binary files /dev/null and b/myphoneinfo/src/main/res/font/pingfang_regular.ttf differ diff --git a/myphoneinfo/src/main/res/font/semibold.ttf b/myphoneinfo/src/main/res/font/semibold.ttf deleted file mode 100644 index 23e4502..0000000 Binary files a/myphoneinfo/src/main/res/font/semibold.ttf and /dev/null differ diff --git a/myphoneinfo/src/main/res/layout/activity_main.xml b/myphoneinfo/src/main/res/layout/activity_main.xml index 88aa5fb..d41d129 100644 --- a/myphoneinfo/src/main/res/layout/activity_main.xml +++ b/myphoneinfo/src/main/res/layout/activity_main.xml @@ -22,84 +22,24 @@ app:layout_scrollFlags="scroll|exitUntilCollapsed"> + android:paddingHorizontal="15dp" + android:src="@mipmap/more_point" /> - - - - - - - - - - - @@ -129,127 +69,4 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> - - - - - - - - - - - - - - - - - - diff --git a/myphoneinfo/src/main/res/layout/activity_slide_in_pop_view.xml b/myphoneinfo/src/main/res/layout/activity_slide_in_pop_view.xml new file mode 100644 index 0000000..7c26067 --- /dev/null +++ b/myphoneinfo/src/main/res/layout/activity_slide_in_pop_view.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/myphoneinfo/src/main/res/layout/dashboard_module_bottom.xml b/myphoneinfo/src/main/res/layout/dashboard_module_bottom.xml index d44ffcd..87f72ac 100644 --- a/myphoneinfo/src/main/res/layout/dashboard_module_bottom.xml +++ b/myphoneinfo/src/main/res/layout/dashboard_module_bottom.xml @@ -1,162 +1,89 @@ - + android:paddingVertical="@dimen/dashboard_model_padding_vertical"> + + + android:paddingVertical="@dimen/dashboard_model_padding_vertical"> - + + - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/myphoneinfo/src/main/res/layout/dashboard_module_center.xml b/myphoneinfo/src/main/res/layout/dashboard_module_center.xml index 76ab825..1b9c50f 100644 --- a/myphoneinfo/src/main/res/layout/dashboard_module_center.xml +++ b/myphoneinfo/src/main/res/layout/dashboard_module_center.xml @@ -11,48 +11,88 @@ android:id="@+id/relayout_battery" android:layout_width="0dp" android:layout_height="wrap_content" - android:background="@drawable/dashboard_model_background_left_top" + android:background="@drawable/dashboard_model_background_right_bottom" + android:paddingHorizontal="@dimen/each_item_padding_horizontal" + android:paddingVertical="@dimen/each_item_padding_horizontal" + app:layout_constraintHorizontal_weight="1" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + + + + + + + + - - - + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toBottomOf="@id/relayout_battery"> - - - - + + android:layout_toEndOf="@+id/icon_storage" + android:layout_marginStart="@dimen/each_item_padding_horizontal" + android:orientation="vertical"> + + + + @@ -60,31 +100,32 @@ android:id="@+id/relayout_network" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/common_module_interval_small" - android:background="@drawable/dashboard_model_background_right_top" + android:background="@drawable/dashboard_model_background_right_bottom" android:paddingHorizontal="@dimen/dashboard_model_padding_horizontal" android:paddingVertical="@dimen/dashboard_model_padding_vertical" app:layout_constraintHorizontal_weight="1" - app:layout_constraintLeft_toRightOf="@id/relayout_battery" - app:layout_constraintRight_toRightOf="parent" - app:layout_constraintTop_toTopOf="@id/relayout_battery"> + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toLeftOf="@+id/relayout_ram" + app:layout_constraintTop_toTopOf="@id/relayout_ram"> + android:src="@mipmap/top_grey_more" /> - - + + + + + + + + + + + + app:layout_constraintRight_toLeftOf="@id/relayout_apps" + app:layout_constraintTop_toBottomOf="@id/relayout_network" + > + + + + + + + + + + + + + android:src="@mipmap/top_grey_more" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/myphoneinfo/src/main/res/layout/dashboard_module_cpu.xml b/myphoneinfo/src/main/res/layout/dashboard_module_cpu.xml index f6985fd..88d7415 100644 --- a/myphoneinfo/src/main/res/layout/dashboard_module_cpu.xml +++ b/myphoneinfo/src/main/res/layout/dashboard_module_cpu.xml @@ -5,6 +5,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginTop="@dimen/dashboard_model_padding_horizontal" android:orientation="vertical"> + android:src="@mipmap/top_grey_more" /> + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/myphoneinfo/src/main/res/layout/fragment_dashboard.xml b/myphoneinfo/src/main/res/layout/fragment_dashboard.xml index bbc7fcb..338131b 100644 --- a/myphoneinfo/src/main/res/layout/fragment_dashboard.xml +++ b/myphoneinfo/src/main/res/layout/fragment_dashboard.xml @@ -20,15 +20,17 @@ android:paddingHorizontal="@dimen/dashboard_fragment_padding_horizontal" android:paddingVertical="@dimen/dashboard_fragment_padding_vertical"> - + android:id="@+id/layout_top" + layout="@layout/dashboard_module_top" /> + #7F7F7F #1E8C29 #FFFFFF - #EDEDED + #f4f4f4 #3B948A #626262 #757575 @@ -15,4 +15,9 @@ #757575 #2B2B2B #B1B1B1 + + + #F8F8F8 + #76B4AD + #FFD54F \ No newline at end of file diff --git a/myphoneinfo/src/main/res/values/dimens.xml b/myphoneinfo/src/main/res/values/dimens.xml index e90d92f..f5e679f 100644 --- a/myphoneinfo/src/main/res/values/dimens.xml +++ b/myphoneinfo/src/main/res/values/dimens.xml @@ -15,9 +15,9 @@ 10dp 0dp - 8dp - 15dp - 8dp + 16dp + 8dp + 10dp 10dp @@ -26,7 +26,10 @@ 8dp - 5dp + 10dp 7dp 10dp + + 14dp + 16dp \ No newline at end of file diff --git a/myphoneinfo/src/main/res/values/styles.xml b/myphoneinfo/src/main/res/values/styles.xml index e500a08..1770d7f 100644 --- a/myphoneinfo/src/main/res/values/styles.xml +++ b/myphoneinfo/src/main/res/values/styles.xml @@ -6,19 +6,14 @@ false 14sp - - + @@ -26,14 +21,14 @@ 23sp @color/dialog_value_color bold - @font/arimo + @font/pingfang_heavy_0 @@ -52,14 +47,14 @@ @@ -67,7 +62,7 @@ @@ -147,7 +142,7 @@ @@ -155,26 +150,26 @@ @@ -190,13 +185,13 @@ @@ -210,4 +205,35 @@ false stateAlwaysHidden + + + + + + + + + + + + \ No newline at end of file