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

Commit 9ba2de56 authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Merge "Port power widget improvements from CM7 to CM9." into ics

parents 964474de 8367b648
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -140,4 +140,5 @@
    <string name="gps_notification_searching_text" msgid="8574247005642736060">"GPS wird gesucht"</string>
    <string name="gps_notification_found_text" msgid="4619274244146446464">"Standort durch GPS festgelegt"</string>
    <string name="accessibility_clear_all" msgid="5235938559247164925">"Alle Benachrichtigungen löschen"</string>
    <string name="powerwidget_screen_timeout_toast">Bildschirm-Timeout ist jetzt %1$d %2$s</string>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -403,4 +403,6 @@
    <string name="navbar_menu_conditional_button">Menu (autoHide) button</string>
    <string name="navbar_menu_always_button">Menu (alwaysShow) button</string>
    <string name="navbar_menu_big_button">Menu button</string>

    <string name="powerwidget_screen_timeout_toast">Screen timeout set to: %1$d %2$s</string>
</resources>
+1 −2
Original line number Diff line number Diff line
@@ -401,7 +401,6 @@ public class PhoneStatusBar extends StatusBar {


        mPowerWidget = (PowerWidget)expanded.findViewById(R.id.exp_power_stat);
        mPowerWidget.setupSettingsObserver(mHandler);
        mPowerWidget.setGlobalButtonOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        if(Settings.System.getInt(mContext.getContentResolver(),
@@ -612,7 +611,7 @@ public class PhoneStatusBar extends StatusBar {
        StatusBarIconView view = new StatusBarIconView(mContext, slot, null);
        view.set(icon);
        mStatusIcons.addView(view, viewIndex, new LinearLayout.LayoutParams(mIconSize, mIconSize));
	mPowerWidget.updateWidget();
	mPowerWidget.updateAllButtons();
    }

    public void updateIcon(String slot, int index, int viewIndex,
+6 −7
Original line number Diff line number Diff line
@@ -21,8 +21,8 @@ public class AirplaneButton extends PowerButton {
    public AirplaneButton() { mType = BUTTON_AIRPLANE; }

    @Override
    protected void updateState() {
        if (getState(mView.getContext())) {
    protected void updateState(Context context) {
        if (getState(context)) {
            mIcon = R.drawable.stat_airplane_on;
            mState = STATE_ENABLED;
        } else {
@@ -32,8 +32,7 @@ public class AirplaneButton extends PowerButton {
    }

    @Override
    protected void toggleState() {
        Context context = mView.getContext();
    protected void toggleState(Context context) {
        boolean state = getState(context);
        Settings.System.putInt(context.getContentResolver(),
            Settings.System.AIRPLANE_MODE_ON, state ? 0 : 1);
@@ -45,11 +44,11 @@ public class AirplaneButton extends PowerButton {
    }

    @Override
    protected boolean handleLongClick() {
    protected boolean handleLongClick(Context context) {
        Intent intent = new Intent("android.settings.AIRPLANE_MODE_SETTINGS");
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mView.getContext().startActivity(intent);
        context.startActivity(intent);
        return true;
    }

@@ -58,7 +57,7 @@ public class AirplaneButton extends PowerButton {
        return OBSERVED_URIS;
    }

    private static boolean getState(Context context) {
    private boolean getState(Context context) {
        return Settings.System.getInt(context.getContentResolver(),
                 Settings.System.AIRPLANE_MODE_ON,0) == 1;
    }
+9 −9
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@ public class AutoRotateButton extends PowerButton {
    public AutoRotateButton() { mType = BUTTON_AUTOROTATE; }

    @Override
    protected void updateState() {
        if (getAutoRotation()) {
    protected void updateState(Context context) {
        if (getAutoRotation(context)) {
            mIcon = R.drawable.stat_orientation_on;
            mState = STATE_ENABLED;
        } else {
@@ -39,16 +39,16 @@ public class AutoRotateButton extends PowerButton {
    }

    @Override
    protected void toggleState() {
        setAutoRotation(!getAutoRotation());
    protected void toggleState(Context context) {
        setAutoRotation(!getAutoRotation(context));
    }

    @Override
    protected boolean handleLongClick() {
    protected boolean handleLongClick(Context context) {
        Intent intent = new Intent("android.settings.DISPLAY_SETTINGS");
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mView.getContext().startActivity(intent);
        context.startActivity(intent);
        return true;
    }

@@ -57,9 +57,9 @@ public class AutoRotateButton extends PowerButton {
        return OBSERVED_URIS;
    }

    private boolean getAutoRotation() {
        ContentResolver cr = mView.getContext().getContentResolver();
        return 0 != Settings.System.getInt(cr, Settings.System.ACCELEROMETER_ROTATION, 0);
    private boolean getAutoRotation(Context context) {
        ContentResolver cr = context.getContentResolver();
        return Settings.System.getInt(cr, Settings.System.ACCELEROMETER_ROTATION, 0) != 0;
    }

    private void setAutoRotation(final boolean autorotate) {
Loading