diff --git a/mobile/build.gradle b/mobile/build.gradle index c6bdd2c90161344833aac2acd6414f83b0e6a60d..2b840ae35ee5cc8b55bf2bbd5a92781059461bb2 100644 --- a/mobile/build.gradle +++ b/mobile/build.gradle @@ -120,6 +120,7 @@ dependencies { implementation('com.mikepenz:aboutlibraries:6.0.8@aar') { transitive = true } + implementation 'com.github.GrenderG:Toasty:1.3.0' // Crash reporting fullImplementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') { diff --git a/mobile/src/main/java/org/openhab/habdroid/core/OpenHABVoiceService.java b/mobile/src/main/java/org/openhab/habdroid/core/OpenHABVoiceService.java index e91d6f35ff72900a4a8934a2458307e74b7c8ac1..2f44f9edc5120abb9010cb7f978f6cb568bf22f2 100644 --- a/mobile/src/main/java/org/openhab/habdroid/core/OpenHABVoiceService.java +++ b/mobile/src/main/java/org/openhab/habdroid/core/OpenHABVoiceService.java @@ -15,6 +15,7 @@ import android.os.Handler; import android.os.Looper; import android.speech.RecognizerIntent; import android.support.annotation.Nullable; +import android.support.v4.content.ContextCompat; import android.util.Log; import android.widget.Toast; @@ -28,9 +29,10 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; +import es.dmoral.toasty.Toasty; + /** - * This service handles voice commands and sends them to OpenHAB. - * It will use the openHAB base URL if passed in the intent's extra. + * This service handles voice commands and sends them to openHAB. */ public class OpenHABVoiceService extends IntentService { private static final String TAG = OpenHABVoiceService.class.getSimpleName(); @@ -92,6 +94,8 @@ public class OpenHABVoiceService extends IntentService { } private void showToast(CharSequence text) { - mHandler.post(() -> Toast.makeText(this, text, Toast.LENGTH_SHORT).show()); + mHandler.post(() -> Toasty.custom(this, text, R.drawable.ic_openhab_appicon_24dp, + ContextCompat.getColor(this, R.color.openhab_orange), Toast.LENGTH_SHORT, + true, true).show()); } } diff --git a/mobile/src/main/java/org/openhab/habdroid/ui/OpenHABMainActivity.java b/mobile/src/main/java/org/openhab/habdroid/ui/OpenHABMainActivity.java index 9c478dd2b23afa71e7a301a4747d9570adc81bd6..b2c6c8d334b188544120e91ca18de689979f8f7d 100644 --- a/mobile/src/main/java/org/openhab/habdroid/ui/OpenHABMainActivity.java +++ b/mobile/src/main/java/org/openhab/habdroid/ui/OpenHABMainActivity.java @@ -108,6 +108,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import es.dmoral.toasty.Toasty; import okhttp3.Call; import okhttp3.Headers; import okhttp3.Request; @@ -507,9 +508,6 @@ public class OpenHABMainActivity extends AppCompatActivity implements openNotificationsPageIfNeeded(); } - /** - * Overriding onStop to enable Google Analytics stats collection - */ @Override public void onStop() { Log.d(TAG, "onStop()"); @@ -1012,8 +1010,8 @@ public class OpenHABMainActivity extends AppCompatActivity implements startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.googlequicksearchbox"))); } catch (ActivityNotFoundException appStoreNotFoundException) { - Toast.makeText(this, R.string.error_no_app_store_found, - Toast.LENGTH_LONG).show(); + Toasty.error(this, getString(R.string.error_no_app_store_found), + Toast.LENGTH_LONG, true).show(); } } }