Compare commits

...
14 Commits
Author SHA1 Message Date
Akinwale Ariwodola 85ed2da518 fixes for Play Store crash reports 2020-05-31 16:19:33 +01:00
Clayton Hickey dcc91f75cc Added ability to read comments on claims (#920)
* Added ability to read comments on claims
* Added simple handling for pagination in CommentListTask
2020-05-30 00:47:50 +01:00
Akinwale Ariwodola a40c160ac6 fix selection mode for reposts on Publishes page 2020-05-28 03:45:56 +01:00
Akinwale Ariwodola e6861c8436 set timestamp when building claim object from edited claim 2020-05-28 03:25:42 +01:00
Akinwale Ariwodola e6a5d97fb8 bumpversion 0.15.8 --> 0.15.9 2020-05-28 03:23:45 +01:00
Akinwale Ariwodola ddeb209d51 fix publish release time and crash bug on publish form 2020-05-28 03:22:20 +01:00
Akinwale Ariwodola 3283b3a607 fix channel links on history page 2020-05-27 23:22:08 +01:00
Akinwale Ariwodola 83a41ca6ce auto-rotate video to sensor landscape orientation 2020-05-27 23:16:25 +01:00
Akinwale Ariwodola 6c63eb7d66 better handling of permanent storage permission denial on file view page 2020-05-27 23:11:09 +01:00
Akinwale Ariwodola 7cf9de8c2a fix typo 2020-05-27 23:01:00 +01:00
Akinwale Ariwodola a859682954 fix permission request handling for permanently denied permissions 2020-05-27 22:56:07 +01:00
Akinwale Ariwodola c844c4f896 fix PIP mode display for Android version < 10 2020-05-27 11:20:51 +01:00
Akinwale Ariwodola a49cfe91da remove debug logs 2020-05-27 10:58:28 +01:00
Akinwale Ariwodola 2bacba2c87 properly close all activities when service is stopped 2020-05-27 10:52:25 +01:00
29 changed files with 759 additions and 158 deletions

No files matched your search

+2 -2
View File
@@ -16,8 +16,8 @@ android {
applicationId "io.lbry.browser"
minSdkVersion 21
targetSdkVersion 29
versionCode 1507
versionName "0.15.7"
versionCode 1509
versionName "0.15.9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -10,7 +10,6 @@ import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.text.HtmlCompat;
@@ -20,10 +19,11 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry;
import io.lbry.browser.utils.LbryAnalytics;
import io.lbry.browser.utils.Lbryio;
import io.lbry.lbrysdk.LbrynetService;
public class FirstRunActivity extends AppCompatActivity {
private BroadcastReceiver sdkReadyReceiver;
private BroadcastReceiver sdkReceiver;
private BroadcastReceiver authReceiver;
@Override
@@ -45,19 +45,26 @@ public class FirstRunActivity extends AppCompatActivity {
registerAuthReceiver();
if (!Lbry.SDK_READY) {
findViewById(R.id.welcome_wait_container).setVisibility(View.VISIBLE);
IntentFilter filter = new IntentFilter();
filter.addAction(MainActivity.ACTION_SDK_READY);
sdkReadyReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// authenticate after we receive the sdk ready event
authenticate();
}
};
registerReceiver(sdkReadyReceiver, filter);
} else {
authenticate();
}
IntentFilter filter = new IntentFilter();
filter.addAction(MainActivity.ACTION_SDK_READY);
filter.addAction(LbrynetService.ACTION_STOP_SERVICE);
sdkReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (MainActivity.ACTION_SDK_READY.equals(action)) {
// authenticate after we receive the sdk ready event
authenticate();
} else if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) {
finish();
}
}
};
registerReceiver(sdkReceiver, filter);
}
public void onResume() {
@@ -122,7 +129,7 @@ public class FirstRunActivity extends AppCompatActivity {
@Override
protected void onDestroy() {
Helper.unregisterReceiver(authReceiver, this);
Helper.unregisterReceiver(sdkReadyReceiver, this);
Helper.unregisterReceiver(sdkReceiver, this);
super.onDestroy();
}
@@ -115,6 +115,7 @@ import io.lbry.browser.listener.DownloadActionListener;
import io.lbry.browser.listener.FetchChannelsListener;
import io.lbry.browser.listener.FetchClaimsListener;
import io.lbry.browser.listener.FilePickerListener;
import io.lbry.browser.listener.PIPModeListener;
import io.lbry.browser.listener.ScreenOrientationListener;
import io.lbry.browser.listener.SdkStatusListener;
import io.lbry.browser.listener.StoragePermissionListener;
@@ -316,6 +317,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
private List<CameraPermissionListener> cameraPermissionListeners;
private List<DownloadActionListener> downloadActionListeners;
private List<FilePickerListener> filePickerListeners;
private List<PIPModeListener> pipModeListeners;
private List<ScreenOrientationListener> screenOrientationListeners;
private List<SdkStatusListener> sdkStatusListeners;
private List<StoragePermissionListener> storagePermissionListeners;
@@ -351,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
new WebView(this);
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();
@@ -363,17 +369,20 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
initSpecialRouteMap();
LbryAnalytics.init(this);
FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
@Override
public void onComplete(Task<InstanceIdResult> task) {
if (!task.isSuccessful()) {
return;
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();
}
// Get new Instance ID token
firebaseMessagingToken = task.getResult().getToken();
}
});
});
} catch (IllegalStateException ex) {
// pass
}
super.onCreate(savedInstanceState);
dbHelper = new DatabaseHelper(this);
@@ -393,7 +402,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
return ViewCompat.onApplyWindowInsets(v,
insets.replaceSystemWindowInsets(
insets.getSystemWindowInsetLeft(),
0,
0,
0,
insets.getSystemWindowInsetBottom()));
@@ -426,6 +435,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
fetchChannelsListeners = new ArrayList<>();
fetchClaimsListeners = new ArrayList<>();
filePickerListeners = new ArrayList<>();
pipModeListeners = new ArrayList<>();
screenOrientationListeners = new ArrayList<>();
sdkStatusListeners = new ArrayList<>();
storagePermissionListeners = new ArrayList<>();
@@ -598,6 +608,16 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
filePickerListeners.remove(listener);
}
public void addPIPModeListener(PIPModeListener listener) {
if (!pipModeListeners.contains(listener)) {
pipModeListeners.add(listener);
}
}
public void removePIPModeListener(PIPModeListener listener) {
pipModeListeners.remove(listener);
}
public void addCameraPermissionListener(CameraPermissionListener listener) {
if (!cameraPermissionListeners.contains(listener)) {
cameraPermissionListeners.add(listener);
@@ -726,8 +746,13 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
public void openPublishesOnSuccessfulPublish() {
// close publish form
getSupportFragmentManager().popBackStack();
openFragment(PublishesFragment.class, true, NavMenuItem.ID_ITEM_PUBLISHES);
try {
getSupportFragmentManager().popBackStack();
openFragment(PublishesFragment.class, true, NavMenuItem.ID_ITEM_PUBLISHES);
} catch (IllegalStateException ex) {
// pass
onBackPressed();
}
}
public void openPublishForm(Claim claim) {
@@ -808,6 +833,10 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
findViewById(R.id.app_bar_main_container).setFitsSystemWindows(true);
hideActionBar();
for (PIPModeListener listener : pipModeListeners) {
listener.onEnterPIPMode();
}
PlayerView pipPlayer = findViewById(R.id.pip_player);
pipPlayer.setVisibility(View.VISIBLE);
pipPlayer.setPlayer(appPlayer);
@@ -838,6 +867,9 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
if (!Lbry.SDK_READY && !inFullscreenMode) {
findViewById(R.id.global_sdk_initializing_status).setVisibility(View.VISIBLE);
}
for (PIPModeListener listener : pipModeListeners) {
listener.onExitPIPMode();
}
PlayerView pipPlayer = findViewById(R.id.pip_player);
pipPlayer.setVisibility(View.INVISIBLE);
@@ -921,7 +953,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
applyNavbarSigninPadding();
checkFirstRun();
checkNowPlaying();
fetchRewards();
// check (and start) the LBRY SDK service
serviceRunning = isServiceRunning(this, LbrynetService.class);
@@ -997,7 +1028,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
public boolean canShowUrlSuggestions() {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
return sp.getBoolean(MainActivity.PREFERENCE_KEY_SHOW_URL_SUGGESTIONS, false);
return sp.getBoolean(MainActivity.PREFERENCE_KEY_SHOW_URL_SUGGESTIONS, true);
}
public boolean keepSdkBackground() {
@@ -1369,6 +1400,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
}
findViewById(R.id.global_sdk_initializing_status).setVisibility(View.GONE);
findViewById(R.id.app_bar_main_container).setFitsSystemWindows(false);
lockDrawer();
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
@@ -1405,6 +1437,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
if (actionBar != null) {
actionBar.show();
}
unlockDrawer();
inFullscreenMode = false;
}
@@ -1422,13 +1455,18 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
boolean firstRunCompleted = sp.getBoolean(PREFERENCE_KEY_INTERNAL_FIRST_RUN_COMPLETED, false);
if (!firstRunCompleted) {
findViewById(R.id.drawer_layout).setVisibility(View.INVISIBLE);
startActivity(new Intent(this, FirstRunActivity.class));
} else if (!appStarted) {
return;
}
if (!appStarted) {
// first run completed, startup
startup();
return;
}
fetchRewards();
if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
openFragment(FollowingFragment.class, false, NavMenuItem.ID_ITEM_FOLLOWING);
}
@@ -1492,7 +1530,11 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
initFloatingWalletBalance();
checkAndClaimNewAndroidReward();
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
boolean firstRunCompleted = sp.getBoolean(PREFERENCE_KEY_INTERNAL_FIRST_RUN_COMPLETED, false);
if (firstRunCompleted) {
checkAndClaimNewAndroidReward();
}
}
public void checkAndClaimNewAndroidReward() {
@@ -2196,6 +2238,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
hideActionBar();
lockDrawer();
findViewById(R.id.splash_view).setVisibility(View.VISIBLE);
findViewById(R.id.drawer_layout).setVisibility(View.VISIBLE);
LbryAnalytics.setCurrentScreen(MainActivity.this, "Splash", "Splash");
initStartupStages();
}
@@ -2455,8 +2498,14 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
!startingSignInFlowActivity) {
enteringPIPMode = true;
PictureInPictureParams params = new PictureInPictureParams.Builder().build();
enterPictureInPictureMode(params);
return true;
try {
enterPictureInPictureMode(params);
return true;
} catch (IllegalStateException ex) {
// pass
enteringPIPMode = false;
}
}
return false;
@@ -2886,16 +2935,25 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
public static void requestPermission(String permission, int requestCode, String rationale, Context context, boolean forceRequest) {
if (ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
if (!forceRequest && ActivityCompat.shouldShowRequestPermissionRationale((Activity) context, permission)) {
Toast.makeText(context, rationale, Toast.LENGTH_LONG).show();
} else {
if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) context, permission)) {
if (context instanceof MainActivity) {
((MainActivity) context).showMessage(rationale);
}
} else if (forceRequest) {
startingPermissionRequest = true;
ActivityCompat.requestPermissions((Activity) context, new String[] { permission }, requestCode);
} else {
if (context instanceof MainActivity) {
((MainActivity) context).showError(rationale);
}
}
}
}
public static boolean hasPermission(String permission, Context context) {
if (context == null) {
return false;
}
return (ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED);
}
@@ -1,6 +1,9 @@
package io.lbry.browser;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -18,8 +21,10 @@ import io.lbry.browser.listener.SignInListener;
import io.lbry.browser.listener.WalletSyncListener;
import io.lbry.browser.model.lbryinc.User;
import io.lbry.browser.tasks.lbryinc.FetchCurrentUserTask;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.LbryAnalytics;
import io.lbry.browser.utils.Lbryio;
import io.lbry.lbrysdk.LbrynetService;
public class VerificationActivity extends FragmentActivity implements SignInListener, WalletSyncListener {
@@ -27,6 +32,7 @@ public class VerificationActivity extends FragmentActivity implements SignInList
public static final int VERIFICATION_FLOW_REWARDS = 2;
public static final int VERIFICATION_FLOW_WALLET = 3;
private BroadcastReceiver sdkReceiver;
private String email;
private boolean signedIn;
private int flow;
@@ -54,6 +60,19 @@ public class VerificationActivity extends FragmentActivity implements SignInList
return;
}
IntentFilter filter = new IntentFilter();
filter.addAction(LbrynetService.ACTION_STOP_SERVICE);
sdkReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) {
finish();
}
}
};
registerReceiver(sdkReceiver, filter);
setContentView(R.layout.activity_verification);
ViewPager2 viewPager = findViewById(R.id.verification_pager);
viewPager.setUserInputEnabled(false);
@@ -158,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();
}
});
@@ -194,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();
}
});
@@ -231,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();
}
});
@@ -269,4 +288,10 @@ public class VerificationActivity extends FragmentActivity implements SignInList
public void onWalletSyncFailed(Exception error) {
findViewById(R.id.verification_close_button).setVisibility(View.VISIBLE);
}
@Override
public void onDestroy() {
Helper.unregisterReceiver(sdkReceiver, this);
super.onDestroy();
}
}
@@ -327,7 +327,7 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
}
boolean isPending = item.getConfirmations() == 0;
boolean isSelected = isClaimSelected(item);
boolean isSelected = isClaimSelected(original);
vh.itemView.setSelected(isSelected);
vh.selectedOverlayView.setVisibility(isSelected ? View.VISIBLE : View.GONE);
vh.itemView.setOnClickListener(new View.OnClickListener() {
@@ -0,0 +1,52 @@
package io.lbry.browser.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List;
import androidx.recyclerview.widget.RecyclerView;
import io.lbry.browser.R;
import io.lbry.browser.model.Comment;
public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.ViewHolder> {
private List<Comment> items;
private Context context;
public CommentListAdapter(List<Comment> items, Context context) {
this.items = items;
this.context = context;
}
@Override
public int getItemCount() {
return items != null ? items.size() : 0;
}
public static class ViewHolder extends RecyclerView.ViewHolder {
protected TextView channelName;
protected TextView commentText;
public ViewHolder (View v) {
super(v);
channelName = v.findViewById(R.id.comment_channel_name);
commentText = v.findViewById(R.id.comment_text);
}
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(context).inflate(R.layout.list_item_comment, parent, false);
return new CommentListAdapter.ViewHolder(v);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Comment comment = items.get(position);
holder.channelName.setText(comment.getChannelName());
holder.commentText.setText(comment.getText());
}
}
@@ -44,7 +44,7 @@ public class InlineChannelSpinnerAdapter extends ArrayAdapter<Claim> {
public int getItemPosition(Claim item) {
for (int i = 0; i < channels.size(); i++) {
Claim channel = channels.get(i);
if (item.getClaimId().equalsIgnoreCase(channel.getClaimId())) {
if (item.getClaimId() != null && item.getClaimId().equalsIgnoreCase(channel.getClaimId())) {
return i;
}
}
@@ -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,10 +261,13 @@ public class RepostClaimDialogFragment extends BottomSheetDialogFragment impleme
}
private void showError(String message) {
Snackbar.make(getView(), message, Snackbar.LENGTH_LONG).
setBackgroundTint(Color.RED).
setTextColor(Color.WHITE).
show();
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() {
@@ -91,11 +91,13 @@ public class SendTipDialogFragment extends BottomSheetDialogFragment implements
TextView infoText = view.findViewById(R.id.tip_info);
infoText.setMovementMethod(LinkMovementMethod.getInstance());
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));
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
@@ -0,0 +1,6 @@
package io.lbry.browser.listener;
public interface PIPModeListener {
void onEnterPIPMode();
void onExitPIPMode();
}
@@ -289,6 +289,9 @@ public class Claim {
Claim signingChannel = new Claim();
signingChannel.setClaimId(viewHistory.getPublisherClaimId());
signingChannel.setName(viewHistory.getPublisherName());
LbryUri channelUrl = LbryUri.tryParse(String.format("%s#%s", signingChannel.getName(), signingChannel.getClaimId()));
signingChannel.setPermanentUrl(channelUrl != null ? channelUrl.toString() : null);
if (!Helper.isNullOrEmpty(viewHistory.getPublisherTitle())) {
GenericMetadata channelValue = new GenericMetadata();
channelValue.setTitle(viewHistory.getPublisherTitle());
@@ -0,0 +1,40 @@
package io.lbry.browser.model;
import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
import lombok.Data;
@Data
public class Comment {
private final String channelName, text, id, parentId;
public Comment(String channelName, String text, String id, String parentId) {
this.channelName = channelName;
this.text = text;
this.id = id;
this.parentId = parentId;
}
public static Comment fromJSONObject(JSONObject jsonObject) {
try {
String parentId = null;
if (jsonObject.has("parent_id")) {
parentId = jsonObject.getString("parent_id");
}
return new Comment(
jsonObject.getString("channel_name"),
jsonObject.getString("comment"),
jsonObject.getString("comment_id"),
parentId
);
} catch (JSONException ex) {
// TODO: Throw exception
Log.e("Comments", ex.toString());
return null;
}
}
}
@@ -0,0 +1,10 @@
package io.lbry.browser.tasks;
import java.util.List;
import io.lbry.browser.model.Comment;
public interface CommentListHandler {
void onSuccess(List<Comment> comments);
void onError(Exception error);
}
@@ -0,0 +1,77 @@
package io.lbry.browser.tasks;
import android.os.AsyncTask;
import android.view.View;
import android.widget.ProgressBar;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.lbry.browser.model.Comment;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry;
public class CommentListTask extends AsyncTask<Void, Void, List<Comment>> {
private final int page;
private final int pageSize;
private final String claim;
private ProgressBar progressBar;
private CommentListHandler handler;
private Exception error;
public CommentListTask(int page, int pageSize, String claim, ProgressBar progressBar, CommentListHandler handler) {
this.page = page;
this.pageSize = pageSize;
this.claim = claim;
this.progressBar = progressBar;
this.handler = handler;
}
protected void onPreExecute() {
Helper.setViewVisibility(progressBar, View.VISIBLE);
}
protected List<Comment> doInBackground(Void... voids) {
List<Comment> comments = null;
try {
Map<String, Object> options = new HashMap<>();
options.put("claim_id", claim);
options.put("page", page);
options.put("page_size", pageSize);
options.put("include_replies", false);
options.put("is_channel_signature_valid", true);
options.put("visible", true);
options.put("hidden", false);
JSONObject result = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_COMMENT_LIST, options);
JSONArray items = result.getJSONArray("items");
comments = new ArrayList<>();
for (int i = 0; i < items.length(); i++) {
comments.add(Comment.fromJSONObject(items.getJSONObject(i)));
}
} catch (Exception ex) {
error = ex;
}
return comments;
}
protected void onPostExecute(List<Comment> comments) {
Helper.setViewVisibility(progressBar, View.GONE);
if (handler != null) {
if (comments != null && error == null) {
handler.onSuccess(comments);
} else {
handler.onError(error);
if (error != null) {
}
}
}
}
}
@@ -73,6 +73,14 @@ public class PublishClaimTask extends AsyncTask<Void, Void, Claim> {
options.put("license_url", metadata.getLicenseUrl());
}
if (metadata.getReleaseTime() > 0) {
options.put("release_time", metadata.getReleaseTime());
} else if (claim.getTimestamp() > 0) {
options.put("release_time", claim.getTimestamp());
} else {
options.put("release_time", Double.valueOf(Math.floor(System.currentTimeMillis() / 1000.0)).intValue());
}
Claim claimResult = null;
try {
JSONObject result = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_PUBLISH, options);
@@ -55,20 +55,22 @@ 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));
while (cursor.moveToNext()) {
int idColumn = cursor.getColumnIndex(MediaStore.MediaColumns._ID);
int nameColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
int typeColumn = cursor.getColumnIndex(MediaStore.MediaColumns.MIME_TYPE);
int pathColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DATA);
int durationColumn = cursor.getColumnIndex(MediaStore.Video.Media.DURATION);
if (cursor != null) {
while (cursor.moveToNext()) {
int idColumn = cursor.getColumnIndex(MediaStore.MediaColumns._ID);
int nameColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
int typeColumn = cursor.getColumnIndex(MediaStore.MediaColumns.MIME_TYPE);
int pathColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DATA);
int durationColumn = cursor.getColumnIndex(MediaStore.Video.Media.DURATION);
GalleryItem item = new GalleryItem();
item.setId(cursor.getString(idColumn));
item.setName(cursor.getString(nameColumn));
item.setType(cursor.getString(typeColumn));
item.setFilePath(cursor.getString(pathColumn));
item.setDuration(cursor.getLong(durationColumn));
items.add(item);
GalleryItem item = new GalleryItem();
item.setId(cursor.getString(idColumn));
item.setName(cursor.getString(nameColumn));
item.setType(cursor.getString(typeColumn));
item.setFilePath(cursor.getString(pathColumn));
item.setDuration(cursor.getLong(durationColumn));
items.add(item);
}
}
} catch (SQLiteException ex) {
// failed to load videos. log and pass
@@ -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;
@@ -9,7 +9,6 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -31,7 +30,6 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
@@ -91,18 +89,21 @@ import java.util.concurrent.TimeUnit;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.adapter.ClaimListAdapter;
import io.lbry.browser.adapter.CommentListAdapter;
import io.lbry.browser.adapter.TagListAdapter;
import io.lbry.browser.dialog.RepostClaimDialogFragment;
import io.lbry.browser.dialog.SendTipDialogFragment;
import io.lbry.browser.exceptions.LbryUriException;
import io.lbry.browser.listener.DownloadActionListener;
import io.lbry.browser.listener.FetchClaimsListener;
import io.lbry.browser.listener.PIPModeListener;
import io.lbry.browser.listener.ScreenOrientationListener;
import io.lbry.browser.listener.SdkStatusListener;
import io.lbry.browser.listener.StoragePermissionListener;
import io.lbry.browser.listener.WalletBalanceListener;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.ClaimCacheKey;
import io.lbry.browser.model.Comment;
import io.lbry.browser.model.Fee;
import io.lbry.browser.model.LbryFile;
import io.lbry.browser.model.NavMenuItem;
@@ -111,6 +112,8 @@ import io.lbry.browser.model.UrlSuggestion;
import io.lbry.browser.model.WalletBalance;
import io.lbry.browser.model.lbryinc.Reward;
import io.lbry.browser.model.lbryinc.Subscription;
import io.lbry.browser.tasks.CommentListHandler;
import io.lbry.browser.tasks.CommentListTask;
import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.tasks.LighthouseSearchTask;
import io.lbry.browser.tasks.ReadTextFileTask;
@@ -140,8 +143,10 @@ import io.lbry.lbrysdk.LbrynetService;
import io.lbry.lbrysdk.Utils;
public class FileViewFragment extends BaseFragment implements
MainActivity.BackPressInterceptor, DownloadActionListener,
MainActivity.BackPressInterceptor,
DownloadActionListener,
FetchClaimsListener,
PIPModeListener,
ScreenOrientationListener,
SdkStatusListener,
StoragePermissionListener,
@@ -163,6 +168,7 @@ public class FileViewFragment extends BaseFragment implements
private Claim claim;
private String currentUrl;
private ClaimListAdapter relatedContentAdapter;
private CommentListAdapter commentListAdapter;
private BroadcastReceiver sdkReceiver;
private Player.EventListener fileViewPlayerListener;
@@ -174,6 +180,7 @@ public class FileViewFragment extends BaseFragment implements
private long startTimeMillis;
private GetFileTask getFileTask;
private boolean storagePermissionRefusedOnce;
private View buttonPublishSomething;
private View layoutLoadingState;
private View layoutNothingAtLocation;
@@ -240,6 +247,7 @@ public class FileViewFragment extends BaseFragment implements
activity.setBackPressInterceptor(this);
activity.addDownloadActionListener(this);
activity.addFetchClaimsListener(this);
activity.addPIPModeListener(this);
activity.addScreenOrientationListener(this);
activity.addWalletBalanceListener(this);
if (!MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
@@ -314,6 +322,7 @@ public class FileViewFragment extends BaseFragment implements
if (claim != null) {
Helper.saveViewHistory(currentUrl, claim);
checkAndLoadRelatedContent();
checkAndLoadComments();
renderClaim();
if (claim.getFile() == null) {
loadFile();
@@ -448,6 +457,7 @@ public class FileViewFragment extends BaseFragment implements
loadFile();
}
checkOwnClaim();
checkAndLoadComments();
}
private String getStreamingUrl() {
@@ -529,6 +539,7 @@ public class FileViewFragment extends BaseFragment implements
if (claim != null) {
Helper.saveViewHistory(url, claim);
checkAndLoadRelatedContent();
checkAndLoadComments();
renderClaim();
}
}
@@ -568,7 +579,7 @@ public class FileViewFragment extends BaseFragment implements
loadAndScheduleDurations();
}
if (Lbry.SDK_READY) {
if (!Lbry.SDK_READY) {
if (context instanceof MainActivity) {
((MainActivity) context).addSdkStatusListener(this);
}
@@ -584,6 +595,7 @@ public class FileViewFragment extends BaseFragment implements
MainActivity activity = (MainActivity) context;
activity.removeDownloadActionListener(this);
activity.removeFetchClaimsListener(this);
activity.removePIPModeListener(this);
activity.removeScreenOrientationListener(this);
activity.removeSdkStatusListener(this);
activity.removeStoragePermissionListener(this);
@@ -648,6 +660,7 @@ public class FileViewFragment extends BaseFragment implements
loadFile();
checkAndLoadRelatedContent();
checkAndLoadComments();
renderClaim();
} else {
// render nothing at location
@@ -767,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();
@@ -985,9 +1001,13 @@ public class FileViewFragment extends BaseFragment implements
});
RecyclerView relatedContentList = root.findViewById(R.id.file_view_related_content_list);
RecyclerView commentsList = root.findViewById(R.id.file_view_comments_list);
relatedContentList.setNestedScrollingEnabled(false);
LinearLayoutManager llm = new LinearLayoutManager(getContext());
relatedContentList.setLayoutManager(llm);
commentsList.setNestedScrollingEnabled(false);
LinearLayoutManager relatedContentListLLM = new LinearLayoutManager(getContext());
LinearLayoutManager commentsListLLM = new LinearLayoutManager(getContext());
relatedContentList.setLayoutManager(relatedContentListLLM);
commentsList.setLayoutManager(commentsListLLM);
}
private void deleteCurrentClaim() {
@@ -1019,6 +1039,12 @@ public class FileViewFragment extends BaseFragment implements
if (MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
startDownload();
} else {
if (storagePermissionRefusedOnce) {
showStoragePermissionRefusedError();
restoreMainActionButton();
return;
}
startDownloadPending = true;
MainActivity.requestPermission(
Manifest.permission.WRITE_EXTERNAL_STORAGE,
@@ -1032,6 +1058,12 @@ public class FileViewFragment extends BaseFragment implements
private void checkStoragePermissionAndFileGet() {
Context context = getContext();
if (!MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
if (storagePermissionRefusedOnce) {
showStoragePermissionRefusedError();
restoreMainActionButton();
return;
}
fileGetPending = true;
MainActivity.requestPermission(
Manifest.permission.WRITE_EXTERNAL_STORAGE,
@@ -1079,11 +1111,12 @@ public class FileViewFragment extends BaseFragment implements
}
}
public void onStoragePermissionRefused() {
storagePermissionRefusedOnce = true;
fileGetPending = false;
startDownloadPending = false;
onDownloadAborted();
Snackbar.make(getView(), R.string.storage_permission_rationale_download, Snackbar.LENGTH_LONG).
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
showStoragePermissionRefusedError();
}
public void startDownload() {
@@ -1300,13 +1333,29 @@ public class FileViewFragment extends BaseFragment implements
}
}
private void checkAndLoadComments() {
View root = getView();
if (root != null) {
RecyclerView commentsList = root.findViewById(R.id.file_view_comments_list);
if (commentsList == null || commentsList.getAdapter() == null || commentsList.getAdapter().getItemCount() == 0) {
TextView commentsSDKInitializing = root.findViewById(R.id.file_view_comments_sdk_initializing);
if (Lbry.SDK_READY) {
Helper.setViewVisibility(commentsSDKInitializing, View.GONE);
loadComments();
} else {
Helper.setViewVisibility(commentsSDKInitializing, View.VISIBLE);
}
}
}
}
private void showUnsupportedView() {
View root = getView();
if (root != null) {
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());
@@ -1839,6 +1888,39 @@ public class FileViewFragment extends BaseFragment implements
}
}
private void loadComments() {
View root = getView();
ProgressBar relatedLoading = root.findViewById(R.id.file_view_comments_progress);
if (claim != null && root != null) {
CommentListTask relatedTask = new CommentListTask(1, 999, claim.getClaimId(), relatedLoading, new CommentListHandler() {
@Override
public void onSuccess(List<Comment> comments) {
Context ctx = getContext();
if (ctx != null) {
commentListAdapter = new CommentListAdapter(comments, ctx);
View v = getView();
if (v != null) {
RecyclerView relatedContentList = root.findViewById(R.id.file_view_comments_list);
relatedContentList.setAdapter(commentListAdapter);
commentListAdapter.notifyDataSetChanged();
Helper.setViewVisibility(
v.findViewById(R.id.file_view_no_comments),
commentListAdapter == null || commentListAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
}
}
}
@Override
public void onError(Exception error) {
}
});
relatedTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
public boolean onBackPressed() {
if (isInFullscreenMode()) {
disableFullScreenMode();
@@ -1898,7 +1980,7 @@ public class FileViewFragment extends BaseFragment implements
int statusBarHeight = activity.getStatusBarHeight();
exoplayerContainer.setPadding(0, 0, 0, statusBarHeight);
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}
}
@@ -2351,4 +2433,28 @@ public class FileViewFragment extends BaseFragment implements
return Integer.MAX_VALUE;
}
}
public void onEnterPIPMode() {
View root = getView();
if (root != null) {
PlayerView playerView = root.findViewById(R.id.file_view_exoplayer_view);
playerView.setVisibility(View.GONE);
}
}
public void onExitPIPMode() {
View root = getView();
if (root != null) {
PlayerView playerView = root.findViewById(R.id.file_view_exoplayer_view);
playerView.setVisibility(View.VISIBLE);
}
}
private void showStoragePermissionRefusedError() {
View root = getView();
if (root != null) {
Snackbar.make(root, R.string.storage_permission_rationale_download, Snackbar.LENGTH_LONG).
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
}
}
}
@@ -102,6 +102,7 @@ public class PublishFormFragment extends BaseFragment implements
private static final int MAX_VIDEO_DIMENSION = 1920;
private static final int MAX_BITRATE = 5000000; // 5mbps
private boolean storageRefusedOnce;
private static final int SUGGESTED_LIMIT = 8;
private boolean editMode;
@@ -580,58 +581,63 @@ public class PublishFormFragment extends BaseFragment implements
private void updateFieldsFromCurrentClaim() {
if (currentClaim != null && !editFieldsLoaded) {
Context context = getContext();
Claim.StreamMetadata metadata = (Claim.StreamMetadata) currentClaim.getValue();
uploadedThumbnailUrl = currentClaim.getThumbnailUrl();
if (context != null && !Helper.isNullOrEmpty(uploadedThumbnailUrl)) {
Glide.with(context.getApplicationContext()).load(uploadedThumbnailUrl).centerCrop().into(imageThumbnail);
}
inputTitle.setText(currentClaim.getTitle());
inputDescription.setText(currentClaim.getDescription());
if (addedTagsAdapter != null && currentClaim.getTagObjects() != null) {
addedTagsAdapter.addTags(currentClaim.getTagObjects());
updateSuggestedTags(currentFilter, SUGGESTED_LIMIT, true);
}
if (metadata.getFee() != null) {
Fee fee = metadata.getFee();
switchPrice.setChecked(true);
inputPrice.setText(fee.getAmount());
priceCurrencySpinner.setSelection("lbc".equalsIgnoreCase(fee.getCurrency()) ? 0 : 1);
}
inputAddress.setText(currentClaim.getName());
inputDeposit.setText(currentClaim.getAmount());
if (metadata.getLanguages() != null && metadata.getLanguages().size() > 0) {
// get the first language
String langCode = metadata.getLanguages().get(0);
int langCodePosition = ((LanguageSpinnerAdapter) languageSpinner.getAdapter()).getItemPosition(langCode);
if (langCodePosition > -1) {
languageSpinner.setSelection(langCodePosition);
}
}
if (!Helper.isNullOrEmpty(metadata.getLicense())) {
LicenseSpinnerAdapter adapter = (LicenseSpinnerAdapter) licenseSpinner.getAdapter();
int licPosition = adapter.getItemPosition(metadata.getLicense());
if (licPosition == -1) {
licPosition = adapter.getItemPosition(Predefined.LICENSE_OTHER);
}
if (licPosition > -1) {
licenseSpinner.setSelection(licPosition);
try {
Claim.StreamMetadata metadata = (Claim.StreamMetadata) currentClaim.getValue();
uploadedThumbnailUrl = currentClaim.getThumbnailUrl();
if (context != null && !Helper.isNullOrEmpty(uploadedThumbnailUrl)) {
Glide.with(context.getApplicationContext()).load(uploadedThumbnailUrl).centerCrop().into(imageThumbnail);
}
License selectedLicense = (License) licenseSpinner.getSelectedItem();
boolean otherLicense = Arrays.asList(
Predefined.LICENSE_COPYRIGHTED.toLowerCase(),
Predefined.LICENSE_OTHER.toLowerCase()).contains(selectedLicense.getName().toLowerCase());
inputOtherLicenseDescription.setText(otherLicense ? metadata.getLicense() : null);
}
inputTitle.setText(currentClaim.getTitle());
inputDescription.setText(currentClaim.getDescription());
if (addedTagsAdapter != null && currentClaim.getTagObjects() != null) {
addedTagsAdapter.addTags(currentClaim.getTagObjects());
updateSuggestedTags(currentFilter, SUGGESTED_LIMIT, true);
}
inputAddress.setEnabled(false);
editMode = true;
editFieldsLoaded = true;
if (metadata.getFee() != null) {
Fee fee = metadata.getFee();
switchPrice.setChecked(true);
inputPrice.setText(fee.getAmount());
priceCurrencySpinner.setSelection("lbc".equalsIgnoreCase(fee.getCurrency()) ? 0 : 1);
}
inputAddress.setText(currentClaim.getName());
inputDeposit.setText(currentClaim.getAmount());
if (metadata.getLanguages() != null && metadata.getLanguages().size() > 0) {
// get the first language
String langCode = metadata.getLanguages().get(0);
int langCodePosition = ((LanguageSpinnerAdapter) languageSpinner.getAdapter()).getItemPosition(langCode);
if (langCodePosition > -1) {
languageSpinner.setSelection(langCodePosition);
}
}
if (!Helper.isNullOrEmpty(metadata.getLicense())) {
LicenseSpinnerAdapter adapter = (LicenseSpinnerAdapter) licenseSpinner.getAdapter();
int licPosition = adapter.getItemPosition(metadata.getLicense());
if (licPosition == -1) {
licPosition = adapter.getItemPosition(Predefined.LICENSE_OTHER);
}
if (licPosition > -1) {
licenseSpinner.setSelection(licPosition);
}
License selectedLicense = (License) licenseSpinner.getSelectedItem();
boolean otherLicense = Arrays.asList(
Predefined.LICENSE_COPYRIGHTED.toLowerCase(),
Predefined.LICENSE_OTHER.toLowerCase()).contains(selectedLicense.getName().toLowerCase());
inputOtherLicenseDescription.setText(otherLicense ? metadata.getLicense() : null);
}
inputAddress.setEnabled(false);
editMode = true;
editFieldsLoaded = true;
} catch (ClassCastException ex) {
// invalid claim value type
cancelOnFatalCondition(getString(R.string.publish_invalid_claim_type));
}
}
}
@@ -1037,6 +1043,16 @@ public class PublishFormFragment extends BaseFragment implements
metadata.setLicenseUrl(selectedLicense.getUrl());
}
// set release time from current claim (on edit)
if (currentClaim != null) {
Claim.StreamMetadata currentMetadata = (Claim.StreamMetadata) currentClaim.getValue();
metadata.setReleaseTime(currentMetadata.getReleaseTime());
if (metadata.getReleaseTime() == 0) {
metadata.setReleaseTime(currentClaim.getTimestamp());
}
claim.setTimestamp(currentClaim.getTimestamp());
}
claim.setValueType(Claim.TYPE_STREAM);
claim.setValue(metadata);
@@ -1394,15 +1410,21 @@ public class PublishFormFragment extends BaseFragment implements
@Override
public void onStoragePermissionRefused() {
showError(getString(R.string.storage_permission_rationale_images));
if (!storageRefusedOnce) {
showError(getString(R.string.storage_permission_rationale_images));
storageRefusedOnce = true;
}
launchPickerPending = false;
}
@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;
}
@@ -12,7 +12,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.camera.core.Camera;
@@ -53,6 +52,7 @@ public class PublishFragment extends BaseFragment implements
CameraPermissionListener, FilePickerListener, StoragePermissionListener {
private boolean cameraPreviewInitialized;
private boolean storagePermissionRefusedOnce;
private PreviewView cameraPreview;
private RecyclerView galleryGrid;
private GalleryGridAdapter adapter;
@@ -254,7 +254,9 @@ public class PublishFragment extends BaseFragment implements
}
}
checkStoragePermissionAndLoadVideos();
if (!storagePermissionRefusedOnce) {
checkStoragePermissionAndLoadVideos();
}
}
@SuppressLint("RestrictedApi")
@@ -399,8 +401,15 @@ public class PublishFragment extends BaseFragment implements
@Override
public void onStoragePermissionRefused() {
Snackbar.make(getView(), R.string.storage_permission_rationale_videos, Snackbar.LENGTH_LONG).
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
storagePermissionRefusedOnce = true;
View root = getView();
if (root != null) {
Snackbar.make(root, R.string.storage_permission_rationale_videos, Snackbar.LENGTH_LONG).
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
Helper.setViewText(noVideosLoaded, R.string.storage_permission_rationale_videos);
}
checkNoVideosLoaded();
}
public String getSuggestedPublishUrl() {
@@ -239,7 +239,8 @@ public class PublishesFragment extends BaseFragment implements ActionMode.Callba
@Override
public boolean onPrepareActionMode(androidx.appcompat.view.ActionMode actionMode, Menu menu) {
int selectionCount = adapter != null ? adapter.getSelectedCount() : 0;
menu.findItem(R.id.action_edit).setVisible(selectionCount == 1);
menu.findItem(R.id.action_edit).setVisible(selectionCount == 1 &&
Claim.TYPE_STREAM.equalsIgnoreCase(adapter.getSelectedItems().get(0).getValueType()));
return true;
}
@@ -70,8 +70,12 @@ public class EmailVerificationFragment extends Fragment {
inputEmail.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
String layoutHint = !hasFocus ? "" : getString(R.string.email);
inputLayoutEmail.setHint(layoutHint);
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).
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
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) {
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
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).
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
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)).
format(new BigDecimal(amountString).doubleValue());
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());
sp.edit().putString(MainActivity.PREFERENCE_KEY_INTERNAL_WALLET_RECEIVE_ADDRESS, newAddress).apply();
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);
}
@@ -102,6 +102,8 @@ public final class Lbry {
public static final String METHOD_STREAM_ABANDON = "stream_abandon";
public static final String METHOD_STREAM_REPOST = "stream_repost";
public static final String METHOD_COMMENT_LIST = "comment_list";
public static KeyStore KEYSTORE;
public static boolean SDK_READY = false;
@@ -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);
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import io.lbry.browser.BuildConfig;
import io.lbry.browser.MainActivity;
import io.lbry.browser.exceptions.LbryioRequestException;
import io.lbry.browser.exceptions.LbryioResponseException;
@@ -81,6 +82,10 @@ public final class Lbryio {
authToken = getAuthToken(context);
}
/*if (BuildConfig.DEBUG) {
Log.d(TAG, String.format("Using authToken for request: %s", authToken));
}*/
String url = String.format("%s/%s/%s", CONNECTION_STRING, resource, action);
if (Helper.METHOD_GET.equalsIgnoreCase(method)) {
Uri.Builder uriBuilder = Uri.parse(url).buildUpon();
@@ -94,6 +99,9 @@ public final class Lbryio {
}
url = uriBuilder.build().toString();
}
/*if (BuildConfig.DEBUG) {
Log.d(TAG, String.format("Request Method: %s, Sending request to URL: %s", method, url));
}*/
Request.Builder builder = new Request.Builder().url(url);
if (Helper.METHOD_POST.equalsIgnoreCase(method)) {
@@ -142,6 +150,9 @@ public final class Lbryio {
}
generatingAuthToken = true;
/*if (BuildConfig.DEBUG) {
Log.d(TAG, "Generating a new auth token");
}*/
Map<String, String> options = new HashMap<>();
options.put("auth_token", "");
@@ -150,6 +161,9 @@ public final class Lbryio {
Response response = Lbryio.call("user", "new", options, "post", context);
try {
JSONObject json = (JSONObject) parseResponse(response);
/*if (BuildConfig.DEBUG) {
Log.d(TAG, String.format("/user/new response: %s", json.toString(2)));
}*/
if (!json.has(AUTH_TOKEN_PARAM)) {
throw new LbryioResponseException("auth_token was not set in the response");
}
+79 -9
View File
@@ -480,23 +480,24 @@
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<LinearLayout
android:id="@+id/file_view_publisher_name_area"
android:clickable="true"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:clickable="true"
android:orientation="vertical">
<TextView
android:id="@+id/file_view_publisher_name"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="@color/lbryGreen"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:fontFamily="@font/inter"
android:textFontWeight="600" />
android:textColor="@color/lbryGreen"
android:textFontWeight="600"
android:textSize="14sp" />
</LinearLayout>
<io.lbry.browser.ui.controls.SolidIconView
android:id="@+id/file_view_icon_follow_unfollow"
@@ -611,6 +612,75 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginBottom="12dp"
android:background="@color/divider" />
<LinearLayout
android:id="@+id/file_view_comments_area"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<ProgressBar
android:id="@+id/file_view_comments_progress"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:visibility="gone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="@font/inter"
android:text="@string/comments"
android:textSize="16sp" />
</RelativeLayout>
<TextView
android:id="@+id/file_view_no_comments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/inter"
android:text="@string/no_comments"
android:textFontWeight="300"
android:textSize="14sp"
android:visibility="gone" />
<TextView
android:id="@+id/file_view_comments_sdk_initializing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/inter"
android:text="@string/sdk_initializing_comments"
android:textFontWeight="300"
android:textSize="14sp"
android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/file_view_comments_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/comment_channel_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:text="channel_name"
android:textColor="@color/lbryGreen"
android:textSize="14sp" />
<TextView
android:id="@+id/comment_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:text="comment_text" />
</LinearLayout>
</LinearLayout>
+6
View File
@@ -59,6 +59,9 @@
<string name="report">Report</string>
<string name="loading_decentralized_data">Loading decentralized data...</string>
<string name="related_content">Related Content</string>
<string name="comments">Comments</string>
<string name="no_comments">No comments to display.</string>
<string name="sdk_initializing_comments">Comments will display once the background service is done initializing.</string>
<string name="share_lbry_content">Share LBRY content</string>
<string name="view">View</string>
<string name="play">Play</string>
@@ -78,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>
@@ -120,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>
@@ -388,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>