Compare commits

..
9 Commits
80 changed files with 5482 additions and 2646 deletions

No files matched your search

+2 -2
View File
@@ -14,8 +14,8 @@ android {
applicationId "io.lbry.browser"
minSdkVersion 21
targetSdkVersion 29
versionCode 1500
versionName "0.15.0"
versionCode 1502
versionName "0.15.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Binary file not shown.
Binary file not shown.
+7 -11
View File
@@ -20,6 +20,9 @@
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<meta-data android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="com.google.android.exoplayer2.ext.cast.DefaultCastOptionsProvider"/>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_lbry" />
@@ -38,8 +41,8 @@
android:label="@string/app_name"
android:supportsPictureInPicture="true"
android:theme="@style/AppTheme.NoActionBar"
android:launchMode="singleInstance"
android:windowSoftInputMode="adjustPan">
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@@ -55,22 +58,15 @@
<activity
android:name=".FirstRunActivity"
android:launchMode="singleInstance"
android:launchMode="singleTask"
android:parentActivityName=".MainActivity"
android:theme="@style/AppTheme.NoActionBarTranslucent" />
<activity
android:name=".VerificationActivity"
android:launchMode="singleInstance"
android:launchMode="singleTask"
android:parentActivityName=".MainActivity"
android:theme="@style/AppTheme.NoActionBarTranslucent"
android:windowSoftInputMode="adjustResize" />
<activity
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|screenLayout"
android:name=".FileViewActivity"
android:launchMode="singleInstance"
android:parentActivityName=".MainActivity"
android:supportsPictureInPicture="true"
android:theme="@style/AppTheme.NoActionBarBlack" />
<service
android:name="io.lbry.browser.LbrynetMessagingService"
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -101,7 +101,7 @@ public class ChannelFilterListAdapter extends RecyclerView.Adapter<ChannelFilter
}
vh.alphaContainer.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.VISIBLE : View.GONE);
vh.thumbnailView.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.GONE : View.VISIBLE);
vh.alphaView.setText(claim.isPlaceholder() ? null : claim.getName().substring(1, 2));
vh.alphaView.setText(claim.isPlaceholder() ? null : claim.getName() != null ? claim.getName().substring(1, 2) : "");
int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
Helper.setIconViewBackgroundColor(vh.alphaContainer, bgColor, claim.isPlaceholder(), context);
@@ -6,6 +6,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -17,13 +18,18 @@ import com.google.android.material.snackbar.Snackbar;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.listener.SelectionModeListener;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.LbryFile;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.LbryUri;
import io.lbry.browser.utils.Lbryio;
import lombok.Getter;
import lombok.Setter;
@@ -32,6 +38,11 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
private static final int VIEW_TYPE_CHANNEL = 2;
private static final int VIEW_TYPE_FEATURED = 3; // featured search result
private Map<String, Claim> quickClaimIdMap;
private Map<String, Claim> quickClaimUrlMap;
private Map<String, Boolean> notFoundClaimIdMap;
private Map<String, Boolean> notFoundClaimUrlMap;
@Setter
private boolean canEnterSelectionMode;
private Context context;
@@ -44,11 +55,19 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
private boolean inSelectionMode;
@Setter
private SelectionModeListener selectionModeListener;
private float scale;
public ClaimListAdapter(List<Claim> items, Context context) {
this.context = context;
this.items = new ArrayList<>(items);
this.selectedItems = new ArrayList<>();
quickClaimIdMap = new HashMap<>();
quickClaimUrlMap = new HashMap<>();
notFoundClaimIdMap = new HashMap<>();
notFoundClaimUrlMap = new HashMap<>();
if (context != null) {
scale = context.getResources().getDisplayMetrics().density;
}
}
public List<Claim> getSelectedItems() {
@@ -73,12 +92,24 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
return null;
}
public List<Claim> getItems() {
return new ArrayList<>(this.items);
}
public void clearItems() {
clearSelectedItems();
this.items.clear();
quickClaimIdMap.clear();
quickClaimUrlMap.clear();
notFoundClaimIdMap.clear();
notFoundClaimUrlMap.clear();
notifyDataSetChanged();
}
public Claim getLastItem() {
return items.size() > 0 ? items.get(items.size() - 1) : null;
}
public void addFeaturedItem(Claim claim) {
items.add(0, claim);
notifyDataSetChanged();
@@ -90,6 +121,9 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
items.add(claim);
}
}
notFoundClaimUrlMap.clear();
notFoundClaimIdMap.clear();
notifyDataSetChanged();
}
public void setItems(List<Claim> claims) {
@@ -97,6 +131,11 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
notifyDataSetChanged();
}
public void removeItems(List<Claim> claims) {
items.removeAll(claims);
notifyDataSetChanged();
}
public void removeItem(Claim claim) {
items.remove(claim);
selectedItems.remove(claim);
@@ -118,6 +157,9 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
protected View repostInfoView;
protected TextView repostChannelView;
protected View selectedOverlayView;
protected TextView fileSizeView;
protected ProgressBar downloadProgressView;
protected TextView deviceView;
public ViewHolder(View v) {
super(v);
feeContainer = v.findViewById(R.id.claim_fee_container);
@@ -134,6 +176,9 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
repostInfoView = v.findViewById(R.id.claim_repost_info);
repostChannelView = v.findViewById(R.id.claim_repost_channel);
selectedOverlayView = v.findViewById(R.id.claim_selected_overlay);
fileSizeView = v.findViewById(R.id.claim_file_size);
downloadProgressView = v.findViewById(R.id.claim_download_progress);
deviceView = v.findViewById(R.id.claim_view_device);
}
}
@@ -155,6 +200,68 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
return Claim.TYPE_CHANNEL.equalsIgnoreCase(actualClaim.getValueType()) ? VIEW_TYPE_CHANNEL : VIEW_TYPE_STREAM;
}
public void updateFileForClaimByIdOrUrl(LbryFile file, String claimId, String url) {
updateFileForClaimByIdOrUrl(file, claimId, url, false);
}
public void updateFileForClaimByIdOrUrl(LbryFile file, String claimId, String url, boolean skipNotFound) {
if (!skipNotFound) {
if (notFoundClaimIdMap.containsKey(claimId) && notFoundClaimUrlMap.containsKey(url)) {
return;
}
}
if (quickClaimIdMap.containsKey(claimId)) {
quickClaimIdMap.get(claimId).setFile(file);
notifyDataSetChanged();
return;
}
if (quickClaimUrlMap.containsKey(claimId)) {
quickClaimUrlMap.get(claimId).setFile(file);
notifyDataSetChanged();
return;
}
boolean claimFound = false;
for (int i = 0; i < items.size(); i++) {
Claim claim = items.get(i);
if (claimId.equalsIgnoreCase(claim.getClaimId()) || url.equalsIgnoreCase(claim.getPermanentUrl())) {
quickClaimIdMap.put(claimId, claim);
quickClaimUrlMap.put(url, claim);
claim.setFile(file);
notifyDataSetChanged();
claimFound = true;
break;
}
}
if (!claimFound) {
notFoundClaimIdMap.put(claimId, true);
notFoundClaimUrlMap.put(url, true);
}
}
public void clearFileForClaimOrUrl(String outpoint, String url) {
clearFileForClaimOrUrl(outpoint, url, false);
notifyDataSetChanged();
}
public void clearFileForClaimOrUrl(String outpoint, String url, boolean remove) {
int claimIndex = -1;
for (int i = 0; i < items.size(); i++) {
Claim claim = items.get(i);
if (outpoint.equalsIgnoreCase(claim.getOutpoint()) || url.equalsIgnoreCase(claim.getPermanentUrl())) {
claimIndex = i;
claim.setFile(null);
break;
}
}
if (remove && claimIndex > -1) {
Claim removed = items.remove(claimIndex);
selectedItems.remove(removed);
}
notifyDataSetChanged();
}
@Override
public ClaimListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
int viewResourceId = -1;
@@ -168,9 +275,18 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
return new ClaimListAdapter.ViewHolder(v);
}
public int getScaledValue(int value) {
return (int) (value * scale + 0.5f);
}
@Override
public void onBindViewHolder(ClaimListAdapter.ViewHolder vh, int position) {
int type = getItemViewType(position);
int paddingTop = position == 0 ? 16 : 8;
int paddingBottom = position == getItemCount() - 1 ? 16 : 8;
int paddingTopScaled = getScaledValue(paddingTop);
int paddingBottomScaled = getScaledValue(paddingBottom);
vh.itemView.setPadding(vh.itemView.getPaddingLeft(), paddingTopScaled, vh.itemView.getPaddingRight(), paddingBottomScaled);
Claim original = items.get(position);
boolean isRepost = Claim.TYPE_REPOST.equalsIgnoreCase(original.getValueType());
@@ -280,15 +396,33 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
into(vh.thumbnailView);
}
BigDecimal cost = streamMetadata != null && streamMetadata.getFee() != null ? new BigDecimal(streamMetadata.getFee().getAmount()) : new BigDecimal(0);
BigDecimal cost = item.getActualCost(Lbryio.LBCUSDRate);
vh.feeContainer.setVisibility(cost.doubleValue() > 0 ? View.VISIBLE : View.GONE);
vh.feeView.setText(cost.doubleValue() > 0 ? Helper.shortCurrencyFormat(cost.divide(new BigDecimal(100000000)).doubleValue()) : null);
vh.feeView.setText(cost.doubleValue() > 0 ? Helper.shortCurrencyFormat(cost.doubleValue()) : "Paid");
vh.alphaView.setText(item.getName().substring(0, Math.min(5, item.getName().length() - 1)));
vh.publisherView.setText(signingChannel != null ? signingChannel.getName() : context.getString(R.string.anonymous));
vh.publishTimeView.setText(DateUtils.getRelativeTimeSpanString(
publishTime, System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE));
vh.durationView.setVisibility(duration > 0 ? View.VISIBLE : View.GONE);
vh.durationView.setText(Helper.formatDuration(duration));
LbryFile claimFile = item.getFile();
boolean isDownloading = false;
int progress = 0;
String fileSizeString = claimFile == null ? null : Helper.formatBytes(claimFile.getTotalBytes(), false);
if (claimFile != null && !claimFile.isCompleted() && claimFile.getWrittenBytes() < claimFile.getTotalBytes()) {
isDownloading = true;
progress = claimFile.getTotalBytes() > 0 ?
Double.valueOf(((double) claimFile.getWrittenBytes() / (double) claimFile.getTotalBytes()) * 100.0).intValue() : 0;
fileSizeString = String.format("%s / %s",
Helper.formatBytes(claimFile.getWrittenBytes(), false),
Helper.formatBytes(claimFile.getTotalBytes(), false));
}
Helper.setViewText(vh.fileSizeView, fileSizeString);
Helper.setViewVisibility(vh.downloadProgressView, isDownloading ? View.VISIBLE : View.INVISIBLE);
Helper.setViewProgress(vh.downloadProgressView, progress);
Helper.setViewText(vh.deviceView, item.getDevice());
} else if (Claim.TYPE_CHANNEL.equalsIgnoreCase(item.getValueType())) {
if (!Helper.isNullOrEmpty(thumbnailUrl)) {
Glide.with(context.getApplicationContext()).
@@ -56,6 +56,11 @@ public class SuggestedChannelGridAdapter extends RecyclerView.Adapter<SuggestedC
public int getSelectedCount() { return selectedItems.size(); }
public void clearItems() {
items.clear();
notifyDataSetChanged();
}
public List<Claim> getSelectedItems() {
return this.selectedItems;
}
@@ -16,6 +16,7 @@ import io.lbry.browser.exceptions.LbryUriException;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.UrlSuggestion;
import io.lbry.browser.ui.controls.SolidIconView;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.LbryUri;
import lombok.Setter;
@@ -96,7 +97,7 @@ public class UrlSuggestionListAdapter extends RecyclerView.Adapter<UrlSuggestion
iconStringId = R.string.fa_at;
fullTitle = item.getTitle();
desc = item.getClaim() != null ? item.getClaim().getTitle() :
(item.isUseTextAsDescription() ? item.getText() : String.format(context.getString(R.string.view_channel_url_desc), item.getText()));
((item.isUseTextAsDescription() && !Helper.isNullOrEmpty(item.getText())) ? item.getText() : String.format(context.getString(R.string.view_channel_url_desc), item.getText()));
break;
case UrlSuggestion.TYPE_TAG:
iconStringId = R.string.fa_hashtag;
@@ -113,7 +114,7 @@ public class UrlSuggestionListAdapter extends RecyclerView.Adapter<UrlSuggestion
iconStringId = R.string.fa_file;
fullTitle = item.getTitle();
desc = item.getClaim() != null ? item.getClaim().getTitle() :
(item.isUseTextAsDescription() ? item.getText() : String.format(context.getString(R.string.view_file_url_desc), item.getText()));
((item.isUseTextAsDescription() && !Helper.isNullOrEmpty(item.getText())) ? item.getText() : String.format(context.getString(R.string.view_file_url_desc), item.getText()));
break;
}
@@ -4,7 +4,10 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.opengl.Visibility;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -21,6 +24,7 @@ import io.lbry.browser.utils.LbryUri;
public class DatabaseHelper extends SQLiteOpenHelper {
public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "LbryApp.db";
private static DatabaseHelper instance;
private static final String[] SQL_CREATE_TABLES = {
// local subscription store
@@ -58,13 +62,16 @@ public class DatabaseHelper extends SQLiteOpenHelper {
private static final String SQL_DELETE_SUBSCRIPTION = "DELETE FROM subscriptions WHERE url = ?";
private static final String SQL_GET_SUBSCRIPTIONS = "SELECT channel_name, url FROM subscriptions";
private static final String SQL_INSERT_URL_HISTORY = "REPLACE INTO url_history (value, url, type, timestamp) VALUES (?, ?, ?)";
private static final String SQL_INSERT_URL_HISTORY = "REPLACE INTO url_history (value, url, type, timestamp) VALUES (?, ?, ?, ?)";
private static final String SQL_CLEAR_URL_HISTORY = "DELETE FROM url_history";
private static final String SQL_CLEAR_URL_HISTORY_BEFORE_TIME = "DELETE FROM url_history WHERE timestamp < ?";
private static final String SQL_GET_RECENT_URL_HISTORY = "SELECT value, url, type FROM url_history ORDER BY timestamp DESC LIMIT 10";
private static final String SQL_INSERT_VIEW_HISTORY =
"REPLACE INTO view_history (url, claim_id, claim_name, cost, title, publisher_claim_id, publisher_name, publisher_title, thumbnail_url, device, release_time, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
private static final String SQL_GET_VIEW_HISTORY =
"SELECT url, claim_id, claim_name, cost, title, publisher_claim_id, publisher_name, publisher_title, thumbnail_url, device, release_time, timestamp " +
"FROM view_history WHERE '' = ? OR timestamp < ? ORDER BY timestamp DESC LIMIT %d";
private static final String SQL_CLEAR_VIEW_HISTORY = "DELETE FROM view_history";
private static final String SQL_CLEAR_VIEW_HISTORY_BY_DEVICE = "DELETE FROM view_history WHERE device = ?";
private static final String SQL_CLEAR_VIEW_HISTORY_BEFORE_TIME = "DELETE FROM view_history WHERE timestamp < ?";
@@ -77,6 +84,10 @@ public class DatabaseHelper extends SQLiteOpenHelper {
public DatabaseHelper(Context context) {
super(context, String.format("%s/%s", context.getFilesDir().getAbsolutePath(), DATABASE_NAME), null, DATABASE_VERSION);
instance = this;
}
public static DatabaseHelper getInstance() {
return instance;
}
public void onCreate(SQLiteDatabase db) {
for (String sql : SQL_CREATE_TABLES) {
@@ -113,13 +124,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
while (cursor.moveToNext()) {
UrlSuggestion suggestion = new UrlSuggestion();
suggestion.setText(cursor.getString(0));
suggestion.setUri(cursor.isNull(1) ? null : LbryUri.tryParse(cursor.getString(1)));
suggestion.setType(cursor.getInt(2));
try {
suggestion.setUri(cursor.isNull(1) ? null : LbryUri.parse(cursor.getString(1)));
} catch (LbryUriException ex) {
// don't fail if the LbryUri is invalid
}
suggestion.setTitleUrlOnly(true);
suggestions.add(suggestion);
}
} finally {
@@ -146,6 +153,41 @@ public class DatabaseHelper extends SQLiteOpenHelper {
});
}
public static List<ViewHistory> getViewHistory(String lastTimestamp, int pageLimit, SQLiteDatabase db) {
List<ViewHistory> history = new ArrayList<>();
Cursor cursor = null;
try {
String arg = lastTimestamp == null ? "" : lastTimestamp;
cursor = db.rawQuery(String.format(SQL_GET_VIEW_HISTORY, pageLimit), new String[] { arg, arg });
while (cursor.moveToNext()) {
ViewHistory item = new ViewHistory();
int cursorIndex = 0;
item.setUri(LbryUri.tryParse(cursor.getString(cursorIndex++)));
item.setClaimId(cursor.getString(cursorIndex++));
item.setClaimName(cursor.getString(cursorIndex++));
item.setCost(new BigDecimal(cursor.getDouble(cursorIndex++)));
item.setTitle(cursor.getString(cursorIndex++));
item.setPublisherClaimId(cursor.getString(cursorIndex++));
item.setPublisherName(cursor.getString(cursorIndex++));
item.setPublisherTitle(cursor.getString(cursorIndex++));
item.setThumbnailUrl(cursor.getString(cursorIndex++));
item.setDevice(cursor.getString(cursorIndex++));
item.setReleaseTime(cursor.getLong(cursorIndex++));
try {
item.setTimestamp(new SimpleDateFormat(Helper.ISO_DATE_FORMAT_PATTERN).parse(cursor.getString(cursorIndex)));
} catch (ParseException ex) {
// invalid timestamp (which shouldn't happen). Skip this item
continue;
}
history.add(item);
}
} finally {
Helper.closeCursor(cursor);
}
return history;
}
public static void createOrUpdateTag(Tag tag, SQLiteDatabase db) {
db.execSQL(SQL_INSERT_TAG, new Object[] { tag.getLowercaseName(), tag.isFollowed() ? 1 : 0 });
}
@@ -84,10 +84,16 @@ public class DiscoverDialogFragment extends BottomSheetDialogFragment {
dialogActionsListener.onResume();
}
}
@Override
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
super.onDismiss(dialog);
if (dialogActionsListener != null) {
dialogActionsListener.onCancel();
}
}
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
if (dialogActionsListener != null) {
dialogActionsListener.onCancel();
}
@@ -24,7 +24,6 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import io.lbry.browser.FileViewActivity;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.adapter.InlineChannelSpinnerAdapter;
@@ -147,16 +146,16 @@ public class RepostClaimDialogFragment extends BottomSheetDialogFragment impleme
public void onResume() {
super.onResume();
Context context = getContext();
if (context instanceof FileViewActivity) {
((FileViewActivity) context).addWalletBalanceListener(this);
if (context instanceof MainActivity) {
((MainActivity) context).addWalletBalanceListener(this);
}
fetchChannels();
}
public void onPause() {
Context context = getContext();
if (context instanceof FileViewActivity) {
((FileViewActivity) context).removeWalletBalanceListener(this);
if (context instanceof MainActivity) {
((MainActivity) context).removeWalletBalanceListener(this);
}
inputDeposit.clearFocus();
super.onPause();
@@ -178,8 +177,8 @@ public class RepostClaimDialogFragment extends BottomSheetDialogFragment impleme
public void onError(Exception error) {
// could not fetch channels
Context context = getContext();
if (context instanceof FileViewActivity) {
((FileViewActivity) context).showError(error.getMessage());
if (context instanceof MainActivity) {
((MainActivity) context).showError(error.getMessage());
}
dismiss();
}
@@ -23,7 +23,6 @@ import com.google.android.material.textfield.TextInputEditText;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import io.lbry.browser.FileViewActivity;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.listener.WalletBalanceListener;
@@ -164,15 +163,15 @@ public class SendTipDialogFragment extends BottomSheetDialogFragment implements
public void onResume() {
super.onResume();
Context context = getContext();
if (context instanceof FileViewActivity) {
((FileViewActivity) context).addWalletBalanceListener(this);
if (context instanceof MainActivity) {
((MainActivity) context).addWalletBalanceListener(this);
}
}
public void onPause() {
Context context = getContext();
if (context instanceof FileViewActivity) {
((FileViewActivity) context).removeWalletBalanceListener(this);
if (context instanceof MainActivity) {
((MainActivity) context).removeWalletBalanceListener(this);
}
super.onPause();
}
@@ -0,0 +1,5 @@
package io.lbry.browser.listener;
public interface DownloadActionListener {
void onDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress);
}
@@ -0,0 +1,6 @@
package io.lbry.browser.listener;
public interface StoragePermissionListener {
void onStoragePermissionGranted();
void onStoragePermissionRefused();
}
@@ -9,6 +9,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -81,6 +82,9 @@ public class Claim {
private GenericMetadata value;
private LbryFile file; // associated file if it exists
// device it was viewed on (for view history)
private String device;
public static Claim claimFromOutput(JSONObject item) {
// we only need name, permanent_url, txid and nout
Claim claim = new Claim();
@@ -92,6 +96,10 @@ public class Claim {
return claim;
}
public String getOutpoint() {
return String.format("%s:%d", txid, nout);
}
public boolean isFree() {
if (!(value instanceof StreamMetadata)) {
return true;
@@ -101,6 +109,24 @@ public class Claim {
return fee == null || Helper.parseDouble(fee.getAmount(), 0) == 0;
}
public BigDecimal getActualCost(double usdRate) {
if (!(value instanceof StreamMetadata)) {
return new BigDecimal(0);
}
Fee fee = ((StreamMetadata) value).getFee();
if (fee != null) {
double amount = Helper.parseDouble(fee.getAmount(), 0);
if ("usd".equalsIgnoreCase(fee.getCurrency())) {
return new BigDecimal(String.valueOf(amount / usdRate));
}
return new BigDecimal(String.valueOf(amount)).divide(new BigDecimal(100000000)); // deweys
}
return new BigDecimal(0);
}
public String getMediaType() {
if (value instanceof StreamMetadata) {
StreamMetadata metadata = (StreamMetadata) value;
@@ -227,6 +253,8 @@ public class Claim {
claim.setName(viewHistory.getClaimName());
claim.setValueType(TYPE_STREAM);
claim.setPermanentUrl(viewHistory.getUri().toString());
claim.setDevice(viewHistory.getDevice());
claim.setConfirmations(1);
StreamMetadata value = new StreamMetadata();
value.setTitle(viewHistory.getTitle());
@@ -353,9 +381,10 @@ public class Claim {
Claim signingChannel = new Claim();
signingChannel.setClaimId(searchResultObject.getString("channel_claim_id"));
signingChannel.setName(searchResultObject.getString("channel"));
claimUri.setChannelClaimId(signingChannel.getClaimId());
claimUri.setChannelName(signingChannel.getName());
LbryUri channelUri = new LbryUri();
channelUri.setChannelClaimId(signingChannel.getClaimId());
channelUri.setChannelName(signingChannel.getName());
signingChannel.setPermanentUrl(channelUri.toString());
claim.setSigningChannel(signingChannel);
}
@@ -5,34 +5,36 @@ import androidx.annotation.Nullable;
import io.lbry.browser.utils.Helper;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* Class to represent a key to check equality with another object
*/
@ToString
public class ClaimCacheKey {
@Getter
@Setter
private String claimId;
@Getter
@Setter
private String canonicalUrl;
@Getter
@Setter
private String permanentUrl;
@Getter
@Setter
private String shortUrl;
@Getter
@Setter
private String vanityUrl;
private String url;
public static ClaimCacheKey fromClaimShortUrl(Claim claim) {
ClaimCacheKey key = new ClaimCacheKey();
key.setUrl(claim.getShortUrl());
return key;
}
public static ClaimCacheKey fromClaimPermanentUrl(Claim claim) {
ClaimCacheKey key = new ClaimCacheKey();
key.setUrl(claim.getPermanentUrl());
return key;
}
public static ClaimCacheKey fromClaim(Claim claim) {
ClaimCacheKey key = new ClaimCacheKey();
key.setClaimId(claim.getClaimId());
key.setCanonicalUrl(claim.getCanonicalUrl());
key.setPermanentUrl(claim.getPermanentUrl());
key.setShortUrl(claim.getShortUrl());
key.setUrl(!Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl());
return key;
}
@@ -41,44 +43,24 @@ public class ClaimCacheKey {
if (obj == null || !(obj instanceof ClaimCacheKey)) {
return false;
}
ClaimCacheKey key = (ClaimCacheKey) obj;
if (!Helper.isNullOrEmpty(claimId) && !Helper.isNullOrEmpty(key.getClaimId())) {
return claimId.equalsIgnoreCase(key.getClaimId());
}
if (!Helper.isNullOrEmpty(permanentUrl) && !Helper.isNullOrEmpty(key.getPermanentUrl())) {
return permanentUrl.equalsIgnoreCase(key.getPermanentUrl());
if (!Helper.isNullOrEmpty(url) && !Helper.isNullOrEmpty(key.getUrl())) {
return url.equalsIgnoreCase(key.getUrl());
}
if (!Helper.isNullOrEmpty(canonicalUrl) && !Helper.isNullOrEmpty(key.getCanonicalUrl())) {
return canonicalUrl.equalsIgnoreCase(key.getCanonicalUrl());
}
if (!Helper.isNullOrEmpty(shortUrl) && !Helper.isNullOrEmpty(key.getShortUrl())) {
return shortUrl.equalsIgnoreCase(key.getShortUrl());
}
if (!Helper.isNullOrEmpty(vanityUrl) && !Helper.isNullOrEmpty(key.getVanityUrl())) {
return vanityUrl.equalsIgnoreCase(key.getVanityUrl());
}
return false;
}
@Override
public int hashCode() {
if (!Helper.isNullOrEmpty(url)) {
return url.hashCode();
}
if (!Helper.isNullOrEmpty(claimId)) {
return claimId.hashCode();
}
if (!Helper.isNullOrEmpty(permanentUrl)) {
return permanentUrl.hashCode();
}
if (!Helper.isNullOrEmpty(canonicalUrl)) {
return canonicalUrl.hashCode();
}
if (!Helper.isNullOrEmpty(shortUrl)) {
return shortUrl.hashCode();
}
if (!Helper.isNullOrEmpty(vanityUrl)) {
return vanityUrl.hashCode();
}
return super.hashCode();
}
@@ -9,9 +9,12 @@ import org.json.JSONObject;
import java.lang.reflect.Type;
import io.lbry.browser.utils.LbryUri;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class LbryFile {
private Claim.StreamMetadata metadata;
private long addedOn;
@@ -20,6 +23,7 @@ public class LbryFile {
private int blobsRemaining;
private String channelClaimId;
private String channelName;
@EqualsAndHashCode.Include
private String claimId;
private String claimName;
private boolean completed;
@@ -39,16 +43,50 @@ public class LbryFile {
private String streamName;
private String streamingUrl;
private String suggestedFileName;
private long timestamp;
private long totalBytes;
private long totalBytesLowerBound;
private String txid;
private long writtenBytes;
private Claim generatedClaim;
public Claim getClaim() {
if (generatedClaim != null) {
return generatedClaim;
}
generatedClaim = new Claim();
generatedClaim.setValueType(Claim.TYPE_STREAM);
generatedClaim.setPermanentUrl(LbryUri.tryParse(String.format("%s#%s", claimName, claimId)).toString());
generatedClaim.setClaimId(claimId);
generatedClaim.setName(claimName);
generatedClaim.setValue(metadata);
generatedClaim.setConfirmations(1);
generatedClaim.setTxid(txid);
generatedClaim.setNout(nout);
generatedClaim.setFile(this);
if (channelClaimId != null) {
Claim signingChannel = new Claim();
signingChannel.setClaimId(channelClaimId);
signingChannel.setName(channelName);
signingChannel.setPermanentUrl(LbryUri.tryParse(String.format("%s#%s", claimName, claimId)).toString());
generatedClaim.setSigningChannel(signingChannel);
}
return generatedClaim;
}
public static LbryFile fromJSONObject(JSONObject fileObject) {
String fileJson = fileObject.toString();
Type type = new TypeToken<LbryFile>(){}.getType();
Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
LbryFile file = gson.fromJson(fileJson, type);
if (file.getMetadata() != null && file.getMetadata().getReleaseTime() == 0) {
file.getMetadata().setReleaseTime(file.getTimestamp());
}
return file;
}
}
@@ -15,6 +15,7 @@ public class UrlSuggestion {
private LbryUri uri;
private Claim claim; // associated claim if resolved
private boolean titleTextOnly;
private boolean titleUrlOnly;
private boolean useTextAsDescription;
public UrlSuggestion() {
@@ -34,6 +35,10 @@ public class UrlSuggestion {
}
public String getTitle() {
if (titleUrlOnly && (type == TYPE_CHANNEL || type == TYPE_FILE)) {
return uri.toString();
}
if (!titleTextOnly) {
switch (type) {
case TYPE_CHANNEL:
@@ -5,6 +5,7 @@ import java.util.Date;
import io.lbry.browser.exceptions.LbryUriException;
import io.lbry.browser.utils.LbryUri;
import io.lbry.browser.utils.Lbryio;
import lombok.Data;
@Data
@@ -39,9 +40,12 @@ public class ViewHistory {
Claim.StreamMetadata value = (Claim.StreamMetadata) metadata;
history.setReleaseTime(value.getReleaseTime());
if (value.getFee() != null) {
history.setCost(new BigDecimal(value.getFee().getAmount()));
history.setCost(claim.getActualCost(Lbryio.LBCUSDRate));
}
}
if (history.getReleaseTime() == 0) {
history.setReleaseTime(claim.getTimestamp());
}
Claim signingChannel = claim.getSigningChannel();
if (signingChannel != null) {
@@ -8,9 +8,13 @@ public class WalletSync {
private String data;
private boolean changed;
public WalletSync(String hash, String data, boolean changed) {
public WalletSync(String hash, String data) {
this.hash = hash;
this.data = data;
}
public WalletSync(String hash, String data, boolean changed) {
this(hash, data);
this.changed = changed;
}
}
@@ -24,6 +24,19 @@ public class User {
private String primaryEmail;
private String rewardStatusChangeTrigger;
private String updatedAt;
private List<String> youtubeChannels;
private List<YoutubeChannel> youtubeChannels;
private List<String> deviceTypes;
@Data
public static class YoutubeChannel {
String ytChannelName;
String lbryChannelName;
String channelClaimId;
String syncStatus;
String statusToken;
boolean transferable;
String transferState;
List<String> publishToAddress;
String publicKey;
}
}
@@ -0,0 +1,45 @@
package io.lbry.browser.tasks;
import android.os.AsyncTask;
import java.util.HashMap;
import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.utils.Lbry;
public class SetSdkSettingTask extends AsyncTask<Void, Void, Boolean> {
private String key;
private String value;
private GenericTaskHandler handler;
private Exception error;
public SetSdkSettingTask(String key, String value, GenericTaskHandler handler) {
this.key = key;
this.value = value;
this.handler = handler;
}
@Override
protected Boolean doInBackground(Void... params) {
try {
Map<String, Object> options = new HashMap<>();
options.put("key", key);
options.put("value", value);
Lbry.genericApiCall("setting_set", options);
return true;
} catch (ApiCallException ex) {
error = ex;
return false;
}
}
protected void onPostExecute(Boolean result) {
if (handler != null) {
if (result) {
handler.onSuccess();
} else {
handler.onError(error);
}
}
}
}
@@ -0,0 +1,63 @@
package io.lbry.browser.tasks.claim;
import android.os.AsyncTask;
import android.view.View;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry;
public class AbandonChannelTask extends AsyncTask<Void, Void, Boolean> {
private List<String> claimIds;
private List<String> successfulClaimIds;
private List<String> failedClaimIds;
private List<Exception> failedExceptions;
private View progressView;
private AbandonHandler handler;
public AbandonChannelTask(List<String> claimIds, View progressView, AbandonHandler handler) {
this.claimIds = claimIds;
this.progressView = progressView;
this.handler = handler;
}
protected void onPreExecute() {
Helper.setViewVisibility(progressView, View.VISIBLE);
}
public Boolean doInBackground(Void... params) {
successfulClaimIds = new ArrayList<>();
failedClaimIds = new ArrayList<>();
failedExceptions = new ArrayList<>();
for (String claimId : claimIds) {
try {
Map<String, Object> options = new HashMap<>();
options.put("claim_id", claimId);
options.put("blocking", false);
JSONObject result = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_CHANNEL_ABANDON, options);
successfulClaimIds.add(claimId);
} catch (ApiCallException ex) {
failedClaimIds.add(claimId);
failedExceptions.add(ex);
}
}
return true;
}
protected void onPostExecute(Boolean result) {
Helper.setViewVisibility(progressView, View.GONE);
if (handler != null) {
handler.onComplete(successfulClaimIds, failedClaimIds, failedExceptions);
}
}
}
@@ -0,0 +1,7 @@
package io.lbry.browser.tasks.claim;
import java.util.List;
public interface AbandonHandler {
void onComplete(List<String> successfulClaimIds, List<String> failedClaimIds, List<Exception> errors);
}
@@ -30,7 +30,7 @@ public class ClaimSearchTask extends AsyncTask<Void, Void, List<Claim>> {
}
protected List<Claim> doInBackground(Void... params) {
try {
return Lbry.claimSearch(options, connectionString);
return Helper.filterInvalidReposts(Lbry.claimSearch(options, connectionString));
} catch (ApiCallException ex) {
error = ex;
return null;
@@ -34,7 +34,7 @@ public class ResolveTask extends AsyncTask<Void, Void, List<Claim>> {
}
protected List<Claim> doInBackground(Void... params) {
try {
return Lbry.resolve(urls, connectionString);
return Helper.filterInvalidReposts(Lbry.resolve(urls, connectionString));
} catch (ApiCallException ex) {
error = ex;
return null;
@@ -0,0 +1,32 @@
package io.lbry.browser.tasks.file;
import android.os.AsyncTask;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.utils.Lbry;
// Just run delete on the specified claim IDs (no need for a handler)
public class BulkDeleteFilesTask extends AsyncTask<Void, Void, Boolean> {
private List<String> claimIds;
public BulkDeleteFilesTask(List<String> claimIds) {
this.claimIds = claimIds;
}
protected Boolean doInBackground(Void... params) {
for (String claimId : claimIds) {
try {
Map<String, Object> options = new HashMap<>();
options.put("claim_id", claimId);
options.put("delete_from_download_dir", true);
Lbry.genericApiCall(Lbry.METHOD_FILE_DELETE, options);
} catch (ApiCallException ex) {
// pass
}
}
return true;
}
}
@@ -26,6 +26,7 @@ public class DeleteFileTask extends AsyncTask<Void, Void, Boolean> {
options.put("delete_from_download_dir", true);
return (boolean) Lbry.genericApiCall(Lbry.METHOD_FILE_DELETE, options);
} catch (ApiCallException ex) {
error = ex;
return false;
}
}
@@ -12,12 +12,18 @@ import io.lbry.browser.utils.Lbry;
public class FileListTask extends AsyncTask<Void, Void, List<LbryFile>> {
private String claimId;
private boolean downloads;
private int page;
private int pageSize;
private FileListResultHandler handler;
private View progressView;
private ApiCallException error;
public FileListTask(View progressView, FileListResultHandler handler) {
public FileListTask(int page, int pageSize, boolean downloads, View progressView, FileListResultHandler handler) {
this(null, progressView, handler);
this.page = page;
this.pageSize = pageSize;
this.downloads = downloads;
}
public FileListTask(String claimId, View progressView, FileListResultHandler handler) {
@@ -30,7 +36,7 @@ public class FileListTask extends AsyncTask<Void, Void, List<LbryFile>> {
}
protected List<LbryFile> doInBackground(Void... params) {
try {
return Lbry.fileList(claimId);
return Lbry.fileList(claimId, downloads, page, pageSize);
} catch (ApiCallException ex) {
error = ex;
return null;
@@ -40,7 +46,7 @@ public class FileListTask extends AsyncTask<Void, Void, List<LbryFile>> {
Helper.setViewVisibility(progressView, View.GONE);
if (handler != null) {
if (files != null) {
handler.onSuccess(files);
handler.onSuccess(files, files.size() < pageSize);
} else {
handler.onError(error);
}
@@ -48,7 +54,7 @@ public class FileListTask extends AsyncTask<Void, Void, List<LbryFile>> {
}
public interface FileListResultHandler {
void onSuccess(List<LbryFile> files);
void onSuccess(List<LbryFile> files, boolean hasReachedEnd);
void onError(Exception error);
}
}
@@ -0,0 +1,37 @@
package io.lbry.browser.tasks.localdata;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.os.AsyncTask;
import java.util.ArrayList;
import java.util.List;
import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.model.UrlSuggestion;
public class FetchRecentUrlHistoryTask extends AsyncTask<Void, Void, List<UrlSuggestion>> {
private DatabaseHelper dbHelper;
private FetchRecentUrlHistoryHandler handler;
public FetchRecentUrlHistoryTask(DatabaseHelper dbHelper, FetchRecentUrlHistoryHandler handler) {
this.dbHelper = dbHelper;
this.handler = handler;
}
protected List<UrlSuggestion> doInBackground(Void... params) {
try {
SQLiteDatabase db = dbHelper.getReadableDatabase();
return DatabaseHelper.getRecentHistory(db);
} catch (SQLiteException ex) {
return new ArrayList<>();
}
}
protected void onPostExecute(List<UrlSuggestion> recentHistory) {
if (handler != null) {
handler.onSuccess(recentHistory);
}
}
public interface FetchRecentUrlHistoryHandler {
void onSuccess(List<UrlSuggestion> recentHistory);
}
}
@@ -0,0 +1,46 @@
package io.lbry.browser.tasks.localdata;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.os.AsyncTask;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.model.UrlSuggestion;
import io.lbry.browser.model.ViewHistory;
import io.lbry.browser.utils.Helper;
public class FetchViewHistoryTask extends AsyncTask<Void, Void, List<ViewHistory>> {
private DatabaseHelper dbHelper;
private FetchViewHistoryHandler handler;
private int pageSize;
private Date lastDate;
public FetchViewHistoryTask(Date lastDate, int pageSize, DatabaseHelper dbHelper, FetchViewHistoryHandler handler) {
this.lastDate = lastDate;
this.pageSize = pageSize;
this.dbHelper = dbHelper;
this.handler = handler;
}
protected List<ViewHistory> doInBackground(Void... params) {
try {
SQLiteDatabase db = dbHelper.getReadableDatabase();
return DatabaseHelper.getViewHistory(
lastDate == null ? null : new SimpleDateFormat(Helper.ISO_DATE_FORMAT_PATTERN).format(lastDate), pageSize, db);
} catch (SQLiteException ex) {
return new ArrayList<>();
}
}
protected void onPostExecute(List<ViewHistory> history) {
if (handler != null) {
handler.onSuccess(history, history.size() < pageSize);
}
}
public interface FetchViewHistoryHandler {
void onSuccess(List<ViewHistory> history, boolean hasReachedEnd);
}
}
@@ -9,21 +9,21 @@ import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.model.UrlSuggestion;
import io.lbry.browser.tasks.GenericTaskHandler;
public class CreateUrlHistoryTask extends AsyncTask<Void, Void, Boolean> {
private Context context;
public class SaveUrlHistoryTask extends AsyncTask<Void, Void, Boolean> {
private DatabaseHelper dbHelper;
private UrlSuggestion suggestion;
private GenericTaskHandler handler;
private SaveUrlHistoryHandler handler;
private Exception error;
public CreateUrlHistoryTask(UrlSuggestion suggestion, Context context, GenericTaskHandler handler) {
public SaveUrlHistoryTask(UrlSuggestion suggestion, DatabaseHelper dbHelper, SaveUrlHistoryHandler handler) {
this.suggestion = suggestion;
this.context = context;
this.dbHelper = dbHelper;
this.handler = handler;
}
protected Boolean doInBackground(Void... params) {
try {
SQLiteDatabase db = ((MainActivity) context).getDbHelper().getWritableDatabase();
SQLiteDatabase db = dbHelper.getWritableDatabase();
DatabaseHelper.createOrUpdateUrlHistoryItem(suggestion.getText(), suggestion.getUri().toString(), suggestion.getType(), db);
} catch (Exception ex) {
error = ex;
@@ -35,10 +35,15 @@ public class CreateUrlHistoryTask extends AsyncTask<Void, Void, Boolean> {
protected void onPostExecute(Boolean result) {
if (handler != null) {
if (result) {
handler.onSuccess();
handler.onSuccess(suggestion);
} else {
handler.onError(error);
}
}
}
public interface SaveUrlHistoryHandler {
void onSuccess(UrlSuggestion item);
void onError(Exception error);
}
}
@@ -0,0 +1,45 @@
package io.lbry.browser.tasks.localdata;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;
import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.model.ViewHistory;
public class SaveViewHistoryTask extends AsyncTask<Void, Void, Boolean> {
private DatabaseHelper dbHelper;
private ViewHistory history;
private SaveViewHistoryHandler handler;
private Exception error;
public SaveViewHistoryTask(ViewHistory history, DatabaseHelper dbHelper, SaveViewHistoryHandler handler) {
this.history = history;
this.dbHelper = dbHelper;
this.handler = handler;
}
protected Boolean doInBackground(Void... params) {
try {
SQLiteDatabase db = dbHelper.getWritableDatabase();
DatabaseHelper.createOrUpdateViewHistoryItem(history, db);
} catch (Exception ex) {
error = ex;
return false;
}
return true;
}
protected void onPostExecute(Boolean result) {
if (handler != null) {
if (result) {
handler.onSuccess(history);
} else {
handler.onError(error);
}
}
}
public interface SaveViewHistoryHandler {
void onSuccess(ViewHistory item);
void onError(Exception error);
}
}
@@ -45,7 +45,7 @@ public class SyncSetTask extends AsyncTask<Void, Void, String> {
if (handler != null) {
if (!Helper.isNullOrEmpty(hash)) {
handler.onSyncSetSuccess(hash);
} else if (error != null) {
} else {
handler.onSyncSetError(error);
}
}
@@ -7,6 +7,7 @@ import androidx.fragment.app.Fragment;
import java.util.Map;
import io.lbry.browser.MainActivity;
import io.lbry.browser.ui.following.FileViewFragment;
import lombok.Getter;
import lombok.Setter;
@@ -19,7 +20,15 @@ public class BaseFragment extends Fragment {
super.onResume();
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).setSelectedMenuItemForFragment(this);
MainActivity activity = (MainActivity) context;
activity.setSelectedMenuItemForFragment(this);
if (this instanceof FileViewFragment) {
activity.hideGlobalNowPlaying();
} else {
activity.checkNowPlaying();
}
}
}
}
@@ -15,14 +15,17 @@ import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.exoplayer2.offline.Download;
import com.google.android.material.snackbar.Snackbar;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import io.lbry.browser.FileViewActivity;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.adapter.ClaimListAdapter;
@@ -30,8 +33,10 @@ import io.lbry.browser.dialog.ContentFromDialogFragment;
import io.lbry.browser.dialog.ContentScopeDialogFragment;
import io.lbry.browser.dialog.ContentSortDialogFragment;
import io.lbry.browser.dialog.CustomizeTagsDialogFragment;
import io.lbry.browser.listener.DownloadActionListener;
import io.lbry.browser.listener.TagListener;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.LbryFile;
import io.lbry.browser.model.Tag;
import io.lbry.browser.tasks.claim.ClaimSearchTask;
import io.lbry.browser.tasks.FollowUnfollowTagTask;
@@ -43,7 +48,7 @@ import io.lbry.browser.utils.Predefined;
import lombok.Getter;
// TODO: Similar code to FollowingFragment and Channel page fragment. Probably make common operations (sorting/filtering) into a control
public class AllContentFragment extends BaseFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
public class AllContentFragment extends BaseFragment implements DownloadActionListener, SharedPreferences.OnSharedPreferenceChangeListener {
@Getter
private boolean singleTagView;
@@ -207,6 +212,7 @@ public class AllContentFragment extends BaseFragment implements SharedPreference
singleTagView = true;
tags = Arrays.asList(tagName);
titleView.setText(Helper.capitalize(tagName));
Helper.setViewVisibility(customizeLink, View.GONE);
} else {
singleTagView = false;
// default to followed Tags scope if any tags are followed
@@ -218,8 +224,8 @@ public class AllContentFragment extends BaseFragment implements SharedPreference
titleView.setText(getString(R.string.all_content));
}
forPrefix.setVisibility(singleTagView ? View.GONE : View.VISIBLE);
scopeLink.setVisibility(singleTagView ? View.GONE : View.VISIBLE);
Helper.setViewVisibility(forPrefix, singleTagView ? View.GONE : View.VISIBLE);
Helper.setViewVisibility(scopeLink, singleTagView ? View.GONE : View.VISIBLE);
if (reload) {
fetchClaimSearchContent(true);
@@ -374,6 +380,7 @@ public class AllContentFragment extends BaseFragment implements SharedPreference
} else {
LbryAnalytics.setCurrentScreen(activity, "All Content", "AllContent");
}
activity.addDownloadActionListener(this);
}
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
@@ -384,7 +391,11 @@ public class AllContentFragment extends BaseFragment implements SharedPreference
}
public void onPause() {
PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this);
Context context = getContext();
if (context != null) {
((MainActivity) context).removeDownloadActionListener(this);
}
PreferenceManager.getDefaultSharedPreferences(context).unregisterOnSharedPreferenceChangeListener(this);
super.onPause();
}
@@ -440,21 +451,15 @@ public class AllContentFragment extends BaseFragment implements SharedPreference
contentListAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
@Override
public void onClaimClicked(Claim claim) {
String claimId = claim.getClaimId();
String url = !Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl();
if (claim.getName().startsWith("@")) {
// channel claim
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).openChannelClaim(claim);
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
if (claim.getName().startsWith("@")) {
// channel claim
activity.openChannelClaim(claim);
} else {
activity.openFileClaim(claim);
}
} else {
Intent intent = new Intent(getContext(), FileViewActivity.class);
intent.putExtra("claimId", claimId);
intent.putExtra("url", url);
MainActivity.startingFileViewActivity = true;
startActivity(intent);
}
}
});
@@ -490,4 +495,24 @@ public class AllContentFragment extends BaseFragment implements SharedPreference
fetchClaimSearchContent(true);
}
}
public void onDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress) {
if ("abort".equals(downloadAction)) {
if (contentListAdapter != null) {
contentListAdapter.clearFileForClaimOrUrl(outpoint, uri);
}
return;
}
try {
JSONObject fileInfo = new JSONObject(fileInfoJson);
LbryFile claimFile = LbryFile.fromJSONObject(fileInfo);
String claimId = claimFile.getClaimId();
if (contentListAdapter != null) {
contentListAdapter.updateFileForClaimByIdOrUrl(claimFile, claimId, uri);
}
} catch (JSONException ex) {
// invalid file info for download
}
}
}
@@ -16,25 +16,29 @@ import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import io.lbry.browser.FileViewActivity;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.adapter.ClaimListAdapter;
import io.lbry.browser.dialog.ContentFromDialogFragment;
import io.lbry.browser.dialog.ContentSortDialogFragment;
import io.lbry.browser.listener.DownloadActionListener;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.LbryFile;
import io.lbry.browser.tasks.claim.ClaimSearchTask;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry;
import io.lbry.browser.utils.Predefined;
import lombok.Setter;
public class ChannelContentFragment extends Fragment implements SharedPreferences.OnSharedPreferenceChangeListener {
public class ChannelContentFragment extends Fragment implements DownloadActionListener, SharedPreferences.OnSharedPreferenceChangeListener {
@Setter
private String channelId;
@@ -189,12 +193,20 @@ public class ChannelContentFragment extends Fragment implements SharedPreference
public void onResume() {
super.onResume();
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
Context context = getContext();
if (context != null) {
((MainActivity) context).addDownloadActionListener(this);
}
PreferenceManager.getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(this);
fetchClaimSearchContent();
}
public void onPause() {
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
Context context = getContext();
if (context != null) {
((MainActivity) context).removeDownloadActionListener(this);
}
PreferenceManager.getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(this);
super.onPause();
}
@@ -250,20 +262,15 @@ public class ChannelContentFragment extends Fragment implements SharedPreference
contentListAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
@Override
public void onClaimClicked(Claim claim) {
String claimId = claim.getClaimId();
String url = !Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl();
if (claim.getName().startsWith("@")) {
// channel claim
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).openChannelClaim(claim);
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
if (claim.getName().startsWith("@")) {
// channel claim
activity.openChannelClaim(claim);
} else {
activity.openFileClaim(claim);
}
} else {
Intent intent = new Intent(getContext(), FileViewActivity.class);
intent.putExtra("claimId", claimId);
intent.putExtra("url", url);
MainActivity.startingFileViewActivity = true;
startActivity(intent);
}
}
});
@@ -299,4 +306,24 @@ public class ChannelContentFragment extends Fragment implements SharedPreference
fetchClaimSearchContent(true);
}
}
public void onDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress) {
if ("abort".equals(downloadAction)) {
if (contentListAdapter != null) {
contentListAdapter.clearFileForClaimOrUrl(outpoint, uri);
}
return;
}
try {
JSONObject fileInfo = new JSONObject(fileInfoJson);
LbryFile claimFile = LbryFile.fromJSONObject(fileInfo);
String claimId = claimFile.getClaimId();
if (contentListAdapter != null) {
contentListAdapter.updateFileForClaimByIdOrUrl(claimFile, claimId, uri);
}
} catch (JSONException ex) {
// invalid file info for download
}
}
}
@@ -37,6 +37,7 @@ import io.lbry.browser.BuildConfig;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.adapter.TagListAdapter;
import io.lbry.browser.listener.StoragePermissionListener;
import io.lbry.browser.listener.WalletBalanceListener;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.NavMenuItem;
@@ -54,7 +55,8 @@ import io.lbry.browser.utils.LbryAnalytics;
import io.lbry.browser.utils.LbryUri;
import lombok.Getter;
public class ChannelFormFragment extends BaseFragment implements WalletBalanceListener, TagListAdapter.TagClickListener {
public class ChannelFormFragment extends BaseFragment implements
StoragePermissionListener, TagListAdapter.TagClickListener, WalletBalanceListener {
private static final int SUGGESTED_LIMIT = 8;
@@ -326,6 +328,14 @@ public class ChannelFormFragment extends BaseFragment implements WalletBalanceLi
logPublish.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
if (!editMode) {
// channel created
Bundle bundle = new Bundle();
bundle.putString("claim_id", claimResult.getClaimId());
bundle.putString("claim_name", claimResult.getName());
LbryAnalytics.logEvent(LbryAnalytics.EVENT_CHANNEL_CREATE, bundle);
}
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
@@ -436,6 +446,12 @@ public class ChannelFormFragment extends BaseFragment implements WalletBalanceLi
Snackbar.make(getView(), R.string.image_upload_failed, Snackbar.LENGTH_LONG).setBackgroundTint(
ContextCompat.getColor(context, R.color.red)
).show();
if (coverFilePickerActive) {
// cover selected
imageCover.setImageResource(R.drawable.default_channel_cover);
} else if (thumbnailFilePickerActive) {
imageThumbnail.setImageDrawable(null);
}
coverFilePickerActive = false;
thumbnailFilePickerActive = false;
uploading = false;
@@ -490,6 +506,7 @@ public class ChannelFormFragment extends BaseFragment implements WalletBalanceLi
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) getContext();
activity.removeStoragePermissionListener(this);
activity.removeWalletBalanceListener(this);
activity.restoreToggle();
activity.showFloatingWalletBalance();
@@ -509,6 +526,7 @@ public class ChannelFormFragment extends BaseFragment implements WalletBalanceLi
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
LbryAnalytics.setCurrentScreen(activity, "Channel Form", "ChannelForm");
activity.addStoragePermissionListener(this);
if (editMode) {
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null) {
@@ -31,10 +31,13 @@ import java.util.Map;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.dialog.SendTipDialogFragment;
import io.lbry.browser.exceptions.LbryUriException;
import io.lbry.browser.listener.FetchChannelsListener;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.ClaimCacheKey;
import io.lbry.browser.model.UrlSuggestion;
import io.lbry.browser.model.lbryinc.Subscription;
import io.lbry.browser.tasks.lbryinc.ChannelSubscribeTask;
import io.lbry.browser.tasks.claim.ClaimListResultHandler;
@@ -285,24 +288,36 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
updateRequired = true;
}
}
if (!updateRequired && params.containsKey("url")) {
if (params.containsKey("url")) {
String newUrl = params.get("url").toString();
if (!newUrl.equalsIgnoreCase(url) || claim == null) {
if (claim == null || !newUrl.equalsIgnoreCase(url)) {
this.claim = null;
this.url = newUrl;
updateRequired = true;
}
}
if (updateRequired) {
resetSubCount();
if (!Helper.isNullOrEmpty(url)) {
resolveUrl();
// check if the claim is already cached
ClaimCacheKey key = new ClaimCacheKey();
key.setUrl(url);
if (Lbry.claimCache.containsKey(key)) {
claim = Lbry.claimCache.get(key);
} else {
resolveUrl();
}
} else if (claim == null) {
// nothing at this location
renderNothingAtLocation();
}
}
if (!Helper.isNullOrEmpty(url)) {
Helper.saveUrlHistory(url, claim != null ? claim.getTitle() : null, UrlSuggestion.TYPE_CHANNEL);
}
if (claim != null) {
renderClaim();
}
@@ -315,6 +330,10 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
public void onSuccess(List<Claim> claims) {
if (claims.size() > 0 && !Helper.isNullOrEmpty(claims.get(0).getClaimId())) {
claim = claims.get(0);
if (!Helper.isNullOrEmpty(url)) {
Helper.saveUrlHistory(url, claim.getTitle(), UrlSuggestion.TYPE_CHANNEL);
}
renderClaim();
checkOwnChannel();
} else {
@@ -2,6 +2,7 @@ package io.lbry.browser.ui.channel;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -19,6 +20,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import java.util.ArrayList;
import java.util.HashMap;
@@ -32,6 +34,8 @@ import io.lbry.browser.listener.SdkStatusListener;
import io.lbry.browser.listener.SelectionModeListener;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.NavMenuItem;
import io.lbry.browser.tasks.claim.AbandonChannelTask;
import io.lbry.browser.tasks.claim.AbandonHandler;
import io.lbry.browser.tasks.claim.ClaimListResultHandler;
import io.lbry.browser.tasks.claim.ClaimListTask;
import io.lbry.browser.ui.BaseFragment;
@@ -144,7 +148,7 @@ public class ChannelManagerFragment extends BaseFragment implements ActionMode.C
ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, getLoading(), new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
Lbry.ownChannels = new ArrayList<>(claims);
Lbry.ownChannels = Helper.filterDeletedClaims(new ArrayList<>(claims));
Context context = getContext();
if (adapter == null) {
adapter = new ClaimListAdapter(claims, context);
@@ -260,7 +264,7 @@ public class ChannelManagerFragment extends BaseFragment implements ActionMode.C
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//handleDeleteSelectedClaims(selectedClaims);
handleDeleteSelectedClaims(selectedClaims);
}
}).setNegativeButton(R.string.no, null);
builder.show();
@@ -270,4 +274,48 @@ public class ChannelManagerFragment extends BaseFragment implements ActionMode.C
return false;
}
private void handleDeleteSelectedClaims(List<Claim> selectedClaims) {
List<String> claimIds = new ArrayList<>();
for (Claim claim : selectedClaims) {
claimIds.add(claim.getClaimId());
}
if (actionMode != null) {
actionMode.finish();
}
Helper.setViewVisibility(channelList, View.INVISIBLE);
Helper.setViewVisibility(fabNewChannel, View.INVISIBLE);
AbandonChannelTask task = new AbandonChannelTask(claimIds, bigLoading, new AbandonHandler() {
@Override
public void onComplete(List<String> successfulClaimIds, List<String> failedClaimIds, List<Exception> errors) {
View root = getView();
if (root != null) {
if (failedClaimIds.size() > 0) {
Snackbar.make(root, R.string.one_or_more_channels_failed_abandon, Snackbar.LENGTH_LONG).
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
} else if (successfulClaimIds.size() == claimIds.size()) {
try {
String message = getResources().getQuantityString(R.plurals.channels_deleted, successfulClaimIds.size());
Snackbar.make(root, message, Snackbar.LENGTH_LONG).show();
} catch (IllegalStateException ex) {
// pass
}
}
}
Lbry.abandonedClaimIds.addAll(successfulClaimIds);
if (adapter != null) {
adapter.setItems(Helper.filterDeletedClaims(adapter.getItems()));
}
Helper.setViewVisibility(channelList, View.VISIBLE);
Helper.setViewVisibility(fabNewChannel, View.VISIBLE);
checkNoChannels();
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
@@ -22,7 +22,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import io.lbry.browser.FileViewActivity;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.adapter.EditorsChoiceItemAdapter;
@@ -116,11 +115,10 @@ public class EditorsChoiceFragment extends BaseFragment {
@Override
public void onEditorsChoiceItemClicked(EditorsChoiceItem item) {
String url = item.getPermanentUrl();
Intent intent = new Intent(getContext(), FileViewActivity.class);
intent.putExtra("url", url);
MainActivity.startingFileViewActivity = true;
startActivity(intent);
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).openFileUrl(url);
}
}
});
} else {
File diff suppressed because it is too large. Load diff
@@ -20,12 +20,14 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.snackbar.Snackbar;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import io.lbry.browser.FileViewActivity;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.adapter.ChannelFilterListAdapter;
@@ -35,7 +37,9 @@ import io.lbry.browser.dialog.ContentFromDialogFragment;
import io.lbry.browser.dialog.ContentSortDialogFragment;
import io.lbry.browser.dialog.DiscoverDialogFragment;
import io.lbry.browser.exceptions.LbryUriException;
import io.lbry.browser.listener.DownloadActionListener;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.LbryFile;
import io.lbry.browser.model.lbryinc.Subscription;
import io.lbry.browser.tasks.lbryinc.ChannelSubscribeTask;
import io.lbry.browser.tasks.claim.ClaimListResultHandler;
@@ -53,7 +57,9 @@ import io.lbry.browser.utils.Predefined;
public class FollowingFragment extends BaseFragment implements
FetchSubscriptionsTask.FetchSubscriptionsHandler,
ChannelItemSelectionListener, SharedPreferences.OnSharedPreferenceChangeListener {
ChannelItemSelectionListener,
DownloadActionListener,
SharedPreferences.OnSharedPreferenceChangeListener {
public static boolean resetClaimSearchContent;
private static final int SUGGESTED_PAGE_SIZE = 45;
@@ -83,6 +89,7 @@ public class FollowingFragment extends BaseFragment implements
private boolean contentClaimSearchLoading = false;
private boolean suggestedClaimSearchLoading = false;
private View noContentView;
private boolean subscriptionsShown;
private List<Integer> queuedContentPages = new ArrayList<>();
private List<Integer> queuedSuggestedPages = new ArrayList<>();
@@ -242,8 +249,8 @@ public class FollowingFragment extends BaseFragment implements
@Override
public void onClick(View view) {
buildChannelIdsAndUrls();
currentSuggestedPage = 1;
discoverDialog = DiscoverDialogFragment.newInstance();
excludeChannelIdsForDiscover = channelIds != null ? new ArrayList<>(channelIds) : null;
discoverDialog.setAdapter(suggestedChannelAdapter);
discoverDialog.setDialogActionsListener(new DiscoverDialogFragment.DiscoverDialogListener() {
@Override
@@ -258,6 +265,9 @@ public class FollowingFragment extends BaseFragment implements
public void onCancel() {
discoverDialog = null;
excludeChannelIdsForDiscover = null;
if (suggestedChannelAdapter != null) {
suggestedChannelAdapter.clearItems();
}
}
@Override
public void onResume() {
@@ -334,6 +344,7 @@ public class FollowingFragment extends BaseFragment implements
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
LbryAnalytics.setCurrentScreen(activity, "Subscriptions", "Subscriptions");
activity.addDownloadActionListener(this);
}
// check if subscriptions exist
@@ -345,16 +356,20 @@ public class FollowingFragment extends BaseFragment implements
}
if (Lbryio.subscriptions != null && Lbryio.subscriptions.size() > 0) {
fetchLoadedSubscriptions();
fetchLoadedSubscriptions(true);
} else {
fetchSubscriptions();
}
}
public void onPause() {
PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this);
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).removeDownloadActionListener(this);
}
PreferenceManager.getDefaultSharedPreferences(context).unregisterOnSharedPreferenceChangeListener(this);
super.onPause();
}
public void fetchLoadedSubscriptions() {
public void fetchLoadedSubscriptions(boolean showSubscribed) {
subscriptionsList = new ArrayList<>(Lbryio.subscriptions);
buildChannelIdsAndUrls();
if (Lbryio.cacheResolvedSubscriptions.size() > 0) {
@@ -365,7 +380,9 @@ public class FollowingFragment extends BaseFragment implements
fetchClaimSearchContent(resetClaimSearchContent);
resetClaimSearchContent = false;
showSubscribedContent();
if (showSubscribed && subscriptionsList.size() > 0) {
showSubscribedContent();
}
}
public void loadFollowing() {
@@ -446,6 +463,7 @@ public class FollowingFragment extends BaseFragment implements
}
private void showSubscribedContent() {
subscriptionsShown = true;
Helper.setViewText(titleView, R.string.channels_you_follow);
Helper.setViewVisibility(horizontalChannelList, View.VISIBLE);
@@ -472,6 +490,8 @@ public class FollowingFragment extends BaseFragment implements
}
}
}
excludeChannelIdsForDiscover = channelIds != null ? new ArrayList<>(channelIds) : null;
}
private void fetchAndResolveChannelList() {
@@ -567,21 +587,15 @@ public class FollowingFragment extends BaseFragment implements
contentListAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
@Override
public void onClaimClicked(Claim claim) {
String claimId = claim.getClaimId();
String url = !Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl();
if (claim.getName().startsWith("@")) {
// channel claim
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).openChannelClaim(claim);
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
if (claim.getName().startsWith("@")) {
// channel claim
activity.openChannelClaim(claim);
} else {
activity.openFileClaim(claim);
}
} else {
Intent intent = new Intent(getContext(), FileViewActivity.class);
intent.putExtra("claimId", claimId);
intent.putExtra("url", url);
MainActivity.startingFileViewActivity = true;
startActivity(intent);
}
}
});
@@ -705,12 +719,11 @@ public class FollowingFragment extends BaseFragment implements
ChannelSubscribeTask task = new ChannelSubscribeTask(getContext(), channelClaimId, subscription, false, new ChannelSubscribeTask.ChannelSubscribeHandler() {
@Override
public void onSuccess() {
if (discoverDialog != null) {
Lbryio.addSubscription(subscription);
Lbryio.addCachedResolvedSubscription(claim);
resetClaimSearchContent = true;
fetchLoadedSubscriptions();
}
Lbryio.addSubscription(subscription);
Lbryio.addCachedResolvedSubscription(claim);
resetClaimSearchContent = true;
fetchLoadedSubscriptions(subscriptionsShown);
saveSharedUserState();
}
@@ -727,12 +740,11 @@ public class FollowingFragment extends BaseFragment implements
ChannelSubscribeTask task = new ChannelSubscribeTask(getContext(), channelClaimId, subscription, true, new ChannelSubscribeTask.ChannelSubscribeHandler() {
@Override
public void onSuccess() {
if (discoverDialog != null) {
Lbryio.removeSubscription(subscription);
Lbryio.removeCachedResolvedSubscription(claim);
resetClaimSearchContent = true;
fetchLoadedSubscriptions();
}
Lbryio.removeSubscription(subscription);
Lbryio.removeCachedResolvedSubscription(claim);
resetClaimSearchContent = true;
fetchLoadedSubscriptions(subscriptionsShown);
saveSharedUserState();
}
@@ -766,4 +778,24 @@ public class FollowingFragment extends BaseFragment implements
fetchClaimSearchContent(true);
}
}
public void onDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress) {
if ("abort".equals(downloadAction)) {
if (contentListAdapter != null) {
contentListAdapter.clearFileForClaimOrUrl(outpoint, uri);
}
return;
}
try {
JSONObject fileInfo = new JSONObject(fileInfoJson);
LbryFile claimFile = LbryFile.fromJSONObject(fileInfo);
String claimId = claimFile.getClaimId();
if (contentListAdapter != null) {
contentListAdapter.updateFileForClaimByIdOrUrl(claimFile, claimId, uri);
}
} catch (JSONException ex) {
// invalid file info for download
}
}
}
@@ -0,0 +1,585 @@
package io.lbry.browser.ui.library;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.view.ActionMode;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.snackbar.Snackbar;
import org.json.JSONException;
import org.json.JSONObject;
import java.nio.channels.AsynchronousChannel;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.adapter.ClaimListAdapter;
import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.listener.DownloadActionListener;
import io.lbry.browser.listener.SdkStatusListener;
import io.lbry.browser.listener.SelectionModeListener;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.LbryFile;
import io.lbry.browser.model.NavMenuItem;
import io.lbry.browser.model.ViewHistory;
import io.lbry.browser.tasks.claim.AbandonChannelTask;
import io.lbry.browser.tasks.claim.AbandonHandler;
import io.lbry.browser.tasks.file.BulkDeleteFilesTask;
import io.lbry.browser.tasks.file.DeleteFileTask;
import io.lbry.browser.tasks.file.FileListTask;
import io.lbry.browser.tasks.localdata.FetchViewHistoryTask;
import io.lbry.browser.ui.BaseFragment;
import io.lbry.browser.ui.channel.ChannelFormFragment;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry;
import io.lbry.browser.utils.LbryAnalytics;
public class LibraryFragment extends BaseFragment implements
ActionMode.Callback, DownloadActionListener, SelectionModeListener, SdkStatusListener {
private static final int FILTER_DOWNLOADS = 1;
private static final int FILTER_HISTORY = 2;
private static final int PAGE_SIZE = 50;
private ActionMode actionMode;
private int currentFilter;
private List<LbryFile> currentFiles;
private View layoutSdkInitializing;
private RecyclerView contentList;
private ClaimListAdapter contentListAdapter;
private ProgressBar listLoading;
private TextView linkFilterDownloads;
private TextView linkFilterHistory;
private View layoutListEmpty;
private TextView textListEmpty;
private int currentPage;
private Date lastDate;
private boolean listReachedEnd;
private boolean contentListLoading;
private CardView cardStats;
private TextView linkStats;
private TextView linkHide;
private View viewStatsDistribution;
private View viewVideoStatsBar;
private View viewAudioStatsBar;
private View viewImageStatsBar;
private View viewOtherStatsBar;
private TextView textStatsTotalSize;
private TextView textStatsTotalSizeUnits;
private TextView textStatsVideoSize;
private TextView textStatsAudioSize;
private TextView textStatsImageSize;
private TextView textStatsOtherSize;
private View legendVideo;
private View legendAudio;
private View legendImage;
private View legendOther;
private long totalBytes;
private long totalVideoBytes;
private long totalAudioBytes;
private long totalImageBytes;
private long totalOtherBytes;
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_library, container, false);
layoutSdkInitializing = root.findViewById(R.id.container_library_sdk_initializing);
LinearLayoutManager llm = new LinearLayoutManager(getContext());
contentList = root.findViewById(R.id.library_list);
contentList.setLayoutManager(llm);
listLoading = root.findViewById(R.id.library_list_loading);
linkFilterDownloads = root.findViewById(R.id.library_filter_link_downloads);
linkFilterHistory = root.findViewById(R.id.library_filter_link_history);
layoutListEmpty = root.findViewById(R.id.library_empty_container);
textListEmpty = root.findViewById(R.id.library_list_empty_text);
currentFilter = FILTER_DOWNLOADS;
linkFilterDownloads.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showDownloads();
}
});
linkFilterHistory.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showHistory();
}
});
contentList.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (contentListLoading) {
return;
}
LinearLayoutManager lm = (LinearLayoutManager) recyclerView.getLayoutManager();
if (lm != null) {
int visibleItemCount = lm.getChildCount();
int totalItemCount = lm.getItemCount();
int pastVisibleItems = lm.findFirstVisibleItemPosition();
if (pastVisibleItems + visibleItemCount >= totalItemCount) {
if (!listReachedEnd) {
// load more
if (currentFilter == FILTER_DOWNLOADS) {
currentPage++;
fetchDownloads();
} else if (currentFilter == FILTER_HISTORY) {
fetchHistory();
}
}
}
}
}
});
// stats
linkStats = root.findViewById(R.id.library_show_stats);
linkHide = root.findViewById(R.id.library_hide_stats);
cardStats = root.findViewById(R.id.library_storage_stats_card);
viewStatsDistribution = root.findViewById(R.id.library_storage_stat_distribution);
viewVideoStatsBar = root.findViewById(R.id.library_storage_stat_video_bar);
viewAudioStatsBar = root.findViewById(R.id.library_storage_stat_audio_bar);
viewImageStatsBar = root.findViewById(R.id.library_storage_stat_image_bar);
viewOtherStatsBar = root.findViewById(R.id.library_storage_stat_other_bar);
textStatsTotalSize = root.findViewById(R.id.library_storage_stat_used);
textStatsTotalSizeUnits = root.findViewById(R.id.library_storage_stat_unit);
textStatsVideoSize = root.findViewById(R.id.library_storage_stat_video_size);
textStatsAudioSize = root.findViewById(R.id.library_storage_stat_audio_size);
textStatsImageSize = root.findViewById(R.id.library_storage_stat_image_size);
textStatsOtherSize = root.findViewById(R.id.library_storage_stat_other_size);
legendVideo = root.findViewById(R.id.library_storage_legend_video);
legendAudio = root.findViewById(R.id.library_storage_legend_audio);
legendImage = root.findViewById(R.id.library_storage_legend_image);
legendOther = root.findViewById(R.id.library_storage_legend_other);
linkStats.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
updateStats();
cardStats.setVisibility(View.VISIBLE);
checkStatsLink();
}
});
linkHide.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
cardStats.setVisibility(View.GONE);
checkStatsLink();
}
});
return root;
}
public void onResume() {
super.onResume();
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
LbryAnalytics.setCurrentScreen(activity, "Library", "Library");
activity.addDownloadActionListener(this);
}
layoutSdkInitializing.setVisibility(
!Lbry.SDK_READY && currentFilter == FILTER_DOWNLOADS ? View.VISIBLE : View.GONE);
if (!Lbry.SDK_READY) {
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
activity.addSdkStatusListener(this);
}
} else {
onSdkReady();
}
}
public void onPause() {
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
activity.removeSdkStatusListener(this);
activity.removeDownloadActionListener(this);
}
super.onPause();
}
public void onSdkReady() {
layoutSdkInitializing.setVisibility(View.GONE);
if (currentFilter == FILTER_DOWNLOADS) {
showDownloads();
} else if (currentFilter == FILTER_HISTORY) {
showHistory();
}
}
private void showDownloads() {
currentFilter = FILTER_DOWNLOADS;
linkFilterDownloads.setTypeface(null, Typeface.BOLD);
linkFilterHistory.setTypeface(null, Typeface.NORMAL);
if (contentListAdapter != null) {
contentListAdapter.clearItems();
contentListAdapter.setCanEnterSelectionMode(true);
}
listReachedEnd = false;
checkStatsLink();
layoutSdkInitializing.setVisibility(Lbry.SDK_READY ? View.GONE : View.VISIBLE);
currentPage = 1;
if (Lbry.SDK_READY) {
fetchDownloads();
}
}
private void showHistory() {
currentFilter = FILTER_HISTORY;
linkFilterDownloads.setTypeface(null, Typeface.NORMAL);
linkFilterHistory.setTypeface(null, Typeface.BOLD);
if (actionMode != null) {
actionMode.finish();
}
if (contentListAdapter != null) {
contentListAdapter.clearItems();
contentListAdapter.setCanEnterSelectionMode(false);
}
listReachedEnd = false;
cardStats.setVisibility(View.GONE);
checkStatsLink();
layoutSdkInitializing.setVisibility(View.GONE);
lastDate = null;
fetchHistory();
}
private void initContentListAdapter(List<Claim> claims) {
contentListAdapter = new ClaimListAdapter(claims, getContext());
contentListAdapter.setCanEnterSelectionMode(true);
contentListAdapter.setSelectionModeListener(this);
contentListAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
@Override
public void onClaimClicked(Claim claim) {
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) getContext();
if (claim.getName().startsWith("@")) {
activity.openChannelUrl(claim.getPermanentUrl());
} else {
activity.openFileUrl(claim.getPermanentUrl());
}
}
}
});
}
private void fetchDownloads() {
contentListLoading = true;
Helper.setViewVisibility(linkStats, View.GONE);
Helper.setViewVisibility(layoutListEmpty, View.GONE);
FileListTask task = new FileListTask(currentPage, PAGE_SIZE, true, listLoading, new FileListTask.FileListResultHandler() {
@Override
public void onSuccess(List<LbryFile> files, boolean hasReachedEnd) {
listReachedEnd = hasReachedEnd;
List<LbryFile> filteredFiles = Helper.filterDownloads(files);
List<Claim> claims = Helper.claimsFromFiles(filteredFiles);
addFiles(filteredFiles);
updateStats();
checkStatsLink();
if (contentListAdapter == null) {
initContentListAdapter(claims);
} else {
contentListAdapter.addItems(claims);
}
contentList.setAdapter(contentListAdapter);
checkListEmpty();
contentListLoading = false;
}
@Override
public void onError(Exception error) {
// pass
checkStatsLink();
checkListEmpty();
contentListLoading = false;
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
private void fetchHistory() {
contentListLoading = true;
Helper.setViewVisibility(layoutListEmpty, View.GONE);
DatabaseHelper dbHelper = DatabaseHelper.getInstance();
if (dbHelper != null) {
FetchViewHistoryTask task = new FetchViewHistoryTask(lastDate, PAGE_SIZE, dbHelper, new FetchViewHistoryTask.FetchViewHistoryHandler() {
@Override
public void onSuccess(List<ViewHistory> history, boolean hasReachedEnd) {
listReachedEnd = hasReachedEnd;
if (history.size() > 0) {
lastDate = history.get(history.size() - 1).getTimestamp();
}
List<Claim> claims = Helper.claimsFromViewHistory(history);
if (contentListAdapter == null) {
initContentListAdapter(claims);
} else {
contentListAdapter.addItems(claims);
}
contentList.setAdapter(contentListAdapter);
checkListEmpty();
contentListLoading = false;
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
checkListEmpty();
contentListLoading = false;
}
}
public void onDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress) {
if ("abort".equals(downloadAction)) {
if (contentListAdapter != null) {
contentListAdapter.clearFileForClaimOrUrl(outpoint, uri, currentFilter == FILTER_DOWNLOADS);
}
return;
}
try {
JSONObject fileInfo = new JSONObject(fileInfoJson);
LbryFile claimFile = LbryFile.fromJSONObject(fileInfo);
String claimId = claimFile.getClaimId();
if (contentListAdapter != null) {
contentListAdapter.updateFileForClaimByIdOrUrl(claimFile, claimId, uri, true);
}
} catch (JSONException ex) {
// invalid file info for download
}
}
private void checkListEmpty() {
layoutListEmpty.setVisibility(contentListAdapter == null || contentListAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
textListEmpty.setText(currentFilter == FILTER_DOWNLOADS ? R.string.library_no_downloads : R.string.library_no_history);
}
private void addFiles(List<LbryFile> files) {
if (currentFiles == null) {
currentFiles = new ArrayList<>();
}
for (LbryFile file : files) {
if (!currentFiles.contains(file)) {
currentFiles.add(file);
}
}
}
private void updateStats() {
totalBytes = 0;
totalVideoBytes = 0;
totalAudioBytes = 0;
totalImageBytes = 0;
totalOtherBytes = 0;
if (currentFiles != null) {
for (LbryFile file : currentFiles) {
long writtenBytes = file.getWrittenBytes();
String mime = file.getMimeType();
if (mime != null) {
if (mime.startsWith("video/")) {
totalVideoBytes += writtenBytes;
} else if (mime.startsWith("audio/")) {
totalAudioBytes += writtenBytes;
} else if (mime.startsWith("image/")) {
totalImageBytes += writtenBytes;
} else {
totalOtherBytes += writtenBytes;
}
}
totalBytes += writtenBytes;
}
}
renderStats();
}
private void renderStats() {
String[] totalSizeParts = Helper.formatBytesParts(totalBytes, false);
textStatsTotalSize.setText(totalSizeParts[0]);
textStatsTotalSizeUnits.setText(totalSizeParts[1]);
viewStatsDistribution.setVisibility(totalBytes > 0 ? View.VISIBLE : View.GONE);
int percentVideo = normalizePercent((double) totalVideoBytes / (double) totalBytes * 100.0);
legendVideo.setVisibility(totalVideoBytes > 0 ? View.VISIBLE : View.GONE);
textStatsVideoSize.setText(Helper.formatBytes(totalVideoBytes, false));
applyLayoutWeight(viewVideoStatsBar, percentVideo);
int percentAudio = normalizePercent((double) totalAudioBytes / (double) totalBytes * 100.0);
legendAudio.setVisibility(totalAudioBytes > 0 ? View.VISIBLE : View.GONE);
textStatsAudioSize.setText(Helper.formatBytes(totalAudioBytes, false));
applyLayoutWeight(viewAudioStatsBar, percentAudio);
int percentImage = normalizePercent((double) totalImageBytes / (double) totalBytes * 100.0);
legendImage.setVisibility(totalImageBytes > 0 ? View.VISIBLE : View.GONE);
textStatsImageSize.setText(Helper.formatBytes(totalImageBytes, false));
applyLayoutWeight(viewImageStatsBar, percentImage);
int percentOther = normalizePercent((double) totalOtherBytes / (double) totalBytes * 100.0);
legendOther.setVisibility(totalOtherBytes > 0 ? View.VISIBLE : View.GONE);
textStatsOtherSize.setText(Helper.formatBytes(totalOtherBytes, false));
applyLayoutWeight(viewOtherStatsBar, percentOther);
// We have to get to 100 (or adjust the container accordingly)
int totalPercent = percentVideo + percentAudio + percentImage + percentOther;
((LinearLayout) viewStatsDistribution).setWeightSum(totalPercent);
}
private void applyLayoutWeight(View view, int weight) {
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) view.getLayoutParams();
params.weight = weight;
}
private static int normalizePercent(double value) {
if (value > 0 && value < 1) {
return 1;
}
return Double.valueOf(Math.floor(value)).intValue();
}
private void checkStatsLink() {
linkStats.setVisibility(cardStats.getVisibility() == View.VISIBLE ||
listLoading.getVisibility() == View.VISIBLE ||
currentFilter == FILTER_HISTORY ?
View.GONE : View.VISIBLE);
}
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
this.actionMode = actionMode;
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
if (!activity.isDarkMode()) {
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}
}
actionMode.getMenuInflater().inflate(R.menu.menu_claim_list, menu);
return true;
}
@Override
public void onDestroyActionMode(ActionMode actionMode) {
if (contentListAdapter != null) {
contentListAdapter.clearSelectedItems();
contentListAdapter.setInSelectionMode(false);
contentListAdapter.notifyDataSetChanged();
}
Context context = getContext();
if (context != null) {
MainActivity activity = (MainActivity) context;
if (!activity.isDarkMode()) {
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
}
this.actionMode = null;
}
@Override
public boolean onPrepareActionMode(androidx.appcompat.view.ActionMode actionMode, Menu menu) {
menu.findItem(R.id.action_edit).setVisible(false);
return true;
}
@Override
public boolean onActionItemClicked(androidx.appcompat.view.ActionMode actionMode, MenuItem menuItem) {
if (R.id.action_delete == menuItem.getItemId()) {
if (contentListAdapter != null && contentListAdapter.getSelectedCount() > 0) {
final List<Claim> selectedClaims = new ArrayList<>(contentListAdapter.getSelectedItems());
String message = getResources().getQuantityString(R.plurals.confirm_delete_files, selectedClaims.size());
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).
setTitle(R.string.delete_selection).
setMessage(message)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
handleDeleteSelectedClaims(selectedClaims);
}
}).setNegativeButton(R.string.no, null);
builder.show();
return true;
}
}
return false;
}
private void handleDeleteSelectedClaims(List<Claim> selectedClaims) {
List<String> claimIds = new ArrayList<>();
for (Claim claim : selectedClaims) {
claimIds.add(claim.getClaimId());
}
new BulkDeleteFilesTask(claimIds).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
Lbry.unsetFilesForCachedClaims(claimIds);
if (currentFilter == FILTER_DOWNLOADS) {
contentListAdapter.removeItems(selectedClaims);
}
if (actionMode != null) {
actionMode.finish();
}
View root = getView();
if (root != null) {
String message = getResources().getQuantityString(R.plurals.files_deleted, claimIds.size());
Snackbar.make(root, message, Snackbar.LENGTH_LONG).show();
}
}
public void onEnterSelectionMode() {
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
activity.startSupportActionMode(this);
}
}
public void onItemSelectionToggled() {
if (actionMode != null) {
actionMode.setTitle(String.valueOf(contentListAdapter.getSelectedCount()));
actionMode.invalidate();
}
}
public void onExitSelectionMode() {
if (actionMode != null) {
actionMode.finish();
}
}
}
@@ -193,7 +193,7 @@ public class AboutFragment extends BaseFragment implements SdkStatusListener {
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
LbryAnalytics.setCurrentScreen(activity, "Settings", "Settings");
LbryAnalytics.setCurrentScreen(activity, "About", "About");
if (!Lbry.SDK_READY) {
activity.addSdkStatusListener(this);
@@ -15,13 +15,20 @@ import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.exoplayer2.offline.Download;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.adapter.ClaimListAdapter;
import io.lbry.browser.listener.DownloadActionListener;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.ClaimCacheKey;
import io.lbry.browser.model.LbryFile;
import io.lbry.browser.tasks.claim.ClaimListResultHandler;
import io.lbry.browser.tasks.claim.ClaimSearchTask;
import io.lbry.browser.tasks.LighthouseSearchTask;
@@ -34,10 +41,10 @@ import io.lbry.browser.utils.LbryUri;
import lombok.Setter;
public class SearchFragment extends BaseFragment implements
ClaimListAdapter.ClaimListItemListener, SharedPreferences.OnSharedPreferenceChangeListener {
private ClaimListAdapter resultListAdapter;
ClaimListAdapter.ClaimListItemListener, DownloadActionListener, SharedPreferences.OnSharedPreferenceChangeListener {
private static final int PAGE_SIZE = 25;
private ClaimListAdapter resultListAdapter;
private ProgressBar loadingView;
private RecyclerView resultList;
private TextView noQueryView;
@@ -95,6 +102,7 @@ public class SearchFragment extends BaseFragment implements
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
LbryAnalytics.setCurrentScreen(activity, "Search", "Search");
activity.addDownloadActionListener(this);
}
if (!Helper.isNullOrEmpty(currentQuery)) {
logSearch(currentQuery);
@@ -106,7 +114,11 @@ public class SearchFragment extends BaseFragment implements
}
public void onPause() {
PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this);
Context context = getContext();
if (context != null) {
((MainActivity) context).removeDownloadActionListener(this);
}
PreferenceManager.getDefaultSharedPreferences(context).unregisterOnSharedPreferenceChangeListener(this);
super.onPause();
}
@@ -141,7 +153,7 @@ public class SearchFragment extends BaseFragment implements
private void resolveFeaturedItem(String vanityUrl) {
final ClaimCacheKey key = new ClaimCacheKey();
key.setVanityUrl(vanityUrl);
key.setUrl(vanityUrl);
if (Lbry.claimCache.containsKey(key)) {
Claim cachedClaim = Lbry.claimCache.get(key);
updateFeaturedItemFromResolvedClaim(cachedClaim);
@@ -253,7 +265,7 @@ public class SearchFragment extends BaseFragment implements
((MainActivity) getContext()).openChannelUrl(claim.getPermanentUrl());
} else {
// not a channel
MainActivity.openFileClaim(claim, getContext());
((MainActivity) getContext()).openFileClaim(claim);
}
}
@@ -262,4 +274,24 @@ public class SearchFragment extends BaseFragment implements
search(currentQuery, currentFrom);
}
}
public void onDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress) {
if ("abort".equals(downloadAction)) {
if (resultListAdapter != null) {
resultListAdapter.clearFileForClaimOrUrl(outpoint, uri);
}
return;
}
try {
JSONObject fileInfo = new JSONObject(fileInfoJson);
LbryFile claimFile = LbryFile.fromJSONObject(fileInfo);
String claimId = claimFile.getClaimId();
if (resultListAdapter != null) {
resultListAdapter.updateFileForClaimByIdOrUrl(claimFile, claimId, uri);
}
} catch (JSONException ex) {
// invalid file info for download
}
}
}
@@ -248,7 +248,10 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
}
private void updateInviteLink(Claim claim) {
String link = String.format(INVITE_LINK_FORMAT, claim.getName(), claim.getClaimId());
LbryUri canonical = LbryUri.tryParse(claim.getCanonicalUrl());
String link = String.format(INVITE_LINK_FORMAT,
canonical != null ? String.format("@%s", canonical.getChannelName()) : claim.getName(),
canonical != null ? canonical.getChannelClaimId() : claim.getClaimId());
textInviteLink.setText(link);
}
private void copyInviteLink() {
@@ -523,6 +526,12 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
logPublishTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
// channel created
Bundle bundle = new Bundle();
bundle.putString("claim_id", claimResult.getClaimId());
bundle.putString("claim_name", claimResult.getName());
LbryAnalytics.logEvent(LbryAnalytics.EVENT_CHANNEL_CREATE, bundle);
// add the claim to the channel list and set it as the selected item
channelSpinnerAdapter.add(claimResult);
channelSpinner.setSelection(channelSpinnerAdapter.getCount() - 1);
@@ -161,7 +161,7 @@ public class TransactionHistoryFragment extends BaseFragment implements Transact
if (uri.isChannel()) {
activity.openChannelUrl(uri.toString());
} else {
MainActivity.openFileUrl(uri.toString(), context);
activity.openFileUrl(uri.toString());
}
}
}
@@ -401,11 +401,11 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
LbryAnalytics.setCurrentScreen(activity, "Wallet", "Wallet");
}
Helper.setViewVisibility(layoutAccountRecommended, hasSkippedAccount() || Lbryio.isSignedIn() ? View.GONE : View.VISIBLE);
if (!Lbry.SDK_READY) {
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
activity.addSdkStatusListener(this);
activity.addWalletBalanceListener(this);
}
checkReceiveAddress();
@@ -441,7 +441,9 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
public void onSdkReady() {
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).removeSdkStatusListener(this);
MainActivity activity = (MainActivity) context;
activity.syncWalletAndLoadPreferences();
activity.addWalletBalanceListener(this);
}
// update view
@@ -12,12 +12,14 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
@@ -40,10 +42,16 @@ import java.util.Map;
import java.util.Random;
import io.lbry.browser.MainActivity;
import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.dialog.ContentFromDialogFragment;
import io.lbry.browser.dialog.ContentSortDialogFragment;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.LbryFile;
import io.lbry.browser.model.Tag;
import io.lbry.browser.model.UrlSuggestion;
import io.lbry.browser.model.ViewHistory;
import io.lbry.browser.tasks.localdata.SaveUrlHistoryTask;
import io.lbry.browser.tasks.localdata.SaveViewHistoryTask;
import okhttp3.MediaType;
public final class Helper {
@@ -57,6 +65,7 @@ public final class Helper {
public static final int CONTENT_PAGE_SIZE = 25;
public static final double MIN_DEPOSIT = 0.05;
public static final String LBC_CURRENCY_FORMAT_PATTERN = "#,###.##";
public static final String FILE_SIZE_FORMAT_PATTERN = "#,###.#";
public static final DecimalFormat LBC_CURRENCY_FORMAT = new DecimalFormat(LBC_CURRENCY_FORMAT_PATTERN);
public static final DecimalFormat USD_CURRENCY_FORMAT = new DecimalFormat("#,##0.00");
public static final String EXPLORER_TX_PREFIX = "https://explorer.lbry.com/tx";
@@ -117,6 +126,12 @@ public final class Helper {
}
}
public static void setViewProgress(ProgressBar progressBar, int progress) {
if (progressBar != null) {
progressBar.setProgress(progress);
}
}
public static void setViewText(TextView view, int stringResourceId) {
if (view != null) {
view.setText(stringResourceId);
@@ -179,6 +194,43 @@ public final class Helper {
}
return String.format("%d:%02d", minutes, seconds);
}
public static String[] formatBytesParts(long bytes, boolean showTB) {
DecimalFormat formatter = new DecimalFormat(FILE_SIZE_FORMAT_PATTERN);
if (bytes < 1048576) {
// less than 1MB
return new String[] { formatter.format(bytes / 1024.0), "KB" };
}
if (bytes < 1073741824) {
// less than 1GB
return new String[] { formatter.format(bytes / (1024.0 * 1024.0)), "MB" };
}
if (showTB) {
if (bytes < (1073741824L * 1024L)) {
return new String[] { formatter.format(bytes / (1024.0 * 1024.0 * 1024.0)), "GB" };
}
return new String[] { formatter.format(bytes / (1024.0 * 1024.0 * 1024.0 * 1024.0)), "TB" };
}
return new String[] { formatter.format(bytes / (1024.0 * 1024.0 * 1024.0)), "GB" };
}
public static String formatBytes(long bytes, boolean showTB) {
DecimalFormat formatter = new DecimalFormat(FILE_SIZE_FORMAT_PATTERN);
if (bytes < 1048576) {
// less than 1MB
return String.format("%sKB", formatter.format(bytes / 1024.0));
}
if (bytes < 1073741824) {
// less than 1GB
return String.format("%sMB", formatter.format(bytes / (1024.0 * 1024.0)));
}
if (showTB) {
if (bytes < (1073741824L * 1024L)) {
return String.format("%sGB", formatter.format(bytes / (1024.0 * 1024.0 * 1024.0)));
}
return String.format("%sTB", formatter.format(bytes / (1024.0 * 1024.0 * 1024.0 * 1024.0)));
}
return String.format("%sGB", formatter.format(bytes / (1024.0 * 1024.0 * 1024.0)));
}
public static JSONObject getJSONObject(String name, JSONObject object) {
try {
@@ -233,21 +285,22 @@ public final class Helper {
}
public static String shortCurrencyFormat(double value) {
DecimalFormat format = new DecimalFormat("#,###.#");
if (value > 1000000000.00) {
return String.format("%.1fB", value / 1000000000.0);
return String.format("%sB", format.format(value / 1000000000.0));
}
if (value > 1000000.0) {
return String.format("%.1fM", value / 1000000.0);
return String.format("%sM",format.format( value / 1000000.0));
}
if (value > 1000.0) {
return String.format("%.1fK", value / 1000.0);
return String.format("%sK", format.format(value / 1000.0));
}
if (value == 0) {
return "0";
}
return new DecimalFormat("###.##").format(value);
return format.format(value);
}
public static String getValue(CharSequence cs) {
@@ -349,6 +402,15 @@ public final class Helper {
}
return followedTags;
}
public static List<Claim> filterDeletedClaims(List<Claim> claims) {
List<Claim> filtered = new ArrayList<>();
for (Claim claim : claims) {
if (!Lbry.abandonedClaimIds.contains(claim.getClaimId())) {
filtered.add(claim);
}
}
return filtered;
}
public static void setWunderbarValue(String value, Context context) {
if (context instanceof MainActivity) {
@@ -555,4 +617,61 @@ public final class Helper {
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setText(HtmlCompat.fromHtml(textView.getText().toString(), HtmlCompat.FROM_HTML_MODE_LEGACY));
}
public static List<Claim> filterInvalidReposts(List<Claim> claims) {
List<Claim> filtered = new ArrayList<>();
for (Claim claim : claims) {
if (Claim.TYPE_REPOST.equalsIgnoreCase(claim.getValueType()) && claim.getRepostedClaim() == null) {
continue;
}
filtered.add(claim);
}
return filtered;
}
public static List<LbryFile> filterDownloads(List<LbryFile> files) {
List<LbryFile> filtered = new ArrayList<>();
for (int i = 0; i < files.size(); i++) {
LbryFile file = files.get(i);
if (!Helper.isNullOrEmpty(file.getDownloadPath())) {
filtered.add(file);
}
}
return filtered;
}
public static List<Claim> claimsFromFiles(List<LbryFile> files) {
List<Claim> claims = new ArrayList<>();
for (LbryFile file : files) {
claims.add(file.getClaim());
}
return claims;
}
public static List<Claim> claimsFromViewHistory(List<ViewHistory> history) {
List<Claim> claims = new ArrayList<>();
for (ViewHistory item : history) {
claims.add(Claim.fromViewHistory(item));
}
return claims;
}
public static void saveUrlHistory(String url, String title, int type) {
DatabaseHelper dbHelper = DatabaseHelper.getInstance();
if (dbHelper != null) {
UrlSuggestion suggestion = new UrlSuggestion();
suggestion.setUri(LbryUri.tryParse(url));
suggestion.setType(type);
suggestion.setText(Helper.isNull(title) ? "" : title);
new SaveUrlHistoryTask(suggestion, dbHelper, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
public static void saveViewHistory(String url, Claim claim) {
DatabaseHelper dbHelper = DatabaseHelper.getInstance();
if (dbHelper != null) {
ViewHistory viewHistory = ViewHistory.fromClaimWithUrlAndDeviceName(claim, url, getDeviceName());
new SaveViewHistoryTask(viewHistory, dbHelper, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
}
@@ -8,6 +8,7 @@ import java.io.IOException;
import java.security.KeyStore;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -26,6 +27,9 @@ import io.lbry.browser.model.Tag;
import io.lbry.browser.model.Transaction;
import io.lbry.browser.model.WalletBalance;
import io.lbry.lbrysdk.Utils;
import kotlin.Pair;
import okhttp3.CacheControl;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
@@ -40,6 +44,7 @@ public final class Lbry {
public static List<Tag> followedTags = new ArrayList<>();
public static List<Claim> ownClaims = new ArrayList<>();
public static List<Claim> ownChannels = new ArrayList<>(); // Make this a subset of ownClaims?
public static List<String> abandonedClaimIds = new ArrayList<>();
public static final int TTL_CLAIM_SEARCH_VALUE = 120000; // 2-minute TTL for cache
public static final String SDK_CONNECTION_STRING = "http://127.0.0.1:5279";
@@ -93,6 +98,7 @@ public final class Lbry {
public static boolean SDK_READY = false;
public static void startupInit() {
abandonedClaimIds = new ArrayList<>();
ownChannels = new ArrayList<>();
ownClaims = new ArrayList<>();
knownTags = new ArrayList<>();
@@ -161,7 +167,7 @@ public final class Lbry {
if (value instanceof Double) {
jsonParams.put(param.getKey(), (double) value);
} else {
jsonParams.put(param.getKey(), value);
jsonParams.put(param.getKey(), value == null ? JSONObject.NULL : value);
}
}
} catch (JSONException ex) {
@@ -250,9 +256,7 @@ public final class Lbry {
Claim claim = Claim.fromJSONObject(result.getJSONObject(keys.next()));
claims.add(claim);
// TODO: Add/remove/prune entries claim cache management
ClaimCacheKey key = ClaimCacheKey.fromClaim(claim);
claimCache.put(key, claim);
addClaimToCache(claim);
}
}
} catch (LbryRequestException | LbryResponseException | JSONException ex) {
@@ -309,12 +313,22 @@ public final class Lbry {
return file;
}
public static List<LbryFile> fileList(String claimId) throws ApiCallException {
public static List<LbryFile> fileList(String claimId, boolean downloads, int page, int pageSize) throws ApiCallException {
List<LbryFile> files = new ArrayList<>();
Map<String, Object> params = new HashMap<>();
if (!Helper.isNullOrEmpty(claimId)) {
params.put("claim_id", claimId);
}
if (downloads) {
params.put("download_path", null);
params.put("comparison", "ne");
}
if (page > 0) {
params.put("page", page);
}
if (pageSize > 0) {
params.put("page_size", pageSize);
}
try {
JSONObject result = (JSONObject) parseResponse(apiCall(METHOD_FILE_LIST, params));
JSONArray items = result.getJSONArray("items");
@@ -396,8 +410,7 @@ public final class Lbry {
Claim claim = Claim.fromJSONObject(items.getJSONObject(i));
claims.add(claim);
ClaimCacheKey key = ClaimCacheKey.fromClaim(claim);
claimCache.put(key, claim);
addClaimToCache(claim);
}
}
@@ -452,4 +465,25 @@ public final class Lbry {
}
}
}
public static void addClaimToCache(Claim claim) {
ClaimCacheKey fullKey = ClaimCacheKey.fromClaim(claim);
ClaimCacheKey shortUrlKey = ClaimCacheKey.fromClaimShortUrl(claim);
ClaimCacheKey permanentUrlKey = ClaimCacheKey.fromClaimPermanentUrl(claim);
claimCache.put(fullKey, claim);
claimCache.put(permanentUrlKey, claim);
if (!Helper.isNullOrEmpty(shortUrlKey.getUrl())) {
claimCache.put(shortUrlKey, claim);
}
}
public static void unsetFilesForCachedClaims(List<String> claimIds) {
for (String claimId : claimIds) {
ClaimCacheKey key = new ClaimCacheKey();
key.setClaimId(claimId);
if (claimCache.containsKey(key)) {
claimCache.get(key).setFile(null);
}
}
}
}
@@ -192,8 +192,9 @@ public final class Lbryio {
Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
User user = gson.fromJson(object.toString(), type);
return user;
} catch (LbryioRequestException | LbryioResponseException | ClassCastException ex) {
android.util.Log.e(TAG, "Cannot retrieve the current user", ex);
} catch (LbryioRequestException | LbryioResponseException | ClassCastException | IllegalStateException ex) {
LbryAnalytics.logException(String.format("/user/me failed: %s", ex.getMessage()), ex.getClass().getName());
android.util.Log.e(TAG, "Could not retrieve the current user", ex);
return null;
}
}
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF"
android:alpha="0.8">
<path
android:fillColor="#FF000000"
android:pathData="M21,3L3,3c-1.1,0 -2,0.9 -2,2v3h2L3,5h18v14h-7v2h7c1.1,0 2,-0.9 2,-2L23,5c0,-1.1 -0.9,-2 -2,-2zM1,18v3h3c0,-1.66 -1.34,-3 -3,-3zM1,14v2c2.76,0 5,2.24 5,5h2c0,-3.87 -3.13,-7 -7,-7zM1,10v2c4.97,0 9,4.03 9,9h2c0,-6.08 -4.93,-11 -11,-11z"/>
</vector>
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF"
android:alpha="0.8">
<path
android:fillColor="#FF000000"
android:pathData="M1,18v3h3c0,-1.66 -1.34,-3 -3,-3zM1,14v2c2.76,0 5,2.24 5,5h2c0,-3.87 -3.13,-7 -7,-7zM19,7L5,7v1.63c3.96,1.28 7.09,4.41 8.37,8.37L19,17L19,7zM1,10v2c4.97,0 9,4.03 9,9h2c0,-6.08 -4.93,-11 -11,-11zM21,3L3,3c-1.1,0 -2,0.9 -2,2v3h2L3,5h18v14h-7v2h7c1.1,0 2,-0.9 2,-2L23,5c0,-1.1 -0.9,-2 -2,-2z"/>
</vector>
Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/smallIconBackground" />
<corners android:radius="24dp" />
</shape>
@@ -1,640 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/pageBackground">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/file_view_global_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/file_view_loading_state"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/file_view_loading_container"
android:visibility="gone"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<ProgressBar
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginRight="8dp"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:fontFamily="@font/inter"
android:text="@string/loading_decentralized_data"
android:textSize="16sp"
android:textFontWeight="300" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/file_view_claim_display_area"
android:orientation="vertical"
android:layout_weight="10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<RelativeLayout
android:id="@+id/file_view_media_container"
android:background="@color/mediaContainerBackground"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3.25">
<RelativeLayout
android:id="@+id/file_view_media_meta_container"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/file_view_thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/file_view_main_action_loading"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_centerInParent="true" />
<com.google.android.material.button.MaterialButton
android:id="@+id/file_view_main_action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="invisible"
android:text="@string/play" />
<LinearLayout
android:id="@+id/file_view_fee_container"
android:background="@drawable/bg_stream_cost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:paddingLeft="6dp"
android:paddingRight="7dp"
android:visibility="gone">
<io.lbry.browser.ui.controls.SolidIconView
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_gravity="center_vertical"
android:textSize="8dp"
android:text="@string/fa_coins"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/file_view_fee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="1dp"
android:fontFamily="@font/inter"
android:textColor="@android:color/black"
android:textSize="14sp"
android:textFontWeight="300" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/file_view_exoplayer_container"
android:background="@android:color/black"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/file_view_exoplayer_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:controller_layout_id="@layout/exo_playback_control_view"/>
<ProgressBar
android:id="@+id/player_buffering_progress"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/file_view_unsupported_container"
android:background="@color/mediaContainerBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="36dp"
android:visibility="gone">
<ImageView
android:id="@+id/file_view_unsupported_gerbil"
android:src="@drawable/gerbil_happy"
android:layout_width="64dp"
android:layout_centerVertical="true"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_toRightOf="@id/file_view_unsupported_gerbil"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_centerVertical="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:textColor="@color/white"
android:textSize="18sp"
android:text="@string/unsupported_content" />
<TextView
android:id="@+id/file_view_unsupported_text"
android:fontFamily="@font/inter"
android:text="@string/unsupported_content_desc"
android:textColor="@color/white"
android:textSize="14sp"
android:textFontWeight="300"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/file_view_scroll_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6.75"
android:clipToPadding="false">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/file_view_title_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="4dp">
<LinearLayout
android:id="@+id/file_view_title_layout"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="48dp">
<TextView
android:id="@+id/file_view_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:layout_marginTop="4dp"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/file_view_view_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:fontFamily="@font/inter"
android:textSize="12sp"
android:textFontWeight="300"
android:visibility="gone" />
<TextView
android:id="@+id/file_view_publish_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:textSize="12sp"
android:textFontWeight="300" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/file_view_desc_toggle_arrow"
android:src="@drawable/ic_arrow_dropdown"
android:layout_toLeftOf="@+id/file_view_title_layout"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_width="24dp"
android:layout_height="24dp"
android:tint="@color/foreground" />
</RelativeLayout>
<LinearLayout
android:id="@+id/file_view_actions_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="5">
<LinearLayout
android:id="@+id/file_view_action_share"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<ImageView
android:tint="@color/foreground"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_share" />
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_action_tip"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<io.lbry.browser.ui.controls.SolidIconView
android:textColor="@color/foreground"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:textSize="20dp"
android:text="@string/fa_gift"/>
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_action_repost"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<io.lbry.browser.ui.controls.SolidIconView
android:textColor="@color/foreground"
android:layout_centerInParent="true"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_horizontal"
android:textSize="20dp"
android:text="@string/fa_repost"/>
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/repost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_action_edit"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:visibility="gone">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<ImageView
android:tint="@color/foreground"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_edit" />
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_action_download"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<ProgressBar
android:id="@+id/file_view_download_progress"
android:layout_width="36dp"
android:layout_height="36dp"
style="?android:progressBarStyleHorizontal"
android:progressDrawable="@drawable/determinate_progress_circle"
android:visibility="gone" />
<ImageView
android:id="@+id/file_view_action_download_icon"
android:tint="@color/foreground"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_download" />
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/download"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_action_delete"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:visibility="gone">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<ImageView
android:tint="@color/foreground"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_delete" />
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_action_report"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<ImageView
android:tint="@color/foreground"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_report" />
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/report"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</LinearLayout>
<View
android:background="@color/divider"
android:layout_width="match_parent"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:layout_height="0.5dp" />
<RelativeLayout
android:id="@+id/file_view_publisher_area"
android:layout_width="match_parent"
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">
<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:fontFamily="@font/inter"
android:textFontWeight="600" />
</LinearLayout>
<io.lbry.browser.ui.controls.SolidIconView
android:id="@+id/file_view_icon_follow_unfollow"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_alignParentRight="true"
android:layout_width="24dp"
android:layout_height="24dp"
android:text="@string/fa_heart"
android:textColor="@color/red"
android:textSize="20dp" />
</RelativeLayout>
<View
android:background="@color/divider"
android:layout_width="match_parent"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:layout_height="0.5dp" />
<LinearLayout
android:id="@+id/file_view_description_area"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:id="@+id/file_view_description"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:autoLink="all"
android:textColorLink="@color/lbryGreen"
android:textFontWeight="300"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" />
<LinearLayout
android:id="@+id/file_view_tag_area"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:layout_marginTop="36dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<TextView
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:text="@string/tags"
android:textSize="12sp"
android:textFontWeight="600" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/file_view_tag_list"
android:layout_weight="8"
android:layout_marginLeft="8dp"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:background="@color/divider"
android:layout_width="match_parent"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:layout_height="0.5dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_related_content_area"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/related_content"
android:fontFamily="@font/inter"
android:textSize="16sp"
android:layout_centerVertical="true" />
<ProgressBar
android:id="@+id/file_view_related_content_progress"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:visibility="gone" />
</RelativeLayout>
<TextView
android:id="@+id/file_view_no_related_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:fontFamily="@font/inter"
android:text="@string/no_related_content"
android:textSize="14sp"
android:textFontWeight="300"
android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/file_view_related_content_list"
android:overScrollMode="never"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
<RelativeLayout
android:id="@+id/file_view_imageviewer_container"
android:background="@android:color/black"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/file_view_imageviewer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/file_view_webview_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<WebView
android:id="@+id/file_view_webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<include layout="@layout/floating_wallet_balance" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
@@ -5,7 +5,6 @@
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
+194 -1
View File
@@ -2,6 +2,7 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/app_bar_main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
@@ -58,7 +59,6 @@
</LinearLayout>
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content_main" />
@@ -71,6 +71,7 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:id="@+id/splash_view_loading_container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -90,6 +91,198 @@
android:layout_height="24dp"
android:layout_marginTop="48dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/splash_view_error_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical"
android:visibility="gone"
android:padding="24dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:text="@string/oops_something_went_wrong"
android:textSize="20sp"
android:textColor="@color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:layout_marginTop="8dp"
android:text="@string/startup_failed"
android:textColor="@color/white"
android:textFontWeight="300"
android:textSize="14sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/startup_stage_icon_install_id"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="center_vertical"
android:tint="@color/white"
android:src="@drawable/ic_check" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_gravity="center_vertical"
android:fontFamily="@font/inter"
android:text="@string/installation_id_loaded"
android:textColor="@color/white"
android:textFontWeight="300"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/startup_stage_icon_known_tags"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="center_vertical"
android:tint="@color/white"
android:src="@drawable/ic_check" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_gravity="center_vertical"
android:fontFamily="@font/inter"
android:text="@string/known_tags_loaded"
android:textColor="@color/white"
android:textFontWeight="300"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/startup_stage_icon_exchange_rate"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="center_vertical"
android:tint="@color/white"
android:src="@drawable/ic_check" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_gravity="center_vertical"
android:fontFamily="@font/inter"
android:text="@string/exchange_rate_loaded"
android:textColor="@color/white"
android:textFontWeight="300"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/startup_stage_icon_user_authenticated"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="center_vertical"
android:tint="@color/white"
android:src="@drawable/ic_check" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_gravity="center_vertical"
android:fontFamily="@font/inter"
android:text="@string/user_authenticated"
android:textColor="@color/white"
android:textFontWeight="300"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/startup_stage_icon_install_new"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="center_vertical"
android:tint="@color/white"
android:src="@drawable/ic_check" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_gravity="center_vertical"
android:fontFamily="@font/inter"
android:text="@string/installation_registered"
android:textColor="@color/white"
android:textFontWeight="300"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/startup_stage_icon_subscriptions_loaded"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="center_vertical"
android:tint="@color/white"
android:src="@drawable/ic_check" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_gravity="center_vertical"
android:fontFamily="@font/inter"
android:text="@string/subscriptions_loaded"
android:textColor="@color/white"
android:textFontWeight="300"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/startup_stage_icon_subscriptions_resolved"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="center_vertical"
android:tint="@color/white"
android:src="@drawable/ic_check" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_gravity="center_vertical"
android:fontFamily="@font/inter"
android:text="@string/subscriptions_resolved"
android:textColor="@color/white"
android:textFontWeight="300"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
+3 -2
View File
@@ -2,6 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
@@ -20,9 +21,9 @@
android:id="@+id/url_suggestions_container"
android:background="@color/pageBackground"
android:elevation="6dp"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/url_suggestions"
android:layout_width="match_parent"
@@ -21,7 +21,25 @@
style="@style/ExoMediaButton.Pause" />
<RelativeLayout
android:id="@+id/player_toggle_full_screen"
android:id="@+id/player_toggle_cast"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:visibility="gone">
<ImageView
android:id="@+id/player_image_cast_toggle"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_cast"
android:tint="@color/white" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/player_toggle_fullscreen"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_width="48dp"
@@ -41,12 +59,12 @@
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@id/player_toggle_full_screen"
android:layout_toLeftOf="@id/player_toggle_fullscreen"
android:paddingLeft="16dp"
android:paddingRight="4dp">
<TextView
android:id="@+id/player_duration_elapsed"
android:layout_width="wrap_content"
android:layout_width="64dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="@font/inter"
@@ -59,18 +77,19 @@
android:layout_toRightOf="@id/player_duration_elapsed"
android:layout_width="match_parent"
android:layout_height="24dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_centerVertical="true"
app:scrubber_color="@color/scrubberColor"
app:played_color="@color/playedColor"
app:buffered_color="@color/bufferedColor" />
<TextView
android:id="@+id/player_duration_total"
android:layout_width="wrap_content"
android:layout_width="64dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:gravity="end"
android:fontFamily="@font/inter"
android:text="@string/zero_duration"
android:textColor="@color/white"
@@ -54,6 +54,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_above="@+id/channel_view_tabs"
android:layout_toRightOf="@id/channel_view_icon_container"
android:orientation="vertical">
@@ -66,7 +67,9 @@
android:paddingRight="4dp"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:ellipsize="end"
android:fontFamily="@font/inter"
android:maxLines="2"
android:textSize="20sp"
android:textColor="@color/white" />
<TextView
@@ -25,15 +25,22 @@
android:layout_height="match_parent"
android:src="@drawable/default_channel_cover"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/channel_form_cover_edit_icon"
android:layout_width="16dp"
android:layout_height="16dp"
<RelativeLayout
android:background="@drawable/bg_small_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="16dp"
android:layout_alignParentBottom="true"
android:src="@drawable/ic_edit"
android:tint="@color/white" />
android:layout_alignParentBottom="true">
<ImageView
android:id="@+id/channel_form_cover_edit_icon"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_edit"
android:tint="@color/white" />
</RelativeLayout>
<LinearLayout
android:id="@+id/channel_form_upload_progress"
@@ -92,14 +99,21 @@
android:id="@+id/channel_form_thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
<RelativeLayout
android:background="@drawable/bg_small_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="16dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_edit"
android:tint="@color/white" />
android:layout_centerHorizontal="true">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_edit"
android:tint="@color/white" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
@@ -0,0 +1,641 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/file_view_global_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/file_view_loading_state"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/file_view_loading_container"
android:visibility="gone"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<ProgressBar
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginRight="8dp"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:fontFamily="@font/inter"
android:text="@string/loading_decentralized_data"
android:textSize="16sp"
android:textFontWeight="300" />
</LinearLayout>
<include layout="@layout/container_nothing_at_location" />
</RelativeLayout>
<LinearLayout
android:id="@+id/file_view_claim_display_area"
android:orientation="vertical"
android:layout_weight="10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<RelativeLayout
android:id="@+id/file_view_media_container"
android:background="@color/mediaContainerBackground"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3.25">
<RelativeLayout
android:id="@+id/file_view_media_meta_container"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/file_view_thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/file_view_main_action_loading"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_centerInParent="true" />
<com.google.android.material.button.MaterialButton
android:id="@+id/file_view_main_action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="invisible"
android:text="@string/play" />
<LinearLayout
android:id="@+id/file_view_fee_container"
android:background="@drawable/bg_stream_cost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:paddingLeft="6dp"
android:paddingRight="7dp"
android:visibility="gone">
<io.lbry.browser.ui.controls.SolidIconView
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_gravity="center_vertical"
android:textSize="8dp"
android:text="@string/fa_coins"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/file_view_fee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="1dp"
android:fontFamily="@font/inter"
android:textColor="@android:color/black"
android:textSize="14sp"
android:textFontWeight="300" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/file_view_exoplayer_container"
android:background="@android:color/black"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/file_view_exoplayer_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:controller_layout_id="@layout/exo_playback_control_view"/>
<ProgressBar
android:id="@+id/player_buffering_progress"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/file_view_unsupported_container"
android:background="@color/mediaContainerBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="36dp"
android:visibility="gone">
<ImageView
android:id="@+id/file_view_unsupported_gerbil"
android:src="@drawable/gerbil_happy"
android:layout_width="64dp"
android:layout_centerVertical="true"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_toRightOf="@id/file_view_unsupported_gerbil"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_centerVertical="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:textColor="@color/white"
android:textSize="18sp"
android:text="@string/unsupported_content" />
<TextView
android:id="@+id/file_view_unsupported_text"
android:fontFamily="@font/inter"
android:text="@string/unsupported_content_desc"
android:textColor="@color/white"
android:textSize="14sp"
android:textFontWeight="300"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<com.google.android.exoplayer2.ui.PlayerControlView android:id="@+id/file_view_cast_control_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:repeat_toggle_modes="all|one"
app:show_timeout="-1"/>
<androidx.core.widget.NestedScrollView
android:id="@+id/file_view_scroll_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6.75"
android:clipToPadding="false">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/file_view_title_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="4dp">
<LinearLayout
android:id="@+id/file_view_title_layout"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="48dp">
<TextView
android:id="@+id/file_view_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:layout_marginTop="4dp"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/file_view_view_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:fontFamily="@font/inter"
android:textSize="12sp"
android:textFontWeight="300"
android:visibility="gone" />
<TextView
android:id="@+id/file_view_publish_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:textSize="12sp"
android:textFontWeight="300" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/file_view_desc_toggle_arrow"
android:src="@drawable/ic_arrow_dropdown"
android:layout_toLeftOf="@+id/file_view_title_layout"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_width="24dp"
android:layout_height="24dp"
android:tint="@color/foreground" />
</RelativeLayout>
<LinearLayout
android:id="@+id/file_view_actions_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="5">
<LinearLayout
android:id="@+id/file_view_action_share"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<ImageView
android:tint="@color/foreground"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_share" />
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_action_tip"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<io.lbry.browser.ui.controls.SolidIconView
android:textColor="@color/foreground"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:textSize="20dp"
android:text="@string/fa_gift"/>
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_action_repost"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<io.lbry.browser.ui.controls.SolidIconView
android:textColor="@color/foreground"
android:layout_centerInParent="true"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_horizontal"
android:textSize="20dp"
android:text="@string/fa_repost"/>
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/repost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_action_edit"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:visibility="gone">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<ImageView
android:tint="@color/foreground"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_edit" />
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_action_download"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<ProgressBar
android:id="@+id/file_view_download_progress"
android:layout_width="36dp"
android:layout_height="36dp"
style="?android:progressBarStyleHorizontal"
android:progressDrawable="@drawable/determinate_progress_circle"
android:visibility="gone" />
<ImageView
android:id="@+id/file_view_action_download_icon"
android:tint="@color/foreground"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_download" />
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/download"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_action_delete"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:visibility="gone">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<ImageView
android:tint="@color/foreground"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_delete" />
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_action_report"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<RelativeLayout
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal">
<ImageView
android:tint="@color/foreground"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_report" />
</RelativeLayout>
<TextView
android:fontFamily="@font/inter"
android:textSize="12sp"
android:text="@string/report"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</LinearLayout>
<View
android:background="@color/divider"
android:layout_width="match_parent"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:layout_height="0.5dp" />
<RelativeLayout
android:id="@+id/file_view_publisher_area"
android:layout_width="match_parent"
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">
<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:fontFamily="@font/inter"
android:textFontWeight="600" />
</LinearLayout>
<io.lbry.browser.ui.controls.SolidIconView
android:id="@+id/file_view_icon_follow_unfollow"
android:clickable="true"
android:background="?attr/selectableItemBackground"
android:layout_alignParentRight="true"
android:layout_width="24dp"
android:layout_height="24dp"
android:text="@string/fa_heart"
android:textColor="@color/red"
android:textSize="20dp" />
</RelativeLayout>
<View
android:background="@color/divider"
android:layout_width="match_parent"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:layout_height="0.5dp" />
<LinearLayout
android:id="@+id/file_view_description_area"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:id="@+id/file_view_description"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:autoLink="all"
android:textColorLink="@color/lbryGreen"
android:textFontWeight="300"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" />
<LinearLayout
android:id="@+id/file_view_tag_area"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:layout_marginTop="36dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<TextView
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:text="@string/tags"
android:textSize="12sp"
android:textFontWeight="600" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/file_view_tag_list"
android:layout_weight="8"
android:layout_marginLeft="8dp"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:background="@color/divider"
android:layout_width="match_parent"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:layout_height="0.5dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/file_view_related_content_area"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/related_content"
android:fontFamily="@font/inter"
android:textSize="16sp"
android:layout_centerVertical="true" />
<ProgressBar
android:id="@+id/file_view_related_content_progress"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:visibility="gone" />
</RelativeLayout>
<TextView
android:id="@+id/file_view_no_related_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:fontFamily="@font/inter"
android:text="@string/no_related_content"
android:textSize="14sp"
android:textFontWeight="300"
android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/file_view_related_content_list"
android:overScrollMode="never"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
<RelativeLayout
android:id="@+id/file_view_imageviewer_container"
android:background="@android:color/black"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/file_view_imageviewer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/file_view_webview_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<WebView
android:id="@+id/file_view_webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,345 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/pageBackground">
<androidx.cardview.widget.CardView
android:id="@+id/library_filter_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp">
<TextView
android:id="@+id/library_filter_link_downloads"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="@font/inter"
android:text="@string/downloads"
android:textStyle="bold" />
<TextView
android:id="@+id/library_filter_link_history"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_toRightOf="@id/library_filter_link_downloads"
android:fontFamily="@font/inter"
android:text="@string/history"
android:textSize="14sp" />
<ProgressBar
android:id="@+id/library_list_loading"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:visibility="gone" />
<TextView
android:id="@+id/library_show_stats"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:layout_alignParentRight="true"
android:fontFamily="@font/inter"
android:text="@string/stats"
android:textColor="@color/lbryGreen"
android:textFontWeight="300"
android:textSize="12sp"
android:visibility="gone" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/library_storage_stats_card"
android:layout_below="@id/library_filter_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/library_storage_stat_used"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:text="@string/zero"
android:textColor="@color/lbryGreen"
android:textFontWeight="300"
android:textSize="30sp" />
<TextView
android:id="@+id/library_storage_stat_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:fontFamily="@font/inter"
android:text="@string/mb"
android:textColor="@color/lbryGreen"
android:textFontWeight="300"
android:textSize="20sp" />
</LinearLayout>
<TextView
android:id="@+id/library_hide_stats"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:fontFamily="@font/inter"
android:text="@string/hide"
android:textFontWeight="300"
android:textSize="12sp" />
</RelativeLayout>
<LinearLayout
android:id="@+id/library_storage_stat_distribution"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginTop="4dp"
android:orientation="horizontal"
android:weightSum="100"
android:visibility="gone">
<View
android:id="@+id/library_storage_stat_video_bar"
android:background="@color/statsVideo"
android:layout_weight="0"
android:layout_width="0dp"
android:layout_height="match_parent" />
<View
android:id="@+id/library_storage_stat_audio_bar"
android:background="@color/statsAudio"
android:layout_weight="0"
android:layout_width="0dp"
android:layout_height="match_parent" />
<View
android:id="@+id/library_storage_stat_image_bar"
android:background="@color/statsImage"
android:layout_weight="0"
android:layout_width="0dp"
android:layout_height="match_parent" />
<View
android:id="@+id/library_storage_stat_other_bar"
android:background="@color/statsOther"
android:layout_weight="0"
android:layout_width="0dp"
android:layout_height="match_parent" />
</LinearLayout>
<RelativeLayout
android:id="@+id/library_storage_legend_video"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:visibility="gone">
<View
android:id="@+id/library_storage_legend_video_icon"
android:background="@color/statsVideo"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerVertical="true" />
<TextView
android:layout_toRightOf="@id/library_storage_legend_video_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="@font/inter"
android:text="@string/video"
android:layout_marginLeft="4dp"
android:textFontWeight="300"
android:textSize="12sp" />
<TextView
android:id="@+id/library_storage_stat_video_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:fontFamily="@font/inter"
android:text="@string/zero_mb"
android:textFontWeight="300"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/library_storage_legend_audio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:visibility="gone">
<View
android:id="@+id/library_storage_legend_audio_icon"
android:background="@color/statsAudio"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerVertical="true" />
<TextView
android:layout_toRightOf="@id/library_storage_legend_audio_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="@font/inter"
android:text="@string/audio"
android:layout_marginLeft="4dp"
android:textFontWeight="300"
android:textSize="12sp" />
<TextView
android:id="@+id/library_storage_stat_audio_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:fontFamily="@font/inter"
android:text="@string/zero_mb"
android:textFontWeight="300"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/library_storage_legend_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:visibility="gone">
<View
android:id="@+id/library_storage_legend_image_icon"
android:background="@color/statsImage"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerVertical="true" />
<TextView
android:layout_toRightOf="@id/library_storage_legend_image_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="@font/inter"
android:text="@string/images"
android:layout_marginLeft="4dp"
android:textFontWeight="300"
android:textSize="12sp" />
<TextView
android:id="@+id/library_storage_stat_image_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:fontFamily="@font/inter"
android:text="@string/zero_mb"
android:textFontWeight="300"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/library_storage_legend_other"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:visibility="gone">
<View
android:id="@+id/library_storage_legend_other_icon"
android:background="@color/statsOther"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerVertical="true" />
<TextView
android:layout_toRightOf="@id/library_storage_legend_other_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="@font/inter"
android:text="@string/other"
android:layout_marginLeft="4dp"
android:textFontWeight="300"
android:textSize="12sp" />
<TextView
android:id="@+id/library_storage_stat_other_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:fontFamily="@font/inter"
android:text="@string/zero_mb"
android:textFontWeight="300"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/library_list"
android:clipToPadding="false"
android:layout_below="@id/library_storage_stats_card"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="@+id/library_empty_container"
android:background="@color/pageBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="36dp">
<ImageView
android:layout_gravity="center_horizontal"
android:layout_width="160dp"
android:layout_height="300dp"
android:adjustViewBounds="true"
android:src="@drawable/gerbil_happy" />
<TextView
android:id="@+id/library_list_empty_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:fontFamily="@font/inter"
android:text="@string/library_no_downloads"
android:textAlignment="center"
android:textSize="16sp"
android:textFontWeight="300" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/container_library_sdk_initializing"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/library_filter_card"
android:visibility="gone">
<include layout="@layout/container_sdk_initializing" android:visibility="visible" />
</RelativeLayout>
</RelativeLayout>
@@ -53,10 +53,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_centerVertical="true"
android:lineHeight="14dp"
android:fontFamily="@font/inter"
android:ellipsize="end"
android:maxLines="6"
android:maxLines="8"
android:textFontWeight="300"
android:textSize="12sp" />
</RelativeLayout>
+51 -18
View File
@@ -9,7 +9,8 @@
android:paddingBottom="8dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground">
android:foreground="?attr/selectableItemBackground"
android:background="@drawable/bg_selected_list_item">
<LinearLayout
android:id="@+id/claim_repost_info"
android:layout_width="match_parent"
@@ -168,24 +169,56 @@
android:textColor="@color/lbryGreen"
android:fontFamily="@font/inter"
android:textSize="12sp" />
<TextView
android:id="@+id/claim_publish_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:textSize="11sp"
android:textFontWeight="300" />
<TextView
android:id="@+id/claim_pending_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:text="@string/pending"
android:textSize="11sp"
android:textStyle="italic"
android:textFontWeight="300"
android:visibility="gone" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/claim_publish_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:textSize="11sp"
android:textFontWeight="300" />
<TextView
android:id="@+id/claim_pending_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:text="@string/pending"
android:textSize="11sp"
android:textStyle="italic"
android:textFontWeight="300"
android:visibility="gone" />
<TextView
android:id="@+id/claim_file_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:fontFamily="@font/inter"
android:textSize="11sp"
android:textFontWeight="300" />
</RelativeLayout>
<!-- download progress bar -->
<ProgressBar
android:id="@+id/claim_download_progress"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_marginTop="4dp"
android:visibility="invisible"
style="?android:progressBarStyleHorizontal" />
<TextView
android:id="@+id/claim_view_device"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_gravity="end"
android:ellipsize="end"
android:fontFamily="@font/inter"
android:singleLine="true"
android:textColor="@color/lightGrey"
android:textSize="10sp"
android:textFontWeight="300" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
+43 -33
View File
@@ -2,32 +2,38 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="86dp"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="vertical"
android:background="@color/pageBackground"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<RelativeLayout
android:id="@+id/sign_in_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:id="@+id/sign_in_button_container"
android:background="@color/lbryGreen"
android:clickable="true"
android:paddingTop="38dp"
android:foreground="?attr/selectableItemBackground"
android:background="@color/lbryGreen">
<TextView
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:gravity="center"
android:text="@string/sign_in"
android:fontFamily="@font/inter"
android:textSize="14sp"
android:textFontWeight="600"
android:textAllCaps="true" />
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/sign_in_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/lbryGreen"
android:paddingTop="16dp"
android:paddingBottom="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:text="@string/sign_in"
android:fontFamily="@font/inter"
android:textSize="14sp"
android:textFontWeight="600"
android:textAllCaps="true" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
@@ -35,22 +41,26 @@
android:background="@color/drawerBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="38dp"
android:visibility="gone">
<TextView
android:id="@+id/signed_in_email"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:ellipsize="middle"
android:fontFamily="@font/inter"
android:gravity="center"
android:singleLine="true"
android:textSize="14sp"
android:textAllCaps="true"
android:textColor="@color/menuItemForeground"
android:textFontWeight="300" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingBottom="16dp">
<TextView
android:id="@+id/signed_in_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ellipsize="middle"
android:fontFamily="@font/inter"
android:gravity="center"
android:singleLine="true"
android:textSize="14sp"
android:textAllCaps="true"
android:textColor="@color/menuItemForeground"
android:textFontWeight="300" />
</RelativeLayout>
</RelativeLayout>
<View
+2
View File
@@ -12,6 +12,7 @@
<color name="menuItemForeground">#AAAAAA</color>
<color name="selectedNavItem">#0E0E0E</color>
<color name="channelCoverBackground">#CC000000</color>
<color name="smallIconBackground">#55000000</color>
<color name="costBackground">#F4E866</color>
<color name="playerControlsBackground">#33000000</color>
@@ -48,6 +49,7 @@
<color name="uriDescBlue">#3971DB</color>
<color name="rewardDriverBlue">#2196f3</color>
<color name="statsVideo">@color/nextLbryGreen</color>
<color name="statsAudio">#F6A637</color>
<color name="statsImage">#FF4A7D</color>
<color name="statsOther">#26BCF7</color>
+2
View File
@@ -12,6 +12,7 @@
<color name="menuItemForeground">#444444</color>
<color name="selectedNavItem">#F1F1F1</color>
<color name="channelCoverBackground">#CC000000</color>
<color name="smallIconBackground">#55000000</color>
<color name="costBackground">#F4E866</color>
<color name="playerControlsBackground">#33000000</color>
@@ -47,6 +48,7 @@
<color name="uriDescBlue">#3971DB</color>
<color name="rewardDriverBlue">#2196f3</color>
<color name="statsVideo">@color/nextLbryGreen</color>
<color name="statsAudio">#F6A637</color>
<color name="statsImage">#FF4A7D</color>
<color name="statsOther">#26BCF7</color>
+41 -1
View File
@@ -67,12 +67,13 @@
<string name="nothing_at_this_location">There\'s nothing at this location.</string>
<string name="publish_something_here">Publish something here</string>
<string name="cannot_view_claim">This content cannot be accessed at this time. Please try again later.</string>
<string name="zero_duration">00:00</string>
<string name="zero_duration">0:00</string>
<string name="claim_file_not_found">The file at "%1$s" does not exist.</string>
<string name="confirm_purchase">Confirm Purchase</string>
<string name="delete_file">Delete file</string>
<string name="confirm_delete_file_message">Are you sure you want to remove this file from your device?</string>
<string name="unable_to_view_url">Failed to load %1$s. Please try again later.</string>
<string name="no_cast_session_available">There is no cast session available at this time.</string>
<plurals name="view_count">
<item quantity="one">%1$s view</item>
<item quantity="other">%1$s views</item>
@@ -92,6 +93,16 @@
<item quantity="other">%1$s followers</item>
</plurals>
<!-- Splash -->
<string name="oops_something_went_wrong">Oops! Something went wrong.</string>
<string name="installation_id_loaded">Loaded Installation ID.</string>
<string name="known_tags_loaded">Loaded local known and followed tags.</string>
<string name="exchange_rate_loaded">Loaded LBC/USD exchange rate.</string>
<string name="user_authenticated">User authenticated.</string>
<string name="installation_registered">Installation registered.</string>
<string name="subscriptions_loaded">Loaded subscriptions.</string>
<string name="subscriptions_resolved">Resolved subscriptions.</string>
<!-- Settings -->
<string name="user_interface">Content &amp; User interface</string>
<string name="other">Other</string>
@@ -294,6 +305,7 @@
<string name="at">\@</string>
<string name="deposit">Deposit</string>
<string name="deposit_remains_yours">This LBC remains yours. It is a deposit to reserve the name and can be undone at any time.</string>
<string name="storage_permission_rationale_download">LBRY requires access to download content to your device.</string>
<string name="storage_permission_rationale_images">LBRY requires access to load images from your device storage.</string>
<string name="select_thumbnail">Select thumbnail</string>
<string name="select_cover">Select cover image</string>
@@ -311,6 +323,7 @@
<string name="item_pending_blockchain">The claim is pending publish on the blockchain. You will be able to access or edit the claim in a few moments.</string>
<string name="pending">Pending</string>
<string name="create">Create</string>
<string name="one_or_more_channels_failed_abandon">One or moe channels could not be deleted at this time. Please try again later.</string>
<plurals name="min_deposit_required">
<item quantity="one">A minimum deposit of %1$s credit is required.</item>
<item quantity="other">A minimum deposit of %1$s credits is required.</item>
@@ -319,6 +332,10 @@
<item quantity="one">Are you sure you want to delete the selected channel?</item>
<item quantity="other">Are you sure you want to delete the selected channels?</item>
</plurals>
<plurals name="channels_deleted">
<item quantity="one">The channel was successfully deleted.</item>
<item quantity="other">The channels were successfully deleted.</item>
</plurals>
<!-- Rewards -->
<string name="lbry_credits_allow">LBRY credits allow you to publish or purchase content.</string>
@@ -362,6 +379,29 @@
<string name="invite_link_copied">Invite link copied.</string>
<string name="invite_sent_to">Invite sent to %1$s</string>
<!-- Library -->
<string name="downloads">Downloads</string>
<string name="history">History</string>
<string name="library_no_downloads">You have not downloaded any content to this device.</string>
<string name="library_no_history">You have not viewed any content on this device.</string>
<string name="hide">Hide</string>
<string name="stats">Stats</string>
<string name="video">Video</string>
<string name="audio">Audio</string>
<string name="images">Images</string>
<string name="mb">MB</string>
<string name="kb">KB</string>
<string name="gb">GB</string>
<string name="zero_mb">0MB</string>
<plurals name="confirm_delete_files">
<item quantity="one">Are you sure you want to remove the selected file from your device?</item>
<item quantity="other">Are you sure you want to remove the selected files from your device?</item>
</plurals>
<plurals name="files_deleted">
<item quantity="one">The file was successfully deleted.</item>
<item quantity="other">The files were successfully deleted.</item>
</plurals>
<!-- About -->
<string name="about_lbry">About LBRY</string>
<string name="content_freedom">Content Freedom</string>