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

Commit e704fc0d authored by d34d's avatar d34d Committed by Gerrit Code Review
Browse files

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

Change-Id: Ieed59aa488a0a26fa9fc27bd77cbdc6156baac68
parent 6c769a70
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
@@ -271,4 +271,8 @@

    <!-- Path data for circle battery -->
    <string name="battery_circle_path" translatable="false">M 12 3.5 C 16.6944203736 3.5 20.5 7.30557962644 20.5 12 C 20.5 16.6944203736 16.6944203736 20.5 12 20.5 C 7.30557962644 20.5 3.5 16.6944203736 3.5 12 C 3.5 7.30557962644 7.30557962644 3.5 12 3.5 Z</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 −3
Original line number Diff line number Diff line
@@ -77,10 +77,13 @@ import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
import com.android.systemui.statusbar.policy.LiveLockScreenController;
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;

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

    private static final boolean DEBUG = false;

@@ -265,6 +268,11 @@ public class NotificationPanelView extends PanelView implements
    private ViewLinker mViewLinker;
    private final UnlockMethodCache mUnlockMethodCache;
    private boolean mDetailScrollLock;

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

    private enum SwipeLockedDirection {
        UNKNOWN,
        HORIZONTAL,
@@ -402,6 +410,11 @@ public class NotificationPanelView extends PanelView implements
        mLiveLockscreenController = liveController;
    }

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

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
@@ -504,6 +517,8 @@ public class NotificationPanelView extends PanelView implements
                }
            }
        });

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

    public boolean isAffordanceSwipeInProgress() {
@@ -521,6 +536,7 @@ public class NotificationPanelView extends PanelView implements
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        mSettingsObserver.unobserve();
        mWeatherController.removeCallback(this);
    }

    @Override
@@ -2749,6 +2765,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();
        }

@@ -2774,8 +2792,13 @@ public class NotificationPanelView extends PanelView implements
            mDoubleTapToSleepEnabled = CMSettings.System.getInt(
                    resolver, CMSettings.System.DOUBLE_TAP_SLEEP_GESTURE, 1) == 1;

            boolean liveLockScreenEnabled = CMSettings.Secure.getInt(
                    resolver, CMSettings.Secure.LIVE_LOCK_SCREEN_ENABLED, 0) == 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());
            }
        }
    }

@@ -2876,6 +2899,19 @@ public class NotificationPanelView extends PanelView implements
        }
    }

    @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);
        }
    }

    private class SlideInAnimationListener implements ValueAnimator.AnimatorUpdateListener,
            ValueAnimator.AnimatorListener {
        @Override
+2 −0
Original line number Diff line number Diff line
@@ -1328,6 +1328,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        mHeader.setNextAlarmController(mNextAlarmController);
        mHeader.setWeatherController(mWeatherController);

        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));