@@ -8,10 +8,8 @@ import android.os.Bundle
88import android.view.View
99import androidx.activity.viewModels
1010import androidx.appcompat.app.AppCompatActivity
11- import com.google.android.material.dialog.MaterialAlertDialogBuilder
1211import dagger.hilt.android.AndroidEntryPoint
1312import me.rosuh.easywatermark.BuildConfig
14- import me.rosuh.easywatermark.R
1513import me.rosuh.easywatermark.data.model.UserPreferences
1614import me.rosuh.easywatermark.databinding.ActivityAboutBinding
1715import me.rosuh.easywatermark.ui.dialog.ChangeLogDialogFragment
@@ -97,71 +95,15 @@ class AboutActivity : AppCompatActivity() {
9795 openLink(" https://tovi.fun/" )
9896 }
9997 ivBack.setOnClickListener { finish() }
100- }
101- }
10298
103- private fun showOutputDialog () {
104- MaterialAlertDialogBuilder (this @AboutActivity, R .style.ThemeOverlay_App_MaterialAlertDialog )
105- .setTitle(getString(R .string.dialog_out_put_title))
106- .setSingleChoiceItems(
107- arrayOf(" JPG 100%" , " JPG 95%" , " JPG 80%" , " PNG" ),
108- getSelectedFormatting(viewModel.userPreferences.value)
109- ) { _, which ->
110- when (which) {
111- 0 -> {
112- viewModel.saveOutput(Bitmap .CompressFormat .JPEG , 100 )
113- }
114- 1 -> {
115- viewModel.saveOutput(Bitmap .CompressFormat .JPEG , 95 )
116- }
117- 2 -> {
118- viewModel.saveOutput(Bitmap .CompressFormat .JPEG , 80 )
119- }
120- 3 -> {
121- viewModel.saveOutput(Bitmap .CompressFormat .PNG , 95 )
122- }
123- }
124- }
125- .setPositiveButton(R .string.tips_confirm_dialog) { dialog, _ ->
126- dialog.cancel()
99+ switchDebug.setOnCheckedChangeListener { _, isChecked ->
100+ viewModel.toggleBounds(isChecked)
127101 }
128- .setNegativeButton(R .string.tips_cancel_dialog) { dialog, _ ->
129- viewModel.saveOutput(viewModel.outputFormat, viewModel.compressLevel)
130- dialog.cancel()
131- }
132- .setCancelable(true )
133- .show()
134- }
135102
136- private fun getSelectedFormatting (config : UserPreferences ? ): Int {
137- if (config == null ) {
138- return 1
139- }
140- return when {
141- config.outputFormat == Bitmap .CompressFormat .PNG -> 3
142- config.compressLevel == 100 -> 0
143- config.compressLevel == 80 -> 2
144- else -> 1
145- }
146- }
147-
148- private fun trapFormattingValue (config : UserPreferences ? ): String {
149- if (config == null ) {
150- return " "
151- }
152- val format = when (config.outputFormat) {
153- Bitmap .CompressFormat .JPEG -> " JPG"
154- Bitmap .CompressFormat .PNG -> " PNG"
155- Bitmap .CompressFormat .WEBP -> " WEBP"
156- else -> {
157- " WEBP"
103+ viewModel.waterMark.observe(this @AboutActivity) {
104+ switchDebug.isChecked = viewModel.waterMark.value?.enableBounds ? : false
158105 }
159106 }
160- val value = if (config.outputFormat == Bitmap .CompressFormat .JPEG ) {
161- " ${config.compressLevel} %"
162- } else {
163- " "
164- }
165- return " $format$value "
166107 }
108+
167109}
0 commit comments