diff --git a/app/src/main/java/io/lbry/browser/MainActivity.java b/app/src/main/java/io/lbry/browser/MainActivity.java index 5d4832ed..5d0eb20a 100644 --- a/app/src/main/java/io/lbry/browser/MainActivity.java +++ b/app/src/main/java/io/lbry/browser/MainActivity.java @@ -95,6 +95,7 @@ import io.lbry.browser.data.DatabaseHelper; import io.lbry.browser.dialog.ContentScopeDialogFragment; import io.lbry.browser.exceptions.LbryUriException; import io.lbry.browser.listener.CameraPermissionListener; +import io.lbry.browser.listener.DarkThemeChangeListener; import io.lbry.browser.listener.DownloadActionListener; import io.lbry.browser.listener.FetchChannelsListener; import io.lbry.browser.listener.SdkStatusListener; @@ -774,6 +775,9 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener applyNavbarSigninPadding(); checkFirstRun(); checkNowPlaying(); + if (Lbryio.totalUnclaimedRewardAmount > 0) { + showFloatingUnclaimedRewards(); + } // check (and start) the LBRY SDK service serviceRunning = isServiceRunning(this, LbrynetService.class); @@ -962,9 +966,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener public void clearWunderbarFocus(View view) { findViewById(R.id.wunderbar).clearFocus(); - findViewById(R.id.wunderbar_container).requestFocus(); - InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + findViewById(R.id.app_bar_main_container).requestFocus(); } public View getWunderbar() { return findViewById(R.id.wunderbar); @@ -2486,7 +2488,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener return; } - fragment.setRetainInstance(true); + //fragment.setRetainInstance(true); FragmentManager manager = getSupportFragmentManager(); FragmentTransaction transaction = manager.beginTransaction().replace(R.id.content_main, fragment); if (allowNavigateBack) { @@ -2554,6 +2556,16 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener return (ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED); } + public void onThemeChanged() { + FragmentManager manager = getSupportFragmentManager(); + for (int i = 0; i < manager.getFragments().size(); i++) { + Fragment f = manager.getFragments().get(i); + if (f instanceof DarkThemeChangeListener) { + ((DarkThemeChangeListener) f).onDarkThemeToggled(); + } + } + } + public interface BackPressInterceptor { boolean onBackPressed(); } diff --git a/app/src/main/java/io/lbry/browser/adapter/ClaimListAdapter.java b/app/src/main/java/io/lbry/browser/adapter/ClaimListAdapter.java index 75a64bdf..b2ac5c4e 100644 --- a/app/src/main/java/io/lbry/browser/adapter/ClaimListAdapter.java +++ b/app/src/main/java/io/lbry/browser/adapter/ClaimListAdapter.java @@ -92,6 +92,19 @@ public class ClaimListAdapter extends RecyclerView.Adapter -1) { + items.remove(featuredIndex); + } + } + public List getItems() { return new ArrayList<>(this.items); } @@ -325,7 +338,7 @@ public class ClaimListAdapter extends RecyclerView.Adapter tags = getTags(); + if (tags != null && tags.size() > 0) { + for (String tag : tags) { + if (Predefined.MATURE_TAGS.contains(tag.toLowerCase())) { + return true; + } + } + } + return false; + } public String getThumbnailUrl() { if (value != null && value.getThumbnail() != null) { diff --git a/app/src/main/java/io/lbry/browser/tasks/MergeSubscriptionsTask.java b/app/src/main/java/io/lbry/browser/tasks/MergeSubscriptionsTask.java index 2a8df44e..ae9af238 100644 --- a/app/src/main/java/io/lbry/browser/tasks/MergeSubscriptionsTask.java +++ b/app/src/main/java/io/lbry/browser/tasks/MergeSubscriptionsTask.java @@ -109,7 +109,7 @@ public class MergeSubscriptionsTask extends AsyncTask { + private List claimIds; + private List successfulClaimIds; + private List failedClaimIds; + private List failedExceptions; + private View progressView; + private AbandonHandler handler; + + public AbandonStreamTask(List claimIds, View progressView, AbandonHandler handler) { + this.claimIds = claimIds; + this.progressView = progressView; + this.handler = handler; + } + + protected void onPreExecute() { + Helper.setViewVisibility(progressView, View.VISIBLE); + } + + public Boolean doInBackground(Void... params) { + successfulClaimIds = new ArrayList<>(); + failedClaimIds = new ArrayList<>(); + failedExceptions = new ArrayList<>(); + + for (String claimId : claimIds) { + try { + Map options = new HashMap<>(); + options.put("claim_id", claimId); + options.put("blocking", false); + JSONObject result = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_STREAM_ABANDON, options); + android.util.Log.d("#HELP", result.toString()); + successfulClaimIds.add(claimId); + } catch (ApiCallException ex) { + android.util.Log.e("#HELP", ex.getMessage(), ex); + failedClaimIds.add(claimId); + failedExceptions.add(ex); + } + } + + return true; + } + + protected void onPostExecute(Boolean result) { + Helper.setViewVisibility(progressView, View.GONE); + if (handler != null) { + handler.onComplete(successfulClaimIds, failedClaimIds, failedExceptions); + } + } +} diff --git a/app/src/main/java/io/lbry/browser/tasks/wallet/LoadSharedUserStateTask.java b/app/src/main/java/io/lbry/browser/tasks/wallet/LoadSharedUserStateTask.java index 8e4509d6..ac941123 100644 --- a/app/src/main/java/io/lbry/browser/tasks/wallet/LoadSharedUserStateTask.java +++ b/app/src/main/java/io/lbry/browser/tasks/wallet/LoadSharedUserStateTask.java @@ -83,7 +83,7 @@ public class LoadSharedUserStateTask extends AsyncTask { if (db != null) { DatabaseHelper.createOrUpdateSubscription(subscription, db); } - } catch (LbryUriException | SQLiteException ex) { + } catch (LbryUriException | SQLiteException | IllegalStateException ex) { // pass } } diff --git a/app/src/main/java/io/lbry/browser/ui/channel/ChannelManagerFragment.java b/app/src/main/java/io/lbry/browser/ui/channel/ChannelManagerFragment.java index 4f2454e2..eef59baa 100644 --- a/app/src/main/java/io/lbry/browser/ui/channel/ChannelManagerFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/channel/ChannelManagerFragment.java @@ -257,6 +257,7 @@ public class ChannelManagerFragment extends BaseFragment implements ActionMode.C if (R.id.action_delete == menuItem.getItemId()) { if (adapter != null && adapter.getSelectedCount() > 0) { final List selectedClaims = new ArrayList<>(adapter.getSelectedItems()); + android.util.Log.d("#HELP", selectedClaims.toString()); String message = getResources().getQuantityString(R.plurals.confirm_delete_channels, selectedClaims.size()); AlertDialog.Builder builder = new AlertDialog.Builder(getContext()). setTitle(R.string.delete_selection). diff --git a/app/src/main/java/io/lbry/browser/ui/following/FollowingFragment.java b/app/src/main/java/io/lbry/browser/ui/following/FollowingFragment.java index 59988c9e..35748650 100644 --- a/app/src/main/java/io/lbry/browser/ui/following/FollowingFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/following/FollowingFragment.java @@ -37,6 +37,7 @@ import io.lbry.browser.dialog.ContentFromDialogFragment; import io.lbry.browser.dialog.ContentSortDialogFragment; import io.lbry.browser.dialog.DiscoverDialogFragment; import io.lbry.browser.exceptions.LbryUriException; +import io.lbry.browser.listener.DarkThemeChangeListener; import io.lbry.browser.listener.DownloadActionListener; import io.lbry.browser.model.Claim; import io.lbry.browser.model.LbryFile; @@ -58,6 +59,7 @@ import io.lbry.browser.utils.Predefined; public class FollowingFragment extends BaseFragment implements FetchSubscriptionsTask.FetchSubscriptionsHandler, ChannelItemSelectionListener, + DarkThemeChangeListener, DownloadActionListener, SharedPreferences.OnSharedPreferenceChangeListener { @@ -802,4 +804,13 @@ public class FollowingFragment extends BaseFragment implements // invalid file info for download } } + + public void onDarkThemeToggled() { + Helper.refreshRecyclerView(contentList); + Helper.refreshRecyclerView(horizontalChannelList); + Helper.refreshRecyclerView(suggestedChannelGrid); + if (discoverDialog != null) { + //discoverDialog.onDarkThemeToggled(); + } + } } diff --git a/app/src/main/java/io/lbry/browser/ui/other/SettingsFragment.java b/app/src/main/java/io/lbry/browser/ui/other/SettingsFragment.java index 4ac2b59a..9a209b30 100644 --- a/app/src/main/java/io/lbry/browser/ui/other/SettingsFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/other/SettingsFragment.java @@ -40,15 +40,18 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared public void onResume() { super.onResume(); Context context = getContext(); - PreferenceManager.getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(this); if (context instanceof MainActivity) { + PreferenceManager.getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(this); MainActivity activity = (MainActivity) context; LbryAnalytics.setCurrentScreen(activity, "Settings", "Settings"); } } @Override public void onPause() { - PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this); + Context context = getContext(); + if (context != null) { + PreferenceManager.getDefaultSharedPreferences(context).unregisterOnSharedPreferenceChangeListener(this); + } super.onPause(); } @Override @@ -69,9 +72,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared Context context = getContext(); if (context instanceof MainActivity) { - MainActivity activity = (MainActivity) context; - activity.getDelegate().applyDayNight(); - activity.recreate(); + ((MainActivity) context).onThemeChanged(); } } } diff --git a/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java b/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java index 9fe3be47..a2335306 100644 --- a/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java @@ -16,6 +16,8 @@ public class PublishFormFragment extends BaseFragment { ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_publishes, container, false); + + return root; } diff --git a/app/src/main/java/io/lbry/browser/ui/publish/PublishesFragment.java b/app/src/main/java/io/lbry/browser/ui/publish/PublishesFragment.java index 3420f5fa..96d826b5 100644 --- a/app/src/main/java/io/lbry/browser/ui/publish/PublishesFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/publish/PublishesFragment.java @@ -36,6 +36,7 @@ import io.lbry.browser.listener.SelectionModeListener; import io.lbry.browser.model.Claim; import io.lbry.browser.tasks.claim.AbandonChannelTask; 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.ClaimListTask; import io.lbry.browser.ui.BaseFragment; @@ -288,7 +289,7 @@ public class PublishesFragment extends BaseFragment implements ActionMode.Callba Helper.setViewVisibility(contentList, View.INVISIBLE); Helper.setViewVisibility(fabNewPublish, View.INVISIBLE); - AbandonChannelTask task = new AbandonChannelTask(claimIds, bigLoading, new AbandonHandler() { + AbandonStreamTask task = new AbandonStreamTask(claimIds, bigLoading, new AbandonHandler() { @Override public void onComplete(List successfulClaimIds, List failedClaimIds, List errors) { View root = getView(); diff --git a/app/src/main/java/io/lbry/browser/ui/search/SearchFragment.java b/app/src/main/java/io/lbry/browser/ui/search/SearchFragment.java index 6f9a09b1..779ab613 100644 --- a/app/src/main/java/io/lbry/browser/ui/search/SearchFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/search/SearchFragment.java @@ -182,16 +182,26 @@ public class SearchFragment extends BaseFragment implements if (resultListAdapter != null) { Claim unresolved = resultListAdapter.getFeaturedItem(); - // only set the values we need - unresolved.setClaimId(resolved.getClaimId()); - unresolved.setName(resolved.getName()); - unresolved.setTimestamp(resolved.getTimestamp()); - unresolved.setValueType(resolved.getValueType()); - unresolved.setPermanentUrl(resolved.getPermanentUrl()); - unresolved.setValue(resolved.getValue()); - unresolved.setSigningChannel(resolved.getSigningChannel()); - unresolved.setUnresolved(false); - unresolved.setConfirmations(resolved.getConfirmations()); + Context context = getContext(); + boolean canShowMatureContent = false; + if (context != null) { + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); + canShowMatureContent = sp.getBoolean(MainActivity.PREFERENCE_KEY_SHOW_MATURE_CONTENT, false); + } + if (resolved.isMature() && !canShowMatureContent) { + resultListAdapter.removeFeaturedItem(); + } else { + // only set the values we need + unresolved.setClaimId(resolved.getClaimId()); + unresolved.setName(resolved.getName()); + unresolved.setTimestamp(resolved.getTimestamp()); + unresolved.setValueType(resolved.getValueType()); + unresolved.setPermanentUrl(resolved.getPermanentUrl()); + unresolved.setValue(resolved.getValue()); + unresolved.setSigningChannel(resolved.getSigningChannel()); + unresolved.setUnresolved(false); + unresolved.setConfirmations(resolved.getConfirmations()); + } resultListAdapter.notifyDataSetChanged(); } diff --git a/app/src/main/java/io/lbry/browser/utils/Helper.java b/app/src/main/java/io/lbry/browser/utils/Helper.java index edca68fe..19e428a3 100644 --- a/app/src/main/java/io/lbry/browser/utils/Helper.java +++ b/app/src/main/java/io/lbry/browser/utils/Helper.java @@ -19,11 +19,15 @@ import android.provider.DocumentsContract; import android.provider.MediaStore; import android.text.method.LinkMovementMethod; import android.view.View; +import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; import androidx.core.content.ContextCompat; import androidx.core.text.HtmlCompat; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import org.json.JSONArray; import org.json.JSONException; @@ -685,4 +689,26 @@ public final class Helper { public static int getScaledValue(int value, float scale) { return (int) (value * scale + 0.5f); } + + public static void refreshRecyclerView(RecyclerView rv) { + if (rv == null) { + android.util.Log.d("#HELP", "rv is null?"); + return; + } + + android.util.Log.d("#HELP", "Refereshing recycler view..."); + RecyclerView.Adapter adapter = rv.getAdapter(); + int prevScrollPosition = 0; + + RecyclerView.LayoutManager lm = rv.getLayoutManager(); + if (lm instanceof LinearLayoutManager) { + prevScrollPosition = ((LinearLayoutManager) lm).findLastCompletelyVisibleItemPosition(); + } else if (lm instanceof GridLayoutManager) { + prevScrollPosition = ((GridLayoutManager) lm).findLastCompletelyVisibleItemPosition(); + } + + rv.setAdapter(null); + rv.setAdapter(adapter); + rv.scrollToPosition(prevScrollPosition > 0 ? prevScrollPosition : 0); + } } diff --git a/app/src/main/java/io/lbry/browser/utils/Lbry.java b/app/src/main/java/io/lbry/browser/utils/Lbry.java index b5397f79..1e6e2c9f 100644 --- a/app/src/main/java/io/lbry/browser/utils/Lbry.java +++ b/app/src/main/java/io/lbry/browser/utils/Lbry.java @@ -91,7 +91,9 @@ public final class Lbry { public static final String METHOD_CHANNEL_CREATE = "channel_create"; public static final String METHOD_CHANNEL_UPDATE = "channel_update"; + public static final String METHOD_CLAIM_LIST = "claim_list"; + public static final String METHOD_STREAM_ABANDON = "stream_abandon"; public static final String METHOD_STREAM_REPOST = "stream_repost"; public static KeyStore KEYSTORE; diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index 44fd8b9e..212efa4c 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -7,6 +7,8 @@ android:layout_height="match_parent" android:fitsSystemWindows="true" android:background="@color/white" + android:focusable="true" + android:focusableInTouchMode="true" tools:context=".MainActivity"> + + + + + - + + android:layout_height="match_parent" + android:background="@color/pageBackground"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 74026d86..59546685 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -35,7 +35,7 @@ #329A7E #77D510B8 - #454545 + #292929 #0A0A0A #CCCCCC diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 698db218..6660284a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -102,6 +102,7 @@ LBRY requires access to be able to display and publish your videos, images and other files from your device. LBRY requires access to your camera to record videos. LBRY requires access to your camera to take photos. + Mature tags One or more content items could not be deleted at this time. Please try again later.