Compare commits

..

No commits in common. "master" and "0.16.9" have entirely different histories.

222 changed files with 2661 additions and 4552 deletions

View file

@ -1 +0,0 @@

1
.gitignore vendored
View file

@ -66,4 +66,3 @@ app/twitter.properties
*.hprof *.hprof
app/build app/build
bin bin
app/debuglib

View file

@ -9,8 +9,8 @@ build apk:
image: lbry/android-base:platform-28 image: lbry/android-base:platform-28
before_script: before_script:
- echo "$PGP_PRIVATE_KEY" | gpg --batch --import - echo "$PGP_PRIVATE_KEY" | gpg --batch --import
- echo 'deb https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret main' >> /etc/apt/sources.list - echo "deb https://dl.bintray.com/sobolevn/deb git-secret main" | tee -a /etc/apt/sources.list
- wget -qO - 'https://gitsecret.jfrog.io/artifactory/api/gpg/key/public' | apt-key add - - wget -O - https://api.bintray.com/users/sobolevn/keys/gpg/public.key | apt-key add -
- apt-get -y update && apt-get -y install build-essential ca-certificates curl git gpg-agent openjdk-8-jdk software-properties-common wget zipalign git-secret - apt-get -y update && apt-get -y install build-essential ca-certificates curl git gpg-agent openjdk-8-jdk software-properties-common wget zipalign git-secret
- git secret reveal - git secret reveal
- chmod u+x $CI_PROJECT_DIR/gradlew - chmod u+x $CI_PROJECT_DIR/gradlew
@ -36,8 +36,8 @@ deploy build.lbry.io:
before_script: before_script:
- apt-get -y update && apt-get -y install apt-transport-https - apt-get -y update && apt-get -y install apt-transport-https
- echo "$PGP_PRIVATE_KEY" | gpg --batch --import - echo "$PGP_PRIVATE_KEY" | gpg --batch --import
- echo 'deb https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret main' >> /etc/apt/sources.list - echo "deb https://dl.bintray.com/sobolevn/deb git-secret main" | tee -a /etc/apt/sources.list
- wget -qO - 'https://gitsecret.jfrog.io/artifactory/api/gpg/key/public' | apt-key add - - wget -O - https://api.bintray.com/users/sobolevn/keys/gpg/public.key | apt-key add -
- apt-get -y update && apt-get -y install openjdk-8-jdk git git-secret - apt-get -y update && apt-get -y install openjdk-8-jdk git git-secret
- pip install awscli - pip install awscli
- chmod u+x $CI_PROJECT_DIR/gradlew - chmod u+x $CI_PROJECT_DIR/gradlew
@ -60,8 +60,8 @@ release apk:
before_script: before_script:
- apt-get -y update && apt-get -y install apt-transport-https - apt-get -y update && apt-get -y install apt-transport-https
- echo "$PGP_PRIVATE_KEY" | gpg --batch --import - echo "$PGP_PRIVATE_KEY" | gpg --batch --import
- echo 'deb https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret main' >> /etc/apt/sources.list - echo "deb https://dl.bintray.com/sobolevn/deb git-secret main" | tee -a /etc/apt/sources.list
- wget -qO - 'https://gitsecret.jfrog.io/artifactory/api/gpg/key/public' | apt-key add - - wget -O - https://api.bintray.com/users/sobolevn/keys/gpg/public.key | apt-key add -
- apt-get -y update && apt-get -y install openjdk-8-jdk git git-secret - apt-get -y update && apt-get -y install openjdk-8-jdk git git-secret
- pip install awscli githubrelease - pip install awscli githubrelease
- git secret reveal - git secret reveal

View file

@ -18,19 +18,7 @@ The minimum supported Android version is 5.0 Lollipop. There are two ways to ins
The app can be launched by opening **LBRY** from the device's app drawer or via the shortcut on the home screen if that was created upon installation. The app can be launched by opening **LBRY** from the device's app drawer or via the shortcut on the home screen if that was created upon installation.
## Running from Source ## Running from Source
Clone the repository and open the project in Android Studio. Android Studio will automatically run the initial build process. Clone the repository and open the project in Android Studio. Android Studio will automatically run the initial build process. Click the Run button to launch the app on your simulator or connected debugging device after the build process is complete.
Create file 'twitter.properties' in app/ folder with the following content:
```
twitterConsumerKey=XXXXXX
twitterConsumerSecret=XXXXXX
```
Copy the file 'google-services.sample.json' to 'google-services.json' in the app/ folder.
Click the Sync button and when process finishes, the Run button to launch the app on your simulator or connected debugging device after the build process is complete.
## Contributing ## Contributing
Contributions to this project are welcome, encouraged, and compensated. For more details, see https://lbry.io/faq/contributing Contributions to this project are welcome, encouraged, and compensated. For more details, see https://lbry.io/faq/contributing
@ -39,7 +27,7 @@ Contributions to this project are welcome, encouraged, and compensated. For more
This project is MIT licensed. For the full license, see [LICENSE](LICENSE). This project is MIT licensed. For the full license, see [LICENSE](LICENSE).
## Security ## Security
We take security seriously. Please contact security@lbry.com regarding any security issues. Our PGP key is [here](https://lbry.com/faq/pgp-key) if you need it. We take security seriously. Please contact security@lbry.com regarding any security issues. Our PGP key is [here](https://keybase.io/lbry/key.asc) if you need it.
## Contact ## Contact
The primary contact for this project is [@akinwale](https://github.com/akinwale) (akinwale@lbry.com) The primary contact for this project is [@akinwale](https://github.com/akinwale) (akinwale@lbry.com)

View file

@ -4,7 +4,7 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 29 compileSdkVersion 29
buildToolsVersion "29.0.2" buildToolsVersion "29.0.1"
flavorDimensions "default" flavorDimensions "default"
compileOptions { compileOptions {
@ -16,8 +16,9 @@ android {
applicationId "io.lbry.browser" applicationId "io.lbry.browser"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
versionCode 1701 versionCode 1609
versionName "0.17.1" versionName "0.16.9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
@ -79,13 +80,13 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.3.0-alpha01' implementation 'com.google.android.material:material:1.3.0-alpha01'
implementation "androidx.cardview:cardview:1.0.0" implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.navigation:navigation-fragment:2.3.1' implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.1' implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.webkit:webkit:1.4.0-rc01' implementation 'androidx.webkit:webkit:1.3.0-alpha03'
implementation 'androidx.camera:camera-core:1.0.0-beta03' implementation 'androidx.camera:camera-core:1.0.0-beta03'
implementation 'androidx.camera:camera-camera2:1.0.0-beta03' implementation 'androidx.camera:camera-camera2:1.0.0-beta03'
implementation 'androidx.camera:camera-lifecycle:1.0.0-beta03' implementation 'androidx.camera:camera-lifecycle:1.0.0-beta03'
@ -95,19 +96,19 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.11.0' implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.squareup.okhttp3:okhttp:4.4.1' implementation 'com.squareup.okhttp3:okhttp:4.4.1'
implementation 'com.google.firebase:firebase-analytics:18.0.0' implementation 'com.google.firebase:firebase-analytics:17.5.0'
implementation 'com.google.android.gms:play-services-base:17.5.0' implementation 'com.google.android.gms:play-services-base:17.4.0'
implementation 'com.google.firebase:firebase-messaging:21.0.0' implementation 'com.google.firebase:firebase-messaging:20.3.0'
implementation 'com.google.oauth-client:google-oauth-client:1.30.4' implementation 'com.google.oauth-client:google-oauth-client:1.30.4'
implementation 'com.android.billingclient:billing:3.0.2' implementation 'com.android.billingclient:billing:3.0.1'
implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.android.exoplayer:exoplayer-core:2.12.2' implementation 'com.google.android.exoplayer:exoplayer-core:2.11.4'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.12.2' implementation 'com.google.android.exoplayer:exoplayer-dash:2.11.4'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.12.2' implementation 'com.google.android.exoplayer:exoplayer-ui:2.11.4'
implementation 'com.google.android.exoplayer:extension-cast:2.12.2' implementation 'com.google.android.exoplayer:extension-cast:2.11.4'
implementation 'com.google.android.exoplayer:extension-mediasession:2.12.2' implementation 'com.google.android.exoplayer:extension-mediasession:2.11.4'
implementation 'com.google.android:flexbox:2.0.1' implementation 'com.google.android:flexbox:2.0.1'
@ -118,26 +119,19 @@ dependencies {
implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.3.1.LTS' implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.3.1.LTS'
implementation 'commons-codec:commons-codec:1.15'
implementation 'org.bitcoinj:bitcoinj-tools:0.14.7' implementation 'org.bitcoinj:bitcoinj-tools:0.14.7'
implementation 'org.java-websocket:Java-WebSocket:1.5.1' implementation 'org.java-websocket:Java-WebSocket:1.5.1'
implementation ('com.journeyapps:zxing-android-embedded:4.1.0') { transitive = false }
implementation 'com.google.zxing:core:3.3.0'
compileOnly 'org.projectlombok:lombok:1.18.10' compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10' annotationProcessor 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
testImplementation 'junit:junit:4.12' 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.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
__32bitImplementation 'io.lbry:lbrysdk32:0.102.0' __32bitImplementation 'io.lbry:lbrysdk32:0.82.0'
__64bitImplementation 'io.lbry:lbrysdk64:0.102.0' __64bitImplementation 'io.lbry:lbrysdk64:0.82.0'
//__64bitImplementation(name: 'lbrysdk', ext: 'aar')
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'

View file

@ -1,12 +0,0 @@
package io.lbry.browser.utils;
import androidx.test.filters.SmallTest;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@SmallTest
public class HelperTest {
}

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="io.lbry.browser" package="io.lbry.browser"
android:installLocation="auto"> android:installLocation="auto">
@ -12,9 +11,6 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.vending.BILLING" /> <uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-sdk tools:overrideLibrary="com.google.zxing.client.android" />
<application <application
android:allowBackup="true" android:allowBackup="true"
@ -101,11 +97,6 @@
android:theme="@style/AppTheme.NoActionBarTranslucent" android:theme="@style/AppTheme.NoActionBarTranslucent"
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="fullSensor"
tools:replace="screenOrientation" />
<service <service
android:name="io.lbry.browser.LbrynetMessagingService" android:name="io.lbry.browser.LbrynetMessagingService"
android:exported="false"> android:exported="false">

View file

@ -172,8 +172,8 @@ public class FirstRunActivity extends AppCompatActivity {
} }
private static class CheckInstallIdTask extends AsyncTask<Void, Void, Boolean> { private static class CheckInstallIdTask extends AsyncTask<Void, Void, Boolean> {
private final Context context; private Context context;
private final InstallIdHandler handler; private InstallIdHandler handler;
public CheckInstallIdTask(Context context, InstallIdHandler handler) { public CheckInstallIdTask(Context context, InstallIdHandler handler) {
this.context = context; this.context = context;
this.handler = handler; this.handler = handler;
@ -236,7 +236,7 @@ public class FirstRunActivity extends AppCompatActivity {
} }
private static class AuthenticateTask extends AsyncTask<Void, Void, Void> { private static class AuthenticateTask extends AsyncTask<Void, Void, Void> {
private final Context context; private Context context;
public AuthenticateTask(Context context) { public AuthenticateTask(Context context) {
this.context = context; this.context = context;
} }

View file

@ -58,7 +58,7 @@ public class LbrynetMessagingService extends FirebaseMessagingService {
String name = payload.get("name"); // notification name String name = payload.get("name"); // notification name
String hash = payload.get("hash"); // comment hash String hash = payload.get("hash"); // comment hash
if (type != null && getEnabledTypes().contains(type) && body != null && body.trim().length() > 0) { if (type != null && getEnabledTypes().indexOf(type) > -1 && body != null && body.trim().length() > 0) {
// only log the receive event for valid notifications received // only log the receive event for valid notifications received
if (firebaseAnalytics != null) { if (firebaseAnalytics != null) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();

View file

@ -1,6 +1,5 @@
package io.lbry.browser; package io.lbry.browser;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
@ -41,14 +40,12 @@ import android.view.KeyEvent;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Menu; import android.view.Menu;
import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.webkit.WebView; import android.webkit.WebView;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -73,7 +70,8 @@ import com.google.android.gms.cast.framework.CastContext;
import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task; import com.google.android.gms.tasks.Task;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.messaging.FirebaseMessaging; import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -109,7 +107,6 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import org.java_websocket.client.WebSocketClient; import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake; import org.java_websocket.handshake.ServerHandshake;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -117,12 +114,9 @@ import org.json.JSONObject;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.ConnectException; import java.net.ConnectException;
import java.net.URI; import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -141,7 +135,6 @@ import javax.net.ssl.SSLParameters;
import io.lbry.browser.adapter.NavigationMenuAdapter; import io.lbry.browser.adapter.NavigationMenuAdapter;
import io.lbry.browser.adapter.NotificationListAdapter; import io.lbry.browser.adapter.NotificationListAdapter;
import io.lbry.browser.adapter.StartupStageAdapter;
import io.lbry.browser.adapter.UrlSuggestionListAdapter; import io.lbry.browser.adapter.UrlSuggestionListAdapter;
import io.lbry.browser.data.DatabaseHelper; import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.dialog.ContentScopeDialogFragment; import io.lbry.browser.dialog.ContentScopeDialogFragment;
@ -161,7 +154,6 @@ import io.lbry.browser.listener.WalletBalanceListener;
import io.lbry.browser.model.Claim; import io.lbry.browser.model.Claim;
import io.lbry.browser.model.ClaimCacheKey; import io.lbry.browser.model.ClaimCacheKey;
import io.lbry.browser.model.NavMenuItem; import io.lbry.browser.model.NavMenuItem;
import io.lbry.browser.model.StartupStage;
import io.lbry.browser.model.Tag; import io.lbry.browser.model.Tag;
import io.lbry.browser.model.UrlSuggestion; import io.lbry.browser.model.UrlSuggestion;
import io.lbry.browser.model.WalletBalance; import io.lbry.browser.model.WalletBalance;
@ -225,9 +217,6 @@ import lombok.Setter;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import static android.os.Build.VERSION_CODES.M;
import static android.os.Build.VERSION_CODES.P;
public class MainActivity extends AppCompatActivity implements SdkStatusListener, public class MainActivity extends AppCompatActivity implements SdkStatusListener,
SharedPreferences.OnSharedPreferenceChangeListener, SharedPreferences.OnSharedPreferenceChangeListener,
ActionMode.Callback, SelectionModeListener { ActionMode.Callback, SelectionModeListener {
@ -263,7 +252,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
public static boolean startingFilePickerActivity = false; public static boolean startingFilePickerActivity = false;
public static boolean startingShareActivity = false; public static boolean startingShareActivity = false;
public static boolean startingPermissionRequest = false; public static boolean startingPermissionRequest = false;
public static final boolean startingSignInFlowActivity = false; public static boolean startingSignInFlowActivity = false;
private ActionMode actionMode; private ActionMode actionMode;
private BillingClient billingClient; private BillingClient billingClient;
@ -339,7 +328,6 @@ 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";
@ -352,7 +340,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
public static final String PREFERENCE_KEY_KEEP_SDK_BACKGROUND = "io.lbry.browser.preference.other.KeepSdkInBackground"; public static final String PREFERENCE_KEY_KEEP_SDK_BACKGROUND = "io.lbry.browser.preference.other.KeepSdkInBackground";
public static final String PREFERENCE_KEY_PARTICIPATE_DATA_NETWORK = "io.lbry.browser.preference.other.ParticipateInDataNetwork"; public static final String PREFERENCE_KEY_PARTICIPATE_DATA_NETWORK = "io.lbry.browser.preference.other.ParticipateInDataNetwork";
public static final String PREFERENCE_KEY_SEND_BUFFERING_EVENTS = "io.lbry.browser.preference.other.SendBufferingEvents"; public static final String PREFERENCE_KEY_SEND_BUFFERING_EVENTS = "io.lbry.browser.preference.other.SendBufferingEvents";
public static final String PREFERENCE_KEY_SHARE_USAGE_DATA = "io.lbry.browser.preference.other.ShareUsageData";
// Internal flags / setting preferences // Internal flags / setting preferences
public static final String PREFERENCE_KEY_INTERNAL_SKIP_WALLET_ACCOUNT = "io.lbry.browser.preference.internal.WalletSkipAccount"; public static final String PREFERENCE_KEY_INTERNAL_SKIP_WALLET_ACCOUNT = "io.lbry.browser.preference.internal.WalletSkipAccount";
@ -407,7 +394,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
private List<FetchClaimsListener> fetchClaimsListeners; private List<FetchClaimsListener> fetchClaimsListeners;
private List<FetchChannelsListener> fetchChannelsListeners; private List<FetchChannelsListener> fetchChannelsListeners;
@Getter @Getter
private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); private ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
private boolean walletBalanceUpdateScheduled; private boolean walletBalanceUpdateScheduled;
private boolean shouldOpenUserSelectedMenuItem; private boolean shouldOpenUserSelectedMenuItem;
private boolean walletSyncScheduled; private boolean walletSyncScheduled;
@ -426,8 +413,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
private static final int STARTUP_STAGE_NEW_INSTALL_DONE = 5; private static final int STARTUP_STAGE_NEW_INSTALL_DONE = 5;
private static final int STARTUP_STAGE_SUBSCRIPTIONS_LOADED = 6; private static final int STARTUP_STAGE_SUBSCRIPTIONS_LOADED = 6;
private static final int STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED = 7; private static final int STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED = 7;
private static final int STARTUP_STAGE_BLOCK_LIST_LOADED = 8;
private static final int STARTUP_STAGE_FILTER_LIST_LOADED = 9;
private static final int DEFAULT_MINI_PLAYER_MARGIN = 4; private static final int DEFAULT_MINI_PLAYER_MARGIN = 4;
@Override @Override
@ -444,20 +429,21 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
initKeyStore(); initKeyStore();
loadAuthToken(); loadAuthToken();
if (Build.VERSION.SDK_INT >= M && !isDarkMode()) { if (!isDarkMode()) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} }
initSpecialRouteMap(); initSpecialRouteMap();
LbryAnalytics.init(this); LbryAnalytics.init(this);
try { try {
FirebaseMessaging.getInstance().getToken().addOnCompleteListener(new OnCompleteListener<String>() { FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
@Override @Override
public void onComplete(@NonNull Task<String> task) { public void onComplete(Task<InstanceIdResult> task) {
if (!task.isSuccessful()) { if (!task.isSuccessful()) {
return; return;
} }
firebaseMessagingToken = task.getResult(); // Get new Instance ID token
firebaseMessagingToken = task.getResult().getToken();
} }
}); });
} catch (IllegalStateException ex) { } catch (IllegalStateException ex) {
@ -529,7 +515,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
// setup uri bar // setup uri bar
setupUriBar(); setupUriBar();
initNotificationsPage(); initNotificationsPage();
loadUnseenNotificationsCount(); loadUnreadNotificationsCount();
// other // other
pendingSyncSetQueue = new ArrayList<>(); pendingSyncSetQueue = new ArrayList<>();
@ -684,11 +670,6 @@ 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);
@ -827,23 +808,11 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
walletBalanceListeners.remove(listener); walletBalanceListeners.remove(listener);
} }
public void restoreWalletContainerPosition() {
View floatingBalance = findViewById(R.id.floating_balance_main_container);
ObjectAnimator animation = ObjectAnimator.ofFloat(floatingBalance, "translationY", 0f);
animation.setDuration(250).start();
}
public void translateFloatingWallet(float initialY) {
if (findViewById(R.id.floating_balance_main_container).getY() == initialY) {
ObjectAnimator animation = ObjectAnimator.ofFloat(findViewById(R.id.floating_balance_main_container), "translationY", 2 * findViewById(R.id.floating_balance_main_container).getHeight());
animation.setDuration(300).start();
}
}
public void removeNavFragment(Class fragmentClass, int navItemId) { public void removeNavFragment(Class fragmentClass, int navItemId) {
String key = buildNavFragmentKey(fragmentClass, navItemId, null); String key = buildNavFragmentKey(fragmentClass, navItemId, null);
openNavFragments.remove(key); if (openNavFragments.containsKey(key)) {
openNavFragments.remove(key);
}
} }
public void addFetchChannelsListener(FetchChannelsListener listener) { public void addFetchChannelsListener(FetchChannelsListener listener) {
@ -1037,7 +1006,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
openFragment(RewardsFragment.class, true, NavMenuItem.ID_ITEM_REWARDS); openFragment(RewardsFragment.class, true, NavMenuItem.ID_ITEM_REWARDS);
} }
private final FragmentManager.OnBackStackChangedListener backStackChangedListener = new FragmentManager.OnBackStackChangedListener() { private FragmentManager.OnBackStackChangedListener backStackChangedListener = new FragmentManager.OnBackStackChangedListener() {
@Override @Override
public void onBackStackChanged() { public void onBackStackChanged() {
FragmentManager manager = getSupportFragmentManager(); FragmentManager manager = getSupportFragmentManager();
@ -1271,7 +1240,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
return sp.getBoolean(PREFERENCE_KEY_INTERNAL_FIRST_RUN_COMPLETED, false); return sp.getBoolean(PREFERENCE_KEY_INTERNAL_FIRST_RUN_COMPLETED, false);
} }
public void checkPurchases() { private void checkPurchases() {
if (billingClient != null) { if (billingClient != null) {
Purchase.PurchasesResult result = billingClient.queryPurchases(BillingClient.SkuType.INAPP); Purchase.PurchasesResult result = billingClient.queryPurchases(BillingClient.SkuType.INAPP);
if (result.getPurchasesList() != null) { if (result.getPurchasesList() != null) {
@ -1282,24 +1251,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
} }
} }
public void checkPurchases(GenericTaskHandler handler) {
boolean purchaseFound = false;
if (billingClient != null) {
Purchase.PurchasesResult result = billingClient.queryPurchases(BillingClient.SkuType.INAPP);
if (result.getPurchasesList() != null) {
for (Purchase purchase : result.getPurchasesList()) {
handlePurchase(purchase, handler);
purchaseFound = true;
return;
}
}
}
if (!purchaseFound) {
handler.onError(new Exception(getString(R.string.skip_queue_purchase_not_found)));
}
}
private void handlePurchase(Purchase purchase) { private void handlePurchase(Purchase purchase) {
handleBillingPurchase(purchase, billingClient, MainActivity.this, null, new RewardVerifiedHandler() { handleBillingPurchase(purchase, billingClient, MainActivity.this, null, new RewardVerifiedHandler() {
@Override @Override
@ -1316,28 +1267,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
}); });
} }
private void handlePurchase(Purchase purchase, GenericTaskHandler handler) {
handleBillingPurchase(purchase, billingClient, MainActivity.this, null, new RewardVerifiedHandler() {
@Override
public void onSuccess(RewardVerified rewardVerified) {
if (Lbryio.currentUser != null) {
Lbryio.currentUser.setRewardApproved(rewardVerified.isRewardApproved());
}
if (handler != null) {
handler.onSuccess();
}
}
@Override
public void onError(Exception error) {
if (handler != null) {
handler.onError(error);
}
}
});
}
private void checkPendingOpens() { private void checkPendingOpens() {
if (pendingFollowingReload) { if (pendingFollowingReload) {
loadFollowingContent(); loadFollowingContent();
@ -1382,7 +1311,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
private void toggleUrlSuggestions(boolean visible) { private void toggleUrlSuggestions(boolean visible) {
View container = findViewById(R.id.url_suggestions_container); View container = findViewById(R.id.url_suggestions_container);
View closeIcon = findViewById(R.id.wunderbar_close); View closeIcon = findViewById(R.id.wunderbar_close);
//EditText wunderbar = findViewById(R.id.wunderbar); EditText wunderbar = findViewById(R.id.wunderbar);
//wunderbar.setPadding(0, 0, visible ? getScaledValue(36) : 0, 0); //wunderbar.setPadding(0, 0, visible ? getScaledValue(36) : 0, 0);
container.setVisibility(visible ? View.VISIBLE : View.GONE); container.setVisibility(visible ? View.VISIBLE : View.GONE);
@ -1864,7 +1793,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
if (!Helper.isNullOrEmpty(encryptedAuthToken)) { if (!Helper.isNullOrEmpty(encryptedAuthToken)) {
try { try {
Lbryio.AUTH_TOKEN = new String(Utils.decrypt( Lbryio.AUTH_TOKEN = new String(Utils.decrypt(
Base64.decode(encryptedAuthToken, Base64.NO_WRAP), this, Lbry.KEYSTORE), StandardCharsets.UTF_8); Base64.decode(encryptedAuthToken, Base64.NO_WRAP), this, Lbry.KEYSTORE), "UTF8");
} catch (Exception ex) { } catch (Exception ex) {
// pass. A new auth token would have to be generated if the old one cannot be decrypted // pass. A new auth token would have to be generated if the old one cannot be decrypted
Log.e(TAG, "Could not decrypt existing auth token.", ex); Log.e(TAG, "Could not decrypt existing auth token.", ex);
@ -1895,7 +1824,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);
checkAndEnableShareUsageData();
scheduleWalletBalanceUpdate(); scheduleWalletBalanceUpdate();
scheduleWalletSyncTask(); scheduleWalletSyncTask();
@ -1930,13 +1858,17 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
new DecimalFormat(Helper.LBC_CURRENCY_FORMAT_PATTERN).format(amountClaimed)); new DecimalFormat(Helper.LBC_CURRENCY_FORMAT_PATTERN).format(amountClaimed));
} }
Snackbar.make(findViewById(R.id.content_main), message, Snackbar.LENGTH_LONG).show(); Snackbar.make(findViewById(R.id.content_main), message, Snackbar.LENGTH_LONG).show();
sp.edit().putBoolean(PREFERENCE_KEY_INTERNAL_NEW_ANDROID_REWARD_CLAIMED, true).apply(); if (sp != null) {
sp.edit().putBoolean(PREFERENCE_KEY_INTERNAL_NEW_ANDROID_REWARD_CLAIMED, true).apply();
}
} }
@Override @Override
public void onError(Exception error) { public void onError(Exception error) {
// pass. fail silently // pass. fail silently
sp.edit().putBoolean(PREFERENCE_KEY_INTERNAL_NEW_ANDROID_REWARD_CLAIMED, true).apply(); if (sp != null) {
sp.edit().putBoolean(PREFERENCE_KEY_INTERNAL_NEW_ANDROID_REWARD_CLAIMED, true).apply();
}
} }
}); });
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
@ -2021,7 +1953,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
notificationListAdapter.setInSelectionMode(false); notificationListAdapter.setInSelectionMode(false);
notificationListAdapter.notifyDataSetChanged(); notificationListAdapter.notifyDataSetChanged();
} }
if (Build.VERSION.SDK_INT >= M && isDarkMode()) { if (isDarkMode()) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} }
this.actionMode = null; this.actionMode = null;
@ -2085,7 +2017,8 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
if (nowPlayingClaimUrl != null) { if (nowPlayingClaimUrl != null) {
Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(nowPlayingClaimUrl)); Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(nowPlayingClaimUrl));
launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
return PendingIntent.getActivity(MainActivity.this, 0, launchIntent, 0); PendingIntent intent = PendingIntent.getActivity(MainActivity.this, 0, launchIntent, 0);
return intent;
} }
return null; return null;
} }
@ -2102,7 +2035,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
if (nowPlayingClaimBitmap == null && if (nowPlayingClaimBitmap == null &&
nowPlayingClaim != null && nowPlayingClaim != null &&
!Helper.isNullOrEmpty(nowPlayingClaim.getThumbnailUrl())) { !Helper.isNullOrEmpty(nowPlayingClaim.getThumbnailUrl())) {
Glide.with(getApplicationContext()).asBitmap().load(nowPlayingClaim.getThumbnailUrl(0, 0, 75)).into(new CustomTarget<Bitmap>() { Glide.with(getApplicationContext()).asBitmap().load(nowPlayingClaim.getThumbnailUrl()).into(new CustomTarget<Bitmap>() {
@Override @Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
nowPlayingClaimBitmap = resource; nowPlayingClaimBitmap = resource;
@ -2298,7 +2231,8 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
@Override @Override
public void onSyncSetSuccess(String hash) { public void onSyncSetSuccess(String hash) {
Lbryio.lastRemoteHash = hash; Lbryio.lastRemoteHash = hash;
Lbryio.lastWalletSync = new WalletSync(hash, data); WalletSync walletSync = new WalletSync(hash, data);
Lbryio.lastWalletSync = walletSync;
if (pendingSyncSetQueue.size() > 0) { if (pendingSyncSetQueue.size() > 0) {
fullSyncInProgress = true; fullSyncInProgress = true;
@ -2478,7 +2412,8 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
pendingFollowingReload = true; pendingFollowingReload = true;
} }
private void handleOpenChannelUrl(Intent intent) { private void handleOpenChannelUrl(Intent intent) {
pendingChannelUrl = intent.getStringExtra("url"); String url = intent.getStringExtra("url");
pendingChannelUrl = url;
} }
}; };
registerReceiver(requestsReceiver, intentFilter); registerReceiver(requestsReceiver, intentFilter);
@ -2512,7 +2447,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
} }
if (notificationListAdapter != null) { if (notificationListAdapter != null) {
markNotificationsSeen(); markNotificationsRead();
} }
} }
@ -2521,17 +2456,17 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
findViewById(R.id.notifications_container).setVisibility(View.GONE); findViewById(R.id.notifications_container).setVisibility(View.GONE);
} }
private void markNotificationsSeen() { private void markNotificationsRead() {
List<LbryNotification> all = notificationListAdapter != null ? notificationListAdapter.getItems() : null; List<LbryNotification> all = notificationListAdapter != null ? notificationListAdapter.getItems() : null;
if (all != null) { if (all != null) {
List<Long> unseenIds = new ArrayList<>(); List<Long> unreadIds = new ArrayList<>();
for (LbryNotification notification : all) { for (LbryNotification notification : all) {
if (!notification.isSeen() && notification.getRemoteId() > 0) { if (!notification.isRead() && notification.getRemoteId() > 0) {
unseenIds.add(notification.getRemoteId()); unreadIds.add(notification.getRemoteId());
} }
} }
if (unseenIds.size() > 0) { if (unreadIds.size() > 0) {
NotificationUpdateTask task = new NotificationUpdateTask(unseenIds, true); NotificationUpdateTask task = new NotificationUpdateTask(unreadIds, true);
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
@ -2541,14 +2476,14 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {
try { try {
SQLiteDatabase db = dbHelper.getWritableDatabase(); SQLiteDatabase db = dbHelper.getWritableDatabase();
DatabaseHelper.markNotificationsSeen(db); DatabaseHelper.markNotificationsRead(db);
} catch (Exception ex) { } catch (Exception ex) {
// pass // pass
} }
return null; return null;
} }
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
loadUnseenNotificationsCount(); loadUnreadNotificationsCount();
} }
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@ -2638,7 +2573,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
} }
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NotNull String[] permissions, @NotNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) { switch (requestCode) {
case REQUEST_STORAGE_PERMISSION: case REQUEST_STORAGE_PERMISSION:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
@ -2673,7 +2608,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_FILE_PICKER) { if (requestCode == REQUEST_FILE_PICKER) {
startingFilePickerActivity = false; startingFilePickerActivity = false;
if (resultCode == RESULT_OK && data != null) { if (resultCode == RESULT_OK) {
Uri fileUri = data.getData(); Uri fileUri = data.getData();
String filePath = Helper.getRealPathFromURI_API19(this, fileUri); String filePath = Helper.getRealPathFromURI_API19(this, fileUri);
for (FilePickerListener listener : filePickerListeners) { for (FilePickerListener listener : filePickerListeners) {
@ -2781,7 +2716,16 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
} }
private Fragment getCurrentFragment() { private Fragment getCurrentFragment() {
return getSupportFragmentManager().findFragmentById(R.id.content_main); int backCount = getSupportFragmentManager().getBackStackEntryCount();
if (backCount > 0) {
try {
Fragment fragment = getSupportFragmentManager().getFragments().get(backCount - 1);
return fragment;
} catch (IndexOutOfBoundsException ex) {
return null;
}
}
return null;
} }
public void hideActionBar() { public void hideActionBar() {
@ -2796,28 +2740,23 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
actionBar.show(); actionBar.show();
} }
} }
private void renderStartupFailed(List<StartupStage> startupStages) { private void renderStartupFailed(Map<Integer, Boolean> startupStages) {
ListView listView = findViewById(R.id.startup_stage_error_listview); Map<Integer, Integer> startupStageIconIds = new HashMap<>();
StartupStageAdapter adapter = new StartupStageAdapter(this, startupStages); startupStageIconIds.put(STARTUP_STAGE_INSTALL_ID_LOADED, R.id.startup_stage_icon_install_id);
listView.setAdapter(adapter); startupStageIconIds.put(STARTUP_STAGE_KNOWN_TAGS_LOADED, R.id.startup_stage_icon_known_tags);
startupStageIconIds.put(STARTUP_STAGE_EXCHANGE_RATE_LOADED, R.id.startup_stage_icon_exchange_rate);
startupStageIconIds.put(STARTUP_STAGE_USER_AUTHENTICATED, R.id.startup_stage_icon_user_authenticated);
startupStageIconIds.put(STARTUP_STAGE_NEW_INSTALL_DONE, R.id.startup_stage_icon_install_new);
startupStageIconIds.put(STARTUP_STAGE_SUBSCRIPTIONS_LOADED, R.id.startup_stage_icon_subscriptions_loaded);
startupStageIconIds.put(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED, R.id.startup_stage_icon_subscriptions_resolved);
// Add 1 pixel to listview height for (Integer key : startupStages.keySet()) {
int listHeight = Math.round(getResources().getDisplayMetrics().density); boolean stageDone = startupStages.get(key);
ImageView icon = findViewById(startupStageIconIds.get(key));
for (int i = 0; i < startupStages.size(); i++) { icon.setImageResource(stageDone ? R.drawable.ic_check : R.drawable.ic_close);
View item = adapter.getView(i, null, listView); icon.setColorFilter(stageDone ? Color.WHITE : Color.RED);
item.measure(0, 0);
listHeight += item.getMeasuredHeight();
} }
// Properly set listview height by adding all seven items and the divider heights
// and the additional 1 pixel so no vertical scroll bar is shown
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = listHeight + (listView.getCount() + 1) * listView.getDividerHeight();
listView.setLayoutParams(params);
listView.invalidate();
listView.requestLayout();
findViewById(R.id.splash_view_loading_container).setVisibility(View.GONE); findViewById(R.id.splash_view_loading_container).setVisibility(View.GONE);
findViewById(R.id.splash_view_error_container).setVisibility(View.VISIBLE); findViewById(R.id.splash_view_error_container).setVisibility(View.VISIBLE);
} }
@ -2829,18 +2768,16 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
// perform some tasks before launching // perform some tasks before launching
(new AsyncTask<Void, Void, Boolean>() { (new AsyncTask<Void, Void, Boolean>() {
private final List<StartupStage> startupStages = new ArrayList<>(7); private Map<Integer, Boolean> startupStages = new HashMap<>();
private void initStartupStages() { private void initStartupStages() {
startupStages.add(new StartupStage(STARTUP_STAGE_INSTALL_ID_LOADED, false)); startupStages.put(STARTUP_STAGE_INSTALL_ID_LOADED, false);
startupStages.add(new StartupStage(STARTUP_STAGE_KNOWN_TAGS_LOADED, false)); startupStages.put(STARTUP_STAGE_KNOWN_TAGS_LOADED, false);
startupStages.add(new StartupStage(STARTUP_STAGE_EXCHANGE_RATE_LOADED, false)); startupStages.put(STARTUP_STAGE_EXCHANGE_RATE_LOADED, false);
startupStages.add(new StartupStage(STARTUP_STAGE_USER_AUTHENTICATED, false)); startupStages.put(STARTUP_STAGE_USER_AUTHENTICATED, false);
startupStages.add(new StartupStage(STARTUP_STAGE_NEW_INSTALL_DONE, false)); startupStages.put(STARTUP_STAGE_NEW_INSTALL_DONE, false);
startupStages.add(new StartupStage(STARTUP_STAGE_SUBSCRIPTIONS_LOADED, false)); startupStages.put(STARTUP_STAGE_SUBSCRIPTIONS_LOADED, false);
startupStages.add(new StartupStage(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED, false)); startupStages.put(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED, false);
startupStages.add(new StartupStage(STARTUP_STAGE_BLOCK_LIST_LOADED, false));
startupStages.add(new StartupStage(STARTUP_STAGE_FILTER_LIST_LOADED, false));
} }
protected void onPreExecute() { protected void onPreExecute() {
hideActionBar(); hideActionBar();
@ -2860,26 +2797,26 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
String installId = reader.readLine(); String installId = reader.readLine();
if (Helper.isNullOrEmpty(installId)) { if (Helper.isNullOrEmpty(installId)) {
// no install_id found (first run didn't start the sdk successfully?) // no install_id found (first run didn't start the sdk successfully?)
startupStages.set(STARTUP_STAGE_INSTALL_ID_LOADED - 1, new StartupStage(STARTUP_STAGE_INSTALL_ID_LOADED, false)); startupStages.put(STARTUP_STAGE_INSTALL_ID_LOADED, false);
return false; return false;
} }
Lbry.INSTALLATION_ID = installId; Lbry.INSTALLATION_ID = installId;
startupStages.set(STARTUP_STAGE_INSTALL_ID_LOADED - 1, new StartupStage(STARTUP_STAGE_INSTALL_ID_LOADED, true)); startupStages.put(STARTUP_STAGE_INSTALL_ID_LOADED, true);
SQLiteDatabase db = dbHelper.getReadableDatabase(); SQLiteDatabase db = dbHelper.getReadableDatabase();
List<Tag> fetchedTags = DatabaseHelper.getTags(db); List<Tag> fetchedTags = DatabaseHelper.getTags(db);
Lbry.knownTags = Helper.mergeKnownTags(fetchedTags); Lbry.knownTags = Helper.mergeKnownTags(fetchedTags);
Collections.sort(Lbry.knownTags, new Tag()); Collections.sort(Lbry.knownTags, new Tag());
Lbry.followedTags = Helper.filterFollowedTags(Lbry.knownTags); Lbry.followedTags = Helper.filterFollowedTags(Lbry.knownTags);
startupStages.set(STARTUP_STAGE_KNOWN_TAGS_LOADED - 1, new StartupStage(STARTUP_STAGE_KNOWN_TAGS_LOADED, true)); startupStages.put(STARTUP_STAGE_KNOWN_TAGS_LOADED, true);
// load the exchange rate // load the exchange rate
Lbryio.loadExchangeRate(); Lbryio.loadExchangeRate();
if (Lbryio.LBCUSDRate == 0) { if (Lbryio.LBCUSDRate == 0) {
return false; return false;
} }
startupStages.set(STARTUP_STAGE_EXCHANGE_RATE_LOADED - 1, new StartupStage(STARTUP_STAGE_EXCHANGE_RATE_LOADED, true)); startupStages.put(STARTUP_STAGE_EXCHANGE_RATE_LOADED, true);
try { try {
Lbryio.authenticate(context); Lbryio.authenticate(context);
@ -2891,10 +2828,10 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
if (Lbryio.currentUser == null) { if (Lbryio.currentUser == null) {
throw new Exception("Did not retrieve authenticated user."); throw new Exception("Did not retrieve authenticated user.");
} }
startupStages.set(STARTUP_STAGE_USER_AUTHENTICATED - 1, new StartupStage(STARTUP_STAGE_USER_AUTHENTICATED, true)); startupStages.put(STARTUP_STAGE_USER_AUTHENTICATED, true);
Lbryio.newInstall(context); Lbryio.newInstall(context);
startupStages.set(STARTUP_STAGE_NEW_INSTALL_DONE - 1, new StartupStage(STARTUP_STAGE_NEW_INSTALL_DONE, true)); startupStages.put(STARTUP_STAGE_NEW_INSTALL_DONE, true);
// (light) fetch subscriptions // (light) fetch subscriptions
if (Lbryio.subscriptions.size() == 0) { if (Lbryio.subscriptions.size() == 0) {
@ -2915,35 +2852,26 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
subUrls.add(url.toString()); subUrls.add(url.toString());
} }
Lbryio.subscriptions = subscriptions; Lbryio.subscriptions = subscriptions;
startupStages.set(STARTUP_STAGE_SUBSCRIPTIONS_LOADED - 1, new StartupStage(STARTUP_STAGE_SUBSCRIPTIONS_LOADED, true)); startupStages.put(STARTUP_STAGE_SUBSCRIPTIONS_LOADED, true);
// resolve subscriptions // resolve subscriptions
if (subUrls.size() > 0 && Lbryio.cacheResolvedSubscriptions.size() != Lbryio.subscriptions.size()) { if (subUrls.size() > 0 && Lbryio.cacheResolvedSubscriptions.size() != Lbryio.subscriptions.size()) {
Lbryio.cacheResolvedSubscriptions = Lbry.resolve(subUrls, Lbry.LBRY_TV_CONNECTION_STRING); List<Claim> resolvedSubs = Lbry.resolve(subUrls, Lbry.LBRY_TV_CONNECTION_STRING);
Lbryio.cacheResolvedSubscriptions = resolvedSubs;
} }
// if no exceptions occurred here, subscriptions have been loaded and resolved // if no exceptions occurred here, subscriptions have been loaded and resolved
startupStages.set(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED - 1, new StartupStage(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED, true)); startupStages.put(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED, true);
} else { } else {
// user has not subscribed to anything // user has not subscribed to anything
startupStages.set(STARTUP_STAGE_SUBSCRIPTIONS_LOADED - 1, new StartupStage(STARTUP_STAGE_SUBSCRIPTIONS_LOADED, true)); startupStages.put(STARTUP_STAGE_SUBSCRIPTIONS_LOADED, true);
startupStages.set(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED - 1, new StartupStage(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED, true)); startupStages.put(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED, true);
} }
} else { } else {
startupStages.set(STARTUP_STAGE_SUBSCRIPTIONS_LOADED - 1, new StartupStage(STARTUP_STAGE_SUBSCRIPTIONS_LOADED, true)); startupStages.put(STARTUP_STAGE_SUBSCRIPTIONS_LOADED, true);
startupStages.set(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED - 1, new StartupStage(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED, true)); startupStages.put(STARTUP_STAGE_SUBSCRIPTIONS_RESOLVED, true);
} }
JSONObject blockedObject = (JSONObject) Lbryio.parseResponse(Lbryio.call("file", "list_blocked", context));
JSONArray blockedArray = blockedObject.getJSONArray("outpoints");
Lbryio.populateOutpointList(Lbryio.blockedOutpoints, blockedArray);
startupStages.set(STARTUP_STAGE_BLOCK_LIST_LOADED - 1, new StartupStage(STARTUP_STAGE_BLOCK_LIST_LOADED, true));
JSONObject filteredObject = (JSONObject) Lbryio.parseResponse(Lbryio.call("file", "list_filtered", context));
JSONArray filteredArray = filteredObject.getJSONArray("outpoints");
Lbryio.populateOutpointList(Lbryio.filteredOutpoints, filteredArray);
startupStages.set(STARTUP_STAGE_FILTER_LIST_LOADED - 1, new StartupStage(STARTUP_STAGE_FILTER_LIST_LOADED, true));
} catch (Exception ex) { } catch (Exception ex) {
// nope // nopecd
Log.e(TAG, String.format("App startup failed: %s", ex.getMessage()), ex); Log.e(TAG, String.format("App startup failed: %s", ex.getMessage()), ex);
return false; return false;
} finally { } finally {
@ -3056,11 +2984,10 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
} else { } else {
try { try {
LbryUri uri = LbryUri.parse(url); LbryUri uri = LbryUri.parse(url);
String checkedURL = url.startsWith(LbryUri.PROTO_DEFAULT) ? url : uri.toString();
if (uri.isChannel()) { if (uri.isChannel()) {
openChannelUrl(checkedURL); openChannelUrl(url.startsWith(LbryUri.PROTO_DEFAULT) ? url : uri.toString());
} else { } else {
openFileUrl(checkedURL); openFileUrl(url.startsWith(LbryUri.PROTO_DEFAULT) ? url : uri.toString());
} }
} catch (LbryUriException ex) { } catch (LbryUriException ex) {
// pass // pass
@ -3177,17 +3104,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
String action = intent.getAction(); String action = intent.getAction();
if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) { if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) {
MainActivity.this.receivedStopService = true; MainActivity.this.receivedStopService = true;
// STOP is meant to close everything,
// So destroy the player at this point (even with background play enabled)
if (appPlayer != null) {
playerNotificationManager.setPlayer(null);
stopExoplayer();
nowPlayingClaim = null;
nowPlayingClaimUrl = null;
nowPlayingClaimBitmap = null;
}
MainActivity.this.finish(); MainActivity.this.finish();
} else if (LbrynetService.LBRY_SDK_SERVICE_STARTED.equals(action)) { } else if (LbrynetService.LBRY_SDK_SERVICE_STARTED.equals(action)) {
// Rebuild the service notification // Rebuild the service notification
@ -3316,8 +3232,8 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
} }
private static class CheckSdkReadyTask extends AsyncTask<Void, Void, Boolean> { private static class CheckSdkReadyTask extends AsyncTask<Void, Void, Boolean> {
private final Context context; private Context context;
private final List<SdkStatusListener> listeners; private List<SdkStatusListener> listeners;
public CheckSdkReadyTask(Context context, List<SdkStatusListener> listeners) { public CheckSdkReadyTask(Context context, List<SdkStatusListener> listeners) {
this.context = context; this.context = context;
@ -3470,11 +3386,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
return String.format("%s-%d", fragmentClass.getName(), navItemId); 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) { public void openFragment(Class fragmentClass, boolean allowNavigateBack, int navItemId, Map<String, Object> params) {
try { try {
String key = buildNavFragmentKey(fragmentClass, navItemId, params); String key = buildNavFragmentKey(fragmentClass, navItemId, params);
@ -3487,18 +3398,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
return; return;
} }
if (currentFragment != null && ((BaseFragment) currentFragment).getParams() != null
&& ((BaseFragment) currentFragment).getParams().containsKey("source")
&& ((BaseFragment) currentFragment).getParams().get("source").equals("notification")) {
Map<String, Object> currentParams = new HashMap<>(1);
if (((BaseFragment) currentFragment).getParams().containsKey("url"))
currentParams.put("url", ((BaseFragment) currentFragment).getParams().get("url"));
((BaseFragment) currentFragment).setParams(currentParams);
}
//fragment.setRetainInstance(true); //fragment.setRetainInstance(true);
FragmentManager manager = getSupportFragmentManager(); FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction().replace(R.id.content_main, fragment); FragmentTransaction transaction = manager.beginTransaction().replace(R.id.content_main, fragment);
@ -3584,7 +3483,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
private void displayUnseenNotificationCount(int count) { private void displayUnreadNotificationCount(int count) {
String text = count > 99 ? "99+" : String.valueOf(count); String text = count > 99 ? "99+" : String.valueOf(count);
TextView badge = findViewById(R.id.notifications_badge_count); TextView badge = findViewById(R.id.notifications_badge_count);
@ -3592,19 +3491,19 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
badge.setText(text); badge.setText(text);
} }
private void loadUnseenNotificationsCount() { private void loadUnreadNotificationsCount() {
(new AsyncTask<Void, Void, Integer>() { (new AsyncTask<Void, Void, Integer>() {
@Override @Override
protected Integer doInBackground(Void... params) { protected Integer doInBackground(Void... params) {
try { try {
SQLiteDatabase db = dbHelper.getReadableDatabase(); SQLiteDatabase db = dbHelper.getReadableDatabase();
return DatabaseHelper.getUnseenNotificationsCount(db); return DatabaseHelper.getUnreadNotificationsCount(db);
} catch (Exception ex) { } catch (Exception ex) {
return 0; return 0;
} }
} }
protected void onPostExecute(Integer count) { protected void onPostExecute(Integer count) {
displayUnseenNotificationCount(count); displayUnreadNotificationCount(count);
} }
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@ -3616,10 +3515,10 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
public void onSuccess(List<LbryNotification> notifications) { public void onSuccess(List<LbryNotification> notifications) {
remoteNotifcationsLastLoaded = new Date(); remoteNotifcationsLastLoaded = new Date();
loadUnseenNotificationsCount(); loadUnreadNotificationsCount();
loadLocalNotifications(); loadLocalNotifications();
if (markRead && findViewById(R.id.notifications_container).getVisibility() == View.VISIBLE) { if (markRead && findViewById(R.id.notifications_container).getVisibility() == View.VISIBLE) {
markNotificationsSeen(); markNotificationsRead();
} }
if (notificationsSwipeContainer != null) { if (notificationsSwipeContainer != null) {
@ -3660,7 +3559,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
protected void onPostExecute(List<LbryNotification> notifications) { protected void onPostExecute(List<LbryNotification> notifications) {
findViewById(R.id.notification_list_empty_container).setVisibility(notifications.size() == 0 ? View.VISIBLE : View.GONE); findViewById(R.id.notification_list_empty_container).setVisibility(notifications.size() == 0 ? View.VISIBLE : View.GONE);
findViewById(R.id.notifications_progress).setVisibility(View.GONE); findViewById(R.id.notifications_progress).setVisibility(View.GONE);
loadUnseenNotificationsCount(); loadUnreadNotificationsCount();
if (notificationListAdapter == null) { if (notificationListAdapter == null) {
notificationListAdapter = new NotificationListAdapter(notifications, MainActivity.this); notificationListAdapter = new NotificationListAdapter(notifications, MainActivity.this);
@ -3717,7 +3616,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
return null; return null;
} }
protected void onPostExecute() { protected void onPostExecute() {
loadUnseenNotificationsCount(); loadUnreadNotificationsCount();
} }
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@ -3831,51 +3730,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
} }
} }
private void checkAndEnableShareUsageData() {
final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
boolean shareUsageData = sp.getBoolean(PREFERENCE_KEY_SHARE_USAGE_DATA, false);
if (shareUsageData) {
return;
}
(new AsyncTask<Void, Void, Void>() {
protected Void doInBackground(Void... params) {
PrintStream out = null;
try {
String fileContent = "true";
String path = String.format("%s/sud", Utils.getAppInternalStorageDir(MainActivity.this));
out = new PrintStream(new FileOutputStream(path));
out.print(fileContent);
} catch (Exception ex) {
// pass
} finally {
Helper.closeCloseable(out);
}
return null;
}
protected void onPostExecute(Void result) {
updateSdkSetting("share_usage_data", true);
sp.edit().putBoolean(PREFERENCE_KEY_SHARE_USAGE_DATA, true).apply();
}
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
public void updateSdkSetting(String key, Object value) {
(new Thread() {
public void run() {
Map<String, Object> params = new HashMap<>();
params.put(key, value);
try {
Lbry.parseResponse(Lbry.apiCall("settings_set", params, Lbry.SDK_CONNECTION_STRING));
} catch (Exception ex) {
// pass
Log.d(TAG, ex.getMessage(), ex);
}
}
}).start();
}
public interface BackPressInterceptor { public interface BackPressInterceptor {
boolean onBackPressed(); boolean onBackPressed();
} }

View file

@ -31,7 +31,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import io.lbry.browser.adapter.VerificationPagerAdapter; import io.lbry.browser.adapter.VerificationPagerAdapter;
import io.lbry.browser.listener.SdkStatusListener;
import io.lbry.browser.listener.SignInListener; import io.lbry.browser.listener.SignInListener;
import io.lbry.browser.listener.WalletSyncListener; import io.lbry.browser.listener.WalletSyncListener;
import io.lbry.browser.model.lbryinc.RewardVerified; import io.lbry.browser.model.lbryinc.RewardVerified;
@ -49,14 +48,13 @@ public class VerificationActivity extends FragmentActivity implements SignInList
public static final int VERIFICATION_FLOW_REWARDS = 2; public static final int VERIFICATION_FLOW_REWARDS = 2;
public static final int VERIFICATION_FLOW_WALLET = 3; public static final int VERIFICATION_FLOW_WALLET = 3;
private List<SdkStatusListener> sdkStatusListeners;
private BillingClient billingClient; private BillingClient billingClient;
private BroadcastReceiver sdkReceiver; private BroadcastReceiver sdkReceiver;
private String email; private String email;
private boolean signedIn; private boolean signedIn;
private int flow; private int flow;
private final PurchasesUpdatedListener purchasesUpdatedListener = new PurchasesUpdatedListener() { private PurchasesUpdatedListener purchasesUpdatedListener = new PurchasesUpdatedListener() {
@Override @Override
public void onPurchasesUpdated(@NonNull BillingResult billingResult, @Nullable List<Purchase> purchases) { public void onPurchasesUpdated(@NonNull BillingResult billingResult, @Nullable List<Purchase> purchases) {
int responseCode = billingResult.getResponseCode(); int responseCode = billingResult.getResponseCode();
@ -107,8 +105,6 @@ public class VerificationActivity extends FragmentActivity implements SignInList
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
sdkStatusListeners = new ArrayList<>();
signedIn = Lbryio.isSignedIn(); signedIn = Lbryio.isSignedIn();
Intent intent = getIntent(); Intent intent = getIntent();
if (intent != null) { if (intent != null) {
@ -130,18 +126,11 @@ public class VerificationActivity extends FragmentActivity implements SignInList
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
filter.addAction(LbrynetService.ACTION_STOP_SERVICE); filter.addAction(LbrynetService.ACTION_STOP_SERVICE);
filter.addAction(MainActivity.ACTION_SDK_READY);
sdkReceiver = new BroadcastReceiver() { sdkReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
String action = intent.getAction(); String action = intent.getAction();
if (MainActivity.ACTION_SDK_READY.equals(action)) { if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) {
for (SdkStatusListener listener : sdkStatusListeners) {
if (listener != null) {
listener.onSdkReady();
}
}
} else if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) {
finish(); finish();
} }
} }
@ -204,16 +193,15 @@ public class VerificationActivity extends FragmentActivity implements SignInList
} else if (flow == VERIFICATION_FLOW_REWARDS) { } else if (flow == VERIFICATION_FLOW_REWARDS) {
User user = Lbryio.currentUser; User user = Lbryio.currentUser;
// disable phone verification for now // disable phone verification for now
if (!user.isIdentityVerified()) { /*if (!user.isIdentityVerified()) {
// phone number verification required // phone number verification required
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false); viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false);
flowHandled = true; flowHandled = true;
} else { } else */
if (!user.isRewardApproved()) { if (!user.isRewardApproved()) {
// manual verification required // manual verification required
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false); viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false);
flowHandled = true; flowHandled = true;
}
} }
} }
@ -226,11 +214,6 @@ public class VerificationActivity extends FragmentActivity implements SignInList
} }
} }
public void showPhoneVerification() {
ViewPager2 viewPager = findViewById(R.id.verification_pager);
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false);
}
public void showLoading() { public void showLoading() {
findViewById(R.id.verification_loading_progress).setVisibility(View.VISIBLE); findViewById(R.id.verification_loading_progress).setVisibility(View.VISIBLE);
findViewById(R.id.verification_pager).setVisibility(View.INVISIBLE); findViewById(R.id.verification_pager).setVisibility(View.INVISIBLE);
@ -244,12 +227,8 @@ public class VerificationActivity extends FragmentActivity implements SignInList
@Override @Override
public void onBackPressed() { public void onBackPressed() {
ViewPager2 viewPager = findViewById(R.id.verification_pager); // ignore back press
return;
if (viewPager.getCurrentItem() != VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL)
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL);
else
super.onBackPressed();
} }
public void onEmailAdded(String email) { public void onEmailAdded(String email) {
@ -306,18 +285,20 @@ public class VerificationActivity extends FragmentActivity implements SignInList
ViewPager2 viewPager = findViewById(R.id.verification_pager); ViewPager2 viewPager = findViewById(R.id.verification_pager);
// for rewards, (show phone verification if not done, or manual verification if required) // for rewards, (show phone verification if not done, or manual verification if required)
if (flow == VERIFICATION_FLOW_REWARDS) { if (flow == VERIFICATION_FLOW_REWARDS) {
if (!user.isIdentityVerified()) { // skipping phone verification
/*if (!user.isIdentityVerified()) {
// phone number verification required // phone number verification required
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false); viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false);
} else
*/
if (!user.isRewardApproved()) {
// manual verification required
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false);
} else { } else {
if (!user.isRewardApproved()) { // fully verified
// manual verification required setResult(RESULT_OK);
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false); finish();
} else {
// fully verified
setResult(RESULT_OK);
finish();
}
} }
} else if (flow == VERIFICATION_FLOW_WALLET) { } else if (flow == VERIFICATION_FLOW_WALLET) {
// for wallet sync, if password unlock is required, show password entry page // for wallet sync, if password unlock is required, show password entry page
@ -355,7 +336,6 @@ public class VerificationActivity extends FragmentActivity implements SignInList
return; return;
} }
findViewById(R.id.verification_close_button).setVisibility(View.VISIBLE);
// show manual verification page if the user is still not reward approved // show manual verification page if the user is still not reward approved
ViewPager2 viewPager = findViewById(R.id.verification_pager); ViewPager2 viewPager = findViewById(R.id.verification_pager);
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false); viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false);
@ -456,14 +436,4 @@ public class VerificationActivity extends FragmentActivity implements SignInList
Helper.unregisterReceiver(sdkReceiver, this); Helper.unregisterReceiver(sdkReceiver, this);
super.onDestroy(); super.onDestroy();
} }
public void addSdkStatusListener(SdkStatusListener listener) {
if (!sdkStatusListeners.contains(listener)) {
sdkStatusListeners.add(listener);
}
}
public void removeSdkStatusListener(SdkStatusListener listener) {
sdkStatusListeners.remove(listener);
}
} }

View file

@ -23,7 +23,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
public class ChannelFilterListAdapter extends RecyclerView.Adapter<ChannelFilterListAdapter.ViewHolder> { public class ChannelFilterListAdapter extends RecyclerView.Adapter<ChannelFilterListAdapter.ViewHolder> {
private final Context context; private Context context;
private List<Claim> items; private List<Claim> items;
@Getter @Getter
@Setter @Setter
@ -42,12 +42,12 @@ public class ChannelFilterListAdapter extends RecyclerView.Adapter<ChannelFilter
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final View mediaContainer; protected View mediaContainer;
protected final View alphaContainer; protected View alphaContainer;
protected final View allView; protected View allView;
protected final ImageView thumbnailView; protected ImageView thumbnailView;
protected final TextView alphaView; protected TextView alphaView;
protected final TextView titleView; protected TextView titleView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
mediaContainer = v.findViewById(R.id.channel_filter_media_container); mediaContainer = v.findViewById(R.id.channel_filter_media_container);
@ -95,13 +95,13 @@ public class ChannelFilterListAdapter extends RecyclerView.Adapter<ChannelFilter
vh.allView.setVisibility(claim.isPlaceholder() ? View.VISIBLE : View.GONE); vh.allView.setVisibility(claim.isPlaceholder() ? View.VISIBLE : View.GONE);
vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle()); vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
String thumbnailUrl = claim.getThumbnailUrl(vh.thumbnailView.getLayoutParams().width, vh.thumbnailView.getLayoutParams().height, 85); String thumbnailUrl = claim.getThumbnailUrl();
if (!Helper.isNullOrEmpty(thumbnailUrl) && context != null) { if (!Helper.isNullOrEmpty(thumbnailUrl) && context != null) {
Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView); Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
} }
vh.alphaContainer.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.VISIBLE : View.GONE); vh.alphaContainer.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.VISIBLE : View.GONE);
vh.thumbnailView.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.GONE : View.VISIBLE); vh.thumbnailView.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.GONE : View.VISIBLE);
vh.alphaView.setText(claim.isPlaceholder() ? null : claim.getName() != null ? claim.getName().substring(1, 2).toUpperCase() : ""); vh.alphaView.setText(claim.isPlaceholder() ? null : claim.getName() != null ? claim.getName().substring(1, 2) : "");
int bgColor = Helper.generateRandomColorForValue(claim.getClaimId()); int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
Helper.setIconViewBackgroundColor(vh.alphaContainer, bgColor, claim.isPlaceholder(), context); Helper.setIconViewBackgroundColor(vh.alphaContainer, bgColor, claim.isPlaceholder(), context);

View file

@ -21,6 +21,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R; import io.lbry.browser.R;
import io.lbry.browser.listener.SelectionModeListener; import io.lbry.browser.listener.SelectionModeListener;
import io.lbry.browser.model.Claim; import io.lbry.browser.model.Claim;
@ -36,18 +37,18 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
private static final int VIEW_TYPE_CHANNEL = 2; private static final int VIEW_TYPE_CHANNEL = 2;
private static final int VIEW_TYPE_FEATURED = 3; // featured search result private static final int VIEW_TYPE_FEATURED = 3; // featured search result
private final Map<String, Claim> quickClaimIdMap; private Map<String, Claim> quickClaimIdMap;
private final Map<String, Claim> quickClaimUrlMap; private Map<String, Claim> quickClaimUrlMap;
private final Map<String, Boolean> notFoundClaimIdMap; private Map<String, Boolean> notFoundClaimIdMap;
private final Map<String, Boolean> notFoundClaimUrlMap; private Map<String, Boolean> notFoundClaimUrlMap;
@Setter @Setter
private boolean hideFee; private boolean hideFee;
@Setter @Setter
private boolean canEnterSelectionMode; private boolean canEnterSelectionMode;
private final Context context; private Context context;
private List<Claim> items; private List<Claim> items;
private final List<Claim> selectedItems; private List<Claim> selectedItems;
@Setter @Setter
private ClaimListItemListener listener; private ClaimListItemListener listener;
@Getter @Getter
@ -175,27 +176,27 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final View feeContainer; protected View feeContainer;
protected final TextView feeView; protected TextView feeView;
protected final ImageView thumbnailView; protected ImageView thumbnailView;
protected final View noThumbnailView; protected View noThumbnailView;
protected final TextView alphaView; protected TextView alphaView;
protected final TextView vanityUrlView; protected TextView vanityUrlView;
protected final TextView durationView; protected TextView durationView;
protected final TextView titleView; protected TextView titleView;
protected final TextView publisherView; protected TextView publisherView;
protected final TextView publishTimeView; protected TextView publishTimeView;
protected final TextView pendingTextView; protected TextView pendingTextView;
protected final View repostInfoView; protected View repostInfoView;
protected final TextView repostChannelView; protected TextView repostChannelView;
protected final View selectedOverlayView; protected View selectedOverlayView;
protected final TextView fileSizeView; protected TextView fileSizeView;
protected final ProgressBar downloadProgressView; protected ProgressBar downloadProgressView;
protected final TextView deviceView; protected TextView deviceView;
protected final View loadingImagePlaceholder; protected View loadingImagePlaceholder;
protected final View loadingTextPlaceholder1; protected View loadingTextPlaceholder1;
protected final View loadingTextPlaceholder2; protected View loadingTextPlaceholder2;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
feeContainer = v.findViewById(R.id.claim_fee_container); feeContainer = v.findViewById(R.id.claim_fee_container);
@ -334,8 +335,7 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
if (metadata instanceof Claim.StreamMetadata) { if (metadata instanceof Claim.StreamMetadata) {
streamMetadata = (Claim.StreamMetadata) metadata; streamMetadata = (Claim.StreamMetadata) metadata;
} }
String thumbnailUrl = item.getThumbnailUrl();
String thumbnailUrl = item.getThumbnailUrl(vh.thumbnailView.getLayoutParams().width, vh.thumbnailView.getLayoutParams().height, 85);
long publishTime = (streamMetadata != null && streamMetadata.getReleaseTime() > 0) ? streamMetadata.getReleaseTime() * 1000 : item.getTimestamp() * 1000; long publishTime = (streamMetadata != null && streamMetadata.getReleaseTime() > 0) ? streamMetadata.getReleaseTime() * 1000 : item.getTimestamp() * 1000;
int bgColor = Helper.generateRandomColorForValue(item.getClaimId()); int bgColor = Helper.generateRandomColorForValue(item.getClaimId());
if (bgColor == 0) { if (bgColor == 0) {
@ -404,7 +404,7 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
vh.publishTimeView.setVisibility(!isPending ? View.VISIBLE : View.GONE); vh.publishTimeView.setVisibility(!isPending ? View.VISIBLE : View.GONE);
vh.pendingTextView.setVisibility(isPending && !item.isLoadingPlaceholder() ? 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.repostInfoView.setVisibility(isRepost && type != VIEW_TYPE_FEATURED ? View.VISIBLE : View.GONE);
vh.repostChannelView.setText(isRepost && original.getSigningChannel() != null ? original.getSigningChannel().getName() : null); vh.repostChannelView.setText(isRepost ? original.getSigningChannel().getName() : null);
vh.repostChannelView.setOnClickListener(new View.OnClickListener() { vh.repostChannelView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {

View file

@ -27,9 +27,9 @@ import io.lbry.browser.utils.LbryUri;
import lombok.Setter; import lombok.Setter;
public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.ViewHolder> { public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.ViewHolder> {
private final List<Comment> items; private List<Comment> items;
private final Context context; private Context context;
private final boolean nested; private boolean nested;
private float scale; private float scale;
@Setter @Setter
private ClaimListAdapter.ClaimListItemListener listener; private ClaimListAdapter.ClaimListItemListener listener;
@ -102,14 +102,14 @@ public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final TextView channelName; protected TextView channelName;
protected final TextView commentText; protected TextView commentText;
protected final ImageView thumbnailView; protected ImageView thumbnailView;
protected final View noThumbnailView; protected View noThumbnailView;
protected final TextView alphaView; protected TextView alphaView;
protected final TextView commentTimeView; protected TextView commentTimeView;
protected final View replyLink; protected View replyLink;
protected final RecyclerView repliesList; protected RecyclerView repliesList;
public ViewHolder (View v) { public ViewHolder (View v) {
super(v); super(v);
@ -190,7 +190,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.
int bgColor = Helper.generateRandomColorForValue(comment.getChannelId()); int bgColor = Helper.generateRandomColorForValue(comment.getChannelId());
Helper.setIconViewBackgroundColor(holder.noThumbnailView, bgColor, false, context); Helper.setIconViewBackgroundColor(holder.noThumbnailView, bgColor, false, context);
if (hasThumbnail) { if (hasThumbnail) {
Glide.with(context.getApplicationContext()).asBitmap().load(comment.getPoster().getThumbnailUrl(holder.thumbnailView.getLayoutParams().width, holder.thumbnailView.getLayoutParams().height, 85)). Glide.with(context.getApplicationContext()).asBitmap().load(comment.getPoster().getThumbnailUrl()).
apply(RequestOptions.circleCropTransform()).into(holder.thumbnailView); apply(RequestOptions.circleCropTransform()).into(holder.thumbnailView);
} }
holder.alphaView.setText(comment.getChannelName() != null ? comment.getChannelName().substring(1, 2).toUpperCase() : null); holder.alphaView.setText(comment.getChannelName() != null ? comment.getChannelName().substring(1, 2).toUpperCase() : null);

View file

@ -23,8 +23,8 @@ public class EditorsChoiceItemAdapter extends RecyclerView.Adapter<EditorsChoice
private static final int VIEW_TYPE_HEADER = 1; private static final int VIEW_TYPE_HEADER = 1;
private static final int VIEW_TYPE_CONTENT = 2; private static final int VIEW_TYPE_CONTENT = 2;
private final Context context; private Context context;
private final List<EditorsChoiceItem> items; private List<EditorsChoiceItem> items;
@Setter @Setter
private EditorsChoiceItemListener listener; private EditorsChoiceItemListener listener;
@ -48,11 +48,11 @@ public class EditorsChoiceItemAdapter extends RecyclerView.Adapter<EditorsChoice
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final ImageView thumbnailView; protected ImageView thumbnailView;
protected final TextView descriptionView; protected TextView descriptionView;
protected final TextView headerView; protected TextView headerView;
protected final TextView titleView; protected TextView titleView;
protected final View cardView; protected View cardView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);

View file

@ -21,8 +21,8 @@ import io.lbry.browser.utils.Helper;
import lombok.Setter; import lombok.Setter;
public class GalleryGridAdapter extends RecyclerView.Adapter<GalleryGridAdapter.ViewHolder> { public class GalleryGridAdapter extends RecyclerView.Adapter<GalleryGridAdapter.ViewHolder> {
private final Context context; private Context context;
private final List<GalleryItem> items; private List<GalleryItem> items;
@Setter @Setter
private GalleryItemClickListener listener; private GalleryItemClickListener listener;
@ -32,8 +32,8 @@ public class GalleryGridAdapter extends RecyclerView.Adapter<GalleryGridAdapter.
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final ImageView thumbnailView; protected ImageView thumbnailView;
protected final TextView durationView; protected TextView durationView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
thumbnailView = v.findViewById(R.id.gallery_item_thumbnail); thumbnailView = v.findViewById(R.id.gallery_item_thumbnail);
@ -96,8 +96,8 @@ public class GalleryGridAdapter extends RecyclerView.Adapter<GalleryGridAdapter.
public static class GalleryGridItemDecoration extends RecyclerView.ItemDecoration { public static class GalleryGridItemDecoration extends RecyclerView.ItemDecoration {
private final int spanCount; private int spanCount;
private final int spacing; private int spacing;
public GalleryGridItemDecoration(int spanCount, int spacing) { public GalleryGridItemDecoration(int spanCount, int spacing) {
this.spanCount = spanCount; this.spanCount = spanCount;

View file

@ -1,10 +1,12 @@
package io.lbry.browser.adapter; package io.lbry.browser.adapter;
import android.content.Context; import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.SpinnerAdapter;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
@ -16,9 +18,9 @@ import io.lbry.browser.model.Claim;
public class InlineChannelSpinnerAdapter extends ArrayAdapter<Claim> { public class InlineChannelSpinnerAdapter extends ArrayAdapter<Claim> {
private final List<Claim> channels; private List<Claim> channels;
private final int layoutResourceId; private int layoutResourceId;
private final LayoutInflater inflater; private LayoutInflater inflater;
public InlineChannelSpinnerAdapter(Context context, int resource, List<Claim> channels) { public InlineChannelSpinnerAdapter(Context context, int resource, List<Claim> channels) {
super(context, resource, 0, channels); super(context, resource, 0, channels);

View file

@ -1,7 +1,9 @@
package io.lbry.browser.adapter; package io.lbry.browser.adapter;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.net.Uri;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -9,16 +11,21 @@ import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import io.lbry.browser.R; import io.lbry.browser.R;
import io.lbry.browser.model.lbryinc.Invitee; import io.lbry.browser.model.lbryinc.Invitee;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.LbryUri;
import lombok.Setter;
public class InviteeListAdapter extends RecyclerView.Adapter<InviteeListAdapter.ViewHolder> { public class InviteeListAdapter extends RecyclerView.Adapter<InviteeListAdapter.ViewHolder> {
private final Context context; private Context context;
private final List<Invitee> items; private List<Invitee> items;
public InviteeListAdapter(List<Invitee> invitees, Context context) { public InviteeListAdapter(List<Invitee> invitees, Context context) {
this.context = context; this.context = context;
@ -73,8 +80,8 @@ public class InviteeListAdapter extends RecyclerView.Adapter<InviteeListAdapter.
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final TextView emailView; protected TextView emailView;
protected final TextView rewardView; protected TextView rewardView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);

View file

@ -10,12 +10,13 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import io.lbry.browser.R; import io.lbry.browser.R;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.Language; import io.lbry.browser.model.Language;
import io.lbry.browser.utils.Predefined; import io.lbry.browser.utils.Predefined;
public class LanguageSpinnerAdapter extends ArrayAdapter<Language> { public class LanguageSpinnerAdapter extends ArrayAdapter<Language> {
private final int layoutResourceId; private int layoutResourceId;
private final LayoutInflater inflater; private LayoutInflater inflater;
public LanguageSpinnerAdapter(Context context, int resource) { public LanguageSpinnerAdapter(Context context, int resource) {
super(context, resource, 0, Predefined.PUBLISH_LANGUAGES); super(context, resource, 0, Predefined.PUBLISH_LANGUAGES);

View file

@ -10,12 +10,13 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import io.lbry.browser.R; import io.lbry.browser.R;
import io.lbry.browser.model.Language;
import io.lbry.browser.model.License; import io.lbry.browser.model.License;
import io.lbry.browser.utils.Predefined; import io.lbry.browser.utils.Predefined;
public class LicenseSpinnerAdapter extends ArrayAdapter<License> { public class LicenseSpinnerAdapter extends ArrayAdapter<License> {
private final int layoutResourceId; private int layoutResourceId;
private final LayoutInflater inflater; private LayoutInflater inflater;
public LicenseSpinnerAdapter(Context context, int resource) { public LicenseSpinnerAdapter(Context context, int resource) {
super(context, resource, 0, Predefined.LICENSES); super(context, resource, 0, Predefined.LICENSES);

View file

@ -2,8 +2,10 @@ package io.lbry.browser.adapter;
import android.content.Context; import android.content.Context;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -15,14 +17,15 @@ import io.lbry.browser.R;
import io.lbry.browser.model.NavMenuItem; import io.lbry.browser.model.NavMenuItem;
import io.lbry.browser.ui.controls.SolidIconView; import io.lbry.browser.ui.controls.SolidIconView;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import lombok.Getter;
import lombok.Setter; import lombok.Setter;
public class NavigationMenuAdapter extends RecyclerView.Adapter<NavigationMenuAdapter.ViewHolder> { public class NavigationMenuAdapter extends RecyclerView.Adapter<NavigationMenuAdapter.ViewHolder> {
private static final int TYPE_GROUP = 1; private static final int TYPE_GROUP = 1;
private static final int TYPE_ITEM = 2; private static final int TYPE_ITEM = 2;
private final Context context; private Context context;
private final List<NavMenuItem> menuItems; private List<NavMenuItem> menuItems;
private NavMenuItem currentItem; private NavMenuItem currentItem;
@Setter @Setter
private NavigationMenuItemClickListener listener; private NavigationMenuItemClickListener listener;
@ -62,8 +65,8 @@ public class NavigationMenuAdapter extends RecyclerView.Adapter<NavigationMenuAd
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final SolidIconView iconView; protected SolidIconView iconView;
protected final TextView titleView; protected TextView titleView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
titleView = v.findViewById(R.id.nav_menu_title); titleView = v.findViewById(R.id.nav_menu_title);

View file

@ -14,10 +14,12 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.snackbar.Snackbar;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
@ -32,6 +34,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@ -40,9 +43,9 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
private static final String RULE_CREATOR_SUBSCRIBER = "creator_subscriber"; private static final String RULE_CREATOR_SUBSCRIBER = "creator_subscriber";
private static final String RULE_COMMENT = "comment"; private static final String RULE_COMMENT = "comment";
private final Context context; private Context context;
private final List<LbryNotification> items; private List<LbryNotification> items;
private final List<LbryNotification> selectedItems; private List<LbryNotification> selectedItems;
@Setter @Setter
private NotificationClickListener clickListener; private NotificationClickListener clickListener;
@Getter @Getter
@ -59,13 +62,13 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final View layoutView; protected View layoutView;
protected final TextView titleView; protected TextView titleView;
protected final TextView bodyView; protected TextView bodyView;
protected final TextView timeView; protected TextView timeView;
protected final SolidIconView iconView; protected SolidIconView iconView;
protected final ImageView thumbnailView; protected ImageView thumbnailView;
protected final View selectedOverlayView; protected View selectedOverlayView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
layoutView = v.findViewById(R.id.notification_layout); layoutView = v.findViewById(R.id.notification_layout);
@ -193,7 +196,7 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
vh.thumbnailView.setVisibility(notification.getCommentAuthor() == null ? View.INVISIBLE : View.VISIBLE); vh.thumbnailView.setVisibility(notification.getCommentAuthor() == null ? View.INVISIBLE : View.VISIBLE);
if (notification.getCommentAuthor() != null) { if (notification.getCommentAuthor() != null) {
Glide.with(context.getApplicationContext()).load( Glide.with(context.getApplicationContext()).load(
notification.getCommentAuthor().getThumbnailUrl(vh.thumbnailView.getLayoutParams().width, vh.thumbnailView.getLayoutParams().height, 85)).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView); notification.getCommentAuthor().getThumbnailUrl()).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
} }
vh.iconView.setVisibility(notification.getCommentAuthor() != null ? View.INVISIBLE : View.VISIBLE); vh.iconView.setVisibility(notification.getCommentAuthor() != null ? View.INVISIBLE : View.VISIBLE);

View file

@ -32,7 +32,7 @@ public class RewardListAdapter extends RecyclerView.Adapter<RewardListAdapter.Vi
public static final int DISPLAY_MODE_ALL = 1; public static final int DISPLAY_MODE_ALL = 1;
public static final int DISPLAY_MODE_UNCLAIMED = 2; public static final int DISPLAY_MODE_UNCLAIMED = 2;
private final Context context; private Context context;
@Setter @Setter
private List<Reward> all; private List<Reward> all;
private List<Reward> items; private List<Reward> items;
@ -85,16 +85,16 @@ public class RewardListAdapter extends RecyclerView.Adapter<RewardListAdapter.Vi
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final View iconClaimed; protected View iconClaimed;
protected final View loading; protected View loading;
protected final View upTo; protected View upTo;
protected final TextView textTitle; protected TextView textTitle;
protected final TextView textDescription; protected TextView textDescription;
protected final TextView textLbcValue; protected TextView textLbcValue;
protected final TextView textUsdValue; protected TextView textUsdValue;
protected final TextView textLinkTransaction; protected TextView textLinkTransaction;
protected final EditText inputCustomCode; protected EditText inputCustomCode;
protected final MaterialButton buttonClaimCustom; protected MaterialButton buttonClaimCustom;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
iconClaimed = v.findViewById(R.id.reward_item_claimed_icon); iconClaimed = v.findViewById(R.id.reward_item_claimed_icon);

View file

@ -1,70 +0,0 @@
package io.lbry.browser.adapter;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
import io.lbry.browser.R;
import io.lbry.browser.model.StartupStage;
public class StartupStageAdapter extends BaseAdapter {
private final List<StartupStage> list;
private final LayoutInflater inflater;
private final String[] stagesString;
public StartupStageAdapter(Context ctx, List<StartupStage> rows) {
this.list = rows;
this.inflater = LayoutInflater.from(ctx);
stagesString = new String[9];
stagesString[0] = ctx.getResources().getString(R.string.installation_id_loaded);
stagesString[1] = ctx.getResources().getString(R.string.known_tags_loaded);
stagesString[2] = ctx.getResources().getString(R.string.exchange_rate_loaded);
stagesString[3] = ctx.getResources().getString(R.string.user_authenticated);
stagesString[4] = ctx.getResources().getString(R.string.installation_registered);
stagesString[5] = ctx.getResources().getString(R.string.subscriptions_loaded);
stagesString[6] = ctx.getResources().getString(R.string.subscriptions_resolved);
stagesString[7] = ctx.getResources().getString(R.string.block_list_loaded);
stagesString[8] = ctx.getResources().getString(R.string.filter_list_loaded);
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int i) {
return list.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null) {
view = inflater.inflate(R.layout.list_item_startupstage, viewGroup, false);
ImageView iconView = view.findViewById(R.id.startup_stage_icon);
TextView textView = view.findViewById(R.id.startup_stage_text);
StartupStage item = (StartupStage) getItem(i);
iconView.setImageResource(item.stageDone ? R.drawable.ic_check : R.drawable.ic_close);
iconView.setColorFilter(item.stageDone ? Color.WHITE : Color.RED);
textView.setText(stagesString[item.stage - 1]);
}
return view;
}
}

View file

@ -22,9 +22,9 @@ import io.lbry.browser.utils.Helper;
import lombok.Setter; import lombok.Setter;
public class SuggestedChannelGridAdapter extends RecyclerView.Adapter<SuggestedChannelGridAdapter.ViewHolder> { public class SuggestedChannelGridAdapter extends RecyclerView.Adapter<SuggestedChannelGridAdapter.ViewHolder> {
private final Context context; private Context context;
private final List<Claim> items; private List<Claim> items;
private final List<Claim> selectedItems; private List<Claim> selectedItems;
@Setter @Setter
private ChannelItemSelectionListener listener; private ChannelItemSelectionListener listener;
@ -35,11 +35,11 @@ public class SuggestedChannelGridAdapter extends RecyclerView.Adapter<SuggestedC
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final View noThumbnailView; protected View noThumbnailView;
protected final ImageView thumbnailView; protected ImageView thumbnailView;
protected final TextView alphaView; protected TextView alphaView;
protected final TextView titleView; protected TextView titleView;
protected final TextView tagView; protected TextView tagView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
noThumbnailView = v.findViewById(R.id.suggested_channel_no_thumbnail); noThumbnailView = v.findViewById(R.id.suggested_channel_no_thumbnail);
@ -89,8 +89,7 @@ public class SuggestedChannelGridAdapter extends RecyclerView.Adapter<SuggestedC
@Override @Override
public void onBindViewHolder(SuggestedChannelGridAdapter.ViewHolder vh, int position) { public void onBindViewHolder(SuggestedChannelGridAdapter.ViewHolder vh, int position) {
Claim claim = items.get(position); Claim claim = items.get(position);
ViewGroup.LayoutParams lp = vh.thumbnailView.getLayoutParams(); String thumbnailUrl = claim.getThumbnailUrl();
String thumbnailUrl = claim.getThumbnailUrl(lp.width, lp.height, 85);
int bgColor = Helper.generateRandomColorForValue(claim.getClaimId()); int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
Helper.setIconViewBackgroundColor(vh.noThumbnailView, bgColor, false, context); Helper.setIconViewBackgroundColor(vh.noThumbnailView, bgColor, false, context);

View file

@ -23,13 +23,12 @@ public class TagListAdapter extends RecyclerView.Adapter<TagListAdapter.ViewHold
public static final int CUSTOMIZE_MODE_ADD = 1; public static final int CUSTOMIZE_MODE_ADD = 1;
public static final int CUSTOMIZE_MODE_REMOVE = 2; public static final int CUSTOMIZE_MODE_REMOVE = 2;
private final Context context; private Context context;
private List<Tag> items; private List<Tag> items;
@Setter @Setter
private TagClickListener clickListener; private TagClickListener clickListener;
@Setter
@Getter @Getter
@Setter
private int customizeMode; private int customizeMode;
public TagListAdapter(List<Tag> tags, Context context) { public TagListAdapter(List<Tag> tags, Context context) {
@ -39,8 +38,8 @@ public class TagListAdapter extends RecyclerView.Adapter<TagListAdapter.ViewHold
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final ImageView iconView; protected ImageView iconView;
protected final TextView nameView; protected TextView nameView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
iconView = v.findViewById(R.id.tag_action); iconView = v.findViewById(R.id.tag_action);

View file

@ -26,8 +26,8 @@ public class TransactionListAdapter extends RecyclerView.Adapter<TransactionList
private static final DecimalFormat TX_LIST_AMOUNT_FORMAT = new DecimalFormat("#,##0.0000"); private static final DecimalFormat TX_LIST_AMOUNT_FORMAT = new DecimalFormat("#,##0.0000");
private static final SimpleDateFormat TX_LIST_DATE_FORMAT = new SimpleDateFormat("MMM d"); private static final SimpleDateFormat TX_LIST_DATE_FORMAT = new SimpleDateFormat("MMM d");
private final Context context; private Context context;
private final List<Transaction> items; private List<Transaction> items;
@Setter @Setter
private TransactionClickListener listener; private TransactionClickListener listener;
@ -107,14 +107,14 @@ public class TransactionListAdapter extends RecyclerView.Adapter<TransactionList
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final TextView descView; protected TextView descView;
protected final TextView amountView; protected TextView amountView;
protected final TextView claimView; protected TextView claimView;
protected final TextView feeView; protected TextView feeView;
protected final TextView txidLinkView; protected TextView txidLinkView;
protected final TextView dateView; protected TextView dateView;
protected final TextView pendingView; protected TextView pendingView;
protected final View infoFeeContainer; protected View infoFeeContainer;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);

View file

@ -21,8 +21,8 @@ import io.lbry.browser.utils.LbryUri;
import lombok.Setter; import lombok.Setter;
public class UrlSuggestionListAdapter extends RecyclerView.Adapter<UrlSuggestionListAdapter.ViewHolder> { public class UrlSuggestionListAdapter extends RecyclerView.Adapter<UrlSuggestionListAdapter.ViewHolder> {
private final Context context; private Context context;
private final List<UrlSuggestion> items; private List<UrlSuggestion> items;
@Setter @Setter
private UrlSuggestionClickListener listener; private UrlSuggestionClickListener listener;
@ -130,9 +130,9 @@ public class UrlSuggestionListAdapter extends RecyclerView.Adapter<UrlSuggestion
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected final SolidIconView iconView; protected SolidIconView iconView;
protected final TextView titleView; protected TextView titleView;
protected final TextView descView; protected TextView descView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
iconView = v.findViewById(R.id.url_suggestion_icon); iconView = v.findViewById(R.id.url_suggestion_icon);

View file

@ -25,7 +25,7 @@ public class VerificationPagerAdapter extends FragmentStateAdapter {
public static final int PAGE_VERIFICATION_WALLET = 2; public static final int PAGE_VERIFICATION_WALLET = 2;
public static final int PAGE_VERIFICATION_MANUAL = 3; public static final int PAGE_VERIFICATION_MANUAL = 3;
private final FragmentActivity activity; private FragmentActivity activity;
public VerificationPagerAdapter(FragmentActivity activity) { public VerificationPagerAdapter(FragmentActivity activity) {
super(activity); super(activity);

View file

@ -1,100 +0,0 @@
package io.lbry.browser.adapter;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import java.util.List;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.model.WalletDetailItem;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.views.CreditsBalanceView;
public class WalletDetailAdapter extends BaseAdapter {
private final List<WalletDetailItem> list;
private final LayoutInflater inflater;
public WalletDetailAdapter(Context ctx, List<WalletDetailItem> rows) {
this.list = rows;
this.inflater = LayoutInflater.from(ctx);
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int i) {
return list.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null) {
view = inflater.inflate(R.layout.list_item_boosting_balance, viewGroup, false);
CreditsBalanceView balanceView = view.findViewById(R.id.wallet_supporting_balance);
TextView detailTextView = view.findViewById(R.id.detail);
TextView detailExplanationTextView = view.findViewById(R.id.detail_explanation);
WalletDetailItem item = (WalletDetailItem) getItem(i);
detailTextView.setText(item.detail);
detailExplanationTextView.setText(item.detailDesc);
Helper.setViewText(balanceView, item.detailAmount);
ProgressBar progressUnlockTips = view.findViewById(R.id.wallet_unlock_tips_progress);
progressUnlockTips.setVisibility(item.isInProgress ? View.VISIBLE : View.GONE);
ImageButton buttonLock = view.findViewById(R.id.lock_button);
buttonLock.setVisibility((item.isUnlockable && !item.isInProgress) ? View.VISIBLE : View.GONE);
if (item.isUnlockable) {
buttonLock.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (view.getContext() != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()).
setTitle(R.string.unlock_tips).
setMessage(R.string.confirm_unlock_tips)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
unlockTips(view);
}
}).setNegativeButton(R.string.no, null);
builder.show();
}
}
});
}
}
return view;
}
private void unlockTips(View v) {
Context ctx = v.getContext();
if (ctx instanceof MainActivity) {
v.setVisibility(View.GONE);
View progress = v.getRootView().findViewById(R.id.wallet_unlock_tips_progress);
progress.setVisibility(View.VISIBLE);
((MainActivity) ctx).unlockTips();
}
}
}

View file

@ -6,6 +6,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.SQLInput;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -123,9 +124,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
private static final String SQL_INSERT_NOTIFICATION = "REPLACE INTO notifications (remote_id, author_url, title, description, rule, target_url, is_read, is_seen, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; private static final String SQL_INSERT_NOTIFICATION = "REPLACE INTO notifications (remote_id, author_url, title, description, rule, target_url, is_read, is_seen, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
private static final String SQL_GET_NOTIFICATIONS = "SELECT id, remote_id, author_url, title, description, rule, target_url, is_read, is_seen, timestamp FROM notifications ORDER BY timestamp DESC LIMIT 500"; private static final String SQL_GET_NOTIFICATIONS = "SELECT id, remote_id, author_url, title, description, rule, target_url, is_read, is_seen, timestamp FROM notifications ORDER BY timestamp DESC LIMIT 500";
private static final String SQL_GET_UNREAD_NOTIFICATIONS_COUNT = "SELECT COUNT(id) FROM notifications WHERE is_read <> 1"; private static final String SQL_GET_UNREAD_NOTIFICATIONS_COUNT = "SELECT COUNT(id) FROM notifications WHERE is_read <> 1";
private static final String SQL_GET_UNSEEN_NOTIFICATIONS_COUNT = "SELECT COUNT(id) FROM notifications WHERE is_seen <> 1";
private static final String SQL_MARK_NOTIFICATIONS_READ = "UPDATE notifications SET is_read = 1 WHERE is_read = 0"; private static final String SQL_MARK_NOTIFICATIONS_READ = "UPDATE notifications SET is_read = 1 WHERE is_read = 0";
private static final String SQL_MARK_NOTIFICATIONS_SEEN = "UPDATE notifications SET is_seen = 1 WHERE is_seen = 0";
private static final String SQL_MARK_NOTIFICATION_READ_AND_SEEN = "UPDATE notifications SET is_read = 1, is_seen = 1 WHERE id = ?"; private static final String SQL_MARK_NOTIFICATION_READ_AND_SEEN = "UPDATE notifications SET is_read = 1, is_seen = 1 WHERE id = ?";
private static final String SQL_INSERT_SHUFFLE_WATCHED = "REPLACE INTO shuffle_watched (claim_id) VALUES (?)"; private static final String SQL_INSERT_SHUFFLE_WATCHED = "REPLACE INTO shuffle_watched (claim_id) VALUES (?)";
@ -418,22 +417,6 @@ public class DatabaseHelper extends SQLiteOpenHelper {
} }
return count; return count;
} }
public static int getUnseenNotificationsCount(SQLiteDatabase db) {
int count = 0;
Cursor cursor = null;
try {
cursor = db.rawQuery(SQL_GET_UNSEEN_NOTIFICATIONS_COUNT, null);
if (cursor.moveToNext()) {
count = cursor.getInt(0);
}
} finally {
Helper.closeCursor(cursor);
}
return count;
}
public static void markNotificationsSeen(SQLiteDatabase db) {
db.execSQL(SQL_MARK_NOTIFICATIONS_SEEN);
}
public static void markNotificationsRead(SQLiteDatabase db) { public static void markNotificationsRead(SQLiteDatabase db) {
db.execSQL(SQL_MARK_NOTIFICATIONS_READ); db.execSQL(SQL_MARK_NOTIFICATIONS_READ);
} }

View file

@ -67,8 +67,8 @@ public class ContentFromDialogFragment extends BottomSheetDialogFragment {
R.id.content_from_past_year_item, R.id.content_from_past_year_item,
R.id.content_from_all_time_item R.id.content_from_all_time_item
}; };
private final BottomSheetDialogFragment dialog; private BottomSheetDialogFragment dialog;
private final ContentFromListener listener; private ContentFromListener listener;
public ContentFromItemClickListener(BottomSheetDialogFragment dialog, ContentFromListener listener) { public ContentFromItemClickListener(BottomSheetDialogFragment dialog, ContentFromListener listener) {
this.dialog = dialog; this.dialog = dialog;

View file

@ -54,8 +54,8 @@ public class ContentScopeDialogFragment extends BottomSheetDialogFragment {
private final int[] checkViewIds = { private final int[] checkViewIds = {
R.id.content_scope_everyone_item_selected, R.id.content_scope_tags_item_selected R.id.content_scope_everyone_item_selected, R.id.content_scope_tags_item_selected
}; };
private final BottomSheetDialogFragment dialog; private BottomSheetDialogFragment dialog;
private final ContentScopeListener listener; private ContentScopeListener listener;
public ContentScopeItemClickListener(BottomSheetDialogFragment dialog, ContentScopeListener listener) { public ContentScopeItemClickListener(BottomSheetDialogFragment dialog, ContentScopeListener listener) {
this.dialog = dialog; this.dialog = dialog;

View file

@ -57,8 +57,8 @@ public class ContentSortDialogFragment extends BottomSheetDialogFragment {
private final int[] checkViewIds = { private final int[] checkViewIds = {
R.id.sort_by_trending_item_selected, R.id.sort_by_new_item_selected, R.id.sort_by_top_item_selected R.id.sort_by_trending_item_selected, R.id.sort_by_new_item_selected, R.id.sort_by_top_item_selected
}; };
private final BottomSheetDialogFragment dialog; private BottomSheetDialogFragment dialog;
private final SortByListener listener; private SortByListener listener;
public SortByItemClickListener(BottomSheetDialogFragment dialog, SortByListener listener) { public SortByItemClickListener(BottomSheetDialogFragment dialog, SortByListener listener) {
this.dialog = dialog; this.dialog = dialog;

View file

@ -13,6 +13,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.widget.AppCompatSpinner; import androidx.appcompat.widget.AppCompatSpinner;
@ -40,6 +41,7 @@ import io.lbry.browser.tasks.claim.ClaimListTask;
import io.lbry.browser.tasks.wallet.SupportCreateTask; import io.lbry.browser.tasks.wallet.SupportCreateTask;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
import lombok.Setter;
public class CreateSupportDialogFragment extends BottomSheetDialogFragment implements WalletBalanceListener { public class CreateSupportDialogFragment extends BottomSheetDialogFragment implements WalletBalanceListener {
public static final String TAG = "CreateSupportDialog"; public static final String TAG = "CreateSupportDialog";
@ -59,17 +61,13 @@ public class CreateSupportDialogFragment extends BottomSheetDialogFragment imple
private ProgressBar progressLoadingChannels; private ProgressBar progressLoadingChannels;
private final CreateSupportListener listener; @Setter
private final Claim claim; private CreateSupportListener listener;
@Setter
private Claim claim;
private CreateSupportDialogFragment(Claim claim, CreateSupportListener listener) { public static CreateSupportDialogFragment newInstance() {
super(); return new CreateSupportDialogFragment();
this.claim = claim;
this.listener = listener;
}
public static CreateSupportDialogFragment newInstance(Claim claim, CreateSupportListener listener) {
return new CreateSupportDialogFragment(claim, listener);
} }
private void disableControls() { private void disableControls() {

View file

@ -142,7 +142,7 @@ public class CustomizeTagsDialogFragment extends BottomSheetDialogFragment {
return view; return view;
} }
private final TagListAdapter.TagClickListener customizeTagClickListener = new TagListAdapter.TagClickListener() { private TagListAdapter.TagClickListener customizeTagClickListener = new TagListAdapter.TagClickListener() {
@Override @Override
public void onTagClicked(Tag tag, int customizeMode) { public void onTagClicked(Tag tag, int customizeMode) {
if (customizeMode == TagListAdapter.CUSTOMIZE_MODE_ADD) { if (customizeMode == TagListAdapter.CUSTOMIZE_MODE_ADD) {

View file

@ -5,6 +5,7 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ProgressBar;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;

View file

@ -37,6 +37,7 @@ import io.lbry.browser.tasks.claim.StreamRepostTask;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
import io.lbry.browser.utils.LbryUri; import io.lbry.browser.utils.LbryUri;
import lombok.Setter;
public class RepostClaimDialogFragment extends BottomSheetDialogFragment implements WalletBalanceListener { public class RepostClaimDialogFragment extends BottomSheetDialogFragment implements WalletBalanceListener {
public static final String TAG = "RepostClaimDialog"; public static final String TAG = "RepostClaimDialog";
@ -56,17 +57,13 @@ public class RepostClaimDialogFragment extends BottomSheetDialogFragment impleme
private TextView linkToggleAdvanced; private TextView linkToggleAdvanced;
private View advancedContainer; private View advancedContainer;
private final RepostClaimListener listener; @Setter
private final Claim claim; private RepostClaimListener listener;
@Setter
private Claim claim;
private RepostClaimDialogFragment(Claim claim, RepostClaimListener listener) { public static RepostClaimDialogFragment newInstance() {
super(); return new RepostClaimDialogFragment();
this.listener = listener;
this.claim = claim;
}
public static RepostClaimDialogFragment newInstance(Claim claim, RepostClaimListener listener) {
return new RepostClaimDialogFragment(claim, listener);
} }
@Override @Override

View file

@ -1,7 +1,5 @@
package io.lbry.browser.model; package io.lbry.browser.model;
import androidx.annotation.Nullable;
import com.google.gson.FieldNamingPolicy; import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
@ -17,6 +15,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Stream;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.LbryUri; import io.lbry.browser.utils.LbryUri;
@ -139,14 +138,6 @@ public class Claim {
return null; return null;
} }
public boolean hasSource() {
if (value instanceof StreamMetadata) {
StreamMetadata metadata = (StreamMetadata) value;
return metadata.getSource() != null;
}
return false;
}
public boolean isPlayable() { public boolean isPlayable() {
if (value instanceof StreamMetadata) { if (value instanceof StreamMetadata) {
StreamMetadata metadata = (StreamMetadata) value; StreamMetadata metadata = (StreamMetadata) value;
@ -186,21 +177,6 @@ public class Claim {
return null; return null;
} }
/**
* Gets the URL from the CDN where getting the image file
* @param width Pass zero for width and height for the full size image file
* @param height Pass zero for width and height for the full size image file
* @param q Desired quality for the image to be retrieved
* @return URL from the CDN from where image can be retrieved
*/
public String getThumbnailUrl(int width, int height, int q) {
if (value != null && value.getThumbnail() != null) {
ImageCDNUrl imageCDNUrl = new ImageCDNUrl(Math.max(width, 0), Math.max(height, 0), q, null, value.getThumbnail().getUrl());
return imageCDNUrl.toString();
}
return null;
}
public String getCoverUrl() { public String getCoverUrl() {
if (TYPE_CHANNEL.equals(valueType) && value != null && value instanceof ChannelMetadata && ((ChannelMetadata) value).getCover() != null) { if (TYPE_CHANNEL.equals(valueType) && value != null && value instanceof ChannelMetadata && ((ChannelMetadata) value).getCover() != null) {
return ((ChannelMetadata) value).getCover().getUrl(); return ((ChannelMetadata) value).getCover().getUrl();
@ -508,30 +484,6 @@ public class Claim {
private String url; private String url;
} }
/**
* Object to be instantiated. In order to get the URLto the CDN, call toString() on it
*/
static class ImageCDNUrl {
private String appendedPath = "";
public ImageCDNUrl(int width, int height, int quality, @Nullable String format, String thumbnailUrl) {
if (width != 0 && height != 0)
appendedPath = "s:".concat(String.valueOf(width)).concat(":").concat(String.valueOf(height)).concat("/");
appendedPath = appendedPath.concat("quality:").concat(String.valueOf(quality)).concat("/");
appendedPath = appendedPath.concat("plain/").concat(thumbnailUrl);
if (format != null)
appendedPath = appendedPath.concat("@").concat(format);
}
@Override
public String toString() {
String url = "https://image-processor.vanwanet.com/optimize/";
return url.concat(appendedPath);
}
}
@Data @Data
public static class StreamInfo { public static class StreamInfo {
private long duration; // video / audio private long duration; // video / audio

View file

@ -40,7 +40,7 @@ public class ClaimCacheKey {
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (!(obj instanceof ClaimCacheKey)) { if (obj == null || !(obj instanceof ClaimCacheKey)) {
return false; return false;
} }
ClaimCacheKey key = (ClaimCacheKey) obj; ClaimCacheKey key = (ClaimCacheKey) obj;

View file

@ -1,15 +1,19 @@
package io.lbry.browser.model; package io.lbry.browser.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter;
public class ClaimSearchCacheValue { public class ClaimSearchCacheValue {
@Getter @Getter
private final List<Claim> claims; @Setter
private List<Claim> claims;
@Getter @Getter
private final long timestamp; @Setter
private long timestamp;
public ClaimSearchCacheValue(List<Claim> claims, long timestamp) { public ClaimSearchCacheValue(List<Claim> claims, long timestamp) {
this.claims = new ArrayList<>(claims); this.claims = new ArrayList<>(claims);

View file

@ -3,6 +3,7 @@ package io.lbry.browser.model;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -10,7 +11,8 @@ import io.lbry.browser.utils.Helper;
import lombok.Data; import lombok.Data;
@Data @Data
public class Comment implements Comparable<Comment> { public class Comment {
public static final double LBC_COST = 1;
public static final int MAX_LENGTH = 2000; public static final int MAX_LENGTH = 2000;
private Claim poster; private Claim poster;
@ -64,9 +66,4 @@ public class Comment implements Comparable<Comment> {
return null; return null;
} }
} }
@Override
public int compareTo(Comment comment) {
return (int)(this.getTimestamp() - comment.getTimestamp());
}
} }

View file

@ -4,9 +4,9 @@ import lombok.Data;
@Data @Data
public class Language { public class Language {
private final String code; private String code;
private final String name; private String name;
private final int stringResourceId; private int stringResourceId;
public Language(String code, String name, int stringResourceId) { public Language(String code, String name, int stringResourceId) {
this.code = code; this.code = code;

View file

@ -4,9 +4,9 @@ import lombok.Data;
@Data @Data
public class License { public class License {
private final String name; private String name;
private String url; private String url;
private final int stringResourceId; private int stringResourceId;
public License(String name, int stringResourceId) { public License(String name, int stringResourceId) {
this.name = name; this.name = name;

View file

@ -2,6 +2,8 @@ package io.lbry.browser.model;
import android.content.Context; import android.content.Context;
import androidx.core.content.res.ResourcesCompat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -35,8 +37,8 @@ public class NavMenuItem {
public static final int ID_ITEM_SETTINGS = 401; public static final int ID_ITEM_SETTINGS = 401;
public static final int ID_ITEM_ABOUT = 402; public static final int ID_ITEM_ABOUT = 402;
private final Context context; private Context context;
private final int id; private int id;
private boolean group; private boolean group;
private int icon; private int icon;
private String title; private String title;

View file

@ -1,11 +0,0 @@
package io.lbry.browser.model;
public class StartupStage {
public final Integer stage;
public final Boolean stageDone;
public StartupStage(Integer stage, Boolean stageDone) {
this.stage = stage;
this.stageDone = stageDone;
}
}

View file

@ -3,7 +3,9 @@ package io.lbry.browser.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import io.lbry.browser.exceptions.LbryUriException;
import io.lbry.browser.utils.LbryUri; import io.lbry.browser.utils.LbryUri;
import io.lbry.browser.utils.Lbryio;
import lombok.Data; import lombok.Data;
@Data @Data

View file

@ -6,28 +6,14 @@ import java.math.BigDecimal;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import lombok.Data; import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@Data @Data
public class WalletBalance { public class WalletBalance {
@Setter
@Getter
private BigDecimal available; private BigDecimal available;
@Setter
@Getter
private BigDecimal reserved; private BigDecimal reserved;
@Setter
@Getter
private BigDecimal claims; private BigDecimal claims;
@Setter
@Getter
private BigDecimal supports; private BigDecimal supports;
@Setter
@Getter
private BigDecimal tips; private BigDecimal tips;
@Setter
@Getter
private BigDecimal total; private BigDecimal total;
public WalletBalance() { public WalletBalance() {

View file

@ -1,17 +0,0 @@
package io.lbry.browser.model;
public class WalletDetailItem {
public String detail;
public String detailDesc;
public String detailAmount;
public boolean isUnlockable;
public boolean isInProgress;
public WalletDetailItem(String detail, String detailDesc, String detailAmount, boolean isUnlockable, boolean isInProgress) {
this.detail = detail;
this.detailDesc = detailDesc;
this.detailAmount = detailAmount;
this.isUnlockable = isUnlockable;
this.isInProgress = isInProgress;
}
}

View file

@ -1,15 +1,11 @@
package io.lbry.browser.model; package io.lbry.browser.model;
import lombok.Data; import lombok.Data;
import lombok.Getter;
@Data @Data
public class WalletSync { public class WalletSync {
@Getter private String hash;
private final String hash; private String data;
@Getter
private final String data;
@Getter
private boolean changed; private boolean changed;
public WalletSync(String hash, String data) { public WalletSync(String hash, String data) {
@ -21,5 +17,4 @@ public class WalletSync {
this(hash, data); this(hash, data);
this.changed = changed; this.changed = changed;
} }
} }

View file

@ -9,6 +9,7 @@ import org.json.JSONObject;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import io.lbry.browser.model.Claim;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import lombok.Data; import lombok.Data;

View file

@ -12,17 +12,16 @@ import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
import okhttp3.ResponseBody;
public class BufferEventTask extends AsyncTask<Void, Void, Void> { public class BufferEventTask extends AsyncTask<Void, Void, Void> {
private static final String TAG = "LbryBufferEvent"; private static final String TAG = "LbryBufferEvent";
private static final String ENDPOINT = "https://collector-service.api.lbry.tv/api/v1/events/video"; private static final String ENDPOINT = "https://collector-service.api.lbry.tv/api/v1/events/video";
private final String streamUrl; private String streamUrl;
private final String userIdHash; private String userIdHash;
private final long streamDuration; private long streamDuration;
private final long streamPosition; private long streamPosition;
private final long bufferDuration; private long bufferDuration;
public BufferEventTask(String streamUrl, long streamDuration, long streamPosition, long bufferDuration, String userIdHash) { public BufferEventTask(String streamUrl, long streamDuration, long streamPosition, long bufferDuration, String userIdHash) {
this.streamUrl = streamUrl; this.streamUrl = streamUrl;
@ -54,11 +53,7 @@ public class BufferEventTask extends AsyncTask<Void, Void, Void> {
build(); build();
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
ResponseBody resBody = response.body(); String responseString = response.body().string();
String responseString = "";
if (resBody != null) {
responseString = response.body().string();
}
Log.d(TAG, String.format("buffer event sent: %s", responseString)); Log.d(TAG, String.format("buffer event sent: %s", responseString));
} catch (Exception ex) { } catch (Exception ex) {
// we don't want to fail if a buffer event fails to register // we don't want to fail if a buffer event fails to register

View file

@ -1,85 +0,0 @@
package io.lbry.browser.tasks;
import android.os.AsyncTask;
import android.view.View;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.Objects;
import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.model.Comment;
import io.lbry.browser.utils.Comments;
import io.lbry.browser.utils.Helper;
import okhttp3.Response;
public class CommentCreateTask extends AsyncTask<Void, Void, Comment> {
private final Comment comment;
private final View progressView;
private final CommentCreateWithTipHandler handler;
private Exception error;
public CommentCreateTask(Comment comment, View progressView, CommentCreateWithTipHandler handler) {
this.comment = comment;
this.progressView = progressView;
this.handler = handler;
}
protected void onPreExecute() {
Helper.setViewVisibility(progressView, View.VISIBLE);
}
public Comment doInBackground(Void... params) {
Comment createdComment = null;
try {
// check comments status endpoint
Comments.checkCommentsEndpointStatus();
JSONObject comment_body = new JSONObject();
comment_body.put("comment", comment.getText());
comment_body.put("claim_id", comment.getClaimId());
if (!Helper.isNullOrEmpty(comment.getParentId())) {
comment_body.put("parent_id", comment.getParentId());
}
comment_body.put("channel_id", comment.getChannelId());
comment_body.put("channel_name", comment.getChannelName());
JSONObject jsonChannelSign = Comments.channelSign(comment_body, comment.getChannelId(), comment.getChannelName());
if (jsonChannelSign.has("signature") && jsonChannelSign.has("signing_ts")) {
comment_body.put("signature", jsonChannelSign.getString("signature"));
comment_body.put("signing_ts", jsonChannelSign.getString("signing_ts"));
}
Response resp = Comments.performRequest(comment_body, "comment.Create");
String responseString = Objects.requireNonNull(resp.body()).string();
resp.close();
JSONObject jsonResponse = new JSONObject(responseString);
if (jsonResponse.has("result"))
createdComment = Comment.fromJSONObject(jsonResponse.getJSONObject("result"));
} catch (ApiCallException | ClassCastException | IOException | JSONException ex) {
error = ex;
}
return createdComment;
}
protected void onPostExecute(Comment createdComment) {
Helper.setViewVisibility(progressView, View.GONE);
if (handler != null) {
if (createdComment != null) {
handler.onSuccess(createdComment);
} else {
handler.onError(error);
}
}
}
public interface CommentCreateWithTipHandler {
void onSuccess(Comment createdComment);
void onError(Exception error);
}
}

View file

@ -0,0 +1,103 @@
package io.lbry.browser.tasks;
import android.os.AsyncTask;
import android.view.View;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.model.Comment;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry;
import io.lbry.browser.utils.Lbryio;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class CommentCreateWithTipTask extends AsyncTask<Void, Void, Comment> {
private static final String STATUS_ENDPOINT = "https://comments.lbry.com";
private Comment comment;
private BigDecimal amount;
private View progressView;
private CommentCreateWithTipHandler handler;
private Exception error;
public CommentCreateWithTipTask(Comment comment, BigDecimal amount, View progressView, CommentCreateWithTipHandler handler) {
this.comment = comment;
this.amount = amount;
this.progressView = progressView;
this.handler = handler;
}
protected void onPreExecute() {
Helper.setViewVisibility(progressView, View.VISIBLE);
}
public Comment doInBackground(Void... params) {
Comment createdComment = null;
try {
// check comments status endpoint
Request request = new Request.Builder().url(STATUS_ENDPOINT).build();
OkHttpClient client = new OkHttpClient.Builder().
writeTimeout(30, TimeUnit.SECONDS).
readTimeout(30, TimeUnit.SECONDS).
build();
Response response = client.newCall(request).execute();
JSONObject status = new JSONObject(response.body().string());
String statusText = Helper.getJSONString("text", null, status);
boolean isRunning = Helper.getJSONBoolean("is_running", false, status);
if (!"ok".equalsIgnoreCase(statusText) || !isRunning) {
throw new ApiCallException("The comment server is not available at this time. Please try again later.");
}
Map<String, Object> options = new HashMap<>();
options.put("blocking", true);
options.put("claim_id", comment.getClaimId());
options.put("amount", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).format(amount.doubleValue()));
options.put("tip", true);
Lbry.genericApiCall(Lbry.METHOD_SUPPORT_CREATE, options);
options = new HashMap<>();
options.put("comment", comment.getText());
options.put("claim_id", comment.getClaimId());
options.put("channel_id", comment.getChannelId());
options.put("channel_name", comment.getChannelName());
if (!Helper.isNullOrEmpty(comment.getParentId())) {
options.put("parent_id", comment.getParentId());
}
JSONObject jsonObject = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_COMMENT_CREATE, options);
createdComment = Comment.fromJSONObject(jsonObject);
} catch (ApiCallException | ClassCastException | IOException | JSONException ex) {
error = ex;
}
return createdComment;
}
protected void onPostExecute(Comment createdComment) {
Helper.setViewVisibility(progressView, View.GONE);
if (handler != null) {
if (createdComment != null) {
handler.onSuccess(createdComment);
} else {
handler.onError(error);
}
}
}
public interface CommentCreateWithTipHandler {
void onSuccess(Comment createdComment);
void onError(Exception error);
}
}

View file

@ -8,13 +8,11 @@ import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
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 io.lbry.browser.model.Comment; import io.lbry.browser.model.Comment;
import io.lbry.browser.utils.Comments;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
@ -22,8 +20,8 @@ public class CommentListTask extends AsyncTask<Void, Void, List<Comment>> {
private final int page; private final int page;
private final int pageSize; private final int pageSize;
private final String claim; private final String claim;
private final ProgressBar progressBar; private ProgressBar progressBar;
private final CommentListHandler handler; private CommentListHandler handler;
private Exception error; private Exception error;
public CommentListTask(int page, int pageSize, String claim, ProgressBar progressBar, CommentListHandler handler) { public CommentListTask(int page, int pageSize, String claim, ProgressBar progressBar, CommentListHandler handler) {
@ -53,7 +51,7 @@ public class CommentListTask extends AsyncTask<Void, Void, List<Comment>> {
options.put("skip_validation", true); options.put("skip_validation", true);
options.put("visible", true); options.put("visible", true);
JSONObject result = (JSONObject) Lbry.parseResponse(Comments.performRequest(Lbry.buildJsonParams(options), "comment.List")); JSONObject result = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_COMMENT_LIST, options);
JSONArray items = result.getJSONArray("items"); JSONArray items = result.getJSONArray("items");
List<Comment> children = new ArrayList<>(); List<Comment> children = new ArrayList<>();
@ -69,9 +67,6 @@ public class CommentListTask extends AsyncTask<Void, Void, List<Comment>> {
} }
} }
// Sort all replies from oldest to newest at once
Collections.sort(children);
for (Comment child : children) { for (Comment child : children) {
for (Comment parent : comments) { for (Comment parent : comments) {
if (parent.getId().equalsIgnoreCase(child.getParentId())) { if (parent.getId().equalsIgnoreCase(child.getParentId())) {

View file

@ -10,10 +10,10 @@ import io.lbry.browser.model.Tag;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class FollowUnfollowTagTask extends AsyncTask<Void, Void, Boolean> { public class FollowUnfollowTagTask extends AsyncTask<Void, Void, Boolean> {
private final Tag tag; private Tag tag;
private final boolean unfollowing; private boolean unfollowing;
private final Context context; private Context context;
private final FollowUnfollowTagHandler handler; private FollowUnfollowTagHandler handler;
private Exception error; private Exception error;
public FollowUnfollowTagTask(Tag tag, boolean unfollowing, Context context, FollowUnfollowTagHandler handler) { public FollowUnfollowTagTask(Tag tag, boolean unfollowing, Context context, FollowUnfollowTagHandler handler) {

View file

@ -12,9 +12,9 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lighthouse; import io.lbry.browser.utils.Lighthouse;
public class LighthouseAutoCompleteTask extends AsyncTask<Void, Void, List<UrlSuggestion>> { public class LighthouseAutoCompleteTask extends AsyncTask<Void, Void, List<UrlSuggestion>> {
private final String text; private String text;
private final AutoCompleteResultHandler handler; private AutoCompleteResultHandler handler;
private final View progressView; private View progressView;
private Exception error; private Exception error;
public LighthouseAutoCompleteTask(String text, View progressView, AutoCompleteResultHandler handler) { public LighthouseAutoCompleteTask(String text, View progressView, AutoCompleteResultHandler handler) {

View file

@ -14,13 +14,13 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lighthouse; import io.lbry.browser.utils.Lighthouse;
public class LighthouseSearchTask extends AsyncTask<Void, Void, List<Claim>> { public class LighthouseSearchTask extends AsyncTask<Void, Void, List<Claim>> {
private final String rawQuery; private String rawQuery;
private final int size; private int size;
private final int from; private int from;
private final boolean nsfw; private boolean nsfw;
private final String relatedTo; private String relatedTo;
private final ClaimSearchResultHandler handler; private ClaimSearchResultHandler handler;
private final ProgressBar progressBar; private ProgressBar progressBar;
private Exception error; private Exception error;
public LighthouseSearchTask(String rawQuery, int size, int from, boolean nsfw, String relatedTo, ProgressBar progressBar, ClaimSearchResultHandler handler) { public LighthouseSearchTask(String rawQuery, int size, int from, boolean nsfw, String relatedTo, ProgressBar progressBar, ClaimSearchResultHandler handler) {

View file

@ -4,16 +4,22 @@ import android.content.Context;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteException;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.view.View;
import android.widget.ProgressBar;
import java.util.List; import java.util.List;
import io.lbry.browser.MainActivity; import io.lbry.browser.MainActivity;
import io.lbry.browser.data.DatabaseHelper; import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.exceptions.LbryRequestException;
import io.lbry.browser.exceptions.LbryResponseException;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.Tag; import io.lbry.browser.model.Tag;
import io.lbry.browser.utils.Helper;
public class LoadTagsTask extends AsyncTask<Void, Void, List<Tag>> { public class LoadTagsTask extends AsyncTask<Void, Void, List<Tag>> {
private final Context context; private Context context;
private final LoadTagsHandler handler; private LoadTagsHandler handler;
private Exception error; private Exception error;
public LoadTagsTask(Context context, LoadTagsHandler handler) { public LoadTagsTask(Context context, LoadTagsHandler handler) {

View file

@ -4,6 +4,7 @@ import android.content.Context;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteException;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@ -16,21 +17,24 @@ import java.util.Map;
import io.lbry.browser.MainActivity; import io.lbry.browser.MainActivity;
import io.lbry.browser.data.DatabaseHelper; import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.exceptions.LbryUriException;
import io.lbry.browser.exceptions.LbryioRequestException; import io.lbry.browser.exceptions.LbryioRequestException;
import io.lbry.browser.exceptions.LbryioResponseException; import io.lbry.browser.exceptions.LbryioResponseException;
import io.lbry.browser.model.lbryinc.Subscription; import io.lbry.browser.model.lbryinc.Subscription;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.LbryUri; import io.lbry.browser.utils.LbryUri;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
import okhttp3.Response;
// background task to create a diff of local and remote subscriptions and try to merge // background task to create a diff of local and remote subscriptions and try to merge
public class MergeSubscriptionsTask extends AsyncTask<Void, Void, List<Subscription>> { public class MergeSubscriptionsTask extends AsyncTask<Void, Void, List<Subscription>> {
private static final String TAG = "MergeSubscriptionsTask"; private static final String TAG = "MergeSubscriptionsTask";
private final Context context; private Context context;
private final List<Subscription> base; private List<Subscription> base;
private List<Subscription> diff; private List<Subscription> diff;
private final MergeSubscriptionsHandler handler; private MergeSubscriptionsHandler handler;
private Exception error; private Exception error;
private final boolean replaceLocal; private boolean replaceLocal;
public MergeSubscriptionsTask(List<Subscription> base, boolean replaceLocal, Context context, MergeSubscriptionsHandler handler) { public MergeSubscriptionsTask(List<Subscription> base, boolean replaceLocal, Context context, MergeSubscriptionsHandler handler) {
this.base = base; this.base = base;

View file

@ -4,15 +4,18 @@ import android.os.AsyncTask;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.Buffer;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
public class ReadTextFileTask extends AsyncTask<Void, Void, String> { public class ReadTextFileTask extends AsyncTask<Void, Void, String> {
private final String filePath; private String filePath;
private Exception error; private Exception error;
private final ReadTextFileHandler handler; private ReadTextFileHandler handler;
public ReadTextFileTask(String filePath, ReadTextFileHandler handler) { public ReadTextFileTask(String filePath, ReadTextFileHandler handler) {
this.filePath = filePath; this.filePath = filePath;
this.handler = handler; this.handler = handler;

View file

@ -9,9 +9,9 @@ import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class SetSdkSettingTask extends AsyncTask<Void, Void, Boolean> { public class SetSdkSettingTask extends AsyncTask<Void, Void, Boolean> {
private final String key; private String key;
private final String value; private String value;
private final GenericTaskHandler handler; private GenericTaskHandler handler;
private Exception error; private Exception error;
public SetSdkSettingTask(String key, String value, GenericTaskHandler handler) { public SetSdkSettingTask(String key, String value, GenericTaskHandler handler) {
this.key = key; this.key = key;

View file

@ -13,13 +13,13 @@ import io.lbry.browser.utils.Lbry;
public class UpdateSuggestedTagsTask extends AsyncTask<Void, Void, List<Tag>> { public class UpdateSuggestedTagsTask extends AsyncTask<Void, Void, List<Tag>> {
private final boolean clearPrevious; private boolean clearPrevious;
private final boolean excludeMature; private boolean excludeMature;
private final int limit; private int limit;
private final String filter; private String filter;
private final TagListAdapter addedTagsAdapter; private TagListAdapter addedTagsAdapter;
private final TagListAdapter suggestedTagsAdapter; private TagListAdapter suggestedTagsAdapter;
private final KnownTagsHandler handler; private KnownTagsHandler handler;
public UpdateSuggestedTagsTask( public UpdateSuggestedTagsTask(
String filter, String filter,

View file

@ -21,9 +21,9 @@ import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
public class UploadImageTask extends AsyncTask<Void, Void, String> { public class UploadImageTask extends AsyncTask<Void, Void, String> {
private final String filePath; private String filePath;
private final View progressView; private View progressView;
private final UploadThumbnailHandler handler; private UploadThumbnailHandler handler;
private Exception error; private Exception error;
public UploadImageTask(String filePath, View progressView, UploadThumbnailHandler handler) { public UploadImageTask(String filePath, View progressView, UploadThumbnailHandler handler) {

View file

@ -11,16 +11,17 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException; import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class AbandonChannelTask extends AsyncTask<Void, Void, Boolean> { public class AbandonChannelTask extends AsyncTask<Void, Void, Boolean> {
private final List<String> claimIds; private List<String> claimIds;
private List<String> successfulClaimIds; private List<String> successfulClaimIds;
private List<String> failedClaimIds; private List<String> failedClaimIds;
private List<Exception> failedExceptions; private List<Exception> failedExceptions;
private final View progressView; private View progressView;
private final AbandonHandler handler; private AbandonHandler handler;
public AbandonChannelTask(List<String> claimIds, View progressView, AbandonHandler handler) { public AbandonChannelTask(List<String> claimIds, View progressView, AbandonHandler handler) {
this.claimIds = claimIds; this.claimIds = claimIds;

View file

@ -11,16 +11,17 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException; import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class AbandonStreamTask extends AsyncTask<Void, Void, Boolean> { public class AbandonStreamTask extends AsyncTask<Void, Void, Boolean> {
private final List<String> claimIds; private List<String> claimIds;
private List<String> successfulClaimIds; private List<String> successfulClaimIds;
private List<String> failedClaimIds; private List<String> failedClaimIds;
private List<Exception> failedExceptions; private List<Exception> failedExceptions;
private final View progressView; private View progressView;
private final AbandonHandler handler; private AbandonHandler handler;
public AbandonStreamTask(List<String> claimIds, View progressView, AbandonHandler handler) { public AbandonStreamTask(List<String> claimIds, View progressView, AbandonHandler handler) {
this.claimIds = claimIds; this.claimIds = claimIds;

View file

@ -21,12 +21,12 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class ChannelCreateUpdateTask extends AsyncTask<Void, Void, Claim> { public class ChannelCreateUpdateTask extends AsyncTask<Void, Void, Claim> {
private final Claim claim; private Claim claim;
private final BigDecimal deposit; private BigDecimal deposit;
private final boolean update; private boolean update;
private Exception error; private Exception error;
private final ClaimResultHandler handler; private ClaimResultHandler handler;
private final View progressView; private View progressView;
public ChannelCreateUpdateTask(Claim claim, BigDecimal deposit, boolean update, View progressView, ClaimResultHandler handler) { public ChannelCreateUpdateTask(Claim claim, BigDecimal deposit, boolean update, View progressView, ClaimResultHandler handler) {
this.claim = claim; this.claim = claim;

View file

@ -19,9 +19,9 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class ClaimListTask extends AsyncTask<Void, Void, List<Claim>> { public class ClaimListTask extends AsyncTask<Void, Void, List<Claim>> {
private final List<String> types; private List<String> types;
private final View progressView; private View progressView;
private final ClaimListResultHandler handler; private ClaimListResultHandler handler;
private Exception error; private Exception error;
public ClaimListTask(String type, View progressView, ClaimListResultHandler handler) { public ClaimListTask(String type, View progressView, ClaimListResultHandler handler) {

View file

@ -12,10 +12,10 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class ClaimSearchTask extends AsyncTask<Void, Void, List<Claim>> { public class ClaimSearchTask extends AsyncTask<Void, Void, List<Claim>> {
private final Map<String, Object> options; private Map<String, Object> options;
private final String connectionString; private String connectionString;
private final ClaimSearchResultHandler handler; private ClaimSearchResultHandler handler;
private final View progressView; private View progressView;
private ApiCallException error; private ApiCallException error;
public ClaimSearchTask(Map<String, Object> options, String connectionString, View progressView, ClaimSearchResultHandler handler) { public ClaimSearchTask(Map<String, Object> options, String connectionString, View progressView, ClaimSearchResultHandler handler) {

View file

@ -21,10 +21,10 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class PublishClaimTask extends AsyncTask<Void, Void, Claim> { public class PublishClaimTask extends AsyncTask<Void, Void, Claim> {
private final Claim claim; private Claim claim;
private final String filePath; private String filePath;
private final View progressView; private View progressView;
private final ClaimResultHandler handler; private ClaimResultHandler handler;
private Exception error; private Exception error;
public PublishClaimTask(Claim claim, String filePath, View progressView, ClaimResultHandler handler) { public PublishClaimTask(Claim claim, String filePath, View progressView, ClaimResultHandler handler) {
this.claim = claim; this.claim = claim;

View file

@ -21,8 +21,8 @@ public class PurchaseListTask extends AsyncTask<Void, Void, List<Claim>> {
private String claimId; private String claimId;
private int page; private int page;
private int pageSize; private int pageSize;
private final ClaimSearchResultHandler handler; private ClaimSearchResultHandler handler;
private final View progressView; private View progressView;
private Exception error; private Exception error;
public PurchaseListTask(String claimId, View progressView, ClaimSearchResultHandler handler) { public PurchaseListTask(String claimId, View progressView, ClaimSearchResultHandler handler) {

View file

@ -13,10 +13,10 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class ResolveTask extends AsyncTask<Void, Void, List<Claim>> { public class ResolveTask extends AsyncTask<Void, Void, List<Claim>> {
private final List<String> urls; private List<String> urls;
private final String connectionString; private String connectionString;
private final ClaimListResultHandler handler; private ClaimListResultHandler handler;
private final View progressView; private View progressView;
private ApiCallException error; private ApiCallException error;
public ResolveTask(String url, String connectionString, View progressView, ClaimListResultHandler handler) { public ResolveTask(String url, String connectionString, View progressView, ClaimListResultHandler handler) {

View file

@ -20,12 +20,12 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class StreamRepostTask extends AsyncTask<Void, Void, Claim> { public class StreamRepostTask extends AsyncTask<Void, Void, Claim> {
private final String name; private String name;
private final BigDecimal bid; private BigDecimal bid;
private final String claimId; private String claimId;
private final String channelId; private String channelId;
private final View progressView; private View progressView;
private final ClaimResultHandler handler; private ClaimResultHandler handler;
private Exception error; private Exception error;
public StreamRepostTask(String name, BigDecimal bid, String claimId, String channelId, View progressView, ClaimResultHandler handler) { public StreamRepostTask(String name, BigDecimal bid, String claimId, String channelId, View progressView, ClaimResultHandler handler) {

View file

@ -7,11 +7,12 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException; import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
// Just run delete on the specified claim IDs (no need for a handler) // Just run delete on the specified claim IDs (no need for a handler)
public class BulkDeleteFilesTask extends AsyncTask<Void, Void, Boolean> { public class BulkDeleteFilesTask extends AsyncTask<Void, Void, Boolean> {
private final List<String> claimIds; private List<String> claimIds;
public BulkDeleteFilesTask(List<String> claimIds) { public BulkDeleteFilesTask(List<String> claimIds) {
this.claimIds = claimIds; this.claimIds = claimIds;
} }

View file

@ -10,9 +10,9 @@ import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class DeleteFileTask extends AsyncTask<Void, Void, Boolean> { public class DeleteFileTask extends AsyncTask<Void, Void, Boolean> {
private final String claimId; private String claimId;
private Exception error; private Exception error;
private final GenericTaskHandler handler; private GenericTaskHandler handler;
public DeleteFileTask(String claimId, GenericTaskHandler handler) { public DeleteFileTask(String claimId, GenericTaskHandler handler) {
this.claimId = claimId; this.claimId = claimId;

View file

@ -11,12 +11,12 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class FileListTask extends AsyncTask<Void, Void, List<LbryFile>> { public class FileListTask extends AsyncTask<Void, Void, List<LbryFile>> {
private final String claimId; private String claimId;
private boolean downloads; private boolean downloads;
private int page; private int page;
private int pageSize; private int pageSize;
private final FileListResultHandler handler; private FileListResultHandler handler;
private final View progressView; private View progressView;
private ApiCallException error; private ApiCallException error;
public FileListTask(int page, int pageSize, boolean downloads, View progressView, FileListResultHandler handler) { public FileListTask(int page, int pageSize, boolean downloads, View progressView, FileListResultHandler handler) {

View file

@ -14,10 +14,10 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class GetFileTask extends AsyncTask<Void, Void, LbryFile> { public class GetFileTask extends AsyncTask<Void, Void, LbryFile> {
private final String uri; private String uri;
private final boolean saveFile; private boolean saveFile;
private final View progressView; private View progressView;
private final GetFileHandler handler; private GetFileHandler handler;
private Exception error; private Exception error;
public GetFileTask(String uri, boolean saveFile, View progressView, GetFileHandler handler) { public GetFileTask(String uri, boolean saveFile, View progressView, GetFileHandler handler) {

View file

@ -15,16 +15,18 @@ import java.lang.reflect.Type;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import io.lbry.browser.MainActivity;
import io.lbry.browser.model.lbryinc.RewardVerified; import io.lbry.browser.model.lbryinc.RewardVerified;
import io.lbry.browser.tasks.RewardVerifiedHandler; import io.lbry.browser.tasks.RewardVerifiedHandler;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
import okhttp3.Response;
public class AndroidPurchaseTask extends AsyncTask<Void, Void, RewardVerified> { public class AndroidPurchaseTask extends AsyncTask<Void, Void, RewardVerified> {
private final Context context; private Context context;
private final View progressView; private View progressView;
private final String purchaseToken; private String purchaseToken;
private final RewardVerifiedHandler handler; private RewardVerifiedHandler handler;
private Exception error; private Exception error;
public AndroidPurchaseTask(String purchaseToken, View progressView, Context context, RewardVerifiedHandler handler) { public AndroidPurchaseTask(String purchaseToken, View progressView, Context context, RewardVerifiedHandler handler) {

View file

@ -13,15 +13,16 @@ import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.exceptions.LbryioRequestException; import io.lbry.browser.exceptions.LbryioRequestException;
import io.lbry.browser.exceptions.LbryioResponseException; import io.lbry.browser.exceptions.LbryioResponseException;
import io.lbry.browser.model.lbryinc.Subscription; import io.lbry.browser.model.lbryinc.Subscription;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class ChannelSubscribeTask extends AsyncTask<Void, Void, Boolean> { public class ChannelSubscribeTask extends AsyncTask<Void, Void, Boolean> {
private final Context context; private Context context;
private final String channelClaimId; private String channelClaimId;
private final Subscription subscription; private Subscription subscription;
private final ChannelSubscribeHandler handler; private ChannelSubscribeHandler handler;
private Exception error; private Exception error;
private final boolean isUnsubscribing; private boolean isUnsubscribing;
public ChannelSubscribeTask(Context context, String channelClaimId, Subscription subscription, boolean isUnsubscribing, ChannelSubscribeHandler handler) { public ChannelSubscribeTask(Context context, String channelClaimId, Subscription subscription, boolean isUnsubscribing, ChannelSubscribeHandler handler) {
this.context = context; this.context = context;

View file

@ -9,6 +9,7 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -24,12 +25,12 @@ import io.lbry.browser.utils.Lbryio;
public class ClaimRewardTask extends AsyncTask<Void, Void, String> { public class ClaimRewardTask extends AsyncTask<Void, Void, String> {
private final Context context; private Context context;
private final String type; private String type;
private final String rewardCode; private String rewardCode;
private final View progressView; private View progressView;
private double amountClaimed; private double amountClaimed;
private final ClaimRewardHandler handler; private ClaimRewardHandler handler;
private Exception error; private Exception error;
public ClaimRewardTask(String type, String rewardCode, View progressView, Context context, ClaimRewardHandler handler) { public ClaimRewardTask(String type, String rewardCode, View progressView, Context context, ClaimRewardHandler handler) {

View file

@ -7,9 +7,9 @@ import io.lbry.browser.model.lbryinc.User;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class FetchCurrentUserTask extends AsyncTask<Void, Void, User> { public class FetchCurrentUserTask extends AsyncTask<Void, Void, User> {
private final Context context; private Context context;
private Exception error; private Exception error;
private final FetchUserTaskHandler handler; private FetchUserTaskHandler handler;
public FetchCurrentUserTask(Context context, FetchUserTaskHandler handler) { public FetchCurrentUserTask(Context context, FetchUserTaskHandler handler) {
this.context = context; this.context = context;

View file

@ -17,8 +17,8 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class FetchInviteStatusTask extends AsyncTask<Void, Void, List<Invitee>> { public class FetchInviteStatusTask extends AsyncTask<Void, Void, List<Invitee>> {
private final FetchInviteStatusHandler handler; private FetchInviteStatusHandler handler;
private final View progressView; private View progressView;
private Exception error; private Exception error;
public FetchInviteStatusTask(View progressView, FetchInviteStatusHandler handler) { public FetchInviteStatusTask(View progressView, FetchInviteStatusHandler handler) {

View file

@ -12,8 +12,8 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class FetchReferralCodeTask extends AsyncTask<Void, Void, String> { public class FetchReferralCodeTask extends AsyncTask<Void, Void, String> {
private final FetchReferralCodeHandler handler; private FetchReferralCodeHandler handler;
private final View progressView; private View progressView;
private Exception error; private Exception error;
public FetchReferralCodeTask(View progressView, FetchReferralCodeHandler handler) { public FetchReferralCodeTask(View progressView, FetchReferralCodeHandler handler) {

View file

@ -18,8 +18,8 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class FetchRewardsTask extends AsyncTask<Void, Void, List<Reward>> { public class FetchRewardsTask extends AsyncTask<Void, Void, List<Reward>> {
private final FetchRewardsHandler handler; private FetchRewardsHandler handler;
private final View progressView; private View progressView;
private Exception error; private Exception error;
public FetchRewardsTask(View progressView, FetchRewardsHandler handler) { public FetchRewardsTask(View progressView, FetchRewardsHandler handler) {

View file

@ -15,10 +15,10 @@ public class FetchStatCountTask extends AsyncTask<Void, Void, Integer> {
public static final int STAT_VIEW_COUNT = 1; public static final int STAT_VIEW_COUNT = 1;
public static final int STAT_SUB_COUNT = 2; public static final int STAT_SUB_COUNT = 2;
private final String claimId; private String claimId;
private final int stat; private int stat;
private final FetchStatCountHandler handler; private FetchStatCountHandler handler;
private final View progressView; private View progressView;
private Exception error; private Exception error;
public FetchStatCountTask(int stat, String claimId, View progressView, FetchStatCountHandler handler) { public FetchStatCountTask(int stat, String claimId, View progressView, FetchStatCountHandler handler) {

View file

@ -23,9 +23,9 @@ import io.lbry.browser.utils.LbryUri;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class FetchSubscriptionsTask extends AsyncTask<Void, Void, List<Subscription>> { public class FetchSubscriptionsTask extends AsyncTask<Void, Void, List<Subscription>> {
private final Context context; private Context context;
private final FetchSubscriptionsHandler handler; private FetchSubscriptionsHandler handler;
private final ProgressBar progressBar; private ProgressBar progressBar;
private Exception error; private Exception error;
public FetchSubscriptionsTask(Context context, ProgressBar progressBar, FetchSubscriptionsHandler handler) { public FetchSubscriptionsTask(Context context, ProgressBar progressBar, FetchSubscriptionsHandler handler) {

View file

@ -14,9 +14,9 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class InviteByEmailTask extends AsyncTask<Void, Void, Boolean> { public class InviteByEmailTask extends AsyncTask<Void, Void, Boolean> {
private final String email; private String email;
private final View progressView; private View progressView;
private final GenericTaskHandler handler; private GenericTaskHandler handler;
private Exception error; private Exception error;
public InviteByEmailTask(String email, View progressView, GenericTaskHandler handler) { public InviteByEmailTask(String email, View progressView, GenericTaskHandler handler) {

View file

@ -2,21 +2,24 @@ package io.lbry.browser.tasks.lbryinc;
import android.os.AsyncTask; import android.os.AsyncTask;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Executor;
import io.lbry.browser.exceptions.LbryioRequestException; import io.lbry.browser.exceptions.LbryioRequestException;
import io.lbry.browser.exceptions.LbryioResponseException; import io.lbry.browser.exceptions.LbryioResponseException;
import io.lbry.browser.model.Claim; import io.lbry.browser.model.Claim;
import io.lbry.browser.tasks.GenericTaskHandler; import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
import okhttp3.Response;
public class LogFileViewTask extends AsyncTask<Void, Void, Boolean> { public class LogFileViewTask extends AsyncTask<Void, Void, Boolean> {
private final String uri; private String uri;
private final Claim claim; private Claim claim;
private Exception error; private Exception error;
private final GenericTaskHandler handler; private GenericTaskHandler handler;
private final long timeToStart; private long timeToStart;
public LogFileViewTask(String uri, Claim claim, long timeToStart, GenericTaskHandler handler) { public LogFileViewTask(String uri, Claim claim, long timeToStart, GenericTaskHandler handler) {
this.uri = uri; this.uri = uri;

View file

@ -2,6 +2,7 @@ package io.lbry.browser.tasks.lbryinc;
import android.os.AsyncTask; import android.os.AsyncTask;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -9,9 +10,10 @@ import io.lbry.browser.exceptions.LbryioRequestException;
import io.lbry.browser.exceptions.LbryioResponseException; import io.lbry.browser.exceptions.LbryioResponseException;
import io.lbry.browser.model.Claim; import io.lbry.browser.model.Claim;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
import okhttp3.Response;
public class LogPublishTask extends AsyncTask<Void, Void, Void> { public class LogPublishTask extends AsyncTask<Void, Void, Void> {
private final Claim claimResult; private Claim claimResult;
public LogPublishTask(Claim claimResult) { public LogPublishTask(Claim claimResult) {
this.claimResult = claimResult; this.claimResult = claimResult;
} }

View file

@ -12,7 +12,7 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class NotificationDeleteTask extends AsyncTask<Void, Void, Boolean> { public class NotificationDeleteTask extends AsyncTask<Void, Void, Boolean> {
private final List<Long> ids; private List<Long> ids;
public NotificationDeleteTask(List<Long> ids) { public NotificationDeleteTask(List<Long> ids) {
this.ids = ids; this.ids = ids;

View file

@ -16,10 +16,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import io.lbry.browser.MainActivity; import io.lbry.browser.MainActivity;
import io.lbry.browser.data.DatabaseHelper; import io.lbry.browser.data.DatabaseHelper;
@ -32,9 +30,9 @@ import io.lbry.browser.utils.Lbryio;
public class NotificationListTask extends AsyncTask<Void, Void, List<LbryNotification>> { public class NotificationListTask extends AsyncTask<Void, Void, List<LbryNotification>> {
private static final String TAG = "Notifications"; private static final String TAG = "Notifications";
private final Context context; private Context context;
private final ListNotificationsHandler handler; private ListNotificationsHandler handler;
private final ProgressBar progressBar; private ProgressBar progressBar;
private Exception error; private Exception error;
public NotificationListTask(Context context, ProgressBar progressBar, ListNotificationsHandler handler) { public NotificationListTask(Context context, ProgressBar progressBar, ListNotificationsHandler handler) {
@ -49,9 +47,7 @@ public class NotificationListTask extends AsyncTask<Void, Void, List<LbryNotific
List<LbryNotification> notifications = new ArrayList<>(); List<LbryNotification> notifications = new ArrayList<>();
SQLiteDatabase db = null; SQLiteDatabase db = null;
try { try {
Map<String, String> parameters = new HashMap<>(1); JSONArray array = (JSONArray) Lbryio.parseResponse(Lbryio.call("notification", "list", context));
parameters.put("is_app_readable", "true");
JSONArray array = (JSONArray) Lbryio.parseResponse(Lbryio.call("notification", "list", parameters, context));
if (array != null) { if (array != null) {
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);

View file

@ -12,28 +12,28 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class NotificationUpdateTask extends AsyncTask<Void, Void, Boolean> { public class NotificationUpdateTask extends AsyncTask<Void, Void, Boolean> {
private final List<Long> ids; private List<Long> ids;
private final boolean seen; private boolean seen;
private final boolean read; private boolean read;
private final boolean updateRead; private boolean updateSeen;
public NotificationUpdateTask(List<Long> ids, boolean seen) { public NotificationUpdateTask(List<Long> ids, boolean read) {
this(ids, false, true, false); this(ids, read, false, false);
} }
public NotificationUpdateTask(List<Long> ids, boolean read, boolean seen, boolean updateRead) { public NotificationUpdateTask(List<Long> ids, boolean read, boolean seen, boolean updateSeen) {
this.ids = ids; this.ids = ids;
this.read = read; this.read = read;
this.seen = seen; this.seen = seen;
this.updateRead = updateRead; this.updateSeen = updateSeen;
} }
protected Boolean doInBackground(Void... params) { protected Boolean doInBackground(Void... params) {
Map<String, String> options = new HashMap<>(); Map<String, String> options = new HashMap<>();
options.put("notification_ids", Helper.joinL(ids, ",")); options.put("notification_ids", Helper.joinL(ids, ","));
options.put("is_seen", String.valueOf(seen)); options.put("is_read", String.valueOf(read));
if (updateRead) { if (updateSeen) {
options.put("is_read", String.valueOf(read)); options.put("is_seen", String.valueOf(seen));
} }
try { try {

View file

@ -22,10 +22,10 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class TwitterVerifyTask extends AsyncTask<Void, Void, RewardVerified> { public class TwitterVerifyTask extends AsyncTask<Void, Void, RewardVerified> {
private final Context context; private Context context;
private final View progressView; private View progressView;
private final TwitterOauth twitterOauth; private TwitterOauth twitterOauth;
private final RewardVerifiedHandler handler; private RewardVerifiedHandler handler;
private Exception error; private Exception error;
public TwitterVerifyTask(TwitterOauth twitterOauth, View progressView, Context context, RewardVerifiedHandler handler) { public TwitterVerifyTask(TwitterOauth twitterOauth, View progressView, Context context, RewardVerifiedHandler handler) {

View file

@ -11,8 +11,8 @@ import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.model.UrlSuggestion; import io.lbry.browser.model.UrlSuggestion;
public class FetchRecentUrlHistoryTask extends AsyncTask<Void, Void, List<UrlSuggestion>> { public class FetchRecentUrlHistoryTask extends AsyncTask<Void, Void, List<UrlSuggestion>> {
private final DatabaseHelper dbHelper; private DatabaseHelper dbHelper;
private final FetchRecentUrlHistoryHandler handler; private FetchRecentUrlHistoryHandler handler;
public FetchRecentUrlHistoryTask(DatabaseHelper dbHelper, FetchRecentUrlHistoryHandler handler) { public FetchRecentUrlHistoryTask(DatabaseHelper dbHelper, FetchRecentUrlHistoryHandler handler) {
this.dbHelper = dbHelper; this.dbHelper = dbHelper;
this.handler = handler; this.handler = handler;

View file

@ -10,14 +10,15 @@ import java.util.Date;
import java.util.List; import java.util.List;
import io.lbry.browser.data.DatabaseHelper; import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.model.UrlSuggestion;
import io.lbry.browser.model.ViewHistory; import io.lbry.browser.model.ViewHistory;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
public class FetchViewHistoryTask extends AsyncTask<Void, Void, List<ViewHistory>> { public class FetchViewHistoryTask extends AsyncTask<Void, Void, List<ViewHistory>> {
private final DatabaseHelper dbHelper; private DatabaseHelper dbHelper;
private final FetchViewHistoryHandler handler; private FetchViewHistoryHandler handler;
private final int pageSize; private int pageSize;
private final Date lastDate; private Date lastDate;
public FetchViewHistoryTask(Date lastDate, int pageSize, DatabaseHelper dbHelper, FetchViewHistoryHandler handler) { public FetchViewHistoryTask(Date lastDate, int pageSize, DatabaseHelper dbHelper, FetchViewHistoryHandler handler) {
this.lastDate = lastDate; this.lastDate = lastDate;
this.pageSize = pageSize; this.pageSize = pageSize;

View file

@ -6,6 +6,7 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.util.Log; import android.util.Log;
@ -22,9 +23,9 @@ import io.lbry.browser.utils.Helper;
public class LoadGalleryItemsTask extends AsyncTask<Void, GalleryItem, List<GalleryItem>> { public class LoadGalleryItemsTask extends AsyncTask<Void, GalleryItem, List<GalleryItem>> {
private static final String TAG = "LoadGalleryItemsTask"; private static final String TAG = "LoadGalleryItemsTask";
private final LoadGalleryHandler handler; private LoadGalleryHandler handler;
private final View progressView; private View progressView;
private final Context context; private Context context;
public LoadGalleryItemsTask(View progressView, Context context, LoadGalleryHandler handler) { public LoadGalleryItemsTask(View progressView, Context context, LoadGalleryHandler handler) {
this.progressView = progressView; this.progressView = progressView;
@ -43,7 +44,6 @@ public class LoadGalleryItemsTask extends AsyncTask<Void, GalleryItem, List<Gall
if (context != null) { if (context != null) {
ContentResolver resolver = context.getContentResolver(); ContentResolver resolver = context.getContentResolver();
try { try {
// TODO: MediaStore.Video.Media.DURATION requires API level 29
String[] projection = { String[] projection = {
MediaStore.MediaColumns._ID, MediaStore.MediaColumns._ID,
MediaStore.MediaColumns.DATA, MediaStore.MediaColumns.DATA,
@ -61,7 +61,6 @@ public class LoadGalleryItemsTask extends AsyncTask<Void, GalleryItem, List<Gall
int nameColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME); int nameColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
int typeColumn = cursor.getColumnIndex(MediaStore.MediaColumns.MIME_TYPE); int typeColumn = cursor.getColumnIndex(MediaStore.MediaColumns.MIME_TYPE);
int pathColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DATA); int pathColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DATA);
// TODO: MediaStore.Video.Media.DURATION requires API level 29
int durationColumn = cursor.getColumnIndex(MediaStore.Video.Media.DURATION); int durationColumn = cursor.getColumnIndex(MediaStore.Video.Media.DURATION);
GalleryItem item = new GalleryItem(); GalleryItem item = new GalleryItem();

View file

@ -1,15 +1,18 @@
package io.lbry.browser.tasks.localdata; package io.lbry.browser.tasks.localdata;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask; import android.os.AsyncTask;
import io.lbry.browser.MainActivity;
import io.lbry.browser.data.DatabaseHelper; import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.model.UrlSuggestion; import io.lbry.browser.model.UrlSuggestion;
import io.lbry.browser.tasks.GenericTaskHandler;
public class SaveUrlHistoryTask extends AsyncTask<Void, Void, Boolean> { public class SaveUrlHistoryTask extends AsyncTask<Void, Void, Boolean> {
private final DatabaseHelper dbHelper; private DatabaseHelper dbHelper;
private final UrlSuggestion suggestion; private UrlSuggestion suggestion;
private final SaveUrlHistoryHandler handler; private SaveUrlHistoryHandler handler;
private Exception error; private Exception error;
public SaveUrlHistoryTask(UrlSuggestion suggestion, DatabaseHelper dbHelper, SaveUrlHistoryHandler handler) { public SaveUrlHistoryTask(UrlSuggestion suggestion, DatabaseHelper dbHelper, SaveUrlHistoryHandler handler) {

View file

@ -7,9 +7,9 @@ import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.model.ViewHistory; import io.lbry.browser.model.ViewHistory;
public class SaveViewHistoryTask extends AsyncTask<Void, Void, Boolean> { public class SaveViewHistoryTask extends AsyncTask<Void, Void, Boolean> {
private final DatabaseHelper dbHelper; private DatabaseHelper dbHelper;
private final ViewHistory history; private ViewHistory history;
private final SaveViewHistoryHandler handler; private SaveViewHistoryHandler handler;
private Exception error; private Exception error;
public SaveViewHistoryTask(ViewHistory history, DatabaseHelper dbHelper, SaveViewHistoryHandler handler) { public SaveViewHistoryTask(ViewHistory history, DatabaseHelper dbHelper, SaveViewHistoryHandler handler) {

View file

@ -8,8 +8,8 @@ import io.lbry.browser.model.lbryinc.User;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class CheckUserEmailVerifiedTask extends AsyncTask<Void, Void, Boolean> { public class CheckUserEmailVerifiedTask extends AsyncTask<Void, Void, Boolean> {
private final Context context; private Context context;
private final CheckUserEmailVerifiedHandler handler; private CheckUserEmailVerifiedHandler handler;
public CheckUserEmailVerifiedTask(Context context, CheckUserEmailVerifiedHandler handler) { public CheckUserEmailVerifiedTask(Context context, CheckUserEmailVerifiedHandler handler) {
this.context = context; this.context = context;

View file

@ -3,6 +3,8 @@ package io.lbry.browser.tasks.verification;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.view.View; import android.view.View;
import org.json.JSONObject;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -13,9 +15,9 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class EmailNewTask extends AsyncTask<Void, Void, Boolean> { public class EmailNewTask extends AsyncTask<Void, Void, Boolean> {
private final String email; private String email;
private final View progressView; private View progressView;
private final EmailNewHandler handler; private EmailNewHandler handler;
private Exception error; private Exception error;
public EmailNewTask(String email, View progressView, EmailNewHandler handler) { public EmailNewTask(String email, View progressView, EmailNewHandler handler) {

Some files were not shown because too many files have changed in this diff Show more