Implement file and channel page delete actions. UI action cleanup.
This commit is contained in:
parent
0fec3c6a6f
commit
2231119d36
18 changed files with 297 additions and 116 deletions
|
@ -104,6 +104,7 @@ import io.lbry.browser.exceptions.LbryUriException;
|
||||||
import io.lbry.browser.listener.CameraPermissionListener;
|
import io.lbry.browser.listener.CameraPermissionListener;
|
||||||
import io.lbry.browser.listener.DownloadActionListener;
|
import io.lbry.browser.listener.DownloadActionListener;
|
||||||
import io.lbry.browser.listener.FetchChannelsListener;
|
import io.lbry.browser.listener.FetchChannelsListener;
|
||||||
|
import io.lbry.browser.listener.FetchClaimsListener;
|
||||||
import io.lbry.browser.listener.FilePickerListener;
|
import io.lbry.browser.listener.FilePickerListener;
|
||||||
import io.lbry.browser.listener.SdkStatusListener;
|
import io.lbry.browser.listener.SdkStatusListener;
|
||||||
import io.lbry.browser.listener.StoragePermissionListener;
|
import io.lbry.browser.listener.StoragePermissionListener;
|
||||||
|
@ -135,17 +136,17 @@ import io.lbry.browser.ui.BaseFragment;
|
||||||
import io.lbry.browser.ui.channel.ChannelFormFragment;
|
import io.lbry.browser.ui.channel.ChannelFormFragment;
|
||||||
import io.lbry.browser.ui.channel.ChannelFragment;
|
import io.lbry.browser.ui.channel.ChannelFragment;
|
||||||
import io.lbry.browser.ui.channel.ChannelManagerFragment;
|
import io.lbry.browser.ui.channel.ChannelManagerFragment;
|
||||||
import io.lbry.browser.ui.editorschoice.EditorsChoiceFragment;
|
import io.lbry.browser.ui.findcontent.EditorsChoiceFragment;
|
||||||
import io.lbry.browser.ui.following.FileViewFragment;
|
import io.lbry.browser.ui.findcontent.FileViewFragment;
|
||||||
import io.lbry.browser.ui.following.FollowingFragment;
|
import io.lbry.browser.ui.findcontent.FollowingFragment;
|
||||||
import io.lbry.browser.ui.library.LibraryFragment;
|
import io.lbry.browser.ui.library.LibraryFragment;
|
||||||
import io.lbry.browser.ui.other.AboutFragment;
|
import io.lbry.browser.ui.other.AboutFragment;
|
||||||
import io.lbry.browser.ui.publish.PublishFormFragment;
|
import io.lbry.browser.ui.publish.PublishFormFragment;
|
||||||
import io.lbry.browser.ui.publish.PublishFragment;
|
import io.lbry.browser.ui.publish.PublishFragment;
|
||||||
import io.lbry.browser.ui.publish.PublishesFragment;
|
import io.lbry.browser.ui.publish.PublishesFragment;
|
||||||
import io.lbry.browser.ui.search.SearchFragment;
|
import io.lbry.browser.ui.findcontent.SearchFragment;
|
||||||
import io.lbry.browser.ui.other.SettingsFragment;
|
import io.lbry.browser.ui.other.SettingsFragment;
|
||||||
import io.lbry.browser.ui.allcontent.AllContentFragment;
|
import io.lbry.browser.ui.findcontent.AllContentFragment;
|
||||||
import io.lbry.browser.ui.wallet.InvitesFragment;
|
import io.lbry.browser.ui.wallet.InvitesFragment;
|
||||||
import io.lbry.browser.ui.wallet.RewardsFragment;
|
import io.lbry.browser.ui.wallet.RewardsFragment;
|
||||||
import io.lbry.browser.ui.wallet.WalletFragment;
|
import io.lbry.browser.ui.wallet.WalletFragment;
|
||||||
|
@ -294,6 +295,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
private List<SdkStatusListener> sdkStatusListeners;
|
private List<SdkStatusListener> sdkStatusListeners;
|
||||||
private List<StoragePermissionListener> storagePermissionListeners;
|
private List<StoragePermissionListener> storagePermissionListeners;
|
||||||
private List<WalletBalanceListener> walletBalanceListeners;
|
private List<WalletBalanceListener> walletBalanceListeners;
|
||||||
|
private List<FetchClaimsListener> fetchClaimsListeners;
|
||||||
private List<FetchChannelsListener> fetchChannelsListeners;
|
private List<FetchChannelsListener> fetchChannelsListeners;
|
||||||
@Getter
|
@Getter
|
||||||
private ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
|
private ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
|
||||||
|
@ -412,6 +414,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
sdkStatusListeners = new ArrayList<>();
|
sdkStatusListeners = new ArrayList<>();
|
||||||
storagePermissionListeners = new ArrayList<>();
|
storagePermissionListeners = new ArrayList<>();
|
||||||
walletBalanceListeners = new ArrayList<>();
|
walletBalanceListeners = new ArrayList<>();
|
||||||
|
fetchClaimsListeners = new ArrayList<>();
|
||||||
fetchChannelsListeners = new ArrayList<>();
|
fetchChannelsListeners = new ArrayList<>();
|
||||||
|
|
||||||
sdkStatusListeners.add(this);
|
sdkStatusListeners.add(this);
|
||||||
|
@ -601,6 +604,15 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
fetchChannelsListeners.remove(listener);
|
fetchChannelsListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addFetchClaimsListener(FetchClaimsListener listener) {
|
||||||
|
if (!fetchClaimsListeners.contains(listener)) {
|
||||||
|
fetchClaimsListeners.add(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void removeFetchClaimsListener(FetchClaimsListener listener) {
|
||||||
|
fetchClaimsListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
private void openSelectedMenuItem() {
|
private void openSelectedMenuItem() {
|
||||||
switch (selectedMenuItemId) {
|
switch (selectedMenuItemId) {
|
||||||
// TODO: reverse map lookup for class?
|
// TODO: reverse map lookup for class?
|
||||||
|
@ -830,9 +842,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
applyNavbarSigninPadding();
|
applyNavbarSigninPadding();
|
||||||
checkFirstRun();
|
checkFirstRun();
|
||||||
checkNowPlaying();
|
checkNowPlaying();
|
||||||
if (Lbryio.totalUnclaimedRewardAmount > 0) {
|
fetchRewards();
|
||||||
showFloatingUnclaimedRewards();
|
|
||||||
}
|
|
||||||
|
|
||||||
// check (and start) the LBRY SDK service
|
// check (and start) the LBRY SDK service
|
||||||
serviceRunning = isServiceRunning(this, LbrynetService.class);
|
serviceRunning = isServiceRunning(this, LbrynetService.class);
|
||||||
|
@ -1326,7 +1336,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
|
|
||||||
if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
|
if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
|
||||||
openFragment(FollowingFragment.class, false, NavMenuItem.ID_ITEM_FOLLOWING);
|
openFragment(FollowingFragment.class, false, NavMenuItem.ID_ITEM_FOLLOWING);
|
||||||
fetchRewards();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2157,13 +2166,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
|
|
||||||
if (Lbryio.totalUnclaimedRewardAmount > 0) {
|
if (Lbryio.totalUnclaimedRewardAmount > 0) {
|
||||||
showFloatingUnclaimedRewards();
|
showFloatingUnclaimedRewards();
|
||||||
double usdRewardAmount = Lbryio.totalUnclaimedRewardAmount * Lbryio.LBCUSDRate;
|
updateRewardsUsdVale();
|
||||||
if (navMenuAdapter != null) {
|
|
||||||
navMenuAdapter.setExtraLabelForItem(
|
|
||||||
NavMenuItem.ID_ITEM_REWARDS,
|
|
||||||
Lbryio.LBCUSDRate > 0 ? String.format("$%s", Helper.SIMPLE_CURRENCY_FORMAT.format(usdRewardAmount)) : null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2174,6 +2177,18 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateRewardsUsdVale() {
|
||||||
|
if (Lbryio.totalUnclaimedRewardAmount > 0) {
|
||||||
|
double usdRewardAmount = Lbryio.totalUnclaimedRewardAmount * Lbryio.LBCUSDRate;
|
||||||
|
if (navMenuAdapter != null) {
|
||||||
|
navMenuAdapter.setExtraLabelForItem(
|
||||||
|
NavMenuItem.ID_ITEM_REWARDS,
|
||||||
|
Lbryio.LBCUSDRate > 0 ? String.format("$%s", Helper.SIMPLE_CURRENCY_FORMAT.format(usdRewardAmount)) : null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void showFloatingUnclaimedRewards() {
|
public void showFloatingUnclaimedRewards() {
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
boolean notInterestedInRewards = sp.getBoolean(PREFERENCE_KEY_INTERNAL_REWARDS_NOT_INTERESTED, false);
|
boolean notInterestedInRewards = sp.getBoolean(PREFERENCE_KEY_INTERNAL_REWARDS_NOT_INTERESTED, false);
|
||||||
|
@ -2647,6 +2662,9 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Claim> claims) {
|
public void onSuccess(List<Claim> claims) {
|
||||||
Lbry.ownClaims = Helper.filterDeletedClaims(new ArrayList<>(claims));
|
Lbry.ownClaims = Helper.filterDeletedClaims(new ArrayList<>(claims));
|
||||||
|
for (FetchClaimsListener listener : fetchClaimsListeners) {
|
||||||
|
listener.onClaimsFetched(claims);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -239,7 +239,8 @@ public class VerificationActivity extends FragmentActivity implements SignInList
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showFetchUserError(String message) {
|
private void showFetchUserError(String message) {
|
||||||
Snackbar.make(findViewById(R.id.verification_pager), message, Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).show();
|
Snackbar.make(findViewById(R.id.verification_pager), message, Snackbar.LENGTH_LONG).
|
||||||
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -197,7 +197,8 @@ public class RewardListAdapter extends RecyclerView.Adapter<RewardListAdapter.Vi
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
String claimCode = Helper.getValue(vh.inputCustomCode.getText());
|
String claimCode = Helper.getValue(vh.inputCustomCode.getText());
|
||||||
if (Helper.isNullOrEmpty(claimCode)) {
|
if (Helper.isNullOrEmpty(claimCode)) {
|
||||||
Snackbar.make(view, R.string.please_enter_claim_code, Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).show();
|
Snackbar.make(view, R.string.please_enter_claim_code, Snackbar.LENGTH_LONG).
|
||||||
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package io.lbry.browser.listener;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.lbry.browser.model.Claim;
|
||||||
|
|
||||||
|
public interface FetchClaimsListener {
|
||||||
|
void onClaimsFetched(List<Claim> claims);
|
||||||
|
}
|
|
@ -7,7 +7,6 @@ import androidx.fragment.app.Fragment;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import io.lbry.browser.MainActivity;
|
import io.lbry.browser.MainActivity;
|
||||||
import io.lbry.browser.ui.following.FileViewFragment;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package io.lbry.browser.ui.channel;
|
package io.lbry.browser.ui.channel;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -9,8 +11,10 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
@ -26,12 +30,12 @@ import com.google.android.material.tabs.TabLayoutMediator;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
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.MainActivity;
|
||||||
import io.lbry.browser.R;
|
import io.lbry.browser.R;
|
||||||
import io.lbry.browser.data.DatabaseHelper;
|
|
||||||
import io.lbry.browser.dialog.SendTipDialogFragment;
|
import io.lbry.browser.dialog.SendTipDialogFragment;
|
||||||
import io.lbry.browser.exceptions.LbryUriException;
|
import io.lbry.browser.exceptions.LbryUriException;
|
||||||
import io.lbry.browser.listener.FetchChannelsListener;
|
import io.lbry.browser.listener.FetchChannelsListener;
|
||||||
|
@ -39,13 +43,15 @@ import io.lbry.browser.model.Claim;
|
||||||
import io.lbry.browser.model.ClaimCacheKey;
|
import io.lbry.browser.model.ClaimCacheKey;
|
||||||
import io.lbry.browser.model.UrlSuggestion;
|
import io.lbry.browser.model.UrlSuggestion;
|
||||||
import io.lbry.browser.model.lbryinc.Subscription;
|
import io.lbry.browser.model.lbryinc.Subscription;
|
||||||
|
import io.lbry.browser.tasks.claim.AbandonChannelTask;
|
||||||
|
import io.lbry.browser.tasks.claim.AbandonHandler;
|
||||||
import io.lbry.browser.tasks.lbryinc.ChannelSubscribeTask;
|
import io.lbry.browser.tasks.lbryinc.ChannelSubscribeTask;
|
||||||
import io.lbry.browser.tasks.claim.ClaimListResultHandler;
|
import io.lbry.browser.tasks.claim.ClaimListResultHandler;
|
||||||
import io.lbry.browser.tasks.claim.ResolveTask;
|
import io.lbry.browser.tasks.claim.ResolveTask;
|
||||||
import io.lbry.browser.tasks.lbryinc.FetchStatCountTask;
|
import io.lbry.browser.tasks.lbryinc.FetchStatCountTask;
|
||||||
import io.lbry.browser.ui.BaseFragment;
|
import io.lbry.browser.ui.BaseFragment;
|
||||||
import io.lbry.browser.ui.controls.SolidIconView;
|
import io.lbry.browser.ui.controls.SolidIconView;
|
||||||
import io.lbry.browser.ui.following.FollowingFragment;
|
import io.lbry.browser.ui.findcontent.FollowingFragment;
|
||||||
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.LbryAnalytics;
|
import io.lbry.browser.utils.LbryAnalytics;
|
||||||
|
@ -122,8 +128,16 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (claim != null) {
|
if (claim != null) {
|
||||||
// show confirmation?
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).
|
||||||
// delete claim task and redirect
|
setTitle(R.string.delete_channel).
|
||||||
|
setMessage(R.string.confirm_delete_channel)
|
||||||
|
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
deleteCurrentClaim();
|
||||||
|
}
|
||||||
|
}).setNegativeButton(R.string.no, null);
|
||||||
|
builder.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -228,6 +242,33 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteCurrentClaim() {
|
||||||
|
if (claim != null) {
|
||||||
|
Helper.setViewVisibility(layoutDisplayArea, View.GONE);
|
||||||
|
Helper.setViewVisibility(layoutLoadingState, View.VISIBLE);
|
||||||
|
AbandonChannelTask task = new AbandonChannelTask(Arrays.asList(claim.getClaimId()), layoutResolving, new AbandonHandler() {
|
||||||
|
@Override
|
||||||
|
public void onComplete(List<String> successfulClaimIds, List<String> failedClaimIds, List<Exception> errors) {
|
||||||
|
Context context = getContext();
|
||||||
|
if (context instanceof MainActivity) {
|
||||||
|
if (failedClaimIds.size() == 0) {
|
||||||
|
MainActivity activity = (MainActivity) context;
|
||||||
|
activity.showMessage(R.string.channel_deleted);
|
||||||
|
activity.onBackPressed();
|
||||||
|
} else {
|
||||||
|
View root = getView();
|
||||||
|
if (root != null) {
|
||||||
|
Snackbar.make(root, R.string.channel_failed_delete, Toast.LENGTH_LONG).
|
||||||
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void checkIsFollowing() {
|
private void checkIsFollowing() {
|
||||||
if (claim != null) {
|
if (claim != null) {
|
||||||
boolean isFollowing = Lbryio.isFollowing(claim);
|
boolean isFollowing = Lbryio.isFollowing(claim);
|
||||||
|
@ -324,7 +365,8 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resolveUrl() {
|
private void resolveUrl() {
|
||||||
layoutDisplayArea.setVisibility(View.INVISIBLE);
|
Helper.setViewVisibility(layoutDisplayArea, View.INVISIBLE);
|
||||||
|
Helper.setViewVisibility(layoutLoadingState, View.VISIBLE);
|
||||||
ResolveTask task = new ResolveTask(url, Lbry.LBRY_TV_CONNECTION_STRING, layoutResolving, new ClaimListResultHandler() {
|
ResolveTask task = new ResolveTask(url, Lbry.LBRY_TV_CONNECTION_STRING, layoutResolving, new ClaimListResultHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Claim> claims) {
|
public void onSuccess(List<Claim> claims) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package io.lbry.browser.ui.allcontent;
|
package io.lbry.browser.ui.findcontent;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
|
@ -1,4 +1,4 @@
|
||||||
package io.lbry.browser.ui.editorschoice;
|
package io.lbry.browser.ui.findcontent;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
|
@ -1,4 +1,4 @@
|
||||||
package io.lbry.browser.ui.following;
|
package io.lbry.browser.ui.findcontent;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
@ -80,6 +80,7 @@ import io.lbry.browser.dialog.RepostClaimDialogFragment;
|
||||||
import io.lbry.browser.dialog.SendTipDialogFragment;
|
import io.lbry.browser.dialog.SendTipDialogFragment;
|
||||||
import io.lbry.browser.exceptions.LbryUriException;
|
import io.lbry.browser.exceptions.LbryUriException;
|
||||||
import io.lbry.browser.listener.DownloadActionListener;
|
import io.lbry.browser.listener.DownloadActionListener;
|
||||||
|
import io.lbry.browser.listener.FetchClaimsListener;
|
||||||
import io.lbry.browser.listener.SdkStatusListener;
|
import io.lbry.browser.listener.SdkStatusListener;
|
||||||
import io.lbry.browser.listener.StoragePermissionListener;
|
import io.lbry.browser.listener.StoragePermissionListener;
|
||||||
import io.lbry.browser.model.Claim;
|
import io.lbry.browser.model.Claim;
|
||||||
|
@ -94,6 +95,8 @@ import io.lbry.browser.tasks.GenericTaskHandler;
|
||||||
import io.lbry.browser.tasks.LighthouseSearchTask;
|
import io.lbry.browser.tasks.LighthouseSearchTask;
|
||||||
import io.lbry.browser.tasks.ReadTextFileTask;
|
import io.lbry.browser.tasks.ReadTextFileTask;
|
||||||
import io.lbry.browser.tasks.SetSdkSettingTask;
|
import io.lbry.browser.tasks.SetSdkSettingTask;
|
||||||
|
import io.lbry.browser.tasks.claim.AbandonHandler;
|
||||||
|
import io.lbry.browser.tasks.claim.AbandonStreamTask;
|
||||||
import io.lbry.browser.tasks.claim.ClaimListResultHandler;
|
import io.lbry.browser.tasks.claim.ClaimListResultHandler;
|
||||||
import io.lbry.browser.tasks.claim.ClaimSearchResultHandler;
|
import io.lbry.browser.tasks.claim.ClaimSearchResultHandler;
|
||||||
import io.lbry.browser.tasks.claim.ResolveTask;
|
import io.lbry.browser.tasks.claim.ResolveTask;
|
||||||
|
@ -116,7 +119,7 @@ import io.lbry.lbrysdk.LbrynetService;
|
||||||
import io.lbry.lbrysdk.Utils;
|
import io.lbry.lbrysdk.Utils;
|
||||||
|
|
||||||
public class FileViewFragment extends BaseFragment implements
|
public class FileViewFragment extends BaseFragment implements
|
||||||
MainActivity.BackPressInterceptor, DownloadActionListener, SdkStatusListener, StoragePermissionListener {
|
MainActivity.BackPressInterceptor, DownloadActionListener, FetchClaimsListener, SdkStatusListener, StoragePermissionListener {
|
||||||
private static final int RELATED_CONTENT_SIZE = 16;
|
private static final int RELATED_CONTENT_SIZE = 16;
|
||||||
private PlayerControlView castControlView;
|
private PlayerControlView castControlView;
|
||||||
private Player currentPlayer;
|
private Player currentPlayer;
|
||||||
|
@ -195,6 +198,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
MainActivity activity = (MainActivity) context;
|
MainActivity activity = (MainActivity) context;
|
||||||
activity.setBackPressInterceptor(this);
|
activity.setBackPressInterceptor(this);
|
||||||
activity.addDownloadActionListener(this);
|
activity.addDownloadActionListener(this);
|
||||||
|
activity.addFetchClaimsListener(this);
|
||||||
if (!MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
if (!MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
||||||
activity.addStoragePermissionListener(this);
|
activity.addStoragePermissionListener(this);
|
||||||
}
|
}
|
||||||
|
@ -378,6 +382,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
if (loadFilePending) {
|
if (loadFilePending) {
|
||||||
loadFile();
|
loadFile();
|
||||||
}
|
}
|
||||||
|
checkOwnClaim();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getStreamingUrl() {
|
private String getStreamingUrl() {
|
||||||
|
@ -504,6 +509,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
if (context instanceof MainActivity) {
|
if (context instanceof MainActivity) {
|
||||||
MainActivity activity = (MainActivity) context;
|
MainActivity activity = (MainActivity) context;
|
||||||
activity.removeDownloadActionListener(this);
|
activity.removeDownloadActionListener(this);
|
||||||
|
activity.removeFetchClaimsListener(this);
|
||||||
activity.removeSdkStatusListener(this);
|
activity.removeSdkStatusListener(this);
|
||||||
activity.removeStoragePermissionListener(this);
|
activity.removeStoragePermissionListener(this);
|
||||||
}
|
}
|
||||||
|
@ -667,6 +673,21 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
root.findViewById(R.id.file_view_action_edit).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (!Lbry.SDK_READY) {
|
||||||
|
Snackbar.make(root.findViewById(R.id.file_view_claim_display_area), R.string.sdk_initializing_functionality, Snackbar.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Context context = getContext();
|
||||||
|
if (claim != null && context instanceof MainActivity) {
|
||||||
|
((MainActivity) context).openPublishForm(claim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
root.findViewById(R.id.file_view_action_delete).setOnClickListener(new View.OnClickListener() {
|
root.findViewById(R.id.file_view_action_delete).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -675,16 +696,32 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).
|
if (claim != null) {
|
||||||
setTitle(R.string.delete_file).
|
boolean isOwnClaim = Lbry.ownClaims.contains(claim);
|
||||||
setMessage(R.string.confirm_delete_file_message)
|
if (isOwnClaim) {
|
||||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).
|
||||||
@Override
|
setTitle(R.string.delete_content).
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
setMessage(R.string.confirm_delete_content_message)
|
||||||
deleteClaimFile();
|
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
}
|
@Override
|
||||||
}).setNegativeButton(R.string.no, null);
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
builder.show();
|
deleteCurrentClaim();
|
||||||
|
}
|
||||||
|
}).setNegativeButton(R.string.no, null);
|
||||||
|
builder.show();
|
||||||
|
} else {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).
|
||||||
|
setTitle(R.string.delete_file).
|
||||||
|
setMessage(R.string.confirm_delete_file_message)
|
||||||
|
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
deleteClaimFile();
|
||||||
|
}
|
||||||
|
}).setNegativeButton(R.string.no, null);
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -803,6 +840,30 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
relatedContentList.setLayoutManager(llm);
|
relatedContentList.setLayoutManager(llm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteCurrentClaim() {
|
||||||
|
if (claim != null) {
|
||||||
|
Helper.setViewVisibility(layoutDisplayArea, View.INVISIBLE);
|
||||||
|
Helper.setViewVisibility(layoutLoadingState, View.VISIBLE);
|
||||||
|
Helper.setViewVisibility(layoutNothingAtLocation, View.GONE);
|
||||||
|
AbandonStreamTask task = new AbandonStreamTask(Arrays.asList(claim.getClaimId()), layoutResolving, new AbandonHandler() {
|
||||||
|
@Override
|
||||||
|
public void onComplete(List<String> successfulClaimIds, List<String> failedClaimIds, List<Exception> errors) {
|
||||||
|
Context context = getContext();
|
||||||
|
if (context instanceof MainActivity) {
|
||||||
|
if (failedClaimIds.size() == 0) {
|
||||||
|
MainActivity activity = (MainActivity) context;
|
||||||
|
activity.showMessage(R.string.content_deleted);
|
||||||
|
activity.onBackPressed();
|
||||||
|
} else {
|
||||||
|
showError(getString(R.string.content_failed_delete));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void checkStoragePermissionAndStartDownload() {
|
private void checkStoragePermissionAndStartDownload() {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
if (MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
||||||
|
@ -904,10 +965,13 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
actionDelete.setVisibility(View.GONE);
|
Helper.setViewVisibility(actionDelete, View.GONE);
|
||||||
getView().findViewById(R.id.file_view_action_download).setVisibility(View.VISIBLE);
|
View root = getView();
|
||||||
getView().findViewById(R.id.file_view_unsupported_container).setVisibility(View.GONE);
|
if (root != null) {
|
||||||
actionDelete.setEnabled(true);
|
root.findViewById(R.id.file_view_action_download).setVisibility(View.VISIBLE);
|
||||||
|
root.findViewById(R.id.file_view_unsupported_container).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
Helper.setViewEnabled(actionDelete, true);
|
||||||
|
|
||||||
claim.setFile(null);
|
claim.setFile(null);
|
||||||
Lbry.unsetFilesForCachedClaims(Arrays.asList(claim.getClaimId()));
|
Lbry.unsetFilesForCachedClaims(Arrays.asList(claim.getClaimId()));
|
||||||
|
@ -1057,6 +1121,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
loadRelatedContent();
|
loadRelatedContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
checkOwnClaim();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showUnsupportedView() {
|
private void showUnsupportedView() {
|
||||||
|
@ -1484,53 +1549,58 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
// reset the list view
|
// reset the list view
|
||||||
String title = claim.getTitle();
|
String title = claim.getTitle();
|
||||||
String claimId = claim.getClaimId();
|
String claimId = claim.getClaimId();
|
||||||
ProgressBar relatedLoading = getView().findViewById(R.id.file_view_related_content_progress);
|
View root = getView();
|
||||||
|
if (root != null) {
|
||||||
Context context = getContext();
|
ProgressBar relatedLoading = root.findViewById(R.id.file_view_related_content_progress);
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
Context context = getContext();
|
||||||
boolean canShowMatureContent = sp.getBoolean(MainActivity.PREFERENCE_KEY_SHOW_MATURE_CONTENT, false);
|
boolean canShowMatureContent = false;
|
||||||
LighthouseSearchTask relatedTask = new LighthouseSearchTask(
|
if (context != null) {
|
||||||
title, RELATED_CONTENT_SIZE, 0, canShowMatureContent, claimId, relatedLoading, new ClaimSearchResultHandler() {
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
@Override
|
canShowMatureContent = sp.getBoolean(MainActivity.PREFERENCE_KEY_SHOW_MATURE_CONTENT, false);
|
||||||
public void onSuccess(List<Claim> claims, boolean hasReachedEnd) {
|
}
|
||||||
List<Claim> filteredClaims = new ArrayList<>();
|
LighthouseSearchTask relatedTask = new LighthouseSearchTask(
|
||||||
for (Claim c : claims) {
|
title, RELATED_CONTENT_SIZE, 0, canShowMatureContent, claimId, relatedLoading, new ClaimSearchResultHandler() {
|
||||||
if (!c.getClaimId().equalsIgnoreCase(claim.getClaimId())) {
|
@Override
|
||||||
filteredClaims.add(c);
|
public void onSuccess(List<Claim> claims, boolean hasReachedEnd) {
|
||||||
}
|
List<Claim> filteredClaims = new ArrayList<>();
|
||||||
}
|
for (Claim c : claims) {
|
||||||
|
if (!c.getClaimId().equalsIgnoreCase(claim.getClaimId())) {
|
||||||
relatedContentAdapter = new ClaimListAdapter(filteredClaims, context);
|
filteredClaims.add(c);
|
||||||
relatedContentAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
|
|
||||||
@Override
|
|
||||||
public void onClaimClicked(Claim claim) {
|
|
||||||
if (context instanceof MainActivity) {
|
|
||||||
MainActivity activity = (MainActivity) context;
|
|
||||||
if (claim.getName().startsWith("@")) {
|
|
||||||
activity.openChannelUrl(claim.getPermanentUrl());
|
|
||||||
} else {
|
|
||||||
activity.openFileUrl(claim.getPermanentUrl()); //openClaimUrl(claim.getPermanentUrl());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
View view = getView();
|
relatedContentAdapter = new ClaimListAdapter(filteredClaims, context);
|
||||||
if (view != null) {
|
relatedContentAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
|
||||||
RecyclerView relatedContentList = view.findViewById(R.id.file_view_related_content_list);
|
@Override
|
||||||
relatedContentList.setAdapter(relatedContentAdapter);
|
public void onClaimClicked(Claim claim) {
|
||||||
relatedContentAdapter.notifyDataSetChanged();
|
if (context instanceof MainActivity) {
|
||||||
|
MainActivity activity = (MainActivity) context;
|
||||||
|
if (claim.getName().startsWith("@")) {
|
||||||
|
activity.openChannelUrl(claim.getPermanentUrl());
|
||||||
|
} else {
|
||||||
|
activity.openFileUrl(claim.getPermanentUrl()); //openClaimUrl(claim.getPermanentUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Helper.setViewVisibility(view.findViewById(R.id.file_view_no_related_content), relatedContentAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
RecyclerView relatedContentList = view.findViewById(R.id.file_view_related_content_list);
|
||||||
|
relatedContentList.setAdapter(relatedContentAdapter);
|
||||||
|
relatedContentAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
Helper.setViewVisibility(view.findViewById(R.id.file_view_no_related_content), relatedContentAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception error) {
|
public void onError(Exception error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
relatedTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
relatedTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onBackPressed() {
|
public boolean onBackPressed() {
|
||||||
|
@ -1888,6 +1958,11 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClaimsFetched(List<Claim> claims) {
|
||||||
|
checkOwnClaim();
|
||||||
|
}
|
||||||
|
|
||||||
private static class LbryWebViewClient extends WebViewClient {
|
private static class LbryWebViewClient extends WebViewClient {
|
||||||
private Context context;
|
private Context context;
|
||||||
public LbryWebViewClient(Context context) {
|
public LbryWebViewClient(Context context) {
|
||||||
|
@ -1928,4 +2003,17 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
public boolean shouldHideGlobalPlayer() {
|
public boolean shouldHideGlobalPlayer() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkOwnClaim() {
|
||||||
|
if (claim != null) {
|
||||||
|
boolean isOwnClaim = Lbry.ownClaims.contains(claim);
|
||||||
|
View root = getView();
|
||||||
|
if (root != null) {
|
||||||
|
Helper.setViewVisibility(root.findViewById(R.id.file_view_action_download), isOwnClaim ? View.GONE : View.VISIBLE);
|
||||||
|
Helper.setViewVisibility(root.findViewById(R.id.file_view_action_report), isOwnClaim ? View.GONE : View.VISIBLE);
|
||||||
|
Helper.setViewVisibility(root.findViewById(R.id.file_view_action_edit), isOwnClaim ? View.VISIBLE : View.GONE);
|
||||||
|
Helper.setViewVisibility(root.findViewById(R.id.file_view_action_delete), isOwnClaim ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package io.lbry.browser.ui.following;
|
package io.lbry.browser.ui.findcontent;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
|
@ -1,4 +1,4 @@
|
||||||
package io.lbry.browser.ui.search;
|
package io.lbry.browser.ui.findcontent;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
|
@ -1369,15 +1369,12 @@ public class PublishFormFragment extends BaseFragment implements
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
android.util.Log.d("#HELP", "FilePicked: " + filePath);
|
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
if (filePath.equalsIgnoreCase(lastSelectedThumbnailFile)) {
|
if (filePath.equalsIgnoreCase(lastSelectedThumbnailFile)) {
|
||||||
// previous selected cover was uploaded successfully
|
// previous selected cover was uploaded successfully
|
||||||
android.util.Log.d("#HELP", "lastSelectedThumbnailFile the same");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
android.util.Log.d("#HELP", "PickedFilePath=" + filePath);
|
|
||||||
|
|
||||||
Uri fileUri = Uri.fromFile(new File(filePath));
|
Uri fileUri = Uri.fromFile(new File(filePath));
|
||||||
Glide.with(context.getApplicationContext()).load(fileUri).centerCrop().into(imageThumbnail);
|
Glide.with(context.getApplicationContext()).load(fileUri).centerCrop().into(imageThumbnail);
|
||||||
|
@ -1456,7 +1453,6 @@ public class PublishFormFragment extends BaseFragment implements
|
||||||
"-pix_fmt yuv420p " +
|
"-pix_fmt yuv420p " +
|
||||||
"-maxrate 5000K -bufsize 5000K " +
|
"-maxrate 5000K -bufsize 5000K " +
|
||||||
"-movflags +faststart \"%s\"", filePath, scaleFlag, outputFilePath) : movFlagsCommand;
|
"-movflags +faststart \"%s\"", filePath, scaleFlag, outputFilePath) : movFlagsCommand;
|
||||||
android.util.Log.d("#HELP", command);
|
|
||||||
|
|
||||||
Config.enableStatisticsCallback(new StatisticsCallback() {
|
Config.enableStatisticsCallback(new StatisticsCallback() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package io.lbry.browser.ui.verification;
|
package io.lbry.browser.ui.verification;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -95,7 +96,8 @@ public class EmailVerificationFragment extends Fragment {
|
||||||
private void addEmail() {
|
private void addEmail() {
|
||||||
currentEmail = Helper.getValue(inputEmail.getText());
|
currentEmail = Helper.getValue(inputEmail.getText());
|
||||||
if (Helper.isNullOrEmpty(currentEmail) || currentEmail.indexOf("@") == -1) {
|
if (Helper.isNullOrEmpty(currentEmail) || currentEmail.indexOf("@") == -1) {
|
||||||
Snackbar.make(getView(), R.string.provide_valid_email, Snackbar.LENGTH_LONG).setBackgroundTint(getResources().getColor(R.color.red)).show();
|
Snackbar.make(getView(), R.string.provide_valid_email, Snackbar.LENGTH_LONG).
|
||||||
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +127,8 @@ public class EmailVerificationFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception error) {
|
public void onError(Exception error) {
|
||||||
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).setBackgroundTint(getResources().getColor(R.color.red)).show();
|
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).
|
||||||
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
Helper.setViewVisibility(buttonContinue, View.VISIBLE);
|
Helper.setViewVisibility(buttonContinue, View.VISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -188,7 +191,8 @@ public class EmailVerificationFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception error) {
|
public void onError(Exception error) {
|
||||||
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).setBackgroundTint(getResources().getColor(R.color.red)).show();
|
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).
|
||||||
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
Helper.setViewEnabled(buttonResend, true);
|
Helper.setViewEnabled(buttonResend, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -74,7 +74,8 @@ public class PhoneVerificationFragment extends Fragment {
|
||||||
currentPhoneNumber = Helper.getValue(inputPhoneNumber.getText());
|
currentPhoneNumber = Helper.getValue(inputPhoneNumber.getText());
|
||||||
|
|
||||||
if (Helper.isNullOrEmpty(currentPhoneNumber) || !countryCodePicker.isValidFullNumber()) {
|
if (Helper.isNullOrEmpty(currentPhoneNumber) || !countryCodePicker.isValidFullNumber()) {
|
||||||
Snackbar.make(getView(), R.string.please_enter_valid_phone, Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).show();
|
Snackbar.make(getView(), R.string.please_enter_valid_phone, Snackbar.LENGTH_LONG).
|
||||||
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +88,8 @@ public class PhoneVerificationFragment extends Fragment {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
String code = Helper.getValue(inputVerificationCode.getText());
|
String code = Helper.getValue(inputVerificationCode.getText());
|
||||||
if (Helper.isNullOrEmpty(code)) {
|
if (Helper.isNullOrEmpty(code)) {
|
||||||
Snackbar.make(getView(), R.string.please_enter_verification_code, Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).show();
|
Snackbar.make(getView(), R.string.please_enter_verification_code, Snackbar.LENGTH_LONG).
|
||||||
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
verifyPhoneNumber(code);
|
verifyPhoneNumber(code);
|
||||||
|
@ -109,8 +111,8 @@ public class PhoneVerificationFragment extends Fragment {
|
||||||
PhoneNewVerifyTask task = new PhoneNewVerifyTask(currentCountryCode, currentPhoneNumber, null, newLoading, new GenericTaskHandler() {
|
PhoneNewVerifyTask task = new PhoneNewVerifyTask(currentCountryCode, currentPhoneNumber, null, newLoading, new GenericTaskHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeStart() {
|
public void beforeStart() {
|
||||||
continueButton.setEnabled(false);
|
Helper.setViewEnabled(continueButton, false);
|
||||||
continueButton.setVisibility(View.GONE);
|
Helper.setViewVisibility(continueButton, View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,18 +121,21 @@ public class PhoneVerificationFragment extends Fragment {
|
||||||
listener.onPhoneAdded(currentCountryCode, currentPhoneNumber);
|
listener.onPhoneAdded(currentCountryCode, currentPhoneNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
textVerifyParagraph.setText(getString(R.string.enter_phone_verify_code, countryCodePicker.getFullNumberWithPlus()));
|
Helper.setViewText(textVerifyParagraph, getString(R.string.enter_phone_verify_code, countryCodePicker.getFullNumberWithPlus()));
|
||||||
layoutCollect.setVisibility(View.GONE);
|
Helper.setViewVisibility(layoutCollect, View.GONE);
|
||||||
layoutVerify.setVisibility(View.VISIBLE);
|
Helper.setViewVisibility(layoutVerify, View.VISIBLE);
|
||||||
continueButton.setEnabled(true);
|
Helper.setViewEnabled(continueButton, true);
|
||||||
continueButton.setVisibility(View.VISIBLE);
|
Helper.setViewVisibility(continueButton, View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception error) {
|
public void onError(Exception error) {
|
||||||
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).show();
|
if (error != null && getView() != null) {
|
||||||
continueButton.setEnabled(true);
|
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).
|
||||||
continueButton.setVisibility(View.VISIBLE);
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
|
}
|
||||||
|
Helper.setViewEnabled(continueButton, true);
|
||||||
|
Helper.setViewVisibility(continueButton, View.VISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
@ -140,8 +145,8 @@ public class PhoneVerificationFragment extends Fragment {
|
||||||
PhoneNewVerifyTask task = new PhoneNewVerifyTask(currentCountryCode, currentPhoneNumber, verificationCode, verifyLoading, new GenericTaskHandler() {
|
PhoneNewVerifyTask task = new PhoneNewVerifyTask(currentCountryCode, currentPhoneNumber, verificationCode, verifyLoading, new GenericTaskHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeStart() {
|
public void beforeStart() {
|
||||||
verifyButton.setEnabled(false);
|
Helper.setViewEnabled(verifyButton, false);
|
||||||
editButton.setEnabled(false);
|
Helper.setViewEnabled(editButton, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -149,15 +154,18 @@ public class PhoneVerificationFragment extends Fragment {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onPhoneVerified();
|
listener.onPhoneVerified();
|
||||||
}
|
}
|
||||||
verifyButton.setEnabled(true);
|
Helper.setViewEnabled(verifyButton, true);
|
||||||
editButton.setEnabled(true);
|
Helper.setViewEnabled(editButton, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception error) {
|
public void onError(Exception error) {
|
||||||
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).show();
|
if (getView() != null && error != null) {
|
||||||
verifyButton.setEnabled(true);
|
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).
|
||||||
editButton.setEnabled(true);
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
|
}
|
||||||
|
Helper.setViewEnabled(verifyButton, true);
|
||||||
|
Helper.setViewEnabled(editButton, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
|
@ -565,7 +565,8 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
|
||||||
private void showError(String message) {
|
private void showError(String message) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
Snackbar.make(getView(), message, Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).show();
|
Snackbar.make(getView(), message, Snackbar.LENGTH_LONG).
|
||||||
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,6 +237,11 @@ public class RewardsFragment extends BaseFragment implements RewardListAdapter.R
|
||||||
} catch (IllegalStateException ex) {
|
} catch (IllegalStateException ex) {
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context context = getContext();
|
||||||
|
if (context instanceof MainActivity) {
|
||||||
|
((MainActivity) context).updateRewardsUsdVale();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -278,7 +283,8 @@ public class RewardsFragment extends BaseFragment implements RewardListAdapter.R
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception error) {
|
public void onError(Exception error) {
|
||||||
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).show();
|
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).
|
||||||
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
Helper.setViewEnabled(buttonClaim, true);
|
Helper.setViewEnabled(buttonClaim, true);
|
||||||
Helper.setViewEnabled(inputClaimCode, true);
|
Helper.setViewEnabled(inputClaimCode, true);
|
||||||
rewardClaimInProgress = false;
|
rewardClaimInProgress = false;
|
||||||
|
|
|
@ -198,7 +198,7 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
|
||||||
String amountString = Helper.getValue(inputSendAmount.getText());
|
String amountString = Helper.getValue(inputSendAmount.getText());
|
||||||
if (!recipientAddress.matches(LbryUri.REGEX_ADDRESS)) {
|
if (!recipientAddress.matches(LbryUri.REGEX_ADDRESS)) {
|
||||||
Snackbar.make(getView(), R.string.invalid_recipient_address, Snackbar.LENGTH_LONG).
|
Snackbar.make(getView(), R.string.invalid_recipient_address, Snackbar.LENGTH_LONG).
|
||||||
setBackgroundTint(Color.RED).show();
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,13 +208,13 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
|
||||||
double availableAmount = Lbry.walletBalance.getAvailable().doubleValue();
|
double availableAmount = Lbry.walletBalance.getAvailable().doubleValue();
|
||||||
if (availableAmount < amountValue) {
|
if (availableAmount < amountValue) {
|
||||||
Snackbar.make(getView(), R.string.insufficient_balance, Snackbar.LENGTH_LONG).
|
Snackbar.make(getView(), R.string.insufficient_balance, Snackbar.LENGTH_LONG).
|
||||||
setBackgroundTint(getResources().getColor(R.color.red)).show();
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
// pass
|
// pass
|
||||||
Snackbar.make(getView(), R.string.invalid_amount, Snackbar.LENGTH_LONG).
|
Snackbar.make(getView(), R.string.invalid_amount, Snackbar.LENGTH_LONG).
|
||||||
setBackgroundTint(getResources().getColor(R.color.red)).show();
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,7 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception error) {
|
public void onError(Exception error) {
|
||||||
Snackbar.make(getView(), R.string.send_credit_error, Snackbar.LENGTH_LONG).
|
Snackbar.make(getView(), R.string.send_credit_error, Snackbar.LENGTH_LONG).
|
||||||
setBackgroundTint(getResources().getColor(R.color.red)).show();
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
enableSendControls();
|
enableSendControls();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -74,6 +74,10 @@
|
||||||
<string name="confirm_delete_file_message">Are you sure you want to remove this file from your device?</string>
|
<string name="confirm_delete_file_message">Are you sure you want to remove this file from your device?</string>
|
||||||
<string name="unable_to_view_url">Failed to load %1$s. Please try again later.</string>
|
<string name="unable_to_view_url">Failed to load %1$s. Please try again later.</string>
|
||||||
<string name="no_cast_session_available">There is no cast session available at this time.</string>
|
<string name="no_cast_session_available">There is no cast session available at this time.</string>
|
||||||
|
<string name="delete_content">Delete content?</string>
|
||||||
|
<string name="confirm_delete_content_message">Are you sure you want to unpublish this content? No files will be removed from your device.</string>
|
||||||
|
<string name="content_deleted">The content was successfully deleted from the blockchain.</string>
|
||||||
|
<string name="content_failed_delete">The content could not be deleted at this time. Please try again later.</string>
|
||||||
<plurals name="view_count">
|
<plurals name="view_count">
|
||||||
<item quantity="one">%1$s view</item>
|
<item quantity="one">%1$s view</item>
|
||||||
<item quantity="other">%1$s views</item>
|
<item quantity="other">%1$s views</item>
|
||||||
|
@ -390,6 +394,10 @@
|
||||||
<string name="create_a_channel_item">Create a channel...</string>
|
<string name="create_a_channel_item">Create a channel...</string>
|
||||||
<string name="edit_channel">Edit channel</string>
|
<string name="edit_channel">Edit channel</string>
|
||||||
<string name="delete_selection">Delete selection?</string>
|
<string name="delete_selection">Delete selection?</string>
|
||||||
|
<string name="delete_channel">Delete channel?</string>
|
||||||
|
<string name="confirm_delete_channel">Are you sure you want to delete this channel?</string>
|
||||||
|
<string name="channel_deleted">The channel was successfully deleted.</string>
|
||||||
|
<string name="channel_failed_delete">The channel could not be deleted at this time. Please try again later.</string>
|
||||||
<string name="description">Description</string>
|
<string name="description">Description</string>
|
||||||
<string name="yes">Yes</string>
|
<string name="yes">Yes</string>
|
||||||
<string name="no">No</string>
|
<string name="no">No</string>
|
||||||
|
|
Loading…
Reference in a new issue