diff --git a/.idea/misc.xml b/.idea/misc.xml index 773fe0f..8978d23 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/app/release/app-release.apk b/app/release/app-release.apk deleted file mode 100644 index 332ccd1..0000000 Binary files a/app/release/app-release.apk and /dev/null differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json deleted file mode 100644 index 2d32550..0000000 --- a/app/release/output-metadata.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": 3, - "artifactType": { - "type": "APK", - "kind": "Directory" - }, - "applicationId": "com.example.childguard", - "variantName": "release", - "elements": [ - { - "type": "SINGLE", - "filters": [], - "attributes": [], - "versionCode": 1, - "versionName": "1.0", - "outputFile": "app-release.apk" - } - ], - "elementType": "File" -} \ No newline at end of file diff --git a/app/src/main/java/com/example/childguard/Bluetooth_device_save.java b/app/src/main/java/com/example/childguard/Bluetooth_device_save.java new file mode 100644 index 0000000..5673005 --- /dev/null +++ b/app/src/main/java/com/example/childguard/Bluetooth_device_save.java @@ -0,0 +1,22 @@ +package com.example.childguard; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceManager; + +import androidx.appcompat.app.AppCompatActivity; + +public class Bluetooth_device_save { + SharedPreferences pref; + +// public void device_save(String deviceAddress){ +// pref = PreferenceManager.getDefaultSharedPreferencesName() +// SharedPreferences.Editor e=pref.edit(); +// e.putString("bluetooth_device1",deviceAddress); +// e.apply(); +// } + public String device_info(){ + return pref.getString("bluetooth_device1","not_device"); + } +} diff --git a/app/src/main/java/com/example/childguard/First_Start.java b/app/src/main/java/com/example/childguard/First_Start.java index 479aed8..77e6104 100644 --- a/app/src/main/java/com/example/childguard/First_Start.java +++ b/app/src/main/java/com/example/childguard/First_Start.java @@ -1,18 +1,14 @@ package com.example.childguard; -import android.annotation.SuppressLint; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; public class First_Start extends AppCompatActivity { - - protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.first_start); - } } diff --git a/app/src/main/java/com/example/childguard/GenerateQrFragment.java b/app/src/main/java/com/example/childguard/GenerateQrFragment.java index 6a6cd08..ed71a65 100644 --- a/app/src/main/java/com/example/childguard/GenerateQrFragment.java +++ b/app/src/main/java/com/example/childguard/GenerateQrFragment.java @@ -23,7 +23,6 @@ public class GenerateQrFragment extends Fragment { public GenerateQrFragment() { // Required empty public constructor } - public static GenerateQrFragment newInstance(String key) { GenerateQrFragment fragment = new GenerateQrFragment(); Bundle args = new Bundle(); @@ -55,7 +54,7 @@ public class GenerateQrFragment extends Fragment { ImageView imageView = view.findViewById(R.id.result_bitmap_image_view); imageView.setImageBitmap(result); - view.findViewById(R.id.button_print).setOnClickListener(v -> { + view.findViewById(R.id.button_print).setOnClickListener( v -> { PrintHelper photoPrinter = new PrintHelper(requireContext()); photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT); photoPrinter.printBitmap("placeholder", result, () -> { @@ -63,7 +62,7 @@ public class GenerateQrFragment extends Fragment { }); }); - view.findViewById(R.id.button_cancel).setOnClickListener(v -> { + view.findViewById(R.id.button_cancel).setOnClickListener( v -> { getParentFragmentManager().popBackStack(); }); } diff --git a/app/src/main/java/com/example/childguard/HomeFragment.java b/app/src/main/java/com/example/childguard/HomeFragment.java index 9058f94..49a054e 100644 --- a/app/src/main/java/com/example/childguard/HomeFragment.java +++ b/app/src/main/java/com/example/childguard/HomeFragment.java @@ -20,7 +20,7 @@ import androidx.fragment.app.FragmentTransaction; * Use the {@link HomeFragment#newInstance} factory method to * create an instance of this fragment. */ -public class HomeFragment extends Fragment implements OnEventListener { +public class HomeFragment extends Fragment implements OnEventListener{ // TODO: Rename parameter arguments, choose names that match // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER @@ -133,26 +133,26 @@ public class HomeFragment extends Fragment implements OnEventListener { return true; } - private boolean updateBluetoothSituation(Boolean BluetoothConnect) { + private boolean updateBluetoothSituation(Boolean Bluetoothconnect){ FrameLayout frameLayout; TextView textView; ImageView imageView; try { - frameLayout = requireView().findViewById(R.id.situation_bg2); - textView = requireView().findViewById(R.id.Bluetoothsituation); - imageView = requireView().findViewById(R.id.Bluetoothsituationimage); - } catch (NullPointerException e) { + frameLayout=requireView().findViewById(R.id.situation_bg2); + textView=requireView().findViewById(R.id.Bluetoothsituation); + imageView=requireView().findViewById(R.id.Bluetoothsituationimage); + }catch (NullPointerException e) { Log.d("HomeFragment", "updateUiState: view is null"); return false; } catch (IllegalStateException e) { Log.d("HomeFragment", "updateUiState: view is not attached"); getParentFragmentManager().beginTransaction().replace(R.id.fragmentContainerView, HomeFragment.newInstance("test", "test")).commit(); - updateBluetoothSituation(BluetoothConnect); + updateBluetoothSituation(Bluetoothconnect); return false; } - String connect = "接続中"; - String disconnect = "切断中"; - if (BluetoothConnect) { + String connect="接続中"; + String disconnect="切断中"; + if (Bluetoothconnect) { //接続状態にする frameLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style_orange, null)); textView.setText(connect); @@ -177,13 +177,13 @@ public class HomeFragment extends Fragment implements OnEventListener { @Override public void onEvent2(boolean BluetoothConnect) { - return; + return ; } @Override - public boolean onEvent2(Boolean BluetoothConnect) {//Bluetoothの接続切断を受け取ってupdateBluetoothSituation()に渡す - updateBluetoothSituation(BluetoothConnect); + public boolean onEvent2(Boolean Bluetoothconnect) {//Bluetoothの接続切断を受け取ってupdateBluetoothSituation()に渡す + updateBluetoothSituation(Bluetoothconnect); return false; } } diff --git a/app/src/main/java/com/example/childguard/MainActivity.java b/app/src/main/java/com/example/childguard/MainActivity.java index c67c8ea..0ddb084 100644 --- a/app/src/main/java/com/example/childguard/MainActivity.java +++ b/app/src/main/java/com/example/childguard/MainActivity.java @@ -12,6 +12,7 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.graphics.Color; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Handler; @@ -24,6 +25,7 @@ import android.widget.Toast; import androidx.activity.result.ActivityResultLauncher; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; +import androidx.browser.customtabs.CustomTabsIntent; import androidx.core.app.ActivityCompat; import androidx.core.app.NotificationCompat; import androidx.fragment.app.Fragment; @@ -63,7 +65,7 @@ public class MainActivity extends AppCompatActivity { if (!contents.contains("https://practicefirestore1-8808c.web.app/")) { Toast.makeText(this, "Child Guardに対応するQRコードではありません", Toast.LENGTH_LONG).show(); } else { - changeIsInCar(); + changeisInCar(); } } } @@ -99,7 +101,7 @@ public class MainActivity extends AppCompatActivity { .replace(findViewById(R.id.fragmentContainerView).getId(), this.homeFragment) .addToBackStack(null) .commit(); - firebaseLink(); + firebaselink(); } else if (v.getItemId() == findViewById(R.id.navigation_settings).getId()) { findViewById(R.id.fab_scan_qr_code).setVisibility(FrameLayout.GONE); @@ -108,7 +110,7 @@ public class MainActivity extends AppCompatActivity { .addToBackStack(null) .commit(); } - firebaseLink(); + firebaselink(); Bluetooth_status(); return true; }); @@ -144,7 +146,7 @@ public class MainActivity extends AppCompatActivity { super.onResume(); Log.d("onResume", "called"); Log.d("onResume", "mDocRef is null"); - firebaseLink(); + firebaselink(); } private void initNotification(DocumentReference mDocRef) {//サイト上で押されたボタンの管理 @@ -166,7 +168,7 @@ public class MainActivity extends AppCompatActivity { //FireBaseで更新された情報の判定 if (!documentSnapshot.getBoolean("isReported")) {//isReportedがfalseのとき=サイト上で保護者ボタンが押されたとき if (fragment instanceof HomeFragment) {//fragmentがHomeFragmentのインスタンスかの判定 -// changes-situation();// changes-situation()メソッドを処理→アプリ側の乗降状態を変化 +// changessituation();// changessituation()メソッドを処理→アプリ側の乗降状態を変化 ((HomeFragment) fragment).onEvent(!isInCar); } } else if (isInCar) {//第三者ボタンが押されたときにisInCarがtrueのとき=乗車状態のとき→いたずら防止 @@ -229,7 +231,7 @@ public class MainActivity extends AppCompatActivity { - public void firebaseLink() {//Firebaseのドキュメントの取得 + public void firebaselink() {//Firebaseのドキュメントの取得 //共有プリファレンス全体の準備 SharedPreferences sharedPreferences = getSharedPreferences("app_situation", MODE_PRIVATE); String IdPref = sharedPreferences.getString("ID", null);////アプリに記録されているIDの取得 @@ -253,7 +255,7 @@ 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() { + public void changeisInCar() { //共有プリファレンス全体の準備 SharedPreferences sharedPreferences = MainActivity.this.getSharedPreferences("app_situation", MODE_PRIVATE); //共有プリファレンス 書き込みの準備 @@ -416,6 +418,7 @@ public class MainActivity extends AppCompatActivity { String action = intent.getAction(); // may need to chain this to a recognizing function BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); Boolean isInCar = pref.getBoolean("isInCarPref", false); + Boolean Bluetoothconnect = pref.getBoolean("change", false); if (ActivityCompat.checkSelfPermission(context, android.Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) { Log.d("BT", "No permission to connect bluetooth devices"); return; @@ -474,9 +477,9 @@ public class MainActivity extends AppCompatActivity { public void changeBluetooth(){ SharedPreferences pref=getSharedPreferences("Bluetooth_situation",MODE_PRIVATE); SharedPreferences.Editor e=pref.edit(); - Boolean BluetoothConnect = pref.getBoolean("change", false); + Boolean Bluetoothconnect = pref.getBoolean("change", false); Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragmentContainerView); - ((HomeFragment) fragment).onEvent2(BluetoothConnect); + ((HomeFragment) fragment).onEvent2(Bluetoothconnect); } } diff --git a/app/src/main/java/com/example/childguard/NotificationReceiver.java b/app/src/main/java/com/example/childguard/NotificationReceiver.java index 97b395b..4fb3f5f 100644 --- a/app/src/main/java/com/example/childguard/NotificationReceiver.java +++ b/app/src/main/java/com/example/childguard/NotificationReceiver.java @@ -5,7 +5,6 @@ import android.content.Context; import android.content.Intent; public class NotificationReceiver extends BroadcastReceiver {//通知をタップしたときにアプリを起動する処理 - @Override public void onReceive(Context context, Intent intent) { if (intent.getAction() != null && intent.getAction().equals("OPEN_ACTIVITY")) {// 通知がタップされたときの処理 diff --git a/app/src/main/java/com/example/childguard/OnEventListener.java b/app/src/main/java/com/example/childguard/OnEventListener.java index 1782b5f..095bf84 100644 --- a/app/src/main/java/com/example/childguard/OnEventListener.java +++ b/app/src/main/java/com/example/childguard/OnEventListener.java @@ -6,5 +6,5 @@ public interface OnEventListener { void onEvent2(boolean BluetoothConnect); - boolean onEvent2(Boolean BluetoothConnect); + boolean onEvent2(Boolean Bluetoothconnect); } diff --git a/app/src/main/java/com/example/childguard/QrUtils.java b/app/src/main/java/com/example/childguard/QrUtils.java index 522097a..4583c03 100644 --- a/app/src/main/java/com/example/childguard/QrUtils.java +++ b/app/src/main/java/com/example/childguard/QrUtils.java @@ -1,14 +1,19 @@ package com.example.childguard; import android.content.Context; +import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; +import android.graphics.drawable.BitmapDrawable; import android.util.AndroidRuntimeException; import android.util.DisplayMetrics; import android.util.Log; import android.view.WindowManager; +import android.widget.ImageView; + +import androidx.print.PrintHelper; import com.google.zxing.BarcodeFormat; import com.google.zxing.WriterException; @@ -25,20 +30,20 @@ public class QrUtils { public Bitmap getBitmap(String key) { Log.d("getBitmap", "getBitmap: " + key); - String fixationURL = "https://practicefirestore1-8808c.web.app/?id="; + String KoteiURL = "https://practicefirestore1-8808c.web.app/?id="; //すべてのドメイン String AllURL; //IdPrefにの値が初期値の場合 - AllURL = fixationURL + key; + AllURL=KoteiURL+key; int qrCodeSize = calculateQRCodeSize(); // 画面密度に応じてサイズを計算 - Bitmap QRImage; - Bitmap bitmapQR; + Bitmap QRGazou; + Bitmap bitmapqr; try { //QRコード生成 BarcodeEncoder barcodeEncoder = new BarcodeEncoder(); - bitmapQR = barcodeEncoder.encodeBitmap(AllURL, BarcodeFormat.QR_CODE, qrCodeSize, qrCodeSize); + bitmapqr = barcodeEncoder.encodeBitmap(AllURL, BarcodeFormat.QR_CODE, qrCodeSize, qrCodeSize); } catch (WriterException e) { throw new AndroidRuntimeException("Barcode Error.", e); } @@ -46,20 +51,19 @@ public class QrUtils { Bitmap bitmap = BitmapFactory.decodeResource(this.context.getResources(), R.drawable.a_group_qr_sos_2); int width = bitmap.getWidth(); int height = bitmap.getHeight(); - QRImage = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + QRGazou = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); // Canvasの準備 - Canvas canvas = new Canvas(QRImage); + Canvas canvas = new Canvas(QRGazou); // 画像のサイズの調整 - int disWidth = (width - bitmapQR.getWidth()) / 2; - int disHeight = (int) ((height - bitmapQR.getHeight()) / 1.5); + int disWidth = (width - bitmapqr.getWidth()) / 2; + int disHeight = (int) ((height - bitmapqr.getHeight()) / 1.5); canvas.drawBitmap(bitmap, 0, 0, (Paint) null); - canvas.drawBitmap(bitmapQR, disWidth, disHeight, (Paint) null); // 画像合成 + canvas.drawBitmap(bitmapqr, disWidth, disHeight, (Paint) null); // 画像合成 //Androidからプリンターへ印刷指示を出すサポートライブラリ - return QRImage; + return QRGazou; } - private int calculateQRCodeSize() { // 画面解像度を取得 DisplayMetrics metrics = new DisplayMetrics(); diff --git a/app/src/main/java/com/example/childguard/RecyclerAdapter.java b/app/src/main/java/com/example/childguard/RecyclerAdapter.java index 87a161c..2a184f5 100644 --- a/app/src/main/java/com/example/childguard/RecyclerAdapter.java +++ b/app/src/main/java/com/example/childguard/RecyclerAdapter.java @@ -23,7 +23,6 @@ public class RecyclerAdapter extends RecyclerView.Adapter deviceList, Context applicationContext, View parentView) { // Init @@ -31,7 +30,6 @@ public class RecyclerAdapter extends RecyclerView.Adapter { + holder.textView.setOnClickListener( v -> { // アラートダイアログを表示 new AlertDialog.Builder(v.getContext()) @@ -55,13 +53,14 @@ public class RecyclerAdapter extends RecyclerView.Adapter { + view.findViewById(R.id.button_bluetooth_setting).setOnClickListener( v -> { getParentFragmentManager().beginTransaction().replace(R.id.fragmentContainerView, bluetooth_setupFragment.newInstance("test", "test")).addToBackStack(null).commit(); }); - view.findViewById(R.id.button_print_qr).setOnClickListener(v -> { + view.findViewById(R.id.button_print_qr).setOnClickListener( v -> { SharedPreferences sharedPreferences = getActivity().getSharedPreferences("app_situation", MODE_PRIVATE); boolean alreadySaved = sharedPreferences.getBoolean("alreadySaved", false); //falseのときにFirebaseへの登録 diff --git a/app/src/main/java/com/example/childguard/TestService.java b/app/src/main/java/com/example/childguard/TestService.java index 7a69b01..ebb97cd 100644 --- a/app/src/main/java/com/example/childguard/TestService.java +++ b/app/src/main/java/com/example/childguard/TestService.java @@ -77,7 +77,6 @@ public class TestService extends Service { Log.d("nt", "レスポンスを検知しました1"); if (isInCar) {//isReportedがtrue=サイト上で乗車状態のとき if (documentSnapshot.getBoolean("isReported")) { - //ここスタート(リサイクル) ResetReported();// ResetReported();を処理→FireBaseのisReportedをfalseにする NotificationSetting();//通知に関する設定のメソッド Notification(getApplicationContext());//通知を行うメソッド diff --git a/app/src/main/java/com/example/childguard/bluetooth_setupFragment.java b/app/src/main/java/com/example/childguard/bluetooth_setupFragment.java index e8e3f55..14d4044 100644 --- a/app/src/main/java/com/example/childguard/bluetooth_setupFragment.java +++ b/app/src/main/java/com/example/childguard/bluetooth_setupFragment.java @@ -126,6 +126,7 @@ public class bluetooth_setupFragment extends Fragment { for (BluetoothDevice device : pairedDevices) { + String[] deviceInfo = new String[2]; deviceInfo[0] = device.getName(); deviceInfo[1] = device.getAddress(); // MAC address @@ -142,8 +143,9 @@ public class bluetooth_setupFragment extends Fragment { //④RecyclerViewとAdapterの結び付け recyclerView1.setAdapter(adapter); - TextView textView = view.findViewById(R.id.registered_device); - textView.setText(PreferenceManager.getDefaultSharedPreferences(requireActivity().getApplicationContext()).getString("bluetooth_device_name", "none")); + TextView textView=view.findViewById(R.id.registered_device); + textView.setText(PreferenceManager.getDefaultSharedPreferences(requireActivity().getApplicationContext()).getString("bluetooth_device_name","none")); + } diff --git a/app/src/main/res/drawable/bluetooth_and_qr.png b/app/src/main/res/drawable/bluetooth_and_qr.png new file mode 100644 index 0000000..cc7274d Binary files /dev/null and b/app/src/main/res/drawable/bluetooth_and_qr.png differ diff --git a/app/src/main/res/drawable/bluetooth_and_qr2.png b/app/src/main/res/drawable/bluetooth_and_qr2.png new file mode 100644 index 0000000..4112821 Binary files /dev/null and b/app/src/main/res/drawable/bluetooth_and_qr2.png differ diff --git a/app/src/main/res/drawable/bluetooth_and_qr3.png b/app/src/main/res/drawable/bluetooth_and_qr3.png new file mode 100644 index 0000000..28019eb Binary files /dev/null and b/app/src/main/res/drawable/bluetooth_and_qr3.png differ diff --git a/app/src/main/res/layout/fragment_setting.xml b/app/src/main/res/layout/fragment_setting.xml index 1645ec7..44bbfaf 100644 --- a/app/src/main/res/layout/fragment_setting.xml +++ b/app/src/main/res/layout/fragment_setting.xml @@ -7,28 +7,50 @@ tools:context=".SettingFragment" android:padding="16dp"> -