Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39e9336de0 | ||
|
|
b3972ef0e0 | ||
|
|
ffd307233b | ||
|
|
3404e833e7 | ||
|
|
54950e9d38 | ||
|
|
9d431bd297 | ||
|
|
e84b21288f | ||
|
|
b28911f386 |
No files matched your search
@@ -1,5 +1,7 @@
|
||||
package com.example.childguard;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -61,6 +63,7 @@ public class HomeFragment extends Fragment implements OnEventListener{
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,6 +79,12 @@ public class HomeFragment extends Fragment implements OnEventListener{
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Log.d("HomeFragment", "onResume: called");
|
||||
this.updateUiState(getIsInCarLocal());
|
||||
}
|
||||
|
||||
private boolean getIsInCarLocal() {
|
||||
SharedPreferences pref = requireActivity().getSharedPreferences("app_situation", requireActivity().MODE_PRIVATE);
|
||||
return pref.getBoolean("isInCar", false);
|
||||
}
|
||||
|
||||
//画面遷移メソッド
|
||||
|
||||
@@ -94,12 +94,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
.commit();
|
||||
firebaselink();
|
||||
|
||||
} else if (v.getItemId() == findViewById(R.id.navigation_notification).getId()) {
|
||||
findViewById(R.id.fab_scan_qr_code).setVisibility(FrameLayout.VISIBLE);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(findViewById(R.id.fragmentContainerView).getId(), NotificationFragment.newInstance("test", "test"))
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
|
||||
} else if (v.getItemId() == findViewById(R.id.navigation_settings).getId()) {
|
||||
findViewById(R.id.fab_scan_qr_code).setVisibility(FrameLayout.GONE);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
@@ -107,6 +102,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
}
|
||||
firebaselink();
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -131,13 +127,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
Log.d("BT", "Permission to connect bluetooth devices granted");
|
||||
}
|
||||
registerReceiver(receiver, intentFilter);
|
||||
changessituation();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
changessituation();
|
||||
Log.d("onResume", "called");
|
||||
Log.d("onResume", "mDocRef is null");
|
||||
firebaselink();
|
||||
@@ -162,7 +156,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
//FireBaseで更新された情報の判定
|
||||
if (documentSnapshot.getBoolean("isReported") == false) {//isReportedがfalseのとき=サイト上で保護者ボタンが押されたとき
|
||||
if (fragment instanceof HomeFragment) {//fragementがHomeFragmentのインスタンスかの判定
|
||||
changessituation();// changessituation()メソッドを処理→アプリ側の乗降状態を変化
|
||||
// changessituation();// changessituation()メソッドを処理→アプリ側の乗降状態を変化
|
||||
((HomeFragment) fragment).onEvent(!isInCar);
|
||||
}
|
||||
} else if (isInCar) {//第三者ボタンが押されたときにisInCarがtrueのとき=乗車状態のとき→いたずら防止
|
||||
int importance = NotificationManager.IMPORTANCE_DEFAULT;
|
||||
@@ -302,17 +297,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
notificationManager.notify(R.string.app_name, builder.build());//通知の表示
|
||||
}
|
||||
|
||||
|
||||
public void changessituation() {//乗降状態の管理をするためにHomeFramgentを呼び出すメソッド
|
||||
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("app_situation", MODE_PRIVATE);
|
||||
//共有プリファレンス 書き込みの準備
|
||||
SharedPreferences.Editor E = sharedPreferences.edit();
|
||||
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragmentContainerView);
|
||||
Boolean isInCar = sharedPreferences.getBoolean("isInCarPref", false);//現在の乗降状態を保存する共有プリファレンス
|
||||
((HomeFragment) fragment).onEvent(!isInCar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {//アプリをバックグラウンドにした時のメソッド
|
||||
super.onStop();
|
||||
|
||||
@@ -36,14 +36,14 @@ public class QrUtils {
|
||||
//IdPrefにの値が初期値の場合
|
||||
AllURL=KoteiURL+key;
|
||||
|
||||
int size = 1500;
|
||||
|
||||
int qrCodeSize = calculateQRCodeSize(); // 画面密度に応じてサイズを計算
|
||||
Bitmap QRGazou;
|
||||
Bitmap bitmapqr;
|
||||
try {
|
||||
//QRコード生成
|
||||
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
|
||||
bitmapqr = barcodeEncoder.encodeBitmap(AllURL, BarcodeFormat.QR_CODE, size, size);
|
||||
bitmapqr = barcodeEncoder.encodeBitmap(AllURL, BarcodeFormat.QR_CODE, qrCodeSize, qrCodeSize);
|
||||
} catch (WriterException e) {
|
||||
throw new AndroidRuntimeException("Barcode Error.", e);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class QrUtils {
|
||||
|
||||
// 画像のサイズの調整
|
||||
int disWidth = (width - bitmapqr.getWidth()) / 2;
|
||||
int disHeight = (int) ((height - bitmapqr.getHeight()) / 1.4);
|
||||
int disHeight = (int) ((height - bitmapqr.getHeight()) / 1.5);
|
||||
canvas.drawBitmap(bitmap, 0, 0, (Paint) null);
|
||||
canvas.drawBitmap(bitmapqr, disWidth, disHeight, (Paint) null); // 画像合成
|
||||
//Androidからプリンターへ印刷指示を出すサポートライブラリ
|
||||
@@ -72,7 +72,7 @@ public class QrUtils {
|
||||
|
||||
// 画面密度に基づいてQRコードのサイズを計算
|
||||
float density = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (1500 * density);
|
||||
return (int) (800 * density);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -73,26 +73,16 @@ public class TestService extends Service {
|
||||
E.putBoolean("isInCarPref", documentSnapshot.getBoolean("isInCar"));//乗降状態の判定
|
||||
E.apply();//確定処理
|
||||
Log.d("nt", "レスポンスを検知しました1");
|
||||
if (documentSnapshot.getBoolean("isReported") == true && isInCar) {//isReportedがtrueかつisInCarがtrueのとき=サイト上で第三者ボタンが押されたときに乗車状態のとき
|
||||
ResetReported();// ResetReported();を処理→FireBaseのisReportedをfalseにする
|
||||
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");
|
||||
NotificationSetting();//通知に関する設定のメソッド
|
||||
Notification(getApplicationContext());//通知を行うメソッド
|
||||
} else if(isInCar){//Bluetoothの切断後5分以上乗車状態のままのとき→QRコード読み取りを忘れているとき→置き去り発生
|
||||
if (isInCar) {//isReportedがtrue=サイト上で乗車状態のとき
|
||||
if (documentSnapshot.getBoolean("isReported")) {
|
||||
ResetReported();// ResetReported();を処理→FireBaseのisReportedをfalseにする
|
||||
NotificationSetting();//通知に関する設定のメソッド
|
||||
Notification(getApplicationContext());//通知を行うメソッド
|
||||
}
|
||||
} else if(!isInCar){//isReportedがfalse=サイト上で降車状態のとき
|
||||
ResetReported();//ResetReported();を処理→FireBaseのisReportedをfalseにする
|
||||
periodicTaskManager.startPeriodicTask();//通知のループをストップする
|
||||
E.putBoolean("isInCarPref", !documentSnapshot.getBoolean("isInCar"));//乗降状態の判定
|
||||
E.apply();//確定処理
|
||||
}else {
|
||||
ResetReported();//ResetReported();を処理→FireBaseのisReportedをfalseにする
|
||||
periodicTaskManager.stopPeriodicTask();//5分毎に通知を行う
|
||||
E.putBoolean("isInCarPref", documentSnapshot.getBoolean("isInCar"));//乗降状態の判定
|
||||
E.apply();//確定処理
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
android:id="@+id/navigation_home"
|
||||
android:icon="@drawable/ic_home_black_24dp"
|
||||
android:title="home"/>
|
||||
<item
|
||||
android:id="@+id/navigation_notification"
|
||||
android:icon="@drawable/notifications_fill0_wght400_grad0_opsz24"
|
||||
android:title="notification"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/navigation_settings"
|
||||
android:icon="@drawable/baseline_app_settings_alt_24"
|
||||
|
||||
Reference in new issue
Block a user