diff --git a/app/src/main/assets/font_awesome_5_free_regular.otf b/app/src/main/assets/font_awesome_5_free_regular.otf new file mode 100644 index 00000000..7b525099 Binary files /dev/null and b/app/src/main/assets/font_awesome_5_free_regular.otf differ diff --git a/app/src/main/java/io/lbry/browser/ui/channel/ChannelFragment.java b/app/src/main/java/io/lbry/browser/ui/channel/ChannelFragment.java index 5c5d9aed..0f325bc8 100644 --- a/app/src/main/java/io/lbry/browser/ui/channel/ChannelFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/channel/ChannelFragment.java @@ -49,6 +49,7 @@ import io.lbry.browser.tasks.claim.ClaimListResultHandler; import io.lbry.browser.tasks.claim.ResolveTask; import io.lbry.browser.tasks.lbryinc.FetchStatCountTask; import io.lbry.browser.ui.BaseFragment; +import io.lbry.browser.ui.controls.OutlineIconView; import io.lbry.browser.ui.controls.SolidIconView; import io.lbry.browser.ui.findcontent.FollowingFragment; import io.lbry.browser.utils.Helper; @@ -80,7 +81,8 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen private View buttonTip; private View buttonFollowUnfollow; private int subCount; - private SolidIconView iconFollowUnfollow; + private OutlineIconView iconFollow; + private SolidIconView iconUnfollow; private View layoutNothingAtLocation; private View layoutLoadingState; @@ -105,7 +107,8 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen buttonShare = root.findViewById(R.id.channel_view_share); buttonTip = root.findViewById(R.id.channel_view_tip); buttonFollowUnfollow = root.findViewById(R.id.channel_view_follow_unfollow); - iconFollowUnfollow = root.findViewById(R.id.channel_view_icon_follow_unfollow); + iconFollow = root.findViewById(R.id.channel_view_icon_follow); + iconUnfollow = root.findViewById(R.id.channel_view_icon_unfollow); tabPager = root.findViewById(R.id.channel_view_pager); tabLayout = root.findViewById(R.id.channel_view_tabs); @@ -274,13 +277,8 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen private void checkIsFollowing() { if (claim != null) { boolean isFollowing = Lbryio.isFollowing(claim); - if (iconFollowUnfollow != null) { - iconFollowUnfollow.setText(isFollowing ? R.string.fa_heart_broken : R.string.fa_heart); - Context context = getContext(); - if (context != null) { - iconFollowUnfollow.setTextColor(ContextCompat.getColor(context, isFollowing ? R.color.foreground : R.color.red)); - } - } + Helper.setViewVisibility(iconFollow, !isFollowing ? View.VISIBLE : View.GONE); + Helper.setViewVisibility(iconUnfollow, isFollowing ? View.VISIBLE : View.GONE); } } diff --git a/app/src/main/java/io/lbry/browser/ui/controls/OutlineIconView.java b/app/src/main/java/io/lbry/browser/ui/controls/OutlineIconView.java new file mode 100644 index 00000000..46c3c2b2 --- /dev/null +++ b/app/src/main/java/io/lbry/browser/ui/controls/OutlineIconView.java @@ -0,0 +1,29 @@ +package io.lbry.browser.ui.controls; + +import android.content.Context; +import android.graphics.Typeface; +import android.util.AttributeSet; +import android.view.Gravity; + +import androidx.appcompat.widget.AppCompatTextView; + +public class OutlineIconView extends AppCompatTextView { + private Context context; + + public OutlineIconView(Context context) { + super(context); + this.context = context; + init(); + } + + public OutlineIconView(Context context, AttributeSet attrs) { + super(context, attrs); + this.context = context; + init(); + } + + private void init() { + setGravity(Gravity.CENTER); + setTypeface(Typeface.createFromAsset(context.getAssets(), "font_awesome_5_free_regular.otf")); + } +} diff --git a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java index a3d0a1d1..4f7a5b71 100644 --- a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java @@ -9,6 +9,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.graphics.Color; +import android.graphics.Outline; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; @@ -141,6 +142,7 @@ import io.lbry.browser.tasks.lbryinc.ClaimRewardTask; import io.lbry.browser.tasks.lbryinc.FetchStatCountTask; import io.lbry.browser.tasks.lbryinc.LogFileViewTask; import io.lbry.browser.ui.BaseFragment; +import io.lbry.browser.ui.controls.OutlineIconView; import io.lbry.browser.ui.controls.SolidIconView; import io.lbry.browser.ui.publish.PublishFragment; import io.lbry.browser.utils.Helper; @@ -724,6 +726,44 @@ public class FileViewFragment extends BaseFragment implements } } + private View.OnClickListener followUnfollowListener = new View.OnClickListener() { + @Override + public void onClick(View view) { + if (claim != null && claim.getSigningChannel() != null) { + Claim publisher = claim.getSigningChannel(); + boolean isFollowing = Lbryio.isFollowing(publisher); + Subscription subscription = Subscription.fromClaim(publisher); + view.setEnabled(false); + Context context = getContext(); + new ChannelSubscribeTask(context, publisher.getClaimId(), subscription, isFollowing, new ChannelSubscribeTask.ChannelSubscribeHandler() { + @Override + public void onSuccess() { + if (isFollowing) { + Lbryio.removeSubscription(subscription); + Lbryio.removeCachedResolvedSubscription(publisher); + } else { + Lbryio.addSubscription(subscription); + Lbryio.addCachedResolvedSubscription(publisher); + } + view.setEnabled(true); + checkIsFollowing(); + FollowingFragment.resetClaimSearchContent = true; + + // Save shared user state + if (context != null) { + context.sendBroadcast(new Intent(MainActivity.ACTION_SAVE_SHARED_USER_STATE)); + } + } + + @Override + public void onError(Exception exception) { + view.setEnabled(true); + } + }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + } + }; + private void resolveUrl(String url) { resolving = true; Helper.setViewVisibility(layoutDisplayArea, View.INVISIBLE); @@ -1060,44 +1100,10 @@ public class FileViewFragment extends BaseFragment implements } }); - View buttonFollowUnfollow = root.findViewById(R.id.file_view_icon_follow_unfollow); - buttonFollowUnfollow.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (claim != null && claim.getSigningChannel() != null) { - Claim publisher = claim.getSigningChannel(); - boolean isFollowing = Lbryio.isFollowing(publisher); - Subscription subscription = Subscription.fromClaim(publisher); - buttonFollowUnfollow.setEnabled(false); - Context context = getContext(); - new ChannelSubscribeTask(context, publisher.getClaimId(), subscription, isFollowing, new ChannelSubscribeTask.ChannelSubscribeHandler() { - @Override - public void onSuccess() { - if (isFollowing) { - Lbryio.removeSubscription(subscription); - Lbryio.removeCachedResolvedSubscription(publisher); - } else { - Lbryio.addSubscription(subscription); - Lbryio.addCachedResolvedSubscription(publisher); - } - buttonFollowUnfollow.setEnabled(true); - checkIsFollowing(); - FollowingFragment.resetClaimSearchContent = true; - - // Save shared user state - if (context != null) { - context.sendBroadcast(new Intent(MainActivity.ACTION_SAVE_SHARED_USER_STATE)); - } - } - - @Override - public void onError(Exception exception) { - buttonFollowUnfollow.setEnabled(true); - } - }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } - } - }); + View buttonFollow = root.findViewById(R.id.file_view_icon_follow); + View buttonUnfollow = root.findViewById(R.id.file_view_icon_unfollow); + buttonFollow.setOnClickListener(followUnfollowListener); + buttonUnfollow.setOnClickListener(followUnfollowListener); commentChannelSpinnerAdapter = new InlineChannelSpinnerAdapter(getContext(), R.layout.spinner_item_channel, new ArrayList<>()); commentChannelSpinnerAdapter.addPlaceholder(false); @@ -1418,7 +1424,17 @@ public class FileViewFragment extends BaseFragment implements } } - root.findViewById(R.id.file_view_icon_follow_unfollow).setVisibility(claim.getSigningChannel() != null ? View.VISIBLE : View.GONE); + boolean isAnonymous = claim.getSigningChannel() == null; + View iconFollow = root.findViewById(R.id.file_view_icon_follow); + View iconUnfollow = root.findViewById(R.id.file_view_icon_unfollow); + if (isAnonymous) { + if (iconFollow.getVisibility() == View.VISIBLE) { + iconFollow.setVisibility(View.INVISIBLE); + } + if (iconUnfollow.getVisibility() == View.VISIBLE) { + iconUnfollow.setVisibility(View.INVISIBLE); + } + } MaterialButton mainActionButton = root.findViewById(R.id.file_view_main_action_button); if (claim.isPlayable()) { @@ -2408,11 +2424,10 @@ public class FileViewFragment extends BaseFragment implements Context context = getContext(); View root = getView(); if (context != null && root != null) { - SolidIconView iconFollowUnfollow = root.findViewById(R.id.file_view_icon_follow_unfollow); - if (iconFollowUnfollow != null) { - iconFollowUnfollow.setText(isFollowing ? R.string.fa_heart_broken : R.string.fa_heart); - iconFollowUnfollow.setTextColor(ContextCompat.getColor(context, isFollowing ? R.color.foreground : R.color.red)); - } + OutlineIconView iconFollow = root.findViewById(R.id.file_view_icon_follow); + SolidIconView iconUnfollow = root.findViewById(R.id.file_view_icon_unfollow); + Helper.setViewVisibility(iconFollow, !isFollowing ? View.VISIBLE: View.INVISIBLE); + Helper.setViewVisibility(iconUnfollow, isFollowing ? View.VISIBLE : View.INVISIBLE); } } } diff --git a/app/src/main/res/layout/fragment_channel.xml b/app/src/main/res/layout/fragment_channel.xml index af46977f..7602a54a 100644 --- a/app/src/main/res/layout/fragment_channel.xml +++ b/app/src/main/res/layout/fragment_channel.xml @@ -210,14 +210,22 @@ android:clickable="true" android:layout_width="36dp" android:layout_height="36dp"> - + diff --git a/app/src/main/res/layout/fragment_file_view.xml b/app/src/main/res/layout/fragment_file_view.xml index ebac1449..1ff24b8e 100644 --- a/app/src/main/res/layout/fragment_file_view.xml +++ b/app/src/main/res/layout/fragment_file_view.xml @@ -484,7 +484,7 @@ android:paddingTop="12dp" android:paddingLeft="16dp" android:paddingBottom="12dp" - android:layout_toLeftOf="@id/file_view_icon_follow_unfollow"> + android:layout_toLeftOf="@id/file_view_icon_follow"> - + +