Search in sources :

Example 1 with NewRepoConfig

use of org.fdroid.fdroid.data.NewRepoConfig in project fdroidclient by f-droid.

the class SwapWorkflowActivity method checkIncomingIntent.

private void checkIncomingIntent() {
    Intent intent = getIntent();
    if (intent.getBooleanExtra(EXTRA_CONFIRM, false) && !intent.getBooleanExtra(EXTRA_SWAP_INTENT_HANDLED, false)) {
        // Storing config in this variable will ensure that when showRelevantView() is next
        // run, it will show the connect swap view (if the service is available).
        intent.putExtra(EXTRA_SWAP_INTENT_HANDLED, true);
        confirmSwapConfig = new NewRepoConfig(this, intent);
    }
}
Also used : NewRepoConfig(org.fdroid.fdroid.data.NewRepoConfig) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Example 2 with NewRepoConfig

use of org.fdroid.fdroid.data.NewRepoConfig in project fdroidclient by f-droid.

the class SwapWorkflowActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
    if (scanResult != null) {
        if (scanResult.getContents() != null) {
            NewRepoConfig repoConfig = new NewRepoConfig(this, scanResult.getContents());
            if (repoConfig.isValidRepo()) {
                confirmSwapConfig = repoConfig;
                showRelevantView();
            } else {
                Toast.makeText(this, R.string.swap_qr_isnt_for_swap, Toast.LENGTH_SHORT).show();
            }
        }
    } else if (requestCode == CONNECT_TO_SWAP && resultCode == Activity.RESULT_OK) {
        finish();
    } else if (requestCode == REQUEST_BLUETOOTH_ENABLE_FOR_SWAP) {
        if (resultCode == RESULT_OK) {
            Utils.debugLog(TAG, "User enabled Bluetooth, will make sure we are discoverable.");
            ensureBluetoothDiscoverableThenStart();
        } else {
            // Didn't enable bluetooth
            Utils.debugLog(TAG, "User chose not to enable Bluetooth, so doing nothing (i.e. sticking with wifi).");
        }
    } else if (requestCode == REQUEST_BLUETOOTH_DISCOVERABLE) {
        if (resultCode != RESULT_CANCELED) {
            Utils.debugLog(TAG, "User made Bluetooth discoverable, will proceed to start bluetooth server.");
            getState().getBluetoothSwap().startInBackground();
        } else {
            Utils.debugLog(TAG, "User chose not to make Bluetooth discoverable, so doing nothing (i.e. sticking with wifi).");
        }
    } else if (requestCode == REQUEST_BLUETOOTH_ENABLE_FOR_SEND) {
        sendFDroidApk();
    }
}
Also used : IntentResult(com.google.zxing.integration.android.IntentResult) NewRepoConfig(org.fdroid.fdroid.data.NewRepoConfig)

Example 3 with NewRepoConfig

use of org.fdroid.fdroid.data.NewRepoConfig in project fdroidclient by f-droid.

the class MainActivity method checkForAddRepoIntent.

private void checkForAddRepoIntent(Intent intent) {
    // http://stackoverflow.com/a/14820849
    if (!intent.hasExtra(ADD_REPO_INTENT_HANDLED)) {
        intent.putExtra(ADD_REPO_INTENT_HANDLED, true);
        NewRepoConfig parser = new NewRepoConfig(this, intent);
        if (parser.isValidRepo()) {
            if (parser.isFromSwap()) {
                SwapWorkflowActivity.requestSwap(this, intent.getData());
            } else {
                Intent clean = new Intent(ACTION_ADD_REPO, intent.getData(), this, ManageReposActivity.class);
                if (intent.hasExtra(ManageReposActivity.EXTRA_FINISH_AFTER_ADDING_REPO)) {
                    clean.putExtra(ManageReposActivity.EXTRA_FINISH_AFTER_ADDING_REPO, intent.getBooleanExtra(ManageReposActivity.EXTRA_FINISH_AFTER_ADDING_REPO, true));
                }
                startActivity(clean);
            }
            finish();
        } else if (parser.getErrorMessage() != null) {
            Toast.makeText(this, parser.getErrorMessage(), Toast.LENGTH_LONG).show();
            finish();
        }
    }
}
Also used : NewRepoConfig(org.fdroid.fdroid.data.NewRepoConfig) Intent(android.content.Intent)

Example 4 with NewRepoConfig

use of org.fdroid.fdroid.data.NewRepoConfig in project fdroidclient by f-droid.

the class SwapWorkflowActivity method checkIncomingIntent.

/**
 * Check whether incoming {@link Intent} is a swap repo, and ensure that
 * it is a valid swap URL.  The hostname can only be either an IP or
 * Bluetooth address.
 */
private void checkIncomingIntent() {
    Intent intent = getIntent();
    if (!ACTION_REQUEST_SWAP.equals(intent.getAction())) {
        return;
    }
    Uri uri = intent.getData();
    if (uri != null && !HttpDownloader.isSwapUrl(uri) && !BluetoothDownloader.isBluetoothUri(uri)) {
        String msg = getString(R.string.swap_toast_invalid_url, uri);
        Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
        return;
    }
    confirmSwapConfig = new NewRepoConfig(this, intent);
}
Also used : NewRepoConfig(org.fdroid.fdroid.data.NewRepoConfig) Intent(android.content.Intent) Uri(android.net.Uri)

Example 5 with NewRepoConfig

use of org.fdroid.fdroid.data.NewRepoConfig in project fdroidclient by f-droid.

the class SwapWorkflowActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
    if (scanResult != null) {
        if (scanResult.getContents() != null) {
            NewRepoConfig repoConfig = new NewRepoConfig(this, scanResult.getContents());
            if (repoConfig.isValidRepo()) {
                confirmSwapConfig = repoConfig;
                showRelevantView();
            } else {
                Toast.makeText(this, R.string.swap_qr_isnt_for_swap, Toast.LENGTH_SHORT).show();
            }
        }
    } else if (requestCode == REQUEST_WRITE_SETTINGS_PERMISSION) {
        if (Build.VERSION.SDK_INT >= 23 && Settings.System.canWrite(this)) {
            setupWifiAP();
        }
    } else if (requestCode == REQUEST_BLUETOOTH_ENABLE_FOR_SWAP) {
        if (resultCode == RESULT_OK) {
            Utils.debugLog(TAG, "User enabled Bluetooth, will make sure we are discoverable.");
            ensureBluetoothDiscoverableThenStart();
        } else {
            Utils.debugLog(TAG, "User chose not to enable Bluetooth, so doing nothing");
            SwapService.putBluetoothVisibleUserPreference(false);
        }
    } else if (requestCode == REQUEST_BLUETOOTH_DISCOVERABLE) {
        if (resultCode != RESULT_CANCELED) {
            Utils.debugLog(TAG, "User made Bluetooth discoverable, will proceed to start bluetooth server.");
            BluetoothManager.start(this);
        } else {
            Utils.debugLog(TAG, "User chose not to make Bluetooth discoverable, so doing nothing");
            SwapService.putBluetoothVisibleUserPreference(false);
        }
    } else if (requestCode == REQUEST_BLUETOOTH_ENABLE_FOR_SEND) {
        sendFDroidApk();
    }
}
Also used : IntentResult(com.google.zxing.integration.android.IntentResult) NewRepoConfig(org.fdroid.fdroid.data.NewRepoConfig)

Aggregations

NewRepoConfig (org.fdroid.fdroid.data.NewRepoConfig)7 Intent (android.content.Intent)3 IntentResult (com.google.zxing.integration.android.IntentResult)2 PendingIntent (android.app.PendingIntent)1 Uri (android.net.Uri)1 View (android.view.View)1 Button (android.widget.Button)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 SearchView (androidx.appcompat.widget.SearchView)1 MaterialButton (com.google.android.material.button.MaterialButton)1