Android Open Source - o365api-android-get-events-app Settings Activity






From Project

Back to project page o365api-android-get-events-app.

License

The source code is released under:

MIT License

If you think the Android project o365api-android-get-events-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.mattleib.myinboxapplication;
//from w  w  w .  ja  v a 2s.c  om
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.app.Activity;
import android.preference.PreferenceManager;


public class SettingsActivity extends Activity
        implements SettingsFragment.EventTimespanChanged {

    private static PreferenceSettings mPreferenceSettings = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Display the fragment as the main content.
        getFragmentManager().beginTransaction()
                .replace(android.R.id.content, new SettingsFragment())
                .commit();

        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        String eventSpan = sharedPreferences.getString(Constants.PreferenceKeys.CalendarTimeSpan, "day");
        Boolean usePPE = sharedPreferences.getBoolean(Constants.PreferenceKeys.UsePPE, false);
        Boolean useCoolColors = sharedPreferences.getBoolean(Constants.PreferenceKeys.UseCoolColors, false);
        Boolean doNotShowPastEvents = sharedPreferences.getBoolean(Constants.PreferenceKeys.DoNotShowPastEvents, false);

        mPreferenceSettings = new PreferenceSettings(
                new PreferenceSetting(eventSpan, eventSpan),
                new PreferenceSetting(usePPE.toString(), usePPE.toString()),
                new PreferenceSetting(useCoolColors.toString(), useCoolColors.toString()),
                new PreferenceSetting(doNotShowPastEvents.toString(), doNotShowPastEvents.toString())
        );
        setIntent();
    }

    /**
     * The interface for preference Fragment to notify to Refresh events
     */
    private void setIntent()
    {
        Intent returnIntent = new Intent();
        Bundle mBundle = new Bundle();
        mBundle.putSerializable(PreferenceSettings.SER_KEY, mPreferenceSettings);
        returnIntent.putExtras(mBundle);

        setResult(Constants.PICK_PREFERENCE_REQUEST, returnIntent);
    }

    public void onNewTimeSpan(String timeSpan) {
        mPreferenceSettings.getEventTimeSpan().setNewValue(timeSpan);
        setIntent();
    }

    public void onEnvironmentChanged(Boolean usePPE) {
        mPreferenceSettings.getUsePPE().setNewValue(usePPE.toString());
        setIntent();
    }

    public void onColorChanged(Boolean useCool) {
        mPreferenceSettings.getUseCoolColor().setNewValue(useCool.toString());
        setIntent();
    }

    public void onNoPastEventsChanged(Boolean doNotShowPastEvents) {
        mPreferenceSettings.getDoNotShowPastEvents().setNewValue(doNotShowPastEvents.toString());
        setIntent();
    }
}




Java Source Code List

com.example.mattleib.myinboxapplication.AppConfig.java
com.example.mattleib.myinboxapplication.AppHelper.java
com.example.mattleib.myinboxapplication.ApplicationTest.java
com.example.mattleib.myinboxapplication.Constants.java
com.example.mattleib.myinboxapplication.DataTypes.java
com.example.mattleib.myinboxapplication.EmailAddress.java
com.example.mattleib.myinboxapplication.EmptyItem.java
com.example.mattleib.myinboxapplication.EventItem.java
com.example.mattleib.myinboxapplication.EventItemsFragment.java
com.example.mattleib.myinboxapplication.Helpers.java
com.example.mattleib.myinboxapplication.InMemoryCacheStore.java
com.example.mattleib.myinboxapplication.Item.java
com.example.mattleib.myinboxapplication.LocalDateTimeConverter.java
com.example.mattleib.myinboxapplication.Location.java
com.example.mattleib.myinboxapplication.MainActivity.java
com.example.mattleib.myinboxapplication.Organizer.java
com.example.mattleib.myinboxapplication.PreferenceSetting.java
com.example.mattleib.myinboxapplication.PreferenceSettings.java
com.example.mattleib.myinboxapplication.SectionItem.java
com.example.mattleib.myinboxapplication.SettingsActivity.java
com.example.mattleib.myinboxapplication.SettingsFragment.java
com.example.mattleib.myinboxapplication.SimpleAlertDialog.java