Fix conflicts after merging from upstream

This commit is contained in:
Javi Rueda 2021-01-12 18:48:19 +01:00
commit 2f1bed9646
No known key found for this signature in database
GPG key ID: BF881E052BAA3A4E
8 changed files with 58 additions and 36 deletions

View file

@ -14,8 +14,8 @@ android {
applicationId "io.lbry.browser"
minSdkVersion 21
targetSdkVersion 29
versionCode 1612
versionName "0.16.12"
versionCode 1613
versionName "0.16.13"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@ -92,10 +92,10 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.4.1'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.android.exoplayer:exoplayer-core:2.11.4'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.11.4'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.11.4'
implementation 'com.google.android.exoplayer:extension-mediasession:2.11.4'
implementation 'com.google.android.exoplayer:exoplayer-core:2.12.2'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.12.2'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.12.2'
implementation 'com.google.android.exoplayer:extension-mediasession:2.12.2'
implementation 'com.google.android:flexbox:2.0.1'
@ -115,6 +115,8 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

View file

@ -0,0 +1,15 @@
package io.lbry.browser.utils;
import androidx.test.filters.SmallTest;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@SmallTest
public class HelperTest {
@Test
public void SHA256() {
assertEquals("de9edb2044d012f04553e49b04d54cbec8e8a46a40ad5a19bc5dcce1da00ecfd", Helper.SHA256(String.valueOf(12345678912345L)));
}
}

View file

@ -3318,6 +3318,11 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
return String.format("%s-%d", fragmentClass.getName(), navItemId);
}
public void popFragment(Class fragmentClass, int navItemId, Map<String, Object> params) {
String key = buildNavFragmentKey(fragmentClass, navItemId, params);
openNavFragments.remove(key);
}
public void openFragment(Class fragmentClass, boolean allowNavigateBack, int navItemId, Map<String, Object> params) {
try {
String key = buildNavFragmentKey(fragmentClass, navItemId, params);

View file

@ -404,7 +404,7 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
vh.publishTimeView.setVisibility(!isPending ? View.VISIBLE : View.GONE);
vh.pendingTextView.setVisibility(isPending && !item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE);
vh.repostInfoView.setVisibility(isRepost && type != VIEW_TYPE_FEATURED ? View.VISIBLE : View.GONE);
vh.repostChannelView.setText(isRepost ? original.getSigningChannel().getName() : null);
vh.repostChannelView.setText(isRepost && original.getSigningChannel() != null ? original.getSigningChannel().getName() : null);
vh.repostChannelView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View file

@ -12,9 +12,11 @@ import android.graphics.Color;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.format.DateUtils;
import android.util.Base64;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.MenuItem;
@ -92,8 +94,6 @@ import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
@ -310,8 +310,7 @@ public class FileViewFragment extends BaseFragment implements
String mediaSourceUrl = getStreamingUrl();
long duration = MainActivity.appPlayer.getDuration();
long position = MainActivity.appPlayer.getCurrentPosition();
// TODO: Determine a hash for the userId
String userIdHash = Helper.SHA256(Lbryio.currentUser != null ? String.valueOf(Lbryio.currentUser.getId()) : "0");
String userIdHash = Lbryio.currentUser != null ? String.valueOf(Lbryio.currentUser.getId()) : "0";
if (mediaSourceUrl.startsWith(CDN_PREFIX)) {
BufferEventTask bufferEvent = new BufferEventTask(claim.getPermanentUrl(), duration, position, 1, userIdHash);
bufferEvent.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
@ -429,8 +428,11 @@ public class FileViewFragment extends BaseFragment implements
renderNothingAtLocation();
} else if (claim.getName().startsWith("@")) {
// this is a reposted channel, so launch the channel url
if (context instanceof MainActivity) {
((MainActivity) context).openChannelUrl(!Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl());
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
//activity.onBackPressed(); // remove the reposted url page from the back stack
activity.getSupportFragmentManager().popBackStack();
activity.openChannelUrl(!Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl());
}
return;
}
@ -899,7 +901,9 @@ public class FileViewFragment extends BaseFragment implements
// this is a reposted channel, so finish this activity and launch the channel url
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).openChannelUrl(!Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl());
MainActivity activity = (MainActivity) context;
activity.getSupportFragmentManager().popBackStack();
activity.openChannelUrl(!Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl());
}
return;
}
@ -1668,6 +1672,8 @@ public class FileViewFragment extends BaseFragment implements
.build();
MainActivity.appPlayer = new SimpleExoPlayer.Builder(context).build();
MainActivity.appPlayer.setWakeMode(C.WAKE_MODE_NETWORK);
MainActivity.appPlayer.setAudioAttributes(audioAttributes, true);
MainActivity.playerCache =
new SimpleCache(context.getCacheDir(),
@ -2122,19 +2128,9 @@ public class FileViewFragment extends BaseFragment implements
ReadTextFileTask task = new ReadTextFileTask(filePath, new ReadTextFileTask.ReadTextFileHandler() {
@Override
public void onSuccess(String text) {
String html = buildMarkdownHtml(text);
if (webView != null) {
// Due to a change to Chrome, WebView only displays '#' -and everything after it-
// if it is '%23' instead. Problem appears in text like '#2' or #hashtags.
Pattern pattern = Pattern.compile("#(\\S+)");
Matcher matcher = pattern.matcher(html);
if (matcher.find()) {
html = html.replaceAll(pattern.toString(), "&%2335;" + matcher.group(1));
}
webView.loadData(html, "text/html", "utf-8");
String html = buildMarkdownHtml(text);
webView.loadData(Base64.encodeToString(html.getBytes(), Base64.NO_PADDING), "text/html", "base64");
}
}

View file

@ -131,8 +131,7 @@ public class ShuffleFragment extends BaseFragment {
String mediaSourceUrl = getStreamingUrl();
long duration = MainActivity.appPlayer.getDuration();
long position = MainActivity.appPlayer.getCurrentPosition();
// TODO: Determine a hash for the userId
String userIdHash = Helper.SHA256(Lbryio.currentUser != null ? String.valueOf(Lbryio.currentUser.getId()) : "0");
String userIdHash = Lbryio.currentUser != null ? String.valueOf(Lbryio.currentUser.getId()) : "0";
if (mediaSourceUrl.startsWith(FileViewFragment.CDN_PREFIX)) {
BufferEventTask bufferEvent = new BufferEventTask(current.getPermanentUrl(), duration, position, 1, userIdHash);
bufferEvent.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
@ -448,6 +447,7 @@ public class ShuffleFragment extends BaseFragment {
.build();
MainActivity.appPlayer = new SimpleExoPlayer.Builder(context).build();
MainActivity.appPlayer.setWakeMode(C.WAKE_MODE_NETWORK);
MainActivity.appPlayer.setAudioAttributes(audioAttributes, true);
MainActivity.playerCache =
new SimpleCache(context.getCacheDir(),

View file

@ -6,9 +6,13 @@ import android.os.Handler;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.audio.AudioCapabilities;
import com.google.android.exoplayer2.audio.AudioProcessor;
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
import com.google.android.exoplayer2.audio.AudioSink;
import com.google.android.exoplayer2.audio.DefaultAudioSink;
import com.google.android.exoplayer2.audio.TeeAudioProcessor;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
@ -30,22 +34,18 @@ public class ExoplayerAudioRenderer extends DefaultRenderersFactory {
Context context,
int extensionRendererMode,
MediaCodecSelector mediaCodecSelector,
@Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
boolean playClearSamplesWithoutKeys,
boolean enableDecoderFallback,
AudioProcessor[] audioProcessors,
AudioSink audioSink,
Handler eventHandler,
AudioRendererEventListener eventListener,
ArrayList<Renderer> out) {
AudioProcessor[] audioProcessorList = { new TeeAudioProcessor(audioBufferSink) };
super.buildAudioRenderers(
context,
extensionRendererMode,
mediaCodecSelector,
drmSessionManager,
playClearSamplesWithoutKeys,
enableDecoderFallback,
audioProcessorList,
audioSink,
eventHandler,
eventListener,
out);

View file

@ -795,7 +795,11 @@ public final class Helper {
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(value.getBytes(StandardCharsets.UTF_8));
return Hex.encodeHexString(hash, true);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O_MR1)
return Hex.encodeHexString(hash, true);
else
return new String(Hex.encodeHex(hash)).toLowerCase();
} catch (NoSuchAlgorithmException ex) {
return null;
}