Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39e9336de0 | ||
|
|
b3972ef0e0 | ||
|
|
ffd307233b | ||
|
|
994bdb4b06 | ||
|
|
b774658eb4 | ||
|
|
3404e833e7 |
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
package com.example.childguard;
|
package com.example.childguard;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -62,6 +63,7 @@ public class HomeFragment extends Fragment implements OnEventListener{
|
|||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -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;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,7 @@ import android.os.Looper;
|
|||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
@@ -72,22 +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=サイト上で乗車状態のとき
|
||||||
ResetReported();// ResetReported();を処理→FireBaseのisReportedをfalseにする
|
if (documentSnapshot.getBoolean("isReported")) {
|
||||||
int importance = NotificationManager.IMPORTANCE_DEFAULT;
|
ResetReported();// ResetReported();を処理→FireBaseのisReportedをfalseにする
|
||||||
NotificationChannel channel = new NotificationChannel("CHANNEL_ID", "通報通知", importance);
|
NotificationSetting();//通知に関する設定のメソッド
|
||||||
channel.setDescription("第3者からの通報を検知しました");
|
Notification(getApplicationContext());//通知を行うメソッド
|
||||||
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
}
|
||||||
notificationManager.createNotificationChannel(channel);
|
} else if(!isInCar){//isReportedがfalse=サイト上で降車状態のとき
|
||||||
Log.d("nt", "レスポンスを検知しました2");
|
|
||||||
NotificationSetting();//通知に関する設定のメソッド
|
|
||||||
Notification(getApplicationContext());//通知を行うメソッド
|
|
||||||
} else if(isInCar){//Bluetoothの切断後5分以上乗車状態のままのとき→QRコード読み取りを忘れているとき→置き去り発生
|
|
||||||
ResetReported();//ResetReported();を処理→FireBaseのisReportedをfalseにする
|
ResetReported();//ResetReported();を処理→FireBaseのisReportedをfalseにする
|
||||||
periodicTaskManager.startPeriodicTask();//通知のループをストップする
|
|
||||||
}else {
|
}else {
|
||||||
ResetReported();//ResetReported();を処理→FireBaseのisReportedをfalseにする
|
ResetReported();//ResetReported();を処理→FireBaseのisReportedをfalseにする
|
||||||
periodicTaskManager.stopPeriodicTask();//5分毎に通知を行う
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +206,7 @@ public class TestService extends Service {
|
|||||||
}
|
}
|
||||||
public class PeriodicTaskManager {//Bluetoothの切断後に乗車状態にならなかった場合に5分毎に通知を送るメソッド
|
public class PeriodicTaskManager {//Bluetoothの切断後に乗車状態にならなかった場合に5分毎に通知を送るメソッド
|
||||||
|
|
||||||
private static final long INTERVAL = 5 *60* 1000; //300秒
|
private static final long INTERVAL = 5 * 1000; //300秒
|
||||||
private final Handler handler;
|
private final Handler handler;
|
||||||
private final Runnable periodicTask;
|
private final Runnable periodicTask;
|
||||||
|
|
||||||
@@ -232,7 +227,7 @@ public class TestService extends Service {
|
|||||||
E.putInt("time",5);
|
E.putInt("time",5);
|
||||||
E.apply();;
|
E.apply();;
|
||||||
}else {
|
}else {
|
||||||
E.putInt("time",time*2);
|
E.putInt("time",time+5);
|
||||||
E.apply();
|
E.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,6 +246,14 @@ public class TestService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void stopPeriodicTask() {
|
public void stopPeriodicTask() {
|
||||||
|
//共有プリファレンス全体の準備
|
||||||
|
SharedPreferences sharedPreferences = getSharedPreferences("app_situation", MODE_PRIVATE);
|
||||||
|
|
||||||
|
int time=sharedPreferences.getInt("time",0);
|
||||||
|
//共有プリファレンス 書き込みの準備
|
||||||
|
SharedPreferences.Editor E = sharedPreferences.edit();
|
||||||
|
E.putInt("time",0);
|
||||||
|
E.apply();
|
||||||
// 定期的な処理の停止
|
// 定期的な処理の停止
|
||||||
handler.removeCallbacks(periodicTask);
|
handler.removeCallbacks(periodicTask);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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