Merge branch 'suite-of-crash-fixes' into 'master'
Suite of crash fixes See merge request fdroid/fdroidclient!810
This commit is contained in:
commit
9ed4fe8c64
@ -60,8 +60,17 @@ class MainViewController extends RecyclerView.ViewHolder {
|
|||||||
new CategoriesViewBinder(activity, frame);
|
new CategoriesViewBinder(activity, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link android.os.Environment#isExternalStorageRemovable()} sometimes
|
||||||
|
* throughs {@link IllegalArgumentException}s when it can't find the
|
||||||
|
* storage.
|
||||||
|
*/
|
||||||
public void bindSwapView() {
|
public void bindSwapView() {
|
||||||
new NearbyViewBinder(activity, frame);
|
try {
|
||||||
|
new NearbyViewBinder(activity, frame);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,8 +81,6 @@ class NearbyViewBinder {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
Log.i(TAG, "Environment.isExternalStorageRemovable(activity.getExternalFilesDir(\"\")) " +
|
|
||||||
Environment.isExternalStorageRemovable(activity.getExternalFilesDir("")));
|
|
||||||
File[] dirs = activity.getExternalFilesDirs("");
|
File[] dirs = activity.getExternalFilesDirs("");
|
||||||
if (dirs != null) {
|
if (dirs != null) {
|
||||||
for (File dir : dirs) {
|
for (File dir : dirs) {
|
||||||
|
@ -288,9 +288,9 @@ public class SwapAppsView extends ListView implements
|
|||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange) {
|
public void onChange(boolean selfChange) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null && app != null) {
|
||||||
app = AppProvider.Helper.findSpecificApp(
|
app = AppProvider.Helper.findSpecificApp(
|
||||||
getActivity().getContentResolver(),
|
activity.getContentResolver(),
|
||||||
app.packageName,
|
app.packageName,
|
||||||
app.repoId,
|
app.repoId,
|
||||||
AppMetadataTable.Cols.ALL);
|
AppMetadataTable.Cols.ALL);
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package org.fdroid.fdroid;
|
package org.fdroid.fdroid;
|
||||||
|
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.IntentService;
|
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.job.JobInfo;
|
import android.app.job.JobInfo;
|
||||||
@ -33,8 +32,6 @@ import android.content.IntentFilter;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
@ -87,7 +84,6 @@ public class UpdateService extends JobIntentService {
|
|||||||
private static final int NOTIFY_ID_UPDATING = 0;
|
private static final int NOTIFY_ID_UPDATING = 0;
|
||||||
|
|
||||||
private static UpdateService updateService;
|
private static UpdateService updateService;
|
||||||
private static Handler toastHandler;
|
|
||||||
|
|
||||||
private NotificationManager notificationManager;
|
private NotificationManager notificationManager;
|
||||||
private NotificationCompat.Builder notificationBuilder;
|
private NotificationCompat.Builder notificationBuilder;
|
||||||
@ -391,22 +387,6 @@ public class UpdateService extends JobIntentService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* In order to send a {@link Toast} from a {@link IntentService}, we have to do these tricks.
|
|
||||||
*/
|
|
||||||
private void sendNoInternetToast() {
|
|
||||||
if (toastHandler == null) {
|
|
||||||
toastHandler = new Handler(Looper.getMainLooper());
|
|
||||||
}
|
|
||||||
toastHandler.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(getApplicationContext(),
|
|
||||||
R.string.warning_no_internet, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isLocalRepoAddress(String address) {
|
private static boolean isLocalRepoAddress(String address) {
|
||||||
return address != null &&
|
return address != null &&
|
||||||
(address.startsWith(BluetoothDownloader.SCHEME)
|
(address.startsWith(BluetoothDownloader.SCHEME)
|
||||||
@ -453,7 +433,7 @@ public class UpdateService extends JobIntentService {
|
|||||||
if (!foundLocalRepo) {
|
if (!foundLocalRepo) {
|
||||||
Utils.debugLog(TAG, "No internet, cannot update");
|
Utils.debugLog(TAG, "No internet, cannot update");
|
||||||
if (manualUpdate) {
|
if (manualUpdate) {
|
||||||
sendNoInternetToast();
|
Utils.showToastFromService(this, getString(R.string.warning_no_internet), Toast.LENGTH_SHORT);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ import android.database.Cursor;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.StatFs;
|
import android.os.StatFs;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
@ -42,6 +44,7 @@ import android.text.style.TypefaceSpan;
|
|||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
import android.widget.Toast;
|
||||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||||
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
||||||
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
||||||
@ -101,6 +104,8 @@ public final class Utils {
|
|||||||
|
|
||||||
private static Pattern safePackageNamePattern;
|
private static Pattern safePackageNamePattern;
|
||||||
|
|
||||||
|
private static Handler toastHandler;
|
||||||
|
|
||||||
public static final String FALLBACK_ICONS_DIR = "/icons/";
|
public static final String FALLBACK_ICONS_DIR = "/icons/";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -578,7 +583,8 @@ public final class Utils {
|
|||||||
Date result;
|
Date result;
|
||||||
try {
|
try {
|
||||||
result = format.parse(str);
|
result = format.parse(str);
|
||||||
} catch (ParseException e) {
|
} catch (ArrayIndexOutOfBoundsException | NumberFormatException | ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
result = fallback;
|
result = fallback;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -839,4 +845,21 @@ public final class Utils {
|
|||||||
Utils.debugLog(logTag, "[" + duration + "ms] " + message);
|
Utils.debugLog(logTag, "[" + duration + "ms] " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In order to send a {@link Toast} from a {@link android.app.Service}, we
|
||||||
|
* have to do these tricks.
|
||||||
|
*/
|
||||||
|
public static void showToastFromService(final Context context, final String msg, final int length) {
|
||||||
|
if (toastHandler == null) {
|
||||||
|
toastHandler = new Handler(Looper.getMainLooper());
|
||||||
|
}
|
||||||
|
toastHandler.post(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Toast.makeText(context.getApplicationContext(), msg, length).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1112,7 +1112,10 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
|||||||
}
|
}
|
||||||
eventType = xml.nextToken();
|
eventType = xml.nextToken();
|
||||||
}
|
}
|
||||||
} catch (PackageManager.NameNotFoundException | IOException | XmlPullParserException e) {
|
} catch (PackageManager.NameNotFoundException
|
||||||
|
| IOException
|
||||||
|
| XmlPullParserException
|
||||||
|
| NumberFormatException e) {
|
||||||
Log.e(TAG, "Could not get min/max sdk version", e);
|
Log.e(TAG, "Could not get min/max sdk version", e);
|
||||||
}
|
}
|
||||||
if (targetSdkVersion < minSdkVersion) {
|
if (targetSdkVersion < minSdkVersion) {
|
||||||
|
@ -57,6 +57,7 @@ import org.fdroid.fdroid.UpdateService;
|
|||||||
import org.fdroid.fdroid.Utils;
|
import org.fdroid.fdroid.Utils;
|
||||||
import org.fdroid.fdroid.data.NewRepoConfig;
|
import org.fdroid.fdroid.data.NewRepoConfig;
|
||||||
import org.fdroid.fdroid.localrepo.SDCardScannerService;
|
import org.fdroid.fdroid.localrepo.SDCardScannerService;
|
||||||
|
import org.fdroid.fdroid.net.WifiStateChangeService;
|
||||||
import org.fdroid.fdroid.views.AppDetailsActivity;
|
import org.fdroid.fdroid.views.AppDetailsActivity;
|
||||||
import org.fdroid.fdroid.views.ManageReposActivity;
|
import org.fdroid.fdroid.views.ManageReposActivity;
|
||||||
import org.fdroid.fdroid.views.apps.AppListActivity;
|
import org.fdroid.fdroid.views.apps.AppListActivity;
|
||||||
@ -249,6 +250,7 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB
|
|||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { // NOCHECKSTYLE LineLength
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { // NOCHECKSTYLE LineLength
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
if (requestCode == REQUEST_LOCATION_PERMISSIONS) {
|
if (requestCode == REQUEST_LOCATION_PERMISSIONS) {
|
||||||
|
WifiStateChangeService.start(this, null);
|
||||||
startActivity(new Intent(this, SwapWorkflowActivity.class));
|
startActivity(new Intent(this, SwapWorkflowActivity.class));
|
||||||
} else if (requestCode == REQUEST_STORAGE_PERMISSIONS) {
|
} else if (requestCode == REQUEST_STORAGE_PERMISSIONS) {
|
||||||
Toast.makeText(this,
|
Toast.makeText(this,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user