Commit a4afe519 authored by Robert Hitt's avatar Robert Hitt

Added settings page

- Might not actually work, haven't tested it
parent 3482956e
Pipeline #863 passed with stages
in 5 minutes and 15 seconds
......@@ -37,10 +37,10 @@ dependencies {
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'io.reactivex:rxandroid:1.2.0'
compile 'io.reactivex:rxjava:1.1.4'
testCompile 'junit:junit:4.12'
......@@ -53,4 +53,5 @@ dependencies {
compile 'com.github.castorflex.smoothprogressbar:library-circular:1.2.0'
compile 'io.reactivex:rxandroid:1.2.0'
compile 'io.reactivex:rxjava:1.1.4'
compile 'com.takisoft.fix:preference-v7:25.1.1.0'
}
......@@ -37,6 +37,13 @@
android:value=".views.activities.MainActivity"/>
</activity>
<activity android:name=".views.activities.SettingsActivity"
android:parentActivityName=".views.activities.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".views.activities.MainActivity"/>
</activity>
<receiver android:name=".util.NotificationReceiver"
android:process=":remote" >
</receiver>
......
......@@ -80,6 +80,7 @@ public class MainActivity extends AppCompatActivity implements MainView {
mPresenter.loadFacilities();
return true;
case R.id.action_settings:
expandSettingsActivity();
return true;
case R.id.action_about:
expandAboutActivity();
......@@ -111,4 +112,10 @@ public class MainActivity extends AppCompatActivity implements MainView {
Intent i = new Intent(this, AboutActivity.class);
startActivity(i);
}
// Opens the About page for the app
private void expandSettingsActivity() {
Intent i = new Intent(this, SettingsActivity.class);
startActivity(i);
}
}
package srct.whatsopen.views.activities;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.NavUtils;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import butterknife.ButterKnife;
import srct.whatsopen.R;
import srct.whatsopen.views.fragments.SettingsFragment;
public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Configure toolbar
Toolbar toolbar = ButterKnife.findById(this, R.id.toolbar);
setSupportActionBar(toolbar);
getSupportFragmentManager().beginTransaction()
.replace(R.id.activity_settings, new SettingsFragment())
.commit();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
package srct.whatsopen.views.fragments;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompat;
import java.util.List;
import srct.whatsopen.R;
public class SettingsFragment extends PreferenceFragmentCompat {
//implements SharedPreferences.OnSharedPreferenceChangeListener {
private SharedPreferences mSharedPreferences;
@Override
public void onCreatePreferencesFix(@Nullable Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.settings, rootKey);
//mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/activity_settings">
<include
layout="@layout/toolbar_main"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
</LinearLayout>
\ No newline at end of file
......@@ -2,4 +2,23 @@
<string name="app_name">What\'s Open</string>
<string name="toast_set_favorite">Added %s to Favorites</string>
<string name="toast_unset_favorite">Removed %s from Favorites</string>
<!-- Strings from PreferenceFragment -->
<string name="title_list_view">List View Preferences</string>
<string name="title_list_view_information">Duration Display</string>
<string name="title_rotation">Rotation Preferences</string>
<string name="title_turn_off_rotation">Turn off rotation</string>
<string name="title_notification">Notification Preferences</string>
<string name="title_turn_off_notifications">Turn off rotation</string>
<string-array name="entries_list_view_information_preference">
<item>Duration on Open Facilities</item>
<item>Duration on Closed Facilities</item>
<item>Both</item>
</string-array>
<string-array name="entryvalues_list_view_information_preference">
<item>display_duration_open</item>
<item>display_duration_closed</item>
<item>display_duration_both</item>
</string-array>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent" android:layout_width="match_parent">
<PreferenceCategory
android:title="@string/title_list_view">
<ListPreference
android:key="list_view_information_preference"
android:title="@string/title_list_view_information"
android:entries="@array/entries_list_view_information_preference"
android:entryValues="@array/entryvalues_list_view_information_preference" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/title_rotation">
<CheckBoxPreference
android:key="turn_off_rotation_preference"
android:title="@string/title_turn_off_rotation" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/title_notification">
<CheckBoxPreference
android:key="turn_off_notifications_preference"
android:title="@string/title_turn_off_notifications" />
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment