Example usage for android.preference EditTextPreference setSummary

List of usage examples for android.preference EditTextPreference setSummary

Introduction

In this page you can find the example usage for android.preference EditTextPreference setSummary.

Prototype

public void setSummary(CharSequence summary) 

Source Link

Document

Sets the summary for this Preference with a CharSequence.

Usage

From source file:im.vector.fragments.VectorRoomSettingsFragment.java

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(LOG_TAG, "## onCreate() IN");

        // retrieve fragment extras
        String matrixId = getArguments().getString(EXTRA_MATRIX_ID);
        String roomId = getArguments().getString(EXTRA_ROOM_ID);

        if (TextUtils.isEmpty(matrixId) || TextUtils.isEmpty(roomId)) {
            Log.e(LOG_TAG, "## onCreate(): fragment extras (MatrixId or RoomId) are missing");
            getActivity().finish();//from ww  w . j  a  va 2 s  . c o  m
        } else {
            mSession = Matrix.getInstance(getActivity()).getSession(matrixId);
            if ((null != mSession) && mSession.isAlive()) {
                mRoom = mSession.getDataHandler().getRoom(roomId);
                mBingRulesManager = mSession.getDataHandler().getBingRulesManager();
            }

            if (null == mRoom) {
                Log.e(LOG_TAG, "## onCreate(): unable to retrieve Room object");
                getActivity().finish();
            }
        }

        // load preference xml file
        addPreferencesFromResource(R.xml.vector_room_settings_preferences);

        // init preference fields
        mRoomPhotoAvatar = (RoomAvatarPreference) findPreference(PREF_KEY_ROOM_PHOTO_AVATAR);
        mRoomNameEditTxt = (EditTextPreference) findPreference(PREF_KEY_ROOM_NAME);
        mRoomTopicEditTxt = (EditTextPreference) findPreference(PREF_KEY_ROOM_TOPIC);
        mRoomDirectoryVisibilitySwitch = (CheckBoxPreference) findPreference(
                PREF_KEY_ROOM_DIRECTORY_VISIBILITY_SWITCH);
        mRoomTagListPreference = (ListPreference) findPreference(PREF_KEY_ROOM_TAG_LIST);
        mRoomAccessRulesListPreference = (VectorListPreference) findPreference(PREF_KEY_ROOM_ACCESS_RULES_LIST);
        mRoomHistoryReadabilityRulesListPreference = (ListPreference) findPreference(
                PREF_KEY_ROOM_HISTORY_READABILITY_LIST);
        mAddressesSettingsCategory = (PreferenceCategory) getPreferenceManager().findPreference(PREF_KEY_ADDRESSES);
        mAdvandceSettingsCategory = (PreferenceCategory) getPreferenceManager().findPreference(PREF_KEY_ADVANCED);
        mBannedMembersSettingsCategory = (PreferenceCategory) getPreferenceManager()
                .findPreference(PREF_KEY_BANNED);
        mBannedMembersSettingsCategoryDivider = (PreferenceCategory) getPreferenceManager()
                .findPreference(PREF_KEY_BANNED_DIVIDER);
        mFlairSettingsCategory = (PreferenceCategory) getPreferenceManager().findPreference(PREF_KEY_FLAIR);
        mRoomNotificationsPreference = (ListPreference) getPreferenceManager()
                .findPreference(PREF_KEY_ROOM_NOTIFICATIONS_LIST);

        mRoomAccessRulesListPreference.setOnPreferenceWarningIconClickListener(
                new VectorListPreference.OnPreferenceWarningIconClickListener() {
                    @Override
                    public void onWarningIconClick(Preference preference) {
                        displayAccessRoomWarning();
                    }
                });

        // display the room Id.
        EditTextPreference roomInternalIdPreference = (EditTextPreference) findPreference(
                PREF_KEY_ROOM_INTERNAL_ID);
        if (null != roomInternalIdPreference) {
            roomInternalIdPreference.setSummary(mRoom.getRoomId());

            roomInternalIdPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
                @Override
                public boolean onPreferenceClick(Preference preference) {
                    VectorUtils.copyToClipboard(getActivity(), mRoom.getRoomId());
                    return false;
                }
            });
        }

        // leave room
        EditTextPreference leaveRoomPreference = (EditTextPreference) findPreference(PREF_KEY_ROOM_LEAVE);

        if (null != leaveRoomPreference) {
            leaveRoomPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
                @Override
                public boolean onPreferenceClick(Preference preference) {
                    // leave room
                    new AlertDialog.Builder(getActivity()).setTitle(R.string.room_participants_leave_prompt_title)
                            .setMessage(getString(R.string.room_participants_leave_prompt_msg))
                            .setPositiveButton(R.string.leave, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    displayLoadingView();

                                    mRoom.leave(new ApiCallback<Void>() {
                                        @Override
                                        public void onSuccess(Void info) {
                                            if (null != getActivity()) {
                                                getActivity().runOnUiThread(new Runnable() {
                                                    @Override
                                                    public void run() {
                                                        getActivity().finish();
                                                    }
                                                });
                                            }
                                        }

                                        private void onError(final String errorMessage) {
                                            if (null != getActivity()) {
                                                getActivity().runOnUiThread(new Runnable() {
                                                    @Override
                                                    public void run() {
                                                        hideLoadingView(true);
                                                        Toast.makeText(getActivity(), errorMessage,
                                                                Toast.LENGTH_SHORT).show();
                                                    }
                                                });
                                            }
                                        }

                                        @Override
                                        public void onNetworkError(Exception e) {
                                            onError(e.getLocalizedMessage());
                                        }

                                        @Override
                                        public void onMatrixError(MatrixError e) {
                                            onError(e.getLocalizedMessage());
                                        }

                                        @Override
                                        public void onUnexpectedError(Exception e) {
                                            onError(e.getLocalizedMessage());
                                        }
                                    });

                                }
                            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                }
                            }).create().show();
                    return true;
                }
            });
        }

        // init the room avatar: session and room
        mRoomPhotoAvatar.setConfiguration(mSession, mRoom);
        mRoomPhotoAvatar.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                if ((null != mRoomPhotoAvatar) && mRoomPhotoAvatar.isEnabled()) {
                    onRoomAvatarPreferenceChanged();
                    return true; //True if the click was handled.
                } else
                    return false;
            }
        });

        // listen to preference changes
        enableSharedPreferenceListener(true);

        setRetainInstance(true);
    }

From source file:com.aware.Aware_Preferences.java

/**
 * Developer UI options/*from w ww.  j a v  a2s.c  o  m*/
 * - Debug flag
 * - Debug tag
 * - AWARE updates
 * - Device ID
 */
private void developerOptions() {
    final CheckBoxPreference debug_flag = (CheckBoxPreference) findPreference(Aware_Preferences.DEBUG_FLAG);
    debug_flag
            .setChecked(Aware.getSetting(getApplicationContext(), Aware_Preferences.DEBUG_FLAG).equals("true"));
    debug_flag.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Aware.DEBUG = debug_flag.isChecked();
            Aware.setSetting(getApplicationContext(), Aware_Preferences.DEBUG_FLAG, debug_flag.isChecked());
            return true;
        }
    });

    final EditTextPreference debug_tag = (EditTextPreference) findPreference(Aware_Preferences.DEBUG_TAG);
    debug_tag.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.DEBUG_TAG));
    debug_tag.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.TAG = (String) newValue;
            Aware.setSetting(getApplicationContext(), Aware_Preferences.DEBUG_TAG, (String) newValue);
            return true;
        }
    });

    final CheckBoxPreference auto_update = (CheckBoxPreference) findPreference(
            Aware_Preferences.AWARE_AUTO_UPDATE);
    auto_update.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.AWARE_AUTO_UPDATE).equals("true"));

    PackageInfo awareInfo = null;
    try {
        awareInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_ACTIVITIES);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    auto_update.setSummary("Current version is " + ((awareInfo != null) ? awareInfo.versionCode : "???"));
    auto_update.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.AWARE_AUTO_UPDATE,
                    auto_update.isChecked());
            return true;
        }
    });

    final CheckBoxPreference debug_db_slow = (CheckBoxPreference) findPreference(
            Aware_Preferences.DEBUG_DB_SLOW);
    debug_db_slow.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.DEBUG_DB_SLOW).equals("true"));
    debug_db_slow.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.DEBUG_DB_SLOW,
                    debug_db_slow.isChecked());
            return true;
        }
    });

    final EditTextPreference device_id = (EditTextPreference) findPreference(Aware_Preferences.DEVICE_ID);
    device_id.setSummary("UUID: " + Aware.getSetting(getApplicationContext(), DEVICE_ID));
    device_id.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID));
    device_id.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID, (String) newValue);
            device_id.setSummary(
                    "UUID: " + Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID));
            return true;
        }
    });
}

From source file:com.aware.Aware_Preferences.java

/**
 * WiFi module settings UI/* ww w  .j  av a  2  s .co m*/
 */
private void wifi() {
    final CheckBoxPreference wifi = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_WIFI);
    wifi.setChecked(Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_WIFI).equals("true"));
    wifi.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_WIFI, wifi.isChecked());
            if (wifi.isChecked()) {
                framework.startWiFi();
            } else {
                framework.stopWiFi();
            }
            return true;
        }
    });

    final EditTextPreference wifiInterval = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_WIFI);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_WIFI).length() > 0) {
        wifiInterval.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_WIFI) + " seconds");
    }
    wifiInterval.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_WIFI));
    wifiInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_WIFI, (String) newValue);
            wifiInterval.setSummary((String) newValue + " seconds");
            framework.startWiFi();
            return true;
        }
    });
}

From source file:com.aware.Aware_Preferences.java

/**
 * TimeZone module settings UI/*from w w  w .  j  av  a 2  s.co  m*/
 */
private void timeZone() {
    final CheckBoxPreference timeZone = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_TIMEZONE);
    timeZone.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_TIMEZONE).equals("true"));
    timeZone.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_TIMEZONE, timeZone.isChecked());
            if (timeZone.isChecked()) {
                framework.startTimeZone();
            } else {
                framework.stopTimeZone();
            }
            return true;
        }
    });

    final EditTextPreference frequencyTimeZone = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_TIMEZONE);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_TIMEZONE).length() > 0) {
        frequencyTimeZone.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_TIMEZONE) + " seconds");
    }
    frequencyTimeZone.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_TIMEZONE));
    frequencyTimeZone.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_TIMEZONE, (String) newValue);
            frequencyTimeZone.setSummary((String) newValue + " seconds");
            framework.startTimeZone();
            return true;
        }
    });
}

From source file:com.aware.Aware_Preferences.java

/**
 * Processor module settings UI//from w w w .  ja  v  a 2 s  .  c o m
 */
private void processor() {
    final CheckBoxPreference processor = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_PROCESSOR);
    processor.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_PROCESSOR).equals("true"));
    processor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_PROCESSOR,
                    processor.isChecked());
            if (processor.isChecked()) {
                framework.startProcessor();
            } else {
                framework.stopProcessor();
            }
            return true;
        }
    });

    final EditTextPreference frequencyProcessor = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_PROCESSOR);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_PROCESSOR).length() > 0) {
        frequencyProcessor.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_PROCESSOR) + " seconds");
    }
    frequencyProcessor
            .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_PROCESSOR));
    frequencyProcessor.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_PROCESSOR, (String) newValue);
            frequencyProcessor.setSummary((String) newValue + " seconds");
            framework.startProcessor();
            return true;
        }
    });
}

From source file:com.aware.Aware_Preferences.java

/**
 * Light module settings UI/*  ww  w.java2s. c  o  m*/
 */
private void light() {

    final PreferenceScreen light_pref = (PreferenceScreen) findPreference("light");
    Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_LIGHT);
    if (temp != null) {
        light_pref.setSummary(
                light_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA"));
    } else {
        light_pref.setSummary(light_pref.getSummary().toString().replace("*", ""));
    }

    final CheckBoxPreference light = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_LIGHT);
    light.setChecked(Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_LIGHT).equals("true"));
    light.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (mSensorMgr.getDefaultSensor(Sensor.TYPE_LIGHT) == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                light.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LIGHT, false);
                return false;
            }

            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LIGHT, light.isChecked());
            if (light.isChecked()) {
                framework.startLight();
            } else {
                framework.stopLight();
            }
            return true;
        }
    });

    final EditTextPreference frequency_light = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_LIGHT);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LIGHT).length() > 0) {
        frequency_light.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LIGHT) + " microseconds");
    }
    frequency_light.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LIGHT));
    frequency_light.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LIGHT, (String) newValue);
            frequency_light.setSummary((String) newValue + " microseconds");
            framework.startLight();
            return true;
        }
    });

}

From source file:com.aware.Aware_Preferences.java

/**
 * Bluetooth module settings UI//w  w  w . jav a  2  s  .  c  o m
 */
private void bluetooth() {
    final CheckBoxPreference bluetooth = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_BLUETOOTH);
    bluetooth.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_BLUETOOTH).equals("true"));
    bluetooth.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
            if (btAdapter == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                bluetooth.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_BLUETOOTH, false);
                return false;
            }

            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_BLUETOOTH,
                    bluetooth.isChecked());
            if (bluetooth.isChecked()) {
                framework.startBluetooth();
            } else {
                framework.stopBluetooth();
            }
            return true;
        }
    });

    final EditTextPreference bluetoothInterval = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_BLUETOOTH);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_BLUETOOTH).length() > 0) {
        bluetoothInterval.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_BLUETOOTH) + " seconds");
    }
    bluetoothInterval.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_BLUETOOTH));
    bluetoothInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_BLUETOOTH, (String) newValue);
            bluetoothInterval.setSummary((String) newValue + " seconds");
            framework.startBluetooth();
            return true;
        }
    });
}

From source file:com.aware.Aware_Preferences.java

/**
 * Gravity module settings UI//from ww w  .  j av a  2  s .  c  om
 */
private void gravity() {
    final PreferenceScreen grav_pref = (PreferenceScreen) findPreference("gravity");
    Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_GRAVITY);
    if (temp != null) {
        grav_pref.setSummary(
                grav_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA"));
    } else {
        grav_pref.setSummary(grav_pref.getSummary().toString().replace("*", ""));
    }

    final CheckBoxPreference gravity = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_GRAVITY);
    gravity.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_GRAVITY).equals("true"));
    gravity.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            if (mSensorMgr.getDefaultSensor(Sensor.TYPE_GRAVITY) == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                gravity.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_GRAVITY, false);
                return false;
            }
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_GRAVITY, gravity.isChecked());
            if (gravity.isChecked()) {
                framework.startGravity();
            } else {
                framework.stopGravity();
            }
            return true;
        }
    });

    final EditTextPreference frequency_gravity = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_GRAVITY);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GRAVITY).length() > 0) {
        frequency_gravity
                .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GRAVITY)
                        + " microseconds");
    }
    frequency_gravity.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GRAVITY));
    frequency_gravity.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GRAVITY, (String) newValue);
            frequency_gravity.setSummary((String) newValue + " microseconds");
            framework.startGravity();
            return true;
        }
    });
}

From source file:com.aware.Aware_Preferences.java

/**
 * Rotation module settings UI//from ww  w  .  j  a v  a 2 s . c o  m
 */
private void rotation() {

    final PreferenceScreen rotation_pref = (PreferenceScreen) findPreference("rotation");
    Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
    if (temp != null) {
        rotation_pref.setSummary(
                rotation_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA"));
    } else {
        rotation_pref.setSummary(rotation_pref.getSummary().toString().replace("*", ""));
    }

    final CheckBoxPreference rotation = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_ROTATION);
    rotation.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_ROTATION).equals("true"));
    rotation.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (mSensorMgr.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR) == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                rotation.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_ROTATION, false);
                return false;
            }

            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_ROTATION, rotation.isChecked());
            if (rotation.isChecked()) {
                framework.startRotation();
            } else {
                framework.stopRotation();
            }
            return true;
        }
    });

    final EditTextPreference frequency_rotation = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_ROTATION);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ROTATION).length() > 0) {
        frequency_rotation
                .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ROTATION)
                        + " microseconds");
    }
    frequency_rotation.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ROTATION));
    frequency_rotation.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ROTATION, (String) newValue);
            frequency_rotation.setSummary((String) newValue + " microseconds");
            framework.startRotation();
            return true;
        }
    });

}