Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c7c4d1a88 | ||
|
|
f5390316a7 | ||
|
|
da1ea77aa9 | ||
|
|
8ea48977ae | ||
|
|
6721db54e2 | ||
|
|
6a7079c8b2 | ||
|
|
8cc7e9d6c9 | ||
|
|
d0ac41c242 | ||
|
|
bc8f476ef1 | ||
|
|
2d01b63cfe | ||
|
|
88dc31e9af | ||
|
|
8d1e5eb64d | ||
|
|
8113ef3f8a | ||
|
|
a74ed0e93b | ||
|
|
11f42bf71e | ||
|
|
8eb96025ec | ||
|
|
1ece7ff433 | ||
|
|
e312c451f8 | ||
|
|
bb64e91648 | ||
|
|
69398f6a2c | ||
|
|
bef7aa0ae9 | ||
|
|
2776696501 | ||
|
|
fa075df278 | ||
|
|
05311fd3a1 | ||
|
|
79001239d9 | ||
|
|
e344733bf0 | ||
|
|
282fdbb903 | ||
|
|
ee7c571101 | ||
|
|
87e42d6b7e | ||
|
|
8fcf135280 | ||
|
|
ae9364ad7e | ||
|
|
6aa44d8a9e | ||
|
|
3f013d1272 | ||
|
|
94d1f5a4eb | ||
|
|
1d8a7d838b | ||
|
|
c5d441fa1f | ||
|
|
4276a78a81 | ||
|
|
36c24a448f | ||
|
|
4bf1051549 | ||
|
|
fc4ab3128c | ||
|
|
65d32ea13e | ||
|
|
4cd8c80226 | ||
|
|
7adcdc43cf | ||
|
|
77852dc135 | ||
|
|
746ca62ca7 | ||
|
|
5e993f0fcc | ||
|
|
168dbba62c | ||
|
|
4db7bf814c | ||
|
|
21a3ff318b |
No files matched your search
+2
-2
@@ -6,7 +6,7 @@ stages:
|
||||
|
||||
build arm64 apk:
|
||||
stage: build
|
||||
image: lbry/android-base:latest
|
||||
image: lbry/android-base:platform-28
|
||||
before_script:
|
||||
- export BUILD_VERSION=$(cat $CI_PROJECT_DIR/src/main/python/main.py | grep --color=never -oP '([0-9]+\.?)+')
|
||||
- git submodule sync --recursive
|
||||
@@ -37,7 +37,7 @@ build arm64 apk:
|
||||
|
||||
build arm apk:
|
||||
stage: build2
|
||||
image: lbry/android-base:latest
|
||||
image: lbry/android-base:platform-28
|
||||
before_script:
|
||||
- export BUILD_VERSION=$(cat $CI_PROJECT_DIR/src/main/python/main.py | grep --color=never -oP '([0-9]+\.?)+')
|
||||
- git submodule sync --recursive
|
||||
|
||||
+3
-2
@@ -10,8 +10,9 @@ RUN dpkg --add-architecture i386 && \
|
||||
python-pip zlib1g-dev m4 zlib1g:i386 libc6-dev-i386 gawk nodejs npm unzip openjdk-8-jdk \
|
||||
autoconf autogen automake libtool libffi-dev build-essential \
|
||||
ccache git libncurses5:i386 libstdc++6:i386 \
|
||||
libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 && \
|
||||
npm install -g yarn react-native-cli && \
|
||||
libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386
|
||||
RUN npm install -g npm@latest
|
||||
RUN npm install -g yarn react-native-cli && \
|
||||
pip2 install --upgrade cython setuptools && \
|
||||
pip2 install git+https://github.com/lbryio/buildozer.git@master && \
|
||||
ln -s /src/scripts/build-docker.sh /usr/local/bin/build && \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017-2019 LBRY Inc
|
||||
Copyright (c) 2017-2020 LBRY Inc
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
+1
-1
Submodule app updated: bc62580aae...19d3d8cd94.
@@ -9,6 +9,9 @@ package.name = browser
|
||||
# (str) Package domain (needed for android/ios packaging)
|
||||
package.domain = io.lbry
|
||||
|
||||
# Temporary
|
||||
package.type = application
|
||||
|
||||
# (str) Source code where the main.py live
|
||||
source.dir = ./src/main/python
|
||||
|
||||
@@ -36,7 +39,7 @@ version.filename = %(source.dir)s/main.py
|
||||
|
||||
# (list) Application requirements
|
||||
# comma seperated e.g. requirements = sqlite3,kivy
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro==1.4.0, pyjnius, certifi==2018.11.29, appdirs==1.4.3, docopt==0.6.2, base58==1.0.0, colorama==0.3.7, ecdsa==0.13.3, jsonschema==2.6.0, pbkdf2==1.3, pyyaml, protobuf==3.6.1, keyring==10.4.0, defusedxml, git+https://github.com/lbryio/aioupnp.git@ab7ef0048bbce6404e463d20e8a15046ea6941f0#egg=aioupnp, asn1crypto, mock, netifaces, cryptography, aiohttp==3.5.4, multidict==4.5.2, yarl==1.3.0, chardet==3.0.4, async_timeout==3.0.1, coincurve, msgpack==0.6.1, six, attrs==18.2.0, pylru, hachoir, "git+https://github.com/lbryio/lbry-sdk@v0.51.2#egg=lbry&subdirectory=lbry", "git+https://github.com/lbryio/lbry-sdk@v0.51.2#egg=torba&subdirectory=torba"
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro==1.4.0, pyjnius, certifi==2018.11.29, appdirs==1.4.3, docopt==0.6.2, base58==1.0.0, colorama==0.3.7, ecdsa==0.13.3, jsonschema==2.6.0, pbkdf2==1.3, pyyaml, protobuf==3.6.1, keyring==10.4.0, defusedxml, git+https://github.com/lbryio/aioupnp.git@ab7ef0048bbce6404e463d20e8a15046ea6941f0#egg=aioupnp, asn1crypto, mock, netifaces, cryptography, aiohttp==3.5.4, multidict==4.5.2, yarl==1.3.0, chardet==3.0.4, async_timeout==3.0.1, coincurve, msgpack==0.6.1, six, attrs==18.2.0, pylru, hachoir, prometheus_client==0.7.1, "git+https://github.com/lbryio/lbry-sdk@v0.61.0#egg=lbry"
|
||||
|
||||
# (str) Custom source folders for requirements
|
||||
# Sets custom source for any requirements with recipes
|
||||
|
||||
@@ -9,6 +9,9 @@ package.name = browser
|
||||
# (str) Package domain (needed for android/ios packaging)
|
||||
package.domain = io.lbry
|
||||
|
||||
# Temporary
|
||||
package.type = application
|
||||
|
||||
# (str) Source code where the main.py live
|
||||
source.dir = ./src/main/python
|
||||
|
||||
@@ -36,7 +39,7 @@ version.filename = %(source.dir)s/main.py
|
||||
|
||||
# (list) Application requirements
|
||||
# comma seperated e.g. requirements = sqlite3,kivy
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro==1.4.0, pyjnius, certifi==2018.11.29, appdirs==1.4.3, docopt==0.6.2, base58==1.0.0, colorama==0.3.7, ecdsa==0.13.3, jsonschema==2.6.0, pbkdf2==1.3, pyyaml, protobuf==3.6.1, keyring==10.4.0, defusedxml, git+https://github.com/lbryio/aioupnp.git@ab7ef0048bbce6404e463d20e8a15046ea6941f0#egg=aioupnp, asn1crypto, mock, netifaces, cryptography, aiohttp==3.5.4, multidict==4.5.2, yarl==1.3.0, chardet==3.0.4, async_timeout==3.0.1, coincurve, msgpack==0.6.1, six, attrs==18.2.0, pylru, hachoir, "git+https://github.com/lbryio/lbry-sdk@v0.51.2#egg=lbry&subdirectory=lbry", "git+https://github.com/lbryio/lbry-sdk@v0.51.2#egg=torba&subdirectory=torba"
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro==1.4.0, pyjnius, certifi==2018.11.29, appdirs==1.4.3, docopt==0.6.2, base58==1.0.0, colorama==0.3.7, ecdsa==0.13.3, jsonschema==2.6.0, pbkdf2==1.3, pyyaml, protobuf==3.6.1, keyring==10.4.0, defusedxml, git+https://github.com/lbryio/aioupnp.git@ab7ef0048bbce6404e463d20e8a15046ea6941f0#egg=aioupnp, asn1crypto, mock, netifaces, cryptography, aiohttp==3.5.4, multidict==4.5.2, yarl==1.3.0, chardet==3.0.4, async_timeout==3.0.1, coincurve, msgpack==0.6.1, six, attrs==18.2.0, pylru, hachoir, prometheus_client==0.7.1, "git+https://github.com/lbryio/lbry-sdk@v0.61.0#egg=lbry"
|
||||
|
||||
# (str) Custom source folders for requirements
|
||||
# Sets custom source for any requirements with recipes
|
||||
|
||||
@@ -9,6 +9,9 @@ package.name = browser
|
||||
# (str) Package domain (needed for android/ios packaging)
|
||||
package.domain = io.lbry
|
||||
|
||||
# Temporary
|
||||
package.type = application
|
||||
|
||||
# (str) Source code where the main.py live
|
||||
source.dir = ./src/main/python
|
||||
|
||||
@@ -36,7 +39,7 @@ version.filename = %(source.dir)s/main.py
|
||||
|
||||
# (list) Application requirements
|
||||
# comma seperated e.g. requirements = sqlite3,kivy
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro==1.4.0, pyjnius, certifi==2018.11.29, appdirs==1.4.3, docopt==0.6.2, base58==1.0.0, colorama==0.3.7, ecdsa==0.13.3, jsonschema==2.6.0, pbkdf2==1.3, pyyaml, protobuf==3.6.1, keyring==10.4.0, defusedxml, git+https://github.com/lbryio/aioupnp.git@ab7ef0048bbce6404e463d20e8a15046ea6941f0#egg=aioupnp, asn1crypto, mock, netifaces, cryptography, aiohttp==3.5.4, multidict==4.5.2, yarl==1.3.0, chardet==3.0.4, async_timeout==3.0.1, coincurve, msgpack==0.6.1, six, attrs==18.2.0, pylru, hachoir, "git+https://github.com/lbryio/lbry-sdk@v0.51.2#egg=lbry&subdirectory=lbry", "git+https://github.com/lbryio/lbry-sdk@v0.51.2#egg=torba&subdirectory=torba"
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro==1.4.0, pyjnius, certifi==2018.11.29, appdirs==1.4.3, docopt==0.6.2, base58==1.0.0, colorama==0.3.7, ecdsa==0.13.3, jsonschema==2.6.0, pbkdf2==1.3, pyyaml, protobuf==3.6.1, keyring==10.4.0, defusedxml, git+https://github.com/lbryio/aioupnp.git@ab7ef0048bbce6404e463d20e8a15046ea6941f0#egg=aioupnp, asn1crypto, mock, netifaces, cryptography, aiohttp==3.5.4, multidict==4.5.2, yarl==1.3.0, chardet==3.0.4, async_timeout==3.0.1, coincurve, msgpack==0.6.1, six, attrs==18.2.0, pylru, hachoir, prometheus_client==0.7.1, "git+https://github.com/lbryio/lbry-sdk@v0.61.0#egg=lbry"
|
||||
|
||||
# (str) Custom source folders for requirements
|
||||
# Sets custom source for any requirements with recipes
|
||||
|
||||
@@ -9,6 +9,9 @@ package.name = browser
|
||||
# (str) Package domain (needed for android/ios packaging)
|
||||
package.domain = io.lbry
|
||||
|
||||
# Temporary
|
||||
package.type = application
|
||||
|
||||
# (str) Source code where the main.py live
|
||||
source.dir = ./src/main/python
|
||||
|
||||
@@ -36,7 +39,7 @@ version.filename = %(source.dir)s/main.py
|
||||
|
||||
# (list) Application requirements
|
||||
# comma seperated e.g. requirements = sqlite3,kivy
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro==1.4.0, pyjnius, certifi==2018.11.29, appdirs==1.4.3, docopt==0.6.2, base58==1.0.0, colorama==0.3.7, ecdsa==0.13.3, jsonschema==2.6.0, pbkdf2==1.3, pyyaml, protobuf==3.6.1, keyring==10.4.0, defusedxml, git+https://github.com/lbryio/aioupnp.git@ab7ef0048bbce6404e463d20e8a15046ea6941f0#egg=aioupnp, asn1crypto, mock, netifaces, cryptography, aiohttp==3.5.4, multidict==4.5.2, yarl==1.3.0, chardet==3.0.4, async_timeout==3.0.1, coincurve, msgpack==0.6.1, six, attrs==18.2.0, pylru, hachoir, "git+https://github.com/lbryio/lbry-sdk@v0.51.2#egg=lbry&subdirectory=lbry", "git+https://github.com/lbryio/lbry-sdk@v0.51.2#egg=torba&subdirectory=torba"
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro==1.4.0, pyjnius, certifi==2018.11.29, appdirs==1.4.3, docopt==0.6.2, base58==1.0.0, colorama==0.3.7, ecdsa==0.13.3, jsonschema==2.6.0, pbkdf2==1.3, pyyaml, protobuf==3.6.1, keyring==10.4.0, defusedxml, git+https://github.com/lbryio/aioupnp.git@ab7ef0048bbce6404e463d20e8a15046ea6941f0#egg=aioupnp, asn1crypto, mock, netifaces, cryptography, aiohttp==3.5.4, multidict==4.5.2, yarl==1.3.0, chardet==3.0.4, async_timeout==3.0.1, coincurve, msgpack==0.6.1, six, attrs==18.2.0, pylru, hachoir, prometheus_client==0.7.1, "git+https://github.com/lbryio/lbry-sdk@v0.61.0#egg=lbry"
|
||||
|
||||
# (str) Custom source folders for requirements
|
||||
# Sets custom source for any requirements with recipes
|
||||
|
||||
@@ -2,5 +2,20 @@
|
||||
<style name="LbryAppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="android:windowBackground">@color/lbryGreen</item>
|
||||
<item name="colorControlActivated">@color/nextLbryGreen</item>
|
||||
<item name="android:spinnerItemStyle">@style/LbrySpinnerItem</item>
|
||||
<item name="android:spinnerDropDownItemStyle">@style/LbrySpinnerDropDownItem</item>
|
||||
</style>
|
||||
|
||||
<style name="LbrySpinnerItem" parent="@style/Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="android:fontFamily">Inter-Regular</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
</style>
|
||||
|
||||
<style name="LbrySpinnerDropDownItem" parent="@style/Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="android:fontFamily">Inter-Regular</item>
|
||||
<item name="android:paddingLeft">16dp</item>
|
||||
<item name="android:paddingRight">16dp</item>
|
||||
<item name="android:gravity">center_vertical</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
</style>
|
||||
</resources>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -10,6 +10,7 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
@@ -18,10 +19,11 @@ import com.facebook.react.bridge.ReactMethod;
|
||||
import io.lbry.browser.receivers.NotificationDeletedReceiver;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class DownloadManager {
|
||||
private Context context;
|
||||
@@ -30,6 +32,11 @@ public class DownloadManager {
|
||||
|
||||
private List<String> completedDownloads = new ArrayList<String>();
|
||||
|
||||
private Map<String, String> downloadIdOutpointsMap = new HashMap<String, String>();
|
||||
|
||||
// maintain a map of uris to writtenBytes, so that we check if it's changed and don't flood RN with update events every 500ms
|
||||
private Map<String, Double> writtenDownloadBytes = new HashMap<String, Double>();
|
||||
|
||||
private HashMap<Integer, NotificationCompat.Builder> builders = new HashMap<Integer, NotificationCompat.Builder>();
|
||||
|
||||
private HashMap<String, Integer> downloadIdNotificationIdMap = new HashMap<String, Integer>();
|
||||
@@ -120,7 +127,35 @@ public class DownloadManager {
|
||||
return intent;
|
||||
}
|
||||
|
||||
public void startDownload(String id, String filename) {
|
||||
public void updateWrittenBytesForDownload(String id, double writtenBytes) {
|
||||
if (!writtenDownloadBytes.containsKey(id)) {
|
||||
writtenDownloadBytes.put(id, writtenBytes);
|
||||
}
|
||||
}
|
||||
|
||||
public double getWrittenBytesForDownload(String id) {
|
||||
if (writtenDownloadBytes.containsKey(id)) {
|
||||
return writtenDownloadBytes.get(id);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void clearWrittenBytesForDownload(String id) {
|
||||
if (writtenDownloadBytes.containsKey(id)) {
|
||||
writtenDownloadBytes.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
private Intent getDeleteDownloadIntent(String uri) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(LbrynetService.ACTION_DELETE_DOWNLOAD);
|
||||
intent.putExtra("uri", uri);
|
||||
intent.putExtra("nativeDelete", true);
|
||||
return intent;
|
||||
}
|
||||
|
||||
public void startDownload(String id, String filename, String outpoint) {
|
||||
if (filename == null || filename.trim().length() == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -128,20 +163,26 @@ public class DownloadManager {
|
||||
synchronized (this) {
|
||||
if (!isDownloadActive(id)) {
|
||||
activeDownloads.add(id);
|
||||
downloadIdOutpointsMap.put(id, outpoint);
|
||||
}
|
||||
|
||||
createNotificationChannel();
|
||||
createNotificationGroup();
|
||||
|
||||
PendingIntent stopDownloadIntent = PendingIntent.getBroadcast(context, 0, getDeleteDownloadIntent(id), PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID);
|
||||
// The file URI is used as the unique ID
|
||||
builder.setContentIntent(getLaunchPendingIntent(id, context))
|
||||
builder.setColor(ContextCompat.getColor(context, R.color.lbryGreen))
|
||||
.setContentIntent(getLaunchPendingIntent(id, context))
|
||||
.setContentTitle(String.format("Downloading %s", truncateFilename(filename)))
|
||||
.setGroup(GROUP_DOWNLOADS)
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
.setProgress(MAX_PROGRESS, 0, false)
|
||||
.setSmallIcon(android.R.drawable.stat_sys_download);
|
||||
.setSmallIcon(android.R.drawable.stat_sys_download)
|
||||
.setOngoing(true)
|
||||
.addAction(android.R.drawable.ic_menu_close_clear_cancel, "Stop", stopDownloadIntent);
|
||||
|
||||
int notificationId = getNotificationId(id);
|
||||
downloadIdNotificationIdMap.put(id, notificationId);
|
||||
@@ -170,9 +211,13 @@ public class DownloadManager {
|
||||
if (builders.containsKey(notificationId)) {
|
||||
builder = builders.get(notificationId);
|
||||
} else {
|
||||
PendingIntent stopDownloadIntent = PendingIntent.getBroadcast(context, 0, getDeleteDownloadIntent(id), PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID);
|
||||
builder.setContentTitle(String.format("Downloading %s", truncateFilename(filename)))
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW);
|
||||
builder.setColor(ContextCompat.getColor(context, R.color.lbryGreen))
|
||||
.setContentTitle(String.format("Downloading %s", truncateFilename(filename)))
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
.setOngoing(true)
|
||||
.addAction(android.R.drawable.ic_menu_close_clear_cancel, "Stop", stopDownloadIntent);
|
||||
builders.put(notificationId, builder);
|
||||
}
|
||||
|
||||
@@ -189,7 +234,9 @@ public class DownloadManager {
|
||||
.setContentText(String.format("%s", formatBytes(totalBytes)))
|
||||
.setGroup(GROUP_DOWNLOADS)
|
||||
.setProgress(0, 0, false)
|
||||
.setSmallIcon(android.R.drawable.stat_sys_download_done);
|
||||
.setSmallIcon(android.R.drawable.stat_sys_download_done)
|
||||
.setOngoing(false);
|
||||
builder.mActions.clear();
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
|
||||
if (downloadIdNotificationIdMap.containsKey(id)) {
|
||||
@@ -234,11 +281,13 @@ public class DownloadManager {
|
||||
.setContentText(String.format("%s", formatBytes(totalBytes)))
|
||||
.setGroup(GROUP_DOWNLOADS)
|
||||
.setProgress(0, 0, false)
|
||||
.setSmallIcon(android.R.drawable.stat_sys_download_done);
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
.setSmallIcon(android.R.drawable.stat_sys_download_done)
|
||||
.setOngoing(false);
|
||||
builder.mActions.clear();
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
|
||||
// If there are no more downloads and the group exists, set the icon to stop animating
|
||||
checkGroupDownloadIcon(notificationManager);
|
||||
// If there are no more downloads and the group exists, set the icon to stop animating
|
||||
checkGroupDownloadIcon(notificationManager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,11 +320,22 @@ public class DownloadManager {
|
||||
return completedDownloads;
|
||||
}
|
||||
|
||||
public String getOutpointForDownload(String uri) {
|
||||
if (downloadIdOutpointsMap.containsKey(uri)) {
|
||||
return downloadIdOutpointsMap.get(uri);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void deleteDownloadUri(String uri) {
|
||||
synchronized (this) {
|
||||
activeDownloads.remove(uri);
|
||||
completedDownloads.remove(uri);
|
||||
|
||||
if (downloadIdOutpointsMap.containsKey(uri)) {
|
||||
downloadIdOutpointsMap.remove(uri);
|
||||
}
|
||||
if (downloadIdNotificationIdMap.containsKey(uri)) {
|
||||
removeDownloadNotification(uri);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class LbrynetService extends PythonService {
|
||||
|
||||
public static LbrynetService serviceInstance;
|
||||
|
||||
private static final int SDK_POLL_INTERVAL = 500; // 500 milliseconds
|
||||
private static final int SDK_POLL_INTERVAL = 1000; // 1 second
|
||||
|
||||
private BroadcastReceiver stopServiceReceiver;
|
||||
|
||||
@@ -123,7 +123,8 @@ public class LbrynetService extends PythonService {
|
||||
}
|
||||
} else if (ACTION_DELETE_DOWNLOAD.equals(action)) {
|
||||
String uri = intent.getStringExtra("uri");
|
||||
LbrynetService.this.deleteDownload(uri);
|
||||
boolean nativeDelete = intent.getBooleanExtra("nativeDelete", false);
|
||||
LbrynetService.this.deleteDownload(uri, nativeDelete);
|
||||
} else if (ACTION_CHECK_DOWNLOADS.equals(action)) {
|
||||
LbrynetService.this.checkDownloads();
|
||||
}
|
||||
@@ -210,7 +211,14 @@ public class LbrynetService extends PythonService {
|
||||
}
|
||||
|
||||
if (streamManagerReady) {
|
||||
String fileList = Utils.sdkCall("file_list");
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("page_size", 100);
|
||||
params.put("reverse", true);
|
||||
params.put("sort", "added_on");
|
||||
/*params.put("status", "stopped");
|
||||
params.put("comparison", "ne");*/
|
||||
|
||||
String fileList = Utils.sdkCall("file_list", params);
|
||||
if (fileList != null) {
|
||||
JSONObject response = new JSONObject(fileList);
|
||||
if (!response.has("error")) {
|
||||
@@ -229,7 +237,7 @@ public class LbrynetService extends PythonService {
|
||||
(new AsyncTask<Void, Void, String>() {
|
||||
protected String doInBackground(Void... param) {
|
||||
try {
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("outpoint", outpoint);
|
||||
return Utils.sdkCall("file_list", params);
|
||||
} catch (ConnectException ex) {
|
||||
@@ -244,7 +252,7 @@ public class LbrynetService extends PythonService {
|
||||
if (!response.has("error")) {
|
||||
JSONObject result = response.getJSONObject("result");
|
||||
if (result != null) {
|
||||
JSONArray fileItems = response.optJSONArray("items");
|
||||
JSONArray fileItems = result.optJSONArray("items");
|
||||
if (fileItems != null && fileItems.length() > 0) {
|
||||
// TODO: Create Java FileItem class
|
||||
JSONObject item = fileItems.getJSONObject(0);
|
||||
@@ -257,10 +265,11 @@ public class LbrynetService extends PythonService {
|
||||
String uri = String.format("lbry://%s#%s", claimName, claimId);
|
||||
|
||||
if (!downloadManager.isDownloadActive(uri) && !downloadManager.isDownloadCompleted(uri)) {
|
||||
downloadManager.clearWrittenBytesForDownload(uri);
|
||||
File file = new File(downloadPath);
|
||||
Intent intent = createDownloadEventIntent(uri, outpoint, item.toString());
|
||||
intent.putExtra("action", "start");
|
||||
downloadManager.startDownload(uri, file.getName());
|
||||
downloadManager.startDownload(uri, file.getName(), outpoint);
|
||||
|
||||
Context context = getApplicationContext();
|
||||
if (context != null) {
|
||||
@@ -280,10 +289,46 @@ public class LbrynetService extends PythonService {
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
private void deleteDownload(String uri) {
|
||||
private void deleteDownload(String uri, boolean nativeDelete) {
|
||||
final String outpoint = downloadManager.getOutpointForDownload(uri);
|
||||
if (nativeDelete && outpoint != null) {
|
||||
// send call sdk to delete the file on the corresponding outpoint
|
||||
removeDownloadFromManager(uri);
|
||||
|
||||
(new AsyncTask<Void, Void, String>() {
|
||||
protected String doInBackground(Void... param) {
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("outpoint", outpoint);
|
||||
params.put("delete_from_download_dir", true);
|
||||
return Utils.sdkCall("file_delete", params);
|
||||
} catch (ConnectException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void onPostExecute(String response) {
|
||||
// after deletion, remove the download from the download manager
|
||||
Intent intent = createDownloadEventIntent(uri, outpoint, null);
|
||||
intent.putExtra("action", "abort");
|
||||
|
||||
Context context = getApplicationContext();
|
||||
if (context != null) {
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
removeDownloadFromManager(uri);
|
||||
}
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
removeDownloadFromManager(uri);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeDownloadFromManager(String uri) {
|
||||
if (downloadManager.isDownloadActive(uri)) {
|
||||
downloadManager.abortDownload(uri);
|
||||
}
|
||||
|
||||
downloadManager.deleteDownloadUri(uri);
|
||||
}
|
||||
|
||||
@@ -295,7 +340,6 @@ public class LbrynetService extends PythonService {
|
||||
JSONArray fileItems = result.optJSONArray("items");
|
||||
if (fileItems != null) {
|
||||
try {
|
||||
//List<String> itemUris = new ArrayList<String>();
|
||||
for (int i = 0; i < fileItems.length(); i++) {
|
||||
JSONObject item = fileItems.getJSONObject(i);
|
||||
String downloadPath = item.isNull("download_path") ? null : item.getString("download_path");
|
||||
@@ -320,18 +364,29 @@ public class LbrynetService extends PythonService {
|
||||
|
||||
File file = new File(downloadPath);
|
||||
Intent intent = createDownloadEventIntent(uri, outpoint, item.toString());
|
||||
boolean shouldSendBroadcast = true;
|
||||
if (downloadManager.isDownloadActive(uri)) {
|
||||
if (writtenBytes >= totalBytes || completed) {
|
||||
// completed download
|
||||
downloadManager.clearWrittenBytesForDownload(uri);
|
||||
intent.putExtra("action", "complete");
|
||||
downloadManager.completeDownload(uri, file.getName(), totalBytes);
|
||||
} else {
|
||||
intent.putExtra("action", "update");
|
||||
intent.putExtra("progress", (writtenBytes / totalBytes) * 100);
|
||||
downloadManager.updateDownload(uri, file.getName(), writtenBytes, totalBytes);
|
||||
double prevWrittenBytes = downloadManager.getWrittenBytesForDownload(uri);
|
||||
if (prevWrittenBytes == writtenBytes) {
|
||||
// no change, don't send an update event
|
||||
shouldSendBroadcast = false;
|
||||
}
|
||||
downloadManager.updateWrittenBytesForDownload(uri, writtenBytes);
|
||||
|
||||
if (shouldSendBroadcast) {
|
||||
intent.putExtra("action", "update");
|
||||
intent.putExtra("progress", (writtenBytes / totalBytes) * 100);
|
||||
downloadManager.updateDownload(uri, file.getName(), writtenBytes, totalBytes);
|
||||
}
|
||||
}
|
||||
|
||||
if (context != null) {
|
||||
if (context != null && shouldSendBroadcast) {
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
} else {
|
||||
@@ -339,25 +394,17 @@ public class LbrynetService extends PythonService {
|
||||
// do not start a download that is considered completed
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!completed && downloadPath != null) {
|
||||
downloadManager.clearWrittenBytesForDownload(uri);
|
||||
intent.putExtra("action", "start");
|
||||
downloadManager.startDownload(uri, file.getName());
|
||||
downloadManager.startDownload(uri, file.getName(), outpoint);
|
||||
if (context != null) {
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check download manager uris and clear downloads that may have been cancelled / deleted
|
||||
/*List<String> activeUris = downloadManager.getActiveDownloads();
|
||||
for (int i = 0; i < activeUris.size(); i++) {
|
||||
String activeUri = activeUris.get(i);
|
||||
if (!itemUris.contains(activeUri)) {
|
||||
downloadManager.abortDownload(activeUri);
|
||||
fileListUris.remove(activeUri); // remove URIs from the session that may have been deleted
|
||||
}
|
||||
}*/
|
||||
} catch (JSONException ex) {
|
||||
// pass
|
||||
Log.e(TAG, ex.getMessage(), ex);
|
||||
|
||||
@@ -66,6 +66,7 @@ import java.net.URISyntaxException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -129,9 +130,12 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
protected String getMainComponentName() {
|
||||
return "LBRYApp";
|
||||
}
|
||||
|
||||
|
||||
public static LaunchTiming CurrentLaunchTiming;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
CurrentLaunchTiming = new LaunchTiming(new Date());
|
||||
super.onCreate(savedInstanceState);
|
||||
currentActivity = this;
|
||||
|
||||
@@ -149,6 +153,7 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
// Start the daemon service if it is not started
|
||||
serviceRunning = isServiceRunning(LbrynetService.class);
|
||||
if (!serviceRunning) {
|
||||
CurrentLaunchTiming.setColdStart(true);
|
||||
ServiceHelper.start(this, "", LbrynetService.class, "lbrynetservice");
|
||||
}
|
||||
|
||||
@@ -212,17 +217,28 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
String outpoint = intent.getStringExtra("outpoint");
|
||||
String fileInfoJson = intent.getStringExtra("file_info");
|
||||
|
||||
if (uri == null || outpoint == null || fileInfoJson == null) {
|
||||
|
||||
if (uri == null || outpoint == null || (fileInfoJson == null && !"abort".equals(downloadAction))) {
|
||||
return;
|
||||
}
|
||||
|
||||
String eventName = null;
|
||||
WritableMap params = Arguments.createMap();
|
||||
params.putString("uri", uri);
|
||||
params.putString("outpoint", outpoint);
|
||||
|
||||
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
|
||||
if ("abort".equals(downloadAction)) {
|
||||
eventName = "onDownloadAborted";
|
||||
if (reactContext != null) {
|
||||
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
String eventName = null;
|
||||
JSONObject json = new JSONObject(fileInfoJson);
|
||||
WritableMap fileInfo = JSONObjectToMap(json);
|
||||
WritableMap params = Arguments.createMap();
|
||||
params.putString("uri", uri);
|
||||
params.putString("outpoint", outpoint);
|
||||
params.putMap("fileInfo", fileInfo);
|
||||
|
||||
if (DownloadManager.ACTION_UPDATE.equals(downloadAction)) {
|
||||
@@ -233,7 +249,6 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
eventName = (DownloadManager.ACTION_START.equals(downloadAction)) ? "onDownloadStarted" : "onDownloadCompleted";
|
||||
}
|
||||
|
||||
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
|
||||
if (reactContext != null) {
|
||||
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params);
|
||||
}
|
||||
@@ -835,4 +850,26 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
public static boolean isGooglePhotosUri(Uri uri) {
|
||||
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
public static class LaunchTiming {
|
||||
private Date start;
|
||||
private boolean coldStart;
|
||||
|
||||
public LaunchTiming(Date start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public Date getStart() {
|
||||
return start;
|
||||
}
|
||||
public void setStart(Date start) {
|
||||
this.start = start;
|
||||
}
|
||||
public boolean isColdStart() {
|
||||
return coldStart;
|
||||
}
|
||||
public void setColdStart(boolean coldStart) {
|
||||
this.coldStart = coldStart;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ServiceHelper {
|
||||
|
||||
public static final String SHARED_PREFERENCES_NAME = "LBRY";
|
||||
|
||||
private static final String TAG = "io.lbry.browser.ServiceHelper";
|
||||
|
||||
@@ -34,7 +36,7 @@ public class ServiceHelper {
|
||||
|
||||
public static void start(final Context ctx, String pythonServiceArgument, Class serviceClass, String pythonName) {
|
||||
// always check initial headers status before starting the service
|
||||
final SharedPreferences sp = ctx.getSharedPreferences(MainActivity.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
final SharedPreferences sp = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
boolean initHeaders = sp.getBoolean(HEADERS_ASSET_KEY, false);
|
||||
if (initHeaders) {
|
||||
// initial headers asset copy already done. simply start the service
|
||||
|
||||
@@ -346,13 +346,13 @@ public final class Utils {
|
||||
return sdkCall(method, null);
|
||||
}
|
||||
|
||||
public static String sdkCall(String method, Map<String, String> params) throws ConnectException {
|
||||
public static String sdkCall(String method, Map<String, Object> params) throws ConnectException {
|
||||
try {
|
||||
JSONObject request = new JSONObject();
|
||||
request.put("method", method);
|
||||
if (params != null) {
|
||||
JSONObject requestParams = new JSONObject();
|
||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
requestParams.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
request.put("params", requestParams);
|
||||
|
||||
@@ -20,6 +20,7 @@ import io.lbry.browser.BuildConfig;
|
||||
import io.lbry.browser.MainActivity;
|
||||
import io.lbry.browser.Utils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.json.JSONObject;
|
||||
@@ -108,4 +109,23 @@ public class FirebaseModule extends ReactContextBaseJavaModule {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void logLaunchTiming() {
|
||||
Date end = new Date();
|
||||
MainActivity.LaunchTiming currentTiming = MainActivity.CurrentLaunchTiming;
|
||||
if (currentTiming == null) {
|
||||
// no start timing data, so skip this
|
||||
return;
|
||||
}
|
||||
|
||||
long totalTimeMs = end.getTime() - currentTiming.getStart().getTime();
|
||||
String eventName = currentTiming.isColdStart() ? "app_cold_start" : "app_warm_start";
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong("total_ms", totalTimeMs);
|
||||
bundle.putLong("total_seconds", new Double(Math.ceil(totalTimeMs / 1000.0)).longValue());
|
||||
if (firebaseAnalytics != null) {
|
||||
firebaseAnalytics.logEvent(eventName, bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,15 @@ import logging
|
||||
import pathlib
|
||||
import platform
|
||||
import sys
|
||||
import lbry.wallet
|
||||
|
||||
from jnius import autoclass
|
||||
from keyring.backend import KeyringBackend
|
||||
from lbry import __version__ as lbrynet_version, build_type
|
||||
from lbry import __version__ as lbrynet_version, build_info
|
||||
from lbry.conf import Config
|
||||
from lbry.extras.daemon.loggly_handler import get_loggly_handler
|
||||
from lbry.extras.daemon.Components import DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT
|
||||
from lbry.extras.daemon.Daemon import Daemon
|
||||
from lbry.extras.daemon.components import DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT
|
||||
from lbry.extras.daemon.daemon import Daemon
|
||||
from lbry.extras.daemon.loggly_handler import get_loggly_handler
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -19,7 +21,7 @@ log.setLevel(logging.DEBUG)
|
||||
lbrynet_android_utils = autoclass('io.lbry.browser.Utils')
|
||||
service = autoclass('io.lbry.browser.LbrynetService').serviceInstance
|
||||
platform.platform = lambda: 'Android %s (API %s)' % (lbrynet_android_utils.getAndroidRelease(), lbrynet_android_utils.getAndroidSdk())
|
||||
build_type.BUILD = 'dev' if lbrynet_android_utils.isDebug() else 'release'
|
||||
build_info.BUILD = 'dev' if lbrynet_android_utils.isDebug() else 'release'
|
||||
|
||||
# Keyring backend
|
||||
class LbryAndroidKeyring(KeyringBackend):
|
||||
@@ -66,7 +68,7 @@ def configure_logging(conf):
|
||||
logging.getLogger('lbry').setLevel(logging.DEBUG if lbrynet_android_utils.isDebug() else logging.INFO)
|
||||
logging.getLogger('torba').setLevel(logging.INFO)
|
||||
|
||||
loggly_handler = get_loggly_handler()
|
||||
loggly_handler = get_loggly_handler(conf)
|
||||
loggly_handler.setLevel(logging.ERROR)
|
||||
logging.getLogger('lbry').addHandler(loggly_handler)
|
||||
|
||||
@@ -74,7 +76,7 @@ def start():
|
||||
keyring.set_keyring(LbryAndroidKeyring())
|
||||
private_storage_dir = lbrynet_android_utils.getAppInternalStorageDir(service.getApplicationContext())
|
||||
configured_download_dir = lbrynet_android_utils.getConfiguredDownloadDirectory(service.getApplicationContext())
|
||||
print('configured_download_dir={}'.format(configured_download_dir))
|
||||
|
||||
conf = Config(
|
||||
data_dir=f'{private_storage_dir}/lbrynet',
|
||||
wallet_dir=f'{private_storage_dir}/lbryum',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
__version__ = "0.12.2"
|
||||
__version__ = "0.13.1"
|
||||
|
||||
class ServiceApp(App):
|
||||
def build(self):
|
||||
|
||||
Reference in new issue
Block a user