Android Open Source - Aegis S M S Alarm Fragment






From Project

Back to project page Aegis.

License

The source code is released under:

GNU General Public License

If you think the Android project Aegis 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.decad3nce.aegis.Fragments;
/*  w  w  w. j  a v  a  2 s. c o m*/
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.widget.CompoundButton;
import android.widget.Switch;
import com.decad3nce.aegis.R;
import com.decad3nce.aegis.Utils;

public class SMSAlarmFragment extends PreferenceFragment {
    public static final String PREFERENCES_ALARM_ENABLED = "alarm_toggle";
    public static final String PREFERENCES_ALARM_VIBRATE = "alarm_vibrate";
    public static final String PREFERENCES_ALARM_DURATION = "alarm_duration";
    public static final String PREFERENCES_ALARM_ACTIVATION_SMS = "alarm_activation_sms";

    private Switch mAlarmEnabledPreference;
    protected static boolean alarmEnabled;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.alarm_preference);
        setHasOptionsMenu(true);
    }

    @Override
    public void onResume() {
        super.onResume();
        final SharedPreferences preferences = PreferenceManager
                .getDefaultSharedPreferences(getActivity());
        alarmEnabled = preferences
                .getBoolean(PREFERENCES_ALARM_ENABLED, getActivity().getResources().getBoolean(R.bool.config_default_alarm_enabled));
    }

    @Override
    public void onPrepareOptionsMenu(Menu menu) {
        Utils.showItem(R.id.alarm_menu_settings, menu);
        mAlarmEnabledPreference = (Switch) menu
                .findItem(R.id.alarm_menu_settings).getActionView()
                .findViewById(R.id.alarm_toggle);
        mAlarmEnabledPreference.setChecked(alarmEnabled);
        mAlarmEnabledPreference.setOnCheckedChangeListener(alarmPreferencesOnChangeListener);
        super.onPrepareOptionsMenu(menu);
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
    }


    CompoundButton.OnCheckedChangeListener alarmPreferencesOnChangeListener = new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView,
                                     boolean isChecked) {
            SharedPreferences preferences = PreferenceManager
                    .getDefaultSharedPreferences(getActivity());

            switch (buttonView.getId()) {
                case R.id.alarm_toggle:
                    SharedPreferences.Editor editor = preferences.edit();;

                    if (isChecked) {
                        editor.putBoolean(PREFERENCES_ALARM_ENABLED, true);
                        editor.commit();
                    } else {
                        editor.putBoolean(PREFERENCES_ALARM_ENABLED, false);;
                        editor.commit();
                    }
                    break;
            }
        }
    };
}




Java Source Code List

com.decad3nce.aegis.AegisActivity.java
com.decad3nce.aegis.AlarmService.java
com.decad3nce.aegis.BackupDropboxAccountsActivity.java
com.decad3nce.aegis.BackupGoogleAccountsActivity.java
com.decad3nce.aegis.BackupUtils.java
com.decad3nce.aegis.DeviceAdmin.java
com.decad3nce.aegis.DialerCodeReceiver.java
com.decad3nce.aegis.DrawerLayoutAdapter.java
com.decad3nce.aegis.FontAdapter.java
com.decad3nce.aegis.LoginActivity.java
com.decad3nce.aegis.PhoneTrackerActivity.java
com.decad3nce.aegis.RegisterActivity.java
com.decad3nce.aegis.RootTask.java
com.decad3nce.aegis.SIMStateReceiver.java
com.decad3nce.aegis.SMSReceiver.java
com.decad3nce.aegis.Utils.java
com.decad3nce.aegis.WipeBaseActivity.java
com.decad3nce.aegis.WipeTask.java
com.decad3nce.aegis.Fragments.AboutFragment.java
com.decad3nce.aegis.Fragments.AdvancedSettingsFragment.java
com.decad3nce.aegis.Fragments.BackupAccountsDialogFragment.java
com.decad3nce.aegis.Fragments.ChooseBackupProgramDialogFragment.java
com.decad3nce.aegis.Fragments.InstallToSystemDialogFragment.java
com.decad3nce.aegis.Fragments.SIMListFragment.java
com.decad3nce.aegis.Fragments.SMSAlarmFragment.java
com.decad3nce.aegis.Fragments.SMSDataFragment.java
com.decad3nce.aegis.Fragments.SMSLocateFragment.java
com.decad3nce.aegis.Fragments.SMSLockFragment.java
com.decad3nce.aegis.Fragments.SMSWipeFragment.java