diff --git a/app/build.gradle b/app/build.gradle index e24761a..f7abd53 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -84,8 +84,8 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' - __32bitImplementation files('libs/lbrysdk-0.67.1-release__arm.aar') - __64bitImplementation files('libs/lbrysdk-0.67.1-release__arm64.aar') + __32bitImplementation files('libs/lbrysdk-0.71.0-release__arm.aar') + __64bitImplementation files('libs/lbrysdk-0.71.0-release__arm64.aar') } apply plugin: 'com.google.gms.google-services' diff --git a/app/libs/lbrysdk-0.67.1-release__arm.aar b/app/libs/lbrysdk-0.71.0-release__arm.aar similarity index 69% rename from app/libs/lbrysdk-0.67.1-release__arm.aar rename to app/libs/lbrysdk-0.71.0-release__arm.aar index 5c71ef4..b23902d 100644 Binary files a/app/libs/lbrysdk-0.67.1-release__arm.aar and b/app/libs/lbrysdk-0.71.0-release__arm.aar differ diff --git a/app/libs/lbrysdk-0.67.1-release__arm64.aar b/app/libs/lbrysdk-0.71.0-release__arm64.aar similarity index 71% rename from app/libs/lbrysdk-0.67.1-release__arm64.aar rename to app/libs/lbrysdk-0.71.0-release__arm64.aar index e958b02..32e3701 100644 Binary files a/app/libs/lbrysdk-0.67.1-release__arm64.aar and b/app/libs/lbrysdk-0.71.0-release__arm64.aar differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fdb6230..7f3fdc2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -29,9 +29,15 @@ android:windowSoftInputMode="adjustResize"> - + + + + + + + params = new HashMap<>(); - params.put("url", claim.getPermanentUrl()); + params.put("url", !Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl()); params.put("claim", getCachedClaimForUrl(claim.getPermanentUrl())); openFragment(ChannelFragment.class, true, NavMenuItem.ID_ITEM_FOLLOWING, params); - setWunderbarValue(claim.getShortUrl()); } public void openChannelUrl(String url) { @@ -387,7 +389,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener params.put("url", url); params.put("claim", getCachedClaimForUrl(url)); openFragment(ChannelFragment.class, true, NavMenuItem.ID_ITEM_FOLLOWING, params); - setWunderbarValue(url); // TODO: Move this to fragment onResume } private Claim getCachedClaimForUrl(String url) { @@ -447,6 +448,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener private void renderPictureInPictureMode() { findViewById(R.id.content_main).setVisibility(View.GONE); + findViewById(R.id.floating_balance_main_container).setVisibility(View.GONE); findViewById(R.id.global_now_playing_card).setVisibility(View.GONE); getSupportActionBar().hide(); @@ -457,6 +459,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener private void renderFullMode() { getSupportActionBar().show(); findViewById(R.id.content_main).setVisibility(View.VISIBLE); + findViewById(R.id.floating_balance_main_container).setVisibility(View.VISIBLE); findViewById(R.id.global_now_playing_card).setVisibility(View.VISIBLE); PlayerView pipPlayer = findViewById(R.id.pip_player); @@ -573,6 +576,10 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener findViewById(R.id.wunderbar).setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { + if (hasFocus) { + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(view, 0); + } toggleUrlSuggestions(hasFocus); if (hasFocus && Helper.isNullOrEmpty(Helper.getValue(((EditText) view).getText()))) { displayUrlSuggestionsForNoInput(); @@ -707,6 +714,9 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener List defaultSuggestions = buildDefaultSuggestions(text); urlSuggestionListAdapter.addUrlSuggestions(defaultSuggestions); + if (LbryUri.PROTO_DEFAULT.equalsIgnoreCase(text)) { + return; + } LighthouseAutoCompleteTask task = new LighthouseAutoCompleteTask(text, null, new LighthouseAutoCompleteTask.AutoCompleteResultHandler() { @Override @@ -753,6 +763,10 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener private List buildDefaultSuggestions(String text) { List suggestions = new ArrayList(); + if (LbryUri.PROTO_DEFAULT.equalsIgnoreCase(text)) { + return buildDefaultSuggestionsForBlankUrl(); + } + // First item is always search if (!text.startsWith(LbryUri.PROTO_DEFAULT)) { UrlSuggestion searchSuggestion = new UrlSuggestion(UrlSuggestion.TYPE_SEARCH, text); @@ -760,28 +774,45 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener } if (!text.matches(LbryUri.REGEX_INVALID_URI)) { + boolean isUrlWithScheme = text.startsWith(LbryUri.PROTO_DEFAULT); boolean isChannel = text.startsWith("@"); + LbryUri uri = null; + if (isUrlWithScheme && text.length() > 7) { + try { + uri = LbryUri.parse(text); + isChannel = uri.isChannel(); + } catch (LbryUriException ex) { + // pass + } + } + if (!isChannel) { - LbryUri uri = new LbryUri(); - uri.setStreamName(text); + if (uri == null) { + uri = new LbryUri(); + uri.setStreamName(text); + } UrlSuggestion fileSuggestion = new UrlSuggestion(UrlSuggestion.TYPE_FILE, text); fileSuggestion.setUri(uri); suggestions.add(fileSuggestion); } if (text.indexOf(' ') == -1) { - // channels and tags should not contain spaces + // channels should not contain spaces if (isChannel) { - LbryUri uri = new LbryUri(); - uri.setChannelName(text); + if (uri == null) { + uri = new LbryUri(); + uri.setChannelName(text); + } UrlSuggestion suggestion = new UrlSuggestion(UrlSuggestion.TYPE_CHANNEL, text); suggestion.setUri(uri); suggestions.add(suggestion); - } else { - UrlSuggestion suggestion = new UrlSuggestion(UrlSuggestion.TYPE_TAG, text); - suggestions.add(suggestion); } } + + if (!isUrlWithScheme) { + UrlSuggestion suggestion = new UrlSuggestion(UrlSuggestion.TYPE_TAG, text); + suggestions.add(suggestion); + } } return suggestions; @@ -843,7 +874,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener Base64.decode(encryptedAuthToken, Base64.NO_WRAP), this, Lbry.KEYSTORE), "UTF8"); } catch (Exception ex) { // pass. A new auth token would have to be generated if the old one cannot be decrypted - android.util.Log.e(TAG, "Could not decrypt existing auth token.", ex); + Log.e(TAG, "Could not decrypt existing auth token.", ex); } } } @@ -1328,11 +1359,38 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener loadLastFragment(); showSignedInUser(); + checkUrlIntent(getIntent()); appStarted = true; } }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } + private void checkUrlIntent(Intent intent) { + if (intent != null) { + Uri data = intent.getData(); + if (data != null) { + String url = data.toString(); + // check special urls + if (url.startsWith("lbry://?")) { + String pagePath = url.substring(8); + + // TODO: Handle special page paths + } else { + try { + LbryUri uri = LbryUri.parse(url); + if (uri.isChannel()) { + openChannelUrl(uri.toString()); + } else { + openFileUrl(uri.toString(), this); + } + } catch (LbryUriException ex) { + // pass + } + } + } + } + } + private void loadLastFragment() { Fragment fragment = getCurrentFragment(); @@ -1663,7 +1721,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener Fragment fragment = openNavFragments.containsKey(key) ? openNavFragments.get(key) : (Fragment) fragmentClass.newInstance(); if (fragment instanceof BaseFragment) { ((BaseFragment) fragment).setParams(params); - } + } Fragment currentFragment = getCurrentFragment(); if (currentFragment != null && currentFragment.equals(fragment)) { return; diff --git a/app/src/main/java/io/lbry/browser/ui/allcontent/AllContentFragment.java b/app/src/main/java/io/lbry/browser/ui/allcontent/AllContentFragment.java index d69194e..aa6dd83 100644 --- a/app/src/main/java/io/lbry/browser/ui/allcontent/AllContentFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/allcontent/AllContentFragment.java @@ -359,6 +359,7 @@ public class AllContentFragment extends BaseFragment implements SharedPreference public void onResume() { super.onResume(); + Helper.setWunderbarValue(null, getContext()); PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this); updateContentFromLinkText(); updateContentScopeLinkText(); diff --git a/app/src/main/java/io/lbry/browser/ui/channel/ChannelFragment.java b/app/src/main/java/io/lbry/browser/ui/channel/ChannelFragment.java index d08be4f..6f7a5a6 100644 --- a/app/src/main/java/io/lbry/browser/ui/channel/ChannelFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/channel/ChannelFragment.java @@ -203,6 +203,9 @@ public class ChannelFragment extends BaseFragment { public void onResume() { super.onResume(); + Map params = getParams(); + String url = params != null && params.containsKey("url") ? (String) params.get("url") : null; + Helper.setWunderbarValue(url, getContext()); checkParams(); } diff --git a/app/src/main/java/io/lbry/browser/ui/editorschoice/EditorsChoiceFragment.java b/app/src/main/java/io/lbry/browser/ui/editorschoice/EditorsChoiceFragment.java index 914dea7..20b7b44 100644 --- a/app/src/main/java/io/lbry/browser/ui/editorschoice/EditorsChoiceFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/editorschoice/EditorsChoiceFragment.java @@ -81,6 +81,7 @@ public class EditorsChoiceFragment extends BaseFragment { public void onResume() { super.onResume(); + Helper.setWunderbarValue(null, getContext()); if (contentListAdapter == null || contentListAdapter.getItemCount() == 0) { fetchClaimSearchContent(); } else { 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 756657c..b4e8db4 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 @@ -326,6 +326,7 @@ public class FollowingFragment extends BaseFragment implements public void onResume() { super.onResume(); + Helper.setWunderbarValue(null, getContext()); PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this); // check if subscriptions exist 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 052ec91..a1f9247 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 @@ -86,6 +86,7 @@ public class SearchFragment extends BaseFragment implements public void onResume() { super.onResume(); + Helper.setWunderbarValue(currentQuery, getContext()); PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this); if (!Helper.isNullOrEmpty(currentQuery)) { search(currentQuery, currentFrom); diff --git a/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java b/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java index f631dfb..d7680ce 100644 --- a/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java @@ -219,6 +219,15 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W recentTransactionsList.setLayoutManager(llm); recentTransactionsList.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); + buttonSignUp.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Context context = getContext(); + if (context instanceof MainActivity) { + ((MainActivity) context).walletSyncSignIn(); + } + } + }); buttonGetNewAddress.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -392,6 +401,7 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W public void onResume() { super.onResume(); + Helper.setWunderbarValue(null, getContext()); if (!Lbry.SDK_READY) { Context context = getContext(); if (context instanceof MainActivity) { @@ -415,6 +425,7 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W Context context = getContext(); if (context instanceof MainActivity) { MainActivity activity = (MainActivity) context; + activity.setWunderbarValue(null); activity.hideFloatingWalletBalance(); } } 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 5892618..1f59627 100644 --- a/app/src/main/java/io/lbry/browser/utils/Helper.java +++ b/app/src/main/java/io/lbry/browser/utils/Helper.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.Map; import java.util.Random; +import io.lbry.browser.MainActivity; import io.lbry.browser.dialog.ContentFromDialogFragment; import io.lbry.browser.dialog.ContentSortDialogFragment; import io.lbry.browser.model.Claim; @@ -324,4 +325,10 @@ public final class Helper { } return followedTags; } + + public static void setWunderbarValue(String value, Context context) { + if (context instanceof MainActivity) { + ((MainActivity) context).setWunderbarValue(value); + } + } } diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index f91a2d0..35955a6 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -29,16 +29,17 @@ + android:textSize="14sp" />