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

Commit a616ca5b authored by Suphon Thanakornpakapong's avatar Suphon Thanakornpakapong
Browse files

Expose weather widget as a custom widget

parent 891d8189
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
package foundation.e.blisslauncher.features.weather;

import android.appwidget.AppWidgetProvider;

public class WeatherAppWidgetProvider extends AppWidgetProvider {
}
+21 −0
Original line number Diff line number Diff line
package foundation.e.blisslauncher.features.weather;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.RemoteViews;

import foundation.e.blisslauncher.R;
import foundation.e.blisslauncher.core.customviews.RoundedWidgetView;

public class WeatherWidgetHostView extends RoundedWidgetView {

    public WeatherWidgetHostView(Context context) {
        super(context);
        LayoutInflater.from(context).inflate(R.layout.layout_weather_info, this);
    }

    @Override
    public void updateAppWidget(RemoteViews remoteViews) {
        // do nothing
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -169,5 +169,14 @@
        <meta-data
            android:name="android.nfc.disable_beam_default"
            android:value="true" />

        <receiver android:name="foundation.e.blisslauncher.features.weather.WeatherAppWidgetProvider"
            android:exported="false">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data android:name="android.appwidget.provider"
                android:resource="@xml/weather_appwidget_info" />
        </receiver>
    </application>
</manifest>
+10 −0
Original line number Diff line number Diff line
@@ -3,16 +3,26 @@ package foundation.e.blisslauncher.core.customviews;
import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
import android.content.Context;

import foundation.e.blisslauncher.features.weather.WeatherAppWidgetProvider;
import foundation.e.blisslauncher.features.weather.WeatherWidgetHostView;

public class WidgetHost extends AppWidgetHost {

    private ComponentName mWeatherWidgetProvider;

    public WidgetHost(Context context, int hostId) {
        super(context, hostId);
        mWeatherWidgetProvider = new ComponentName(context, WeatherAppWidgetProvider.class);
    }

    @Override
    protected AppWidgetHostView onCreateView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget) {
        if (appWidget.provider.equals(mWeatherWidgetProvider)) {
            return new WeatherWidgetHostView(context);
        }
        return new RoundedWidgetView(context);
    }

+0 −2
Original line number Diff line number Diff line
@@ -2,8 +2,6 @@
<foundation.e.blisslauncher.features.weather.WeatherInfoView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:layout_marginBottom="8dp"
    android:clipChildren="true"
    android:clipToPadding="true"
    android:orientation="vertical">
Loading