Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/WeatherController.java→core/java/com/android/internal/util/cm/WeatherController.java +6 −2 Original line number Diff line number Diff line /* * Copyright (C) 2014 The CyanogenMod Project * Copyright (C) 2015 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -14,7 +14,9 @@ * limitations under the License. */ package com.android.systemui.statusbar.policy; package com.android.internal.util.cm; import android.graphics.drawable.Drawable; public interface WeatherController { void addCallback(Callback callback); Loading @@ -28,5 +30,7 @@ public interface WeatherController { public String temp = null; public String city = null; public String condition = null; public int conditionCode = 0; public Drawable conditionDrawable = null; } } packages/SystemUI/src/com/android/systemui/statusbar/policy/WeatherControllerImpl.java→core/java/com/android/internal/util/cm/WeatherControllerImpl.java +21 −7 Original line number Diff line number Diff line /* * Copyright (C) 2014 The CyanogenMod Project * Copyright (C) 2015 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -14,19 +14,18 @@ * limitations under the License. */ package com.android.systemui.statusbar.policy; package com.android.internal.util.cm; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.database.ContentObserver; import android.content.pm.PackageManager; import android.content.res.Resources; import android.database.Cursor; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Handler; import android.provider.Settings; import android.util.Log; import java.util.ArrayList; Loading @@ -48,8 +47,10 @@ public class WeatherControllerImpl implements WeatherController { public static final String[] WEATHER_PROJECTION = new String[]{ "temperature", "city", "condition" "condition", "condition_code" }; public static final String LOCK_CLOCK_PACKAGE_NAME = "com.cyanogenmod.lockclock"; private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>(); private final Receiver mReceiver = new Receiver(); Loading Loading @@ -79,6 +80,17 @@ public class WeatherControllerImpl implements WeatherController { mCallbacks.remove(callback); } private Drawable getIcon(int conditionCode) { try { Resources resources = mContext.createPackageContext(LOCK_CLOCK_PACKAGE_NAME, 0).getResources(); return resources.getDrawable(resources.getIdentifier("weather_" + conditionCode, "drawable", LOCK_CLOCK_PACKAGE_NAME)); } catch (PackageManager.NameNotFoundException e) { return null; } } @Override public WeatherInfo getWeatherInfo() { return mCachedInfo; Loading @@ -96,6 +108,8 @@ public class WeatherControllerImpl implements WeatherController { mCachedInfo.temp = c.getString(0); mCachedInfo.city = c.getString(1); mCachedInfo.condition = c.getString(2); mCachedInfo.conditionCode = c.getInt(3); mCachedInfo.conditionDrawable = getIcon(mCachedInfo.conditionCode); } finally { c.close(); } Loading packages/Keyguard/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" /> <uses-permission android:name="android.permission.ACCESS_KEYGUARD_SECURE_STORAGE" /> <uses-permission android:name="android.permission.TRUST_LISTENER" /> <uses-permission android:name="com.cyanogenmod.lockclock.permission.READ_WEATHER" /> <application android:label="@string/app_name" android:process="com.android.systemui" Loading packages/Keyguard/res/layout/keyguard_status_view.xml +18 −8 Original line number Diff line number Diff line Loading @@ -34,6 +34,12 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal|top" android:orientation="vertical" > <LinearLayout android:id="@+id/keyguard_clock_and_weather_container" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:orientation="horizontal" > <TextClock android:id="@+id/clock_view" android:layout_width="wrap_content" Loading @@ -46,6 +52,10 @@ android:format24Hour="@string/keyguard_widget_24_hours_format" android:layout_marginBottom="@dimen/bottom_text_spacing_digital" /> <include layout="@layout/keyguard_weather_view" /> </LinearLayout> <include layout="@layout/keyguard_status_area" /> <TextView android:id="@+id/owner_info" Loading packages/Keyguard/res/layout/keyguard_weather_view.xml 0 → 100644 +56 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ** ** Copyright 2015, The CyanogenMod Project ** ** Licensed under the Apache License, Version 2.0 (the "License") ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ --> <!-- This is a view that shows general weather information in Keyguard. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/keyguard_weather_view" android:layout_centerHorizontal="true" android:layout_gravity="bottom" android:paddingBottom="14dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:id="@+id/weather_image" android:scaleType="centerCrop" android:layout_width="wrap_content" android:layout_marginBottom="-10dp" android:layout_height="wrap_content" /> <TextView android:textColor="@color/clock_white" android:textSize="16sp" android:layout_gravity="center_horizontal" android:includeFontPadding="false" android:id="@+id/temperature" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:textColor="@color/clock_white" android:textSize="16sp" android:layout_gravity="center_horizontal" android:includeFontPadding="false" android:visibility="gone" android:id="@+id/city" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> No newline at end of file Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/WeatherController.java→core/java/com/android/internal/util/cm/WeatherController.java +6 −2 Original line number Diff line number Diff line /* * Copyright (C) 2014 The CyanogenMod Project * Copyright (C) 2015 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -14,7 +14,9 @@ * limitations under the License. */ package com.android.systemui.statusbar.policy; package com.android.internal.util.cm; import android.graphics.drawable.Drawable; public interface WeatherController { void addCallback(Callback callback); Loading @@ -28,5 +30,7 @@ public interface WeatherController { public String temp = null; public String city = null; public String condition = null; public int conditionCode = 0; public Drawable conditionDrawable = null; } }
packages/SystemUI/src/com/android/systemui/statusbar/policy/WeatherControllerImpl.java→core/java/com/android/internal/util/cm/WeatherControllerImpl.java +21 −7 Original line number Diff line number Diff line /* * Copyright (C) 2014 The CyanogenMod Project * Copyright (C) 2015 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -14,19 +14,18 @@ * limitations under the License. */ package com.android.systemui.statusbar.policy; package com.android.internal.util.cm; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.database.ContentObserver; import android.content.pm.PackageManager; import android.content.res.Resources; import android.database.Cursor; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Handler; import android.provider.Settings; import android.util.Log; import java.util.ArrayList; Loading @@ -48,8 +47,10 @@ public class WeatherControllerImpl implements WeatherController { public static final String[] WEATHER_PROJECTION = new String[]{ "temperature", "city", "condition" "condition", "condition_code" }; public static final String LOCK_CLOCK_PACKAGE_NAME = "com.cyanogenmod.lockclock"; private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>(); private final Receiver mReceiver = new Receiver(); Loading Loading @@ -79,6 +80,17 @@ public class WeatherControllerImpl implements WeatherController { mCallbacks.remove(callback); } private Drawable getIcon(int conditionCode) { try { Resources resources = mContext.createPackageContext(LOCK_CLOCK_PACKAGE_NAME, 0).getResources(); return resources.getDrawable(resources.getIdentifier("weather_" + conditionCode, "drawable", LOCK_CLOCK_PACKAGE_NAME)); } catch (PackageManager.NameNotFoundException e) { return null; } } @Override public WeatherInfo getWeatherInfo() { return mCachedInfo; Loading @@ -96,6 +108,8 @@ public class WeatherControllerImpl implements WeatherController { mCachedInfo.temp = c.getString(0); mCachedInfo.city = c.getString(1); mCachedInfo.condition = c.getString(2); mCachedInfo.conditionCode = c.getInt(3); mCachedInfo.conditionDrawable = getIcon(mCachedInfo.conditionCode); } finally { c.close(); } Loading
packages/Keyguard/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" /> <uses-permission android:name="android.permission.ACCESS_KEYGUARD_SECURE_STORAGE" /> <uses-permission android:name="android.permission.TRUST_LISTENER" /> <uses-permission android:name="com.cyanogenmod.lockclock.permission.READ_WEATHER" /> <application android:label="@string/app_name" android:process="com.android.systemui" Loading
packages/Keyguard/res/layout/keyguard_status_view.xml +18 −8 Original line number Diff line number Diff line Loading @@ -34,6 +34,12 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal|top" android:orientation="vertical" > <LinearLayout android:id="@+id/keyguard_clock_and_weather_container" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:orientation="horizontal" > <TextClock android:id="@+id/clock_view" android:layout_width="wrap_content" Loading @@ -46,6 +52,10 @@ android:format24Hour="@string/keyguard_widget_24_hours_format" android:layout_marginBottom="@dimen/bottom_text_spacing_digital" /> <include layout="@layout/keyguard_weather_view" /> </LinearLayout> <include layout="@layout/keyguard_status_area" /> <TextView android:id="@+id/owner_info" Loading
packages/Keyguard/res/layout/keyguard_weather_view.xml 0 → 100644 +56 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ** ** Copyright 2015, The CyanogenMod Project ** ** Licensed under the Apache License, Version 2.0 (the "License") ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ --> <!-- This is a view that shows general weather information in Keyguard. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/keyguard_weather_view" android:layout_centerHorizontal="true" android:layout_gravity="bottom" android:paddingBottom="14dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:id="@+id/weather_image" android:scaleType="centerCrop" android:layout_width="wrap_content" android:layout_marginBottom="-10dp" android:layout_height="wrap_content" /> <TextView android:textColor="@color/clock_white" android:textSize="16sp" android:layout_gravity="center_horizontal" android:includeFontPadding="false" android:id="@+id/temperature" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:textColor="@color/clock_white" android:textSize="16sp" android:layout_gravity="center_horizontal" android:includeFontPadding="false" android:visibility="gone" android:id="@+id/city" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> No newline at end of file