Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c90d0b8f6e | ||
|
|
87fbf5659e | ||
|
|
39ebdf0259 | ||
|
|
23be550762 | ||
|
|
51fd91027d | ||
|
|
e4aafc44c6 | ||
|
|
a4178b6901 |
No files matched your search
Generated
+2
-1
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
@@ -34,6 +35,7 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<service android:name=".TestService" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -23,6 +23,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Vibrator;
|
||||
@@ -85,7 +86,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
String contents = result.getContents();
|
||||
if (contents == null) {
|
||||
Toast.makeText(this, "QRコードが読み取れませんでした", Toast.LENGTH_LONG).show();
|
||||
} else if (!contents.contains("https://practicefirestore1-8808c.web.app/")) {
|
||||
} else {
|
||||
if (!contents.contains("https://practicefirestore1-8808c.web.app/")) {
|
||||
Toast.makeText(this, "Chiled Guardに対応するQRコードではありません", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
//URLの表示
|
||||
@@ -96,6 +98,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
customTabsIntent.launchUrl(this, Uri.parse(contents));
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@Override
|
||||
@@ -134,7 +137,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
});
|
||||
|
||||
findViewById(R.id.fab_scan_qr_code).setOnClickListener(v -> {
|
||||
Log.d("QRFragment", "onClick: called");
|
||||
Log.d("MainActivity/Fab", "onClick: called");
|
||||
//QRリーダ起動
|
||||
ScanOptions options = new ScanOptions();
|
||||
options.setPrompt("QRコードを読み取ってください");
|
||||
@@ -159,19 +162,18 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Log.d("onResume", "called");
|
||||
Log.d("onResume", "mDocRef is null");
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("app_situation", MODE_PRIVATE);
|
||||
String IdPref = sharedPreferences.getString("ID", null);
|
||||
if (IdPref == null) {
|
||||
Log.d("onResume", "ID not initialized.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
mDocRef = FirebaseFirestore.getInstance().document("users/" + IdPref);//現在の位置を取得
|
||||
this.flg = false;
|
||||
initNotification(mDocRef);
|
||||
|
||||
super.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
private void initNotification(DocumentReference mDocRef) {
|
||||
@@ -192,6 +194,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
String parent = documentSnapshot.getString("parent");
|
||||
Log.d("nt", "レスポンスを検知しました1");
|
||||
|
||||
assert parent != null;
|
||||
if (parent.equals("s")) {//FireBaseの更新情報が"S"のとき=サイト上で第三者ボタンが押されたとき
|
||||
if (isInCar) {
|
||||
int importance = NotificationManager.IMPORTANCE_DEFAULT;
|
||||
@@ -203,13 +206,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
notifyMain();
|
||||
}
|
||||
} else {
|
||||
if (isInCar) {
|
||||
E.putBoolean("car", false);
|
||||
E.putBoolean("car", !isInCar);
|
||||
E.apply();
|
||||
} else {
|
||||
E.putBoolean("car", true);
|
||||
E.apply();
|
||||
}
|
||||
// SupportFragmentManagerが現在表示しているFragmentを取得
|
||||
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragmentContainerView);
|
||||
if (fragment instanceof HomeFragment) {
|
||||
@@ -291,6 +289,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onStop() {
|
||||
// super.onStop();
|
||||
// Intent intent = new Intent(getApplication(), TestService.class);
|
||||
// startService(intent);
|
||||
// }
|
||||
|
||||
//Bluetooth_setupの戻るボタン
|
||||
public void setupBackButton(boolean enableBackButton) {
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.example.childguard;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.IBinder;
|
||||
import android.os.Vibrator;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
public class TestService extends Service {
|
||||
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
|
||||
|
||||
audioStart();
|
||||
|
||||
return START_NOT_STICKY;
|
||||
|
||||
}
|
||||
|
||||
private void audioStart(){
|
||||
//↓通知をする際に起動するバイブレーション
|
||||
((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(1000);
|
||||
//通知のやつ↓
|
||||
int importance = NotificationManager.IMPORTANCE_DEFAULT;
|
||||
|
||||
NotificationChannel channel = new NotificationChannel("CHANNEL_ID", "通報通知", importance);
|
||||
//説明・説明 ここに通知の説明を書くことができる↓
|
||||
channel.setDescription("第3者からの通報を検知しました");
|
||||
|
||||
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
//通知のやつ↑
|
||||
Log.d("nt","レスポンスを検知しました2");
|
||||
//↓通知の詳細設定的な奴
|
||||
NotificationCompat.Builder builder = new NotificationCompat
|
||||
|
||||
.Builder(this, "CHANNEL_ID")
|
||||
.setSmallIcon(android.R.drawable.ic_menu_info_details)
|
||||
.setContentTitle("通報検知")
|
||||
.setContentText("子供の置き去りを検知しました。")
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
|
||||
|
||||
|
||||
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
||||
// TODO: Consider calling
|
||||
// ActivityCompat#requestPermissions
|
||||
// here to request the missing permissions, and then overriding
|
||||
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
||||
// int[] grantResults)
|
||||
// to handle the case where the user grants the permission. See the documentation
|
||||
// for ActivityCompat#requestPermissions for more details.
|
||||
return;
|
||||
}
|
||||
notificationManager.notify(R.string.app_name, builder.build());
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user