Compare commits
1
Commits
isono/tuuchi
..
last
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39e9336de0 |
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package com.example.childguard;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -62,6 +63,7 @@ public class HomeFragment extends Fragment implements OnEventListener{
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.os.Bundle;
|
||||
import android.os.Vibrator;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -53,7 +52,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
public static final String TAG = "InspirationQuote";
|
||||
|
||||
|
||||
|
||||
private final ActivityResultLauncher<ScanOptions> QrLauncher = registerForActivityResult(
|
||||
new ScanContract(),
|
||||
result -> {
|
||||
@@ -62,7 +60,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Toast.makeText(this, "QRコードが読み取れませんでした", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
if (!contents.contains("https://practicefirestore1-8808c.web.app/")) {
|
||||
Toast.makeText(this, "Child Guardに対応するQRコードではありません", Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(this, "Chiled Guardに対応するQRコードではありません", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
//URLの表示
|
||||
Toast.makeText(this, contents, Toast.LENGTH_SHORT).show();
|
||||
@@ -75,17 +73,15 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
);
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
db = FirebaseFirestore.getInstance();//Firebaseとの紐づけ
|
||||
|
||||
BottomNavigationView bottomNavigationView = findViewById(R.id.nav_view);
|
||||
|
||||
this.homeFragment = HomeFragment.newInstance("test", "test");
|
||||
this.homeFragment = HomeFragment.newInstance("test", "tset");
|
||||
|
||||
bottomNavigationView.setOnNavigationItemSelectedListener(v ->
|
||||
|
||||
@@ -98,12 +94,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
.commit();
|
||||
firebaselink();
|
||||
|
||||
} else if (v.getItemId() == findViewById(R.id.navigation_notification).getId()) {
|
||||
findViewById(R.id.fab_scan_qr_code).setVisibility(FrameLayout.VISIBLE);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(findViewById(R.id.fragmentContainerView).getId(), NotificationFragment.newInstance("test", "test"))
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
|
||||
} else if (v.getItemId() == findViewById(R.id.navigation_settings).getId()) {
|
||||
findViewById(R.id.fab_scan_qr_code).setVisibility(FrameLayout.GONE);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
@@ -111,6 +102,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
}
|
||||
firebaselink();
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -123,7 +115,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
});
|
||||
|
||||
|
||||
//Bluetooth検知機能
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
|
||||
@@ -136,10 +127,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
Log.d("BT", "Permission to connect bluetooth devices granted");
|
||||
}
|
||||
registerReceiver(receiver, intentFilter);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
@@ -166,7 +155,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Log.d("nt", "レスポンスを検知しました1");
|
||||
//FireBaseで更新された情報の判定
|
||||
if (documentSnapshot.getBoolean("isReported") == false) {//isReportedがfalseのとき=サイト上で保護者ボタンが押されたとき
|
||||
if (fragment instanceof HomeFragment) {//fragmentがHomeFragmentのインスタンスかの判定
|
||||
if (fragment instanceof HomeFragment) {//fragementがHomeFragmentのインスタンスかの判定
|
||||
// changessituation();// changessituation()メソッドを処理→アプリ側の乗降状態を変化
|
||||
((HomeFragment) fragment).onEvent(!isInCar);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.example.childguard;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
@@ -15,7 +14,6 @@ import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
@@ -27,18 +25,10 @@ import android.widget.Toast;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.firebase.firestore.DocumentReference;
|
||||
import com.google.firebase.firestore.FirebaseFirestore;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -50,76 +40,9 @@ public class TestService extends Service {
|
||||
|
||||
public PeriodicTaskManager periodicTaskManager;
|
||||
|
||||
//時間を取得するやつ↓
|
||||
public static String getNowDate() {
|
||||
@SuppressLint("SimpleDateFormat") final DateFormat df = new SimpleDateFormat("yyy/MM/dd HH:mm:ss");
|
||||
final Date date = new Date(System.currentTimeMillis());
|
||||
return df.format(date);
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void NotifityRecycle(){
|
||||
|
||||
RecyclerView recyclerView = recyclerView().findViewById(R.id.recyclerView1);
|
||||
|
||||
//RecyclerViewのサイズを固定
|
||||
recyclerView.setHasFixedSize(true);
|
||||
|
||||
//RecyclerViewに区切り線を入れる
|
||||
RecyclerView.ItemDecoration itemDecoration =
|
||||
new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
|
||||
recyclerView.addItemDecoration(itemDecoration);
|
||||
|
||||
//レイアウトマネージャを設定
|
||||
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
//①リスト構造(String型の可変長の配列)を宣言
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
|
||||
//③Adapterとリスト構造を結び付け
|
||||
//RecyclerAdapterクラスを呼び出す
|
||||
RecyclerAdapter2 adapter = new RecyclerAdapter2(arrayList, null);
|
||||
|
||||
//④RecyclerViewとAdapterの結び付け
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
arrayList.add(0,"通知を検知しました: " + getNowDate());
|
||||
|
||||
//一番下に値が追加されたことをAdapterが画面に通知
|
||||
adapter.notifyItemInserted(arrayList.size());
|
||||
|
||||
//共有プリファレンス 書き込みの準備
|
||||
SharedPreferences.Editor e = pref.edit();
|
||||
|
||||
//リストを,区切りで結合する
|
||||
String str = String.join(",", arrayList);
|
||||
|
||||
//変数名currentに、値の代入
|
||||
e.putString("current", str.toString());
|
||||
|
||||
//確定処理
|
||||
e.apply();
|
||||
|
||||
String strTo = pref.getString("current", null);
|
||||
if (strTo == null) return;
|
||||
|
||||
String[] list = strTo.split(",");
|
||||
arrayList.clear();
|
||||
arrayList.addAll(Arrays.asList(list));
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private Activity recyclerView() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
|
||||
NotifityRecycle();
|
||||
//共有プリファレンス全体の準備
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("app_situation", MODE_PRIVATE);
|
||||
String IdPref = sharedPreferences.getString("ID", null);//アプリに記録されているIDの取得
|
||||
@@ -130,8 +53,6 @@ public class TestService extends Service {
|
||||
initNotification(mDocRef);//現在の位置を引数に initNotification()を処理
|
||||
}
|
||||
return flags;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initNotification(DocumentReference mDocRef) {//サイト上で押されたボタンの管理
|
||||
@@ -252,7 +173,7 @@ public class TestService extends Service {
|
||||
@SuppressLint("NotificationTrampoline") NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "CHANNEL_ID")
|
||||
.setSmallIcon(android.R.drawable.ic_menu_info_details)
|
||||
.setContentTitle("子供の置き去りをしていませんか?")//通知のタイトル
|
||||
.setContentText("Bluetoothと車の切断から"+time+"分が経過しました")//通知の本文
|
||||
.setContentText("Bluetootと車の切断から"+time+"分が経過しました")//通知の本文
|
||||
.setContentIntent(pendingIntent)//通知をタップするとActivityへ移動する
|
||||
.setAutoCancel(true)//通知をタップすると削除する
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH) // プライオリティを高く設定
|
||||
@@ -302,7 +223,7 @@ public class TestService extends Service {
|
||||
int time=sharedPreferences.getInt("time",0);
|
||||
//共有プリファレンス 書き込みの準備
|
||||
SharedPreferences.Editor E = sharedPreferences.edit();
|
||||
if(time==0) {//Bluetooth切断からの時間経過(5分刻み)
|
||||
if(time==0) {//Bluetoot切断からの時間経過(5分刻み)
|
||||
E.putInt("time",5);
|
||||
E.apply();;
|
||||
}else {
|
||||
|
||||
@@ -6,19 +6,11 @@
|
||||
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">
|
||||
android:layout_weight="9"
|
||||
>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView1"
|
||||
@@ -28,8 +20,4 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
@@ -4,10 +4,7 @@
|
||||
android:id="@+id/navigation_home"
|
||||
android:icon="@drawable/ic_home_black_24dp"
|
||||
android:title="home"/>
|
||||
<item
|
||||
android:id="@+id/navigation_notification"
|
||||
android:icon="@drawable/notifications_fill0_wght400_grad0_opsz24"
|
||||
android:title="notification"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/navigation_settings"
|
||||
android:icon="@drawable/baseline_app_settings_alt_24"
|
||||
|
||||
Reference in new issue
Block a user