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