Skip to content

Commit

Permalink
add setting for widget transparency #94
Browse files Browse the repository at this point in the history
  • Loading branch information
woheller69 committed Sep 12, 2024
1 parent 87a66a9 commit 479f43e
Show file tree
Hide file tree
Showing 20 changed files with 347 additions and 305 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static void updateView(Context context, AppWidgetManager appWidgetManager
SQLiteHelper dbHelper = SQLiteHelper.getInstance(context);

SharedPreferences prefManager = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());

views.setFloat(R.id.widget_background,"setAlpha", (100.0f - prefManager.getInt("pref_WidgetTransparency", 0)) /100.0f);
if (prefManager.getBoolean("pref_TimeFormat", true)==TRUE)
views.setCharSequence(R.id.textClockTime,"setFormat12Hour","HH:mm");
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public static void updateView(Context context, AppWidgetManager appWidgetManager
views.setTextViewText(R.id.widget_max_Temp,StringFormatUtils.formatTemperature(context, weekforecasts.get(0).getMaxTemperature()));
views.setTextViewText(R.id.widget_min_Temp,StringFormatUtils.formatTemperature(context, weekforecasts.get(0).getMinTemperature()));
views.setTextViewText(R.id.widget_city_name, city.getCityName());
views.setFloat(R.id.widget_background,"setAlpha", (100.0f - prefManager.getInt("pref_WidgetTransparency", 0)) /100.0f);

if (riseTime==zoneseconds*1000 || setTime==zoneseconds*1000) views.setTextViewText(R.id.widget_sunrise_sunset,"\u2600\u25b2 --:--" + " \u25bc --:--");
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.widget.RemoteViews;
Expand All @@ -30,6 +31,8 @@
import static androidx.core.app.JobIntentService.enqueueWork;
import static org.woheller69.weather.services.UpdateDataService.SKIP_UPDATE_INTERVAL;

import androidx.preference.PreferenceManager;

public class WeatherWidget5day extends AppWidgetProvider {

public void updateAppWidget(Context context, final int appWidgetId) {
Expand All @@ -49,7 +52,8 @@ public void updateAppWidget(Context context, final int appWidgetId) {


public static void updateView(Context context, AppWidgetManager appWidgetManager, RemoteViews views, int appWidgetId, CityToWatch city, List<WeekForecast> weekforecasts) {

SharedPreferences prefManager = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
views.setFloat(R.id.widget_background,"setAlpha", (100.0f - prefManager.getInt("pref_WidgetTransparency", 0)) /100.0f);
int cityId=getWidgetCityID(context);
SQLiteHelper database = SQLiteHelper.getInstance(context.getApplicationContext());
int zonemilliseconds = database.getCurrentWeatherByCityId(cityId).getTimeZoneSeconds()*1000;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/weather_widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
android:layout_marginBottom="5dp"
android:paddingTop="4dp"
android:text="CityName"
android:textColor="@color/colorPrimaryDark"
android:textColor="@color/lightgrey"
android:textSize="18dp"
android:textStyle="bold" />

Expand All @@ -189,7 +189,7 @@
android:layout_marginEnd="8dp"
android:paddingBottom="6dp"
android:text="Weather data by Open-Meteo.com"
android:textColor="@color/colorPrimaryDark"
android:textColor="@color/lightgrey"
android:textSize="15dp" />

<TextView
Expand Down
Loading

0 comments on commit 479f43e

Please sign in to comment.