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

Commit d855e463 authored by Adnan Begovic's avatar Adnan Begovic
Browse files

Keyguard: Create lockscreen weather, move weatherimpl to utils.

Change-Id: Ibf3fb8c877470ae152b778c9dc7bbf9aa6ae5f10
parent d0fb64be
Loading
Loading
Loading
Loading
+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.
@@ -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);
@@ -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;
    }
}
+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.
@@ -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;
@@ -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();
@@ -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;
@@ -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();
            }
+1 −0
Original line number Diff line number Diff line
@@ -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"
+18 −8
Original line number Diff line number Diff line
@@ -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"
@@ -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"
+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