From 9d92652385a09dec89e31441b5f5de44f4d1d99a Mon Sep 17 00:00:00 2001 From: Asura146 Date: Sun, 4 Aug 2024 00:18:43 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=A2?= =?UTF-8?q?=E3=82=A6=E3=83=88=E3=81=A8=E3=81=8B=E3=81=84=E3=82=8D=E3=81=84?= =?UTF-8?q?=E3=82=8D=E7=B4=B0=E3=81=8B=E3=81=84=E4=BF=AE=E6=AD=A3=E3=82=92?= =?UTF-8?q?=E5=8A=A0=E3=81=88=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/childguard/HomeFragment.java | 13 +++++++++---- .../com/example/childguard/MainActivity.java | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/example/childguard/HomeFragment.java b/app/src/main/java/com/example/childguard/HomeFragment.java index c0c71e8..daac6de 100644 --- a/app/src/main/java/com/example/childguard/HomeFragment.java +++ b/app/src/main/java/com/example/childguard/HomeFragment.java @@ -31,6 +31,9 @@ public class HomeFragment extends Fragment implements OnEventListener { private String str_key; private String mParam2; + final String GET_ON = "\n乗車状態"; + final String GET_OFF = "\n降車状態"; + public HomeFragment() { // Required empty public constructor @@ -107,6 +110,9 @@ public class HomeFragment extends Fragment implements OnEventListener { transaction.commit(); } + /** + * 乗車状態の画面を切り替える + */ private boolean updateUiState(boolean isInCar) { Log.d("HomeFragment", "updateUiState: called"); // Init @@ -124,16 +130,15 @@ public class HomeFragment extends Fragment implements OnEventListener { updateUiState(isInCar); return false; } - String get_on = "\n乗車状態"; - String get_off = "\n降車状態"; + if (!isInCar) { //乗車状態にする fl.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style_orange, null)); - tv.setText(get_on); + tv.setText(GET_ON); } else { //降車状態にする fl.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style, null)); - tv.setText(get_off); + tv.setText(GET_OFF); } return true; diff --git a/app/src/main/java/com/example/childguard/MainActivity.java b/app/src/main/java/com/example/childguard/MainActivity.java index 077adf6..ec2e48d 100644 --- a/app/src/main/java/com/example/childguard/MainActivity.java +++ b/app/src/main/java/com/example/childguard/MainActivity.java @@ -240,8 +240,10 @@ public class MainActivity extends AppCompatActivity { initNotification(mDocRef);//現在の位置を引数に initNotification()を処理 } } - - public void ResetReported() {//FireBaseのisReportedをfalseに初期化するメソッド + /** + * FireBaseのisReportedをfalseに初期化するメソッド + */ + public void ResetReported() { //共有プリファレンス全体の準備 SharedPreferences sharedPreferences = MainActivity.this.getSharedPreferences("app_situation", MODE_PRIVATE); String IdPref = sharedPreferences.getString("ID", null);//アプリに記録されているIDの取得 @@ -252,6 +254,9 @@ public class MainActivity extends AppCompatActivity { isReported.update("isReported", false).addOnSuccessListener(unused -> Log.d(TAG, "DocumentSnapshot successfully updated!")).addOnFailureListener(e -> Log.w(TAG, "Error updating document", e)); } + /** + * 乗車状態の変更 + */ public void changeIsInCar() { //共有プリファレンス全体の準備 SharedPreferences sharedPreferences = MainActivity.this.getSharedPreferences("app_situation", MODE_PRIVATE); @@ -272,6 +277,9 @@ public class MainActivity extends AppCompatActivity { E.apply(); } + /** + * 第三者通知に関する設定のメソッド + */ public void NotificationSetting() {//通知に関する設定の処理を行うメソッド int importance = NotificationManager.IMPORTANCE_DEFAULT; //通知チャネルの実装 @@ -280,9 +288,11 @@ public class MainActivity extends AppCompatActivity { NotificationManager notificationManager = getSystemService(NotificationManager.class); notificationManager.createNotificationChannel(channel); - } + /** + * 第三者通知を行うメソッド + */ public void Notification(Context context) {//実際に通知を行うメソッド final String CHANNEL_ID = "my_channel_id"; // 通知がクリックされたときに送信されるIntent