figured out preferences, going to bed now
This commit is contained in:
parent
5977cfeb9b
commit
fb51cefd42
17 changed files with 178 additions and 26 deletions
|
@ -35,6 +35,7 @@ android {
|
|||
dependencies {
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
def lifecycle_version = "2.3.1"
|
||||
def preference_version = '1.1.1'
|
||||
|
||||
// ViewModel
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
|
||||
|
@ -47,6 +48,7 @@ dependencies {
|
|||
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
|
||||
|
||||
implementation "androidx.fragment:fragment:1.3.3"
|
||||
implementation "androidx.preference:preference:$preference_version"
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".wiimmfi.WiimmfiActivity"/>
|
||||
</application>
|
||||
<activity android:name=".settings.SettingsActivity"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -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);
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
package me.brysonsteck.wiimmfiwatcher.preferences;
|
||||
|
||||
public class ParseSettings {
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package me.brysonsteck.wiimmfiwatcher.preferences;
|
||||
|
||||
public class SettingsFragment {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package me.brysonsteck.wiimmfiwatcher.settings;
|
||||
|
||||
public class ParseSettings {
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package me.brysonsteck.wiimmfiwatcher.settings;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public class SettingsMainFragment extends Fragment {
|
||||
}
|
5
app/src/main/res/drawable/ic_baseline_arrow_back_24.xml
Normal file
5
app/src/main/res/drawable/ic_baseline_arrow_back_24.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:tint="#FFFFFF" android:viewportHeight="24"
|
||||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
|
||||
</vector>
|
5
app/src/main/res/drawable/ic_baseline_settings_24.xml
Normal file
5
app/src/main/res/drawable/ic_baseline_settings_24.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z"/>
|
||||
</vector>
|
|
@ -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" />
|
||||
|
||||
|
|
68
app/src/main/res/layout/activity_settings.xml
Normal file
68
app/src/main/res/layout/activity_settings.xml
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/drawer_layout"
|
||||
tools:context=".settings.SettingsActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/Widget.MaterialComponents.Toolbar.Primary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:navigationIcon="@drawable/ic_baseline_arrow_back_24"
|
||||
app:navigationIconTint="#FFFFFF"
|
||||
android:elevation="0dp"
|
||||
app:title="@string/settings_title"
|
||||
app:titleTextColor="@color/white" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/fragmentContainerView"
|
||||
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" />
|
||||
|
||||
<!-- <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton-->
|
||||
<!-- android:id="@+id/clear_button"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_gravity="bottom|right"-->
|
||||
<!-- android:layout_margin="15dp"-->
|
||||
<!-- android:foregroundTint="#FFFFFF"-->
|
||||
<!-- android:text="Clear"-->
|
||||
<!-- android:textColor="#FFFFFF"-->
|
||||
<!-- app:backgroundTint="#1E88E5"-->
|
||||
<!-- app:icon="@drawable/ic_baseline_clear_all_24"-->
|
||||
<!-- app:iconTint="#FFFFFF"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent" />-->
|
||||
|
||||
<!-- Screen content -->
|
||||
<!-- Use app:layout_behavior="@string/appbar_scrolling_view_behavior" to fit below top app bar -->
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
32
app/src/main/res/layout/main_settings_fragment.xml
Normal file
32
app/src/main/res/layout/main_settings_fragment.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switch1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Switch"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/toggleButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="ToggleButton" />
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -5,7 +5,14 @@
|
|||
android:id="@+id/about_button"
|
||||
android:icon="@drawable/ic_baseline_info_24"
|
||||
android:title="About"
|
||||
android:visible="true"
|
||||
android:visible="false"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/settings_button"
|
||||
android:icon="@drawable/ic_baseline_settings_24"
|
||||
android:visible="true"
|
||||
app:showAsAction="ifRoom"
|
||||
android:title="Settings" />
|
||||
|
||||
</menu>
|
4
app/src/main/res/menu/top_app_bar_settings.xml
Normal file
4
app/src/main/res/menu/top_app_bar_settings.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</menu>
|
|
@ -42,4 +42,6 @@
|
|||
<string name="update_message">A new version of Wiimmfi Watcher is available on the Play Store (version %1$s)! You can download it by pressing \"Update\".</string>
|
||||
<string name="update_positive">Update</string>
|
||||
<string name="update_negative">Later</string>
|
||||
|
||||
<string name="settings_title">Settings</string>
|
||||
</resources>
|
4
app/src/main/res/xml/preferences.xml
Normal file
4
app/src/main/res/xml/preferences.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</PreferenceScreen>
|
Reference in a new issue