diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 40af628..1d165bb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,6 +18,9 @@ android:theme="@style/Theme.Oplogy" tools:ignore="ExtraText" tools:targetApi="31"> + diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..93c6136 Binary files /dev/null and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/com/example/oplogy/MainActivity.java b/app/src/main/java/com/example/oplogy/MainActivity.java index 045ba75..7c591d3 100644 --- a/app/src/main/java/com/example/oplogy/MainActivity.java +++ b/app/src/main/java/com/example/oplogy/MainActivity.java @@ -1,10 +1,6 @@ package com.example.oplogy; import android.app.ProgressDialog; -import android.content.ClipData; -import android.content.ClipboardManager; -import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; @@ -30,30 +26,21 @@ import java.util.concurrent.Executors; public class MainActivity extends AppCompatActivity implements View.OnClickListener { - // formコピー用のURL - private static final String URL_TO_COPY = "https://docs.google.com/forms/d/e/1FAIpQLScKI_ca01nO7die7SqZyThiqa7NB7gcucMJtiV_-sc3eZX6KQ/viewform"; + // ダイアログの宣言 private AlertDialog alertDialog; // ID作成のTextViewとImageView - private TextView creatUUID; - private ImageView imageUuid; - // セットアップのTextViewとImageView - private TextView setUp; - private ImageView imageSetup; - // formコピー用のボタン - private TextView formURL; - private ImageView imageFormURL; - // ルート作成のTextViewとImageView private TextView root; private ImageView imageRoot; // 提出状況のTextViewとImageView private TextView submission; private ImageView imageSubmission; + private TextView SettingView; + private ImageView imageSettingView; //firestoreの受信関連 private FirebaseFirestore db; private FirestoreReception firestoreReception; - private FirestoreReception_classIdDatabase firestoreReception_classIdDatabase; //取得するためのクラスID private int classId; @@ -63,24 +50,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); -// ID作成用のインテント - creatUUID = findViewById(R.id.creatUUID); - creatUUID.setOnClickListener(this); - imageUuid = findViewById(R.id.imageUuid); - imageUuid.setOnClickListener(this); - - -// セットアップ用のインテント - setUp = findViewById(R.id.setUp); - setUp.setOnClickListener(this); - imageSetup = findViewById(R.id.imageSetup); - imageSetup.setOnClickListener(this); - -// formコピー用のインテント - formURL = findViewById(R.id.formURL); - formURL.setOnClickListener(this); - imageFormURL = findViewById(R.id.imageFormURL); - imageFormURL.setOnClickListener(this); // ルート作成用のインテント @@ -95,6 +64,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe imageSubmission = findViewById(R.id.imageSubmission); imageSubmission.setOnClickListener(this); +// 設定用のインテント + SettingView = findViewById(R.id.setting); + SettingView.setOnClickListener(this); + imageSettingView = findViewById(R.id.imageSetting); + imageSettingView.setOnClickListener(this); + // firestoreの受信関連 db = FirebaseFirestore.getInstance(); firestoreReception = new FirestoreReception(); @@ -121,40 +96,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe // クリック処理 @Override public void onClick(View view) { -// ID作成のクリック処理 - if (view == creatUUID) { - imageUuid.setImageResource(R.drawable.ischecked_uuid); - showUUIDYesNoDialog();//UUIDを表示するかのダイアログ - } - if (view == imageUuid) { - imageUuid.setImageResource(R.drawable.ischecked_uuid); - showUUIDYesNoDialog();//UUIDを表示するかのダイアログ - } -// セットアップのクリック処理 - if (view == setUp) { - imageSetup.setImageResource(R.drawable.ischecked_uuid); - Intent toSetup = new Intent(MainActivity.this, SetUpActivity.class); - toSetup.putExtra("classId", classId); - startActivity(toSetup); - finish(); // 画面遷移後元の状態に戻す - } - if (view == imageSetup) { - imageSetup.setImageResource(R.drawable.ischecked_uuid); - Intent toSetup = new Intent(MainActivity.this, SetUpActivity.class); - startActivity(toSetup); - finish(); // 画面遷移後元の状態に戻す - } - -// formコピー用のクリック処理 - if (view == formURL) { - imageFormURL.setImageResource(R.drawable.ischecked_uuid); - copyUrlToClipboard(URL_TO_COPY); - } - if (view == imageFormURL) { - imageFormURL.setImageResource(R.drawable.ischecked_uuid); - copyUrlToClipboard(URL_TO_COPY); - } - // ルート作成のクリック処理 if (view == root) { imageRoot.setImageResource(R.drawable.pin); @@ -181,76 +122,14 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe startActivity(toSubmission); }); } - } - - - //ID作成、表示に関する処理 - private void showUUIDYesNoDialog() { - firestoreReception_classIdDatabase = new FirestoreReception_classIdDatabase(); - List classIdList = firestoreReception_classIdDatabase.getAllDocumentsFromClassIdDatabase(); - - - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle("ID"); - builder.setMessage("あなたのIDを表示/もしくは新規で作成しますか?"); - - //作成処理 - builder.setPositiveButton("作成", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - classId = CreateUUID.generateUUID(classIdList); - // 生成されたIDを表示するメソッド - showClassIdDialog("生成されたID", classId); - } - }); - //表示処理 - builder.setNegativeButton("表示", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - //roomを扱うため非同期処理 - ExecutorService executor = Executors.newSingleThreadExecutor(); - executor.execute(() -> { - // 現在のクラスIDを取得 - int currentClassId = getCurrentClassIdFromRoom(); - if (currentClassId == 0) { - currentClassId = classId; - } - final int showDialogClassId = currentClassId; - runOnUiThread(() -> { - // 現在のクラスIDを表示するダイアログ - showClassIdDialog("現在のID", showDialogClassId); - }); - }); - executor.shutdown(); - } - }); - - alertDialog = builder.create(); - alertDialog.show(); - - } - - private int getCurrentClassIdFromRoom() { - AppDatabase db = getDatabaseInstance(); - SetUpTableDao setUpTableDao = db.setUpTableDao(); - - // 現在のクラスIDを取得 - return setUpTableDao.getClassId(); - } - - //クラスIDを表示するダイアログ - private void showClassIdDialog(String title, int classId) { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(title); - builder.setMessage("ID: " + classId); - builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }); - AlertDialog dialog = builder.create(); - dialog.show(); + if (view == SettingView) { + Intent toSettingView = new Intent(MainActivity.this, SettingView.class); + startActivity(toSettingView); + } + if (view == imageSettingView) { + Intent toSettingView = new Intent(MainActivity.this, SettingView.class); + startActivity(toSettingView); + } } @@ -262,7 +141,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe runOnUiThread(onSetupComplete); } else { runOnUiThread(() -> { - Toast.makeText(this, "先にセットアップを済ませてください", Toast.LENGTH_LONG).show(); + Toast.makeText(this, "先に設定画面で情報を入力してください", Toast.LENGTH_SHORT).show(); }); } }).exceptionally(ex -> { @@ -273,7 +152,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe return null; }); } else { - Toast.makeText(this, "先にIDの作成を行ってください", Toast.LENGTH_LONG).show(); + Toast.makeText(this, "先に設定画面で情報を入力してください", Toast.LENGTH_SHORT).show(); } } @@ -302,21 +181,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe }, executorService).whenComplete((result, throwable) -> executorService.shutdown()); } - //クリップボードにURLをコピーする処理 - private void copyUrlToClipboard(String url) { - try { - ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); - ClipData clip = ClipData.newPlainText("URL", url); - if (clipboard != null) { - clipboard.setPrimaryClip(clip); - Toast.makeText(this, "GoogleFormのURLをコピーしました", Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(this, "エラー コピーできませんでした", Toast.LENGTH_SHORT).show(); - } - } catch (Exception e) { - Toast.makeText(this, "Error copying URL: " + e.getMessage(), Toast.LENGTH_SHORT).show(); - } - } //ルート作成の非同期処理 private void fetchDataAndCreateRoute() { diff --git a/app/src/main/java/com/example/oplogy/SetUpActivity.java b/app/src/main/java/com/example/oplogy/SetUpActivity.java index ac275a0..1b7c837 100644 --- a/app/src/main/java/com/example/oplogy/SetUpActivity.java +++ b/app/src/main/java/com/example/oplogy/SetUpActivity.java @@ -97,7 +97,7 @@ public class SetUpActivity extends FragmentActivity Button reset = findViewById(R.id.resetButton); toMain.setOnClickListener(view -> { - Intent intent = new Intent(SetUpActivity.this, MainActivity.class); //main画面へ戻る処理 + Intent intent = new Intent(SetUpActivity.this, SettingView.class); //main画面へ戻る処理 startActivity(intent); }); diff --git a/app/src/main/java/com/example/oplogy/SettingView.java b/app/src/main/java/com/example/oplogy/SettingView.java new file mode 100644 index 0000000..e574f80 --- /dev/null +++ b/app/src/main/java/com/example/oplogy/SettingView.java @@ -0,0 +1,190 @@ +package com.example.oplogy; + +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.Toast; + +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.room.Room; + +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class SettingView extends AppCompatActivity implements View.OnClickListener { + // formコピー用のURL + private static final String URL_TO_COPY = "https://docs.google.com/forms/d/e/1FAIpQLScKI_ca01nO7die7SqZyThiqa7NB7gcucMJtiV_-sc3eZX6KQ/viewform"; + + private View backButton; + private View creatUUID; + private View imageUuid; + private View setUp; + private View imageSetup; + private View formURL; + private View imageFormURL; + private AlertDialog alertDialog; + private int classId; + private FirestoreReception_classIdDatabase firestoreReception_classIdDatabase; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_setting_view); + + // 戻るボタンの処理 + backButton = findViewById(R.id.BackMain_fromSetting); + backButton.setOnClickListener(this); + + // ID作成用のインテント + creatUUID = findViewById(R.id.creatUUID); + creatUUID.setOnClickListener(this); + imageUuid = findViewById(R.id.imageUuid); + imageUuid.setOnClickListener(this); + + +// セットアップ用のインテント + setUp = findViewById(R.id.setUp); + setUp.setOnClickListener(this); + imageSetup = findViewById(R.id.imageSetup); + imageSetup.setOnClickListener(this); + +// formコピー用のインテント + formURL = findViewById(R.id.formURL); + formURL.setOnClickListener(this); + imageFormURL = findViewById(R.id.imageFormURL); + imageFormURL.setOnClickListener(this); + } + + @Override + public void onClick(View view) { + if (view == backButton) { + Intent intent = new Intent(SettingView.this, MainActivity.class); + startActivity(intent); + } + // ID作成のクリック処理 + if (view == creatUUID) { + showUUIDYesNoDialog();//UUIDを表示するかのダイアログ + } + if (view == imageUuid) { + showUUIDYesNoDialog();//UUIDを表示するかのダイアログ + } +// セットアップのクリック処理 + if (view == setUp) { + Intent toSetup = new Intent(SettingView.this, SetUpActivity.class); + toSetup.putExtra("classId", classId); + startActivity(toSetup); + } + if (view == imageSetup) { + Intent toSetup = new Intent(SettingView.this, SetUpActivity.class); + startActivity(toSetup); + } + +// formコピー用のクリック処理 + if (view == formURL) { + copyUrlToClipboard(URL_TO_COPY); + } + if (view == imageFormURL) { + copyUrlToClipboard(URL_TO_COPY); + } + } + + + //ID作成、表示に関する処理 + private void showUUIDYesNoDialog() { + firestoreReception_classIdDatabase = new FirestoreReception_classIdDatabase(); + List classIdList = firestoreReception_classIdDatabase.getAllDocumentsFromClassIdDatabase(); + + + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle("ID"); + builder.setMessage("あなたのIDを表示/もしくは新規で作成しますか?"); + + //作成処理 + builder.setPositiveButton("作成", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + classId = CreateUUID.generateUUID(classIdList); + // 生成されたIDを表示するメソッド + showClassIdDialog("生成されたID", classId); + } + }); + //表示処理 + builder.setNegativeButton("表示", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + //roomを扱うため非同期処理 + ExecutorService executor = Executors.newSingleThreadExecutor(); + executor.execute(() -> { + // 現在のクラスIDを取得 + int currentClassId = getCurrentClassIdFromRoom(); + if (currentClassId == 0) { + currentClassId = classId; + } + final int showDialogClassId = currentClassId; + runOnUiThread(() -> { + // 現在のクラスIDを表示するダイアログ + showClassIdDialog("現在のID", showDialogClassId); + }); + }); + executor.shutdown(); + } + }); + + alertDialog = builder.create(); + alertDialog.show(); + + } + + //Roomから現在のクラスIDを取得するメソッド + private int getCurrentClassIdFromRoom() { + AppDatabase db = getDatabaseInstance(); + SetUpTableDao setUpTableDao = db.setUpTableDao(); + + // 現在のクラスIDを取得 + return setUpTableDao.getClassId(); + } + + //クラスIDを表示するダイアログ + private void showClassIdDialog(String title, int classId) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(title); + builder.setMessage("ID: " + classId); + builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + AlertDialog dialog = builder.create(); + dialog.show(); + } + + //クリップボードにURLをコピーする処理 + private void copyUrlToClipboard(String url) { + try { + ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText("URL", url); + if (clipboard != null) { + clipboard.setPrimaryClip(clip); + Toast.makeText(this, "GoogleFormのURLをコピーしました", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(this, "エラー コピーできませんでした", Toast.LENGTH_SHORT).show(); + } + } catch (Exception e) { + Toast.makeText(this, "Error copying URL: " + e.getMessage(), Toast.LENGTH_SHORT).show(); + } + } + + // データベースのインスタンスを取得するメソッド + private AppDatabase getDatabaseInstance() { + return Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build(); + } + +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_setting_view.xml b/app/src/main/res/layout/activity_setting_view.xml new file mode 100644 index 0000000..9eb64ce --- /dev/null +++ b/app/src/main/res/layout/activity_setting_view.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml index 838d2c2..07a0c51 100644 --- a/app/src/main/res/layout/main.xml +++ b/app/src/main/res/layout/main.xml @@ -13,90 +13,36 @@ android:layout_weight="2" /> - + + + + android:weightSum="3"> + android:src="@drawable/app_icon" /> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index 6f3b755..036d09b 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,6 +1,5 @@ - - - + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index 6f3b755..036d09b 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,6 +1,5 @@ - - - + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp index c209e78..23486ea 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.webp and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp new file mode 100644 index 0000000..f675698 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp index b2dfe3d..4411d8e 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp index 4f0f1d6..ae27057 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.webp and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp new file mode 100644 index 0000000..b1f48c1 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp index 62b611d..da12038 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp index 948a307..723bffe 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp new file mode 100644 index 0000000..ef7e42d Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp index 1b9a695..0221821 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp index 28d4b77..c6c97a5 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp new file mode 100644 index 0000000..52e0fb8 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp index 9287f50..0793bbb 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp index aa7d642..3b4ba0d 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp new file mode 100644 index 0000000..cc7cfc8 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp index 9126ae3..c611c25 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/values/ic_launcher_background.xml b/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..c5d5899 --- /dev/null +++ b/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + \ No newline at end of file