Native rewrite #878
14 changed files with 82 additions and 16 deletions
|
@ -81,6 +81,8 @@ dependencies {
|
||||||
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
||||||
implementation 'com.atlassian.commonmark:commonmark:0.14.0'
|
implementation 'com.atlassian.commonmark:commonmark:0.14.0'
|
||||||
|
|
||||||
|
implementation 'com.arthenica:mobile-ffmpeg-full:4.3.1.LTS'
|
||||||
|
|
||||||
compileOnly 'org.projectlombok:lombok:1.18.10'
|
compileOnly 'org.projectlombok:lombok:1.18.10'
|
||||||
annotationProcessor 'org.projectlombok:lombok:1.18.10'
|
annotationProcessor 'org.projectlombok:lombok:1.18.10'
|
||||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||||
|
|
|
@ -88,6 +88,8 @@ import java.util.Map;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import io.lbry.browser.adapter.NavigationMenuAdapter;
|
import io.lbry.browser.adapter.NavigationMenuAdapter;
|
||||||
import io.lbry.browser.adapter.UrlSuggestionListAdapter;
|
import io.lbry.browser.adapter.UrlSuggestionListAdapter;
|
||||||
|
@ -148,6 +150,7 @@ import io.lbry.lbrysdk.ServiceHelper;
|
||||||
import io.lbry.lbrysdk.Utils;
|
import io.lbry.lbrysdk.Utils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements SdkStatusListener {
|
public class MainActivity extends AppCompatActivity implements SdkStatusListener {
|
||||||
|
|
||||||
|
@ -176,6 +179,8 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
private Map<String, Fragment> openNavFragments;
|
private Map<String, Fragment> openNavFragments;
|
||||||
private static final Map<Class, Integer> fragmentClassNavIdMap = new HashMap<>();
|
private static final Map<Class, Integer> fragmentClassNavIdMap = new HashMap<>();
|
||||||
static {
|
static {
|
||||||
|
Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);
|
||||||
|
|
||||||
fragmentClassNavIdMap.put(FollowingFragment.class, NavMenuItem.ID_ITEM_FOLLOWING);
|
fragmentClassNavIdMap.put(FollowingFragment.class, NavMenuItem.ID_ITEM_FOLLOWING);
|
||||||
fragmentClassNavIdMap.put(EditorsChoiceFragment.class, NavMenuItem.ID_ITEM_EDITORS_CHOICE);
|
fragmentClassNavIdMap.put(EditorsChoiceFragment.class, NavMenuItem.ID_ITEM_EDITORS_CHOICE);
|
||||||
fragmentClassNavIdMap.put(AllContentFragment.class, NavMenuItem.ID_ITEM_ALL_CONTENT);
|
fragmentClassNavIdMap.put(AllContentFragment.class, NavMenuItem.ID_ITEM_ALL_CONTENT);
|
||||||
|
@ -944,6 +949,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
|
|
||||||
public void clearWunderbarFocus(View view) {
|
public void clearWunderbarFocus(View view) {
|
||||||
findViewById(R.id.wunderbar).clearFocus();
|
findViewById(R.id.wunderbar).clearFocus();
|
||||||
|
findViewById(R.id.wunderbar_container).requestFocus();
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,6 +394,9 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
|
||||||
centerCrop().
|
centerCrop().
|
||||||
placeholder(R.drawable.bg_thumbnail_placeholder).
|
placeholder(R.drawable.bg_thumbnail_placeholder).
|
||||||
into(vh.thumbnailView);
|
into(vh.thumbnailView);
|
||||||
|
vh.thumbnailView.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
vh.thumbnailView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal cost = item.getActualCost(Lbryio.LBCUSDRate);
|
BigDecimal cost = item.getActualCost(Lbryio.LBCUSDRate);
|
||||||
|
|
|
@ -267,7 +267,8 @@ public class Claim {
|
||||||
if (viewHistory.getCost() != null && viewHistory.getCost().doubleValue() > 0) {
|
if (viewHistory.getCost() != null && viewHistory.getCost().doubleValue() > 0) {
|
||||||
Fee fee = new Fee();
|
Fee fee = new Fee();
|
||||||
fee.setAmount(String.valueOf(viewHistory.getCost().doubleValue()));
|
fee.setAmount(String.valueOf(viewHistory.getCost().doubleValue()));
|
||||||
fee.setCurrency("LBC"); // always LBC
|
fee.setCurrency(viewHistory.getCurrency());
|
||||||
|
value.setFee(fee);
|
||||||
}
|
}
|
||||||
|
|
||||||
claim.setValue(value);
|
claim.setValue(value);
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class ViewHistory {
|
||||||
private String claimId;
|
private String claimId;
|
||||||
private String claimName;
|
private String claimName;
|
||||||
private BigDecimal cost;
|
private BigDecimal cost;
|
||||||
|
private String currency;
|
||||||
private String title;
|
private String title;
|
||||||
private String publisherClaimId;
|
private String publisherClaimId;
|
||||||
private String publisherName;
|
private String publisherName;
|
||||||
|
@ -40,7 +41,9 @@ public class ViewHistory {
|
||||||
Claim.StreamMetadata value = (Claim.StreamMetadata) metadata;
|
Claim.StreamMetadata value = (Claim.StreamMetadata) metadata;
|
||||||
history.setReleaseTime(value.getReleaseTime());
|
history.setReleaseTime(value.getReleaseTime());
|
||||||
if (value.getFee() != null) {
|
if (value.getFee() != null) {
|
||||||
history.setCost(claim.getActualCost(Lbryio.LBCUSDRate));
|
Fee fee = value.getFee();
|
||||||
|
history.setCost(new BigDecimal(fee.getAmount()));
|
||||||
|
history.setCurrency(fee.getCurrency());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (history.getReleaseTime() == 0) {
|
if (history.getReleaseTime() == 0) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import io.lbry.browser.model.lbryinc.Subscription;
|
||||||
import io.lbry.browser.utils.Helper;
|
import io.lbry.browser.utils.Helper;
|
||||||
import io.lbry.browser.utils.LbryUri;
|
import io.lbry.browser.utils.LbryUri;
|
||||||
import io.lbry.browser.utils.Lbryio;
|
import io.lbry.browser.utils.Lbryio;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
// background task to create a diff of local and remote subscriptions and try to merge
|
// background task to create a diff of local and remote subscriptions and try to merge
|
||||||
public class MergeSubscriptionsTask extends AsyncTask<Void, Void, List<Subscription>> {
|
public class MergeSubscriptionsTask extends AsyncTask<Void, Void, List<Subscription>> {
|
||||||
|
@ -84,8 +85,8 @@ public class MergeSubscriptionsTask extends AsyncTask<Void, Void, List<Subscript
|
||||||
LbryUri uri = LbryUri.parse(local.getUrl());
|
LbryUri uri = LbryUri.parse(local.getUrl());
|
||||||
Map<String, String> options = new HashMap<>();
|
Map<String, String> options = new HashMap<>();
|
||||||
options.put("claim_id", uri.getChannelClaimId());
|
options.put("claim_id", uri.getChannelClaimId());
|
||||||
options.put("channel_name", local.getChannelName());
|
options.put("channel_name", Helper.normalizeChannelName(local.getChannelName()));
|
||||||
Lbryio.call("subscription", "new", options, context);
|
Lbryio.parseResponse(Lbryio.call("subscription", "new", options, context));
|
||||||
} catch (LbryUriException | LbryioRequestException | LbryioResponseException ex) {
|
} catch (LbryUriException | LbryioRequestException | LbryioResponseException ex) {
|
||||||
// pass
|
// pass
|
||||||
Log.e(TAG, String.format("subscription/new failed: %s", ex.getMessage()), ex);
|
Log.e(TAG, String.format("subscription/new failed: %s", ex.getMessage()), ex);
|
||||||
|
|
|
@ -1056,8 +1056,11 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showExoplayerView() {
|
private void showExoplayerView() {
|
||||||
getView().findViewById(R.id.file_view_unsupported_container).setVisibility(View.GONE);
|
View root = getView();
|
||||||
getView().findViewById(R.id.file_view_exoplayer_container).setVisibility(View.VISIBLE);
|
if (root != null) {
|
||||||
|
root.findViewById(R.id.file_view_unsupported_container).setVisibility(View.GONE);
|
||||||
|
root.findViewById(R.id.file_view_exoplayer_container).setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playMedia() {
|
private void playMedia() {
|
||||||
|
@ -1537,12 +1540,14 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
private void enableFullScreenMode() {
|
private void enableFullScreenMode() {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (context instanceof MainActivity) {
|
if (context instanceof MainActivity) {
|
||||||
ConstraintLayout globalLayout = getView().findViewById(R.id.file_view_global_layout);
|
View root = getView();
|
||||||
View exoplayerContainer = getView().findViewById(R.id.file_view_exoplayer_container);
|
ConstraintLayout globalLayout = root.findViewById(R.id.file_view_global_layout);
|
||||||
|
View exoplayerContainer = root.findViewById(R.id.file_view_exoplayer_container);
|
||||||
((ViewGroup) exoplayerContainer.getParent()).removeView(exoplayerContainer);
|
((ViewGroup) exoplayerContainer.getParent()).removeView(exoplayerContainer);
|
||||||
globalLayout.addView(exoplayerContainer);
|
globalLayout.addView(exoplayerContainer);
|
||||||
|
|
||||||
((ImageView) getView().findViewById(R.id.player_image_full_screen_toggle)).setImageResource(R.drawable.ic_fullscreen_exit);
|
root.findViewById(R.id.player_image_full_screen_toggle).setVisibility(View.GONE);
|
||||||
|
root.findViewById(R.id.player_image_full_screen_exit_toggle).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
MainActivity activity = (MainActivity) context;
|
MainActivity activity = (MainActivity) context;
|
||||||
activity.enterFullScreenMode();
|
activity.enterFullScreenMode();
|
||||||
|
@ -1558,13 +1563,15 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (context instanceof MainActivity) {
|
if (context instanceof MainActivity) {
|
||||||
MainActivity activity = (MainActivity) context;
|
MainActivity activity = (MainActivity) context;
|
||||||
|
View root = getView();
|
||||||
|
|
||||||
RelativeLayout mediaContainer = getView().findViewById(R.id.file_view_media_container);
|
RelativeLayout mediaContainer = root.findViewById(R.id.file_view_media_container);
|
||||||
View exoplayerContainer = getView().findViewById(R.id.file_view_exoplayer_container);
|
View exoplayerContainer = root.findViewById(R.id.file_view_exoplayer_container);
|
||||||
((ViewGroup) exoplayerContainer.getParent()).removeView(exoplayerContainer);
|
((ViewGroup) exoplayerContainer.getParent()).removeView(exoplayerContainer);
|
||||||
mediaContainer.addView(exoplayerContainer);
|
mediaContainer.addView(exoplayerContainer);
|
||||||
|
|
||||||
((ImageView) getView().findViewById(R.id.player_image_full_screen_toggle)).setImageResource(R.drawable.ic_fullscreen);
|
root.findViewById(R.id.player_image_full_screen_toggle).setVisibility(View.VISIBLE);
|
||||||
|
root.findViewById(R.id.player_image_full_screen_exit_toggle).setVisibility(View.GONE);
|
||||||
exoplayerContainer.setPadding(0, 0, 0, 0);
|
exoplayerContainer.setPadding(0, 0, 0, 0);
|
||||||
|
|
||||||
activity.exitFullScreenMode();
|
activity.exitFullScreenMode();
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class TransactionHistoryFragment extends BaseFragment implements Transact
|
||||||
}
|
}
|
||||||
public void onClaimUrlClicked(LbryUri uri) {
|
public void onClaimUrlClicked(LbryUri uri) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (context instanceof MainActivity) {
|
if (uri != null && context instanceof MainActivity) {
|
||||||
MainActivity activity = (MainActivity) context;
|
MainActivity activity = (MainActivity) context;
|
||||||
if (uri.isChannel()) {
|
if (uri.isChannel()) {
|
||||||
activity.openChannelUrl(uri.toString());
|
activity.openChannelUrl(uri.toString());
|
||||||
|
|
|
@ -17,6 +17,7 @@ import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
@ -154,6 +155,25 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
|
||||||
public void onSuccess(List<Transaction> transactions, boolean hasReachedEnd) {
|
public void onSuccess(List<Transaction> transactions, boolean hasReachedEnd) {
|
||||||
hasFetchedRecentTransactions = true;
|
hasFetchedRecentTransactions = true;
|
||||||
recentTransactionsAdapter = new TransactionListAdapter(transactions, getContext());
|
recentTransactionsAdapter = new TransactionListAdapter(transactions, getContext());
|
||||||
|
recentTransactionsAdapter.setListener(new TransactionListAdapter.TransactionClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onTransactionClicked(Transaction transaction) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClaimUrlClicked(LbryUri uri) {
|
||||||
|
Context context = getContext();
|
||||||
|
if (uri != null && context instanceof MainActivity) {
|
||||||
|
MainActivity activity = (MainActivity) context;
|
||||||
|
if (uri.isChannel()) {
|
||||||
|
activity.openChannelUrl(uri.toString());
|
||||||
|
} else {
|
||||||
|
activity.openFileUrl(uri.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
recentTransactionsList.setAdapter(recentTransactionsAdapter);
|
recentTransactionsList.setAdapter(recentTransactionsAdapter);
|
||||||
displayNoRecentTransactions();
|
displayNoRecentTransactions();
|
||||||
}
|
}
|
||||||
|
@ -215,7 +235,9 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
LinearLayoutManager llm = new LinearLayoutManager(context);
|
LinearLayoutManager llm = new LinearLayoutManager(context);
|
||||||
recentTransactionsList.setLayoutManager(llm);
|
recentTransactionsList.setLayoutManager(llm);
|
||||||
recentTransactionsList.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
|
DividerItemDecoration itemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL);
|
||||||
|
itemDecoration.setDrawable(ContextCompat.getDrawable(context, R.drawable.thin_divider));
|
||||||
|
recentTransactionsList.addItemDecoration(itemDecoration);
|
||||||
|
|
||||||
buttonSignUp.setOnClickListener(new View.OnClickListener() {
|
buttonSignUp.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -674,4 +674,10 @@ public final class Helper {
|
||||||
new SaveViewHistoryTask(viewHistory, dbHelper, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new SaveViewHistoryTask(viewHistory, dbHelper, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static String normalizeChannelName(String channelName) {
|
||||||
|
if (!channelName.startsWith("@")) {
|
||||||
|
return String.format("@%s", channelName);
|
||||||
|
}
|
||||||
|
return channelName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
5
app/src/main/res/drawable/thin_divider.xml
Normal file
5
app/src/main/res/drawable/thin_divider.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||||
|
<size android:height="0.5dp" />
|
||||||
|
<solid android:color="@color/divider" />
|
||||||
|
</shape>
|
|
@ -24,6 +24,8 @@
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay">
|
app:popupTheme="@style/AppTheme.PopupOverlay">
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/wunderbar_container"
|
android:id="@+id/wunderbar_container"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="24dp">
|
android:layout_marginRight="24dp">
|
||||||
|
|
|
@ -53,6 +53,14 @@
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:src="@drawable/ic_fullscreen"
|
android:src="@drawable/ic_fullscreen"
|
||||||
android:tint="@color/white" />
|
android:tint="@color/white" />
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/player_image_full_screen_exit_toggle"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:src="@drawable/ic_fullscreen_exit"
|
||||||
|
android:tint="@color/white"
|
||||||
|
android:visibility="gone" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
android:background="@color/mediaContainerBackground"
|
android:background="@color/mediaContainerBackground"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="3.25">
|
android:layout_weight="3.55">
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/file_view_media_meta_container"
|
android:id="@+id/file_view_media_meta_container"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
|
@ -173,7 +173,7 @@
|
||||||
android:id="@+id/file_view_scroll_view"
|
android:id="@+id/file_view_scroll_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="6.75"
|
android:layout_weight="6.45"
|
||||||
android:clipToPadding="false">
|
android:clipToPadding="false">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
|
Loading…
Reference in a new issue