Android Open Source - bluetooth-spp-terminal Settings Activity






From Project

Back to project page bluetooth-spp-terminal.

License

The source code is released under:

Apache License

If you think the Android project bluetooth-spp-terminal 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 ru.sash0k.bluetooth_terminal.activity;
/* w  w w.  j a  v  a  2s.c o m*/
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceManager;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockPreferenceActivity;
import com.actionbarsherlock.view.MenuItem;

import ru.sash0k.bluetooth_terminal.R;

/**
 * Created by sash0k on 29.11.13.
 * ??????????? ???????????
 */
@SuppressWarnings("deprecation")
public final class SettingsActivity extends SherlockPreferenceActivity
        implements SharedPreferences.OnSharedPreferenceChangeListener {


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.settings_activity);

        final ActionBar bar = getSupportActionBar();
        bar.setHomeButtonEnabled(true);
        bar.setDisplayHomeAsUpEnabled(true);

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        prefs.registerOnSharedPreferenceChangeListener(this);
        setPrefenceTitle(getString(R.string.pref_commands_mode));
        setPrefenceTitle(getString(R.string.pref_commands_ending));
    }
    // ============================================================================


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        switch (id) {
            case android.R.id.home:
                finish();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
    // ============================================================================


    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String value) {
        setPrefenceTitle(value);
    }
    // ============================================================================


    /**
     * ?????????? ????????? ????????
     */
    private void setPrefenceTitle(String TAG) {
        final Preference preference = findPreference(TAG);
        if (preference == null) return;
        if (preference instanceof ListPreference) {
            if (((ListPreference) preference).getEntry() == null) return;
            final String title = ((ListPreference) preference).getEntry().toString();
            preference.setTitle(title);
        }
    }
    // ============================================================================
}




Java Source Code List

ru.sash0k.bluetooth_terminal.Const.java
ru.sash0k.bluetooth_terminal.DeviceData.java
ru.sash0k.bluetooth_terminal.Utils.java
ru.sash0k.bluetooth_terminal.activity.BaseActivity.java
ru.sash0k.bluetooth_terminal.activity.DeviceControlActivity.java
ru.sash0k.bluetooth_terminal.activity.SettingsActivity.java
ru.sash0k.bluetooth_terminal.bluetooth.BluetoothUtils.java
ru.sash0k.bluetooth_terminal.bluetooth.DeviceConnector.java
ru.sash0k.bluetooth_terminal.bluetooth.DeviceListActivity.java