Itazuraboushi #14
|
@ -3,7 +3,6 @@ package com.example.childguard;
|
||||||
import static android.content.ContentValues.TAG;
|
import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -12,7 +11,6 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -89,9 +87,7 @@ public class HomeFragment extends Fragment {
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
//QRコード印刷の処理
|
//QRコード印刷の処理
|
||||||
Button bt1 = view.findViewById(R.id.QRprinting);
|
Button bt1 = view.findViewById(R.id.QRprinting);
|
||||||
bt1.setOnClickListener(new View.OnClickListener() {
|
bt1.setOnClickListener(v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
//初回起動かを保存する変数
|
//初回起動かを保存する変数
|
||||||
boolean alreadySaved = preferences.getBoolean("alreadySaved", false);
|
boolean alreadySaved = preferences.getBoolean("alreadySaved", false);
|
||||||
//ボタン変数の宣言
|
//ボタン変数の宣言
|
||||||
|
@ -151,40 +147,35 @@ public class HomeFragment extends Fragment {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
//bluetooth設定ボタンの処理
|
//bluetooth設定ボタンの処理
|
||||||
Button bt2 = view.findViewById(R.id.Bluetooth_setup);
|
Button bt2 = view.findViewById(R.id.Bluetooth_setup);
|
||||||
bt2.setOnClickListener(new View.OnClickListener() {
|
bt2.setOnClickListener(v -> replaceFragment(new bluetooth_setupFragment()));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
replaceFragment(new bluetooth_setupFragment());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public void onResume() {
|
// public void onResume() {
|
||||||
super.onResume();
|
// super.onResume();
|
||||||
Log.d("HomeFragment", "onResume: called");
|
// Log.d("HomeFragment", "onResume: called");
|
||||||
TextView situationTextView = getView().findViewById(R.id.situation);
|
// Cargettingonandoff();
|
||||||
FrameLayout situation_bg = getView().findViewById(R.id.situation_bg);
|
// TextView situationTextView = getView().findViewById(R.id.situation);
|
||||||
updateInCarStatus(situationTextView, situation_bg);
|
// FrameLayout situation_bg = getView().findViewById(R.id.situation_bg);
|
||||||
}
|
// updateInCarStatus(situationTextView, situation_bg);
|
||||||
public void updateInCarStatus(TextView situationTextView, FrameLayout situation_bg) {
|
// }
|
||||||
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("default", 0);
|
// public void updateInCarStatus(TextView situationTextView, FrameLayout situation_bg) {
|
||||||
|
// SharedPreferences sharedPreferences = getActivity().getSharedPreferences("default", 0);
|
||||||
Log.d("HomeFragment", "updateInCarStatus: " + sharedPreferences.getBoolean("inCar", false));
|
//
|
||||||
if (sharedPreferences.getBoolean("inCar", false)) {
|
// Log.d("HomeFragment", "updateInCarStatus: " + sharedPreferences.getBoolean("inCar", false));
|
||||||
situationTextView.setText("\n降車状態");
|
// if (sharedPreferences.getBoolean("inCar", false)) {
|
||||||
situation_bg.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style, null));
|
// situationTextView.setText("\n降車状態");
|
||||||
} else {
|
// situation_bg.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style, null));
|
||||||
situationTextView.setText("\n乗車状態");
|
// } else {
|
||||||
situation_bg.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style_orange, null));
|
// situationTextView.setText("\n乗車状態");
|
||||||
}
|
// situation_bg.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style_orange, null));
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
//画面遷移メソッド
|
//画面遷移メソッド
|
||||||
private void replaceFragment(Fragment fragment) {
|
private void replaceFragment(Fragment fragment) {
|
||||||
|
@ -199,4 +190,31 @@ public class HomeFragment extends Fragment {
|
||||||
// フラグメントトランザクションをコミット
|
// フラグメントトランザクションをコミット
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
}
|
}
|
||||||
|
// public void Cargettingonandoff() {
|
||||||
|
// //共有プリファレンス 全体の準備
|
||||||
|
// SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
// //車の乗り降りを管理するtrue=乗車、false=降車
|
||||||
|
// boolean zyoukouzyoutai = preferences.getBoolean("car", false);
|
||||||
|
// SharedPreferences.Editor e = preferences.edit();
|
||||||
|
// String get_on = "\n乗車状態";
|
||||||
|
// String get_off = "\n降車状態";
|
||||||
|
// TextView tv = getView().findViewById(R.id.situation);
|
||||||
|
// FrameLayout fl = getView().findViewById(R.id.situation_bg);
|
||||||
|
//
|
||||||
|
// if (zyoukouzyoutai == true) { //乗降状態の判定
|
||||||
|
// //降車状態にする
|
||||||
|
// fl.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style, null));
|
||||||
|
// tv.setText(get_off);
|
||||||
|
// e.putBoolean("car", false);
|
||||||
|
// e.apply();
|
||||||
|
// } else {
|
||||||
|
// //乗車状態にする
|
||||||
|
// fl.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style_orange, null));
|
||||||
|
// tv.setText(get_on);
|
||||||
|
// e.putBoolean("car", true);
|
||||||
|
// e.apply();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
}
|
}
|
|
@ -12,7 +12,9 @@ import android.app.NotificationManager;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothManager;
|
import android.bluetooth.BluetoothManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
|
|
||||||
|
@ -24,10 +26,15 @@ import java.util.Date;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
|
||||||
import com.google.firebase.firestore.DocumentReference;
|
import com.google.firebase.firestore.DocumentReference;
|
||||||
import com.google.firebase.firestore.DocumentSnapshot;
|
import com.google.firebase.firestore.DocumentSnapshot;
|
||||||
import com.google.firebase.firestore.EventListener;
|
import com.google.firebase.firestore.EventListener;
|
||||||
|
@ -40,7 +47,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
BluetoothAdapter bluetoothAdapter;
|
BluetoothAdapter bluetoothAdapter;
|
||||||
|
|
||||||
public static final String TAG = "InspirationQuote";
|
public static final String TAG = "InspirationQuote";
|
||||||
private DocumentReference mDocRef = FirebaseFirestore.getInstance().document("users/q6t702C8nsXyehckByrr");//現在の位置を取得
|
private DocumentReference mDocRef = FirebaseFirestore.getInstance().document("users/rrVGKi77MAemxvPZrktm");//現在の位置を取得
|
||||||
boolean flg = false;
|
boolean flg = false;
|
||||||
|
|
||||||
//↓日付を取得するやつ
|
//↓日付を取得するやつ
|
||||||
|
@ -101,10 +108,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
//通知のやつ↑
|
//通知のやつ↑
|
||||||
Log.d("nt", "レスポンスを検知しました2");
|
Log.d("nt", "レスポンスを検知しました2");
|
||||||
|
|
||||||
|
|
||||||
notifyMain();
|
notifyMain();
|
||||||
} else if (e != null) {
|
} else {
|
||||||
Log.w(TAG, "Got an exceptiion!", e);
|
Log.w(TAG, "Got an exceptiion!", e);
|
||||||
|
Cargettingonandoff();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -147,4 +154,33 @@ public class MainActivity extends AppCompatActivity {
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
actionBar.setDisplayHomeAsUpEnabled(enableBackButton);
|
actionBar.setDisplayHomeAsUpEnabled(enableBackButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Cargettingonandoff() {
|
||||||
|
//共有プリファレンス 全体の準備
|
||||||
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
//車の乗り降りを管理するtrue=乗車、false=降車
|
||||||
|
boolean zyoukouzyoutai = preferences.getBoolean("car", false);
|
||||||
|
SharedPreferences.Editor e = preferences.edit();
|
||||||
|
String get_on = "\n乗車状態";
|
||||||
|
String get_off = "\n降車状態";
|
||||||
|
setContentView(R.layout.fragment_home);
|
||||||
|
TextView tv = findViewById(R.id.situation);
|
||||||
|
FrameLayout fl = findViewById(R.id.situation_bg);
|
||||||
|
|
||||||
|
if (zyoukouzyoutai == true) { //乗降状態の判定
|
||||||
|
//降車状態にする
|
||||||
|
fl.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style, null));
|
||||||
|
tv.setText(get_off);
|
||||||
|
e.putBoolean("car", false);
|
||||||
|
e.apply();
|
||||||
|
} else {
|
||||||
|
//乗車状態にする
|
||||||
|
fl.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style_orange, null));
|
||||||
|
tv.setText(get_on);
|
||||||
|
e.putBoolean("car", true);
|
||||||
|
e.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,21 +1,21 @@
|
||||||
package com.example.childguard;
|
//package com.example.childguard;
|
||||||
|
//
|
||||||
import android.graphics.Color;
|
//import android.graphics.Color;
|
||||||
import android.graphics.drawable.Drawable;
|
//import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
//import android.os.Bundle;
|
||||||
import android.widget.TextView;
|
//import android.widget.TextView;
|
||||||
|
//
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
//import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
//
|
||||||
public class QR extends AppCompatActivity {
|
//public class QR extends AppCompatActivity {
|
||||||
String get_on="乗車状態";
|
// String get_on="乗車状態";
|
||||||
String get_off ="降車状態";
|
// String get_off ="降車状態";
|
||||||
TextView tv=findViewById(R.id.situation);
|
// TextView tv=findViewById(R.id.situation);
|
||||||
@Override
|
// @Override
|
||||||
protected void onCreate(Bundle savedInstanceState){
|
// protected void onCreate(Bundle savedInstanceState){
|
||||||
super.onCreate(savedInstanceState);
|
// super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.fragment_qr);
|
// setContentView(R.layout.fragment_qr);
|
||||||
//多分いらないコード
|
// //多分いらないコード
|
||||||
// findViewById(R.id.camera).setOnClickListener(
|
// findViewById(R.id.camera).setOnClickListener(
|
||||||
// v -> {
|
// v -> {
|
||||||
// if(get_on.equals(tv.getText().toString())){
|
// if(get_on.equals(tv.getText().toString())){
|
||||||
|
@ -28,6 +28,6 @@ public class QR extends AppCompatActivity {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// );
|
// );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="@color/white"
|
android:background="@color/white"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".HomeFragment">
|
tools:context=".HomeFragment"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
@ -14,13 +15,16 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.0">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/situation_bg"
|
android:id="@+id/situation_bg"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user