Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
230b3f0bae
8 changed files with 136 additions and 36 deletions
|
@ -14,8 +14,8 @@ android {
|
||||||
applicationId "io.lbry.browser"
|
applicationId "io.lbry.browser"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 1514
|
versionCode 1515
|
||||||
versionName "0.15.14"
|
versionName "0.15.15"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ dependencies {
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||||
|
|
||||||
__32bitImplementation 'io.lbry:lbrysdk32:0.76.0'
|
__32bitImplementation 'io.lbry:lbrysdk32:0.79.0'
|
||||||
__64bitImplementation 'io.lbry:lbrysdk64:0.76.0'
|
__64bitImplementation 'io.lbry:lbrysdk64:0.79.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
public static final String SECURE_VALUE_KEY_SAVED_PASSWORD = "io.lbry.browser.PX";
|
public static final String SECURE_VALUE_KEY_SAVED_PASSWORD = "io.lbry.browser.PX";
|
||||||
public static final String SECURE_VALUE_FIRST_RUN_PASSWORD = "firstRunPassword";
|
public static final String SECURE_VALUE_FIRST_RUN_PASSWORD = "firstRunPassword";
|
||||||
|
|
||||||
private static final String TAG = "io.lbry.browser.Main";
|
private static final String TAG = "LbryMain";
|
||||||
|
|
||||||
private NavigationMenuAdapter navMenuAdapter;
|
private NavigationMenuAdapter navMenuAdapter;
|
||||||
private UrlSuggestionListAdapter urlSuggestionListAdapter;
|
private UrlSuggestionListAdapter urlSuggestionListAdapter;
|
||||||
|
@ -1548,7 +1548,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
|
|
||||||
findViewById(R.id.global_sdk_initializing_status).setVisibility(View.GONE);
|
findViewById(R.id.global_sdk_initializing_status).setVisibility(View.GONE);
|
||||||
|
|
||||||
syncWalletAndLoadPreferences();
|
|
||||||
scheduleWalletBalanceUpdate();
|
scheduleWalletBalanceUpdate();
|
||||||
scheduleWalletSyncTask();
|
scheduleWalletSyncTask();
|
||||||
fetchOwnChannels();
|
fetchOwnChannels();
|
||||||
|
@ -1766,7 +1765,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
//openNavFragments.get
|
//openNavFragments.get
|
||||||
MergeSubscriptionsTask mergeTask = new MergeSubscriptionsTask(
|
MergeSubscriptionsTask mergeTask = new MergeSubscriptionsTask(
|
||||||
subscriptions,
|
subscriptions,
|
||||||
!initialSubscriptionMergeDone(),
|
initialSubscriptionMergeDone(),
|
||||||
MainActivity.this, new MergeSubscriptionsTask.MergeSubscriptionsHandler() {
|
MainActivity.this, new MergeSubscriptionsTask.MergeSubscriptionsHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Subscription> subscriptions, List<Subscription> diff) {
|
public void onSuccess(List<Subscription> subscriptions, List<Subscription> diff) {
|
||||||
|
@ -1781,7 +1780,9 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
for (Fragment fragment : openNavFragments.values()) {
|
for (Fragment fragment : openNavFragments.values()) {
|
||||||
if (fragment instanceof FollowingFragment) {
|
if (fragment instanceof FollowingFragment) {
|
||||||
// reload local subscriptions
|
// reload local subscriptions
|
||||||
((FollowingFragment) fragment).fetchLoadedSubscriptions(true);
|
Lbryio.cacheResolvedSubscriptions.clear();
|
||||||
|
FollowingFragment followingFragment = (FollowingFragment) fragment;
|
||||||
|
followingFragment.fetchLoadedSubscriptions(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1919,7 +1920,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
public void onSyncGetSuccess(WalletSync walletSync) {
|
public void onSyncGetSuccess(WalletSync walletSync) {
|
||||||
Lbryio.lastWalletSync = walletSync;
|
Lbryio.lastWalletSync = walletSync;
|
||||||
Lbryio.lastRemoteHash = walletSync.getHash();
|
Lbryio.lastRemoteHash = walletSync.getHash();
|
||||||
loadSharedUserState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2625,7 +2625,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
LbryAnalytics.logEvent(LbryAnalytics.EVENT_LBRY_NOTIFICATION_OPEN, bundle);
|
LbryAnalytics.logEvent(LbryAnalytics.EVENT_LBRY_NOTIFICATION_OPEN, bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void registerServiceActionsReceiver() {
|
private void registerServiceActionsReceiver() {
|
||||||
IntentFilter intentFilter = new IntentFilter();
|
IntentFilter intentFilter = new IntentFilter();
|
||||||
intentFilter.addAction(DownloadManager.ACTION_DOWNLOAD_EVENT);
|
intentFilter.addAction(DownloadManager.ACTION_DOWNLOAD_EVENT);
|
||||||
|
@ -2787,9 +2786,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
JSONObject startupStatus = status.getJSONObject("startup_status");
|
JSONObject startupStatus = status.getJSONObject("startup_status");
|
||||||
sdkReady = startupStatus.getBoolean("file_manager") && startupStatus.getBoolean("wallet");
|
sdkReady = startupStatus.getBoolean("file_manager") && startupStatus.getBoolean("wallet");
|
||||||
}
|
}
|
||||||
} catch (ConnectException ex) {
|
} catch (ConnectException | JSONException ex) {
|
||||||
// pass
|
|
||||||
} catch (JSONException ex) {
|
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
65
app/src/main/java/io/lbry/browser/tasks/BufferEventTask.java
Normal file
65
app/src/main/java/io/lbry/browser/tasks/BufferEventTask.java
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
package io.lbry.browser.tasks;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import io.lbry.browser.utils.Helper;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
public class BufferEventTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
private static final String TAG = "LbryBufferEvent";
|
||||||
|
private static final String ENDPOINT = "https://collector-service.api.lbry.tv/api/v1/events/video";
|
||||||
|
|
||||||
|
private String streamUrl;
|
||||||
|
private String userIdHash;
|
||||||
|
private long streamDuration;
|
||||||
|
private long streamPosition;
|
||||||
|
private long bufferDuration;
|
||||||
|
|
||||||
|
public BufferEventTask(String streamUrl, long streamDuration, long streamPosition, long bufferDuration, String userIdHash) {
|
||||||
|
this.streamUrl = streamUrl;
|
||||||
|
this.bufferDuration = bufferDuration;
|
||||||
|
this.streamDuration = streamDuration;
|
||||||
|
this.streamPosition = streamPosition;
|
||||||
|
this.userIdHash = userIdHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Void doInBackground(Void... params) {
|
||||||
|
JSONObject requestBody = new JSONObject();
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
try {
|
||||||
|
data.put("url", streamUrl);
|
||||||
|
data.put("position", streamPosition);
|
||||||
|
data.put("stream_duration", streamDuration);
|
||||||
|
//data.put("duration", bufferDuration);
|
||||||
|
|
||||||
|
requestBody.put("device", "android");
|
||||||
|
requestBody.put("type", "buffering");
|
||||||
|
requestBody.put("client", userIdHash);
|
||||||
|
requestBody.put("data", data);
|
||||||
|
|
||||||
|
RequestBody body = RequestBody.create(requestBody.toString(), Helper.JSON_MEDIA_TYPE);
|
||||||
|
Request request = new Request.Builder().url(ENDPOINT).post(body).build();
|
||||||
|
OkHttpClient client = new OkHttpClient.Builder().
|
||||||
|
writeTimeout(60, TimeUnit.SECONDS).
|
||||||
|
readTimeout(60, TimeUnit.SECONDS).
|
||||||
|
build();
|
||||||
|
|
||||||
|
Response response = client.newCall(request).execute();
|
||||||
|
String responseString = response.body().string();
|
||||||
|
Log.d(TAG, String.format("buffer event sent: %s", responseString));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// we don't want to fail if a buffer event fails to register
|
||||||
|
Log.d(TAG, String.format("buffer event log failed: %s", ex.getMessage()), ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -73,6 +73,7 @@ public class MergeSubscriptionsTask extends AsyncTask<Void, Void, List<Subscript
|
||||||
// fetch remote subscriptions
|
// fetch remote subscriptions
|
||||||
JSONArray array = (JSONArray) Lbryio.parseResponse(Lbryio.call("subscription", "list", context));
|
JSONArray array = (JSONArray) Lbryio.parseResponse(Lbryio.call("subscription", "list", context));
|
||||||
if (array != null) {
|
if (array != null) {
|
||||||
|
// check for any remote subs that may have been removed, and unsubscribe from them
|
||||||
for (int i = 0; i < array.length(); i++) {
|
for (int i = 0; i < array.length(); i++) {
|
||||||
JSONObject item = array.getJSONObject(i);
|
JSONObject item = array.getJSONObject(i);
|
||||||
String claimId = item.getString("claim_id");
|
String claimId = item.getString("claim_id");
|
||||||
|
@ -86,23 +87,21 @@ public class MergeSubscriptionsTask extends AsyncTask<Void, Void, List<Subscript
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < combined.size(); i++) {
|
List<Subscription> remoteUnsubs = new ArrayList<>();
|
||||||
Subscription local = combined.get(i);
|
List<Subscription> finalRemoteSubs = new ArrayList<>();
|
||||||
if (!remoteSubs.contains(local)) {
|
if (remoteSubs.size() > 0) {
|
||||||
// add to remote subscriptions
|
for (int i = 0; i < remoteSubs.size(); i++) {
|
||||||
try {
|
Subscription sub = remoteSubs.get(i);
|
||||||
LbryUri uri = LbryUri.parse(local.getUrl());
|
if (!combined.contains(sub)) {
|
||||||
Map<String, String> options = new HashMap<>();
|
Map<String, String> options = new HashMap<>();
|
||||||
String channelClaimId = uri.getChannelClaimId();
|
LbryUri uri = LbryUri.tryParse(sub.getUrl());
|
||||||
String channelName = Helper.normalizeChannelName(local.getChannelName());
|
if (uri != null) {
|
||||||
if (!Helper.isNullOrEmpty(channelClaimId) && !Helper.isNullOrEmpty(channelName)) {
|
options.put("claim_id", uri.getChannelClaimId());
|
||||||
options.put("claim_id", channelClaimId);
|
Lbryio.parseResponse(Lbryio.call("subscription", "delete", options, context));
|
||||||
options.put("channel_name", channelName);
|
remoteUnsubs.add(sub);
|
||||||
Lbryio.parseResponse(Lbryio.call("subscription", "new", options, context));
|
} else {
|
||||||
|
finalRemoteSubs.add(sub);
|
||||||
}
|
}
|
||||||
} catch (LbryUriException | LbryioRequestException | LbryioResponseException ex) {
|
|
||||||
// pass
|
|
||||||
Log.e(TAG, String.format("subscription/new failed: %s", ex.getMessage()), ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,13 +113,13 @@ public class MergeSubscriptionsTask extends AsyncTask<Void, Void, List<Subscript
|
||||||
diff.add(local);
|
diff.add(local);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
for (int i = 0; i < finalRemoteSubs.size(); i++) {
|
||||||
for (int i = 0; i < remoteSubs.size(); i++) {
|
Subscription remote = finalRemoteSubs.get(i);
|
||||||
Subscription remote = remoteSubs.get(i);
|
if (!combined.contains(remote)) {
|
||||||
if (!combined.contains(remote)) {
|
combined.add(remote);
|
||||||
combined.add(remote);
|
if (!diff.contains(remote)) {
|
||||||
if (!diff.contains(remote)) {
|
diff.add(remote);
|
||||||
diff.add(remote);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class SyncGetTask extends AsyncTask<Void, Void, WalletSync> {
|
||||||
if (applySyncChanges) {
|
if (applySyncChanges) {
|
||||||
if (applySyncSuccessful) {
|
if (applySyncSuccessful) {
|
||||||
handler.onSyncApplySuccess(syncHash, syncData);
|
handler.onSyncApplySuccess(syncHash, syncData);
|
||||||
} else {
|
} else if (syncApplyError != null) {
|
||||||
handler.onSyncApplyError(syncApplyError);
|
handler.onSyncApplyError(syncApplyError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,6 +120,7 @@ import io.lbry.browser.model.UrlSuggestion;
|
||||||
import io.lbry.browser.model.WalletBalance;
|
import io.lbry.browser.model.WalletBalance;
|
||||||
import io.lbry.browser.model.lbryinc.Reward;
|
import io.lbry.browser.model.lbryinc.Reward;
|
||||||
import io.lbry.browser.model.lbryinc.Subscription;
|
import io.lbry.browser.model.lbryinc.Subscription;
|
||||||
|
import io.lbry.browser.tasks.BufferEventTask;
|
||||||
import io.lbry.browser.tasks.CommentCreateWithTipTask;
|
import io.lbry.browser.tasks.CommentCreateWithTipTask;
|
||||||
import io.lbry.browser.tasks.CommentListHandler;
|
import io.lbry.browser.tasks.CommentListHandler;
|
||||||
import io.lbry.browser.tasks.CommentListTask;
|
import io.lbry.browser.tasks.CommentListTask;
|
||||||
|
@ -165,6 +166,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
WalletBalanceListener {
|
WalletBalanceListener {
|
||||||
private static final int RELATED_CONTENT_SIZE = 16;
|
private static final int RELATED_CONTENT_SIZE = 16;
|
||||||
private static final String DEFAULT_PLAYBACK_SPEED = "1x";
|
private static final String DEFAULT_PLAYBACK_SPEED = "1x";
|
||||||
|
private static final String CDN_PREFIX = "https://cdn.lbryplayer.xyz";
|
||||||
|
|
||||||
private PlayerControlView castControlView;
|
private PlayerControlView castControlView;
|
||||||
private Player currentPlayer;
|
private Player currentPlayer;
|
||||||
|
@ -292,6 +294,27 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
loadingNewClaim = false;
|
loadingNewClaim = false;
|
||||||
}
|
}
|
||||||
} else if (playbackState == Player.STATE_BUFFERING) {
|
} else if (playbackState == Player.STATE_BUFFERING) {
|
||||||
|
if (MainActivity.appPlayer != null && MainActivity.appPlayer.getCurrentPosition() > 0) {
|
||||||
|
// we only want to log a buffer event after the media has already started playing
|
||||||
|
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");
|
||||||
|
if (mediaSourceUrl.startsWith(CDN_PREFIX)) {
|
||||||
|
BufferEventTask bufferEvent = new BufferEventTask(claim.getPermanentUrl(), duration, position, 1, userIdHash);
|
||||||
|
bufferEvent.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
|
} else {
|
||||||
|
// sdk stream buffer events should be handled differently
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("url", claim.getPermanentUrl());
|
||||||
|
bundle.putLong("stream_duration", duration);
|
||||||
|
bundle.putLong("stream_position", position);
|
||||||
|
bundle.putString("user_id_hash", userIdHash);
|
||||||
|
LbryAnalytics.logEvent(LbryAnalytics.EVENT_BUFFER, bundle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
showBuffering();
|
showBuffering();
|
||||||
} else {
|
} else {
|
||||||
hideBuffering();
|
hideBuffering();
|
||||||
|
|
|
@ -30,6 +30,8 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.google.android.gms.common.util.Hex;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -37,6 +39,9 @@ import org.json.JSONObject;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -766,4 +771,14 @@ public final class Helper {
|
||||||
}
|
}
|
||||||
return id.toString();
|
return id.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String SHA256(String value) {
|
||||||
|
try {
|
||||||
|
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||||
|
byte[] hash = digest.digest(value.getBytes("UTF-8"));
|
||||||
|
return Hex.bytesToStringLowercase(hash);
|
||||||
|
} catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ public class LbryAnalytics {
|
||||||
public static final String EVENT_APP_ERROR = "app_error";
|
public static final String EVENT_APP_ERROR = "app_error";
|
||||||
public static final String EVENT_APP_LAUNCH = "app_launch";
|
public static final String EVENT_APP_LAUNCH = "app_launch";
|
||||||
public static final String EVENT_COMMENT_CREATE = "comment_create";
|
public static final String EVENT_COMMENT_CREATE = "comment_create";
|
||||||
|
public static final String EVENT_BUFFER = "buffer";
|
||||||
public static final String EVENT_EMAIL_ADDED = "email_added";
|
public static final String EVENT_EMAIL_ADDED = "email_added";
|
||||||
public static final String EVENT_EMAIL_VERIFIED = "email_verified";
|
public static final String EVENT_EMAIL_VERIFIED = "email_verified";
|
||||||
public static final String EVENT_FIRST_RUN_COMPLETED = "first_run_completed";
|
public static final String EVENT_FIRST_RUN_COMPLETED = "first_run_completed";
|
||||||
|
|
Loading…
Add table
Reference in a new issue