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

Commit 69d62c0e authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add new config to combine unavailable and unknown option" am: a176870d am: 42ffe8be

parents 50bb4d06 42ffe8be
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;