FlashControl: Show toast when QS and app data not in sync

This commit is contained in:
roynatech2544
2023-05-24 06:53:19 +09:00
parent d23aed6283
commit 7691208108
2 changed files with 3 additions and 0 deletions

View File

@@ -19,6 +19,7 @@
<!-- Tests, Infos -->
<string name="flash_current_intesity">Current brightness intesity: %d</string>
<string name="flash_current_on">Flash is currently %s</string>
<string name="use_app_flash">Use app\'s switch to control flashlight on/off while testing</string>
<!-- On Off -->
<string name="on">On</string>

View File

@@ -22,6 +22,7 @@ import android.os.Bundle
import android.os.ServiceManager
import android.provider.Settings
import android.util.Log
import android.widget.Toast
import android.widget.Switch
import androidx.preference.Preference
@@ -83,6 +84,7 @@ class FlashFragment : PreferenceFragmentCompat(), OnMainSwitchChangeListener {
mService.enableFlash(isChecked)
} catch (e : IllegalStateException) {
Log.e(TAG, "enableFlash() failed", e)
Toast.makeText(requireContext(), R.string.use_app_flash, Toast.LENGTH_SHORT).show()
return
}
mCurrentOn.title = String.format(requireContext().getString(R.string.flash_current_on), requireContext().getString(if (isChecked) R.string.on else R.string.off))