Native rewrite #878

Merged
akinwale merged 65 commits from native-rewrite into master 2020-05-23 08:49:00 +02:00
18 changed files with 297 additions and 116 deletions
Showing only changes of commit 2231119d36 - Show all commits

View file

@ -104,6 +104,7 @@ import io.lbry.browser.exceptions.LbryUriException;
import io.lbry.browser.listener.CameraPermissionListener;
import io.lbry.browser.listener.DownloadActionListener;
import io.lbry.browser.listener.FetchChannelsListener;
import io.lbry.browser.listener.FetchClaimsListener;
import io.lbry.browser.listener.FilePickerListener;
import io.lbry.browser.listener.SdkStatusListener;
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.ChannelFragment;
import io.lbry.browser.ui.channel.ChannelManagerFragment;
import io.lbry.browser.ui.editorschoice.EditorsChoiceFragment;
import io.lbry.browser.ui.following.FileViewFragment;
import io.lbry.browser.ui.following.FollowingFragment;
import io.lbry.browser.ui.findcontent.EditorsChoiceFragment;
import io.lbry.browser.ui.findcontent.FileViewFragment;
import io.lbry.browser.ui.findcontent.FollowingFragment;
import io.lbry.browser.ui.library.LibraryFragment;
import io.lbry.browser.ui.other.AboutFragment;
import io.lbry.browser.ui.publish.PublishFormFragment;
import io.lbry.browser.ui.publish.PublishFragment;
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.allcontent.AllContentFragment;
import io.lbry.browser.ui.findcontent.AllContentFragment;
import io.lbry.browser.ui.wallet.InvitesFragment;
import io.lbry.browser.ui.wallet.RewardsFragment;
import io.lbry.browser.ui.wallet.WalletFragment;
@ -294,6 +295,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
private List<SdkStatusListener> sdkStatusListeners;
private List<StoragePermissionListener> storagePermissionListeners;
private List<WalletBalanceListener> walletBalanceListeners;
private List<FetchClaimsListener> fetchClaimsListeners;
private List<FetchChannelsListener> fetchChannelsListeners;
@Getter
private ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
@ -412,6 +414,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
sdkStatusListeners = new ArrayList<>();
storagePermissionListeners = new ArrayList<>();
walletBalanceListeners = new ArrayList<>();
fetchClaimsListeners = new ArrayList<>();
fetchChannelsListeners = new ArrayList<>();
sdkStatusListeners.add(this);
@ -601,6 +604,15 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
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() {
switch (selectedMenuItemId) {
// TODO: reverse map lookup for class?
@ -830,9 +842,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
applyNavbarSigninPadding();
checkFirstRun();
checkNowPlaying();
if (Lbryio.totalUnclaimedRewardAmount > 0) {
showFloatingUnclaimedRewards();
}
fetchRewards();
// check (and start) the LBRY SDK service
serviceRunning = isServiceRunning(this, LbrynetService.class);
@ -1326,7 +1336,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
openFragment(FollowingFragment.class, false, NavMenuItem.ID_ITEM_FOLLOWING);
fetchRewards();
}
}
@ -2157,13 +2166,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
if (Lbryio.totalUnclaimedRewardAmount > 0) {
showFloatingUnclaimedRewards();
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
);
}
updateRewardsUsdVale();
}
}
@ -2174,6 +2177,18 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
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() {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
boolean notInterestedInRewards = sp.getBoolean(PREFERENCE_KEY_INTERNAL_REWARDS_NOT_INTERESTED, false);
@ -2647,6 +2662,9 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
@Override
public void onSuccess(List<Claim> claims) {
Lbry.ownClaims = Helper.filterDeletedClaims(new ArrayList<>(claims));
for (FetchClaimsListener listener : fetchClaimsListeners) {
listener.onClaimsFetched(claims);
}
}
@Override

View file

@ -239,7 +239,8 @@ public class VerificationActivity extends FragmentActivity implements SignInList
}
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

View file

@ -197,7 +197,8 @@ public class RewardListAdapter extends RecyclerView.Adapter<RewardListAdapter.Vi
public void onClick(View view) {
String claimCode = Helper.getValue(vh.inputCustomCode.getText());
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;
}

View file

@ -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);
}

View file

@ -7,7 +7,6 @@ import androidx.fragment.app.Fragment;
import java.util.Map;
import io.lbry.browser.MainActivity;
import io.lbry.browser.ui.following.FileViewFragment;
import lombok.Getter;
import lombok.Setter;

View file

@ -1,7 +1,9 @@
package io.lbry.browser.ui.channel;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -9,8 +11,10 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@ -26,12 +30,12 @@ import com.google.android.material.tabs.TabLayoutMediator;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.dialog.SendTipDialogFragment;
import io.lbry.browser.exceptions.LbryUriException;
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.UrlSuggestion;
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.claim.ClaimListResultHandler;
import io.lbry.browser.tasks.claim.ResolveTask;
import io.lbry.browser.tasks.lbryinc.FetchStatCountTask;
import io.lbry.browser.ui.BaseFragment;
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.Lbry;
import io.lbry.browser.utils.LbryAnalytics;
@ -122,8 +128,16 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
@Override
public void onClick(View view) {
if (claim != null) {
// show confirmation?
// delete claim task and redirect
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).
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;
}
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() {
if (claim != null) {
boolean isFollowing = Lbryio.isFollowing(claim);
@ -324,7 +365,8 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
}
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() {
@Override
public void onSuccess(List<Claim> claims) {

View file

@ -1,4 +1,4 @@
package io.lbry.browser.ui.allcontent;
package io.lbry.browser.ui.findcontent;
import android.content.Context;
import android.content.SharedPreferences;

View file

@ -1,4 +1,4 @@
package io.lbry.browser.ui.editorschoice;
package io.lbry.browser.ui.findcontent;
import android.content.Context;
import android.content.SharedPreferences;

View file

@ -1,4 +1,4 @@
package io.lbry.browser.ui.following;
package io.lbry.browser.ui.findcontent;
import android.Manifest;
import android.annotation.SuppressLint;
@ -80,6 +80,7 @@ import io.lbry.browser.dialog.RepostClaimDialogFragment;
import io.lbry.browser.dialog.SendTipDialogFragment;
import io.lbry.browser.exceptions.LbryUriException;
import io.lbry.browser.listener.DownloadActionListener;
import io.lbry.browser.listener.FetchClaimsListener;
import io.lbry.browser.listener.SdkStatusListener;
import io.lbry.browser.listener.StoragePermissionListener;
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.ReadTextFileTask;
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.ClaimSearchResultHandler;
import io.lbry.browser.tasks.claim.ResolveTask;
@ -116,7 +119,7 @@ import io.lbry.lbrysdk.LbrynetService;
import io.lbry.lbrysdk.Utils;
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 PlayerControlView castControlView;
private Player currentPlayer;
@ -195,6 +198,7 @@ public class FileViewFragment extends BaseFragment implements
MainActivity activity = (MainActivity) context;
activity.setBackPressInterceptor(this);
activity.addDownloadActionListener(this);
activity.addFetchClaimsListener(this);
if (!MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
activity.addStoragePermissionListener(this);
}
@ -378,6 +382,7 @@ public class FileViewFragment extends BaseFragment implements
if (loadFilePending) {
loadFile();
}
checkOwnClaim();
}
private String getStreamingUrl() {
@ -504,6 +509,7 @@ public class FileViewFragment extends BaseFragment implements
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
activity.removeDownloadActionListener(this);
activity.removeFetchClaimsListener(this);
activity.removeSdkStatusListener(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() {
@Override
public void onClick(View view) {
@ -675,16 +696,32 @@ public class FileViewFragment extends BaseFragment implements
return;
}
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();
if (claim != null) {
boolean isOwnClaim = Lbry.ownClaims.contains(claim);
if (isOwnClaim) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).
setTitle(R.string.delete_content).
setMessage(R.string.confirm_delete_content_message)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
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);
}
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() {
Context context = getContext();
if (MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
@ -904,10 +965,13 @@ public class FileViewFragment extends BaseFragment implements
@Override
public void onSuccess() {
actionDelete.setVisibility(View.GONE);
getView().findViewById(R.id.file_view_action_download).setVisibility(View.VISIBLE);
getView().findViewById(R.id.file_view_unsupported_container).setVisibility(View.GONE);
actionDelete.setEnabled(true);
Helper.setViewVisibility(actionDelete, View.GONE);
View root = getView();
if (root != null) {
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);
Lbry.unsetFilesForCachedClaims(Arrays.asList(claim.getClaimId()));
@ -1057,6 +1121,7 @@ public class FileViewFragment extends BaseFragment implements
loadRelatedContent();
}
}
checkOwnClaim();
}
private void showUnsupportedView() {
@ -1484,53 +1549,58 @@ public class FileViewFragment extends BaseFragment implements
// reset the list view
String title = claim.getTitle();
String claimId = claim.getClaimId();
ProgressBar relatedLoading = getView().findViewById(R.id.file_view_related_content_progress);
Context context = getContext();
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
boolean canShowMatureContent = sp.getBoolean(MainActivity.PREFERENCE_KEY_SHOW_MATURE_CONTENT, false);
LighthouseSearchTask relatedTask = new LighthouseSearchTask(
title, RELATED_CONTENT_SIZE, 0, canShowMatureContent, claimId, relatedLoading, new ClaimSearchResultHandler() {
@Override
public void onSuccess(List<Claim> claims, boolean hasReachedEnd) {
List<Claim> filteredClaims = new ArrayList<>();
for (Claim c : claims) {
if (!c.getClaimId().equalsIgnoreCase(claim.getClaimId())) {
filteredClaims.add(c);
}
}
relatedContentAdapter = new ClaimListAdapter(filteredClaims, context);
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 root = getView();
if (root != null) {
ProgressBar relatedLoading = root.findViewById(R.id.file_view_related_content_progress);
Context context = getContext();
boolean canShowMatureContent = false;
if (context != null) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
canShowMatureContent = sp.getBoolean(MainActivity.PREFERENCE_KEY_SHOW_MATURE_CONTENT, false);
}
LighthouseSearchTask relatedTask = new LighthouseSearchTask(
title, RELATED_CONTENT_SIZE, 0, canShowMatureContent, claimId, relatedLoading, new ClaimSearchResultHandler() {
@Override
public void onSuccess(List<Claim> claims, boolean hasReachedEnd) {
List<Claim> filteredClaims = new ArrayList<>();
for (Claim c : claims) {
if (!c.getClaimId().equalsIgnoreCase(claim.getClaimId())) {
filteredClaims.add(c);
}
}
});
View view = getView();
if (view != null) {
RecyclerView relatedContentList = view.findViewById(R.id.file_view_related_content_list);
relatedContentList.setAdapter(relatedContentAdapter);
relatedContentAdapter.notifyDataSetChanged();
relatedContentAdapter = new ClaimListAdapter(filteredClaims, context);
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());
}
}
}
});
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
public void onError(Exception error) {
@Override
public void onError(Exception error) {
}
});
relatedTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
relatedTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
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 Context context;
public LbryWebViewClient(Context context) {
@ -1928,4 +2003,17 @@ public class FileViewFragment extends BaseFragment implements
public boolean shouldHideGlobalPlayer() {
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);
}
}
}
}

View file

@ -1,4 +1,4 @@
package io.lbry.browser.ui.following;
package io.lbry.browser.ui.findcontent;
import android.content.Context;
import android.content.SharedPreferences;

View file

@ -1,4 +1,4 @@
package io.lbry.browser.ui.search;
package io.lbry.browser.ui.findcontent;
import android.content.Context;
import android.content.SharedPreferences;

View file

@ -1369,15 +1369,12 @@ public class PublishFormFragment extends BaseFragment implements
return;
}
android.util.Log.d("#HELP", "FilePicked: " + filePath);
Context context = getContext();
if (context != null) {
if (filePath.equalsIgnoreCase(lastSelectedThumbnailFile)) {
// previous selected cover was uploaded successfully
android.util.Log.d("#HELP", "lastSelectedThumbnailFile the same");
return;
}
android.util.Log.d("#HELP", "PickedFilePath=" + filePath);
Uri fileUri = Uri.fromFile(new File(filePath));
Glide.with(context.getApplicationContext()).load(fileUri).centerCrop().into(imageThumbnail);
@ -1456,7 +1453,6 @@ public class PublishFormFragment extends BaseFragment implements
"-pix_fmt yuv420p " +
"-maxrate 5000K -bufsize 5000K " +
"-movflags +faststart \"%s\"", filePath, scaleFlag, outputFilePath) : movFlagsCommand;
android.util.Log.d("#HELP", command);
Config.enableStatisticsCallback(new StatisticsCallback() {
@Override

View file

@ -1,5 +1,6 @@
package io.lbry.browser.ui.verification;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -95,7 +96,8 @@ public class EmailVerificationFragment extends Fragment {
private void addEmail() {
currentEmail = Helper.getValue(inputEmail.getText());
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;
}
@ -125,7 +127,8 @@ public class EmailVerificationFragment extends Fragment {
@Override
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);
}
});
@ -188,7 +191,8 @@ public class EmailVerificationFragment extends Fragment {
@Override
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);
}
});

View file

@ -74,7 +74,8 @@ public class PhoneVerificationFragment extends Fragment {
currentPhoneNumber = Helper.getValue(inputPhoneNumber.getText());
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;
}
@ -87,7 +88,8 @@ public class PhoneVerificationFragment extends Fragment {
public void onClick(View view) {
String code = Helper.getValue(inputVerificationCode.getText());
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;
}
verifyPhoneNumber(code);
@ -109,8 +111,8 @@ public class PhoneVerificationFragment extends Fragment {
PhoneNewVerifyTask task = new PhoneNewVerifyTask(currentCountryCode, currentPhoneNumber, null, newLoading, new GenericTaskHandler() {
@Override
public void beforeStart() {
continueButton.setEnabled(false);
continueButton.setVisibility(View.GONE);
Helper.setViewEnabled(continueButton, false);
Helper.setViewVisibility(continueButton, View.GONE);
}
@Override
@ -119,18 +121,21 @@ public class PhoneVerificationFragment extends Fragment {
listener.onPhoneAdded(currentCountryCode, currentPhoneNumber);
}
textVerifyParagraph.setText(getString(R.string.enter_phone_verify_code, countryCodePicker.getFullNumberWithPlus()));
layoutCollect.setVisibility(View.GONE);
layoutVerify.setVisibility(View.VISIBLE);
continueButton.setEnabled(true);
continueButton.setVisibility(View.VISIBLE);
Helper.setViewText(textVerifyParagraph, getString(R.string.enter_phone_verify_code, countryCodePicker.getFullNumberWithPlus()));
Helper.setViewVisibility(layoutCollect, View.GONE);
Helper.setViewVisibility(layoutVerify, View.VISIBLE);
Helper.setViewEnabled(continueButton, true);
Helper.setViewVisibility(continueButton, View.VISIBLE);
}
@Override
public void onError(Exception error) {
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).show();
continueButton.setEnabled(true);
continueButton.setVisibility(View.VISIBLE);
if (error != null && getView() != null) {
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
}
Helper.setViewEnabled(continueButton, true);
Helper.setViewVisibility(continueButton, View.VISIBLE);
}
});
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() {
@Override
public void beforeStart() {
verifyButton.setEnabled(false);
editButton.setEnabled(false);
Helper.setViewEnabled(verifyButton, false);
Helper.setViewEnabled(editButton, false);
}
@Override
@ -149,15 +154,18 @@ public class PhoneVerificationFragment extends Fragment {
if (listener != null) {
listener.onPhoneVerified();
}
verifyButton.setEnabled(true);
editButton.setEnabled(true);
Helper.setViewEnabled(verifyButton, true);
Helper.setViewEnabled(editButton, true);
}
@Override
public void onError(Exception error) {
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).show();
verifyButton.setEnabled(true);
editButton.setEnabled(true);
if (getView() != null && error != null) {
Snackbar.make(getView(), error.getMessage(), Snackbar.LENGTH_LONG).
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
}
Helper.setViewEnabled(verifyButton, true);
Helper.setViewEnabled(editButton, true);
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

View file

@ -565,7 +565,8 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
private void showError(String message) {
Context context = getContext();
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();
}
}
}

View file

@ -237,6 +237,11 @@ public class RewardsFragment extends BaseFragment implements RewardListAdapter.R
} catch (IllegalStateException ex) {
// pass
}
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).updateRewardsUsdVale();
}
}
@Override
@ -278,7 +283,8 @@ public class RewardsFragment extends BaseFragment implements RewardListAdapter.R
@Override
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(inputClaimCode, true);
rewardClaimInProgress = false;

View file

@ -198,7 +198,7 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
String amountString = Helper.getValue(inputSendAmount.getText());
if (!recipientAddress.matches(LbryUri.REGEX_ADDRESS)) {
Snackbar.make(getView(), R.string.invalid_recipient_address, Snackbar.LENGTH_LONG).
setBackgroundTint(Color.RED).show();
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
return false;
}
@ -208,13 +208,13 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
double availableAmount = Lbry.walletBalance.getAvailable().doubleValue();
if (availableAmount < amountValue) {
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;
}
} catch (NumberFormatException ex) {
// pass
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;
}
}
@ -390,7 +390,7 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
@Override
public void onError(Exception error) {
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();
}
});

View file

@ -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="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="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">
<item quantity="one">%1$s view</item>
<item quantity="other">%1$s views</item>
@ -390,6 +394,10 @@
<string name="create_a_channel_item">Create a channel...</string>
<string name="edit_channel">Edit channel</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="yes">Yes</string>
<string name="no">No</string>