diff --git a/app/src/main/java/com/lhw/pdf/MainActivity.kt b/app/src/main/java/com/lhw/pdf/MainActivity.kt
index 1b37877..87acc5d 100644
--- a/app/src/main/java/com/lhw/pdf/MainActivity.kt
+++ b/app/src/main/java/com/lhw/pdf/MainActivity.kt
@@ -24,6 +24,7 @@ import androidx.drawerlayout.widget.DrawerLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
+import com.google.android.material.chip.Chip
import com.lhw.pdf.databinding.ActivityMainBinding
import com.tom_roush.pdfbox.android.PDFBoxResourceLoader
import java.io.File
@@ -195,17 +196,16 @@ class MainActivity : AppCompatActivity() {
presentations.values.forEach {it.setScrollProgress(progress)}
}
- binding.appBarMain.contentMain.chipPages1.setOnCheckedChangeListener { _, checked -> if (checked) pagesPerLandscape = 1F }
- binding.appBarMain.contentMain.chipPages15.setOnCheckedChangeListener { _, checked -> if (checked) pagesPerLandscape = 1.5F }
- binding.appBarMain.contentMain.chipPages2.setOnCheckedChangeListener { _, checked -> if (checked) pagesPerLandscape = 2F }
- binding.appBarMain.contentMain.chipPages25.setOnCheckedChangeListener { _, checked -> if (checked) pagesPerLandscape = 2.5F }
- binding.appBarMain.contentMain.chipPages3.setOnCheckedChangeListener { _, checked -> if (checked) pagesPerLandscape = 3F }
- binding.appBarMain.contentMain.chipPages35.setOnCheckedChangeListener { _, checked -> if (checked) pagesPerLandscape = 3.5F }
- binding.appBarMain.contentMain.chipPages4.setOnCheckedChangeListener { _, checked -> if (checked) pagesPerLandscape = 4F }
- binding.appBarMain.contentMain.chipPages5.setOnCheckedChangeListener { _, checked -> if (checked) pagesPerLandscape = 5F }
- binding.appBarMain.contentMain.chipPages6.setOnCheckedChangeListener { _, checked -> if (checked) pagesPerLandscape = 6F }
- binding.appBarMain.contentMain.chipPages8.setOnCheckedChangeListener { _, checked -> if (checked) pagesPerLandscape = 8F }
- binding.appBarMain.contentMain.chipPages10.setOnCheckedChangeListener { _, checked -> if (checked) pagesPerLandscape = 10F }
+ val pageZoomLevels = arrayOf(1F, 1.5F, 2F, 2.5F, 3F, 3.5F, 4F, 5F, 6F, 8F, 10F)
+ val chipGroupPages = binding.appBarMain.contentMain.chipGroupPages
+ pageZoomLevels.forEach { pages ->
+ val chip = Chip(this)
+ chip.text = "$pages pages"
+ chip.isCheckable = true
+ chip.isChecked = (pages == pagesPerLandscape)
+ chip.setOnCheckedChangeListener { _, checked -> if (checked) pagesPerLandscape = pages }
+ chipGroupPages.addView(chip)
+ }
binding.appBarMain.contentMain.chipAutoCrop.setOnCheckedChangeListener { _, checked ->
renderAutoCrop = checked
updatePresentations()
diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml
index 4c58502..6b9201b 100644
--- a/app/src/main/res/layout/content_main.xml
+++ b/app/src/main/res/layout/content_main.xml
@@ -67,84 +67,6 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-