Broadcast for Android

This commit is contained in:
rusefi 2020-08-15 21:49:39 -04:00
parent ccc3012705
commit 3e207b5549
6 changed files with 79 additions and 48 deletions

View File

@ -47,6 +47,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.1.0' implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0' implementation 'androidx.navigation:navigation-ui:2.1.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

View File

@ -3,7 +3,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rusefi.app"> package="com.rusefi.app">
<application android:label="@string/app_name"> <application android:label="@string/app_name"
android:theme="@style/AppTheme">
<!-- <!--
The USB_DEVICE_ATTACHED intent is always sent to an activity. The USB_DEVICE_ATTACHED intent is always sent to an activity.

View File

@ -35,6 +35,8 @@ import android.view.WindowManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import com.google.android.material.snackbar.BaseTransientBottomBar;
import com.google.android.material.snackbar.Snackbar;
import com.rusefi.Callable; import com.rusefi.Callable;
import com.rusefi.app.serial.AndroidSerial; import com.rusefi.app.serial.AndroidSerial;
import com.rusefi.auth.AutoTokenUtil; import com.rusefi.auth.AutoTokenUtil;
@ -211,8 +213,11 @@ public class rusEFI extends Activity {
soundBroadcast.start(); soundBroadcast.start();
} else if (view.getId() == R.id.buttonBroadcast) { } else if (view.getId() == R.id.buttonBroadcast) {
AndroidSerial serial = AndroidSerial.getAndroidSerial(mStatusView, mResultView, usbManager); AndroidSerial serial = AndroidSerial.getAndroidSerial(mStatusView, mResultView, usbManager);
if (serial == null) if (serial == null) {
Snackbar mySnackbar = Snackbar.make(view, "No ECU detected", BaseTransientBottomBar.LENGTH_LONG);
mySnackbar.show();
return; return;
}
LinkManager linkManager = new LinkManager(); LinkManager linkManager = new LinkManager();
linkManager.setConnector(new StreamConnector(linkManager, new Callable<IoStream>() { linkManager.setConnector(new StreamConnector(linkManager, new Callable<IoStream>() {
@ -232,6 +237,10 @@ public class rusEFI extends Activity {
mResultView.append("On connection failed\n"); mResultView.append("On connection failed\n");
} }
}); });
Snackbar mySnackbar = Snackbar.make(view, "Broadcasting with " + AutoTokenUtil.getAuthToken(), BaseTransientBottomBar.LENGTH_LONG);
mySnackbar.show();
} }
} }

View File

@ -1,6 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/myCoordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -11,7 +17,7 @@
android:id="@+id/text_status" android:id="@+id/text_status"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"/> android:textAppearance="?android:textAppearanceMedium" />
<Button <Button
android:id="@+id/button" android:id="@+id/button"
@ -45,10 +51,12 @@
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<TextView <TextView
android:id="@+id/text_result" android:id="@+id/text_result"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content" />
</ScrollView> </ScrollView>
</LinearLayout> </LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -0,0 +1,8 @@
<!--
https://stackoverflow.com/questions/47090526/caused-by-java-lang-unsupportedoperationexception-failed-to-resolve-attribute/47090603
https://stackoverflow.com/questions/27780713/do-i-need-to-use-a-theme-appcompat-theme-or-descendant-for-v21-styles-too
-->
<resources>
<style name="AppTheme" parent="AppBaseTheme">
</style>
</resources>

View File

@ -0,0 +1,4 @@
<resources>
<style name="AppBaseTheme" parent="Theme.AppCompat"></style>
<style name="AppTheme" parent="AppBaseTheme"></style>
</resources>