Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3850e76e authored by Liu Qiong's avatar Liu Qiong Committed by Håkan Gustavsson
Browse files

Add new config to combine unavailable and unknown option

Add a new config for device to combine the block options for
"unavailable" and "unknown" callers options.

Test: Manual; verified that toggling the option to combine the unknown
and unavailable options updates the shared prefs for both.
Bug: 249340131

Change-Id: Id4999c1a71a237096edc895b6f5dbd1aa23c3dc5
parent f979b23c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -73,4 +73,8 @@
    <!-- When set, Telecom will attempt to bind to the {@link CallDiagnosticService} implementation
         defined by the app with this package name. -->
    <string name="call_diagnostic_service_package_name"></string>

    <!-- When true, the options in the call blocking settings to block unavailable and unknown
     callers are combined into a single toggle. -->
    <bool name="combine_options_to_block_unavailable_and_unknown_callers">true</bool>
</resources>
+23 −10
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ public class EnhancedCallBlockingFragment extends PreferenceFragment
    private static final String BLOCK_UNAVAILABLE_NUMBERS_KEY =
            "block_unavailable_calls_setting";
    private boolean mIsCombiningRestrictedAndUnknownOption = false;
    private boolean mIsCombiningUnavailableAndUnknownOption = false;

    @Override
    public void onCreate(Bundle savedInstanceState) {
@@ -94,11 +95,17 @@ public class EnhancedCallBlockingFragment extends PreferenceFragment
                        R.bool.combine_options_to_block_restricted_and_unknown_callers);
        if (mIsCombiningRestrictedAndUnknownOption) {
            Preference restricted_pref = findPreference(BLOCK_RESTRICTED_NUMBERS_KEY);
            Preference unavailable_pref = findPreference(BLOCK_UNAVAILABLE_NUMBERS_KEY);
            screen.removePreference(restricted_pref);
            screen.removePreference(unavailable_pref);
            Log.i(this, "onCreate: removed block restricted preference.");
        }

        mIsCombiningUnavailableAndUnknownOption = getResources().getBoolean(
                R.bool.combine_options_to_block_unavailable_and_unknown_callers);
        if (mIsCombiningUnavailableAndUnknownOption) {
            Preference unavailable_pref = findPreference(BLOCK_UNAVAILABLE_NUMBERS_KEY);
            screen.removePreference(unavailable_pref);
            Log.i(this, "onCreate: removed block unavailable preference.");
        }
    }

    /**
@@ -136,15 +143,21 @@ public class EnhancedCallBlockingFragment extends PreferenceFragment

    @Override
    public boolean onPreferenceChange(Preference preference, Object objValue) {
        if (mIsCombiningRestrictedAndUnknownOption
                && preference.getKey().equals(BLOCK_UNKNOWN_NUMBERS_KEY)) {
        if (preference.getKey().equals(BLOCK_UNKNOWN_NUMBERS_KEY)) {
            if (mIsCombiningRestrictedAndUnknownOption) {
                Log.i(this, "onPreferenceChange: changing %s and %s to %b",
                        preference.getKey(), BLOCK_RESTRICTED_NUMBERS_KEY, (boolean) objValue);
            BlockedNumbersUtil.setEnhancedBlockSetting(getActivity(), BLOCK_RESTRICTED_NUMBERS_KEY,
                    (boolean) objValue);
                BlockedNumbersUtil.setEnhancedBlockSetting(getActivity(),
                        BLOCK_RESTRICTED_NUMBERS_KEY, (boolean) objValue);
            }

            if (mIsCombiningUnavailableAndUnknownOption) {
                Log.i(this, "onPreferenceChange: changing %s and %s to %b",
                        preference.getKey(), BLOCK_UNAVAILABLE_NUMBERS_KEY, (boolean) objValue);
                BlockedNumbersUtil.setEnhancedBlockSetting(getActivity(),
                        BLOCK_UNAVAILABLE_NUMBERS_KEY, (boolean) objValue);
            }
        }
        BlockedNumbersUtil.setEnhancedBlockSetting(getActivity(), preference.getKey(),
                (boolean) objValue);
        return true;