i have no idea what im doing actually

This commit is contained in:
Bryson Steck 2021-08-12 20:43:51 -06:00
parent fb51cefd42
commit d9dfccfc6a
5 changed files with 56 additions and 22 deletions

View file

@ -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);
});

View file

@ -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();
}
}
}

View file

@ -1,6 +1,37 @@
package me.brysonsteck.wiimmfiwatcher.settings;
import androidx.fragment.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class SettingsMainFragment extends Fragment {
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;
}
});
return inflater.inflate(R.layout.main_settings_fragment, container, false);
}
}

View file

@ -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"-->

View file

@ -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>