diff --git a/.idea/misc.xml b/.idea/misc.xml index 8978d23..773fe0f 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 new file mode 100644 index 0000000..332ccd1 Binary files /dev/null and b/app/release/app-release.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json new file mode 100644 index 0000000..2d32550 --- /dev/null +++ b/app/release/output-metadata.json @@ -0,0 +1,20 @@ +{ + "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 deleted file mode 100644 index 5673005..0000000 --- a/app/src/main/java/com/example/childguard/Bluetooth_device_save.java +++ /dev/null @@ -1,22 +0,0 @@ -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 77e6104..479aed8 100644 --- a/app/src/main/java/com/example/childguard/First_Start.java +++ b/app/src/main/java/com/example/childguard/First_Start.java @@ -1,14 +1,18 @@ 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 ed71a65..6a6cd08 100644 --- a/app/src/main/java/com/example/childguard/GenerateQrFragment.java +++ b/app/src/main/java/com/example/childguard/GenerateQrFragment.java @@ -23,6 +23,7 @@ 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(); @@ -54,7 +55,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, () -> { @@ -62,7 +63,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 49a054e..9058f94 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 0ddb084..c67c8ea 100644 --- a/app/src/main/java/com/example/childguard/MainActivity.java +++ b/app/src/main/java/com/example/childguard/MainActivity.java @@ -12,7 +12,6 @@ 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; @@ -25,7 +24,6 @@ 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; @@ -65,7 +63,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(); } } } @@ -101,7 +99,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); @@ -110,7 +108,7 @@ public class MainActivity extends AppCompatActivity { .addToBackStack(null) .commit(); } - firebaselink(); + firebaseLink(); Bluetooth_status(); return true; }); @@ -146,7 +144,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) {//サイト上で押されたボタンの管理 @@ -168,7 +166,7 @@ public class MainActivity extends AppCompatActivity { //FireBaseで更新された情報の判定 if (!documentSnapshot.getBoolean("isReported")) {//isReportedがfalseのとき=サイト上で保護者ボタンが押されたとき if (fragment instanceof HomeFragment) {//fragmentがHomeFragmentのインスタンスかの判定 -// changessituation();// changessituation()メソッドを処理→アプリ側の乗降状態を変化 +// changes-situation();// changes-situation()メソッドを処理→アプリ側の乗降状態を変化 ((HomeFragment) fragment).onEvent(!isInCar); } } else if (isInCar) {//第三者ボタンが押されたときにisInCarがtrueのとき=乗車状態のとき→いたずら防止 @@ -231,7 +229,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の取得 @@ -255,7 +253,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); //共有プリファレンス 書き込みの準備 @@ -418,7 +416,6 @@ 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; @@ -477,9 +474,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 4fb3f5f..97b395b 100644 --- a/app/src/main/java/com/example/childguard/NotificationReceiver.java +++ b/app/src/main/java/com/example/childguard/NotificationReceiver.java @@ -5,6 +5,7 @@ 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 095bf84..1782b5f 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 4583c03..522097a 100644 --- a/app/src/main/java/com/example/childguard/QrUtils.java +++ b/app/src/main/java/com/example/childguard/QrUtils.java @@ -1,19 +1,14 @@ 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; @@ -30,20 +25,20 @@ public class QrUtils { public Bitmap getBitmap(String key) { Log.d("getBitmap", "getBitmap: " + key); - String KoteiURL = "https://practicefirestore1-8808c.web.app/?id="; + String fixationURL = "https://practicefirestore1-8808c.web.app/?id="; //すべてのドメイン String AllURL; //IdPrefにの値が初期値の場合 - AllURL=KoteiURL+key; + AllURL = fixationURL + key; int qrCodeSize = calculateQRCodeSize(); // 画面密度に応じてサイズを計算 - Bitmap QRGazou; - Bitmap bitmapqr; + Bitmap QRImage; + 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); } @@ -51,19 +46,20 @@ 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(); - QRGazou = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + QRImage = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); // Canvasの準備 - Canvas canvas = new Canvas(QRGazou); + Canvas canvas = new Canvas(QRImage); // 画像のサイズの調整 - 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 QRGazou; + return QRImage; } + 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 2a184f5..87a161c 100644 --- a/app/src/main/java/com/example/childguard/RecyclerAdapter.java +++ b/app/src/main/java/com/example/childguard/RecyclerAdapter.java @@ -23,6 +23,7 @@ public class RecyclerAdapter extends RecyclerView.Adapter deviceList, Context applicationContext, View parentView) { // Init @@ -30,6 +31,7 @@ public class RecyclerAdapter extends RecyclerView.Adapter { + holder.textView.setOnClickListener(v -> { // アラートダイアログを表示 new AlertDialog.Builder(v.getContext()) @@ -53,14 +55,13 @@ 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 ebb97cd..7a69b01 100644 --- a/app/src/main/java/com/example/childguard/TestService.java +++ b/app/src/main/java/com/example/childguard/TestService.java @@ -77,6 +77,7 @@ 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 14d4044..e8e3f55 100644 --- a/app/src/main/java/com/example/childguard/bluetooth_setupFragment.java +++ b/app/src/main/java/com/example/childguard/bluetooth_setupFragment.java @@ -126,7 +126,6 @@ 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 @@ -143,9 +142,8 @@ 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")); }