diff --git a/app/build.gradle b/app/build.gradle index 042ac55f..76eeffe8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -81,6 +81,8 @@ dependencies { implementation 'com.github.chrisbanes:PhotoView:2.3.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' annotationProcessor 'org.projectlombok:lombok:1.18.10' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' diff --git a/app/src/main/java/io/lbry/browser/MainActivity.java b/app/src/main/java/io/lbry/browser/MainActivity.java index 6cd3e5b8..d07cb266 100644 --- a/app/src/main/java/io/lbry/browser/MainActivity.java +++ b/app/src/main/java/io/lbry/browser/MainActivity.java @@ -88,6 +88,8 @@ import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; 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.UrlSuggestionListAdapter; @@ -148,6 +150,7 @@ import io.lbry.lbrysdk.ServiceHelper; import io.lbry.lbrysdk.Utils; import lombok.Getter; import lombok.Setter; +import okhttp3.OkHttpClient; public class MainActivity extends AppCompatActivity implements SdkStatusListener { @@ -176,6 +179,8 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener private Map openNavFragments; private static final Map fragmentClassNavIdMap = new HashMap<>(); static { + Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE); + fragmentClassNavIdMap.put(FollowingFragment.class, NavMenuItem.ID_ITEM_FOLLOWING); fragmentClassNavIdMap.put(EditorsChoiceFragment.class, NavMenuItem.ID_ITEM_EDITORS_CHOICE); 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) { findViewById(R.id.wunderbar).clearFocus(); + findViewById(R.id.wunderbar_container).requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } diff --git a/app/src/main/java/io/lbry/browser/adapter/ClaimListAdapter.java b/app/src/main/java/io/lbry/browser/adapter/ClaimListAdapter.java index 414c218a..23f9532d 100644 --- a/app/src/main/java/io/lbry/browser/adapter/ClaimListAdapter.java +++ b/app/src/main/java/io/lbry/browser/adapter/ClaimListAdapter.java @@ -394,6 +394,9 @@ public class ClaimListAdapter extends RecyclerView.Adapter 0) { Fee fee = new Fee(); fee.setAmount(String.valueOf(viewHistory.getCost().doubleValue())); - fee.setCurrency("LBC"); // always LBC + fee.setCurrency(viewHistory.getCurrency()); + value.setFee(fee); } claim.setValue(value); diff --git a/app/src/main/java/io/lbry/browser/model/ViewHistory.java b/app/src/main/java/io/lbry/browser/model/ViewHistory.java index 0940cc3a..ea668615 100644 --- a/app/src/main/java/io/lbry/browser/model/ViewHistory.java +++ b/app/src/main/java/io/lbry/browser/model/ViewHistory.java @@ -14,6 +14,7 @@ public class ViewHistory { private String claimId; private String claimName; private BigDecimal cost; + private String currency; private String title; private String publisherClaimId; private String publisherName; @@ -40,7 +41,9 @@ public class ViewHistory { Claim.StreamMetadata value = (Claim.StreamMetadata) metadata; history.setReleaseTime(value.getReleaseTime()); 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) { diff --git a/app/src/main/java/io/lbry/browser/tasks/MergeSubscriptionsTask.java b/app/src/main/java/io/lbry/browser/tasks/MergeSubscriptionsTask.java index 26e012ef..2a8df44e 100644 --- a/app/src/main/java/io/lbry/browser/tasks/MergeSubscriptionsTask.java +++ b/app/src/main/java/io/lbry/browser/tasks/MergeSubscriptionsTask.java @@ -24,6 +24,7 @@ import io.lbry.browser.model.lbryinc.Subscription; import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.LbryUri; import io.lbry.browser.utils.Lbryio; +import okhttp3.Response; // background task to create a diff of local and remote subscriptions and try to merge public class MergeSubscriptionsTask extends AsyncTask> { @@ -84,8 +85,8 @@ public class MergeSubscriptionsTask extends AsyncTask options = new HashMap<>(); options.put("claim_id", uri.getChannelClaimId()); - options.put("channel_name", local.getChannelName()); - Lbryio.call("subscription", "new", options, context); + options.put("channel_name", Helper.normalizeChannelName(local.getChannelName())); + Lbryio.parseResponse(Lbryio.call("subscription", "new", options, context)); } catch (LbryUriException | LbryioRequestException | LbryioResponseException ex) { // pass Log.e(TAG, String.format("subscription/new failed: %s", ex.getMessage()), ex); diff --git a/app/src/main/java/io/lbry/browser/ui/following/FileViewFragment.java b/app/src/main/java/io/lbry/browser/ui/following/FileViewFragment.java index 9b06b794..e8c84eb0 100644 --- a/app/src/main/java/io/lbry/browser/ui/following/FileViewFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/following/FileViewFragment.java @@ -1056,8 +1056,11 @@ public class FileViewFragment extends BaseFragment implements } private void showExoplayerView() { - getView().findViewById(R.id.file_view_unsupported_container).setVisibility(View.GONE); - getView().findViewById(R.id.file_view_exoplayer_container).setVisibility(View.VISIBLE); + View root = getView(); + 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() { @@ -1537,12 +1540,14 @@ public class FileViewFragment extends BaseFragment implements private void enableFullScreenMode() { Context context = getContext(); if (context instanceof MainActivity) { - ConstraintLayout globalLayout = getView().findViewById(R.id.file_view_global_layout); - View exoplayerContainer = getView().findViewById(R.id.file_view_exoplayer_container); + View root = getView(); + 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); 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; activity.enterFullScreenMode(); @@ -1558,13 +1563,15 @@ public class FileViewFragment extends BaseFragment implements Context context = getContext(); if (context instanceof MainActivity) { MainActivity activity = (MainActivity) context; + View root = getView(); - RelativeLayout mediaContainer = getView().findViewById(R.id.file_view_media_container); - View exoplayerContainer = getView().findViewById(R.id.file_view_exoplayer_container); + RelativeLayout mediaContainer = root.findViewById(R.id.file_view_media_container); + View exoplayerContainer = root.findViewById(R.id.file_view_exoplayer_container); ((ViewGroup) exoplayerContainer.getParent()).removeView(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); activity.exitFullScreenMode(); diff --git a/app/src/main/java/io/lbry/browser/ui/wallet/TransactionHistoryFragment.java b/app/src/main/java/io/lbry/browser/ui/wallet/TransactionHistoryFragment.java index 68b3d34b..d9b70c7c 100644 --- a/app/src/main/java/io/lbry/browser/ui/wallet/TransactionHistoryFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/wallet/TransactionHistoryFragment.java @@ -156,7 +156,7 @@ public class TransactionHistoryFragment extends BaseFragment implements Transact } public void onClaimUrlClicked(LbryUri uri) { Context context = getContext(); - if (context instanceof MainActivity) { + if (uri != null && context instanceof MainActivity) { MainActivity activity = (MainActivity) context; if (uri.isChannel()) { activity.openChannelUrl(uri.toString()); diff --git a/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java b/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java index 5be6cb42..c435e054 100644 --- a/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java @@ -17,6 +17,7 @@ import android.widget.ProgressBar; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; @@ -154,6 +155,25 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W public void onSuccess(List transactions, boolean hasReachedEnd) { hasFetchedRecentTransactions = true; 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); displayNoRecentTransactions(); } @@ -215,7 +235,9 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W Context context = getContext(); LinearLayoutManager llm = new LinearLayoutManager(context); 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() { @Override diff --git a/app/src/main/java/io/lbry/browser/utils/Helper.java b/app/src/main/java/io/lbry/browser/utils/Helper.java index 968a0e95..b1e5434b 100644 --- a/app/src/main/java/io/lbry/browser/utils/Helper.java +++ b/app/src/main/java/io/lbry/browser/utils/Helper.java @@ -674,4 +674,10 @@ public final class Helper { 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; + } } diff --git a/app/src/main/res/drawable/thin_divider.xml b/app/src/main/res/drawable/thin_divider.xml new file mode 100644 index 00000000..ea24b286 --- /dev/null +++ b/app/src/main/res/drawable/thin_divider.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index 01262108..93a043be 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -24,6 +24,8 @@ app:popupTheme="@style/AppTheme.PopupOverlay"> diff --git a/app/src/main/res/layout/exo_playback_control_view.xml b/app/src/main/res/layout/exo_playback_control_view.xml index 73ebc97c..97f6a581 100644 --- a/app/src/main/res/layout/exo_playback_control_view.xml +++ b/app/src/main/res/layout/exo_playback_control_view.xml @@ -53,6 +53,14 @@ android:layout_centerInParent="true" android:src="@drawable/ic_fullscreen" android:tint="@color/white" /> + + android:layout_weight="3.55">