Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DDC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GOKA HARSHITH
DDC
Commits
a928799d
Commit
a928799d
authored
Jun 20, 2016
by
Harshith Goka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add functionalities
parent
f313b577
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
122 additions
and
33 deletions
+122
-33
.idea/misc.xml
.idea/misc.xml
+1
-1
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-1
app/src/main/java/com/example/harshith/ddc/Constants.java
app/src/main/java/com/example/harshith/ddc/Constants.java
+5
-0
app/src/main/java/com/example/harshith/ddc/MainActivity.java
app/src/main/java/com/example/harshith/ddc/MainActivity.java
+6
-0
app/src/main/java/com/example/harshith/ddc/ReceiveDataThread.java
...main/java/com/example/harshith/ddc/ReceiveDataThread.java
+26
-30
app/src/main/java/com/example/harshith/ddc/ReceiveService.java
...rc/main/java/com/example/harshith/ddc/ReceiveService.java
+83
-1
No files found.
.idea/misc.xml
View file @
a928799d
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
<ConfirmationsSetting
value=
"0"
id=
"Add"
/>
<ConfirmationsSetting
value=
"0"
id=
"Add"
/>
<ConfirmationsSetting
value=
"0"
id=
"Remove"
/>
<ConfirmationsSetting
value=
"0"
id=
"Remove"
/>
</component>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
7
"
default=
"true"
assert-keyword=
"true"
jdk-15=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
8
"
default=
"true"
assert-keyword=
"true"
jdk-15=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
</component>
<component
name=
"ProjectType"
>
<component
name=
"ProjectType"
>
...
...
app/src/main/AndroidManifest.xml
View file @
a928799d
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
package=
"com.example.harshith.ddc"
>
package=
"com.example.harshith.ddc"
>
<uses-permission
android:name=
"android.permission.BLUETOOTH"
/>
<uses-permission
android:name=
"android.permission.BLUETOOTH"
/>
<uses-permission
android:name=
"android.permission.BLUETOOTH_ADMIN"
/>
<uses-permission
android:name=
"android.permission.BLUETOOTH_ADMIN"
/>
<uses-permission
android:name=
"android.permission.CALL_PHONE"
/>
<application
<application
android:name=
".GlobalClass"
android:name=
".GlobalClass"
android:allowBackup=
"true"
android:allowBackup=
"true"
...
...
app/src/main/java/com/example/harshith/ddc/Constants.java
View file @
a928799d
...
@@ -12,5 +12,10 @@ public class Constants {
...
@@ -12,5 +12,10 @@ public class Constants {
public
static
int
READ_STATUS
=
18
;
public
static
int
READ_STATUS
=
18
;
public
static
int
READ_STATUS_OK
=
0
;
public
static
int
READ_STATUS_OK
=
0
;
public
static
int
READ_STATUS_NOT_OK
=
1
;
public
static
int
READ_STATUS_NOT_OK
=
1
;
public
static
String
PLAY_PAUSE
=
"Play/Pause"
;
public
static
String
OK_GOOGLE
=
"Ok Google"
;
public
static
String
OPEN_CAMERA
=
"Camera"
;
public
static
String
GOOGLE_NOW
=
"GoogleApp"
;
}
}
app/src/main/java/com/example/harshith/ddc/MainActivity.java
View file @
a928799d
...
@@ -3,6 +3,7 @@ package com.example.harshith.ddc;
...
@@ -3,6 +3,7 @@ package com.example.harshith.ddc;
import
android.bluetooth.BluetoothAdapter
;
import
android.bluetooth.BluetoothAdapter
;
import
android.bluetooth.BluetoothDevice
;
import
android.bluetooth.BluetoothDevice
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.os.Message
;
...
@@ -15,6 +16,7 @@ import android.widget.TextView;
...
@@ -15,6 +16,7 @@ import android.widget.TextView;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.jar.Manifest
;
/**
/**
* Created by harshith on 17/6/16.
* Created by harshith on 17/6/16.
...
@@ -63,6 +65,10 @@ public class MainActivity extends AppCompatActivity {
...
@@ -63,6 +65,10 @@ public class MainActivity extends AppCompatActivity {
checkBTState
();
checkBTState
();
if
(
checkSelfPermission
(
android
.
Manifest
.
permission
.
CALL_PHONE
)
==
PackageManager
.
PERMISSION_DENIED
){
requestPermissions
(
new
String
[]{
android
.
Manifest
.
permission
.
CALL_PHONE
},
1
);
}
mPairedDevicesArrayAdapter
.
clear
();
mPairedDevicesArrayAdapter
.
clear
();
textConnectionStatus
.
setText
(
" "
);
textConnectionStatus
.
setText
(
" "
);
...
...
app/src/main/java/com/example/harshith/ddc/ReceiveDataThread.java
View file @
a928799d
package
com.example.harshith.ddc
;
package
com.example.harshith.ddc
;
import
android.bluetooth.BluetoothSocket
;
import
android.bluetooth.BluetoothSocket
;
import
android.content.Intent
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.os.Looper
;
import
android.provider.MediaStore
;
import
android.util.Log
;
import
android.util.Log
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -36,15 +38,15 @@ public class ReceiveDataThread extends Thread {
...
@@ -36,15 +38,15 @@ public class ReceiveDataThread extends Thread {
int
[]
hand
;
int
q
=
0
;
int
[]
hand
;
int
q
=
0
;
q
=
0
;
hand
=
new
int
[]
{
0
,
0
,
0
,
0
,
8
,
8
,
8
,
8
,
8
,
8
};
q
=
0
;
hand
=
new
int
[]
{
0
,
1
,
1
,
0
,
8
,
8
,
8
,
8
,
8
,
8
};
// neutral
// neutral
a
[
q
].
updateFrame
(
hand
);
a
[
q
].
updateFrame
(
hand
);
q
=
1
;
hand
=
new
int
[]
{
1
,
1
,
0
,
0
,
8
,
8
,
8
,
8
,
1
,
8
};
q
=
1
;
hand
=
new
int
[]
{
1
,
1
,
1
,
1
,
8
,
8
,
8
,
8
,
1
,
8
};
// voice search
// voice search
a
[
q
].
updateFrame
(
hand
);
a
[
q
].
updateFrame
(
hand
);
q
=
2
;
hand
=
new
int
[]
{
1
,
0
,
1
,
1
,
8
,
8
,
8
,
8
,
1
,
8
};
q
=
2
;
hand
=
new
int
[]
{
0
,
1
,
1
,
1
,
8
,
8
,
8
,
8
,
1
,
8
};
// tap
// tap
a
[
q
].
updateFrame
(
hand
);
a
[
q
].
updateFrame
(
hand
);
...
@@ -130,6 +132,27 @@ public class ReceiveDataThread extends Thread {
...
@@ -130,6 +132,27 @@ public class ReceiveDataThread extends Thread {
if
(
count
==
no
){
if
(
count
==
no
){
Log
.
d
(
"Gesture"
,
"Gesture "
+
gestActive
+
" is activated"
);
Log
.
d
(
"Gesture"
,
"Gesture "
+
gestActive
+
" is activated"
);
if
(
gestActive
==
0
){
Looper
.
prepare
();
handler
.
obtainMessage
(
Constants
.
READ_STATUS
,
Constants
.
OPEN_CAMERA
).
sendToTarget
();
Looper
.
loop
();
}
else
if
(
gestActive
==
1
){
Looper
.
prepare
();
handler
.
obtainMessage
(
Constants
.
READ_STATUS
,
Constants
.
OK_GOOGLE
).
sendToTarget
();
Looper
.
loop
();
}
else
if
(
gestActive
==
2
){
Looper
.
prepare
();
handler
.
obtainMessage
(
Constants
.
READ_STATUS
,
Constants
.
GOOGLE_NOW
).
sendToTarget
();
Looper
.
loop
();
}
else
if
(
gestActive
==
3
){
Looper
.
prepare
();
handler
.
obtainMessage
(
Constants
.
READ_STATUS
,
Constants
.
PLAY_PAUSE
).
sendToTarget
();
Looper
.
loop
();
}
count
=
0
;
count
=
0
;
gestActive
=
-
1
;
gestActive
=
-
1
;
//if( str.equals("n") ) { stay = false; break; }
//if( str.equals("n") ) { stay = false; break; }
...
@@ -151,34 +174,7 @@ public class ReceiveDataThread extends Thread {
...
@@ -151,34 +174,7 @@ public class ReceiveDataThread extends Thread {
}
}
}
}
}
}
// int[] flex = new int[5];
// for (int i = 0; i != 5; i++) {
// try {
// flex[i] = readings[i];
// }
// catch (ArrayIndexOutOfBoundsException e) {
//
// }
// }
//
// int[] mpu = new int[6];
// for (int i = 0; i != 6; i++) {
// try {
// mpu[i] = readings[5 + i];
// }
// catch (ArrayIndexOutOfBoundsException e) {
//
// }
// }
}
}
// if(processHandler != null) {
// processHandler.obtainMessage(1, readings).sendToTarget();
// }
// else {
// processHandler = globalClass.getProcessHandler();
// }
}
}
...
...
app/src/main/java/com/example/harshith/ddc/ReceiveService.java
View file @
a928799d
package
com.example.harshith.ddc
;
package
com.example.harshith.ddc
;
import
android.Manifest
;
import
android.app.Service
;
import
android.app.Service
;
import
android.bluetooth.BluetoothSocket
;
import
android.bluetooth.BluetoothSocket
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.content.pm.ResolveInfo
;
import
android.media.AudioManager
;
import
android.net.Uri
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.IBinder
;
import
android.os.IBinder
;
import
android.os.Message
;
import
android.os.Message
;
import
android.os.SystemClock
;
import
android.provider.MediaStore
;
import
android.speech.RecognizerIntent
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v4.content.ContextCompat
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
java.util.UUID
;
import
java.util.UUID
;
import
static
android
.
content
.
ContentValues
.
TAG
;
/**
/**
* Created by harshith on 17/6/16.
* Created by harshith on 17/6/16.
*/
*/
...
@@ -18,6 +33,7 @@ import java.util.UUID;
...
@@ -18,6 +33,7 @@ import java.util.UUID;
public
class
ReceiveService
extends
Service
{
public
class
ReceiveService
extends
Service
{
ConnectThread
connectThread
;
ConnectThread
connectThread
;
ReceiveDataThread
receiveDataThread
;
ReceiveDataThread
receiveDataThread
;
BluetoothSocket
bluetoothSocket
;
private
static
final
UUID
uuid
=
UUID
.
fromString
(
"00001101-0000-1000-8000-00805F9B34FB"
);
private
static
final
UUID
uuid
=
UUID
.
fromString
(
"00001101-0000-1000-8000-00805F9B34FB"
);
public
Handler
handler
;
public
Handler
handler
;
GlobalClass
globalClass
;
GlobalClass
globalClass
;
...
@@ -30,6 +46,7 @@ public class ReceiveService extends Service {
...
@@ -30,6 +46,7 @@ public class ReceiveService extends Service {
if
(
message
.
what
==
Constants
.
CONNECTION_STATUS
)
{
if
(
message
.
what
==
Constants
.
CONNECTION_STATUS
)
{
if
(
message
.
arg1
==
Constants
.
CONNECTION_STATUS_OK
){
if
(
message
.
arg1
==
Constants
.
CONNECTION_STATUS_OK
){
Toast
.
makeText
(
getApplicationContext
(),
"Connected"
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
"Connected"
,
Toast
.
LENGTH_LONG
).
show
();
bluetoothSocket
=
(
BluetoothSocket
)
message
.
obj
;
receiveDataThread
=
new
ReceiveDataThread
((
BluetoothSocket
)
message
.
obj
,
handler
,
globalClass
);
receiveDataThread
=
new
ReceiveDataThread
((
BluetoothSocket
)
message
.
obj
,
handler
,
globalClass
);
receiveDataThread
.
start
();
receiveDataThread
.
start
();
}
}
...
@@ -38,7 +55,23 @@ public class ReceiveService extends Service {
...
@@ -38,7 +55,23 @@ public class ReceiveService extends Service {
}
}
}
}
else
if
(
message
.
what
==
Constants
.
READ_STATUS
)
{
else
if
(
message
.
what
==
Constants
.
READ_STATUS
)
{
if
(((
String
)
message
.
obj
).
equals
(
Constants
.
OPEN_CAMERA
)){
openCamera
();
resumeReading
();
}
else
if
(
message
.
obj
.
equals
(
Constants
.
OK_GOOGLE
)){
okGoogle
();
L
.
s
(
getBaseContext
(),
"Ok Google"
);
resumeReading
();
}
else
if
(
message
.
obj
.
equals
(
Constants
.
GOOGLE_NOW
)){
googleNow
();
resumeReading
();
}
else
if
(
message
.
obj
.
equals
(
Constants
.
PLAY_PAUSE
)){
audioPlayPause
();
resumeReading
();
}
}
}
}
}
};
};
...
@@ -66,5 +99,54 @@ public class ReceiveService extends Service {
...
@@ -66,5 +99,54 @@ public class ReceiveService extends Service {
public
void
onDestroy
(){
public
void
onDestroy
(){
}
}
public
void
openCamera
(){
Intent
i
=
new
Intent
(
android
.
provider
.
MediaStore
.
ACTION_IMAGE_CAPTURE
);
try
{
PackageManager
pm
=
getBaseContext
().
getPackageManager
();
final
ResolveInfo
mInfo
=
pm
.
resolveActivity
(
i
,
0
);
Intent
intent
=
new
Intent
();
intent
.
setComponent
(
new
ComponentName
(
mInfo
.
activityInfo
.
packageName
,
mInfo
.
activityInfo
.
name
));
intent
.
setAction
(
Intent
.
ACTION_MAIN
);
intent
.
addCategory
(
Intent
.
CATEGORY_LAUNCHER
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
startActivity
(
intent
);
}
catch
(
Exception
e
){
Log
.
i
(
TAG
,
"Unable to launch camera: "
+
e
);
}
}
public
void
dialPhoneNumber
(
String
phoneNumber
)
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_DIAL
);
intent
.
setData
(
Uri
.
parse
(
"tel:"
+
phoneNumber
));
if
(
intent
.
resolveActivity
(
getPackageManager
())
!=
null
)
{
startActivity
(
intent
);
}
}
public
void
resumeReading
(){
receiveDataThread
=
new
ReceiveDataThread
(
bluetoothSocket
,
handler
,
globalClass
);
receiveDataThread
.
start
();
}
public
void
googleNow
(){
Intent
intent
=
new
Intent
(
Intent
.
ACTION_ASSIST
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
startActivity
(
intent
);
}
public
void
okGoogle
(){
Intent
intent
=
new
Intent
(
RecognizerIntent
.
ACTION_VOICE_SEARCH_HANDS_FREE
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
startActivity
(
intent
);
}
public
void
audioPlayPause
(){
AudioManager
audioManager
=
(
AudioManager
)
getBaseContext
().
getSystemService
(
Context
.
AUDIO_SERVICE
);
KeyEvent
downEvent
=
new
KeyEvent
(
KeyEvent
.
ACTION_DOWN
,
KeyEvent
.
KEYCODE_MEDIA_PLAY_PAUSE
);
audioManager
.
dispatchMediaKeyEvent
(
downEvent
);
KeyEvent
upEvent
=
new
KeyEvent
(
KeyEvent
.
ACTION_UP
,
KeyEvent
.
KEYCODE_MEDIA_PLAY_PAUSE
);
audioManager
.
dispatchMediaKeyEvent
(
upEvent
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment