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

Commit a7f86420 authored by sssemil's avatar sssemil Committed by Abhisek Devkota
Browse files

Update location tile(1/2)

Uncheking all sets to old(default) mode

Change-Id: I5a05d7ebd3f83043763c2d157b6d1ef1643ef1cf
parent 44af4824
Loading
Loading
Loading
Loading
+37 −13
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@ import com.android.systemui.statusbar.phone.QuickSettingsController;
import com.android.systemui.statusbar.policy.LocationController;
import com.android.systemui.statusbar.policy.LocationController.LocationSettingsChangeCallback;

import java.util.Arrays;


public class GPSTile extends QuickSettingsTile implements LocationSettingsChangeCallback {
    private LocationController mLocationController;
@@ -98,20 +96,46 @@ public class GPSTile extends QuickSettingsTile implements LocationSettingsChange
    }

    private void toggleState() {
        if (mLocatorsMode == 0) {
            int newMode;

            switch (mCurrentMode) {
                case Settings.Secure.LOCATION_MODE_BATTERY_SAVING:
                    newMode = Settings.Secure.LOCATION_MODE_HIGH_ACCURACY;
                    break;
                case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY:
                    newMode = Settings.Secure.LOCATION_MODE_BATTERY_SAVING;
                    break;
                case Settings.Secure.LOCATION_MODE_OFF:
                    newMode = Settings.Secure.LOCATION_MODE_SENSORS_ONLY;
                    break;
                case Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
                    newMode = Settings.Secure.LOCATION_MODE_OFF;
                    break;
                default:
                    newMode = Settings.Secure.LOCATION_MODE_OFF;
            }

            Settings.Secure.putIntForUser(mContext.getContentResolver(),
                    Settings.Secure.LOCATION_MODE, newMode, UserHandle.USER_CURRENT);
        } else {
            int locatorIndex = mLocatorsIndex;
        int mask = 0;
            int mask;
            do {
                locatorIndex++;
                if (locatorIndex >= LOCATORS.length) {
                    locatorIndex = 0;
                }
                mask = (int) Math.pow(2, locatorIndex);
        } while (mLocatorsMode > 1 && (mLocatorsMode & mask) != mask); // Off is always preset
            }
            while ((mLocatorsMode & mask) != mask);

            // Set the desired state
            Settings.Secure.putIntForUser(mContext.getContentResolver(),
                    Settings.Secure.LOCATION_MODE, LOCATORS[locatorIndex], UserHandle.USER_CURRENT);
        }
    }


    private int currentModeToLocatorIndex(int mode) {
        int count = LOCATORS.length;