Skip to content

Commit

Permalink
[migration] migrates to onecall api 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
coderPaddyS committed May 27, 2024
1 parent 224ec9a commit dce6a85
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ android {
buildConfigField "String[]", "DEFAULT_API_KEYS", "{null}"
}

buildConfigField "String", "BASE_URL", "\"https://api.openweathermap.org/data/2.5/\""
buildConfigField "String", "BASE_URL", "\"https://api.openweathermap.org/data/3.0/\""

javaCompileOptions {
annotationProcessorOptions {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.secuso.privacyfriendlyweather.activities;

import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -19,6 +21,7 @@
import org.secuso.privacyfriendlyweather.database.data.CurrentWeatherData;
import org.secuso.privacyfriendlyweather.database.data.Forecast;
import org.secuso.privacyfriendlyweather.database.data.WeekForecast;
import org.secuso.privacyfriendlyweather.preferences.AppPreferencesManager;
import org.secuso.privacyfriendlyweather.ui.updater.IUpdateableCityUI;
import org.secuso.privacyfriendlyweather.ui.updater.ViewUpdater;
import org.secuso.privacyfriendlyweather.ui.viewPager.WeatherPagerAdapter;
Expand All @@ -27,6 +30,7 @@

public class ForecastCityActivity extends BaseActivity implements IUpdateableCityUI {
private WeatherPagerAdapter pagerAdapter;
private AppPreferencesManager appPreferencesManager;

private MenuItem refreshActionButton;
private MenuItem rainviewerButton;
Expand Down Expand Up @@ -73,7 +77,6 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_forecast_city);
overridePendingTransition(0, 0);

//cityId = getIntent().getIntExtra("cityId", -1); //done in onResume

initResources();
Expand Down Expand Up @@ -113,6 +116,18 @@ public void onPageScrollStateChanged(int state) {}
}
}

@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);

if (appPreferencesManager.getOWMApiKey(this) == null) {
new AlertDialog.Builder(this).setTitle("")
.setMessage("Get your own API-Key yo")
.setNeutralButton(android.R.string.ok, null)
.show();
}
}

public void updatePageTitle() {
if (getSupportActionBar() != null && pagerAdapter.getCount() > 0) {
getSupportActionBar().setTitle(pagerAdapter.getPageTitleForActionBar(viewPager.getCurrentItem()));
Expand All @@ -129,6 +144,7 @@ private void initResources() {
viewPager = findViewById(R.id.viewPager);
pagerAdapter = new WeatherPagerAdapter(this, getSupportFragmentManager());
noCityText = findViewById(R.id.noCitySelectedText);
appPreferencesManager = new AppPreferencesManager(PreferenceManager.getDefaultSharedPreferences(this));
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,6 @@
<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="owm_about">Wetterdaten zur Verfügung gestellt von:</string>
<string name="owm_logo_copyright">"Das OpenWeatherMap Logo ist lizensiert unter\n<a href="https://creativecommons.org/licenses/by-sa/3.0/deed.en">Creative Commons BY-SA.</a>"</string>
<string name="dialog_app_api_deprecation_title">App Deprecation and API changes</string>
<string name="dialog_app_api_deprecation_description">Am 1. Juni 2024 deaktiviert Open Weather seine alte API, daher sind die alten API-Schlüssel nicht mehr verwendbar.</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,6 @@
<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="owm_about">Dati meteo forniti da:</string>
<string name="owm_logo_copyright">"Il logo di OpenWeatherMap è concesso in licenza sotto\n<a href="https://creativecommons.org/licenses/by-sa/3.0/deed.en">la licenza Creative Commons BY-SA.</a>"</string>
<string name="dialog_app_api_deprecation_title">Deprecazione dell\'app e modifiche all\'API</string>
<string name="dialog_app_api_deprecation_description">Dal 1° giugno 2024 Open Weather disattiva la sua vecchia API, pertanto le vecchie chiavi API non sono più utilizzabili.</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,7 @@
<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="owm_about">Weather data provided by:</string>
<string name="owm_logo_copyright">"OpenWeatherMap logo is licensed under\n<a href="https://creativecommons.org/licenses/by-sa/3.0/deed.en">Creative Commons BY-SA license.</a>"</string>
<string name="dialog_app_api_deprecation_title">アプリの非推奨と API の変更</string>
<string name="dialog_app_api_deprecation_description">2024 年 6 月 1 日に、Open Weather は古い API を非アクティブ化するため、古い API キーは使用できなくなります。</string>

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,6 @@
<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="owm_about">Dados meteorológicos fornecidos por:</string>
<string name="owm_logo_copyright">"O logótipo OpenWeatherMap está licenciado sob\n<a href="https://creativecommons.org/licenses/by-sa/3.0/deed.en">Creative Commons BY-SA licença.</a>"</string>
<string name="dialog_app_api_deprecation_title">Descontinuação de aplicativos e alterações de API</string>
<string name="dialog_app_api_deprecation_description">Em 1º de junho de 2024, o Open Weather desativa sua API antiga, portanto, as chaves da API antigas não podem mais ser usadas.</string>
</resources>
8 changes: 8 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@
</string>
<string name="dialog_add_close_button">Close</string>
<string name="dialog_add_add_button">Add</string>
<string name="dialog_app_api_deprecation_title">App Deprecation and API changes</string>
<string name="dialog_app_api_deprecation_description">
On 1st June, 2024 Open Weather deactivates its old API, therefore the old api keys are not usable anymore.
As the Privacy Friendly Weather App is deprecated, we won\'t adjust to any api changes and the app won\'t function as expected.

If you want to continue using this app, get your own api key by following the <a href="https://openweathermap.org/appid">OpenWeather instruction</a>.
After obtaining your api key, set it in the settings.
</string>

<!-- ###WEATHER CATEGORIES### -->
<string name="weather_category_clear_sky">Clear Sky</string>
Expand Down

0 comments on commit dce6a85

Please sign in to comment.