diff --git a/app/release/app-release.apk b/app/release/app-release.apk new file mode 100644 index 0000000..bd5c012 Binary files /dev/null and b/app/release/app-release.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json new file mode 100644 index 0000000..eb63433 --- /dev/null +++ b/app/release/output-metadata.json @@ -0,0 +1,20 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "com.avc.robocar", + "variantName": "release", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 1, + "versionName": "1.0", + "outputFile": "app-release.apk" + } + ], + "elementType": "File" +} \ No newline at end of file diff --git a/app/src/main/java/com/avc/robocar/Bluetooth.java b/app/src/main/java/com/avc/robocar/Bluetooth.java index 9546116..4f00411 100644 --- a/app/src/main/java/com/avc/robocar/Bluetooth.java +++ b/app/src/main/java/com/avc/robocar/Bluetooth.java @@ -44,7 +44,7 @@ public BluetoothAdapter getAdapter(){ return ba; } public boolean send(String data){ - Toast.makeText(activity, "Sending : "+data,Toast.LENGTH_LONG).show(); + Toast.makeText(activity, "Sending : "+data,Toast.LENGTH_SHORT).show(); if(!IS_CONNECTED) return false; try{ socket.getOutputStream().write(data.getBytes()); @@ -130,6 +130,12 @@ public void onReceive(Context context, Intent intent) { case BluetoothAdapter.STATE_TURNING_OFF: if(state_listener != null) state_listener.onTurningOFF(); break; + case BluetoothAdapter.STATE_CONNECTING: + if(state_listener != null) state_listener.onConnecting(); + break; + case BluetoothAdapter.STATE_CONNECTED: + if(state_listener != null) state_listener.onConnected(); + break; } } } @@ -145,6 +151,8 @@ public interface OnStateChangedListener{ void onTurnOFF(); void onTurningON(); void onTurningOFF(); + void onConnecting(); + void onConnected(); } @SuppressLint("MissingPermission") public void connect(final BluetoothDevice device){ diff --git a/app/src/main/java/com/avc/robocar/DeviceDialog.java b/app/src/main/java/com/avc/robocar/DeviceDialog.java index c387af3..561a56e 100644 --- a/app/src/main/java/com/avc/robocar/DeviceDialog.java +++ b/app/src/main/java/com/avc/robocar/DeviceDialog.java @@ -1,4 +1,5 @@ package com.avc.robocar; +import android.annotation.SuppressLint; import android.app.*; import android.os.*; import android.support.v7.app.*; @@ -43,6 +44,7 @@ protected void onCreate(Bundle savedInstanceState) public void onSelected(BluetoothDevice device){ blue.pairDevice(device); blue.connect(device); + dismiss(); } }); find.setOnClickListener(new View.OnClickListener(){ @@ -51,6 +53,7 @@ public void onClick(View v){ } }); blue.setOnDeviceDiscoverListener(new Bluetooth.OnDeviceDiscoveredListener(){ + @SuppressLint("MissingPermission") public void onDiscover(BluetoothDevice device){ devices.add(device); deviceString.add(device.getName()); diff --git a/app/src/main/java/com/avc/robocar/MainActivity.java b/app/src/main/java/com/avc/robocar/MainActivity.java index 50e1c2d..4eae6ea 100644 --- a/app/src/main/java/com/avc/robocar/MainActivity.java +++ b/app/src/main/java/com/avc/robocar/MainActivity.java @@ -87,6 +87,16 @@ public void onTurningOFF(){ textStatus.setText("Turning off bluetooth ..."); setStatus(R.color.orange); } + public void onConnecting(){ + state = -1; + textStatus.setText("Connecting ..."); + setStatus(R.color.orange); + } + public void onConnected(){ + state = -1; + textStatus.setText("Connected"); + setStatus(R.color.green); + } }); status.setOnClickListener(new View.OnClickListener(){ @@ -173,7 +183,7 @@ public void itemSelection(int id,MotionEvent event) } break; case R.id.btn_brake: - bluetooth.send("S"); + if(action == MotionEvent.ACTION_DOWN) bluetooth.send("S"); // else if(action == MotionEvent.ACTION_UP) bluetooth.send("X"); break; case R.id.radio_control: diff --git a/app/src/main/java/com/avc/robocar/VoiceControl.java b/app/src/main/java/com/avc/robocar/VoiceControl.java index b398fc2..bfb46b3 100644 --- a/app/src/main/java/com/avc/robocar/VoiceControl.java +++ b/app/src/main/java/com/avc/robocar/VoiceControl.java @@ -4,6 +4,7 @@ import android.content.*; import java.util.*; import android.os.*; +import android.util.ArrayMap; import android.widget.*; import android.speech.tts.*; @@ -15,8 +16,33 @@ public class VoiceControl private Intent speechRecognizerIntent; private TextToSpeech tts; public static boolean IS_LISTENING = false; + private Map dataSet = new ArrayMap(); //private CheckBox micButton; VoiceControl(AppCompatActivity a,Bluetooth b){ + dataSet.put("move forward","F"); + dataSet.put("forward","F"); + dataSet.put("go forward","F"); + dataSet.put("go straight","F"); + dataSet.put("move backward","B"); + dataSet.put("backward","B"); + dataSet.put("go backward","B"); + dataSet.put("go back","B"); + dataSet.put("turn left","L"); + dataSet.put("left","L"); + dataSet.put("move left","L"); + dataSet.put("go left","L"); + dataSet.put("turn right","R"); + dataSet.put("right","R"); + dataSet.put("move right","R"); + dataSet.put("go right","R"); + dataSet.put("brake","S"); + dataSet.put("break","S"); + dataSet.put("stop","S"); + dataSet.put("stop moving","S"); + dataSet.put("obstacle mode","O"); + dataSet.put("switch to obstacle mode","O"); + dataSet.put("control mode","C"); + dataSet.put("switch to control mode","C"); activity = a; blue = b; //micButton = btn; @@ -37,8 +63,14 @@ public void onInit(int i) { public void onResults(Bundle bundle) { ArrayList data = bundle.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); reco.stopListening(); - speak(data.get(0)); - if(IS_LISTENING)reco.startListening(speechRecognizerIntent); + for(String val : data){ + if(dataSet.containsKey(val.toLowerCase())){ + blue.send(dataSet.get(val.toLowerCase())); + speak(val,true); + break; + } + } + if(IS_LISTENING) reco.startListening(speechRecognizerIntent); Toast.makeText(activity,""+data, Toast.LENGTH_SHORT).show(); } @Override