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