diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..ee9f695
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/top/jiecs/screener/MainActivity.kt b/app/src/main/java/top/jiecs/screener/MainActivity.kt
index 3900686..a1eea9a 100644
--- a/app/src/main/java/top/jiecs/screener/MainActivity.kt
+++ b/app/src/main/java/top/jiecs/screener/MainActivity.kt
@@ -12,6 +12,7 @@ import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
+import com.google.android.material.color.DynamicColors
import com.google.android.material.snackbar.Snackbar
import rikka.shizuku.Shizuku
diff --git a/app/src/main/java/top/jiecs/screener/ui/displaymode/DisplayModeDialogFragment.kt b/app/src/main/java/top/jiecs/screener/ui/displaymode/DisplayModeDialogFragment.kt
new file mode 100644
index 0000000..4e07a93
--- /dev/null
+++ b/app/src/main/java/top/jiecs/screener/ui/displaymode/DisplayModeDialogFragment.kt
@@ -0,0 +1,28 @@
+package top.jiecs.screener.ui.displaymode
+
+import android.app.Dialog
+import android.content.DialogInterface
+import android.os.Bundle
+import androidx.appcompat.app.AlertDialog
+import androidx.fragment.app.DialogFragment
+import com.google.android.material.dialog.MaterialAlertDialogBuilder
+import top.jiecs.screener.R
+import top.jiecs.screener.units.ApiCaller
+
+class DisplayModeDialogFragment : DialogFragment() {
+ private lateinit var dialog: AlertDialog
+
+ override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
+ isCancelable = false
+ dialog = MaterialAlertDialogBuilder(requireContext())
+ .setTitle(getString(R.string.display_modes))
+ .setMessage(getString(R.string.reset_hint))
+ .setPositiveButton(getString(R.string.looks_fine), null)
+ .setNegativeButton(getString(R.string.undo_changes)) { _: DialogInterface, _: Int ->
+ val apiCaller = ApiCaller()
+ apiCaller.resetResolution(0)
+ }
+ .create()
+ return dialog
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/top/jiecs/screener/ui/displaymode/DisplayModeFragment.kt b/app/src/main/java/top/jiecs/screener/ui/displaymode/DisplayModeFragment.kt
index 5ac555c..e2f33a9 100644
--- a/app/src/main/java/top/jiecs/screener/ui/displaymode/DisplayModeFragment.kt
+++ b/app/src/main/java/top/jiecs/screener/ui/displaymode/DisplayModeFragment.kt
@@ -1,12 +1,20 @@
package top.jiecs.screener.ui.displaymode
+import android.annotation.SuppressLint
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
+import android.view.Menu
+import android.view.MenuInflater
+import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
+import androidx.appcompat.widget.PopupMenu
+import androidx.core.view.MenuHost
+import androidx.core.view.MenuProvider
+import androidx.lifecycle.Lifecycle
import top.jiecs.screener.R
/**
@@ -26,6 +34,31 @@ class DisplayModeFragment : Fragment() {
adapter = DisplayModeRecyclerViewAdapter(DisplayModeContent.DISPLAY_MODES)
}
}
+
+ // The usage of an interface lets you inject your own implementation
+ val menuHost: MenuHost = requireActivity()
+
+ // Add menu items without using the Fragment Menu APIs
+ // Note how we can tie the MenuProvider to the viewLifecycleOwner
+ // and an optional Lifecycle.State (here, RESUMED) to indicate when
+ // the menu should be visible
+ menuHost.addMenuProvider(object : MenuProvider {
+ override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
+ // Add menu items here
+ menuInflater.inflate(R.menu.display_mode_action_menu, menu)
+ }
+
+ override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
+ // Handle the menu selection
+ return when (menuItem.itemId) {
+ R.id.new_display_mode -> {
+ // dialog to add a new display mode
+ true
+ }
+ else -> false
+ }
+ }
+ }, viewLifecycleOwner, Lifecycle.State.RESUMED)
return view
}
}
\ No newline at end of file
diff --git a/app/src/main/java/top/jiecs/screener/ui/resolution/ResolutionFragment.kt b/app/src/main/java/top/jiecs/screener/ui/resolution/ResolutionFragment.kt
index 4852a82..f8a8b8b 100644
--- a/app/src/main/java/top/jiecs/screener/ui/resolution/ResolutionFragment.kt
+++ b/app/src/main/java/top/jiecs/screener/ui/resolution/ResolutionFragment.kt
@@ -42,7 +42,7 @@ class ResolutionFragment : Fragment() {
private val userId: Int
get() {
val usersList = resolutionViewModel.usersList.value ?: return 0
- val checkedChipId = binding.chipGroup.checkedChipId
+ val checkedChipId = binding.resolution_editor.chipGroup.checkedChipId
val user = usersList.getOrNull(checkedChipId - 1) ?: return 0
return user["id"] as Int
diff --git a/app/src/main/java/top/jiecs/screener/ui/settings/SettingsFragment.kt b/app/src/main/java/top/jiecs/screener/ui/settings/SettingsFragment.kt
index 26f9262..6ac49d5 100644
--- a/app/src/main/java/top/jiecs/screener/ui/settings/SettingsFragment.kt
+++ b/app/src/main/java/top/jiecs/screener/ui/settings/SettingsFragment.kt
@@ -1,6 +1,8 @@
package top.jiecs.screener.ui.settings
import android.os.Bundle
+import android.view.Menu
+import android.view.MenuInflater
import androidx.preference.PreferenceFragmentCompat
import top.jiecs.screener.R
diff --git a/app/src/main/res/drawable/baseline_add_24.xml b/app/src/main/res/drawable/baseline_add_24.xml
new file mode 100644
index 0000000..89633bb
--- /dev/null
+++ b/app/src/main/res/drawable/baseline_add_24.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/layout/fragment_display_mode_item.xml b/app/src/main/res/layout/fragment_display_mode_item.xml
index c0c9512..18c4b92 100644
--- a/app/src/main/res/layout/fragment_display_mode_item.xml
+++ b/app/src/main/res/layout/fragment_display_mode_item.xml
@@ -1,8 +1,9 @@
-
-
\ No newline at end of file
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:text="3200x1440 @ 520dpi" />
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_resolution.xml b/app/src/main/res/layout/fragment_resolution.xml
index 86463af..f0ef703 100644
--- a/app/src/main/res/layout/fragment_resolution.xml
+++ b/app/src/main/res/layout/fragment_resolution.xml
@@ -1,124 +1,47 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:id="@+id/text_resolution"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="18dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginEnd="18dp"
+ android:textSize="20sp"
+ app:layout_constraintTop_toTopOf="parent" />
+
+
+ android:id="@+id/bt_apply"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:text="@string/apply"
+ app:layout_constraintStart_toStartOf="@+id/text_resolution"
+ app:layout_constraintTop_toBottomOf="@+id/resolution_editor" />
+ android:id="@+id/bt_reset"
+ style="?attr/materialButtonOutlinedStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:text="@string/reset"
+ app:layout_constraintStart_toEndOf="@+id/bt_apply"
+ app:layout_constraintTop_toTopOf="@+id/bt_apply" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/resolution_editor.xml b/app/src/main/res/layout/resolution_editor.xml
new file mode 100644
index 0000000..c0d7d59
--- /dev/null
+++ b/app/src/main/res/layout/resolution_editor.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/display_mode_action_menu.xml b/app/src/main/res/menu/display_mode_action_menu.xml
new file mode 100644
index 0000000..1d5ed97
--- /dev/null
+++ b/app/src/main/res/menu/display_mode_action_menu.xml
@@ -0,0 +1,10 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 742c8ba..8857523 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -24,6 +24,7 @@
Display Modes
+ New Display Mode
Quick Settings
Show in Notification
Show in QS Panel