Skip to content

Commit

Permalink
first cut at removing all non-wrapped toast.
Browse files Browse the repository at this point in the history
  • Loading branch information
rksh committed Oct 17, 2017
1 parent b43fe6e commit a261faf
Show file tree
Hide file tree
Showing 32 changed files with 111 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.google.android.gms.vision.barcode.Barcode;
import com.google.android.gms.vision.barcode.BarcodeDetector;

import net.wigle.wigleandroid.util.WiGLEToast;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.KeyStoreException;
Expand Down Expand Up @@ -86,8 +88,8 @@ private void launchBarcodeScanning() {
.setBarcodeFormats(Barcode.QR_CODE)
.build();
if (!barcodeDetector.isOperational()) {
Toast.makeText(this.getApplicationContext(),
"Barcode detection not available on this device", Toast.LENGTH_LONG);
//ALIBI: this *should* be unreachable, but the diversity of android devices and implementation can make this happen
WiGLEToast.showOverActivity(this, R.string.error_general, getString(R.string.no_barcode_support_text));
Log.e(LOG_TAG, "Barcode detection not available on this device.");
this.finish();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.wigle.wigleandroid.background.KmlWriter;
import net.wigle.wigleandroid.model.Pair;
import net.wigle.wigleandroid.model.QueryArgs;
import net.wigle.wigleandroid.util.WiGLEToast;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
Expand Down Expand Up @@ -146,7 +147,7 @@ public void onClick(final View buttonView) {

if (fail != null) {
// toast!
Toast.makeText(getActivity(), fail, Toast.LENGTH_SHORT).show();
WiGLEToast.showOverFragment(getActivity(), R.string.error_general, fail);
} else {
ListFragment.lameStatic.queryArgs = queryArgs;
// start db result activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,7 @@ private void setupPermissions() {
if (permissionsList.contains(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
message = mainActivity.getString(R.string.allow_storage);
}
// Show our own UI to explain to the user why we need to read the contacts
// before actually requesting the permission and showing the default UI
Toast.makeText(mainActivity, message, Toast.LENGTH_LONG).show();*/
} */

MainActivity.info("no permission for " + permissionsNeeded);

Expand Down Expand Up @@ -563,9 +559,6 @@ public void selectFragment(int position) {
} catch (final NullPointerException | IllegalStateException ex) {
final String message = "exception in fragment switch: " + ex;
error(message, ex);
if (!isFinishing()) {
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
}
}

// Highlight the selected item, update the title, and close the drawer
Expand Down Expand Up @@ -784,8 +777,6 @@ static void createConfirmation(final FragmentActivity activity, final String mes
} catch (final IllegalStateException ex) {
final String errorMessage = "Exception trying to show dialog: " + ex;
MainActivity.error(errorMessage, ex);
//TODO: in this static context, we can't check isFinishing
Toast.makeText(activity, errorMessage, Toast.LENGTH_LONG).show();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import net.wigle.wigleandroid.background.QueryThread;
import net.wigle.wigleandroid.model.ConcurrentLinkedHashMap;
import net.wigle.wigleandroid.model.Network;
import net.wigle.wigleandroid.util.WiGLEToast;

/**
* show a map!
Expand Down Expand Up @@ -144,10 +145,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
}
catch (final SecurityException ex) {
MainActivity.error("security exception oncreateview map: " + ex, ex);
Toast.makeText(getActivity(), getString(R.string.status_fail), Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(getActivity(), getString(R.string.map_needs_playservice), Toast.LENGTH_LONG).show();
WiGLEToast.showOverFragment(this.getActivity(), R.string.fatal_pre_message, getString(R.string.map_needs_playservice));
}
MapsInitializer.initialize(getActivity());
final View view = inflater.inflate(R.layout.map, container, false);
Expand Down Expand Up @@ -719,19 +719,19 @@ public void onMapReady(final GoogleMap googleMap) {
switch (newMapType) {
case GoogleMap.MAP_TYPE_NORMAL:
newMapType = GoogleMap.MAP_TYPE_SATELLITE;
Toast.makeText(getActivity(), getString(R.string.map_toast_satellite), Toast.LENGTH_SHORT).show();
WiGLEToast.showOverActivity(getActivity(), R.string.tab_map, getString(R.string.map_toast_satellite), Toast.LENGTH_SHORT);
break;
case GoogleMap.MAP_TYPE_SATELLITE:
newMapType = GoogleMap.MAP_TYPE_HYBRID;
Toast.makeText(getActivity(), getString(R.string.map_toast_hybrid), Toast.LENGTH_SHORT).show();
WiGLEToast.showOverActivity(getActivity(), R.string.tab_map, getString(R.string.map_toast_hybrid), Toast.LENGTH_SHORT);
break;
case GoogleMap.MAP_TYPE_HYBRID:
newMapType = GoogleMap.MAP_TYPE_TERRAIN;
Toast.makeText(getActivity(), getString(R.string.map_toast_terrain), Toast.LENGTH_SHORT).show();
WiGLEToast.showOverActivity(getActivity(), R.string.tab_map, getString(R.string.map_toast_terrain), Toast.LENGTH_SHORT);
break;
case GoogleMap.MAP_TYPE_TERRAIN:
newMapType = GoogleMap.MAP_TYPE_NORMAL;
Toast.makeText(getActivity(), getString(R.string.map_toast_normal), Toast.LENGTH_SHORT).show();
WiGLEToast.showOverActivity(getActivity(), R.string.tab_map, getString(R.string.map_toast_normal), Toast.LENGTH_SHORT);
break;
default:
MainActivity.error("unhandled mapType: " + newMapType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,13 @@ public void setContext(final FragmentActivity context) {
public void handleMessage( final Message msg ) {
synchronized ( lock ) {
if (msg.what == AUTHENTICATION_ERROR) {
Toast.makeText(this.context, R.string.status_login_fail
, Toast.LENGTH_LONG).show();
WiGLEToast.showOverActivity(this.context, R.string.error_general, context.getString(R.string.status_login_fail));
if (pp != null) {
pp.hide();
}
}
if (msg.what == CONNECTION_ERROR) {
Toast.makeText(this.context, R.string.no_wigle_conn
, Toast.LENGTH_LONG).show();
WiGLEToast.showOverActivity(this.context, R.string.error_general, context.getString(R.string.no_wigle_conn));
if (pp != null) {
pp.hide();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import net.wigle.wigleandroid.ListFragment;
import net.wigle.wigleandroid.MainActivity;
import net.wigle.wigleandroid.R;
import net.wigle.wigleandroid.util.WiGLEToast;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
Expand Down Expand Up @@ -232,7 +234,9 @@ else if ( newOK && NETWORK_PROVIDER.equals( newLocation.getProvider() ) ) {
if (!disableToast && null != mainActivity && !mainActivity.isFinishing()) {
final String announce = location == null ? mainActivity.getString(R.string.lost_location)
: mainActivity.getString(R.string.have_location) + " \"" + location.getProvider() + "\"";
Toast.makeText( mainActivity, announce, Toast.LENGTH_SHORT ).show();
if (null != mainActivity && ! mainActivity.isFinishing()) {
WiGLEToast.showOverActivity(mainActivity, "", announce);
}
}

final boolean speechGPS = prefs.getBoolean( ListFragment.PREF_SPEECH_GPS, true );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import net.wigle.wigleandroid.model.NetworkType;
import net.wigle.wigleandroid.FilterMatcher;
import net.wigle.wigleandroid.R;
import net.wigle.wigleandroid.util.WiGLEToast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -792,8 +794,9 @@ private boolean doWifiScan() {
if ( now - lastWifiUnjamTime > resetWifiPeriod ) {
final boolean disableToast = prefs.getBoolean(ListFragment.PREF_DISABLE_TOAST, false);
if (!disableToast && null != mainActivity && !mainActivity.isFinishing()) {
Toast.makeText( mainActivity,
mainActivity.getString(R.string.wifi_jammed), Toast.LENGTH_LONG ).show();
if (null != mainActivity && !mainActivity.isFinishing()) {
WiGLEToast.showOverActivity(mainActivity, R.string.error_general, mainActivity.getString(R.string.wifi_jammed));
}
}
scanInFlight = false;
try {
Expand Down Expand Up @@ -837,15 +840,17 @@ private boolean doWifiScan() {
if ( batteryKill > 0 && batteryLevel > 0 && batteryLevel <= batteryKill
&& batteryStatus != BatteryManager.BATTERY_STATUS_CHARGING
&& (System.currentTimeMillis() - constructionTime) > 30000L) {
final String text = mainActivity.getString(R.string.battery_at) + " " + batteryLevel + " "
if (null != mainActivity) {
final String text = mainActivity.getString(R.string.battery_at) + " " + batteryLevel + " "
+ mainActivity.getString(R.string.battery_postfix);
if (null != mainActivity && !mainActivity.isFinishing()) {
Toast.makeText(mainActivity, text, Toast.LENGTH_LONG).show();
if (!mainActivity.isFinishing()) {
WiGLEToast.showOverActivity(mainActivity, R.string.error_general, text);
}
MainActivity.warn("low battery, shutting down");
mainActivity.speak(text);
MainActivity.sleep(5000L);
mainActivity.finish();
}
MainActivity.warn("low battery, shutting down");
mainActivity.speak( text );
MainActivity.sleep(5000L);
mainActivity.finish();
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions wiglewifiwardriving/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,7 @@
<string name="delete_db_confirm">Are you sure you want to clear your local data? You can re-download network data from WiGLE, but position and observation information will be lost.</string>
<string name="no_wigle_conn">تعذر الاتصال ب ويغل. الرجاء التحقق من الاتصال وإعادة المحاولة.</string>
<string name="no_secure_wigle_conn">تعذر تأمين الاتصال ب ويغل. الرجاء التحقق وإعادة المحاولة</string>
<string name="error_general">خطأ</string>
<string name="no_barcode_support_text">Barcode detection not available on this device.</string>
<string name="gps_status">حالة غس</string>
</resources>
3 changes: 3 additions & 0 deletions wiglewifiwardriving/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,7 @@
<string name="delete_db_confirm">Are you sure you want to clear your local data? You can re-download network data from WiGLE, but position and observation information will be lost.</string>
<string name="no_wigle_conn">Nelze se připojit k WiGLE. Zkontrolujte připojení a zkuste to znovu.</string>
<string name="no_secure_wigle_conn">Nepodařilo se zajistit spojení s WiGLE. Zkontrolujte a zkuste to znovu.</string>
<string name="error_general">Chyba</string>
<string name="no_barcode_support_text">Barcode detection not available on this device.</string>
<string name="gps_status">Stav GPS</string>
</resources>
3 changes: 3 additions & 0 deletions wiglewifiwardriving/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,7 @@
<string name="delete_db_confirm">Are you sure you want to clear your local data? You can re-download network data from WiGLE, but position and observation information will be lost.</string>
<string name="no_wigle_conn">Kan ikke oprette forbindelse til WiGLE. Kontroller din forbindelse og prøv igen.</string>
<string name="no_secure_wigle_conn">Kan ikke sikre forbindelse med WiGLE. Tjek venligst og prøv igen.</string>
<string name="error_general">Fejl</string>
<string name="no_barcode_support_text">Barcode detection not available on this device.</string>
<string name="gps_status">GPS Status</string>
</resources>
3 changes: 3 additions & 0 deletions wiglewifiwardriving/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,7 @@
<string name="delete_db_confirm">ACHTUNG! Sind Sie sicher, dass Sie Ihre lokalen Daten löschen möchten? Sie können Netzwerkdaten von WiGLE neu herunterladen, aber Positions- und Beobachtungsinformationen gehen verloren</string>
<string name="no_wigle_conn">Kann nicht an WiGLE angeschlossen werden. Bitte überprüfen Sie Ihre Verbindung und versuchen Sie es erneut.</string>
<string name="no_secure_wigle_conn">Portino kann nicht mit WiGLE gesichert werden. Bitte überprüfen und wiederholen.</string>
<string name="error_general">Fehler</string>
<string name="no_barcode_support_text">Barcode detection not available on this device.</string>
<string name="gps_status">GPS-Status</string>
</resources>
3 changes: 3 additions & 0 deletions wiglewifiwardriving/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,7 @@
<string name="delete_db_confirm">¿Está seguro de que desea borrar los datos locales? Puede volver a descargar los datos de la red desde WiGLE, pero la información de posición y observación se perderá.</string>
<string name="no_wigle_conn">No se puede conectar a WiGLE. Compruebe su conexión y vuelva a intentarlo.</string>
<string name="no_secure_wigle_conn">No se puede asegurar el connectino con WiGLE. Compruebe y vuelva a intentarlo.</string>
<string name="error_general">Error</string>
<string name="no_barcode_support_text">Barcode detection not available on this device.</string>
<string name="gps_status">Estado del GPS</string>
</resources>
3 changes: 3 additions & 0 deletions wiglewifiwardriving/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,7 @@
<string name="delete_db_confirm">Are you sure you want to clear your local data? You can re-download network data from WiGLE, but position and observation information will be lost.</string>
<string name="no_wigle_conn">Yhteys WiGLEiin ei onnistu. Tarkista yhteys ja yritä uudelleen.</string>
<string name="no_secure_wigle_conn">Yhteyden muodostaminen WiGLE-yhteyteen ei onnistu. Tarkista ja yritä uudelleen.</string>
<string name="error_general">Virhe</string>
<string name="no_barcode_support_text">Barcode detection not available on this device.</string>
<string name="gps_status">GPS-tila</string>
</resources>
3 changes: 3 additions & 0 deletions wiglewifiwardriving/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,7 @@
<string name="delete_db_confirm">Êtes-vous sûr de vouloir effacer vos données locales? Vous pouvez ré-télécharger des données réseau de WiGLE, mais les informations de position et d\'observation seront perdues.</string>
<string name="no_wigle_conn">Impossible de se connecter à WiGLE. Vérifiez votre connexion et réessayez.</string>
<string name="no_secure_wigle_conn">Impossible de sécuriser la connexion avec WiGLE. Veuillez vérifier et réessayer.</string>
<string name="error_general">Erreur</string>
<string name="no_barcode_support_text">Barcode detection not available on this device.</string>
<string name="gps_status">État du GPS</string>
</resources>
3 changes: 3 additions & 0 deletions wiglewifiwardriving/src/main/res/values-fy/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,7 @@
<string name="delete_db_confirm">Are you sure you want to clear your local data? You can re-download network data from WiGLE, but position and observation information will be lost.</string>
<string name="no_wigle_conn">Kin net ferbine mei WiFi. Kontrolearje jo ferbining en werhelje.</string>
<string name="no_secure_wigle_conn">Koe de ferbining net feilichje mei WiFi. Kontrolearje asjebleaft en besykje.</string>
<string name="error_general">Fersin</string>
<string name="no_barcode_support_text">Barcode detection not available on this device.</string>
<string name="gps_status">GPS-stân</string>
</resources>
3 changes: 3 additions & 0 deletions wiglewifiwardriving/src/main/res/values-he/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,7 @@
<string name="delete_db_confirm">Are you sure you want to clear your local data? You can re-download network data from WiGLE, but position and observation information will be lost.</string>
<string name="no_wigle_conn">לא ניתן להתחבר ל- WiGLE. בדוק את החיבור שלך ונסה שוב.</string>
<string name="no_secure_wigle_conn">אין אפשרות לאבטח את החיבור ל- WiGLE. בדוק ונסה שוב.</string>
<string name="error_general">שְׁגִיאָה</string>
<string name="no_barcode_support_text">Barcode detection not available on this device.</string>
<string name="gps_status">מצב GPS</string>
</resources>
3 changes: 3 additions & 0 deletions wiglewifiwardriving/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,7 @@
<string name="delete_db_confirm">क्या आप वाकई अपना स्थानीय डेटा साफ़ करना चाहते हैं? आप WiGLE से नेटवर्क डेटा को फिर से डाउनलोड कर सकते हैं, लेकिन स्थिति और अवलोकन जानकारी खो जाएंगे।</string>
<string name="no_wigle_conn">वाईगल से कनेक्ट करने में असमर्थ कृपया अपना कनेक्शन जांचें और पुनः प्रयास करें।</string>
<string name="no_secure_wigle_conn">वाईगल के साथ कनेक्शन सुरक्षित करने में असमर्थ कृपया चेक करें और पुनः प्रयास करें।</string>
<string name="error_general">त्रुटि</string>
<string name="no_barcode_support_text">Barcode detection not available on this device.</string>
<string name="gps_status">जीपीएस स्थिति</string>
</resources>
3 changes: 3 additions & 0 deletions wiglewifiwardriving/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,7 @@
<string name="delete_db_confirm">Are you sure you want to clear your local data? You can re-download network data from WiGLE, but position and observation information will be lost.</string>
<string name="no_wigle_conn">Nem sikerült csatlakozni a WiGLE-hez. Ellenőrizze a kapcsolatot, és próbálkozzon újra.</string>
<string name="no_secure_wigle_conn">Nem sikerült kapcsolódni a WiGLE kapcsolathoz. Kérjük, ellenőrizze és próbálja újra.</string>
<string name="error_general">Hiba</string>
<string name="no_barcode_support_text">Barcode detection not available on this device.</string>
<string name="gps_status">GPS állapot</string>
</resources>
3 changes: 3 additions & 0 deletions wiglewifiwardriving/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,7 @@
<string name="delete_db_confirm">Sei sicuro di voler cancellare i dati locali? È possibile scaricare nuovamente i dati di rete da WiGLE, ma le informazioni relative alla posizione e all\'osservazione verranno perse.</string>
<string name="no_wigle_conn">Impossibile connettersi a WiGLE. Controllare la connessione e riprovare.</string>
<string name="no_secure_wigle_conn">Impossibile garantire la connessione con WiGLE. Si prega di controllare e riprovare.</string>
<string name="error_general">Errore</string>
<string name="no_barcode_support_text">Barcode detection not available on this device.</string>
<string name="gps_status">Stato GPS</string>
</resources>
Loading

0 comments on commit a261faf

Please sign in to comment.