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

Unverified Commit 0eb9e705 authored by d34d's avatar d34d Committed by Michael Bestas
Browse files

Keyguard: Get your weather on... the lock screen [1/3]

Change-Id: Ieed59aa488a0a26fa9fc27bd77cbdc6156baac68
parent dcdad04d
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|top"
        android:orientation="vertical" >

        <TextClock
            android:id="@+id/clock_view"
            android:layout_width="wrap_content"
@@ -47,6 +48,19 @@
            android:layout_marginBottom="@dimen/bottom_text_spacing_digital" />

        <include layout="@layout/keyguard_status_area" />

        <TextView android:id="@+id/weather_info"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:textColor="@color/clock_white"
            style="@style/widget_label"
            android:textAllCaps="true"
            android:letterSpacing="0.15"
            android:gravity="center"
            android:singleLine="true"
            android:visibility="gone"/>

        <TextView
            android:id="@+id/owner_info"
            android:layout_marginLeft="16dp"
+4 −0
Original line number Diff line number Diff line
@@ -26,6 +26,10 @@
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

     <!-- Weather Provider -->
    <uses-permission android:name="cyanogenmod.permission.READ_WEATHER" />
    <protected-broadcast android:name="com.cyanogenmod.lockclock.action.FORCE_WEATHER_UPDATE" />

    <application>

        <activity-alias
+3 −0
Original line number Diff line number Diff line
@@ -49,4 +49,7 @@
    <!-- Play queue -->
    <string name="play_queue_extension">Show play queue</string>

    <!-- Weather string format in keyguard -->
    <string name="keyguard_status_view_weather_format"><xliff:g id="temp">%1$s</xliff:g> <xliff:g id="condition">%2$s</xliff:g></string>

</resources>
+39 −1
Original line number Diff line number Diff line
@@ -68,9 +68,12 @@ import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
import com.android.systemui.statusbar.policy.WeatherController;
import com.android.systemui.statusbar.policy.WeatherControllerImpl;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.StackStateAnimator;
import cyanogenmod.providers.CMSettings;
import cyanogenmod.weather.util.WeatherUtils;

import java.util.List;

@@ -80,7 +83,7 @@ public class NotificationPanelView extends PanelView implements
        ExpandableView.OnHeightChangedListener,
        View.OnClickListener, NotificationStackScrollLayout.OnOverscrollTopChangedListener,
        KeyguardAffordanceHelper.Callback, NotificationStackScrollLayout.OnEmptySpaceClickListener,
        HeadsUpManager.OnHeadsUpChangedListener {
        HeadsUpManager.OnHeadsUpChangedListener, WeatherController.Callback {

    private static final boolean DEBUG = false;

@@ -224,6 +227,10 @@ public class NotificationPanelView extends PanelView implements
    private int mStatusBarHeaderHeight;
    private GestureDetector mDoubleTapGesture;

    private boolean mKeyguardWeatherEnabled;
    private TextView mKeyguardWeatherInfo;
    private WeatherControllerImpl mWeatherController;

    public NotificationPanelView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setWillNotDraw(!DEBUG);
@@ -245,6 +252,11 @@ public class NotificationPanelView extends PanelView implements
        mStatusBar = bar;
    }

    public void setWeatherController(WeatherControllerImpl weatherController) {
        mWeatherController = weatherController;
        mWeatherController.addCallback(this);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
@@ -290,6 +302,8 @@ public class NotificationPanelView extends PanelView implements
                mNotificationStackScroller.setQsContainer(mQsContainer);
            }
        });

        mKeyguardWeatherInfo = (TextView) mKeyguardStatusView.findViewById(R.id.weather_info);
    }

    @Override
@@ -383,6 +397,7 @@ public class NotificationPanelView extends PanelView implements
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        mSettingsObserver.unobserve();
        mWeatherController.removeCallback(this);
    }

    private void startQsSizeChangeAnimation(int oldHeight, final int newHeight) {
@@ -2417,6 +2432,19 @@ public class NotificationPanelView extends PanelView implements
        mGroupManager = groupManager;
    }

    @Override
    public void onWeatherChanged(WeatherController.WeatherInfo info) {
        if (!mKeyguardWeatherEnabled || Double.isNaN(info.temp) || info.condition == null) {
            mKeyguardWeatherInfo.setVisibility(GONE);
        } else {
            mKeyguardWeatherInfo.setText(mContext.getString(
                    R.string.keyguard_status_view_weather_format,
                    WeatherUtils.formatTemperature(info.temp, info.tempUnit),
                    info.condition));
            mKeyguardWeatherInfo.setVisibility(VISIBLE);
        }
    }

    class SettingsObserver extends ContentObserver {
        SettingsObserver(Handler handler) {
            super(handler);
@@ -2428,6 +2456,8 @@ public class NotificationPanelView extends PanelView implements
                    CMSettings.System.STATUS_BAR_QUICK_QS_PULLDOWN), false, this);
            resolver.registerContentObserver(CMSettings.System.getUriFor(
                    CMSettings.System.DOUBLE_TAP_SLEEP_GESTURE), false, this);
            resolver.registerContentObserver(CMSettings.Secure.getUriFor(
                    CMSettings.Secure.LOCK_SCREEN_WEATHER_ENABLED), false, this);
            update();
        }

@@ -2452,6 +2482,14 @@ public class NotificationPanelView extends PanelView implements
                    resolver, CMSettings.System.STATUS_BAR_QUICK_QS_PULLDOWN, 1);
            mDoubleTapToSleepEnabled = CMSettings.System.getInt(
                    resolver, CMSettings.System.DOUBLE_TAP_SLEEP_GESTURE, 1) == 1;

            boolean wasKeyguardWeatherEnabled = mKeyguardWeatherEnabled;
            mKeyguardWeatherEnabled = CMSettings.Secure.getInt(
                    resolver, CMSettings.Secure.LOCK_SCREEN_WEATHER_ENABLED, 0) == 1;
            if (mWeatherController != null
                    && wasKeyguardWeatherEnabled != mKeyguardWeatherEnabled) {
                onWeatherChanged(mWeatherController.getWeatherInfo());
            }
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -1192,6 +1192,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        }


        mNotificationPanel.setWeatherController(mWeatherController);

        PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mBroadcastReceiver.onReceive(mContext,
                new Intent(pm.isScreenOn() ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF));