Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ef2c129c6 | ||
|
|
b49c73d6b2 | ||
|
|
895732b1b3 |
No files matched your search
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
Binary file not shown.
@@ -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"
|
||||||
|
}
|
||||||
@@ -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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,18 @@
|
|||||||
package com.example.childguard;
|
package com.example.childguard;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
public class First_Start extends AppCompatActivity {
|
public class First_Start extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.first_start);
|
setContentView(R.layout.first_start);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,7 @@ public class GenerateQrFragment extends Fragment {
|
|||||||
public GenerateQrFragment() {
|
public GenerateQrFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GenerateQrFragment newInstance(String key) {
|
public static GenerateQrFragment newInstance(String key) {
|
||||||
GenerateQrFragment fragment = new GenerateQrFragment();
|
GenerateQrFragment fragment = new GenerateQrFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
@@ -54,7 +55,7 @@ public class GenerateQrFragment extends Fragment {
|
|||||||
ImageView imageView = view.findViewById(R.id.result_bitmap_image_view);
|
ImageView imageView = view.findViewById(R.id.result_bitmap_image_view);
|
||||||
imageView.setImageBitmap(result);
|
imageView.setImageBitmap(result);
|
||||||
|
|
||||||
view.findViewById(R.id.button_print).setOnClickListener( v -> {
|
view.findViewById(R.id.button_print).setOnClickListener(v -> {
|
||||||
PrintHelper photoPrinter = new PrintHelper(requireContext());
|
PrintHelper photoPrinter = new PrintHelper(requireContext());
|
||||||
photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
|
photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
|
||||||
photoPrinter.printBitmap("placeholder", result, () -> {
|
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();
|
getParentFragmentManager().popBackStack();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import androidx.fragment.app.FragmentTransaction;
|
|||||||
* Use the {@link HomeFragment#newInstance} factory method to
|
* Use the {@link HomeFragment#newInstance} factory method to
|
||||||
* create an instance of this fragment.
|
* 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
|
// TODO: Rename parameter arguments, choose names that match
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||||
@@ -133,26 +133,26 @@ public class HomeFragment extends Fragment implements OnEventListener{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateBluetoothSituation(Boolean Bluetoothconnect){
|
private boolean updateBluetoothSituation(Boolean BluetoothConnect) {
|
||||||
FrameLayout frameLayout;
|
FrameLayout frameLayout;
|
||||||
TextView textView;
|
TextView textView;
|
||||||
ImageView imageView;
|
ImageView imageView;
|
||||||
try {
|
try {
|
||||||
frameLayout=requireView().findViewById(R.id.situation_bg2);
|
frameLayout = requireView().findViewById(R.id.situation_bg2);
|
||||||
textView=requireView().findViewById(R.id.Bluetoothsituation);
|
textView = requireView().findViewById(R.id.Bluetoothsituation);
|
||||||
imageView=requireView().findViewById(R.id.Bluetoothsituationimage);
|
imageView = requireView().findViewById(R.id.Bluetoothsituationimage);
|
||||||
}catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
Log.d("HomeFragment", "updateUiState: view is null");
|
Log.d("HomeFragment", "updateUiState: view is null");
|
||||||
return false;
|
return false;
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
Log.d("HomeFragment", "updateUiState: view is not attached");
|
Log.d("HomeFragment", "updateUiState: view is not attached");
|
||||||
getParentFragmentManager().beginTransaction().replace(R.id.fragmentContainerView, HomeFragment.newInstance("test", "test")).commit();
|
getParentFragmentManager().beginTransaction().replace(R.id.fragmentContainerView, HomeFragment.newInstance("test", "test")).commit();
|
||||||
updateBluetoothSituation(Bluetoothconnect);
|
updateBluetoothSituation(BluetoothConnect);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String connect="接続中";
|
String connect = "接続中";
|
||||||
String disconnect="切断中";
|
String disconnect = "切断中";
|
||||||
if (Bluetoothconnect) {
|
if (BluetoothConnect) {
|
||||||
//接続状態にする
|
//接続状態にする
|
||||||
frameLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style_orange, null));
|
frameLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style_orange, null));
|
||||||
textView.setText(connect);
|
textView.setText(connect);
|
||||||
@@ -177,13 +177,13 @@ public class HomeFragment extends Fragment implements OnEventListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEvent2(boolean BluetoothConnect) {
|
public void onEvent2(boolean BluetoothConnect) {
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEvent2(Boolean Bluetoothconnect) {//Bluetoothの接続切断を受け取ってupdateBluetoothSituation()に渡す
|
public boolean onEvent2(Boolean BluetoothConnect) {//Bluetoothの接続切断を受け取ってupdateBluetoothSituation()に渡す
|
||||||
updateBluetoothSituation(Bluetoothconnect);
|
updateBluetoothSituation(BluetoothConnect);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import android.content.IntentFilter;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -25,7 +24,6 @@ import android.widget.Toast;
|
|||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.browser.customtabs.CustomTabsIntent;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
@@ -65,7 +63,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
if (!contents.contains("https://practicefirestore1-8808c.web.app/")) {
|
if (!contents.contains("https://practicefirestore1-8808c.web.app/")) {
|
||||||
Toast.makeText(this, "Child Guardに対応するQRコードではありません", Toast.LENGTH_LONG).show();
|
Toast.makeText(this, "Child Guardに対応するQRコードではありません", Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
changeisInCar();
|
changeIsInCar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,7 +99,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
.replace(findViewById(R.id.fragmentContainerView).getId(), this.homeFragment)
|
.replace(findViewById(R.id.fragmentContainerView).getId(), this.homeFragment)
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
firebaselink();
|
firebaseLink();
|
||||||
|
|
||||||
} 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);
|
||||||
@@ -110,7 +108,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
firebaselink();
|
firebaseLink();
|
||||||
Bluetooth_status();
|
Bluetooth_status();
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -146,7 +144,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
Log.d("onResume", "called");
|
Log.d("onResume", "called");
|
||||||
Log.d("onResume", "mDocRef is null");
|
Log.d("onResume", "mDocRef is null");
|
||||||
firebaselink();
|
firebaseLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initNotification(DocumentReference mDocRef) {//サイト上で押されたボタンの管理
|
private void initNotification(DocumentReference mDocRef) {//サイト上で押されたボタンの管理
|
||||||
@@ -168,7 +166,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
//FireBaseで更新された情報の判定
|
//FireBaseで更新された情報の判定
|
||||||
if (!documentSnapshot.getBoolean("isReported")) {//isReportedがfalseのとき=サイト上で保護者ボタンが押されたとき
|
if (!documentSnapshot.getBoolean("isReported")) {//isReportedがfalseのとき=サイト上で保護者ボタンが押されたとき
|
||||||
if (fragment instanceof HomeFragment) {//fragmentがHomeFragmentのインスタンスかの判定
|
if (fragment instanceof HomeFragment) {//fragmentがHomeFragmentのインスタンスかの判定
|
||||||
// changessituation();// changessituation()メソッドを処理→アプリ側の乗降状態を変化
|
// changes-situation();// changes-situation()メソッドを処理→アプリ側の乗降状態を変化
|
||||||
((HomeFragment) fragment).onEvent(!isInCar);
|
((HomeFragment) fragment).onEvent(!isInCar);
|
||||||
}
|
}
|
||||||
} else if (isInCar) {//第三者ボタンが押されたときにisInCarがtrueのとき=乗車状態のとき→いたずら防止
|
} 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);
|
SharedPreferences sharedPreferences = getSharedPreferences("app_situation", MODE_PRIVATE);
|
||||||
String IdPref = sharedPreferences.getString("ID", null);////アプリに記録されているIDの取得
|
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));
|
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);
|
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
|
String action = intent.getAction(); // may need to chain this to a recognizing function
|
||||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||||
Boolean isInCar = pref.getBoolean("isInCarPref", false);
|
Boolean isInCar = pref.getBoolean("isInCarPref", false);
|
||||||
Boolean Bluetoothconnect = pref.getBoolean("change", false);
|
|
||||||
if (ActivityCompat.checkSelfPermission(context, android.Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
|
if (ActivityCompat.checkSelfPermission(context, android.Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
|
||||||
Log.d("BT", "No permission to connect bluetooth devices");
|
Log.d("BT", "No permission to connect bluetooth devices");
|
||||||
return;
|
return;
|
||||||
@@ -477,9 +474,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
public void changeBluetooth(){
|
public void changeBluetooth(){
|
||||||
SharedPreferences pref=getSharedPreferences("Bluetooth_situation",MODE_PRIVATE);
|
SharedPreferences pref=getSharedPreferences("Bluetooth_situation",MODE_PRIVATE);
|
||||||
SharedPreferences.Editor e=pref.edit();
|
SharedPreferences.Editor e=pref.edit();
|
||||||
Boolean Bluetoothconnect = pref.getBoolean("change", false);
|
Boolean BluetoothConnect = pref.getBoolean("change", false);
|
||||||
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragmentContainerView);
|
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragmentContainerView);
|
||||||
((HomeFragment) fragment).onEvent2(Bluetoothconnect);
|
((HomeFragment) fragment).onEvent2(BluetoothConnect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package com.example.childguard;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple {@link Fragment} subclass.
|
|
||||||
* Use the {@link NotificationFragment#newInstance} factory method to
|
|
||||||
* create an instance of this fragment.
|
|
||||||
*/
|
|
||||||
public class NotificationFragment extends Fragment {
|
|
||||||
|
|
||||||
// TODO: Rename parameter arguments, choose names that match
|
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
|
||||||
private static final String ARG_PARAM1 = "param1";
|
|
||||||
private static final String ARG_PARAM2 = "param2";
|
|
||||||
|
|
||||||
// TODO: Rename and change types of parameters
|
|
||||||
private String mParam1;
|
|
||||||
private String mParam2;
|
|
||||||
|
|
||||||
public NotificationFragment() {
|
|
||||||
// Required empty public constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use this factory method to create a new instance of
|
|
||||||
* this fragment using the provided parameters.
|
|
||||||
*
|
|
||||||
* @param param1 Parameter 1.
|
|
||||||
* @param param2 Parameter 2.
|
|
||||||
* @return A new instance of fragment NotificationFragment.
|
|
||||||
*/
|
|
||||||
// TODO: Rename and change types and number of parameters
|
|
||||||
public static NotificationFragment newInstance(String param1, String param2) {
|
|
||||||
NotificationFragment fragment = new NotificationFragment();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString(ARG_PARAM1, param1);
|
|
||||||
args.putString(ARG_PARAM2, param2);
|
|
||||||
fragment.setArguments(args);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
if (getArguments() != null) {
|
|
||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
|
||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
return inflater.inflate(R.layout.fragment_notification, container, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,6 +5,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
public class NotificationReceiver extends BroadcastReceiver {//通知をタップしたときにアプリを起動する処理
|
public class NotificationReceiver extends BroadcastReceiver {//通知をタップしたときにアプリを起動する処理
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (intent.getAction() != null && intent.getAction().equals("OPEN_ACTIVITY")) {// 通知がタップされたときの処理
|
if (intent.getAction() != null && intent.getAction().equals("OPEN_ACTIVITY")) {// 通知がタップされたときの処理
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ public interface OnEventListener {
|
|||||||
|
|
||||||
void onEvent2(boolean BluetoothConnect);
|
void onEvent2(boolean BluetoothConnect);
|
||||||
|
|
||||||
boolean onEvent2(Boolean Bluetoothconnect);
|
boolean onEvent2(Boolean BluetoothConnect);
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,14 @@
|
|||||||
package com.example.childguard;
|
package com.example.childguard;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
|
||||||
import android.util.AndroidRuntimeException;
|
import android.util.AndroidRuntimeException;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import androidx.print.PrintHelper;
|
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.WriterException;
|
import com.google.zxing.WriterException;
|
||||||
@@ -30,20 +25,20 @@ public class QrUtils {
|
|||||||
|
|
||||||
public Bitmap getBitmap(String key) {
|
public Bitmap getBitmap(String key) {
|
||||||
Log.d("getBitmap", "getBitmap: " + key);
|
Log.d("getBitmap", "getBitmap: " + key);
|
||||||
String KoteiURL = "https://practicefirestore1-8808c.web.app/?id=";
|
String fixationURL = "https://practicefirestore1-8808c.web.app/?id=";
|
||||||
//すべてのドメイン
|
//すべてのドメイン
|
||||||
String AllURL;
|
String AllURL;
|
||||||
//IdPrefにの値が初期値の場合
|
//IdPrefにの値が初期値の場合
|
||||||
AllURL=KoteiURL+key;
|
AllURL = fixationURL + key;
|
||||||
|
|
||||||
|
|
||||||
int qrCodeSize = calculateQRCodeSize(); // 画面密度に応じてサイズを計算
|
int qrCodeSize = calculateQRCodeSize(); // 画面密度に応じてサイズを計算
|
||||||
Bitmap QRGazou;
|
Bitmap QRImage;
|
||||||
Bitmap bitmapqr;
|
Bitmap bitmapQR;
|
||||||
try {
|
try {
|
||||||
//QRコード生成
|
//QRコード生成
|
||||||
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
|
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) {
|
} catch (WriterException e) {
|
||||||
throw new AndroidRuntimeException("Barcode Error.", 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);
|
Bitmap bitmap = BitmapFactory.decodeResource(this.context.getResources(), R.drawable.a_group_qr_sos_2);
|
||||||
int width = bitmap.getWidth();
|
int width = bitmap.getWidth();
|
||||||
int height = bitmap.getHeight();
|
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 canvas = new Canvas(QRGazou);
|
Canvas canvas = new Canvas(QRImage);
|
||||||
|
|
||||||
// 画像のサイズの調整
|
// 画像のサイズの調整
|
||||||
int disWidth = (width - bitmapqr.getWidth()) / 2;
|
int disWidth = (width - bitmapQR.getWidth()) / 2;
|
||||||
int disHeight = (int) ((height - bitmapqr.getHeight()) / 1.5);
|
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からプリンターへ印刷指示を出すサポートライブラリ
|
||||||
return QRGazou;
|
return QRImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculateQRCodeSize() {
|
private int calculateQRCodeSize() {
|
||||||
// 画面解像度を取得
|
// 画面解像度を取得
|
||||||
DisplayMetrics metrics = new DisplayMetrics();
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ItemVi
|
|||||||
Context applicationContext;
|
Context applicationContext;
|
||||||
View parentView;
|
View parentView;
|
||||||
|
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
public RecyclerAdapter(ArrayList<String[]> deviceList, Context applicationContext, View parentView) {
|
public RecyclerAdapter(ArrayList<String[]> deviceList, Context applicationContext, View parentView) {
|
||||||
// Init
|
// Init
|
||||||
@@ -30,6 +31,7 @@ public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ItemVi
|
|||||||
this.deviceList = deviceList;
|
this.deviceList = deviceList;
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
this.parentView = parentView;
|
this.parentView = parentView;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -43,7 +45,7 @@ public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ItemVi
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ItemViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ItemViewHolder holder, int position) {
|
||||||
holder.textView.setText(deviceList.get(position)[0]);
|
holder.textView.setText(deviceList.get(position)[0]);
|
||||||
holder.textView.setOnClickListener( v -> {
|
holder.textView.setOnClickListener(v -> {
|
||||||
|
|
||||||
// アラートダイアログを表示
|
// アラートダイアログを表示
|
||||||
new AlertDialog.Builder(v.getContext())
|
new AlertDialog.Builder(v.getContext())
|
||||||
@@ -53,14 +55,13 @@ public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ItemVi
|
|||||||
// OK button pressed
|
// OK button pressed
|
||||||
Toast.makeText(v.getContext(), "OK button clicked", Toast.LENGTH_SHORT).show();
|
Toast.makeText(v.getContext(), "OK button clicked", Toast.LENGTH_SHORT).show();
|
||||||
//共有プリファレンスに保存
|
//共有プリファレンスに保存
|
||||||
SharedPreferences sharedPreferences=PreferenceManager.getDefaultSharedPreferences(this.applicationContext);
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this.applicationContext);
|
||||||
sharedPreferences.edit().putString("bluetooth_device_id", deviceList.get(position)[1]).apply();
|
sharedPreferences.edit().putString("bluetooth_device_id", deviceList.get(position)[1]).apply();
|
||||||
sharedPreferences.edit().putString("bluetooth_device_name",deviceList.get(position)[0]).apply();
|
sharedPreferences.edit().putString("bluetooth_device_name", deviceList.get(position)[0]).apply();
|
||||||
Toast.makeText(v.getContext(),PreferenceManager.getDefaultSharedPreferences(this.applicationContext).getString("bluetooth_device_id","none"), Toast.LENGTH_SHORT).show();
|
Toast.makeText(v.getContext(), PreferenceManager.getDefaultSharedPreferences(this.applicationContext).getString("bluetooth_device_id", "none"), Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
TextView textView = this.parentView.findViewById(R.id.registered_device);
|
TextView textView = this.parentView.findViewById(R.id.registered_device);
|
||||||
textView.setText(PreferenceManager.getDefaultSharedPreferences(this.applicationContext).getString("bluetooth_device_name","none"));
|
textView.setText(PreferenceManager.getDefaultSharedPreferences(this.applicationContext).getString("bluetooth_device_name", "none"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import java.util.Map;
|
|||||||
public class SettingFragment extends Fragment {
|
public class SettingFragment extends Fragment {
|
||||||
|
|
||||||
FirebaseFirestore db;
|
FirebaseFirestore db;
|
||||||
|
|
||||||
public SettingFragment() {
|
public SettingFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
@@ -55,11 +56,11 @@ public class SettingFragment extends Fragment {
|
|||||||
|
|
||||||
db = FirebaseFirestore.getInstance();//Firebaseとの紐づけ
|
db = FirebaseFirestore.getInstance();//Firebaseとの紐づけ
|
||||||
|
|
||||||
view.findViewById(R.id.button_bluetooth_setting).setOnClickListener( v -> {
|
view.findViewById(R.id.button_bluetooth_setting).setOnClickListener(v -> {
|
||||||
getParentFragmentManager().beginTransaction().replace(R.id.fragmentContainerView, bluetooth_setupFragment.newInstance("test", "test")).addToBackStack(null).commit();
|
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);
|
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("app_situation", MODE_PRIVATE);
|
||||||
boolean alreadySaved = sharedPreferences.getBoolean("alreadySaved", false);
|
boolean alreadySaved = sharedPreferences.getBoolean("alreadySaved", false);
|
||||||
//falseのときにFirebaseへの登録
|
//falseのときにFirebaseへの登録
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ public class TestService extends Service {
|
|||||||
Log.d("nt", "レスポンスを検知しました1");
|
Log.d("nt", "レスポンスを検知しました1");
|
||||||
if (isInCar) {//isReportedがtrue=サイト上で乗車状態のとき
|
if (isInCar) {//isReportedがtrue=サイト上で乗車状態のとき
|
||||||
if (documentSnapshot.getBoolean("isReported")) {
|
if (documentSnapshot.getBoolean("isReported")) {
|
||||||
|
//ここスタート(リサイクル)
|
||||||
ResetReported();// ResetReported();を処理→FireBaseのisReportedをfalseにする
|
ResetReported();// ResetReported();を処理→FireBaseのisReportedをfalseにする
|
||||||
NotificationSetting();//通知に関する設定のメソッド
|
NotificationSetting();//通知に関する設定のメソッド
|
||||||
Notification(getApplicationContext());//通知を行うメソッド
|
Notification(getApplicationContext());//通知を行うメソッド
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ public class bluetooth_setupFragment extends Fragment {
|
|||||||
for (BluetoothDevice device : pairedDevices) {
|
for (BluetoothDevice device : pairedDevices) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String[] deviceInfo = new String[2];
|
String[] deviceInfo = new String[2];
|
||||||
deviceInfo[0] = device.getName();
|
deviceInfo[0] = device.getName();
|
||||||
deviceInfo[1] = device.getAddress(); // MAC address
|
deviceInfo[1] = device.getAddress(); // MAC address
|
||||||
@@ -143,9 +142,8 @@ public class bluetooth_setupFragment extends Fragment {
|
|||||||
|
|
||||||
//④RecyclerViewとAdapterの結び付け
|
//④RecyclerViewとAdapterの結び付け
|
||||||
recyclerView1.setAdapter(adapter);
|
recyclerView1.setAdapter(adapter);
|
||||||
TextView textView=view.findViewById(R.id.registered_device);
|
TextView textView = view.findViewById(R.id.registered_device);
|
||||||
textView.setText(PreferenceManager.getDefaultSharedPreferences(requireActivity().getApplicationContext()).getString("bluetooth_device_name","none"));
|
textView.setText(PreferenceManager.getDefaultSharedPreferences(requireActivity().getApplicationContext()).getString("bluetooth_device_name", "none"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context=".NotificationFragment">
|
|
||||||
|
|
||||||
<!-- TODO: Update blank fragment layout -->
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:weightSum="10"
|
|
||||||
android:orientation="vertical"
|
|
||||||
tools:context=".MainActivity">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="9">
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recyclerView1"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:scrollbars="vertical"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
Reference in new issue
Block a user