Implemented Settings screen (WIP)

This commit is contained in:
Caesar2011
2018-08-02 01:19:12 +02:00
parent 092d7fe7f5
commit 4f24e74e18
5 changed files with 52 additions and 9 deletions

View File

@@ -1,12 +1,12 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 27 compileSdkVersion 28
buildToolsVersion '27.0.3' buildToolsVersion '27.0.3'
defaultConfig { defaultConfig {
applicationId "de.sebse.fuplanner" applicationId "de.sebse.fuplanner"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 27 targetSdkVersion 28
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -27,23 +27,24 @@ android {
dependencies { dependencies {
implementation 'com.android.support:recyclerview-v7:27.1.1' implementation 'com.android.support:recyclerview-v7:28.0.0-beta01'
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
implementation 'com.android.support:design:27.1.1' implementation 'com.android.support:preference-v7:28.0.0-beta01'
implementation 'com.android.support:design:28.0.0-beta01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2' implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.volley:volley:1.0.0' implementation 'com.android.volley:volley:1.0.0'
//noinspection GradleDependency //noinspection GradleDependency
implementation 'com.google.android.gms:play-services-auth:15.0.0' implementation 'com.google.android.gms:play-services-auth:15.0.0'
implementation 'com.android.support:support-v4:27.1.1' implementation 'com.android.support:support-v4:28.0.0-beta01'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
implementation 'com.android.support:support-v4:27.1.1' implementation 'com.android.support:support-v4:28.0.0-beta01'
implementation 'org.jetbrains:annotations-java5:15.0' implementation 'org.jetbrains:annotations-java5:15.0'
//implementation 'com.github.quivr:android-week-view:2.0.2'//com.github.alamkanak:android-week-view:1.2.6 //implementation 'com.github.quivr:android-week-view:2.0.2'//com.github.alamkanak:android-week-view:1.2.6
implementation 'com.ms-square:expandableTextView:0.1.4' implementation 'com.ms-square:expandableTextView:0.1.4'

View File

@@ -23,6 +23,7 @@ import java.util.Iterator;
import de.sebse.fuplanner.fragments.CanteensFragment; import de.sebse.fuplanner.fragments.CanteensFragment;
import de.sebse.fuplanner.fragments.LoginFragment; import de.sebse.fuplanner.fragments.LoginFragment;
import de.sebse.fuplanner.fragments.ModulesFragment; import de.sebse.fuplanner.fragments.ModulesFragment;
import de.sebse.fuplanner.fragments.PrefsFragment;
import de.sebse.fuplanner.fragments.ScheduleFragment; import de.sebse.fuplanner.fragments.ScheduleFragment;
import de.sebse.fuplanner.fragments.StartupFragment; import de.sebse.fuplanner.fragments.StartupFragment;
import de.sebse.fuplanner.fragments.canteen.DaySwitcherFragment; import de.sebse.fuplanner.fragments.canteen.DaySwitcherFragment;
@@ -51,6 +52,7 @@ public class MainActivity extends AppCompatActivity
private static final int FRAGMENT_SCHEDULE = 4; private static final int FRAGMENT_SCHEDULE = 4;
private static final int FRAGMENT_CANTEENS = 5; private static final int FRAGMENT_CANTEENS = 5;
private static final int FRAGMENT_CANTEENS_DETAILS = 6; private static final int FRAGMENT_CANTEENS_DETAILS = 6;
private static final int FRAGMENT_PREFERENCES = 7;
private static final String ARG_FRAGMENT_PAGE = "fragment_page"; private static final String ARG_FRAGMENT_PAGE = "fragment_page";
private static final String ARG_FRAGMENT_STATUS = "fragment_status"; private static final String ARG_FRAGMENT_STATUS = "fragment_status";
@@ -156,7 +158,6 @@ public class MainActivity extends AppCompatActivity
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@SuppressWarnings("StatementWithEmptyBody")
@Override @Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) { public boolean onNavigationItemSelected(@NonNull MenuItem item) {
// Handle navigation view item clicks here. // Handle navigation view item clicks here.
@@ -172,6 +173,9 @@ public class MainActivity extends AppCompatActivity
case R.id.nav_dining: case R.id.nav_dining:
changeFragment(FRAGMENT_CANTEENS); changeFragment(FRAGMENT_CANTEENS);
break; break;
case R.id.nav_settings:
changeFragment(FRAGMENT_PREFERENCES);
break;
case R.id.nav_share: case R.id.nav_share:
Intent sendIntent = new Intent(); Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setAction(Intent.ACTION_SEND);
@@ -307,6 +311,9 @@ public class MainActivity extends AppCompatActivity
case FRAGMENT_CANTEENS_DETAILS: case FRAGMENT_CANTEENS_DETAILS:
fragment = DaySwitcherFragment.newInstance(Integer.parseInt(newData)); fragment = DaySwitcherFragment.newInstance(Integer.parseInt(newData));
break; break;
case FRAGMENT_PREFERENCES:
fragment = PrefsFragment.newInstance();
break;
default: // FRAGMENT_STARTUP default: // FRAGMENT_STARTUP
fragment = StartupFragment.newInstance(); fragment = StartupFragment.newInstance();
break; break;

View File

@@ -0,0 +1,22 @@
package de.sebse.fuplanner.fragments;
import android.os.Bundle;
import android.support.v7.preference.PreferenceFragmentCompat;
import de.sebse.fuplanner.R;
public class PrefsFragment extends PreferenceFragmentCompat {
public static PrefsFragment newInstance() {
PrefsFragment fragment = new PrefsFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
// Load the preferences from an XML resource
setPreferencesFromResource(R.xml.preferences, rootKey);
}
}

View File

@@ -47,4 +47,5 @@
<string name="location_name">Location: %1$s</string> <string name="location_name">Location: %1$s</string>
<string name="module_name">Module: %1$s</string> <string name="module_name">Module: %1$s</string>
<string name="close">Close</string> <string name="close">Close</string>
<string name="root_preferences" translatable="false">root_preferences</string>
</resources> </resources>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/root_preferences">
<PreferenceScreen
android:title="@string/hello_blank_fragment"
android:summary="@string/lorem_ipsum_100">
<intent android:action="android.intent.action.VIEW"
android:data="http://www.android.com" />
</PreferenceScreen>
</PreferenceScreen>