commit
800095eb61
|
@ -61,6 +61,12 @@ dependencies {
|
||||||
implementation 'androidx.compose.material3:material3'
|
implementation 'androidx.compose.material3:material3'
|
||||||
implementation 'com.google.firebase:firebase-firestore:24.4.1'
|
implementation 'com.google.firebase:firebase-firestore:24.4.1'
|
||||||
|
|
||||||
|
// Import the BoM for the Firebase platform
|
||||||
|
implementation(platform("com.google.firebase:firebase-bom:32.7.0"))
|
||||||
|
|
||||||
|
// Declare the dependency for the Cloud Firestore library
|
||||||
|
// When using the BoM, you don't specify versions in Firebase library dependencies
|
||||||
|
implementation("com.google.firebase:firebase-firestore")
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
|
|
67
app/google-services.json
Normal file
67
app/google-services.json
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_number": "814788024795",
|
||||||
|
"project_id": "practicefirestore1-8808c",
|
||||||
|
"storage_bucket": "practicefirestore1-8808c.appspot.com"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:814788024795:android:79602ef613cc9860c76ffe",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.example.childguard"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVpoftIYGZwiPRpuI56hoV8ifA2rbZGb4"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:814788024795:android:7c572a838331bba1c76ffe",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.example.connecttointernet"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVpoftIYGZwiPRpuI56hoV8ifA2rbZGb4"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:814788024795:android:67c86939b6350f02c76ffe",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.example.practicefirestore1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVpoftIYGZwiPRpuI56hoV8ifA2rbZGb4"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration_version": "1"
|
||||||
|
}
|
|
@ -1,22 +1,11 @@
|
||||||
package com.example.childguard;
|
package com.example.childguard;
|
||||||
|
|
||||||
|
import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
|
||||||
import androidx.print.PrintHelper;
|
|
||||||
|
|
||||||
import android.util.AndroidRuntimeException;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -25,10 +14,21 @@ import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
import androidx.annotation.NonNull;
|
||||||
import com.google.zxing.WriterException;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
import com.journeyapps.barcodescanner.BarcodeEncoder;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
|
||||||
|
import com.google.android.gms.tasks.OnFailureListener;
|
||||||
|
import com.google.android.gms.tasks.OnSuccessListener;
|
||||||
|
import com.google.firebase.firestore.DocumentReference;
|
||||||
|
import com.google.firebase.firestore.FirebaseFirestore;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
|
@ -36,6 +36,7 @@ import com.journeyapps.barcodescanner.BarcodeEncoder;
|
||||||
* create an instance of this fragment.
|
* create an instance of this fragment.
|
||||||
*/
|
*/
|
||||||
public class HomeFragment extends Fragment {
|
public class HomeFragment extends Fragment {
|
||||||
|
FirebaseFirestore db = FirebaseFirestore.getInstance();//Firebaseとの紐づけ
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -43,7 +44,7 @@ public class HomeFragment extends Fragment {
|
||||||
private static final String ARG_PARAM2 = "param2";
|
private static final String ARG_PARAM2 = "param2";
|
||||||
|
|
||||||
// TODO: Rename and change types of parameters
|
// TODO: Rename and change types of parameters
|
||||||
private String mParam1;
|
private String str_key;
|
||||||
private String mParam2;
|
private String mParam2;
|
||||||
|
|
||||||
public HomeFragment() {
|
public HomeFragment() {
|
||||||
|
@ -72,7 +73,7 @@ public class HomeFragment extends Fragment {
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
// mParam1 = getArguments().getString(ARG_PARAM1);
|
||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,20 +81,80 @@ public class HomeFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
// Log.d("HomeFlagment_cnt", "aaaaa");
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view=inflater.inflate(R.layout.fragment_home,container,false);
|
View view = inflater.inflate(R.layout.fragment_home, container, false);
|
||||||
MainActivity activity = (MainActivity) getActivity();
|
MainActivity activity = (MainActivity) 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(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
replaceFragment(new QrPrintFragment());
|
//初回起動かを保存する変数
|
||||||
|
boolean alreadySaved = preferences.getBoolean("alreadySaved", false);
|
||||||
|
//ボタン変数の宣言
|
||||||
|
Button parent = view.findViewById(R.id.QRprinting);
|
||||||
|
Button born = view.findViewById(R.id.QRprinting);
|
||||||
|
//falseのときにFirebaseへの登録
|
||||||
|
if (alreadySaved) {
|
||||||
|
Log.d("HomeFragment", "already printed");
|
||||||
|
//画面遷移&ID受け渡し
|
||||||
|
Toast.makeText(getActivity(),"再印刷",Toast.LENGTH_SHORT).show();
|
||||||
|
QrPrintFragment qrPrintFragment = new QrPrintFragment();
|
||||||
|
replaceFragment(qrPrintFragment);
|
||||||
|
return;
|
||||||
|
} else Log.d("HomeFragment", "not printed yet"); // debug
|
||||||
|
|
||||||
|
String valueParent = parent.getText().toString();//変数に文字列を代入
|
||||||
|
String valueBorn = born.getText().toString();//変数に文字列を代入
|
||||||
|
Map<String, String> user = new HashMap<>();//mapの宣言
|
||||||
|
|
||||||
|
Log.d("HomeFragment", "onClick is called");
|
||||||
|
|
||||||
|
//mapに入れる
|
||||||
|
user.put("parent", valueParent);
|
||||||
|
user.put("born", valueBorn);
|
||||||
|
//新しいドキュメントにIDを作って追加
|
||||||
|
db.collection("users")
|
||||||
|
.add(user)
|
||||||
|
.addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(DocumentReference documentReference) {
|
||||||
|
//成功したら
|
||||||
|
//documentReference.getId()でID取得
|
||||||
|
Log.d(TAG, "DocumentSnapshot added with ID: " + documentReference.getId());
|
||||||
|
SharedPreferences.Editor e = preferences.edit();
|
||||||
|
// キー"alreadySaved"の値をtrueにする
|
||||||
|
e.putBoolean("alreadySaved", true);
|
||||||
|
//確定処理
|
||||||
|
e.apply();
|
||||||
|
//画面遷移&ID受け渡し
|
||||||
|
str_key = "" + documentReference.getId();
|
||||||
|
Toast.makeText(getActivity(),"初回登録",Toast.LENGTH_SHORT).show();
|
||||||
|
QrPrintFragment qrPrintFragment = new QrPrintFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("STR_KEY",str_key);
|
||||||
|
//値を書き込む
|
||||||
|
qrPrintFragment.setArguments(bundle);
|
||||||
|
replaceFragment(qrPrintFragment);
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.addOnFailureListener(new OnFailureListener() {
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Exception e) {
|
||||||
|
//失敗したら
|
||||||
|
Log.w(TAG, "Error adding document", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//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(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -108,11 +169,10 @@ public class HomeFragment extends Fragment {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
Log.d("HomeFragment", "onResume: called");
|
Log.d("HomeFragment", "onResume: called");
|
||||||
TextView situationTextView = getView().findViewById(R.id.situation);
|
TextView situationTextView = getView().findViewById(R.id.situation);
|
||||||
FrameLayout situation_bg=getView().findViewById(R.id.situation_bg);
|
FrameLayout situation_bg = getView().findViewById(R.id.situation_bg);
|
||||||
updateInCarStatus(situationTextView,situation_bg);
|
updateInCarStatus(situationTextView, situation_bg);
|
||||||
}
|
}
|
||||||
|
public void updateInCarStatus(TextView situationTextView, FrameLayout situation_bg) {
|
||||||
public void updateInCarStatus(TextView situationTextView,FrameLayout situation_bg) {
|
|
||||||
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("default", 0);
|
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("default", 0);
|
||||||
|
|
||||||
Log.d("HomeFragment", "updateInCarStatus: " + sharedPreferences.getBoolean("inCar", false));
|
Log.d("HomeFragment", "updateInCarStatus: " + sharedPreferences.getBoolean("inCar", false));
|
||||||
|
@ -125,8 +185,9 @@ public class HomeFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//画面遷移メソッド
|
//画面遷移メソッド
|
||||||
private void replaceFragment(Fragment fragment){
|
private void replaceFragment(Fragment fragment) {
|
||||||
// フラグメントマネージャーの取得
|
// フラグメントマネージャーの取得
|
||||||
FragmentManager manager = getParentFragmentManager(); // アクティビティではgetSupportFragmentManager()?
|
FragmentManager manager = getParentFragmentManager(); // アクティビティではgetSupportFragmentManager()?
|
||||||
// フラグメントトランザクションの開始
|
// フラグメントトランザクションの開始
|
||||||
|
|
|
@ -15,19 +15,19 @@ public class QR extends AppCompatActivity {
|
||||||
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())){
|
||||||
tv.setText(get_off);
|
// tv.setText(get_off);
|
||||||
findViewById(R.id.situation_bg).setBackgroundColor(Color.parseColor("#dcdcdc"));
|
// findViewById(R.id.situation_bg).setBackgroundColor(Color.parseColor("#dcdcdc"));
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
tv.setText(get_on);
|
// tv.setText(get_on);
|
||||||
findViewById(R.id.situation_bg).setBackgroundColor(Color.parseColor("#ff4500"));
|
// findViewById(R.id.situation_bg).setBackgroundColor(Color.parseColor("#ff4500"));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.activity.result.contract.ActivityResultContracts;
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.browser.customtabs.CustomTabsIntent;
|
import androidx.browser.customtabs.CustomTabsIntent;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -97,15 +99,26 @@ public class QRFragment extends Fragment {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view = inflater.inflate(R.layout.fragment_qr, container, false);
|
View view = inflater.inflate(R.layout.fragment_qr, container, false);
|
||||||
|
|
||||||
Button cameraButton = view.findViewById(R.id.camera);
|
|
||||||
|
|
||||||
cameraButton.setOnClickListener(v -> {
|
|
||||||
Log.d("QRFragment", "onClick: called");
|
Log.d("QRFragment", "onClick: called");
|
||||||
//QRリーダ起動
|
//QRリーダ起動
|
||||||
fragmentLauncher.launch(new ScanOptions());
|
fragmentLauncher.launch(new ScanOptions());
|
||||||
});
|
HomeFragment homeFragment=new HomeFragment();
|
||||||
|
replaceFragment(homeFragment);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
//画面遷移メソッド
|
||||||
|
private void replaceFragment(Fragment fragment) {
|
||||||
|
// フラグメントマネージャーの取得
|
||||||
|
FragmentManager manager = getParentFragmentManager(); // アクティビティではgetSupportFragmentManager()?
|
||||||
|
// フラグメントトランザクションの開始
|
||||||
|
FragmentTransaction transaction = manager.beginTransaction();
|
||||||
|
// レイアウトをfragmentに置き換え(追加)
|
||||||
|
transaction.replace(R.id.fragmentContainerView, fragment);
|
||||||
|
// 置き換えのトランザクションをバックスタックに保存する
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
// フラグメントトランザクションをコミット
|
||||||
|
transaction.commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.example.childguard;
|
package com.example.childguard;
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -8,8 +9,11 @@ import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
import androidx.print.PrintHelper;
|
import androidx.print.PrintHelper;
|
||||||
|
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.util.AndroidRuntimeException;
|
import android.util.AndroidRuntimeException;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -59,7 +63,7 @@ public class QrPrintFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate (Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||||
|
@ -68,18 +72,34 @@ public class QrPrintFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
//共有プリファレンス 全体の準備
|
||||||
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
//User毎のドメインを保存する
|
||||||
|
String IdPref=preferences.getString("ID",null);
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view=inflater.inflate(R.layout.fragment_qr_print, container, false);
|
View view=inflater.inflate(R.layout.fragment_qr_print, container, false);;
|
||||||
|
|
||||||
//固定のドメイン
|
//固定のドメイン
|
||||||
String KoteiURL = "https://practicefirestore1-8808c.web.app/?id=";
|
String KoteiURL = "https://practicefirestore1-8808c.web.app/?id=";
|
||||||
|
//すべてのドメイン
|
||||||
|
String AllURL;
|
||||||
|
//IdPrefにの値が初期値の場合
|
||||||
|
if(IdPref==null) {
|
||||||
//User毎のドメイン
|
//User毎のドメイン
|
||||||
String userURL="YKjFsZgJBlZmcyvdZ3Ap";
|
String userURL = getArguments().getString("STR_KEY");
|
||||||
|
//キー"ID"の値をuserURLの値にする
|
||||||
|
SharedPreferences.Editor e = preferences.edit();
|
||||||
|
e.putString("ID", userURL);
|
||||||
|
//確定処理
|
||||||
|
e.apply();
|
||||||
//二つのドメインを合成する
|
//二つのドメインを合成する
|
||||||
String AllURL=KoteiURL+userURL;
|
AllURL=KoteiURL+userURL;
|
||||||
|
}else{
|
||||||
|
//二つのドメインを合成する
|
||||||
|
AllURL=KoteiURL+IdPref;
|
||||||
|
}
|
||||||
|
|
||||||
int size = 2500;
|
int size = 2500;
|
||||||
ImageView imageViewQrCode;
|
ImageView imageViewQrCode;
|
||||||
|
@ -96,6 +116,7 @@ public class QrPrintFragment extends Fragment {
|
||||||
throw new AndroidRuntimeException("Barcode Error.", e);
|
throw new AndroidRuntimeException("Barcode Error.", e);
|
||||||
}
|
}
|
||||||
// 画像合成の準備
|
// 画像合成の準備
|
||||||
|
// ここのエラーは直すと何故か動かなくなる。このままで動くので放置
|
||||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.a_group_qr_sos);
|
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.a_group_qr_sos);
|
||||||
Bitmap bitmap1 = ((BitmapDrawable) imageViewQrCode.getDrawable()).getBitmap();
|
Bitmap bitmap1 = ((BitmapDrawable) imageViewQrCode.getDrawable()).getBitmap();
|
||||||
int width = bitmap.getWidth(); // 元ファイルの幅取得
|
int width = bitmap.getWidth(); // 元ファイルの幅取得
|
||||||
|
@ -113,7 +134,21 @@ public class QrPrintFragment extends Fragment {
|
||||||
printHelper.setColorMode(PrintHelper.COLOR_MODE_COLOR);
|
printHelper.setColorMode(PrintHelper.COLOR_MODE_COLOR);
|
||||||
printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
|
printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
|
||||||
printHelper.printBitmap("job_name", QRGazou);
|
printHelper.printBitmap("job_name", QRGazou);
|
||||||
|
HomeFragment homeFragment=new HomeFragment();
|
||||||
|
replaceFragment(homeFragment);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
//画面遷移メソッド
|
||||||
|
private void replaceFragment(Fragment fragment) {
|
||||||
|
// フラグメントマネージャーの取得
|
||||||
|
FragmentManager manager = getParentFragmentManager(); // アクティビティではgetSupportFragmentManager()?
|
||||||
|
// フラグメントトランザクションの開始
|
||||||
|
FragmentTransaction transaction = manager.beginTransaction();
|
||||||
|
// レイアウトをfragmentに置き換え(追加)
|
||||||
|
transaction.replace(R.id.fragmentContainerView, fragment);
|
||||||
|
// 置き換えのトランザクションをバックスタックに保存する
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
// フラグメントトランザクションをコミット
|
||||||
|
transaction.commit();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
package com.example.childguard;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
|
|
||||||
public class UrlPageActivity extends AppCompatActivity {
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_url_page);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
|
||||||
tools:context=".UrlPageActivity">
|
|
||||||
<WebView
|
|
||||||
android:id="@+id/url_page"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
|
@ -5,13 +5,6 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".QRFragment">
|
tools:context=".QRFragment">
|
||||||
|
|
||||||
<!-- TODO: Update blank fragment layout -->
|
|
||||||
<Button
|
|
||||||
android:id="@+id/camera"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
/>
|
|
||||||
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
Loading…
Reference in New Issue
Block a user