Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes when entering settings #219

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading