Java Code Examples for android.support.v4.app.DialogFragment#setCancelable()

The following examples show how to use android.support.v4.app.DialogFragment#setCancelable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasePurchaseActivity.java    From aptoide-client with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onClick(int payType, String imsi,  String price, String currency) {
    DialogFragment df = new ProgressDialogFragment();

    df.setCancelable(false);
    df.show(getSupportFragmentManager(), "pleaseWaitDialog");
    PayProductRequestUnitel requestUnitel = new PayProductRequestUnitel();
    requestUnitel.setProductId(String.valueOf(aptoideProductId));
    requestUnitel.setPayType(String.valueOf(payType));
    requestUnitel.setToken(token);
    requestUnitel.setImsi(imsi);
    requestUnitel.setPrice(price);
    requestUnitel.setCurrency(currency);
    requestUnitel.setRepo(repo);
    requestsetExtra(requestUnitel);
    requestUnitel.setRetryPolicy(noRetryPolicy);
    spiceManager.execute(requestUnitel, new PurchaseRequestListener());

}
 
Example 2
Source File: IABPurchaseActivity.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void processPaymentConfirmation(final ProofOfPayment confirmation) {
    final BasePurchaseStatusRequest purchaseStatus = BuildPurchaseStatusRequest(confirmation);

    purchaseStatus.setDeveloperPayload(developerPayload);
    purchaseStatus.setApiVersion(String.valueOf(apiVersion));

    DialogFragment df = new ProgressDialogFragment();
    df.show(getSupportFragmentManager(), "pleaseWaitDialog");
    df.setCancelable(false);

    spiceManager.execute(purchaseStatus, new PurchaseRequestListener() {
        @Override
        public void onRequestFailure(SpiceException spiceException) {
            AlarmManager manager = (AlarmManager) getSystemService(ALARM_SERVICE);
            Toast.makeText(Aptoide.getContext(), R.string.error_occured_retry_later, Toast.LENGTH_LONG).show();

            Intent i = buildIntentForAlarm(confirmation, "iab");
            i.putExtra("apiVersion", apiVersion);
            i.putExtra("developerPayload", developerPayload);

            PendingIntent intent = PendingIntent.getBroadcast(getApplicationContext(), 1, i, PendingIntent.FLAG_UPDATE_CURRENT);
            manager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, 60000, 60000, intent);

            dismissAllowingStateLoss();
        }
    });
}
 
Example 3
Source File: BasePurchaseActivity.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onClick(View view) {
    valuesToVerify = new ValuesToVerify();
    valuesToVerify.currency = this.currency;
    valuesToVerify.price = this.price;
    valuesToVerify.tax = this.tax;
    valuesToVerify.repo = repo;
    if (alreadyRegistered) {
        final String correlationId = PayPalConfiguration.getApplicationCorrelationId(BasePurchaseActivity.this);
        PayProductRequestPayPal request = new PayProductRequestPayPal();
        request.setToken(token);
        request.setRepo(repo);
        request.setProductId(productId);
        request.setPrice(String.valueOf(price));
        request.setCurrency(currency);
        if(simcc!=null && simcc.length()>0){
            request.setSimCountryCode(simcc);
        }
        request.setCorrelationId(correlationId);
        request.setRetryPolicy(noRetryPolicy);
        requestsetExtra(request);

        DialogFragment df = new ProgressDialogFragment();
        df.show(getSupportFragmentManager(), "pleaseWaitDialog");
        df.setCancelable(false);
        spiceManager.execute(request, new PurchaseRequestListener());
    } else {
        Intent ppIntent = new Intent(BasePurchaseActivity.this, PayPalFuturePaymentActivity.class);
        startActivityForResult(ppIntent, REQUEST_CODE_FUTURE_PAYMENT);
        spiceManager.removeDataFromCache(IabSimpleResponseJson.class, "authorization-" + token);
    }
}
 
Example 4
Source File: SplashActivity.java    From mangosta-android with Apache License 2.0 5 votes vote down vote up
private void createLoginDialog() {
    if (!isFinishing() && !isDestroyed()) {
        DialogFragment fragment = LoginDialogFragment.newInstance();
        fragment.setCancelable(false);
        fragment.setStyle(DialogFragment.STYLE_NO_TITLE, 0);

        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.add(fragment, getString(R.string.title_login));
        fragmentTransaction.commitAllowingStateLoss();
    }
}
 
Example 5
Source File: AddPrinterActivity.java    From octoandroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void showQrDialogFragment() {
    if (PlayServiceChecker.isAvailable(this) && doesRearCameraExist()) {
        DialogFragment df = QrDialogFragment.newInstance();
        df.setCancelable(true);
        df.show(getSupportFragmentManager(), null);
    }
}
 
Example 6
Source File: CustomCommandActivity.java    From rpicheck with MIT License 5 votes vote down vote up
private void runCommand(long commandId) {
    this.commandId = commandId;
    ConnectivityManager connMgr = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    if (networkInfo != null && networkInfo.isConnected()) {
        if (currentDevice.usesAuthentificationMethod(RaspberryDeviceBean.AUTH_PUBLIC_KEY)
                || currentDevice.usesAuthentificationMethod(RaspberryDeviceBean.AUTH_PUBLIC_KEY_WITH_PASSWORD)) {
            // need permission to read keyfile
            final String keyfilePath = currentDevice.getKeyfilePath();
            if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                LOGGER.debug("Requesting permission to read private key file from storage...");
                ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                        REQUEST_READ_PERMISSION_FOR_COMMAND);
                return;
            }
            if (currentDevice.usesAuthentificationMethod(RaspberryDeviceBean.AUTH_PUBLIC_KEY_WITH_PASSWORD)
                    && Strings.isNullOrEmpty(currentDevice.getKeyfilePass())) {
                // must ask for key passphrase first
                LOGGER.debug("Asking for key passphrase.");
                // dirty hack, saving commandId as "dialog type"
                final String dialogType = commandId + "";
                final DialogFragment passphraseDialog = new PassphraseDialog();
                final Bundle args = new Bundle();
                args.putString(PassphraseDialog.KEY_TYPE, dialogType);
                passphraseDialog.setArguments(args);
                passphraseDialog.setCancelable(false);
                passphraseDialog.show(getSupportFragmentManager(), "passphrase");
                return;
            }
        }
        LOGGER.debug("Opening command dialog.");
        openCommandDialog(commandId, currentDevice.getKeyfilePass());
    } else {
        Toast.makeText(this, R.string.no_connection, Toast.LENGTH_SHORT).show();
    }
}
 
Example 7
Source File: MainActivity.java    From rpicheck with MIT License 4 votes vote down vote up
private void doRebootOrHalt(String type) {
    LOGGER.info("Doing {} on {}...", type, currentDevice.getName());
    if (isNetworkAvailable()) {
        // get connection settings from shared preferences
        final String host = currentDevice.getHost();
        final String user = currentDevice.getUser();
        final String port = currentDevice.getPort() + "";
        final String sudoPass = currentDevice.getSudoPass();
        if (currentDevice.usesAuthentificationMethod(RaspberryDeviceBean.AUTH_PASSWORD)) {
            final String pass = currentDevice.getPass();
            if (pass != null) {
                new SSHShutdownTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, host, user, pass, port, sudoPass, type, null, null);
            } else {
                Toast.makeText(this, R.string.no_password_specified, Toast.LENGTH_LONG).show();
            }
        } else if (currentDevice.usesAuthentificationMethod(RaspberryDeviceBean.AUTH_PUBLIC_KEY) || currentDevice.usesAuthentificationMethod(RaspberryDeviceBean.AUTH_PUBLIC_KEY_WITH_PASSWORD)) {
            // keyfile must be present and readable
            final String keyfilePath = currentDevice.getKeyfilePath();
            if (keyfilePath != null) {
                if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    LOGGER.debug("Requesting permission to read private key file from storage...");
                    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                            type.equals(Constants.TYPE_HALT) ? REQUEST_PERMISSION_READ_FOR_HALT : REQUEST_PERMISSION_READ_FOR_REBOOT);
                    return;
                } else {
                    final File privateKey = new File(keyfilePath);
                    if (privateKey.exists()) {
                        new SSHShutdownTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, host, user, null, port, sudoPass, type, keyfilePath, null);
                    } else {
                        Toast.makeText(this, "Cannot find keyfile at location: " + keyfilePath, Toast.LENGTH_LONG).show();
                    }
                }
            } else {
                Toast.makeText(this, "No keyfile specified!", Toast.LENGTH_LONG).show();
            }
            if (currentDevice.usesAuthentificationMethod(RaspberryDeviceBean.AUTH_PUBLIC_KEY_WITH_PASSWORD)) {
                if (!Strings.isNullOrEmpty(currentDevice.getKeyfilePass())) {
                    final String passphrase = currentDevice.getKeyfilePass();
                    new SSHShutdownTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, host, user, null, port, sudoPass, type, keyfilePath, passphrase);
                } else {
                    final String dialogType = type.equals(Constants.TYPE_REBOOT) ? PassphraseDialog.SSH_SHUTDOWN : PassphraseDialog.SSH_HALT;
                    final DialogFragment passphraseDialog = new PassphraseDialog();
                    final Bundle args = new Bundle();
                    args.putString(PassphraseDialog.KEY_TYPE, dialogType);
                    passphraseDialog.setArguments(args);
                    passphraseDialog.setCancelable(false);
                    passphraseDialog.show(getSupportFragmentManager(), "passphrase");
                }
            }
        }
    } else {
        // no network available
        Toast.makeText(this, R.string.no_connection, Toast.LENGTH_SHORT).show();
    }
}
 
Example 8
Source File: MainActivity.java    From rpicheck with MIT License 4 votes vote down vote up
private void doQuery(boolean initByPullToRefresh) {
    if (currentDevice == null) {
        // no device available, show hint for user
        Toast.makeText(this, R.string.no_device_available, Toast.LENGTH_LONG).show();
        // stop refresh animation from pull-to-refresh
        swipeRefreshLayout.setRefreshing(false);
        return;
    }
    if (isNetworkAvailable()) {
        // get connection settings from shared preferences
        String host = currentDevice.getHost();
        String user = currentDevice.getUser();
        String port = currentDevice.getPort() + "";
        String pass = null;
        // reading process preference
        final Boolean hideRoot = sharedPrefs.getBoolean(SettingsActivity.KEY_PREF_QUERY_HIDE_ROOT_PROCESSES, true);
        String keyPath = null;
        String keyPass = null;
        boolean canConnect = false;
        // check authentification method
        if (currentDevice.usesAuthentificationMethod(RaspberryDeviceBean.AUTH_PASSWORD)) {
            pass = currentDevice.getPass();
            if (pass != null) {
                canConnect = true;
            } else {
                Toast.makeText(this, R.string.no_password_specified, Toast.LENGTH_LONG).show();
            }
        } else if (currentDevice.usesAuthentificationMethod(RaspberryDeviceBean.AUTH_PUBLIC_KEY) ||
                currentDevice.usesAuthentificationMethod(RaspberryDeviceBean.AUTH_PUBLIC_KEY_WITH_PASSWORD)) {
            // keyfile must be present and readable
            final String keyfilePath = currentDevice.getKeyfilePath();
            if (keyfilePath != null) {
                if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    LOGGER.debug("Requesting permission to read private key file from storage...");
                    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                            initByPullToRefresh ? REQUEST_PERMISSION_READ_FOR_QUERY_PULL : REQUEST_PERMISSION_READ_FOR_QUERY_NO_PULL);
                    return;
                } else {
                    final File privateKey = new File(keyfilePath);
                    if (privateKey.exists()) {
                        keyPath = keyfilePath;
                        canConnect = true;
                    } else {
                        Toast.makeText(this, "Cannot find keyfile at location: " + keyfilePath, Toast.LENGTH_LONG).show();
                    }
                }
            } else {
                Toast.makeText(this, "No keyfile specified!", Toast.LENGTH_LONG).show();
            }
            if (currentDevice.usesAuthentificationMethod(RaspberryDeviceBean.AUTH_PUBLIC_KEY_WITH_PASSWORD)) {
                // keypass must be present
                final String keyfilePass = currentDevice.getKeyfilePass();
                if (keyfilePass != null) {
                    canConnect = true;
                    keyPass = keyfilePass;
                } else {
                    final DialogFragment newFragment = new PassphraseDialog();
                    final Bundle args = new Bundle();
                    args.putString(PassphraseDialog.KEY_TYPE, PassphraseDialog.SSH_QUERY);
                    newFragment.setArguments(args);
                    newFragment.setCancelable(false);
                    newFragment.show(getSupportFragmentManager(), "passphrase");
                    canConnect = false;
                }
            }
        }
        if (canConnect) {
            if (!initByPullToRefresh) {
                // show hint that user can use pull-to-refresh
                showPullToRefreshHint();
            }
            // execute query in background
            new SSHQueryTask(this, getLoadAveragePreference()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, host, user, pass, port, hideRoot.toString(), keyPath, keyPass);
        }
    } else {
        // no network available
        Toast.makeText(this, R.string.no_connection, Toast.LENGTH_SHORT).show();
        // stop refresh animation from pull-to-refresh
        swipeRefreshLayout.setRefreshing(false);
    }
}