Skip to content
Snippets Groups Projects
Unverified Commit f8f97794 authored by mueller-ma's avatar mueller-ma Committed by GitHub
Browse files

Use Toasty library for Toasts (#991)

parent 0de9c2c9
Branches
Tags
No related merge requests found
...@@ -120,6 +120,7 @@ dependencies { ...@@ -120,6 +120,7 @@ dependencies {
implementation('com.mikepenz:aboutlibraries:6.0.8@aar') { implementation('com.mikepenz:aboutlibraries:6.0.8@aar') {
transitive = true transitive = true
} }
implementation 'com.github.GrenderG:Toasty:1.3.0'
// Crash reporting // Crash reporting
fullImplementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') { fullImplementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
......
...@@ -15,6 +15,7 @@ import android.os.Handler; ...@@ -15,6 +15,7 @@ import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.speech.RecognizerIntent; import android.speech.RecognizerIntent;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
...@@ -28,9 +29,10 @@ import java.util.HashMap; ...@@ -28,9 +29,10 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import es.dmoral.toasty.Toasty;
/** /**
* This service handles voice commands and sends them to OpenHAB. * This service handles voice commands and sends them to openHAB.
* It will use the openHAB base URL if passed in the intent's extra.
*/ */
public class OpenHABVoiceService extends IntentService { public class OpenHABVoiceService extends IntentService {
private static final String TAG = OpenHABVoiceService.class.getSimpleName(); private static final String TAG = OpenHABVoiceService.class.getSimpleName();
...@@ -92,6 +94,8 @@ public class OpenHABVoiceService extends IntentService { ...@@ -92,6 +94,8 @@ public class OpenHABVoiceService extends IntentService {
} }
private void showToast(CharSequence text) { 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());
} }
} }
...@@ -108,6 +108,7 @@ import javax.xml.parsers.DocumentBuilder; ...@@ -108,6 +108,7 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import es.dmoral.toasty.Toasty;
import okhttp3.Call; import okhttp3.Call;
import okhttp3.Headers; import okhttp3.Headers;
import okhttp3.Request; import okhttp3.Request;
...@@ -507,9 +508,6 @@ public class OpenHABMainActivity extends AppCompatActivity implements ...@@ -507,9 +508,6 @@ public class OpenHABMainActivity extends AppCompatActivity implements
openNotificationsPageIfNeeded(); openNotificationsPageIfNeeded();
} }
/**
* Overriding onStop to enable Google Analytics stats collection
*/
@Override @Override
public void onStop() { public void onStop() {
Log.d(TAG, "onStop()"); Log.d(TAG, "onStop()");
...@@ -1012,8 +1010,8 @@ public class OpenHABMainActivity extends AppCompatActivity implements ...@@ -1012,8 +1010,8 @@ public class OpenHABMainActivity extends AppCompatActivity implements
startActivity(new Intent(Intent.ACTION_VIEW, startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=com.google.android.googlequicksearchbox"))); Uri.parse("market://details?id=com.google.android.googlequicksearchbox")));
} catch (ActivityNotFoundException appStoreNotFoundException) { } catch (ActivityNotFoundException appStoreNotFoundException) {
Toast.makeText(this, R.string.error_no_app_store_found, Toasty.error(this, getString(R.string.error_no_app_store_found),
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG, true).show();
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment