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

Commit d1c5d1ad authored by Nate Myren's avatar Nate Myren
Browse files

Update subtext for Restricted Preferences when blocked by ECM

When the ECM block is due to a phone call, they should display
"Unavailable during phone call".

Bug: 364535720
Relnote: none
Flag: EXEMPT minor string change
Test: manual
Change-Id: I5342f46a39c417ff7b5bfff9fa3b3b836a2db9ca
parent e4615cb5
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ interface BlockedByAdmin : RestrictedMode {

interface BlockedByEcm : RestrictedMode {
    fun showRestrictedSettingsDetails()
    fun isBlockedByPhoneCall() = false
}

internal data class BlockedByAdminImpl(
@@ -72,8 +73,13 @@ internal data class BlockedByEcmImpl(
    private val context: Context,
    private val intent: Intent,
) : BlockedByEcm {
    private val reasonPhoneState = "phone_state"

    override fun showRestrictedSettingsDetails() {
        context.startActivity(intent)
    }

    override fun isBlockedByPhoneCall(): Boolean {
        return intent.getStringExtra(Intent.EXTRA_REASON) == reasonPhoneState
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -163,9 +163,11 @@ internal class RestrictedSwitchPreferenceModel(

                is BlockedByAdmin ->
                    restrictedMode.getSummary(checkedIfBlockedByAdmin ?: checkedIfNoRestricted())
                is BlockedByEcm ->
                is BlockedByEcm -> if (restrictedMode.isBlockedByPhoneCall()) {
                    context.getString(com.android.settingslib.R.string.disabled_in_phone_call_text)
                } else {
                    context.getString(com.android.settingslib.R.string.disabled)

                }
                null -> context.getPlaceholder()
            }
        }
+2 −0
Original line number Diff line number Diff line
@@ -1228,6 +1228,8 @@

    <!-- Summary for settings preference disabled by app ops [CHAR LIMIT=50] -->
    <string name="disabled_by_app_ops_text">Controlled by Restricted Setting</string>
    <!-- Summary for settings preference disabled while the device is in a phone call [CHAR LIMIT=50] -->
    <string name="disabled_in_phone_call_text">Unavailable during calls</string>

    <!-- [CHAR LIMIT=25] Manage applications, text telling using an application is disabled. -->
    <string name="disabled">Disabled</string>
+13 −2
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ import androidx.preference.PreferenceViewHolder;
public class RestrictedPreferenceHelper {
    private static final String TAG = "RestrictedPreferenceHelper";

    private static final String REASON_PHONE_STATE = "phone_state";

    private final Context mContext;
    private final Preference mPreference;
    String packageName;
@@ -121,7 +123,7 @@ public class RestrictedPreferenceHelper {
                if (mDisabledByAdmin) {
                    summaryView.setText(disabledText);
                } else if (mDisabledByEcm) {
                    summaryView.setText(R.string.disabled_by_app_ops_text);
                    summaryView.setText(getEcmTextResId());
                } else if (TextUtils.equals(disabledText, summaryView.getText())) {
                    // It's previously set to disabled text, clear it.
                    summaryView.setText(null);
@@ -323,7 +325,16 @@ public class RestrictedPreferenceHelper {
        }

        if (!isEnabled && mDisabledByEcm) {
            mPreference.setSummary(R.string.disabled_by_app_ops_text);
            mPreference.setSummary(getEcmTextResId());
        }
    }

    private int getEcmTextResId() {
        if (mDisabledByEcmIntent != null && REASON_PHONE_STATE.equals(
                mDisabledByEcmIntent.getStringExtra(Intent.EXTRA_REASON))) {
            return R.string.disabled_in_phone_call_text;
        } else {
            return R.string.disabled_by_app_ops_text;
        }
    }