박정현

수정

1 -<?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 1 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="com.example.talktalkspeak"> 2 package="com.example.talktalkspeak">
4 3
5 <uses-permission android:name="android.permission.BLUETOOTH" /> 4 <uses-permission android:name="android.permission.BLUETOOTH" />
5 + <uses-permission android:name="android.permission.RECEIVE_SMS"/>
6 +
6 <application 7 <application
7 android:allowBackup="true" 8 android:allowBackup="true"
8 android:icon="@mipmap/ic_launcher" 9 android:icon="@mipmap/ic_launcher"
...@@ -10,13 +11,29 @@ ...@@ -10,13 +11,29 @@
10 android:roundIcon="@mipmap/ic_launcher_round" 11 android:roundIcon="@mipmap/ic_launcher_round"
11 android:supportsRtl="true" 12 android:supportsRtl="true"
12 android:theme="@style/AppTheme"> 13 android:theme="@style/AppTheme">
14 +
13 <activity android:name=".MainActivity"> 15 <activity android:name=".MainActivity">
14 <intent-filter> 16 <intent-filter>
15 <action android:name="android.intent.action.MAIN" /> 17 <action android:name="android.intent.action.MAIN" />
16 -
17 <category android:name="android.intent.category.LAUNCHER" /> 18 <category android:name="android.intent.category.LAUNCHER" />
18 </intent-filter> 19 </intent-filter>
19 </activity> 20 </activity>
21 +
22 + <receiver android:name="com.example.talktalkspeak.SmsReceiver" android:enabled="true" android:exported="true">
23 + <intent-filter android:priority="10000">
24 + <action android:name="android.provider.Telephony.SMS_RECEIVED"/>
25 + <action android:name="android.bluetooth.device.action.ACL_CONNECTED"/>
26 + <action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/>
27 + </intent-filter>
28 + </receiver>
29 +
30 + <service android:name="com.example.talktalkspeak.NotificationService" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
31 + <intent-filter>
32 + <action android:name="android.service.notification.NotificationListenerService"/>
33 + <category android:name="android.intent.category.LAUNCHER"/>
34 + </intent-filter>
35 + </service>
36 +
20 </application> 37 </application>
21 38
22 </manifest> 39 </manifest>
......
...@@ -66,18 +66,26 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn ...@@ -66,18 +66,26 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
66 private int isTTSReady = -2; 66 private int isTTSReady = -2;
67 private BroadcastReceiver kakaoReceiver; 67 private BroadcastReceiver kakaoReceiver;
68 long now = System.currentTimeMillis(); 68 long now = System.currentTimeMillis();
69 -
70 -
71 - /* access modifiers changed from: private */
72 public double speed = 1.0d; 69 public double speed = 1.0d;
73 private Spinner spinner; 70 private Spinner spinner;
74 private Spinner spinner2; 71 private Spinner spinner2;
75 - /* access modifiers changed from: private */
76 public TextToSpeech tts; 72 public TextToSpeech tts;
77 - /* access modifiers changed from: private */
78 public String ttsengine; 73 public String ttsengine;
79 private SeekBar volumebar; 74 private SeekBar volumebar;
80 75
76 + public void onInit(int status) {
77 + if (status == 0) {
78 + int language = this.tts.setLanguage(Locale.KOREAN);
79 + if (language == -1 || language == -2) {
80 + this.editText.setText("지원하지 않는 언어입니다.");
81 + } else {
82 + this.isTTSReady = status;
83 + }
84 + } else {
85 + this.editText.setText("TTS 작업이 실패하였습니다.");
86 + }
87 + }
88 +
81 /* access modifiers changed from: protected */ 89 /* access modifiers changed from: protected */
82 public void onCreate(Bundle savedInstanceState) { 90 public void onCreate(Bundle savedInstanceState) {
83 super.onCreate(savedInstanceState); 91 super.onCreate(savedInstanceState);
...@@ -100,6 +108,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn ...@@ -100,6 +108,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
100 initializeKakaoReceiver(); 108 initializeKakaoReceiver();
101 Regex(this.tts.getEngines().toString()); 109 Regex(this.tts.getEngines().toString());
102 110
111 +
103 int permission = ContextCompat.checkSelfPermission(this, "android.permission.RECEIVE_SMS"); 112 int permission = ContextCompat.checkSelfPermission(this, "android.permission.RECEIVE_SMS");
104 113
105 if (permission == 0) { 114 if (permission == 0) {
...@@ -107,7 +116,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn ...@@ -107,7 +116,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
107 this.button3.setBackgroundResource(R.drawable.on); 116 this.button3.setBackgroundResource(R.drawable.on);
108 } else { 117 } else {
109 Toast.makeText(this, "메시지 수신 권한 없음.", 1).show(); 118 Toast.makeText(this, "메시지 수신 권한 없음.", 1).show();
110 - ActivityCompat.requestPermissions(this, new String[]{"android.permission.RECEIVE_SMS"}, 1); 119 + // ActivityCompat.requestPermissions(this, new String[]{"android.permission.RECEIVE_SMS"}, 1);
111 if (ActivityCompat.shouldShowRequestPermissionRationale(this, "android.permission.RECEIVE_SMS")) { 120 if (ActivityCompat.shouldShowRequestPermissionRationale(this, "android.permission.RECEIVE_SMS")) {
112 Toast.makeText(this, "메시지 권한 설명 필요함.", 1).show(); 121 Toast.makeText(this, "메시지 권한 설명 필요함.", 1).show();
113 } else { 122 } else {
...@@ -115,6 +124,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn ...@@ -115,6 +124,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
115 } 124 }
116 } 125 }
117 126
127 +
118 this.button1.setTag(Integer.valueOf(permission)); 128 this.button1.setTag(Integer.valueOf(permission));
119 this.button1.setOnClickListener(new View.OnClickListener() { 129 this.button1.setOnClickListener(new View.OnClickListener() {
120 public void onClick(View view) { 130 public void onClick(View view) {
...@@ -193,7 +203,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn ...@@ -193,7 +203,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
193 registerReceiver(this.kakaoReceiver, new IntentFilter("android.service.notification.NotificationListenerService")); 203 registerReceiver(this.kakaoReceiver, new IntentFilter("android.service.notification.NotificationListenerService"));
194 setSeekBar(); 204 setSeekBar();
195 if (!permissionGrantred()) { 205 if (!permissionGrantred()) {
196 - startActivity(new Intent(ACTION_NOTIFICATION_LISTENER_SETTINGS)); 206 + startActivity(new Intent("android.setting.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
197 } 207 }
198 } 208 }
199 209
...@@ -202,10 +212,10 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn ...@@ -202,10 +212,10 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
202 if (intent != null) { 212 if (intent != null) {
203 String sender = intent.getStringExtra("sender"); 213 String sender = intent.getStringExtra("sender");
204 String contents = intent.getStringExtra("contents"); 214 String contents = intent.getStringExtra("contents");
205 - String date2 = intent.getStringExtra("receivedDate");
206 215
216 +/*
207 if (sender == null || contents == null) { 217 if (sender == null || contents == null) {
208 - this.editText.setText((CharSequence) null); 218 + this.editText.setText((CharSequence) " ");
209 } else { 219 } else {
210 TextView textView = this.editText; 220 TextView textView = this.editText;
211 textView.setText(sender + 10 + contents + 10); 221 textView.setText(sender + 10 + contents + 10);
...@@ -214,22 +224,11 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn ...@@ -214,22 +224,11 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
214 if (!this.button1.getBackground().getConstantState().equals(getResources().getDrawable(R.drawable.stop).getConstantState())) { 224 if (!this.button1.getBackground().getConstantState().equals(getResources().getDrawable(R.drawable.stop).getConstantState())) {
215 return; 225 return;
216 } 226 }
217 - 227 +*/
218 } 228 }
219 } 229 }
220 230
221 - public void onInit(int status) { 231 +
222 - if (status == 0) {
223 - int language = this.tts.setLanguage(Locale.KOREAN);
224 - if (language == -1 || language == -2) {
225 - this.editText.setText("지원하지 않는 언어입니다.");
226 - } else {
227 - this.isTTSReady = status;
228 - }
229 - } else {
230 - this.editText.setText("TTS 작업이 실패하였습니다.");
231 - }
232 - }
233 232
234 private void initializeKakaoReceiver() { 233 private void initializeKakaoReceiver() {
235 this.kakaoReceiver = new BroadcastReceiver() { 234 this.kakaoReceiver = new BroadcastReceiver() {
...@@ -305,7 +304,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn ...@@ -305,7 +304,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
305 public void onRestart() { 304 public void onRestart() {
306 super.onRestart(); 305 super.onRestart();
307 if (!permissionGrantred()) { 306 if (!permissionGrantred()) {
308 - startActivity(new Intent(ACTION_NOTIFICATION_LISTENER_SETTINGS)); 307 + startActivity(new Intent("android.setting.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
309 } 308 }
310 int permission = ContextCompat.checkSelfPermission(this, "android.permission.RECEIVE_SMS"); 309 int permission = ContextCompat.checkSelfPermission(this, "android.permission.RECEIVE_SMS");
311 if (permission == 0) { 310 if (permission == 0) {
...@@ -321,6 +320,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn ...@@ -321,6 +320,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
321 } 320 }
322 } 321 }
323 this.button1.setTag(Integer.valueOf(permission)); 322 this.button1.setTag(Integer.valueOf(permission));
323 +
324 this.button1.setOnClickListener(new View.OnClickListener() { 324 this.button1.setOnClickListener(new View.OnClickListener() {
325 public void onClick(View view) { 325 public void onClick(View view) {
326 if (MainActivity.this.button1.getBackground().getConstantState().equals(MainActivity.this.getResources().getDrawable(R.drawable.stop).getConstantState())) { 326 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 ...@@ -330,6 +330,7 @@ public class MainActivity extends AppCompatActivity implements TextToSpeech.OnIn
330 } 330 }
331 } 331 }
332 }); 332 });
333 +
333 this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 334 this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
334 BluetoothAdapter bluetoothAdapter2 = this.bluetoothAdapter; 335 BluetoothAdapter bluetoothAdapter2 = this.bluetoothAdapter;
335 if (bluetoothAdapter2 == null) { 336 if (bluetoothAdapter2 == null) {
......
...@@ -10,14 +10,13 @@ import android.os.Bundle; ...@@ -10,14 +10,13 @@ import android.os.Bundle;
10 import android.provider.ContactsContract; 10 import android.provider.ContactsContract;
11 import android.telephony.SmsMessage; 11 import android.telephony.SmsMessage;
12 import android.util.Log; 12 import android.util.Log;
13 -import java.text.SimpleDateFormat;
14 import java.util.Date; 13 import java.util.Date;
15 14
16 public class SmsReceiver extends BroadcastReceiver { 15 public class SmsReceiver extends BroadcastReceiver {
17 - private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
18 16
19 public void onReceive(Context context, Intent intent) { 17 public void onReceive(Context context, Intent intent) {
20 if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) { 18 if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
19 +
21 SmsMessage[] messages = parseSmsMessage(intent.getExtras()); 20 SmsMessage[] messages = parseSmsMessage(intent.getExtras());
22 if (messages.length > 0) { 21 if (messages.length > 0) {
23 sendToActivity(context, messages[0].getOriginatingAddress(), messages[0].getMessageBody().toString(), new Date(messages[0].getTimestampMillis())); 22 sendToActivity(context, messages[0].getOriginatingAddress(), messages[0].getMessageBody().toString(), new Date(messages[0].getTimestampMillis()));
...@@ -43,11 +42,9 @@ public class SmsReceiver extends BroadcastReceiver { ...@@ -43,11 +42,9 @@ public class SmsReceiver extends BroadcastReceiver {
43 intent.addFlags(872415232); 42 intent.addFlags(872415232);
44 intent.putExtra("sender", sender); 43 intent.putExtra("sender", sender);
45 intent.putExtra("contents", contents); 44 intent.putExtra("contents", contents);
46 - intent.putExtra("receivedDate", format.format(receivedDate));
47 intent.putExtra("class", "SMS"); 45 intent.putExtra("class", "SMS");
48 Log.d("SMSToSpeech", "Sender :" + sender); 46 Log.d("SMSToSpeech", "Sender :" + sender);
49 Log.d("SMSToSpeech", "contents : " + contents); 47 Log.d("SMSToSpeech", "contents : " + contents);
50 - Log.d("SMSToSpeech", "receivedDate : " + receivedDate);
51 context.startActivity(intent); 48 context.startActivity(intent);
52 } 49 }
53 50
......