fix crash bugs reported in Play Store
This commit is contained in:
parent
52cfe8dc12
commit
b60b5d16c3
12 changed files with 108 additions and 66 deletions
|
@ -63,6 +63,7 @@ dependencies {
|
|||
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
|
||||
implementation 'androidx.preference:preference:1.1.1'
|
||||
implementation 'androidx.webkit:webkit:1.3.0-alpha02'
|
||||
implementation 'androidx.camera:camera-core:1.0.0-beta03'
|
||||
implementation 'androidx.camera:camera-camera2:1.0.0-beta03'
|
||||
implementation 'androidx.camera:camera-lifecycle:1.0.0-beta03'
|
||||
implementation 'androidx.camera:camera-view:1.0.0-alpha10'
|
||||
|
|
|
@ -84,9 +84,13 @@ public class MergeSubscriptionsTask extends AsyncTask<Void, Void, List<Subscript
|
|||
try {
|
||||
LbryUri uri = LbryUri.parse(local.getUrl());
|
||||
Map<String, String> options = new HashMap<>();
|
||||
options.put("claim_id", uri.getChannelClaimId());
|
||||
options.put("channel_name", Helper.normalizeChannelName(local.getChannelName()));
|
||||
String channelClaimId = uri.getChannelClaimId();
|
||||
String channelName = Helper.normalizeChannelName(local.getChannelName());
|
||||
if (!Helper.isNullOrEmpty(channelClaimId) && !Helper.isNullOrEmpty(channelName)) {
|
||||
options.put("claim_id", channelClaimId);
|
||||
options.put("channel_name", channelName);
|
||||
Lbryio.parseResponse(Lbryio.call("subscription", "new", options, context));
|
||||
}
|
||||
} catch (LbryUriException | LbryioRequestException | LbryioResponseException ex) {
|
||||
// pass
|
||||
Log.e(TAG, String.format("subscription/new failed: %s", ex.getMessage()), ex);
|
||||
|
|
|
@ -62,7 +62,8 @@ public class ClaimListTask extends AsyncTask<Void, Void, List<Claim>> {
|
|||
Helper.setViewVisibility(progressView, View.GONE);
|
||||
if (handler != null) {
|
||||
if (claims != null) {
|
||||
handler.onSuccess(claims);
|
||||
// TODO: Add fix for handling invalid reposts in ClaimListAdapter
|
||||
handler.onSuccess(Helper.filterInvalidReposts(claims));
|
||||
} else {
|
||||
handler.onError(error);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class ClaimSearchTask extends AsyncTask<Void, Void, List<Claim>> {
|
|||
}
|
||||
protected List<Claim> doInBackground(Void... params) {
|
||||
try {
|
||||
return Helper.filterInvalidReposts(Lbry.claimSearch(options, connectionString));
|
||||
return Lbry.claimSearch(options, connectionString);
|
||||
} catch (ApiCallException ex) {
|
||||
error = ex;
|
||||
return null;
|
||||
|
@ -39,7 +39,7 @@ public class ClaimSearchTask extends AsyncTask<Void, Void, List<Claim>> {
|
|||
Helper.setViewVisibility(progressView, View.GONE);
|
||||
if (handler != null) {
|
||||
if (claims != null) {
|
||||
handler.onSuccess(claims, claims.size() < Helper.parseInt(options.get("page_size"), 0));
|
||||
handler.onSuccess(Helper.filterInvalidReposts(claims), claims.size() < Helper.parseInt(options.get("page_size"), 0));
|
||||
} else {
|
||||
handler.onError(error);
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public class LoadSharedUserStateTask extends AsyncTask<Void, Void, Boolean> {
|
|||
if (db != null) {
|
||||
DatabaseHelper.createOrUpdateTag(tag, db);
|
||||
}
|
||||
} catch (SQLiteException ex) {
|
||||
} catch (SQLiteException | IllegalStateException ex) {
|
||||
// pass
|
||||
}
|
||||
}
|
||||
|
|
|
@ -322,6 +322,7 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
|
|||
boolean updateRequired = false;
|
||||
Map<String, Object> params = getParams();
|
||||
|
||||
if (params != null) {
|
||||
if (params.containsKey("claim")) {
|
||||
Claim claim = (Claim) params.get("claim");
|
||||
if (claim != null && !claim.equals(this.claim)) {
|
||||
|
@ -337,6 +338,7 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
|
|||
updateRequired = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updateRequired) {
|
||||
resetSubCount();
|
||||
|
|
|
@ -1104,8 +1104,10 @@ public class FileViewFragment extends BaseFragment implements
|
|||
@Override
|
||||
public void onError(Exception error) {
|
||||
actionDelete.setEnabled(true);
|
||||
if (error != null) {
|
||||
showError(error.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
@ -2055,17 +2057,23 @@ public class FileViewFragment extends BaseFragment implements
|
|||
if (claim != null) {
|
||||
claim.setFile(null);
|
||||
}
|
||||
((ImageView) getView().findViewById(R.id.file_view_action_download_icon)).setImageResource(R.drawable.ic_download);
|
||||
Helper.setViewVisibility(getView().findViewById(R.id.file_view_download_progress), View.GONE);
|
||||
Helper.setViewVisibility(getView().findViewById(R.id.file_view_unsupported_container), View.GONE);
|
||||
View root = getView();
|
||||
if (root != null) {
|
||||
((ImageView) root.findViewById(R.id.file_view_action_download_icon)).setImageResource(R.drawable.ic_download);
|
||||
Helper.setViewVisibility(root.findViewById(R.id.file_view_download_progress), View.GONE);
|
||||
Helper.setViewVisibility(root.findViewById(R.id.file_view_unsupported_container), View.GONE);
|
||||
}
|
||||
|
||||
checkIsFileComplete();
|
||||
restoreMainActionButton();
|
||||
}
|
||||
|
||||
private void restoreMainActionButton() {
|
||||
getView().findViewById(R.id.file_view_main_action_loading).setVisibility(View.INVISIBLE);
|
||||
getView().findViewById(R.id.file_view_main_action_button).setVisibility(View.VISIBLE);
|
||||
View root = getView();
|
||||
if (root != null) {
|
||||
root.findViewById(R.id.file_view_main_action_loading).setVisibility(View.INVISIBLE);
|
||||
root.findViewById(R.id.file_view_main_action_button).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -524,8 +524,9 @@ public class FollowingFragment extends BaseFragment implements
|
|||
}
|
||||
|
||||
private void updateChannelFilterListAdapter(List<Claim> resolvedSubs, boolean reset) {
|
||||
if (channelFilterListAdapter == null) {
|
||||
channelFilterListAdapter = new ChannelFilterListAdapter(getContext());
|
||||
Context context = getContext();
|
||||
if (channelFilterListAdapter == null && context != null) {
|
||||
channelFilterListAdapter = new ChannelFilterListAdapter(context);
|
||||
channelFilterListAdapter.setListener(new ChannelItemSelectionListener() {
|
||||
@Override
|
||||
public void onChannelItemSelected(Claim claim) {
|
||||
|
@ -560,6 +561,7 @@ public class FollowingFragment extends BaseFragment implements
|
|||
});
|
||||
}
|
||||
|
||||
if (channelFilterListAdapter != null) {
|
||||
if (horizontalChannelList != null && horizontalChannelList.getAdapter() == null) {
|
||||
horizontalChannelList.setAdapter(channelFilterListAdapter);
|
||||
}
|
||||
|
@ -569,6 +571,7 @@ public class FollowingFragment extends BaseFragment implements
|
|||
}
|
||||
channelFilterListAdapter.addClaims(resolvedSubs);
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchClaimSearchContent() {
|
||||
fetchClaimSearchContent(false);
|
||||
|
@ -626,11 +629,12 @@ public class FollowingFragment extends BaseFragment implements
|
|||
}
|
||||
|
||||
private void updateSuggestedDoneButtonText() {
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
int selected = suggestedChannelAdapter == null ? 0 : suggestedChannelAdapter.getSelectedCount();
|
||||
int remaining = MIN_SUGGESTED_SUBSCRIBE_COUNT - selected;
|
||||
String buttonText = remaining <= 0 ? getString(R.string.done) : getString(R.string.n_remaining, remaining);
|
||||
if (suggestedDoneButton != null) {
|
||||
suggestedDoneButton.setText(buttonText);
|
||||
Helper.setViewText(suggestedDoneButton, buttonText);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -239,9 +239,10 @@ public class SearchFragment extends BaseFragment implements
|
|||
public void onSuccess(List<Claim> claims, boolean hasReachedEnd) {
|
||||
contentHasReachedEnd = hasReachedEnd;
|
||||
searchLoading = false;
|
||||
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
if (resultListAdapter == null) {
|
||||
resultListAdapter = new ClaimListAdapter(claims, getContext());
|
||||
resultListAdapter = new ClaimListAdapter(claims, context);
|
||||
resultListAdapter.addFeaturedItem(buildFeaturedItem(query));
|
||||
resolveFeaturedItem(buildVanityUrl(query));
|
||||
resultListAdapter.setListener(SearchFragment.this);
|
||||
|
@ -253,17 +254,21 @@ public class SearchFragment extends BaseFragment implements
|
|||
}
|
||||
|
||||
int itemCount = resultListAdapter.getItemCount();
|
||||
noQueryView.setVisibility(View.GONE);
|
||||
noResultsView.setVisibility(itemCount == 0 ? View.VISIBLE : View.GONE);
|
||||
noResultsView.setText(getString(R.string.search_no_results, currentQuery));
|
||||
Helper.setViewVisibility(noQueryView, View.GONE);
|
||||
Helper.setViewVisibility(noResultsView, itemCount == 0 ? View.VISIBLE : View.GONE);
|
||||
Helper.setViewText(noResultsView, getString(R.string.search_no_results, currentQuery));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
Context context = getContext();
|
||||
int itemCount = resultListAdapter == null ? 0 : resultListAdapter.getItemCount();
|
||||
noQueryView.setVisibility(View.GONE);
|
||||
noResultsView.setVisibility(itemCount == 0 ? View.VISIBLE : View.GONE);
|
||||
noResultsView.setText(getString(R.string.search_no_results, currentQuery));
|
||||
Helper.setViewVisibility(noQueryView, View.GONE);
|
||||
Helper.setViewVisibility(noResultsView, itemCount == 0 ? View.VISIBLE : View.GONE);
|
||||
if (context != null) {
|
||||
Helper.setViewText(noResultsView, getString(R.string.search_no_results, currentQuery));
|
||||
}
|
||||
searchLoading = false;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -52,6 +52,7 @@ import io.lbry.browser.utils.LbryAnalytics;
|
|||
public class PublishFragment extends BaseFragment implements
|
||||
CameraPermissionListener, FilePickerListener, StoragePermissionListener {
|
||||
|
||||
private boolean cameraPreviewInitialized;
|
||||
private PreviewView cameraPreview;
|
||||
private RecyclerView galleryGrid;
|
||||
private GalleryGridAdapter adapter;
|
||||
|
@ -122,7 +123,7 @@ public class PublishFragment extends BaseFragment implements
|
|||
|
||||
private void displayPreviewWithCameraX() {
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
if (context != null && MainActivity.hasPermission(Manifest.permission.CAMERA, context)) {
|
||||
cameraProviderFuture = ProcessCameraProvider.getInstance(context);
|
||||
cameraProviderFuture.addListener(new Runnable() {
|
||||
@Override
|
||||
|
@ -137,6 +138,7 @@ public class PublishFragment extends BaseFragment implements
|
|||
|
||||
Camera camera = cameraProvider.bindToLifecycle((LifecycleOwner) context, cameraSelector, preview);
|
||||
preview.setSurfaceProvider(cameraPreview.createSurfaceProvider(camera.getCameraInfo()));
|
||||
cameraPreviewInitialized = true;
|
||||
}
|
||||
} catch (ExecutionException | InterruptedException ex) {
|
||||
// pass
|
||||
|
@ -267,7 +269,9 @@ public class PublishFragment extends BaseFragment implements
|
|||
activity.removeFilePickerListener(this);
|
||||
}
|
||||
}
|
||||
if (cameraPreviewInitialized) {
|
||||
CameraX.unbindAll();
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
@ -361,13 +365,13 @@ public class PublishFragment extends BaseFragment implements
|
|||
public void onCameraPermissionRefused() {
|
||||
if (takePhotoPending) {
|
||||
takePhotoPending = false;
|
||||
Snackbar.make(getView(), R.string.camera_permission_rationale_photo, Toast.LENGTH_LONG).
|
||||
Snackbar.make(getView(), R.string.camera_permission_rationale_photo, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
return;
|
||||
}
|
||||
|
||||
recordPending = false;
|
||||
Snackbar.make(getView(), R.string.camera_permission_rationale_record, Toast.LENGTH_LONG).
|
||||
Snackbar.make(getView(), R.string.camera_permission_rationale_record, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
|
||||
|
@ -395,9 +399,8 @@ public class PublishFragment extends BaseFragment implements
|
|||
|
||||
@Override
|
||||
public void onStoragePermissionRefused() {
|
||||
Snackbar.make(getView(), R.string.storage_permission_rationale_videos, Snackbar.LENGTH_LONG).setBackgroundTint(
|
||||
ContextCompat.getColor(getContext(), R.color.red)
|
||||
).show();
|
||||
Snackbar.make(getView(), R.string.storage_permission_rationale_videos, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
|
||||
public String getSuggestedPublishUrl() {
|
||||
|
|
|
@ -705,6 +705,9 @@ public final class Helper {
|
|||
}
|
||||
}
|
||||
public static String normalizeChannelName(String channelName) {
|
||||
if (Helper.isNullOrEmpty(channelName)) {
|
||||
return "";
|
||||
}
|
||||
if (!channelName.startsWith("@")) {
|
||||
return String.format("@%s", channelName);
|
||||
}
|
||||
|
|
|
@ -32,17 +32,28 @@ public class LbryAnalytics {
|
|||
analytics = FirebaseAnalytics.getInstance(context);
|
||||
}
|
||||
|
||||
public static void checkInitAnalytics(Context context) {
|
||||
if (analytics == null && context != null) {
|
||||
analytics = FirebaseAnalytics.getInstance(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCurrentScreen(Activity activity, String name, String className) {
|
||||
checkInitAnalytics(activity);
|
||||
if (analytics != null) {
|
||||
analytics.setCurrentScreen(activity, name, className);
|
||||
}
|
||||
}
|
||||
|
||||
public static void logEvent(String name) {
|
||||
logEvent(name, null);
|
||||
}
|
||||
|
||||
public static void logEvent(String name, Bundle bundle) {
|
||||
if (analytics != null) {
|
||||
analytics.logEvent(name, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
public static void logException(String message, String exceptionName) {
|
||||
Bundle bundle = new Bundle();
|
||||
|
|
Loading…
Reference in a new issue