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);
}
}
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();
}
}
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();
}
}
}
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);
}
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();
}
}
Aggregations