From 51fd91027d191ce728b00abc94330fd07394c2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 19:49:28 +0900 Subject: [PATCH 1/4] =?UTF-8?q?ShardPreference=E3=81=AE=E3=83=81=E3=82=A7?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=81=8C=E7=95=B0=E5=B8=B8=E3=81=A0=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/childguard/MainActivity.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/example/childguard/MainActivity.java b/app/src/main/java/com/example/childguard/MainActivity.java index 94acdd5..aa8ae60 100644 --- a/app/src/main/java/com/example/childguard/MainActivity.java +++ b/app/src/main/java/com/example/childguard/MainActivity.java @@ -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; @@ -165,12 +166,11 @@ public class MainActivity extends AppCompatActivity { 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); } - mDocRef = FirebaseFirestore.getInstance().document("users/" + IdPref);//現在の位置を取得 - this.flg = false; - initNotification(mDocRef); - super.onResume(); } @@ -203,13 +203,8 @@ public class MainActivity extends AppCompatActivity { notifyMain(); } } else { - if (isInCar) { - E.putBoolean("car", false); - E.apply(); - } else { - E.putBoolean("car", true); - E.apply(); - } + E.putBoolean("car", !isInCar); + E.apply(); // SupportFragmentManagerが現在表示しているFragmentを取得 Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragmentContainerView); if (fragment instanceof HomeFragment) { -- 2.45.1 From 23be550762160bb1f0844f164f86204139688d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 19:50:41 +0900 Subject: [PATCH 2/4] =?UTF-8?q?onResume=E3=81=AE=E5=A0=B4=E6=89=80?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/example/childguard/MainActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/childguard/MainActivity.java b/app/src/main/java/com/example/childguard/MainActivity.java index aa8ae60..e419c10 100644 --- a/app/src/main/java/com/example/childguard/MainActivity.java +++ b/app/src/main/java/com/example/childguard/MainActivity.java @@ -160,6 +160,7 @@ 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); @@ -171,7 +172,6 @@ public class MainActivity extends AppCompatActivity { this.flg = false; initNotification(mDocRef); } - super.onResume(); } private void initNotification(DocumentReference mDocRef) { -- 2.45.1 From 39ebdf0259494c3b50a5328ca07dea2a706ce25e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 19:55:30 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E5=BC=8F=E3=82=92?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/childguard/MainActivity.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/example/childguard/MainActivity.java b/app/src/main/java/com/example/childguard/MainActivity.java index e419c10..babe097 100644 --- a/app/src/main/java/com/example/childguard/MainActivity.java +++ b/app/src/main/java/com/example/childguard/MainActivity.java @@ -86,15 +86,17 @@ 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/")) { - Toast.makeText(this, "Chiled Guardに対応するQRコードではありません", Toast.LENGTH_LONG).show(); } else { - //URLの表示 - Toast.makeText(this, contents, Toast.LENGTH_SHORT).show(); - //ブラウザを起動し、URL先のサイトを開く - CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); - CustomTabsIntent customTabsIntent = builder.build(); - customTabsIntent.launchUrl(this, Uri.parse(contents)); + if (!contents.contains("https://practicefirestore1-8808c.web.app/")) { + Toast.makeText(this, "Chiled Guardに対応するQRコードではありません", Toast.LENGTH_LONG).show(); + } else { + //URLの表示 + Toast.makeText(this, contents, Toast.LENGTH_SHORT).show(); + //ブラウザを起動し、URL先のサイトを開く + CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); + CustomTabsIntent customTabsIntent = builder.build(); + customTabsIntent.launchUrl(this, Uri.parse(contents)); + } } } ); -- 2.45.1 From 87fbf5659ef0a0f1e704a6badeee1e05bc369ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 20:05:49 +0900 Subject: [PATCH 4/4] =?UTF-8?q?onStop=E3=82=92=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=A2=E3=82=A6=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/childguard/MainActivity.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/example/childguard/MainActivity.java b/app/src/main/java/com/example/childguard/MainActivity.java index babe097..797253a 100644 --- a/app/src/main/java/com/example/childguard/MainActivity.java +++ b/app/src/main/java/com/example/childguard/MainActivity.java @@ -137,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コードを読み取ってください"); @@ -194,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; @@ -288,14 +289,12 @@ public class MainActivity extends AppCompatActivity { } - @Override - public void onStop() { - super.onStop(); - Intent intent = new Intent(getApplication(), TestService.class); - startService(intent); - - - } +// @Override +// public void onStop() { +// super.onStop(); +// Intent intent = new Intent(getApplication(), TestService.class); +// startService(intent); +// } //Bluetooth_setupの戻るボタン public void setupBackButton(boolean enableBackButton) { -- 2.45.1