Merge branch 'master' of https://github.com/lbryio/lbry-android
This commit is contained in:
commit
7c7795476f
8 changed files with 97 additions and 12 deletions
|
@ -314,6 +314,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
|
|
||||||
// preference keys
|
// preference keys
|
||||||
public static final String PREFERENCE_KEY_BACKGROUND_PLAYBACK = "io.lbry.browser.preference.userinterface.BackgroundPlayback";
|
public static final String PREFERENCE_KEY_BACKGROUND_PLAYBACK = "io.lbry.browser.preference.userinterface.BackgroundPlayback";
|
||||||
|
public static final String PREFERENCE_KEY_MEDIA_AUTOPLAY = "io.lbry.browser.preference.userinterface.MediaAutoplay";
|
||||||
public static final String PREFERENCE_KEY_DARK_MODE = "io.lbry.browser.preference.userinterface.DarkMode";
|
public static final String PREFERENCE_KEY_DARK_MODE = "io.lbry.browser.preference.userinterface.DarkMode";
|
||||||
public static final String PREFERENCE_KEY_SHOW_MATURE_CONTENT = "io.lbry.browser.preference.userinterface.ShowMatureContent";
|
public static final String PREFERENCE_KEY_SHOW_MATURE_CONTENT = "io.lbry.browser.preference.userinterface.ShowMatureContent";
|
||||||
public static final String PREFERENCE_KEY_SHOW_URL_SUGGESTIONS = "io.lbry.browser.preference.userinterface.UrlSuggestions";
|
public static final String PREFERENCE_KEY_SHOW_URL_SUGGESTIONS = "io.lbry.browser.preference.userinterface.UrlSuggestions";
|
||||||
|
@ -627,6 +628,11 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
return sp.getBoolean(PREFERENCE_KEY_BACKGROUND_PLAYBACK, true);
|
return sp.getBoolean(PREFERENCE_KEY_BACKGROUND_PLAYBACK, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMediaAutoplayEnabled() {
|
||||||
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
return sp.getBoolean(PREFERENCE_KEY_MEDIA_AUTOPLAY, true);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean initialSubscriptionMergeDone() {
|
public boolean initialSubscriptionMergeDone() {
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
return sp.getBoolean(PREFERENCE_KEY_INTERNAL_INITIAL_SUBSCRIPTION_MERGE_DONE, false);
|
return sp.getBoolean(PREFERENCE_KEY_INTERNAL_INITIAL_SUBSCRIPTION_MERGE_DONE, false);
|
||||||
|
|
|
@ -187,12 +187,24 @@ public class ChannelCommentsFragment extends Fragment implements SdkStatusListen
|
||||||
private void checkAndLoadComments() {
|
private void checkAndLoadComments() {
|
||||||
View root = getView();
|
View root = getView();
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
|
View commentsDisabledText = root.findViewById(R.id.channel_disabled_comments);
|
||||||
|
View commentForm = root.findViewById(R.id.container_comment_form);
|
||||||
RecyclerView commentsList = root.findViewById(R.id.channel_comments_list);
|
RecyclerView commentsList = root.findViewById(R.id.channel_comments_list);
|
||||||
|
|
||||||
|
if (claim.getTags().contains("disable-comments")) {
|
||||||
|
Helper.setViewVisibility(commentsDisabledText, View.VISIBLE);
|
||||||
|
Helper.setViewVisibility(commentForm, View.GONE);
|
||||||
|
Helper.setViewVisibility(commentsList, View.GONE);
|
||||||
|
} else {
|
||||||
|
Helper.setViewVisibility(commentsDisabledText, View.GONE);
|
||||||
|
Helper.setViewVisibility(commentForm, View.VISIBLE);
|
||||||
|
Helper.setViewVisibility(commentsList, View.VISIBLE);
|
||||||
if (commentsList == null || commentsList.getAdapter() == null || commentsList.getAdapter().getItemCount() == 0) {
|
if (commentsList == null || commentsList.getAdapter() == null || commentsList.getAdapter().getItemCount() == 0) {
|
||||||
loadComments();
|
loadComments();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadComments() {
|
private void loadComments() {
|
||||||
View root = getView();
|
View root = getView();
|
||||||
|
|
|
@ -503,6 +503,11 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
|
||||||
layoutLoadingState.setVisibility(View.GONE);
|
layoutLoadingState.setVisibility(View.GONE);
|
||||||
layoutDisplayArea.setVisibility(View.VISIBLE);
|
layoutDisplayArea.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
if (claim.getTags().contains("disable-support"))
|
||||||
|
buttonTip.setVisibility(View.GONE);
|
||||||
|
else
|
||||||
|
buttonTip.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
String thumbnailUrl = claim.getThumbnailUrl();
|
String thumbnailUrl = claim.getThumbnailUrl();
|
||||||
String coverUrl = claim.getCoverUrl();
|
String coverUrl = claim.getCoverUrl();
|
||||||
textTitle.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
|
textTitle.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
|
||||||
|
|
|
@ -12,7 +12,6 @@ import android.graphics.Color;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
|
@ -98,6 +97,7 @@ import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
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;
|
||||||
|
@ -209,6 +209,8 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
private View layoutResolving;
|
private View layoutResolving;
|
||||||
private int lastPositionSaved;
|
private int lastPositionSaved;
|
||||||
|
|
||||||
|
private View tipButton;
|
||||||
|
|
||||||
private WebView webView;
|
private WebView webView;
|
||||||
private boolean webViewAdded;
|
private boolean webViewAdded;
|
||||||
|
|
||||||
|
@ -254,6 +256,8 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
layoutDisplayArea = root.findViewById(R.id.file_view_claim_display_area);
|
layoutDisplayArea = root.findViewById(R.id.file_view_claim_display_area);
|
||||||
buttonPublishSomething = root.findViewById(R.id.nothing_at_location_publish_button);
|
buttonPublishSomething = root.findViewById(R.id.nothing_at_location_publish_button);
|
||||||
|
|
||||||
|
tipButton = root.findViewById(R.id.file_view_action_tip);
|
||||||
|
|
||||||
containerReplyToComment = root.findViewById(R.id.comment_form_reply_to_container);
|
containerReplyToComment = root.findViewById(R.id.comment_form_reply_to_container);
|
||||||
textReplyingTo = root.findViewById(R.id.comment_form_replying_to_text);
|
textReplyingTo = root.findViewById(R.id.comment_form_replying_to_text);
|
||||||
textReplyToBody = root.findViewById(R.id.comment_form_reply_to_body);
|
textReplyToBody = root.findViewById(R.id.comment_form_reply_to_body);
|
||||||
|
@ -283,14 +287,13 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
|
|
||||||
fileViewPlayerListener = new Player.EventListener() {
|
fileViewPlayerListener = new Player.EventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
public void onPlaybackStateChanged(@Player.State int playbackState) {
|
||||||
if (playbackState == Player.STATE_READY) {
|
if (playbackState == Player.STATE_READY) {
|
||||||
elapsedDuration = MainActivity.appPlayer.getCurrentPosition();
|
elapsedDuration = MainActivity.appPlayer.getCurrentPosition();
|
||||||
totalDuration = MainActivity.appPlayer.getDuration() < 0 ? 0 : MainActivity.appPlayer.getDuration();
|
totalDuration = MainActivity.appPlayer.getDuration() < 0 ? 0 : MainActivity.appPlayer.getDuration();
|
||||||
if (!playbackStarted) {
|
if (!playbackStarted) {
|
||||||
logPlay(currentUrl, startTimeMillis);
|
logPlay(currentUrl, startTimeMillis);
|
||||||
playbackStarted = true;
|
playbackStarted = true;
|
||||||
isPlaying = true;
|
|
||||||
|
|
||||||
long lastPosition = loadLastPlaybackPosition();
|
long lastPosition = loadLastPlaybackPosition();
|
||||||
if (lastPosition > -1) {
|
if (lastPosition > -1) {
|
||||||
|
@ -302,7 +305,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
hideBuffering();
|
hideBuffering();
|
||||||
|
|
||||||
if (loadingNewClaim) {
|
if (loadingNewClaim) {
|
||||||
MainActivity.appPlayer.setPlayWhenReady(true);
|
MainActivity.appPlayer.setPlayWhenReady(Objects.requireNonNull((MainActivity) (getActivity())).isMediaAutoplayEnabled());
|
||||||
loadingNewClaim = false;
|
loadingNewClaim = false;
|
||||||
}
|
}
|
||||||
} else if (playbackState == Player.STATE_BUFFERING) {
|
} else if (playbackState == Player.STATE_BUFFERING) {
|
||||||
|
@ -339,6 +342,11 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
hideBuffering();
|
hideBuffering();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onIsPlayingChanged(boolean isPlayng) {
|
||||||
|
isPlaying = isPlayng;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
|
@ -1485,6 +1493,11 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
Helper.setViewVisibility(layoutLoadingState, View.GONE);
|
Helper.setViewVisibility(layoutLoadingState, View.GONE);
|
||||||
Helper.setViewVisibility(layoutNothingAtLocation, View.GONE);
|
Helper.setViewVisibility(layoutNothingAtLocation, View.GONE);
|
||||||
|
|
||||||
|
if (claim.getTags().contains("disable-support") || claim.getSigningChannel().getTags().contains("disable-support"))
|
||||||
|
Helper.setViewVisibility(tipButton, View.GONE);
|
||||||
|
else
|
||||||
|
Helper.setViewVisibility(tipButton, View.VISIBLE);
|
||||||
|
|
||||||
loadViewCount();
|
loadViewCount();
|
||||||
checkIsFollowing();
|
checkIsFollowing();
|
||||||
|
|
||||||
|
@ -1667,12 +1680,23 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
private void checkAndLoadComments() {
|
private void checkAndLoadComments() {
|
||||||
View root = getView();
|
View root = getView();
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
|
View commentsDisabledText = root.findViewById(R.id.file_view_disabled_comments);
|
||||||
|
View commentForm = root.findViewById(R.id.container_comment_form);
|
||||||
RecyclerView commentsList = root.findViewById(R.id.file_view_comments_list);
|
RecyclerView commentsList = root.findViewById(R.id.file_view_comments_list);
|
||||||
|
if (claim.getTags().contains("disable-comments") || claim.getSigningChannel().getTags().contains("disable-comments")) {
|
||||||
|
Helper.setViewVisibility(commentsDisabledText, View.VISIBLE);
|
||||||
|
Helper.setViewVisibility(commentForm, View.GONE);
|
||||||
|
Helper.setViewVisibility(commentsList, View.GONE);
|
||||||
|
} else {
|
||||||
|
Helper.setViewVisibility(commentsDisabledText, View.GONE);
|
||||||
|
Helper.setViewVisibility(commentForm, View.VISIBLE);
|
||||||
|
Helper.setViewVisibility(commentsList, View.VISIBLE);
|
||||||
if (commentsList == null || commentsList.getAdapter() == null || commentsList.getAdapter().getItemCount() == 0) {
|
if (commentsList == null || commentsList.getAdapter() == null || commentsList.getAdapter().getItemCount() == 0) {
|
||||||
loadComments();
|
loadComments();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showUnsupportedView() {
|
private void showUnsupportedView() {
|
||||||
View root = getView();
|
View root = getView();
|
||||||
|
@ -1754,7 +1778,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
((MainActivity) context).setNowPlayingClaim(claim, currentUrl);
|
((MainActivity) context).setNowPlayingClaim(claim, currentUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainActivity.appPlayer.setPlayWhenReady(true);
|
MainActivity.appPlayer.setPlayWhenReady(Objects.requireNonNull((MainActivity) (getActivity())).isMediaAutoplayEnabled());
|
||||||
String userAgent = Util.getUserAgent(context, getString(R.string.app_name));
|
String userAgent = Util.getUserAgent(context, getString(R.string.app_name));
|
||||||
String mediaSourceUrl = getStreamingUrl();
|
String mediaSourceUrl = getStreamingUrl();
|
||||||
MediaSource mediaSource = new ProgressiveMediaSource.Factory(
|
MediaSource mediaSource = new ProgressiveMediaSource.Factory(
|
||||||
|
@ -1762,7 +1786,8 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
new DefaultExtractorsFactory()
|
new DefaultExtractorsFactory()
|
||||||
).setLoadErrorHandlingPolicy(new StreamLoadErrorPolicy()).createMediaSource(Uri.parse(mediaSourceUrl));
|
).setLoadErrorHandlingPolicy(new StreamLoadErrorPolicy()).createMediaSource(Uri.parse(mediaSourceUrl));
|
||||||
|
|
||||||
MainActivity.appPlayer.prepare(mediaSource, true, true);
|
MainActivity.appPlayer.setMediaSource(mediaSource, true);
|
||||||
|
MainActivity.appPlayer.prepare();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,27 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include layout="@layout/container_comment_form"
|
<include layout="@layout/container_comment_form"
|
||||||
|
android:id="@+id/container_comment_form"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="0dp"
|
android:layout_marginTop="0dp"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_marginBottom="16dp" />
|
android:layout_marginBottom="16dp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/channel_disabled_comments"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:fontFamily="@font/inter"
|
||||||
|
android:text="@string/channel_disabled_comments"
|
||||||
|
android:textFontWeight="300"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/channel_no_comments"
|
android:id="@+id/channel_no_comments"
|
||||||
|
|
|
@ -845,7 +845,21 @@
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<include layout="@layout/container_comment_form" />
|
<include layout="@layout/container_comment_form"
|
||||||
|
android:id="@+id/container_comment_form"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/file_view_disabled_comments"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:fontFamily="@font/inter"
|
||||||
|
android:text="@string/creator_disabled_comments"
|
||||||
|
android:textFontWeight="300"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/file_view_no_comments"
|
android:id="@+id/file_view_no_comments"
|
||||||
|
|
|
@ -64,6 +64,8 @@
|
||||||
<string name="no_comments">No comments to display at this time.</string>
|
<string name="no_comments">No comments to display at this time.</string>
|
||||||
<string name="sdk_initializing_comments">Comments will display after the background service is initialized.</string>
|
<string name="sdk_initializing_comments">Comments will display after the background service is initialized.</string>
|
||||||
<string name="comment_error">Your comment could not be posted at this time. Please try again later.</string>
|
<string name="comment_error">Your comment could not be posted at this time. Please try again later.</string>
|
||||||
|
<string name="channel_disabled_comments">This channel has disabled comments on their page.</string>
|
||||||
|
<string name="creator_disabled_comments">The creator of this content has disabled comments.</string>
|
||||||
<string name="share_lbry_content">Share LBRY content</string>
|
<string name="share_lbry_content">Share LBRY content</string>
|
||||||
<string name="view">View</string>
|
<string name="view">View</string>
|
||||||
<string name="play">Play</string>
|
<string name="play">Play</string>
|
||||||
|
@ -247,6 +249,7 @@
|
||||||
<string name="user_interface">Content & User interface</string>
|
<string name="user_interface">Content & User interface</string>
|
||||||
<string name="other">Other</string>
|
<string name="other">Other</string>
|
||||||
<string name="enable_background_playback">Enable background playback</string>
|
<string name="enable_background_playback">Enable background playback</string>
|
||||||
|
<string name="enable_autoplay">Autoplay media files</string>
|
||||||
<string name="enable_dark_mode">Enable dark theme</string>
|
<string name="enable_dark_mode">Enable dark theme</string>
|
||||||
<string name="show_mature_content">Show mature content</string>
|
<string name="show_mature_content">Show mature content</string>
|
||||||
<string name="show_url_suggestions">Show URL suggestions</string>
|
<string name="show_url_suggestions">Show URL suggestions</string>
|
||||||
|
|
|
@ -10,6 +10,11 @@
|
||||||
app:defaultValue="true"
|
app:defaultValue="true"
|
||||||
app:title="@string/enable_background_playback"
|
app:title="@string/enable_background_playback"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
app:key="io.lbry.browser.preference.userinterface.MediaAutoplay"
|
||||||
|
app:defaultValue="true"
|
||||||
|
app:title="@string/enable_autoplay"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
app:key="io.lbry.browser.preference.userinterface.DarkMode"
|
app:key="io.lbry.browser.preference.userinterface.DarkMode"
|
||||||
app:title="@string/enable_dark_mode"
|
app:title="@string/enable_dark_mode"
|
||||||
|
|
Loading…
Reference in a new issue