Remove dead NFC (Android Beam) code
This commit is contained in:
parent
6ffb3fe7e3
commit
3d114cd85f
|
@ -29,7 +29,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
@ -56,7 +55,6 @@ import com.google.zxing.integration.android.IntentResult;
|
|||
|
||||
import org.fdroid.fdroid.BuildConfig;
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.NfcHelper;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
|
@ -211,8 +209,6 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
|||
nextStep = R.layout.swap_select_apps;
|
||||
} else if (currentView.getLayoutResId() == R.layout.swap_join_wifi) {
|
||||
nextStep = R.layout.swap_start_swap;
|
||||
} else if (currentView.getLayoutResId() == R.layout.swap_nfc) {
|
||||
nextStep = R.layout.swap_join_wifi;
|
||||
} else if (currentView.getLayoutResId() == R.layout.swap_select_apps) {
|
||||
if (!backstack.isEmpty() && backstack.peek() == R.layout.swap_start_swap) {
|
||||
nextStep = R.layout.swap_start_swap;
|
||||
|
@ -309,10 +305,6 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
|||
menuInflater.inflate(R.menu.swap_next, menu);
|
||||
setUpNextButton(menu, R.string.next, R.drawable.ic_arrow_forward);
|
||||
return true;
|
||||
} else if (currentView.getLayoutResId() == R.layout.swap_nfc) {
|
||||
menuInflater.inflate(R.menu.swap_next, menu);
|
||||
setUpNextButton(menu, R.string.skip, R.drawable.ic_arrow_forward);
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
|
@ -342,8 +334,6 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
|||
onAppsSelected();
|
||||
} else if (currentLayoutResId == R.layout.swap_join_wifi) {
|
||||
inflateSwapView(R.layout.swap_select_apps);
|
||||
} else if (currentLayoutResId == R.layout.swap_nfc) {
|
||||
inflateSwapView(R.layout.swap_wifi_qr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,11 +517,6 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
|||
if (currentSwapViewLayoutRes == R.layout.swap_start_swap) {
|
||||
showIntro();
|
||||
return;
|
||||
} else if (currentSwapViewLayoutRes == R.layout.swap_nfc) {
|
||||
if (!attemptToShowNfc()) {
|
||||
inflateSwapView(R.layout.swap_wifi_qr);
|
||||
return;
|
||||
}
|
||||
} else if (currentSwapViewLayoutRes == R.layout.swap_connecting) {
|
||||
// TODO: Properly decide what to do here (i.e. returning to the activity after it was connecting)...
|
||||
inflateSwapView(R.layout.swap_start_swap);
|
||||
|
@ -624,8 +609,6 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
|||
} else if (currentView.getLayoutResId() == R.layout.swap_wifi_qr) {
|
||||
setUpFromWifi();
|
||||
setUpQrScannerButton();
|
||||
} else if (currentView.getLayoutResId() == R.layout.swap_nfc) {
|
||||
setUpNfcView();
|
||||
} else if (currentView.getLayoutResId() == R.layout.swap_select_apps) {
|
||||
LocalRepoService.create(this, getSwapService().getAppsToSwap());
|
||||
} else if (currentView.getLayoutResId() == R.layout.swap_connecting) {
|
||||
|
@ -730,7 +713,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
|||
hasPreparedLocalRepo = true;
|
||||
if (getSwapService().isConnectingWithPeer()) {
|
||||
startSwappingWithPeer();
|
||||
} else if (!attemptToShowNfc()) {
|
||||
} else {
|
||||
inflateSwapView(R.layout.swap_wifi_qr);
|
||||
}
|
||||
}
|
||||
|
@ -740,23 +723,6 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
|||
inflateSwapView(R.layout.swap_connecting);
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
// TODO move all swap-specific preferences to a SharedPreferences instance for SwapWorkflowActivity
|
||||
if (Preferences.get().showNfcDuringSwap() && nfcMessageReady) {
|
||||
inflateSwapView(R.layout.swap_nfc);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void swapWith(Peer peer) {
|
||||
getSwapService().swapWith(peer);
|
||||
inflateSwapView(R.layout.swap_select_apps);
|
||||
|
@ -1405,14 +1371,6 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private void setUpNfcView() {
|
||||
CheckBox dontShowAgain = container.findViewById(R.id.checkbox_dont_show);
|
||||
if (dontShowAgain != null) {
|
||||
dontShowAgain.setOnCheckedChangeListener((buttonView, isChecked)
|
||||
-> Preferences.get().setShowNfcDuringSwap(!isChecked));
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpConnectingProgressText(String message) {
|
||||
TextView progressText = container.findViewById(R.id.progress_text);
|
||||
if (progressText != null && message != null) {
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 8.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 11 KiB |
|
@ -1,37 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<org.fdroid.fdroid.nearby.SwapView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:swap="http://schemas.android.com/apk/res-auto"
|
||||
swap:toolbarTitle="@string/swap_nfc_title"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/swap_blue"
|
||||
android:paddingTop="38.8dp"> <!-- 69px * 96dpi / 160dpi -->
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/icon_nfc"
|
||||
swap:srcCompat="@drawable/nfc_touch"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_description"
|
||||
android:text="@string/swap_nfc_description"
|
||||
style="@style/SwapTheme.Wizard.MainText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/icon_nfc" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkbox_dont_show"
|
||||
android:text="@string/swap_dont_show_again"
|
||||
style="@style/SwapTheme.Wizard.Text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/text_description"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
</org.fdroid.fdroid.nearby.SwapView>
|
|
@ -260,11 +260,6 @@
|
|||
android:screenOrientation="fullSensor"
|
||||
tools:replace="screenOrientation" />
|
||||
|
||||
<activity
|
||||
android:name=".NfcNotEnabledActivity"
|
||||
android:configChanges="layoutDirection|locale"
|
||||
android:noHistory="true" />
|
||||
|
||||
<activity
|
||||
android:name=".views.repos.RepoDetailsActivity"
|
||||
android:configChanges="layoutDirection|locale"
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package org.fdroid.fdroid;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
@Deprecated
|
||||
public class NfcHelper {
|
||||
|
||||
public static boolean setPushMessage(AppCompatActivity activity, Uri toShare) {
|
||||
// removed in Android 14: https://www.xda-developers.com/android-beam-permanent-removal-android-14/
|
||||
// adapter.setNdefPushMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void setAndroidBeam(AppCompatActivity activity, String packageName) {
|
||||
// removed in SDK 34: https://www.xda-developers.com/android-beam-permanent-removal-android-14/
|
||||
// nfcAdapter.setBeamPushUris(uris, activity);
|
||||
}
|
||||
|
||||
public static void disableAndroidBeam(AppCompatActivity activity) {
|
||||
// removed in Android 14: https://www.xda-developers.com/android-beam-permanent-removal-android-14/
|
||||
// nfcAdapter.setBeamPushUris(null, activity);
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package org.fdroid.fdroid;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class NfcNotEnabledActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
FDroidApp fdroidApp = (FDroidApp) getApplication();
|
||||
fdroidApp.setSecureWindow(this);
|
||||
|
||||
fdroidApp.applyPureBlackBackgroundInDarkTheme(this);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final Intent intent = new Intent();
|
||||
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
|
||||
if (nfcAdapter == null) {
|
||||
return;
|
||||
}
|
||||
if (nfcAdapter.isEnabled()) {
|
||||
intent.setAction(Settings.ACTION_NFCSHARING_SETTINGS);
|
||||
} else {
|
||||
intent.setAction(Settings.ACTION_NFC_SETTINGS);
|
||||
}
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.e("NfcNotEnabledActivity", "Error starting activity: ", e);
|
||||
Toast.makeText(this, R.string.app_error_open, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
finish();
|
||||
}
|
||||
}
|
|
@ -58,7 +58,6 @@ import org.fdroid.database.Repository;
|
|||
import org.fdroid.fdroid.AppUpdateStatusManager;
|
||||
import org.fdroid.fdroid.CompatibilityChecker;
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.NfcHelper;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
|
@ -737,16 +736,6 @@ public class AppDetailsActivity extends AppCompatActivity
|
|||
|| currentStatus.status == AppUpdateStatusManager.Status.Downloading);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableAndroidBeam() {
|
||||
NfcHelper.setAndroidBeam(this, app.packageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableAndroidBeam() {
|
||||
NfcHelper.disableAndroidBeam(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openUrl(String url) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
|
|
|
@ -88,10 +88,6 @@ public class AppDetailsRecyclerViewAdapter
|
|||
|
||||
boolean isAppDownloading();
|
||||
|
||||
void enableAndroidBeam();
|
||||
|
||||
void disableAndroidBeam();
|
||||
|
||||
void openUrl(String url);
|
||||
|
||||
void installApk(Apk apk);
|
||||
|
@ -643,14 +639,12 @@ public class AppDetailsRecyclerViewAdapter
|
|||
progressLayout.setVisibility(View.VISIBLE);
|
||||
} else if (!app.isInstalled(context) && suggestedApk != null) {
|
||||
// Check count > 0 due to incompatible apps resulting in an empty list.
|
||||
callbacks.disableAndroidBeam();
|
||||
progressLayout.setVisibility(View.GONE);
|
||||
// Set Install button and hide second button
|
||||
buttonPrimaryView.setText(R.string.menu_install);
|
||||
buttonPrimaryView.setEnabled(true);
|
||||
buttonPrimaryView.setOnClickListener(v -> callbacks.installApk(suggestedApk));
|
||||
} else if (app.isInstalled(context)) {
|
||||
callbacks.enableAndroidBeam();
|
||||
if (app.canAndWantToUpdate(suggestedApk) && suggestedApk != null) {
|
||||
buttonPrimaryView.setText(R.string.menu_upgrade);
|
||||
buttonPrimaryView.setOnClickListener(v -> callbacks.installApk(suggestedApk));
|
||||
|
|
|
@ -48,7 +48,6 @@ import com.google.android.material.bottomnavigation.BottomNavigationView;
|
|||
|
||||
import org.fdroid.fdroid.AppUpdateStatusManager;
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.NfcHelper;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.UpdateService;
|
||||
|
@ -195,9 +194,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
FDroidApp.checkStartTor(this, Preferences.get());
|
||||
|
||||
// AppDetailsActivity and RepoDetailsActivity set different NFC actions, so reset here
|
||||
NfcHelper.setAndroidBeam(this, getApplication().getPackageName());
|
||||
|
||||
NearbyViewBinder.updateExternalStorageViews(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,6 @@ import org.fdroid.database.Repository;
|
|||
import org.fdroid.database.RepositoryDao;
|
||||
import org.fdroid.download.Mirror;
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.NfcHelper;
|
||||
import org.fdroid.fdroid.NfcNotEnabledActivity;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.UpdateService;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
|
@ -206,12 +204,6 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void setNfc() {
|
||||
if (NfcHelper.setPushMessage(this, Utils.getSharingUri(repo))) {
|
||||
findViewById(android.R.id.content).post(() -> onNewIntent(getIntent()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
@ -228,8 +220,6 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
|||
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver,
|
||||
new IntentFilter(UpdateService.LOCAL_ACTION_STATUS));
|
||||
|
||||
// FDroid.java and AppDetailsActivity set different NFC actions, so reset here
|
||||
setNfc();
|
||||
processIntent(getIntent());
|
||||
}
|
||||
|
||||
|
@ -286,10 +276,6 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
|||
} else if (itemId == R.id.menu_delete) {
|
||||
promptForDelete();
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_enable_nfc) {
|
||||
intent = new Intent(this, NfcNotEnabledActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_share) {
|
||||
intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setType("text/plain");
|
||||
|
@ -303,26 +289,10 @@ public class RepoDetailsActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
prepareNfcMenuItems(menu);
|
||||
prepareShareMenuItems(menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void prepareNfcMenuItems(Menu menu) {
|
||||
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
|
||||
MenuItem menuItem = menu.findItem(R.id.menu_enable_nfc);
|
||||
|
||||
if (nfcAdapter == null) {
|
||||
menuItem.setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean needsEnableNfcMenuItem;
|
||||
needsEnableNfcMenuItem = false; // TODO remove NFC code
|
||||
|
||||
menuItem.setVisible(needsEnableNfcMenuItem);
|
||||
}
|
||||
|
||||
private void prepareShareMenuItems(Menu menu) {
|
||||
if (!TextUtils.isEmpty(repo.getAddress())) {
|
||||
if (!TextUtils.isEmpty(repo.getCertificate())) {
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M20,2L4,2c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM19,20L5,20c-0.55,0 -1,-0.45 -1,-1L4,5c0,-0.55 0.45,-1 1,-1h14c0.55,0 1,0.45 1,1v14c0,0.55 -0.45,1 -1,1zM16,6h-3c-1.1,0 -2,0.9 -2,2v2.28c-0.6,0.35 -1,0.98 -1,1.72 0,1.1 0.9,2 2,2s2,-0.9 2,-2c0,-0.74 -0.4,-1.38 -1,-1.72L13,8h3v7c0,0.55 -0.45,1 -1,1L9,16c-0.55,0 -1,-0.45 -1,-1L8,8h1c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L8,6c-1.1,0 -2,0.9 -2,2v8c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,8c0,-1.1 -0.9,-2 -2,-2z" />
|
||||
</vector>
|
|
@ -8,11 +8,6 @@
|
|||
android:icon="@drawable/ic_share"
|
||||
android:title="@string/menu_share"
|
||||
app:showAsAction="ifRoom|withText" />
|
||||
<item
|
||||
android:id="@+id/menu_enable_nfc"
|
||||
android:icon="@drawable/ic_nfc"
|
||||
android:title="@string/enable_nfc_send"
|
||||
app:showAsAction="ifRoom|withText" />
|
||||
<item
|
||||
android:id="@+id/menu_delete"
|
||||
android:icon="@drawable/ic_delete"
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
<string name="version">Version</string>
|
||||
<string name="by_author_format">by %s</string>
|
||||
<string name="delete">Delete</string>
|
||||
<string name="enable_nfc_send">Enable NFC Send…</string>
|
||||
<string name="prompt_to_send_crash_reports">Prompt to send crash reports</string>
|
||||
<string name="prompt_to_send_crash_reports_summary">Gather data about crashes and ask to send them to the
|
||||
developer
|
||||
|
@ -551,10 +550,6 @@ This often occurs with apps installed via Google Play or other sources, if they
|
|||
<string name="nearby_splach__external_storage_permission_explainer">F-Droid can search for repos and mirrors on your SD Card, but needs your permission to do so.</string>
|
||||
<string name="nearby_splace__external_storage_permission_button">Try it</string>
|
||||
|
||||
<!-- This is a screen title, it should be maximum 25 characters -->
|
||||
<string name="swap_nfc_title">Touch to swap</string>
|
||||
<string name="swap_nfc_description">If your friend has F-Droid and NFC turned on touch your devices together.
|
||||
</string>
|
||||
<string name="swap_join_same_wifi">Join the same Wi-Fi as your friend</string>
|
||||
<string name="swap_join_same_wifi_desc">To swap using Wi-Fi, ensure you are on the same network. If you don\'t have
|
||||
access to the same network, one of you can create a Wi-Fi Hotspot.
|
||||
|
|
|
@ -113,16 +113,6 @@ public class AppDetailsAdapterTest {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableAndroidBeam() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableAndroidBeam() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openUrl(String url) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue