Skip to content

Commit

Permalink
Show Toast if no API key is set
Browse files Browse the repository at this point in the history
  • Loading branch information
woheller69 committed Jan 22, 2022
1 parent 8ad9f1d commit c07f9ba
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.widget.Toast;

import org.woheller69.weather.BuildConfig;
import org.woheller69.weather.R;
Expand Down Expand Up @@ -133,6 +136,7 @@ public String getDistanceUnit(Context applicationContext) {
public String getOWMApiKey(Context context){
String prefValue = preferences.getString("API_key_value", BuildConfig.DEFAULT_API_KEY);
if (prefValue.equals(context.getString(R.string.settings__API_key_default))) {
new Handler(Looper.getMainLooper()).post(() -> Toast.makeText(context, context.getResources().getString(R.string.settings_title_API_key), Toast.LENGTH_LONG).show());
return BuildConfig.DEFAULT_API_KEY;
} else {
return prefValue;
Expand Down

0 comments on commit c07f9ba

Please sign in to comment.