From 9ed8864f2394a5336375e2c72b07979025b91e18 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Tue, 2 Jun 2020 08:55:34 +0100 Subject: [PATCH] More crash fixes. Change comment cost to 2 LBC. --- app/build.gradle | 8 +++---- .../java/io/lbry/browser/MainActivity.java | 23 +++++++++++++------ .../dialog/RepostClaimDialogFragment.java | 8 ++++--- .../java/io/lbry/browser/model/Comment.java | 2 +- .../tasks/UpdateSuggestedTagsTask.java | 13 +++++++---- .../ui/channel/ChannelCommentsFragment.java | 2 +- .../ui/findcontent/FileViewFragment.java | 23 ++++++++++++------- .../browser/ui/publish/PublishFragment.java | 2 +- .../browser/ui/publish/PublishesFragment.java | 1 + .../main/res/layout/fragment_publishes.xml | 2 +- app/src/main/res/values/strings.xml | 1 + 11 files changed, 55 insertions(+), 30 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 331da6cd..1cf47013 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -54,7 +54,7 @@ task printVersionName { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.2.0-rc01' + implementation 'androidx.appcompat:appcompat:1.3.0-alpha01' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.google.android.material:material:1.2.0-alpha06' implementation "androidx.cardview:cardview:1.0.0" @@ -64,7 +64,7 @@ dependencies { implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' implementation 'androidx.preference:preference:1.1.1' - implementation 'androidx.webkit:webkit:1.3.0-alpha02' + implementation 'androidx.webkit:webkit:1.3.0-alpha03' 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' @@ -72,9 +72,9 @@ dependencies { implementation 'com.github.bumptech.glide:glide:4.11.0' implementation 'com.squareup.okhttp3:okhttp:4.4.1' - implementation 'com.google.firebase:firebase-analytics:17.4.1' + implementation 'com.google.firebase:firebase-analytics:17.4.2' implementation 'com.google.android.gms:play-services-base:17.2.1' - implementation 'com.google.firebase:firebase-messaging:20.1.7' + implementation 'com.google.firebase:firebase-messaging:20.2.0' implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.google.android.exoplayer:exoplayer-core:2.11.4' diff --git a/app/src/main/java/io/lbry/browser/MainActivity.java b/app/src/main/java/io/lbry/browser/MainActivity.java index fcbae3d4..957005eb 100644 --- a/app/src/main/java/io/lbry/browser/MainActivity.java +++ b/app/src/main/java/io/lbry/browser/MainActivity.java @@ -746,13 +746,22 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener public void openPublishesOnSuccessfulPublish() { // close publish form - try { - getSupportFragmentManager().popBackStack(); - openFragment(PublishesFragment.class, true, NavMenuItem.ID_ITEM_PUBLISHES); - } catch (IllegalStateException ex) { - // pass - onBackPressed(); - } + runOnUiThread(new Runnable() { + @Override + public void run() { + try { + getSupportFragmentManager().popBackStack(); + openFragment(PublishesFragment.class, true, NavMenuItem.ID_ITEM_PUBLISHES); + } catch (IllegalStateException ex) { + // pass + try { + onBackPressed(); + } catch (IllegalStateException iex) { + // if this fails on some devices. what's the solution? + } + } + } + }); } public void openPublishForm(Claim claim) { diff --git a/app/src/main/java/io/lbry/browser/dialog/RepostClaimDialogFragment.java b/app/src/main/java/io/lbry/browser/dialog/RepostClaimDialogFragment.java index 4cc84758..edd8a1f5 100644 --- a/app/src/main/java/io/lbry/browser/dialog/RepostClaimDialogFragment.java +++ b/app/src/main/java/io/lbry/browser/dialog/RepostClaimDialogFragment.java @@ -192,14 +192,16 @@ public class RepostClaimDialogFragment extends BottomSheetDialogFragment impleme private void loadChannels(List channels) { if (channelSpinnerAdapter == null) { Context context = getContext(); - channelSpinnerAdapter = new InlineChannelSpinnerAdapter(context, R.layout.spinner_item_channel, channels); - channelSpinnerAdapter.notifyDataSetChanged(); + if (context != null) { + channelSpinnerAdapter = new InlineChannelSpinnerAdapter(context, R.layout.spinner_item_channel, channels); + channelSpinnerAdapter.notifyDataSetChanged(); + } } else { channelSpinnerAdapter.clear(); channelSpinnerAdapter.addAll(channels); channelSpinnerAdapter.notifyDataSetChanged(); } - if (channelSpinner != null) { + if (channelSpinner != null && channelSpinnerAdapter != null) { channelSpinner.setAdapter(channelSpinnerAdapter); } } diff --git a/app/src/main/java/io/lbry/browser/model/Comment.java b/app/src/main/java/io/lbry/browser/model/Comment.java index 60c16628..3dfab3e6 100644 --- a/app/src/main/java/io/lbry/browser/model/Comment.java +++ b/app/src/main/java/io/lbry/browser/model/Comment.java @@ -12,7 +12,7 @@ import lombok.Data; @Data public class Comment { - public static final double COST = 0.25; + public static final double LBC_COST = 2; public static final int MAX_LENGTH = 2000; private Claim poster; diff --git a/app/src/main/java/io/lbry/browser/tasks/UpdateSuggestedTagsTask.java b/app/src/main/java/io/lbry/browser/tasks/UpdateSuggestedTagsTask.java index 7d743dd8..d0dd0326 100644 --- a/app/src/main/java/io/lbry/browser/tasks/UpdateSuggestedTagsTask.java +++ b/app/src/main/java/io/lbry/browser/tasks/UpdateSuggestedTagsTask.java @@ -66,10 +66,15 @@ public class UpdateSuggestedTagsTask extends AsyncTask> { if (excludeMature && knownTag.isMature()) { continue; } - if ((knownTag.getLowercaseName().startsWith(filter) || knownTag.getLowercaseName().matches(filter)) && - (!tags.contains(knownTag) && - !Lbry.followedTags.contains(knownTag) && (addedTagsAdapter == null || !addedTagsAdapter.getTags().contains(knownTag)))) { - tags.add(knownTag); + try { + if ((knownTag.getLowercaseName().startsWith(filter) || + knownTag.getLowercaseName().matches(filter)) && + (!tags.contains(knownTag) && !Lbry.followedTags.contains(knownTag) && (addedTagsAdapter == null || !addedTagsAdapter.getTags().contains(knownTag))) + ) { + tags.add(knownTag); + } + } catch (Exception ex) { + // continue } } } diff --git a/app/src/main/java/io/lbry/browser/ui/channel/ChannelCommentsFragment.java b/app/src/main/java/io/lbry/browser/ui/channel/ChannelCommentsFragment.java index 30db98aa..fbb58190 100644 --- a/app/src/main/java/io/lbry/browser/ui/channel/ChannelCommentsFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/channel/ChannelCommentsFragment.java @@ -350,7 +350,7 @@ public class ChannelCommentsFragment extends Fragment implements SdkStatusListen } private void initCommentForm(View root) { - double amount = Comment.COST / Lbryio.LBCUSDRate; + double amount = Comment.LBC_COST; String buttonText = getResources().getQuantityString(R.plurals.post_for_credits, amount == 1 ? 1 : 2, Helper.LBC_CURRENCY_FORMAT.format(amount)); buttonPostComment.setText(buttonText); textCommentLimit.setText(String.format("%d / %d", Helper.getValue(inputComment.getText()).length(), Comment.MAX_LENGTH)); diff --git a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java index 53ec5f44..88dab58e 100644 --- a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java @@ -1171,13 +1171,19 @@ public class FileViewFragment extends BaseFragment implements return; } - fileGetPending = true; - MainActivity.requestPermission( - Manifest.permission.WRITE_EXTERNAL_STORAGE, - MainActivity.REQUEST_STORAGE_PERMISSION, - getString(R.string.storage_permission_rationale_download), - context, - true); + try { + if (context != null) { + fileGetPending = true; + MainActivity.requestPermission( + Manifest.permission.WRITE_EXTERNAL_STORAGE, + MainActivity.REQUEST_STORAGE_PERMISSION, + getString(R.string.storage_permission_rationale_download), + context, + true); + } + } catch (IllegalStateException ex) { + // pass + } } else { fileGet(true); } @@ -2082,6 +2088,7 @@ public class FileViewFragment extends BaseFragment implements private void resolveCommentPosters() { if (commentListAdapter != null) { + long st = System.currentTimeMillis();; List urlsToResolve = new ArrayList<>(commentListAdapter.getClaimUrlsToResolve()); if (urlsToResolve.size() > 0) { ResolveTask task = new ResolveTask(urlsToResolve, Lbry.SDK_CONNECTION_STRING, null, new ClaimListResultHandler() { @@ -2723,7 +2730,7 @@ public class FileViewFragment extends BaseFragment implements } private void initCommentForm(View root) { - double amount = Comment.COST / Lbryio.LBCUSDRate; + double amount = Comment.LBC_COST; String buttonText = getResources().getQuantityString(R.plurals.post_for_credits, amount == 1 ? 1 : 2, Helper.LBC_CURRENCY_FORMAT.format(amount)); buttonPostComment.setText(buttonText); textCommentLimit.setText(String.format("%d / %d", Helper.getValue(inputComment.getText()).length(), Comment.MAX_LENGTH)); diff --git a/app/src/main/java/io/lbry/browser/ui/publish/PublishFragment.java b/app/src/main/java/io/lbry/browser/ui/publish/PublishFragment.java index d2dff01b..9dc62832 100644 --- a/app/src/main/java/io/lbry/browser/ui/publish/PublishFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/publish/PublishFragment.java @@ -140,7 +140,7 @@ public class PublishFragment extends BaseFragment implements preview.setSurfaceProvider(cameraPreview.createSurfaceProvider(camera.getCameraInfo())); cameraPreviewInitialized = true; } - } catch (ExecutionException | InterruptedException ex) { + } catch (ExecutionException | IllegalArgumentException | InterruptedException ex) { // pass } } diff --git a/app/src/main/java/io/lbry/browser/ui/publish/PublishesFragment.java b/app/src/main/java/io/lbry/browser/ui/publish/PublishesFragment.java index 95ebd1d6..a84b62b7 100644 --- a/app/src/main/java/io/lbry/browser/ui/publish/PublishesFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/publish/PublishesFragment.java @@ -12,6 +12,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ProgressBar; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; diff --git a/app/src/main/res/layout/fragment_publishes.xml b/app/src/main/res/layout/fragment_publishes.xml index e3af5bb5..ce375030 100644 --- a/app/src/main/res/layout/fragment_publishes.xml +++ b/app/src/main/res/layout/fragment_publishes.xml @@ -43,7 +43,7 @@ android:adjustViewBounds="true" android:src="@drawable/gerbil_happy" /> + It looks like you have not published content to LBRY yet. Record Take a Photo Upload a file