Merge pull request '変数とかの名前の修正' (#29) from hotfix-notification into main
Reviewed-on: #29
This commit is contained in:
commit
25879c4ad5
|
@ -139,14 +139,17 @@ public class HomeFragment extends Fragment implements OnEventListener {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bluetoothの接続状態の画面を切り替える
|
||||||
|
*/
|
||||||
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_bg_bluetooth);
|
||||||
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;
|
||||||
|
@ -156,17 +159,17 @@ public class HomeFragment extends Fragment implements OnEventListener {
|
||||||
updateBluetoothSituation(BluetoothConnect);
|
updateBluetoothSituation(BluetoothConnect);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String connect = "接続中";
|
final String CONNECT = "接続中";
|
||||||
String disconnect = "切断中";
|
final 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);
|
||||||
imageView.setVisibility(View.GONE);
|
imageView.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
//降車状態にする
|
//降車状態にする
|
||||||
frameLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style, null));
|
frameLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style, null));
|
||||||
textView.setText(disconnect);
|
textView.setText(DISCONNECT);
|
||||||
imageView.setVisibility(View.VISIBLE);
|
imageView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
public static final String TAG = "InspirationQuote";
|
public static final String TAG = "InspirationQuote";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final ActivityResultLauncher<ScanOptions> QrLauncher = registerForActivityResult(
|
private final ActivityResultLauncher<ScanOptions> QrLauncher = registerForActivityResult(
|
||||||
new ScanContract(),
|
new ScanContract(),
|
||||||
result -> {
|
result -> {
|
||||||
|
@ -81,7 +80,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
e.putBoolean("connection_status", false);
|
e.putBoolean("connection_status", false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!hasPermissions()) {
|
if (!hasPermissions()) {
|
||||||
requestPermissions();
|
requestPermissions();
|
||||||
}
|
}
|
||||||
|
@ -187,7 +185,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasPermissions() {
|
private boolean hasPermissions() {
|
||||||
|
@ -229,18 +226,18 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FireBaseのIDの取得
|
||||||
|
*/
|
||||||
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の取得
|
||||||
if (IdPref == null) {//FireBaseのIDがアプリに登録されているとき
|
if (IdPref == null) {//FireBaseのIDがアプリに登録されているとき
|
||||||
Log.d("onResume", "ID not initialized.");
|
Log.d("onResume", "ID not initialized.");
|
||||||
} else {
|
} else {
|
||||||
mDocRef = FirebaseFirestore.getInstance().document("status/" + IdPref);//現在の位置を取得
|
mDocRef = FirebaseFirestore.getInstance().document("status/" + IdPref);//現在の位置を取得
|
||||||
initNotification(mDocRef);//現在の位置を引数に initNotification()を処理
|
initNotification(mDocRef);//現在の位置を引数に initNotification()を処理
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +271,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
isReported.update("isInCar", change).addOnSuccessListener(unused -> Log.d(TAG, "DocumentSnapshot successfully updated!")).addOnFailureListener(e -> Log.w(TAG, "Error updating document", e));
|
isReported.update("isInCar", change).addOnSuccessListener(unused -> Log.d(TAG, "DocumentSnapshot successfully updated!")).addOnFailureListener(e -> Log.w(TAG, "Error updating document", e));
|
||||||
E.apply();
|
E.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NotificationSetting() {//通知に関する設定の処理を行うメソッド
|
public void NotificationSetting() {//通知に関する設定の処理を行うメソッド
|
||||||
int importance = NotificationManager.IMPORTANCE_DEFAULT;
|
int importance = NotificationManager.IMPORTANCE_DEFAULT;
|
||||||
//通知チャネルの実装
|
//通知チャネルの実装
|
||||||
|
@ -388,9 +386,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void Bluetooth_status() {
|
public void Bluetooth_status() {
|
||||||
IntentFilter intentFilter = new IntentFilter();
|
IntentFilter intentFilter = new IntentFilter();
|
||||||
intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
|
intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
|
||||||
|
@ -459,9 +454,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action) && !isInCar) {//その後bluetoothを再接続したり降車状態になったりしていない=置き去りが発生した可能性大
|
if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action) && !isInCar) {//その後bluetoothを再接続したり降車状態になったりしていない=置き去りが発生した可能性大
|
||||||
NotificationBluetooth(getApplicationContext());//通知を行うメソッド
|
NotificationBluetooth(getApplicationContext());//通知を行うメソッド
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}, 5 *60*1000); // 5分をミリ秒に変換
|
}, 5 * 1000); // 5分をミリ秒に変換
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d("BT", " Device disconnected");
|
Log.d("BT", " Device disconnected");
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/situation_bg2"
|
android:id="@+id/situation_bg_bluetooth"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="20dp"
|
android:layout_marginLeft="20dp"
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
android:background="@drawable/frame_style">
|
android:background="@drawable/frame_style">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/Bluetoothsituation"
|
android:id="@+id/BluetoothSituation"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
android:textAlignment="center" />
|
android:textAlignment="center" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/Bluetoothsituationimage"
|
android:id="@+id/BluetoothSituationImage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
android:layout_marginTop="50dp"
|
android:layout_marginTop="50dp"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user