mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-02-20 08:08:04 -05:00
Merge branch 'acra-fixes' into 'master'
Fix two ACRA crashes Closes acra-crash-reports#721 and acra-crash-reports#722 See merge request fdroid/fdroidclient!1331
This commit is contained in:
@@ -1,34 +1,17 @@
|
||||
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;
|
||||
|
||||
// aka Android 4.0 aka Ice Cream Sandwich
|
||||
public class NfcNotEnabledActivity extends AppCompatActivity {
|
||||
|
||||
/*
|
||||
* ACTION_NFC_SETTINGS was added in 4.1 aka Jelly Bean MR1 as a
|
||||
* separate thing from ACTION_NFCSHARING_SETTINGS. It is now
|
||||
* possible to have NFC enabled, but not "Android Beam", which is
|
||||
* needed for NDEF. Therefore, we detect the current state of NFC,
|
||||
* and steer the user accordingly.
|
||||
*/
|
||||
private void doOnJellybean(Intent 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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
FDroidApp fdroidApp = (FDroidApp) getApplication();
|
||||
@@ -39,8 +22,21 @@ public class NfcNotEnabledActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final Intent intent = new Intent();
|
||||
doOnJellybean(intent);
|
||||
startActivity(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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
private void handleSearchOrAppViewIntent(Intent intent) {
|
||||
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
||||
String query = intent.getStringExtra(SearchManager.QUERY);
|
||||
performSearch(query);
|
||||
if (query != null) performSearch(query);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -372,14 +372,14 @@ public class MainActivity extends AppCompatActivity {
|
||||
/**
|
||||
* These strings might end up in a SQL query, so strip all non-alpha-num
|
||||
*/
|
||||
static String sanitizeSearchTerms(String query) {
|
||||
static String sanitizeSearchTerms(@NonNull String query) {
|
||||
return query.replaceAll("[^\\p{L}\\d_ -]", " ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates the {@link AppListActivity} with the relevant search terms passed in via the query arg.
|
||||
*/
|
||||
private void performSearch(String query) {
|
||||
private void performSearch(@NonNull String query) {
|
||||
Intent searchIntent = new Intent(this, AppListActivity.class);
|
||||
searchIntent.putExtra(AppListActivity.EXTRA_SEARCH_TERMS, sanitizeSearchTerms(query));
|
||||
startActivity(searchIntent);
|
||||
|
||||
Reference in New Issue
Block a user