List of usage examples for android.bluetooth BluetoothAdapter ACTION_REQUEST_ENABLE
String ACTION_REQUEST_ENABLE
To view the source code for android.bluetooth BluetoothAdapter ACTION_REQUEST_ENABLE.
Click Source Link
From source file:ja.ohac.wallet.ui.SendCoinsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.send_coins_fragment, container); receivingAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_coins_receiving_address); receivingAddressView.setAdapter(new AutoCompleteAddressAdapter(activity, null)); receivingAddressView.setOnFocusChangeListener(receivingAddressListener); receivingAddressView.addTextChangedListener(receivingAddressListener); receivingStaticView = view.findViewById(R.id.send_coins_receiving_static); receivingStaticAddressView = (TextView) view.findViewById(R.id.send_coins_receiving_static_address); receivingStaticLabelView = (TextView) view.findViewById(R.id.send_coins_receiving_static_label); receivingStaticView.setOnFocusChangeListener(new OnFocusChangeListener() { private ActionMode actionMode; @Override/* w w w .ja v a 2 s. c o m*/ public void onFocusChange(final View v, final boolean hasFocus) { if (hasFocus) actionMode = activity.startActionMode(new ReceivingAddressActionMode()); else actionMode.finish(); } }); final CurrencyAmountView btcAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_btc); btcAmountView.setCurrencySymbol(btcShift == 0 ? Constants.CURRENCY_CODE_BTC : Constants.CURRENCY_CODE_MBTC); btcAmountView.setInputPrecision(btcShift == 0 ? Constants.BTC_MAX_PRECISION : Constants.MBTC_MAX_PRECISION); btcAmountView.setHintPrecision(btcPrecision); btcAmountView.setShift(btcShift); final CurrencyAmountView localAmountView = (CurrencyAmountView) view .findViewById(R.id.send_coins_amount_local); localAmountView.setInputPrecision(Constants.LOCAL_PRECISION); localAmountView.setHintPrecision(Constants.LOCAL_PRECISION); amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView); bluetoothEnableView = (CheckBox) view.findViewById(R.id.send_coins_bluetooth_enable); bluetoothEnableView.setChecked(bluetoothAdapter != null && bluetoothAdapter.isEnabled()); bluetoothEnableView.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { if (isChecked && !bluetoothAdapter.isEnabled()) { // try to enable bluetooth startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_CODE_ENABLE_BLUETOOTH); } } }); bluetoothMessageView = (TextView) view.findViewById(R.id.send_coins_bluetooth_message); sentTransactionView = (ListView) view.findViewById(R.id.send_coins_sent_transaction); sentTransactionListAdapter = new TransactionsListAdapter(activity, wallet, application.maxConnectedPeers(), false); sentTransactionView.setAdapter(sentTransactionListAdapter); viewGo = (Button) view.findViewById(R.id.send_coins_go); viewGo.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { validateReceivingAddress(true); validateAmounts(true); if (everythingValid()) handleGo(); } }); viewCancel = (Button) view.findViewById(R.id.send_coins_cancel); viewCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (state == State.INPUT) activity.setResult(Activity.RESULT_CANCELED); activity.finish(); } }); popupMessageView = (TextView) inflater.inflate(R.layout.send_coins_popup_message, container); popupAvailableView = inflater.inflate(R.layout.send_coins_popup_available, container); if (savedInstanceState != null) { restoreInstanceState(savedInstanceState); } else { final Intent intent = activity.getIntent(); final String action = intent.getAction(); final Uri intentUri = intent.getData(); final String scheme = intentUri != null ? intentUri.getScheme() : null; if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && intentUri != null && "sakuracoin".equals(scheme)) initStateFromBitcoinUri(intentUri); else if (intent.hasExtra(SendCoinsActivity.INTENT_EXTRA_ADDRESS)) initStateFromIntentExtras(intent.getExtras()); } return view; }
From source file:net.usecredits.wallet.ui.SendCoinsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.send_coins_fragment, container); receivingAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_coins_receiving_address); receivingAddressView.setAdapter(new AutoCompleteAddressAdapter(activity, null)); receivingAddressView.setOnFocusChangeListener(receivingAddressListener); receivingAddressView.addTextChangedListener(receivingAddressListener); receivingStaticView = view.findViewById(R.id.send_coins_receiving_static); receivingStaticAddressView = (TextView) view.findViewById(R.id.send_coins_receiving_static_address); receivingStaticLabelView = (TextView) view.findViewById(R.id.send_coins_receiving_static_label); receivingStaticView.setOnFocusChangeListener(new OnFocusChangeListener() { private ActionMode actionMode; @Override/*from w w w. java2 s . com*/ public void onFocusChange(final View v, final boolean hasFocus) { if (hasFocus) actionMode = activity.startActionMode(new ReceivingAddressActionMode()); else actionMode.finish(); } }); final CurrencyAmountView btcAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_btc); btcAmountView.setCurrencySymbol(btcShift == 0 ? Constants.CURRENCY_CODE_BTC : Constants.CURRENCY_CODE_MBTC); btcAmountView.setInputPrecision(btcShift == 0 ? Constants.BTC_MAX_PRECISION : Constants.MBTC_MAX_PRECISION); btcAmountView.setHintPrecision(btcPrecision); btcAmountView.setShift(btcShift); final CurrencyAmountView localAmountView = (CurrencyAmountView) view .findViewById(R.id.send_coins_amount_local); localAmountView.setInputPrecision(Constants.LOCAL_PRECISION); localAmountView.setHintPrecision(Constants.LOCAL_PRECISION); amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView); bluetoothEnableView = (CheckBox) view.findViewById(R.id.send_coins_bluetooth_enable); bluetoothEnableView.setChecked(bluetoothAdapter != null && bluetoothAdapter.isEnabled()); bluetoothEnableView.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { if (isChecked && !bluetoothAdapter.isEnabled()) { // try to enable bluetooth startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_CODE_ENABLE_BLUETOOTH); } } }); bluetoothMessageView = (TextView) view.findViewById(R.id.send_coins_bluetooth_message); sentTransactionView = (ListView) view.findViewById(R.id.send_coins_sent_transaction); sentTransactionListAdapter = new TransactionsListAdapter(activity, wallet, application.maxConnectedPeers(), false); sentTransactionView.setAdapter(sentTransactionListAdapter); viewGo = (Button) view.findViewById(R.id.send_coins_go); viewGo.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { validateReceivingAddress(true); validateAmounts(true); if (everythingValid()) handleGo(); } }); viewCancel = (Button) view.findViewById(R.id.send_coins_cancel); viewCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (state == State.INPUT) activity.setResult(Activity.RESULT_CANCELED); activity.finish(); } }); popupMessageView = (TextView) inflater.inflate(R.layout.send_coins_popup_message, container); popupAvailableView = inflater.inflate(R.layout.send_coins_popup_available, container); if (savedInstanceState != null) { restoreInstanceState(savedInstanceState); } else { final Intent intent = activity.getIntent(); final String action = intent.getAction(); final Uri intentUri = intent.getData(); final String scheme = intentUri != null ? intentUri.getScheme() : null; if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && intentUri != null && "bitcoin".equals(scheme)) initStateFromBitcoinUri(intentUri); else if (intent.hasExtra(SendCoinsActivity.INTENT_EXTRA_ADDRESS)) initStateFromIntentExtras(intent.getExtras()); } return view; }
From source file:ja.keystore00.wallet.ui.SendCoinsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.send_coins_fragment, container); receivingAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_coins_receiving_address); receivingAddressView.setAdapter(new AutoCompleteAddressAdapter(activity, null)); receivingAddressView.setOnFocusChangeListener(receivingAddressListener); receivingAddressView.addTextChangedListener(receivingAddressListener); receivingStaticView = view.findViewById(R.id.send_coins_receiving_static); receivingStaticAddressView = (TextView) view.findViewById(R.id.send_coins_receiving_static_address); receivingStaticLabelView = (TextView) view.findViewById(R.id.send_coins_receiving_static_label); receivingStaticView.setOnFocusChangeListener(new OnFocusChangeListener() { private ActionMode actionMode; @Override/*from w ww .ja v a 2 s. c o m*/ public void onFocusChange(final View v, final boolean hasFocus) { if (hasFocus) actionMode = activity.startActionMode(new ReceivingAddressActionMode()); else actionMode.finish(); } }); final CurrencyAmountView btcAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_btc); btcAmountView.setCurrencySymbol(btcShift == 0 ? Constants.CURRENCY_CODE_BTC : Constants.CURRENCY_CODE_MBTC); btcAmountView.setInputPrecision(btcShift == 0 ? Constants.BTC_MAX_PRECISION : Constants.MBTC_MAX_PRECISION); btcAmountView.setHintPrecision(btcPrecision); btcAmountView.setShift(btcShift); final CurrencyAmountView localAmountView = (CurrencyAmountView) view .findViewById(R.id.send_coins_amount_local); localAmountView.setInputPrecision(Constants.LOCAL_PRECISION); localAmountView.setHintPrecision(Constants.LOCAL_PRECISION); amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView); bluetoothEnableView = (CheckBox) view.findViewById(R.id.send_coins_bluetooth_enable); bluetoothEnableView.setChecked(bluetoothAdapter != null && bluetoothAdapter.isEnabled()); bluetoothEnableView.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { if (isChecked && !bluetoothAdapter.isEnabled()) { // try to enable bluetooth startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_CODE_ENABLE_BLUETOOTH); } } }); bluetoothMessageView = (TextView) view.findViewById(R.id.send_coins_bluetooth_message); sentTransactionView = (ListView) view.findViewById(R.id.send_coins_sent_transaction); sentTransactionListAdapter = new TransactionsListAdapter(activity, wallet, application.maxConnectedPeers(), false); sentTransactionView.setAdapter(sentTransactionListAdapter); viewGo = (Button) view.findViewById(R.id.send_coins_go); viewGo.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { validateReceivingAddress(true); validateAmounts(true); if (everythingValid()) handleGo(); } }); viewCancel = (Button) view.findViewById(R.id.send_coins_cancel); viewCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (state == State.INPUT) activity.setResult(Activity.RESULT_CANCELED); activity.finish(); } }); popupMessageView = (TextView) inflater.inflate(R.layout.send_coins_popup_message, container); popupAvailableView = inflater.inflate(R.layout.send_coins_popup_available, container); if (savedInstanceState != null) { restoreInstanceState(savedInstanceState); } else { final Intent intent = activity.getIntent(); final String action = intent.getAction(); final Uri intentUri = intent.getData(); final String scheme = intentUri != null ? intentUri.getScheme() : null; if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && intentUri != null && "monacoin".equals(scheme)) initStateFromBitcoinUri(intentUri); else if (intent.hasExtra(SendCoinsActivity.INTENT_EXTRA_ADDRESS)) initStateFromIntentExtras(intent.getExtras()); } return view; }
From source file:com.amti.vela.bluetoothlegatt.bluetooth.DeviceScanActivity.java
boolean enableBtIfNeeded() { // Ensures Bluetooth is enabled on the device. If Bluetooth is not currently enabled, // fire an intent to display a dialog asking the user to grant permission to enable it. if (!mBluetoothAdapter.isEnabled()) { //we have enableBtFlag so that we know if we already have one of these dialogs showing if (!mBluetoothAdapter.isEnabled() && !enableBtFlag) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); enableBtFlag = true;// w ww . j a v a2 s. c om //checkedBt is for when onResume is called when we get back from the enable bt dialog, the user has //to manually start the bt search checkedBt = true; } } return enableBtFlag; }
From source file:de.schildbach.litecoinwallet.ui.SendCoinsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.send_coins_fragment, container); receivingAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_coins_receiving_address); receivingAddressView.setAdapter(new AutoCompleteAddressAdapter(activity, null)); receivingAddressView.setOnFocusChangeListener(receivingAddressListener); receivingAddressView.addTextChangedListener(receivingAddressListener); receivingStaticView = view.findViewById(R.id.send_coins_receiving_static); receivingStaticAddressView = (TextView) view.findViewById(R.id.send_coins_receiving_static_address); receivingStaticLabelView = (TextView) view.findViewById(R.id.send_coins_receiving_static_label); receivingStaticView.setOnFocusChangeListener(new OnFocusChangeListener() { private ActionMode actionMode; @Override/*from ww w . ja va 2 s.co m*/ public void onFocusChange(final View v, final boolean hasFocus) { if (hasFocus) actionMode = activity.startActionMode(new ReceivingAddressActionMode()); else actionMode.finish(); } }); final CurrencyAmountView btcAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_btc); btcAmountView.setCurrencySymbol(btcShift == 0 ? Constants.CURRENCY_CODE_BTC : Constants.CURRENCY_CODE_MBTC); btcAmountView.setInputPrecision(btcShift == 0 ? Constants.BTC_MAX_PRECISION : Constants.MBTC_MAX_PRECISION); btcAmountView.setHintPrecision(btcPrecision); btcAmountView.setShift(btcShift); final CurrencyAmountView localAmountView = (CurrencyAmountView) view .findViewById(R.id.send_coins_amount_local); localAmountView.setInputPrecision(Constants.LOCAL_PRECISION); localAmountView.setHintPrecision(Constants.LOCAL_PRECISION); amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView); bluetoothEnableView = (CheckBox) view.findViewById(R.id.send_coins_bluetooth_enable); bluetoothEnableView.setChecked(bluetoothAdapter != null && bluetoothAdapter.isEnabled()); bluetoothEnableView.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { if (isChecked && !bluetoothAdapter.isEnabled()) { // try to enable bluetooth startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_CODE_ENABLE_BLUETOOTH); } } }); bluetoothMessageView = (TextView) view.findViewById(R.id.send_coins_bluetooth_message); sentTransactionView = (ListView) view.findViewById(R.id.send_coins_sent_transaction); sentTransactionListAdapter = new TransactionsListAdapter(activity, wallet, application.maxConnectedPeers(), false); sentTransactionView.setAdapter(sentTransactionListAdapter); viewGo = (Button) view.findViewById(R.id.send_coins_go); viewGo.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { validateReceivingAddress(true); validateAmounts(true); if (everythingValid()) handleGo(); } }); viewCancel = (Button) view.findViewById(R.id.send_coins_cancel); viewCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (state == State.INPUT) activity.setResult(Activity.RESULT_CANCELED); activity.finish(); } }); popupMessageView = (TextView) inflater.inflate(R.layout.send_coins_popup_message, container); popupAvailableView = inflater.inflate(R.layout.send_coins_popup_available, container); if (savedInstanceState != null) { restoreInstanceState(savedInstanceState); } else { final Intent intent = activity.getIntent(); final String action = intent.getAction(); final Uri intentUri = intent.getData(); final String scheme = intentUri != null ? intentUri.getScheme() : null; if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && intentUri != null && "litecoin".equals(scheme)) initStateFromBitcoinUri(intentUri); else if (intent.hasExtra(SendCoinsActivity.INTENT_EXTRA_ADDRESS)) initStateFromIntentExtras(intent.getExtras()); } return view; }
From source file:com.mobilinkd.tncconfig.TncConfig.java
@Override public void onStart() { super.onStart(); if (D)//from w w w .ja v a 2 s . c om Log.e(TAG, "++ ON START ++"); // If BT is not on, request that it be enabled. // setupChat() will then be called during onActivityResult if (!mBluetoothAdapter.isEnabled()) { Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); // Otherwise, setup the chat session } else { if (mTncService == null) setupConfig(); } }
From source file:com.hardcopy.retrowatch.RetroWatchActivity.java
/** * Initialization / Finalization//from w ww . j a va2s.co m */ private void initialize() { Logs.d(TAG, "# Activity - initialize()"); mService.setupService(mActivityHandler); // If BT is not on, request that it be enabled. // RetroWatchService.setupBT() will then be called during onActivityResult if (!mService.isBluetoothEnabled()) { Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, Constants.REQUEST_ENABLE_BT); } // Get notifications from NotificationListenerService mService.sendGetAllNotificationsSignal(); // Get filters getFiltersAll(); }
From source file:com.cs4644.vt.theonering.MainActivity.java
private boolean manageBluetoothAvailability() { boolean isEnabled = true; // Check Bluetooth HW status int errorMessageId = 0; final int bleStatus = BleUtils.getBleStatus(getBaseContext()); switch (bleStatus) { case BleUtils.STATUS_BLE_NOT_AVAILABLE: errorMessageId = R.string.dialog_error_no_ble; isEnabled = false;//from w w w .ja v a 2 s . c o m break; case BleUtils.STATUS_BLUETOOTH_NOT_AVAILABLE: { errorMessageId = R.string.dialog_error_no_bluetooth; isEnabled = false; // it was already off break; } case BleUtils.STATUS_BLUETOOTH_DISABLED: { isEnabled = false; // it was already off // if no enabled, launch settings dialog to enable it (user should always be prompted before automatically enabling bluetooth) Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, kActivityRequestCode_EnableBluetooth); // execution will continue at onActivityResult() break; } } if (errorMessageId > 0) { AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog dialog = builder.setMessage(errorMessageId).setPositiveButton(R.string.dialog_ok, null) .show(); DialogUtils.keepDialogOnOrientationChanges(dialog); } return isEnabled; }
From source file:de.schildbach.wallet.ui.SendCoinsFragmentBackup.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.send_coins_fragment, container); payeeNameView = (TextView) view.findViewById(R.id.send_coins_payee_name); payeeOrganizationView = (TextView) view.findViewById(R.id.send_coins_payee_organization); payeeVerifiedByView = (TextView) view.findViewById(R.id.send_coins_payee_verified_by); receivingAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_coins_receiving_address); receivingAddressView.setAdapter(new AutoCompleteAddressAdapter(activity, null)); receivingAddressView.setOnFocusChangeListener(receivingAddressListener); receivingAddressView.addTextChangedListener(receivingAddressListener); receivingStaticView = view.findViewById(R.id.send_coins_receiving_static); receivingStaticAddressView = (TextView) view.findViewById(R.id.send_coins_receiving_static_address); receivingStaticLabelView = (TextView) view.findViewById(R.id.send_coins_receiving_static_label); receivingStaticView.setOnFocusChangeListener(new OnFocusChangeListener() { private ActionMode actionMode; @Override//from w w w .j av a 2s . co m public void onFocusChange(final View v, final boolean hasFocus) { if (hasFocus) { final Address address = paymentIntent.hasAddress() ? paymentIntent.getAddress() : (validatedAddress != null ? validatedAddress.address : null); if (address != null) actionMode = activity.startActionMode(new ReceivingAddressActionMode(address)); } else { actionMode.finish(); } } }); final CurrencyAmountView btcAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_btc); btcAmountView.setCurrencySymbol(config.getBtcPrefix()); btcAmountView.setInputPrecision(config.getBtcMaxPrecision()); btcAmountView.setHintPrecision(config.getBtcPrecision()); btcAmountView.setShift(config.getBtcShift()); final CurrencyAmountView localAmountView = (CurrencyAmountView) view .findViewById(R.id.send_coins_amount_local); localAmountView.setInputPrecision(Constants.LOCAL_PRECISION); localAmountView.setHintPrecision(Constants.LOCAL_PRECISION); amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView); amountCalculatorLink.setExchangeDirection(config.getLastExchangeDirection()); directPaymentEnableView = (CheckBox) view.findViewById(R.id.send_coins_direct_payment_enable); directPaymentEnableView.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { if (paymentIntent.isBluetoothPaymentUrl() && isChecked && !bluetoothAdapter.isEnabled()) { // ask for permission to enable bluetooth startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_CODE_ENABLE_BLUETOOTH); } } }); directPaymentMessageView = (TextView) view.findViewById(R.id.send_coins_direct_payment_message); sentTransactionView = (ListView) view.findViewById(R.id.send_coins_sent_transaction); sentTransactionListAdapter = new TransactionsListAdapter(activity, wallet, application.maxConnectedPeers(), false); sentTransactionView.setAdapter(sentTransactionListAdapter); viewGo = (Button) view.findViewById(R.id.send_coins_go); viewGo.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { validateReceivingAddress(true); isAmountValid(); if (everythingValid()) handleGo(); else requestFocusFirst(); } }); amountCalculatorLink.setNextFocusId(viewGo.getId()); viewCancel = (Button) view.findViewById(R.id.send_coins_cancel); viewCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (state == State.INPUT) activity.setResult(Activity.RESULT_CANCELED); activity.finish(); } }); popupMessageView = (TextView) inflater.inflate(R.layout.send_coins_popup_message, container); if (savedInstanceState != null) { restoreInstanceState(savedInstanceState); } else { final Intent intent = activity.getIntent(); final String action = intent.getAction(); final Uri intentUri = intent.getData(); final String scheme = intentUri != null ? intentUri.getScheme() : null; final String mimeType = intent.getType(); if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && intentUri != null && "bitcoin".equals(scheme)) { initStateFromBitcoinUri(intentUri); } else if ((NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && PaymentProtocol.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) { final NdefMessage ndefMessage = (NdefMessage) intent .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)[0]; final byte[] ndefMessagePayload = Nfc.extractMimePayload(PaymentProtocol.MIMETYPE_PAYMENTREQUEST, ndefMessage); initStateFromPaymentRequest(mimeType, ndefMessagePayload); } else if ((Intent.ACTION_VIEW.equals(action)) && PaymentProtocol.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) { final byte[] paymentRequest = BitcoinIntegration.paymentRequestFromIntent(intent); if (intentUri != null) initStateFromIntentUri(mimeType, intentUri); else if (paymentRequest != null) initStateFromPaymentRequest(mimeType, paymentRequest); else throw new IllegalArgumentException(); } else if (intent.hasExtra(SendCoinsActivity.INTENT_EXTRA_PAYMENT_INTENT)) { initStateFromIntentExtras(intent.getExtras()); } else { updateStateFrom(PaymentIntent.blank()); } } return view; }
From source file:com.guldencoin.androidwallet.nlg.ui.SendCoinsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.send_coins_fragment, container); payeeNameView = (TextView) view.findViewById(R.id.send_coins_payee_name); payeeOrganizationView = (TextView) view.findViewById(R.id.send_coins_payee_organization); payeeVerifiedByView = (TextView) view.findViewById(R.id.send_coins_payee_verified_by); receivingAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_coins_receiving_address); receivingAddressView.setAdapter(new AutoCompleteAddressAdapter(activity, null)); receivingAddressView.setOnFocusChangeListener(receivingAddressListener); receivingAddressView.addTextChangedListener(receivingAddressListener); receivingStaticView = view.findViewById(R.id.send_coins_receiving_static); receivingStaticAddressView = (TextView) view.findViewById(R.id.send_coins_receiving_static_address); receivingStaticLabelView = (TextView) view.findViewById(R.id.send_coins_receiving_static_label); receivingStaticView.setOnFocusChangeListener(new OnFocusChangeListener() { private ActionMode actionMode; @Override//from w w w . j ava 2s . co m public void onFocusChange(final View v, final boolean hasFocus) { if (hasFocus) { final Address address = paymentIntent.hasAddress() ? paymentIntent.getAddress() : (validatedAddress != null ? validatedAddress.address : null); if (address != null) actionMode = activity.startActionMode(new ReceivingAddressActionMode(address)); } else { actionMode.finish(); } } }); final CurrencyAmountView btcAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_btc); btcAmountView.setCurrencySymbol(config.getBtcPrefix()); btcAmountView.setInputPrecision(config.getBtcMaxPrecision()); btcAmountView.setHintPrecision(config.getBtcPrecision()); btcAmountView.setShift(config.getBtcShift()); final CurrencyAmountView localAmountView = (CurrencyAmountView) view .findViewById(R.id.send_coins_amount_local); localAmountView.setInputPrecision(Constants.LOCAL_PRECISION); localAmountView.setHintPrecision(Constants.LOCAL_PRECISION); amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView); amountCalculatorLink.setExchangeDirection(config.getLastExchangeDirection()); directPaymentEnableView = (CheckBox) view.findViewById(R.id.send_coins_direct_payment_enable); directPaymentEnableView.setChecked(bluetoothAdapter != null && bluetoothAdapter.isEnabled()); directPaymentEnableView.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { if (isChecked && !bluetoothAdapter.isEnabled()) { // try to enable bluetooth startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_CODE_ENABLE_BLUETOOTH); } } }); directPaymentMessageView = (TextView) view.findViewById(R.id.send_coins_direct_payment_message); sentTransactionView = (ListView) view.findViewById(R.id.send_coins_sent_transaction); sentTransactionListAdapter = new TransactionsListAdapter(activity, wallet, application.maxConnectedPeers(), false); sentTransactionView.setAdapter(sentTransactionListAdapter); viewGo = (Button) view.findViewById(R.id.send_coins_go); viewGo.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { validateReceivingAddress(true); isAmountValid(); if (everythingValid()) handleGo(); else requestFocusFirst(); } }); amountCalculatorLink.setNextFocusId(viewGo.getId()); viewCancel = (Button) view.findViewById(R.id.send_coins_cancel); viewCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (state == State.INPUT) activity.setResult(Activity.RESULT_CANCELED); activity.finish(); } }); popupMessageView = (TextView) inflater.inflate(R.layout.send_coins_popup_message, container); if (savedInstanceState != null) { restoreInstanceState(savedInstanceState); } else { final Intent intent = activity.getIntent(); final String action = intent.getAction(); final Uri intentUri = intent.getData(); final String scheme = intentUri != null ? intentUri.getScheme() : null; final String mimeType = intent.getType(); if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && intentUri != null && "bitcoin".equals(scheme)) { initStateFromBitcoinUri(intentUri); } else if ((NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && Constants.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) { final NdefMessage ndefMessage = (NdefMessage) intent .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)[0]; final byte[] ndefMessagePayload = Nfc.extractMimePayload(Constants.MIMETYPE_PAYMENTREQUEST, ndefMessage); initStateFromPaymentRequest(mimeType, ndefMessagePayload); } else if ((Intent.ACTION_VIEW.equals(action)) && intentUri != null && Constants.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) { initStateFromIntentUri(mimeType, intentUri); } else if (intent.hasExtra(SendCoinsActivity.INTENT_EXTRA_PAYMENT_INTENT)) { initStateFromIntentExtras(intent.getExtras()); } else { updateStateFrom(PaymentIntent.blank()); } } return view; }