public UpdateAsyncTask(Context c, @NonNull Set<String> apps) { selectedApps = apps; progressDialog = new ProgressDialog(c); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setTitle(R.string.updating); sharingUri = Utils.getSharingUri(FDroidApp.repo); }
@TargetApi(14) private void setUIFromWifi() { if (TextUtils.isEmpty(FDroidApp.repo.address)) return; // the fingerprint is not useful on the button label String buttonLabel = FDroidApp.repo.address.replaceAll("\\?.*$", ""); TextView sharingUriTextView = (TextView) findViewById(R.id.sharing_uri); sharingUriTextView.setText(buttonLabel); /* * Set URL to UPPER for compact QR Code, FDroid will translate it back. * Remove the SSID from the query string since SSIDs are case-sensitive. * Instead the receiver will have to rely on the BSSID to find the right * wifi AP to join. Lots of QR Scanners are buggy and do not respect * custom URI schemes, so we have to use http:// or https:// :-( */ final String qrUriString = Utils.getSharingUri(this, FDroidApp.repo) .toString() .replaceFirst("fdroidrepo", "http") .replaceAll("ssid=[^?]*", "") .toUpperCase(Locale.ENGLISH); Log.i("QRURI", qrUriString); if (Build.VERSION.SDK_INT >= 8) // zxing requires >= 8 new QrGenAsyncTask(this, R.id.repoQrCode).execute(qrUriString); TextView wifiNetworkNameTextView = (TextView) findViewById(R.id.wifi_network); wifiNetworkNameTextView.setText(FDroidApp.ssid); TextView fingerprintTextView = (TextView) findViewById(R.id.fingerprint); if (FDroidApp.repo.fingerprint != null) { fingerprintTextView.setVisibility(View.VISIBLE); fingerprintTextView.setText(FDroidApp.repo.fingerprint); } else { fingerprintTextView.setVisibility(View.GONE); } // the required NFC API was added in 4.0 aka Ice Cream Sandwich if (Build.VERSION.SDK_INT >= 14) { NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (nfcAdapter == null) return; nfcAdapter.setNdefPushMessage( new NdefMessage( new NdefRecord[] { NdefRecord.createUri(Utils.getSharingUri(this, FDroidApp.repo)), }), this); } }
private boolean attemptToShowNfc() { // TODO: What if NFC is disabled? Hook up with NfcNotEnabledActivity? Or maybe only if they // click a relevant button? // Even if they opted to skip the message which says "Touch devices to swap", // we still want to actually enable the feature, so that they could touch // during the wifi qr code being shown too. boolean nfcMessageReady = NfcHelper.setPushMessage(this, Utils.getSharingUri(FDroidApp.repo)); if (Preferences.get().showNfcDuringSwap() && nfcMessageReady) { showFragment(new NfcSwapFragment(), STATE_NFC); return true; } return false; }