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
6df9528e
Commit
6df9528e
authored
Jun 30, 2016
by
Harshith Goka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some functionalities, change initialisation of gestures
parent
baee4c7b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
197 additions
and
110 deletions
+197
-110
.idea/misc.xml
.idea/misc.xml
+1
-1
app/src/main/java/com/example/harshith/ddc/DynamicQueue.java
app/src/main/java/com/example/harshith/ddc/DynamicQueue.java
+2
-2
app/src/main/java/com/example/harshith/ddc/ReceiveDataThread.java
...main/java/com/example/harshith/ddc/ReceiveDataThread.java
+41
-105
app/src/main/java/com/example/harshith/ddc/ReceiveService.java
...rc/main/java/com/example/harshith/ddc/ReceiveService.java
+153
-2
No files found.
.idea/misc.xml
View file @
6df9528e
...
...
@@ -37,7 +37,7 @@
<ConfirmationsSetting
value=
"0"
id=
"Add"
/>
<ConfirmationsSetting
value=
"0"
id=
"Remove"
/>
</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"
/>
</component>
<component
name=
"ProjectType"
>
...
...
app/src/main/java/com/example/harshith/ddc/DynamicQueue.java
View file @
6df9528e
...
...
@@ -147,8 +147,8 @@ class DynamicQueue{
public
int
proceedExecution
(){
int
no
;
no
=
Math
.
max
((
latestElement
-
20
)%
noOfSlots
,
foremostElement
);
for
(
int
i
=
foremostElement
;
i
!=
no
;
i
=(
i
+
1
)%
noOfSlots
)
{
//
no = Math.max((latestElement - 20)%noOfSlots,foremostElement);
for
(
int
i
=
foremostElement
;
i
!=
latestElement
;
i
=(
i
+
1
)%
noOfSlots
)
{
if
(
getShortlistCount
(
i
)==
0
)
foremostElement
=
(
foremostElement
+
1
)%
noOfSlots
;
else
if
(
getShortlistCount
(
i
)==
1
)
{
//gesture execute
...
...
app/src/main/java/com/example/harshith/ddc/ReceiveDataThread.java
View file @
6df9528e
...
...
@@ -50,15 +50,7 @@ public class ReceiveDataThread extends Thread {
// initialising the 11 gestures
indx
=
0
;
array
=
new
int
[
101
][
11
];
lineDraw
(
array
,
0
,
0
,
101
,
0
,
true
);
lineDraw
(
array
,
0
,
0
,
101
,
1
,
true
);
lineDraw
(
array
,
0
,
0
,
101
,
2
,
true
);
lineDraw
(
array
,
0
,
0
,
101
,
3
,
true
);
lineDraw
(
array
,
0
,
0
,
101
,
4
,
true
);
setValue
(
array
,
35
,
9
,
101
);
array
=
readingsGenerate
(
new
int
[]
{
14
,
13
,
18
,
15
,
12
},
new
int
[]
{
76
,
84
,
88
,
81
,
82
});
a
[
indx
]
=
new
DynamicGesture
(
array
.
length
);
cons
=
new
int
[]
{
1
,
1
,
1
,
1
,
1
,
0
,
0
,
0
,
0
,
1
,
0
};
...
...
@@ -66,17 +58,8 @@ public class ReceiveDataThread extends Thread {
threshold
[
indx
]
=
40
;
indx
=
1
;
array
=
new
int
[
201
][
11
];
setValue
(
array
,
0
,
0
,
201
);
setValue
(
array
,
100
,
1
,
201
);
setValue
(
array
,
100
,
2
,
201
);
setValue
(
array
,
100
,
3
,
201
);
setValue
(
array
,
100
,
4
,
201
);
lineDraw
(
array
,
0
,
0
,
51
,
5
,
false
);
lineDraw
(
array
,
50
,
-
50
,
101
,
5
,
true
);
lineDraw
(
array
,
150
,
50
,
51
,
5
,
false
);
setValue
(
array
,
0
,
8
,
201
);
setValue
(
array
,
0
,
9
,
201
);
array
=
readingsGenerate
(
new
int
[]{
2
},
new
int
[]{
3
});
a
[
indx
]
=
new
DynamicGesture
(
array
.
length
);
cons
=
new
int
[]
{
1
,
1
,
1
,
1
,
1
,
1
,
0
,
0
,
1
,
1
,
0
};
...
...
@@ -85,13 +68,7 @@ public class ReceiveDataThread extends Thread {
threshold
[
indx
]
=
40
;
indx
=
2
;
array
=
new
int
[
51
][
11
];
lineDraw
(
array
,
0
,
0
,
51
,
0
,
true
);
lineDraw
(
array
,
0
,
0
,
51
,
1
,
true
);
lineDraw
(
array
,
0
,
0
,
51
,
2
,
true
);
setValue
(
array
,
0
,
8
,
51
);
setValue
(
array
,
0
,
9
,
51
);
array
=
readingsGenerate
(
new
int
[]
{
14
,
13
,
18
,
15
,
12
},
new
int
[]
{
23
,
75
,
90
,
13
,
8
});
a
[
indx
]
=
new
DynamicGesture
(
array
.
length
);
...
...
@@ -101,14 +78,7 @@ public class ReceiveDataThread extends Thread {
threshold
[
indx
]
=
40
;
indx
=
3
;
array
=
new
int
[
101
][
11
];
lineDraw
(
array
,
0
,
0
,
101
,
0
,
true
);
setValue
(
array
,
0
,
1
,
101
);
setValue
(
array
,
0
,
2
,
101
);
setValue
(
array
,
0
,
3
,
101
);
setValue
(
array
,
0
,
4
,
101
);
setValue
(
array
,
35
,
9
,
101
);
array
=
readingsGenerate
(
new
int
[]
{
14
,
13
,
18
,
15
,
12
},
new
int
[]
{
2
,
11
,
2
,
10
,
1
});
a
[
indx
]
=
new
DynamicGesture
(
array
.
length
);
...
...
@@ -118,14 +88,7 @@ public class ReceiveDataThread extends Thread {
threshold
[
indx
]
=
40
;
indx
=
4
;
array
=
new
int
[
101
][
11
];
lineDraw
(
array
,
0
,
0
,
101
,
0
,
true
);
setValue
(
array
,
0
,
1
,
101
);
setValue
(
array
,
0
,
2
,
101
);
setValue
(
array
,
0
,
3
,
101
);
lineDraw
(
array
,
0
,
0
,
101
,
4
,
true
);
setValue
(
array
,
35
,
9
,
101
);
array
=
readingsGenerate
(
new
int
[]{
2
},
new
int
[]{
3
});
a
[
indx
]
=
new
DynamicGesture
(
array
.
length
);
...
...
@@ -136,15 +99,7 @@ public class ReceiveDataThread extends Thread {
indx
=
5
;
array
=
new
int
[
101
][
11
];
setValue
(
array
,
100
,
0
,
101
);
setValue
(
array
,
0
,
1
,
101
);
setValue
(
array
,
0
,
2
,
101
);
lineDraw
(
array
,
0
,
0
,
101
,
3
,
true
);
setValue
(
array
,
100
,
4
,
101
);
setValue
(
array
,-
35
,
8
,
101
);
setValue
(
array
,
0
,
9
,
101
);
array
=
readingsGenerate
(
new
int
[]
{
14
,
13
,
18
,
15
,
12
}
,
new
int
[]
{
47
,
5
,
5
,
5
,
93
});
a
[
indx
]
=
new
DynamicGesture
(
array
.
length
);
...
...
@@ -155,16 +110,7 @@ public class ReceiveDataThread extends Thread {
indx
=
6
;
array
=
new
int
[
201
][
11
];
setValue
(
array
,
100
,
0
,
201
);
setValue
(
array
,
0
,
1
,
201
);
setValue
(
array
,
0
,
2
,
201
);
setValue
(
array
,
0
,
3
,
201
);
setValue
(
array
,
100
,
4
,
201
);
lineDraw
(
array
,
0
,
0
,
51
,
5
,
false
);
lineDraw
(
array
,
50
,
-
50
,
101
,
5
,
true
);
lineDraw
(
array
,
150
,
50
,
51
,
5
,
false
);
setValue
(
array
,-
35
,
8
,
201
);
setValue
(
array
,
0
,
9
,
201
);
array
=
readingsGenerate
(
new
int
[]{
2
},
new
int
[]{
3
});
a
[
indx
]
=
new
DynamicGesture
(
array
.
length
);
...
...
@@ -176,16 +122,7 @@ public class ReceiveDataThread extends Thread {
indx
=
7
;
array
=
new
int
[
201
][
11
];
setValue
(
array
,
100
,
0
,
201
);
setValue
(
array
,
0
,
1
,
201
);
setValue
(
array
,
0
,
2
,
201
);
setValue
(
array
,
0
,
3
,
201
);
setValue
(
array
,
100
,
4
,
201
);
lineDraw
(
array
,
0
,
0
,
51
,
5
,
true
);
lineDraw
(
array
,
50
,
50
,
101
,
5
,
false
);
lineDraw
(
array
,
150
,
-
50
,
51
,
5
,
true
);
setValue
(
array
,-
35
,
8
,
201
);
setValue
(
array
,
0
,
9
,
201
);
array
=
readingsGenerate
(
new
int
[]{
2
},
new
int
[]{
3
});
a
[
indx
]
=
new
DynamicGesture
(
array
.
length
);
...
...
@@ -196,14 +133,7 @@ public class ReceiveDataThread extends Thread {
indx
=
8
;
array
=
new
int
[
101
][
11
];
lineDraw
(
array
,
0
,
0
,
101
,
0
,
true
);
lineDraw
(
array
,
0
,
0
,
101
,
1
,
true
);
setValue
(
array
,
0
,
2
,
101
);
setValue
(
array
,
0
,
3
,
101
);
setValue
(
array
,
0
,
4
,
101
);
setValue
(
array
,
35
,
9
,
101
);
array
=
readingsGenerate
(
new
int
[]
{
14
,
13
,
18
,
15
,
12
},
new
int
[]
{
47
,
81
,
21
,
15
,
8
});
a
[
indx
]
=
new
DynamicGesture
(
array
.
length
);
...
...
@@ -214,14 +144,7 @@ public class ReceiveDataThread extends Thread {
indx
=
9
;
array
=
new
int
[
101
][
11
];
lineDraw
(
array
,
0
,
100
,
101
,
0
,
false
);
lineDraw
(
array
,
0
,
100
,
101
,
1
,
false
);
setValue
(
array
,
100
,
2
,
101
);
setValue
(
array
,
100
,
3
,
101
);
setValue
(
array
,
100
,
4
,
101
);
setValue
(
array
,
35
,
9
,
101
);
array
=
readingsGenerate
(
new
int
[]
{
76
,
84
,
88
,
81
,
82
},
new
int
[]
{
14
,
5
,
80
,
60
,
75
});
a
[
indx
]
=
new
DynamicGesture
(
array
.
length
);
...
...
@@ -232,17 +155,9 @@ public class ReceiveDataThread extends Thread {
indx
=
10
;
array
=
new
int
[
201
][
11
]
;
array
=
readingsGenerate
(
new
int
[]
{
14
,
5
,
80
,
60
,
75
},
new
int
[]
{
28
,
77
,
77
,
76
,
94
})
;
a
[
indx
]
=
new
DynamicGesture
(
array
.
length
);
setValue
(
array
,
0
,
0
,
201
);
lineDraw
(
array
,
0
,
0
,
101
,
1
,
true
);
lineDraw
(
array
,
100
,
100
,
101
,
1
,
false
);
setValue
(
array
,
100
,
2
,
201
);
setValue
(
array
,
100
,
3
,
201
);
setValue
(
array
,
100
,
4
,
201
);
setValue
(
array
,
35
,
9
,
201
);
cons
=
new
int
[]
{
1
,
1
,
1
,
1
,
1
,
0
,
0
,
0
,
0
,
1
,
0
};
a
[
indx
].
updateFrame
(
array
,
cons
);
// a[indx].printData();
...
...
@@ -250,14 +165,7 @@ public class ReceiveDataThread extends Thread {
indx
=
11
;
array
=
new
int
[
101
][
11
];
lineDraw
(
array
,
0
,
0
,
101
,
0
,
true
);
lineDraw
(
array
,
0
,
0
,
101
,
1
,
true
);
setValue
(
array
,
100
,
2
,
101
);
setValue
(
array
,
100
,
3
,
101
);
setValue
(
array
,
100
,
4
,
101
);
setValue
(
array
,
35
,
9
,
101
);
array
=
readingsGenerate
(
new
int
[]
{
14
,
5
,
80
,
60
,
75
},
new
int
[]
{
76
,
84
,
88
,
81
,
82
});
a
[
indx
]
=
new
DynamicGesture
(
array
.
length
);
...
...
@@ -266,7 +174,7 @@ public class ReceiveDataThread extends Thread {
// a[indx].printData();
threshold
[
indx
]
=
40
;
threshold
=
new
int
[]{
5
,
10
,
10
,
10
,
10
,
10
,
10
,
10
,
10
,
10
,
30
,
1
0
};
threshold
=
new
int
[]{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
DynamicQueue
q
=
new
DynamicQueue
(
a
,
threshold
);
Live
dynamiclive
=
new
Live
();
...
...
@@ -360,4 +268,32 @@ public class ReceiveDataThread extends Thread {
array
[
i
][
sensor
]
=
value
;
}
}
public
static
int
[][]
readingsGenerate
(
int
[]
low
,
int
[]
high
){
int
size
=
0
;
for
(
int
i
=
0
;
i
<
5
;
i
++){
int
diff
=
high
[
i
]-
low
[
i
];
if
(
diff
>
size
){
size
=
diff
;
}
}
//now size = maximum difference between low and high values
int
[]
[]
array
=
new
int
[
size
][
11
];
float
size2
=
size
-
1
;
for
(
int
i
=
0
;
i
<
size
;
i
++){
array
[
i
][
0
]=
low
[
0
]+(
int
)((
high
[
0
]-
low
[
0
])*(
i
/
size2
));
array
[
i
][
1
]=
low
[
1
]+(
int
)((
high
[
1
]-
low
[
1
])*(
i
/
size2
));
array
[
i
][
2
]=
low
[
2
]+(
int
)((
high
[
2
]-
low
[
2
])*(
i
/
size2
));
array
[
i
][
3
]=
low
[
3
]+(
int
)((
high
[
3
]-
low
[
3
])*(
i
/
size2
));
array
[
i
][
4
]=
low
[
4
]+(
int
)((
high
[
4
]-
low
[
4
])*(
i
/
size2
));
array
[
i
][
5
]=
0
;
array
[
i
][
6
]=
0
;
array
[
i
][
7
]=
0
;
array
[
i
][
8
]=
0
;
array
[
i
][
9
]=
0
;
array
[
i
][
10
]=
0
;
}
return
array
;
}
}
app/src/main/java/com/example/harshith/ddc/ReceiveService.java
View file @
6df9528e
package
com.example.harshith.ddc
;
import
android.app.Instrumentation
;
import
android.app.Service
;
import
android.bluetooth.BluetoothSocket
;
import
android.content.ComponentName
;
import
android.content.Context
;
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.IBinder
;
import
android.os.Message
;
import
android.provider.MediaStore
;
import
android.speech.RecognizerIntent
;
import
android.support.v4.content.ContextCompat
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.widget.Toast
;
import
java.util.UUID
;
import
static
android
.
content
.
ContentValues
.
TAG
;
/**
* Created by harshith on 17/6/16.
*/
...
...
@@ -43,9 +57,44 @@ public class ReceiveService extends Service {
else
if
(
message
.
what
==
Constants
.
READ_STATUS
)
{
if
(
message
.
arg1
==
Constants
.
READ_STATUS_OK
){
Toast
.
makeText
(
getBaseContext
(),
"Gesture "
+
message
.
arg2
+
" is executed"
,
Toast
.
LENGTH_SHORT
).
show
();
switch
(
message
.
arg2
)
{
case
0
:
receiveDataThread
=
new
ReceiveDataThread
(
bluetoothSocket
,
handler
,
globalClass
,
false
);
receiveDataThread
.
start
();
break
;
case
1
:
break
;
case
2
:
break
;
case
3
:
break
;
case
4
:
openMusicPlayer
();
break
;
case
5
:
audioPlayPause
();
break
;
case
6
:
break
;
case
7
:
break
;
case
8
:
okGoogle
();
break
;
case
9
:
openCamera
();
break
;
case
10
:
break
;
case
11
:
break
;
default
:
break
;
}
resumeReading
();
}
else
if
(
message
.
arg1
==
Constants
.
READ_STATUS_NOT_OK
){
L
.
s
(
getBaseContext
(),
"Connection Lost"
);
...
...
@@ -77,5 +126,107 @@ public class ReceiveService extends Service {
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
,
false
);
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
);
}
public
void
CameraClick
(){
Thread
t
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
Instrumentation
inst
=
new
Instrumentation
();
inst
.
sendKeyDownUpSync
(
KeyEvent
.
KEYCODE_CAMERA
);
}
catch
(
Exception
e
){
}
}
});
t
.
start
();
}
public
void
VolumeUp
(){
Thread
t
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
Instrumentation
inst
=
new
Instrumentation
();
inst
.
sendKeyDownUpSync
(
KeyEvent
.
KEYCODE_VOLUME_UP
);
}
catch
(
Exception
e
){
}
}
});
t
.
start
();
}
public
void
VolumeDown
(){
Thread
t
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
Instrumentation
inst
=
new
Instrumentation
();
inst
.
sendKeyDownUpSync
(
KeyEvent
.
KEYCODE_VOLUME_DOWN
);
}
catch
(
Exception
e
){
}
}
});
t
.
start
();
}
public
void
openMusicPlayer
(){
Intent
intent
=
new
Intent
();
ComponentName
comp
=
new
ComponentName
(
"com.android.music"
,
"com.android.music.MusicBrowserActivity"
);
intent
.
setComponent
(
comp
);
startActivity
(
intent
);
}
}
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