Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds option to disable widget background #166

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private void readPreferences(@NonNull JsonReader reader, @NonNull Context contex
case "":
pref.edit().putBoolean(name, reader.nextBoolean()).apply();
break;
case "showWidgetBackground":
case "widgetChoice1":
case "widgetChoice2":
case "widgetChoice3":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ public String convertToCurrentSpeedUnit(float speedInMetersPerSecond) {
}
}

public boolean getShowWidgetBackground() {
return preferences.getBoolean("showWidgetBackground", true);
}

public int get1dayWidgetInfo() {
return Integer.parseInt(preferences.getString("widgetChoice4", "1"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public static void updateView(Context context, AppWidgetManager appWidgetManager

views.setImageViewResource(R.id.widget_city_weather_image_view, UiResourceProvider.getIconResourceForWeatherCategory(weatherData.getWeatherID(), isDay));

views.setInt(R.id.widget1day_layout, "setBackgroundResource", prefManager.getShowWidgetBackground() ? R.drawable.rounded_corner_dark : 0);

Intent intent = new Intent(context, ForecastCityActivity.class);
intent.putExtra("cityId", city.getCityId());
PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, intent, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public static void updateView(Context context, AppWidgetManager appWidgetManager
views.setImageViewResource(R.id.widget_city_weather_5day_image4, UiResourceProvider.getIconResourceForWeatherCategory((int) data[3][9], true));
views.setImageViewResource(R.id.widget_city_weather_5day_image5, UiResourceProvider.getIconResourceForWeatherCategory((int) data[4][9], true));

views.setInt(R.id.widget5day_layout, "setBackgroundResource", prefManager.getShowWidgetBackground() ? R.drawable.rounded_corner_dark : 0);

Intent intent = new Intent(context, ForecastCityActivity.class);
intent.putExtra("cityId", city.getCityId());
PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, intent, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public static void updateView(Context context, AppWidgetManager appWidgetManager
views.setImageViewResource(R.id.widget_city_weather_1day_image4, UiResourceProvider.getIconResourceForWeatherCategory((int) data[3][5], true));
views.setImageViewResource(R.id.widget_city_weather_1day_image5, UiResourceProvider.getIconResourceForWeatherCategory((int) data[4][5], true));

views.setInt(R.id.widget1day_layout, "setBackgroundResource", prefManager.getShowWidgetBackground() ? R.drawable.rounded_corner_dark : 0);

Intent intent = new Intent(context, ForecastCityActivity.class);
intent.putExtra("cityId", city.getCityId());
PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, intent, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public static void updateView(Context context, AppWidgetManager appWidgetManager
views.setImageViewResource(R.id.widget_city_weather_3day_image2, UiResourceProvider.getIconResourceForWeatherCategory((int) data[1][9], true));
views.setImageViewResource(R.id.widget_city_weather_3day_image3, UiResourceProvider.getIconResourceForWeatherCategory((int) data[2][9], true));

views.setInt(R.id.widget3day_layout, "setBackgroundResource", prefManager.getShowWidgetBackground() ? R.drawable.rounded_corner_dark : 0);

Intent intent = new Intent(context, ForecastCityActivity.class);
intent.putExtra("cityId", city.getCityId());
PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, intent, 0);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,5 @@
<string name="help_permission_bindservice_heading">Berechtigung: An Job-Service binden</string>
<string name="help_permission_wakelock_description">Um asynchrone Aktualisierungsanforderungen zu ermöglichen und gleichzeitig die App reaktionsfähig zu halten, wird die Wakelock-Berechtigung benötigt. Die Hintergrundaufgaben in Wetter sind nicht lang und werden Ihr Telefon nicht für lange Zeit wach halten. Aber die Berechtigung wird benötigt, um Hintergrunddienste auf diese Weise auszuführen.</string>
<string name="help_permission_bindservice_description">Die Wetter-App ermöglicht Backups mit unserer Privacy Friendly Backup-App. Um diese Funktionalität zu aktivieren, wird die Berechtigung zum Verbinden mit Diensten benötigt.</string>
<string name="showWidgetBackground">Hintergrund anzeigen</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,5 @@
<string name="help_permission_bindservice_heading">Autorizzazione: Legare al servizio di lavoro</string>
<string name="help_permission_wakelock_description">Per abilitare le richieste di aggiornamento asincrone mantenendo l\'app reattiva, è necessario il permesso Wakelock. I compiti in background di Weather non sono lunghi e non terranno il telefono sveglio per molto tempo. Ma il permesso è necessario per eseguire i servizi in background in questo modo.</string>
<string name="help_permission_bindservice_description">L\'app meteo abilita i backup con la nostra app Privacy Friendly Backup. Per abilitare questa funzionalità, è necessario il permesso di legarsi ai servizi.</string>
<string name="showWidgetBackground">Show background</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,6 @@
<string name="help_permission_bindservice_heading">Permission: Bind to Job Service</string>
<string name="help_permission_wakelock_description">To enable asynchronous update requests while keeping the app responsive, the Wakelock permission is needed. The background tasks in weather are not long and will not keep your phone awake for long times. But the permission is needed to run background services in this way.</string>
<string name="help_permission_bindservice_description">The weather app enables backups with our Privacy Friendly Backup app. To enable this functionality, the permission to bind with services is needed.</string>
<string name="showWidgetBackground">Show background</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,5 @@
<string name="help_permission_bindservice_heading">Autorização: Ligar ao Serviço de Emprego</string>
<string name="help_permission_wakelock_description">Para permitir pedidos de actualização assíncrona enquanto se mantém a resposta do aplicativo, é necessária a permissão Wakelock. As tarefas de fundo no tempo não são longas e não irão manter o telefone acordado durante muito tempo. Mas a permissão é necessária para executar serviços de fundo desta forma.</string>
<string name="help_permission_bindservice_description">A aplicação meteorológica permite cópias de segurança com a nossa aplicação Privacy Friendly Backup. Para activar esta funcionalidade, é necessária a permissão de ligação com serviços.</string>
<string name="showWidgetBackground">Show background</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<string name="settings_title_API_key_reset">Reset API Key</string>

<string name="widgets_settings">Widgets</string>
<string name="showWidgetBackground">Show background</string>
<string name="fivedaywidgetchoice">Set the additional information for 5-day widgets at the bottom.</string>
<string name="fivedaywidget">5-day widget</string>
<string name="threedaywidgetchoice_one">Set the first additional information for 3-day widgets at the bottom.</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/xml/pref_general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
</PreferenceCategory>

<PreferenceCategory android:title="@string/widgets_settings">
<CheckBoxPreference
android:defaultValue="true"
android:key="showWidgetBackground"
android:title="@string/showWidgetBackground" />
<ListPreference
android:defaultValue="1"
android:entries="@array/widgetChoiceArray"
Expand Down