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

Commit 1031bb26 authored by alinasuarez's avatar alinasuarez
Browse files

TARE Global Toggle

Add functionality to the global toggle within the TARE homepage in the
developer settings. This allows for users and developers to turn these
settings on/off.

Bug: 195552339

Test: Manual (open Settings > System > Developer Options > TARE > turn
on/off the global toggle and leave and go back and make sure it is being
kept track of correctly)

Change-Id: Ifb8dee1aeb04d2b6883ee9e449ed8ab0493dc27a
parent 8db6e5ac
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ public class TareHomePage extends Activity {
    private Button mRevButton;
    private TextView mAlarmManagerView;
    private TextView mJobSchedulerView;
    private static final int SETTING_VALUE_OFF = 0;
    private static final int SETTING_VALUE_ON = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -51,14 +53,17 @@ public class TareHomePage extends Activity {
        mAlarmManagerView = findViewById(R.id.alarmmanager);
        mJobSchedulerView = findViewById(R.id.jobscheduler);

        // TODO: Set the status of the buttons based on the current status
        final boolean isTareEnabled = Settings.Global.getInt(getContentResolver(),
                Settings.Global.ENABLE_TARE, Settings.Global.DEFAULT_ENABLE_TARE) == 1;
        setEnabled(isTareEnabled);

        mOnSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mRevButton.setEnabled(isChecked);
                mAlarmManagerView.setEnabled(isChecked);
                mJobSchedulerView.setEnabled(isChecked);
                setEnabled(isChecked);
                Settings.Global.putInt(getContentResolver(),
                        Settings.Global.ENABLE_TARE,
                        isChecked ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
            }
        });
    }
@@ -84,4 +89,12 @@ public class TareHomePage extends Activity {
        i.putExtra(EXTRA_POLICY, POLICY_JOB_SCHEDULER);
        startActivity(i);
    }

    /** Changes the enabled state of the TARE homepage buttons based on global toggle */
    private void setEnabled(boolean tareStatus) {
        mRevButton.setEnabled(tareStatus);
        mAlarmManagerView.setEnabled(tareStatus);
        mJobSchedulerView.setEnabled(tareStatus);
        mOnSwitch.setChecked(tareStatus);
    }
}