Skip to content

Commit

Permalink
Fix crashes when entering settings
Browse files Browse the repository at this point in the history
Likely from #209
  • Loading branch information
d4rken committed Jul 12, 2024
1 parent 02f6882 commit 8a46437
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.View
import androidx.annotation.Keep
import androidx.fragment.app.viewModels
import androidx.preference.Preference
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import eu.darken.capod.R
Expand All @@ -27,17 +26,6 @@ class SupportFragment : PreferenceFragment3() {

@Inject lateinit var clipboardHelper: ClipboardHelper

private val installIdPref by lazy { findPreference<Preference>("support.installid")!! }

override fun onPreferencesCreated() {
installIdPref.setOnPreferenceClickListener {
vm.copyInstallID()
true
}

super.onPreferencesCreated()
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
vm.clipboardEvent.observe2(this) { installId ->
Snackbar.make(requireView(), installId, Snackbar.LENGTH_INDEFINITE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import android.view.View
import androidx.annotation.Keep
import androidx.fragment.app.viewModels
import androidx.lifecycle.asLiveData
import androidx.preference.CheckBoxPreference
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.TwoStatePreference
import dagger.hilt.android.AndroidEntryPoint
import eu.darken.capod.R
import eu.darken.capod.common.bluetooth.BluetoothDevice2
Expand Down Expand Up @@ -51,17 +51,17 @@ class ReactionSettingsFragment : PreferenceFragment3() {

override fun onPreferenceTreeClick(preference: Preference): Boolean {
if (preference.key == reactionSettings.autoPlay.key && !isPro) {
preference as CheckBoxPreference
preference as TwoStatePreference
upgradeRepo.launchBillingFlow(requireActivity())
preference.isChecked = false
return true
} else if (preference.key == reactionSettings.autoPause.key && !isPro) {
preference as CheckBoxPreference
preference as TwoStatePreference
upgradeRepo.launchBillingFlow(requireActivity())
preference.isChecked = false
return true
} else if (preference.key == reactionSettings.autoConnect.key) {
preference as CheckBoxPreference
preference as TwoStatePreference

if (!isPro) {
upgradeRepo.launchBillingFlow(requireActivity())
Expand All @@ -79,12 +79,12 @@ class ReactionSettingsFragment : PreferenceFragment3() {
return true
}
} else if (preference.key == reactionSettings.showPopUpOnCaseOpen.key && !isPro) {
preference as CheckBoxPreference
preference as TwoStatePreference
upgradeRepo.launchBillingFlow(requireActivity())
preference.isChecked = false
return true
} else if (preference.key == reactionSettings.showPopUpOnConnection.key && !isPro) {
preference as CheckBoxPreference
preference as TwoStatePreference
upgradeRepo.launchBillingFlow(requireActivity())
preference.isChecked = false
return true
Expand Down
18 changes: 1 addition & 17 deletions app/src/main/res/xml/preferences_support.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<eu.darken.capod.common.preferences.IntentPreference
android:icon="@drawable/ic_discord_onsurface"
android:summary="@string/discord_description"
Expand All @@ -18,19 +17,4 @@
android:data="https://github.com/d4rken-org/capod/issues" />
</eu.darken.capod.common.preferences.IntentPreference>

<!-- Hide Install-ID and bug reporting settings, but keep for possible use in the future.
<PreferenceCategory app:title="@string/settings_category_other_label">
<Preference
android:icon="@drawable/ic_id_onsurface"
android:key="support.installid"
android:summary="@string/settings_support_installid_desc"
android:title="@string/settings_support_installid_label" />
<CheckBoxPreference
android:icon="@drawable/ic_spider_thread_onsurface"
android:key="debug.bugreport.automatic.enabled"
android:summary="@string/settings_debug_autoreports_description"
android:title="@string/settings_debug_autoreports_label" />
</PreferenceCategory>
-->
</PreferenceScreen>

0 comments on commit 8a46437

Please sign in to comment.