Search in sources :

Example 1 with Toast

use of de.schildbach.wallet.util.Toast in project bitcoin-wallet by bitcoin-wallet.

the class AcceptBluetoothService method onCreate.

@Override
public void onCreate() {
    serviceCreatedAt = System.currentTimeMillis();
    log.debug(".onCreate()");
    super.onCreate();
    this.application = (WalletApplication) getApplication();
    this.wallet = application.getWallet();
    final BluetoothAdapter bluetoothAdapter = checkNotNull(BluetoothAdapter.getDefaultAdapter());
    final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
    wakeLock.acquire();
    registerReceiver(bluetoothStateChangeReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
    try {
        classicThread = new AcceptBluetoothThread.ClassicBluetoothThread(bluetoothAdapter) {

            @Override
            public boolean handleTx(final Transaction tx) {
                return AcceptBluetoothService.this.handleTx(tx);
            }
        };
        paymentProtocolThread = new AcceptBluetoothThread.PaymentProtocolThread(bluetoothAdapter) {

            @Override
            public boolean handleTx(final Transaction tx) {
                return AcceptBluetoothService.this.handleTx(tx);
            }
        };
        classicThread.start();
        paymentProtocolThread.start();
    } catch (final IOException x) {
        new Toast(this).longToast(R.string.error_bluetooth, x.getMessage());
        CrashReporter.saveBackgroundTrace(x, application.packageInfo());
    }
}
Also used : PowerManager(android.os.PowerManager) IntentFilter(android.content.IntentFilter) Transaction(org.bitcoinj.core.Transaction) Toast(de.schildbach.wallet.util.Toast) IOException(java.io.IOException) BluetoothAdapter(android.bluetooth.BluetoothAdapter)

Example 2 with Toast

use of de.schildbach.wallet.util.Toast in project bitcoin-wallet by bitcoin-wallet.

the class RequestCoinsFragment method handleLocalApp.

private void handleLocalApp() {
    final ComponentName component = new ComponentName(activity, SendCoinsActivity.class);
    final PackageManager pm = activity.getPackageManager();
    final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(determineBitcoinRequestStr(false)));
    try {
        // launch intent chooser with ourselves excluded
        pm.setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
        startActivity(intent);
    } catch (final ActivityNotFoundException x) {
        new Toast(activity).longToast(R.string.request_coins_no_local_app_msg);
    } finally {
        pm.setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
    }
    activity.finish();
}
Also used : PackageManager(android.content.pm.PackageManager) Toast(de.schildbach.wallet.util.Toast) ActivityNotFoundException(android.content.ActivityNotFoundException) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 3 with Toast

use of de.schildbach.wallet.util.Toast in project bitcoin-wallet by bitcoin-wallet.

the class RequestCoinsFragment method handleCopy.

private void handleCopy() {
    final Uri request = Uri.parse(determineBitcoinRequestStr(false));
    clipboardManager.setPrimaryClip(ClipData.newRawUri("Bitcoin payment request", request));
    log.info("payment request copied to clipboard: {}", request);
    new Toast(activity).toast(R.string.request_coins_clipboard_msg);
}
Also used : Toast(de.schildbach.wallet.util.Toast) Uri(android.net.Uri)

Example 4 with Toast

use of de.schildbach.wallet.util.Toast in project bitcoin-wallet by bitcoin-wallet.

the class SendingAddressesFragment method handleCopyToClipboard.

private void handleCopyToClipboard(final String address) {
    clipboardManager.setPrimaryClip(ClipData.newPlainText("Bitcoin address", address));
    log.info("sending address copied to clipboard: {}", address.toString());
    new Toast(activity).toast(R.string.wallet_address_fragment_clipboard_msg);
}
Also used : Toast(de.schildbach.wallet.util.Toast)

Aggregations

Toast (de.schildbach.wallet.util.Toast)4 BluetoothAdapter (android.bluetooth.BluetoothAdapter)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 PackageManager (android.content.pm.PackageManager)1 Uri (android.net.Uri)1 PowerManager (android.os.PowerManager)1 IOException (java.io.IOException)1 Transaction (org.bitcoinj.core.Transaction)1