diff options
author | Bryson Steck <steck.bryson@gmail.com> | 2021-08-12 20:43:51 -0600 |
---|---|---|
committer | Bryson Steck <steck.bryson@gmail.com> | 2021-08-12 20:43:51 -0600 |
commit | d9dfccfc6a8ba167ba38efdf83368e790f35a636 (patch) | |
tree | 991b63d78c81632d3844334b0db0b53ebbf3e232 | |
parent | fb51cefd42871cc470253edbe9616706bfbd2361 (diff) | |
download | wiimmfi-watcher-dev.tar wiimmfi-watcher-dev.tar.gz wiimmfi-watcher-dev.tar.bz2 |
i have no idea what im doing actuallydev
5 files changed, 55 insertions, 21 deletions
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java index 714aee7..0bf5f5c 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java @@ -40,17 +40,6 @@ public class MainActivity extends AppCompatActivity { database = Room.databaseBuilder(this, AppDatabase.class, "friend-codes-db").build(); 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/settings/SettingsActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsActivity.java index 076d6c0..2ecec14 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsActivity.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsActivity.java @@ -2,17 +2,25 @@ package me.brysonsteck.wiimmfiwatcher.settings; import android.os.Bundle; import android.preference.PreferenceFragment; +import android.view.View; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.preference.PreferenceFragmentCompat; import me.brysonsteck.wiimmfiwatcher.R; +import me.brysonsteck.wiimmfiwatcher.fragments.WatchCodeFragment; -public class SettingsActivity extends PreferenceFragmentCompat { +public class SettingsActivity extends AppCompatActivity { @Override - public void onCreatePreferences(Bundle savedInstanceState, String rootkey) { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setPreferencesFromResource(R.xml.preferences, rootkey); + setContentView(R.layout.activity_settings); + if (savedInstanceState != null) { + getSupportFragmentManager().beginTransaction() + .replace(R.id.settings_fragment_view, new SettingsMainFragment(), null) + .setReorderingAllowed(true) + .commit(); + } } } diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsMainFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsMainFragment.java index 6f9414f..883316d 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsMainFragment.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/settings/SettingsMainFragment.java @@ -1,6 +1,37 @@ package me.brysonsteck.wiimmfiwatcher.settings; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; +import androidx.preference.ListPreference; +import androidx.preference.Preference; +import androidx.preference.PreferenceFragmentCompat; + +import me.brysonsteck.wiimmfiwatcher.R; + +public class SettingsMainFragment extends PreferenceFragmentCompat { + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootkey) { + super.onCreate(savedInstanceState); + setPreferencesFromResource(R.xml.preferences, rootkey); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + ListPreference mListPreference = (ListPreference) getPreferenceManager().findPreference("preference_key"); + mListPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + // your code here + return true; + } + }); -public class SettingsMainFragment extends Fragment { + return inflater.inflate(R.layout.main_settings_fragment, container, false); + } } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 327dc2e..19e6d92 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -35,14 +35,11 @@ </com.google.android.material.appbar.AppBarLayout> <androidx.fragment.app.FragmentContainerView - android:id="@+id/fragmentContainerView" + android:id="@+id/settings_fragment_view" android:name="me.brysonsteck.wiimmfiwatcher.settings.SettingsMainFragment" android:layout_width="match_parent" - android:layout_height="0dp" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/appBarLayout" /> + android:layout_height="wrap_content" + tools:layout_editor_absoluteY="56dp" /> <!-- <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton--> <!-- android:id="@+id/clear_button"--> diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 624ed13..0123331 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -1,4 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> + <Preference + android:key="theme" + android:title="Theme" + android:summary="Blue (Default)" /> + + <SwitchPreference + android:key="dark_mode" + android:title="Dark mode"/> + </PreferenceScreen>
\ No newline at end of file |