Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design2
/
2011104505
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박정현
2020-06-13 05:39:13 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
52abafe2fb7880fa45ef616bfcd02568a18138c2
52abafe2
1 parent
b5d8a2db
수정
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
29 deletions
talktalkspeak2/app/src/main/AndroidManifest.xml
talktalkspeak2/app/src/main/java/com/example/talktalkspeak/MainActivity.java
talktalkspeak2/app/src/main/java/com/example/talktalkspeak/SmsReceiver.java
talktalkspeak2/app/src/main/AndroidManifest.xml
View file @
52abafe
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.example.talktalkspeak"
>
<uses-permission
android:name=
"android.permission.BLUETOOTH"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_SMS"
/>
<application
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
...
...
@@ -10,13 +11,29 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".MainActivity"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<receiver
android:name=
"com.example.talktalkspeak.SmsReceiver"
android:enabled=
"true"
android:exported=
"true"
>
<intent-filter
android:priority=
"10000"
>
<action
android:name=
"android.provider.Telephony.SMS_RECEIVED"
/>
<action
android:name=
"android.bluetooth.device.action.ACL_CONNECTED"
/>
<action
android:name=
"android.bluetooth.device.action.ACL_DISCONNECTED"
/>
</intent-filter>
</receiver>
<service
android:name=
"com.example.talktalkspeak.NotificationService"
android:permission=
"android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
>
<intent-filter>
<action
android:name=
"android.service.notification.NotificationListenerService"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</service>
</application>
</manifest>
...
...
talktalkspeak2/app/src/main/java/com/example/talktalkspeak/MainActivity.java
View file @
52abafe
...
...
@@ -66,18 +66,26 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
private
int
isTTSReady
=
-
2
;
private
BroadcastReceiver
kakaoReceiver
;
long
now
=
System
.
currentTimeMillis
();
/* access modifiers changed from: private */
public
double
speed
=
1.0d
;
private
Spinner
spinner
;
private
Spinner
spinner2
;
/* access modifiers changed from: private */
public
TextToSpeech
tts
;
/* access modifiers changed from: private */
public
String
ttsengine
;
private
SeekBar
volumebar
;
public
void
onInit
(
int
status
)
{
if
(
status
==
0
)
{
int
language
=
this
.
tts
.
setLanguage
(
Locale
.
KOREAN
);
if
(
language
==
-
1
||
language
==
-
2
)
{
this
.
editText
.
setText
(
"지원하지 않는 언어입니다."
);
}
else
{
this
.
isTTSReady
=
status
;
}
}
else
{
this
.
editText
.
setText
(
"TTS 작업이 실패하였습니다."
);
}
}
/* access modifiers changed from: protected */
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -100,6 +108,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
initializeKakaoReceiver
();
Regex
(
this
.
tts
.
getEngines
().
toString
());
int
permission
=
ContextCompat
.
checkSelfPermission
(
this
,
"android.permission.RECEIVE_SMS"
);
if
(
permission
==
0
)
{
...
...
@@ -107,7 +116,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
this
.
button3
.
setBackgroundResource
(
R
.
drawable
.
on
);
}
else
{
Toast
.
makeText
(
this
,
"메시지 수신 권한 없음."
,
1
).
show
();
ActivityCompat
.
requestPermissions
(
this
,
new
String
[]{
"android.permission.RECEIVE_SMS"
},
1
);
//
ActivityCompat.requestPermissions(this, new String[]{"android.permission.RECEIVE_SMS"}, 1);
if
(
ActivityCompat
.
shouldShowRequestPermissionRationale
(
this
,
"android.permission.RECEIVE_SMS"
))
{
Toast
.
makeText
(
this
,
"메시지 권한 설명 필요함."
,
1
).
show
();
}
else
{
...
...
@@ -115,6 +124,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
}
}
this
.
button1
.
setTag
(
Integer
.
valueOf
(
permission
));
this
.
button1
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
public
void
onClick
(
View
view
)
{
...
...
@@ -193,7 +203,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
registerReceiver
(
this
.
kakaoReceiver
,
new
IntentFilter
(
"android.service.notification.NotificationListenerService"
));
setSeekBar
();
if
(!
permissionGrantred
())
{
startActivity
(
new
Intent
(
ACTION_NOTIFICATION_LISTENER_SETTINGS
));
startActivity
(
new
Intent
(
"android.setting.ACTION_NOTIFICATION_LISTENER_SETTINGS"
));
}
}
...
...
@@ -202,10 +212,10 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
if
(
intent
!=
null
)
{
String
sender
=
intent
.
getStringExtra
(
"sender"
);
String
contents
=
intent
.
getStringExtra
(
"contents"
);
String
date2
=
intent
.
getStringExtra
(
"receivedDate"
);
/*
if (sender == null || contents == null) {
this
.
editText
.
setText
((
CharSequence
)
null
);
this.editText.setText((CharSequence)
" "
);
} else {
TextView textView = this.editText;
textView.setText(sender + 10 + contents + 10);
...
...
@@ -214,22 +224,11 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
if (!this.button1.getBackground().getConstantState().equals(getResources().getDrawable(R.drawable.stop).getConstantState())) {
return;
}
*/
}
}
public
void
onInit
(
int
status
)
{
if
(
status
==
0
)
{
int
language
=
this
.
tts
.
setLanguage
(
Locale
.
KOREAN
);
if
(
language
==
-
1
||
language
==
-
2
)
{
this
.
editText
.
setText
(
"지원하지 않는 언어입니다."
);
}
else
{
this
.
isTTSReady
=
status
;
}
}
else
{
this
.
editText
.
setText
(
"TTS 작업이 실패하였습니다."
);
}
}
private
void
initializeKakaoReceiver
()
{
this
.
kakaoReceiver
=
new
BroadcastReceiver
()
{
...
...
@@ -305,7 +304,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
public
void
onRestart
()
{
super
.
onRestart
();
if
(!
permissionGrantred
())
{
startActivity
(
new
Intent
(
ACTION_NOTIFICATION_LISTENER_SETTINGS
));
startActivity
(
new
Intent
(
"android.setting.ACTION_NOTIFICATION_LISTENER_SETTINGS"
));
}
int
permission
=
ContextCompat
.
checkSelfPermission
(
this
,
"android.permission.RECEIVE_SMS"
);
if
(
permission
==
0
)
{
...
...
@@ -321,6 +320,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
}
}
this
.
button1
.
setTag
(
Integer
.
valueOf
(
permission
));
this
.
button1
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
public
void
onClick
(
View
view
)
{
if
(
MainActivity
.
this
.
button1
.
getBackground
().
getConstantState
().
equals
(
MainActivity
.
this
.
getResources
().
getDrawable
(
R
.
drawable
.
stop
).
getConstantState
()))
{
...
...
@@ -330,6 +330,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
}
}
});
this
.
bluetoothAdapter
=
BluetoothAdapter
.
getDefaultAdapter
();
BluetoothAdapter
bluetoothAdapter2
=
this
.
bluetoothAdapter
;
if
(
bluetoothAdapter2
==
null
)
{
...
...
talktalkspeak2/app/src/main/java/com/example/talktalkspeak/SmsReceiver.java
View file @
52abafe
...
...
@@ -10,14 +10,13 @@ import android.os.Bundle;
import
android.provider.ContactsContract
;
import
android.telephony.SmsMessage
;
import
android.util.Log
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
public
class
SmsReceiver
extends
BroadcastReceiver
{
private
static
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
if
(
intent
.
getAction
().
equals
(
"android.provider.Telephony.SMS_RECEIVED"
))
{
SmsMessage
[]
messages
=
parseSmsMessage
(
intent
.
getExtras
());
if
(
messages
.
length
>
0
)
{
sendToActivity
(
context
,
messages
[
0
].
getOriginatingAddress
(),
messages
[
0
].
getMessageBody
().
toString
(),
new
Date
(
messages
[
0
].
getTimestampMillis
()));
...
...
@@ -43,11 +42,9 @@ public class SmsReceiver extends BroadcastReceiver {
intent
.
addFlags
(
872415232
);
intent
.
putExtra
(
"sender"
,
sender
);
intent
.
putExtra
(
"contents"
,
contents
);
intent
.
putExtra
(
"receivedDate"
,
format
.
format
(
receivedDate
));
intent
.
putExtra
(
"class"
,
"SMS"
);
Log
.
d
(
"SMSToSpeech"
,
"Sender :"
+
sender
);
Log
.
d
(
"SMSToSpeech"
,
"contents : "
+
contents
);
Log
.
d
(
"SMSToSpeech"
,
"receivedDate : "
+
receivedDate
);
context
.
startActivity
(
intent
);
}
...
...
Please
register
or
login
to post a comment