fixes for Play Store crash reports #921
12 changed files with 193 additions and 109 deletions
|
@ -353,7 +353,11 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// workaround to fix dark theme because https://issuetracker.google.com/issues/37124582
|
||||
try {
|
||||
new WebView(this);
|
||||
} catch (Exception ex) {
|
||||
// pass (don't fail initialization on some _weird_ device implementations)
|
||||
}
|
||||
AppCompatDelegate.setDefaultNightMode(isDarkMode() ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
|
||||
|
||||
initKeyStore();
|
||||
|
@ -365,17 +369,20 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
|||
initSpecialRouteMap();
|
||||
|
||||
LbryAnalytics.init(this);
|
||||
try {
|
||||
FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
|
||||
@Override
|
||||
public void onComplete(Task<InstanceIdResult> task) {
|
||||
if (!task.isSuccessful()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get new Instance ID token
|
||||
firebaseMessagingToken = task.getResult().getToken();
|
||||
}
|
||||
});
|
||||
} catch (IllegalStateException ex) {
|
||||
// pass
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
dbHelper = new DatabaseHelper(this);
|
||||
|
@ -739,8 +746,13 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
public void openPublishForm(Claim claim) {
|
||||
|
@ -2486,8 +2498,14 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
|||
!startingSignInFlowActivity) {
|
||||
enteringPIPMode = true;
|
||||
PictureInPictureParams params = new PictureInPictureParams.Builder().build();
|
||||
|
||||
try {
|
||||
enterPictureInPictureMode(params);
|
||||
return true;
|
||||
} catch (IllegalStateException ex) {
|
||||
// pass
|
||||
enteringPIPMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -2933,6 +2951,9 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
|||
}
|
||||
|
||||
public static boolean hasPermission(String permission, Context context) {
|
||||
if (context == null) {
|
||||
return false;
|
||||
}
|
||||
return (ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED);
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ public class VerificationActivity extends FragmentActivity implements SignInList
|
|||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
showFetchUserError(error.getMessage());
|
||||
showFetchUserError(error != null ? error.getMessage() : getString(R.string.fetch_current_user_error));
|
||||
hideLoading();
|
||||
}
|
||||
});
|
||||
|
@ -213,7 +213,7 @@ public class VerificationActivity extends FragmentActivity implements SignInList
|
|||
}
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
showFetchUserError(error.getMessage());
|
||||
showFetchUserError(error != null ? error.getMessage() : getString(R.string.fetch_current_user_error));
|
||||
hideLoading();
|
||||
}
|
||||
});
|
||||
|
@ -250,7 +250,7 @@ public class VerificationActivity extends FragmentActivity implements SignInList
|
|||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
showFetchUserError(error.getMessage());
|
||||
showFetchUserError(error != null ? error.getMessage() : getString(R.string.fetch_current_user_error));
|
||||
hideLoading();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -231,6 +231,11 @@ public class RepostClaimDialogFragment extends BottomSheetDialogFragment impleme
|
|||
}
|
||||
|
||||
Claim channel = (Claim) channelSpinner.getSelectedItem();
|
||||
if (channel == null) {
|
||||
showError(getString(R.string.please_select_repost_channel));
|
||||
return;
|
||||
}
|
||||
|
||||
StreamRepostTask task = new StreamRepostTask(name, bid, claim.getClaimId(), channel.getClaimId(), repostProgress, new ClaimResultHandler() {
|
||||
@Override
|
||||
public void beforeStart() {
|
||||
|
@ -256,11 +261,14 @@ public class RepostClaimDialogFragment extends BottomSheetDialogFragment impleme
|
|||
}
|
||||
|
||||
private void showError(String message) {
|
||||
Snackbar.make(getView(), message, Snackbar.LENGTH_LONG).
|
||||
View view = getView();
|
||||
if (view != null && !Helper.isNullOrEmpty(message)) {
|
||||
Snackbar.make(view, message, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).
|
||||
setTextColor(Color.WHITE).
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
private void startLoading() {
|
||||
Dialog dialog = getDialog();
|
||||
|
|
|
@ -91,11 +91,13 @@ public class SendTipDialogFragment extends BottomSheetDialogFragment implements
|
|||
|
||||
TextView infoText = view.findViewById(R.id.tip_info);
|
||||
infoText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
if (claim != null) {
|
||||
infoText.setText(HtmlCompat.fromHtml(
|
||||
Claim.TYPE_CHANNEL.equalsIgnoreCase(claim.getValueType()) ?
|
||||
getString(R.string.send_tip_info_channel, claim.getTitleOrName()) :
|
||||
getString(R.string.send_tip_info_content, claim.getTitleOrName()),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||
}
|
||||
|
||||
sendButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -55,6 +55,7 @@ public class LoadGalleryItemsTask extends AsyncTask<Void, GalleryItem, List<Gall
|
|||
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
||||
projection, null, null,
|
||||
String.format("%s DESC LIMIT 150", MediaStore.MediaColumns.DATE_MODIFIED));
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
int idColumn = cursor.getColumnIndex(MediaStore.MediaColumns._ID);
|
||||
int nameColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
|
||||
|
@ -70,6 +71,7 @@ public class LoadGalleryItemsTask extends AsyncTask<Void, GalleryItem, List<Gall
|
|||
item.setDuration(cursor.getLong(durationColumn));
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
} catch (SQLiteException ex) {
|
||||
// failed to load videos. log and pass
|
||||
Log.e(TAG, ex.getMessage(), ex);
|
||||
|
|
|
@ -254,7 +254,13 @@ public class ChannelFormFragment extends BaseFragment implements
|
|||
|
||||
private void checkParams() {
|
||||
Map<String, Object> params = getParams();
|
||||
if (params.containsKey("claim")) {
|
||||
if (params == null) {
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context).onBackPressed();
|
||||
return;
|
||||
}
|
||||
} else if (params.containsKey("claim")) {
|
||||
Claim claim = (Claim) params.get("claim");
|
||||
if (claim != null && !claim.equals(this.currentClaim)) {
|
||||
this.currentClaim = claim;
|
||||
|
|
|
@ -780,7 +780,10 @@ public class FileViewFragment extends BaseFragment implements
|
|||
dialog.setListener(new RepostClaimDialogFragment.RepostClaimListener() {
|
||||
@Override
|
||||
public void onClaimReposted(Claim claim) {
|
||||
Snackbar.make(root.findViewById(R.id.file_view_claim_display_area), R.string.content_successfully_reposted, Snackbar.LENGTH_LONG).show();
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context).showMessage(R.string.content_successfully_reposted);
|
||||
}
|
||||
}
|
||||
});
|
||||
Context context = getContext();
|
||||
|
@ -1352,7 +1355,7 @@ public class FileViewFragment extends BaseFragment implements
|
|||
root.findViewById(R.id.file_view_exoplayer_container).setVisibility(View.GONE);
|
||||
root.findViewById(R.id.file_view_unsupported_container).setVisibility(View.VISIBLE);
|
||||
String fileNameString = "";
|
||||
if (claim.getFile() != null) {
|
||||
if (claim.getFile() != null && !Helper.isNullOrEmpty(claim.getFile().getDownloadPath())) {
|
||||
LbryFile lbryFile = claim.getFile();
|
||||
File file = new File(lbryFile.getDownloadPath());
|
||||
fileNameString = String.format("\"%s\" ", file.getName());
|
||||
|
|
|
@ -581,6 +581,7 @@ public class PublishFormFragment extends BaseFragment implements
|
|||
private void updateFieldsFromCurrentClaim() {
|
||||
if (currentClaim != null && !editFieldsLoaded) {
|
||||
Context context = getContext();
|
||||
try {
|
||||
Claim.StreamMetadata metadata = (Claim.StreamMetadata) currentClaim.getValue();
|
||||
uploadedThumbnailUrl = currentClaim.getThumbnailUrl();
|
||||
if (context != null && !Helper.isNullOrEmpty(uploadedThumbnailUrl)) {
|
||||
|
@ -633,6 +634,10 @@ public class PublishFormFragment extends BaseFragment implements
|
|||
inputAddress.setEnabled(false);
|
||||
editMode = true;
|
||||
editFieldsLoaded = true;
|
||||
} catch (ClassCastException ex) {
|
||||
// invalid claim value type
|
||||
cancelOnFatalCondition(getString(R.string.publish_invalid_claim_type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1415,8 +1420,11 @@ public class PublishFormFragment extends BaseFragment implements
|
|||
@Override
|
||||
public void onFilePicked(String filePath) {
|
||||
if (Helper.isNullOrEmpty(filePath)) {
|
||||
Snackbar.make(getView(), R.string.undetermined_image_filepath, Snackbar.LENGTH_LONG).setBackgroundTint(
|
||||
ContextCompat.getColor(getContext(), R.color.red)).show();
|
||||
View view = getView();
|
||||
if (view != null) {
|
||||
Snackbar.make(view, R.string.undetermined_image_filepath, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,8 +70,12 @@ public class EmailVerificationFragment extends Fragment {
|
|||
inputEmail.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean hasFocus) {
|
||||
try {
|
||||
String layoutHint = !hasFocus ? "" : getString(R.string.email);
|
||||
inputLayoutEmail.setHint(layoutHint);
|
||||
} catch (IllegalStateException ex) {
|
||||
// pass
|
||||
}
|
||||
}
|
||||
});
|
||||
buttonContinue.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -98,9 +102,12 @@ public class EmailVerificationFragment extends Fragment {
|
|||
|
||||
private void addEmail() {
|
||||
currentEmail = Helper.getValue(inputEmail.getText());
|
||||
if (Helper.isNullOrEmpty(currentEmail) || currentEmail.indexOf("@") == -1) {
|
||||
Snackbar.make(getView(), R.string.provide_valid_email, Snackbar.LENGTH_LONG).
|
||||
if (Helper.isNullOrEmpty(currentEmail) || !currentEmail.contains("@")) {
|
||||
View view = getView();
|
||||
if (view != null) {
|
||||
Snackbar.make(view, R.string.provide_valid_email, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -136,8 +143,11 @@ public class EmailVerificationFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
View view = getView();
|
||||
if (view != null && error != null) {
|
||||
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
};
|
||||
Helper.setViewVisibility(buttonContinue, View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
@ -194,14 +204,20 @@ public class EmailVerificationFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Snackbar.make(getView(), R.string.please_follow_instructions, Snackbar.LENGTH_LONG).show();
|
||||
View view = getView();
|
||||
if (view != null) {
|
||||
Snackbar.make(view, R.string.please_follow_instructions, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
Helper.setViewEnabled(buttonResend, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).
|
||||
View view = getView();
|
||||
if (view != null && error != null) {
|
||||
Snackbar.make(view, error.getMessage(), Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
Helper.setViewEnabled(buttonResend, true);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -409,14 +409,22 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
|
|||
// wallet_send task
|
||||
String recipientAddress = Helper.getValue(inputSendAddress.getText());
|
||||
String amountString = Helper.getValue(inputSendAmount.getText());
|
||||
String amount = new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).
|
||||
String amount = null;
|
||||
try {
|
||||
amount = new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).
|
||||
format(new BigDecimal(amountString).doubleValue());
|
||||
} catch (NumberFormatException ex) {
|
||||
Snackbar.make(getView(), R.string.invalid_amount, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
return;
|
||||
}
|
||||
|
||||
disableSendControls();
|
||||
double actualSendAmount = Double.valueOf(amount);
|
||||
WalletSendTask task = new WalletSendTask(recipientAddress, amount, walletSendProgress, new WalletSendTask.WalletSendHandler() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
double sentAmount = Double.valueOf(amount);
|
||||
double sentAmount = actualSendAmount;
|
||||
String message = getResources().getQuantityString(
|
||||
R.plurals.you_sent_credits, sentAmount == 1.0 ? 1 : 2,
|
||||
new DecimalFormat("#,###.##").format(sentAmount));
|
||||
|
@ -530,8 +538,11 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
|
|||
}
|
||||
@Override
|
||||
public void onSuccess(String newAddress) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
sp.edit().putString(MainActivity.PREFERENCE_KEY_INTERNAL_WALLET_RECEIVE_ADDRESS, newAddress).apply();
|
||||
}
|
||||
Helper.setViewText(textWalletReceiveAddress, newAddress);
|
||||
Helper.setViewEnabled(buttonGetNewAddress, true);
|
||||
}
|
||||
|
|
|
@ -66,6 +66,10 @@ public class LbryUri {
|
|||
REGEX_PART_MODIFIER_SEPARATOR));
|
||||
|
||||
String cleanUrl = url, queryString = null;
|
||||
if (Helper.isNullOrEmpty(url)) {
|
||||
throw new LbryUriException("Invalid url parameter.");
|
||||
}
|
||||
|
||||
Matcher qsMatcher = PATTERN_SEPARATE_QUERY_STRING.matcher(url);
|
||||
if (qsMatcher.matches()) {
|
||||
queryString = qsMatcher.group(2);
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
<string name="confirm_delete_content_message">Are you sure you want to unpublish this content? No files will be removed from your device.</string>
|
||||
<string name="content_deleted">The content was successfully deleted from the blockchain.</string>
|
||||
<string name="content_failed_delete">The content could not be deleted at this time. Please try again later.</string>
|
||||
<string name="please_select_repost_channel">Please select a channel to repost on.</string>
|
||||
<plurals name="view_count">
|
||||
<item quantity="one">%1$s view</item>
|
||||
<item quantity="other">%1$s views</item>
|
||||
|
@ -123,6 +124,7 @@
|
|||
<string name="show_extra_fields">Show extra fields</string>
|
||||
<string name="hide_extra_fields">Hide extra fields</string>
|
||||
<string name="no_file_found">No file found to publish.</string>
|
||||
<string name="publish_invalid_claim_type">Invalid claim specified for editing.</string>
|
||||
<string name="video_optimization">Video optimization</string>
|
||||
<string name="thumbnail_creation_failed">A thumbnail could not be automatically created from your content file.</string>
|
||||
<string name="video_being_optimized">Your video is being optimized for better support on a wide range of devices. You can fill out the remaining fields below while this is in progress.</string>
|
||||
|
@ -391,6 +393,7 @@
|
|||
<string name="verify">Verify</string>
|
||||
<string name="please_enter_valid_phone">Please enter a valid phone number.</string>
|
||||
<string name="please_enter_verification_code">Please enter the verification code sent to your phone number.</string>
|
||||
<string name="fetch_current_user_error">User account could not be retrieved at this time. Please try again later.</string>
|
||||
|
||||
<!-- Forms -->
|
||||
<string name="no_added_tags">You have not added any tags yet. Add tags to improve discovery.</string>
|
||||
|
|
Loading…
Reference in a new issue