mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 13:26:50 +01:00
Fix crash if Catima is not installed
This commit is contained in:
parent
fea3bf50a4
commit
3516099dc9
@ -131,9 +131,12 @@ public class LoyaltyCardsSettingsFragment extends PreferenceFragmentCompat {
|
||||
return true;
|
||||
});
|
||||
|
||||
if (catimaInstalled) {
|
||||
// Ensure the currently selected value is actually an installed Catima package
|
||||
if (StringUtils.isNullOrEmpty(catimaPackage.getValue()) || !installedCatimaPackages.contains(catimaPackage.getValue())) {
|
||||
catimaPackage.setValue(installedCatimaPackages.get(0).toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (installedCatimaPackages.size() <= 1) {
|
||||
catimaPackage.setVisible(false);
|
||||
@ -172,10 +175,9 @@ public class LoyaltyCardsSettingsFragment extends PreferenceFragmentCompat {
|
||||
}
|
||||
|
||||
final boolean permissionGranted = ContextCompat.checkSelfPermission(requireContext(), CatimaContentProvider.PERMISSION_READ_CARDS) == PackageManager.PERMISSION_GRANTED;
|
||||
if (catimaInstalled) {
|
||||
final Preference catimaPermissions = findPreference(LOYALTY_CARDS_CATIMA_PERMISSIONS);
|
||||
if (catimaPermissions != null) {
|
||||
catimaPermissions.setVisible(!permissionGranted);
|
||||
catimaPermissions.setVisible(catimaInstalled && !permissionGranted);
|
||||
catimaPermissions.setOnPreferenceClickListener(preference -> {
|
||||
ActivityCompat.requestPermissions(
|
||||
requireActivity(),
|
||||
@ -185,7 +187,6 @@ public class LoyaltyCardsSettingsFragment extends PreferenceFragmentCompat {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
final boolean catimaCompatible = catima != null && catima.isCatimaCompatible();
|
||||
final Preference catimaNotCompatible = findPreference(LOYALTY_CARDS_CATIMA_NOT_COMPATIBLE);
|
||||
|
Loading…
Reference in New Issue
Block a user