From fb51cefd42871cc470253edbe9616706bfbd2361 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Wed, 11 Aug 2021 22:05:39 -0600 Subject: figured out preferences, going to bed now --- app/src/main/AndroidManifest.xml | 3 +- .../brysonsteck/wiimmfiwatcher/MainActivity.java | 32 +++++----- .../wiimmfiwatcher/preferences/ParseSettings.java | 4 -- .../preferences/SettingsFragment.java | 4 -- .../wiimmfiwatcher/settings/ParseSettings.java | 4 ++ .../wiimmfiwatcher/settings/SettingsActivity.java | 18 ++++++ .../settings/SettingsMainFragment.java | 6 ++ .../res/drawable/ic_baseline_arrow_back_24.xml | 5 ++ .../main/res/drawable/ic_baseline_settings_24.xml | 5 ++ app/src/main/res/layout/activity_main.xml | 2 +- app/src/main/res/layout/activity_settings.xml | 68 ++++++++++++++++++++++ app/src/main/res/layout/main_settings_fragment.xml | 32 ++++++++++ app/src/main/res/menu/top_app_bar.xml | 11 ---- app/src/main/res/menu/top_app_bar_main.xml | 18 ++++++ app/src/main/res/menu/top_app_bar_settings.xml | 4 ++ app/src/main/res/values/strings.xml | 2 + app/src/main/res/xml/preferences.xml | 4 ++ 17 files changed, 186 insertions(+), 36 deletions(-) delete mode 100644 app/src/main/java/me/brysonsteck/wiimmfiwatcher/preferences/ParseSettings.java delete mode 100644 app/src/main/java/me/brysonsteck/wiimmfiwatcher/preferences/SettingsFragment.java create mode 100644 app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/ParseSettings.java create mode 100644 app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsActivity.java create mode 100644 app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsMainFragment.java create mode 100644 app/src/main/res/drawable/ic_baseline_arrow_back_24.xml create mode 100644 app/src/main/res/drawable/ic_baseline_settings_24.xml create mode 100644 app/src/main/res/layout/activity_settings.xml create mode 100644 app/src/main/res/layout/main_settings_fragment.xml delete mode 100644 app/src/main/res/menu/top_app_bar.xml create mode 100644 app/src/main/res/menu/top_app_bar_main.xml create mode 100644 app/src/main/res/menu/top_app_bar_settings.xml create mode 100644 app/src/main/res/xml/preferences.xml (limited to 'app/src/main') diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bae710f..902381a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,6 +19,7 @@ - + + \ No newline at end of file diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java index 878de62..714aee7 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java @@ -14,8 +14,8 @@ import androidx.room.Room; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import me.brysonsteck.wiimmfiwatcher.database.AppDatabase; -import me.brysonsteck.wiimmfiwatcher.fragments.AboutFragment; import me.brysonsteck.wiimmfiwatcher.fragments.WatchCodeFragment; +import me.brysonsteck.wiimmfiwatcher.settings.SettingsActivity; public class MainActivity extends AppCompatActivity { AppDatabase database; @@ -28,9 +28,9 @@ public class MainActivity extends AppCompatActivity { setContentView(R.layout.activity_main); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); - View aboutButton = findViewById(R.id.about_button); + View settingsButton = findViewById(R.id.settings_button); if (savedInstanceState == null) { - aboutButton.setVisibility(View.VISIBLE); + settingsButton.setVisibility(View.VISIBLE); getSupportFragmentManager().beginTransaction() .replace(R.id.friend_code_input_fragment, new WatchCodeFragment(), null) .setReorderingAllowed(true) @@ -39,18 +39,20 @@ public class MainActivity extends AppCompatActivity { database = Room.databaseBuilder(this, AppDatabase.class, "friend-codes-db").build(); - aboutButton.setOnClickListener((about) -> { - aboutButton.setVisibility(View.INVISIBLE); - getSupportFragmentManager().beginTransaction() - .setCustomAnimations( - R.anim.slide_in, - R.anim.fade_out, - R.anim.fade_in, - R.anim.slide_out) - .replace(R.id.friend_code_input_fragment, new AboutFragment(), null) - .setReorderingAllowed(true) - .addToBackStack(null) - .commit(); + settingsButton.setOnClickListener((about) -> { +// settingsButton.setVisibility(View.INVISIBLE); +// getSupportFragmentManager().beginTransaction() +// .setCustomAnimations( +// R.anim.slide_in, +// R.anim.fade_out, +// R.anim.fade_in, +// R.anim.slide_out) +// .replace(R.id.friend_code_input_fragment, new AboutFragment(), null) +// .setReorderingAllowed(true) +// .addToBackStack(null) +// .commit(); + Intent intent = new Intent(this, SettingsActivity.class); + startActivity(intent); }); } diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/preferences/ParseSettings.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/preferences/ParseSettings.java deleted file mode 100644 index 78ecced..0000000 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/preferences/ParseSettings.java +++ /dev/null @@ -1,4 +0,0 @@ -package me.brysonsteck.wiimmfiwatcher.preferences; - -public class ParseSettings { -} diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/preferences/SettingsFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/preferences/SettingsFragment.java deleted file mode 100644 index e24236b..0000000 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/preferences/SettingsFragment.java +++ /dev/null @@ -1,4 +0,0 @@ -package me.brysonsteck.wiimmfiwatcher.preferences; - -public class SettingsFragment { -} diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/ParseSettings.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/ParseSettings.java new file mode 100644 index 0000000..9268bd2 --- /dev/null +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/ParseSettings.java @@ -0,0 +1,4 @@ +package me.brysonsteck.wiimmfiwatcher.settings; + +public class ParseSettings { +} diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsActivity.java new file mode 100644 index 0000000..076d6c0 --- /dev/null +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsActivity.java @@ -0,0 +1,18 @@ +package me.brysonsteck.wiimmfiwatcher.settings; + +import android.os.Bundle; +import android.preference.PreferenceFragment; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.preference.PreferenceFragmentCompat; + +import me.brysonsteck.wiimmfiwatcher.R; + +public class SettingsActivity extends PreferenceFragmentCompat { + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootkey) { + super.onCreate(savedInstanceState); + setPreferencesFromResource(R.xml.preferences, rootkey); + } +} diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsMainFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsMainFragment.java new file mode 100644 index 0000000..6f9414f --- /dev/null +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsMainFragment.java @@ -0,0 +1,6 @@ +package me.brysonsteck.wiimmfiwatcher.settings; + +import androidx.fragment.app.Fragment; + +public class SettingsMainFragment extends Fragment { +} diff --git a/app/src/main/res/drawable/ic_baseline_arrow_back_24.xml b/app/src/main/res/drawable/ic_baseline_arrow_back_24.xml new file mode 100644 index 0000000..31e7df2 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_arrow_back_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_settings_24.xml b/app/src/main/res/drawable/ic_baseline_settings_24.xml new file mode 100644 index 0000000..b240b83 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_settings_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index bf5adcd..039941a 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -27,7 +27,7 @@ android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:elevation="0dp" - app:menu="@menu/top_app_bar" + app:menu="@menu/top_app_bar_main" app:title="Wiimmfi Watcher" app:titleTextColor="@color/white" /> diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml new file mode 100644 index 0000000..327dc2e --- /dev/null +++ b/app/src/main/res/layout/activity_settings.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/main_settings_fragment.xml b/app/src/main/res/layout/main_settings_fragment.xml new file mode 100644 index 0000000..9d0a368 --- /dev/null +++ b/app/src/main/res/layout/main_settings_fragment.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + +