diff options
Diffstat (limited to 'app/src/main/java/me')
3 files changed, 43 insertions, 15 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); + } } |