Search in sources :

Example 1 with LengthFilter

use of android.text.InputFilter.LengthFilter in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothPairingDialog method createPinEntryView.

private View createPinEntryView() {
    View view = getLayoutInflater().inflate(R.layout.bluetooth_pin_entry, null);
    TextView messageViewCaptionHint = (TextView) view.findViewById(R.id.pin_values_hint);
    TextView messageView2 = (TextView) view.findViewById(R.id.message_below_pin);
    CheckBox alphanumericPin = (CheckBox) view.findViewById(R.id.alphanumeric_pin);
    CheckBox contactSharing = (CheckBox) view.findViewById(R.id.phonebook_sharing_message_entry_pin);
    contactSharing.setText(getString(R.string.bluetooth_pairing_shares_phonebook, mCachedDeviceManager.getName(mDevice)));
    if (mPbapClientProfile != null && mPbapClientProfile.isProfileReady()) {
        contactSharing.setVisibility(View.GONE);
    }
    if (mDevice.getPhonebookAccessPermission() == BluetoothDevice.ACCESS_ALLOWED) {
        contactSharing.setChecked(true);
    } else if (mDevice.getPhonebookAccessPermission() == BluetoothDevice.ACCESS_REJECTED) {
        contactSharing.setChecked(false);
    } else {
        if ((mDevice.getBluetoothClass() != null) && (mDevice.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE)) {
            contactSharing.setChecked(true);
            mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
        } else {
            contactSharing.setChecked(false);
            mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
        }
    }
    contactSharing.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if (isChecked) {
                mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
            } else {
                mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
            }
        }
    });
    mPairingView = (EditText) view.findViewById(R.id.text);
    mPairingView.addTextChangedListener(this);
    alphanumericPin.setOnCheckedChangeListener(this);
    int messageId;
    int messageIdHint = R.string.bluetooth_pin_values_hint;
    int maxLength;
    switch(mType) {
        case BluetoothDevice.PAIRING_VARIANT_PIN_16_DIGITS:
            messageIdHint = R.string.bluetooth_pin_values_hint_16_digits;
        // FALLTHROUGH
        case BluetoothDevice.PAIRING_VARIANT_PIN:
            messageId = R.string.bluetooth_enter_pin_other_device;
            // Maximum of 16 characters in a PIN
            maxLength = BLUETOOTH_PIN_MAX_LENGTH;
            break;
        case BluetoothDevice.PAIRING_VARIANT_PASSKEY:
            messageId = R.string.bluetooth_enter_passkey_other_device;
            // Maximum of 6 digits for passkey
            maxLength = BLUETOOTH_PASSKEY_MAX_LENGTH;
            alphanumericPin.setVisibility(View.GONE);
            break;
        default:
            Log.e(TAG, "Incorrect pairing type for createPinEntryView: " + mType);
            return null;
    }
    messageViewCaptionHint.setText(messageIdHint);
    messageView2.setText(messageId);
    mPairingView.setInputType(InputType.TYPE_CLASS_NUMBER);
    mPairingView.setFilters(new InputFilter[] { new LengthFilter(maxLength) });
    return view;
}
Also used : LengthFilter(android.text.InputFilter.LengthFilter) CheckBox(android.widget.CheckBox) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton)

Aggregations

LengthFilter (android.text.InputFilter.LengthFilter)1 View (android.view.View)1 CheckBox (android.widget.CheckBox)1 CompoundButton (android.widget.CompoundButton)1 TextView (android.widget.TextView)1