Merge branch 'master' of https://github.com/lbryio/lbry-android
This commit is contained in:
commit
0ae0614231
3 changed files with 43 additions and 31 deletions
|
@ -1,5 +1,6 @@
|
||||||
package io.lbry.browser;
|
package io.lbry.browser;
|
||||||
|
|
||||||
|
import android.animation.ObjectAnimator;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
@ -771,6 +772,20 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
walletBalanceListeners.remove(listener);
|
walletBalanceListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void restoreWalletContainerPosition() {
|
||||||
|
View floatingBalance = findViewById(R.id.floating_balance_main_container);
|
||||||
|
|
||||||
|
ObjectAnimator animation = ObjectAnimator.ofFloat(floatingBalance, "translationY", 0f);
|
||||||
|
animation.setDuration(250).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void translateFloatingWallet(float initialY) {
|
||||||
|
if (findViewById(R.id.floating_balance_main_container).getY() == initialY) {
|
||||||
|
ObjectAnimator animation = ObjectAnimator.ofFloat(findViewById(R.id.floating_balance_main_container), "translationY", 2 * findViewById(R.id.floating_balance_main_container).getHeight());
|
||||||
|
animation.setDuration(300).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void removeNavFragment(Class fragmentClass, int navItemId) {
|
public void removeNavFragment(Class fragmentClass, int navItemId) {
|
||||||
String key = buildNavFragmentKey(fragmentClass, navItemId, null);
|
String key = buildNavFragmentKey(fragmentClass, navItemId, null);
|
||||||
if (openNavFragments.containsKey(key)) {
|
if (openNavFragments.containsKey(key)) {
|
||||||
|
|
|
@ -2,24 +2,16 @@ package io.lbry.browser.tasks.wallet;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import io.lbry.browser.exceptions.ApiCallException;
|
import io.lbry.browser.exceptions.ApiCallException;
|
||||||
import io.lbry.browser.model.WalletBalance;
|
|
||||||
import io.lbry.browser.tasks.GenericTaskHandler;
|
import io.lbry.browser.tasks.GenericTaskHandler;
|
||||||
import io.lbry.browser.utils.Helper;
|
|
||||||
import io.lbry.browser.utils.Lbry;
|
import io.lbry.browser.utils.Lbry;
|
||||||
|
|
||||||
public class UnlockTipsTask extends AsyncTask<Void, Void, Boolean> {
|
public class UnlockTipsTask extends AsyncTask<Void, Void, Boolean> {
|
||||||
|
|
||||||
private GenericTaskHandler handler;
|
private final GenericTaskHandler handler;
|
||||||
private Exception error;
|
private Exception error;
|
||||||
|
|
||||||
public UnlockTipsTask(GenericTaskHandler handler) {
|
public UnlockTipsTask(GenericTaskHandler handler) {
|
||||||
|
@ -27,35 +19,16 @@ public class UnlockTipsTask extends AsyncTask<Void, Void, Boolean> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean doInBackground(Void... params) {
|
public Boolean doInBackground(Void... params) {
|
||||||
|
|
||||||
List<String> txids = new ArrayList<>();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<String, Object> options = new HashMap<>();
|
Map<String, Object> options = new HashMap<>();
|
||||||
options.put("type", "support");
|
options.put("type", "support");
|
||||||
options.put("is_not_my_input", true);
|
options.put("is_not_my_input", true);
|
||||||
options.put("is_my_output", true);
|
options.put("blocking", true);
|
||||||
JSONObject result = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_TXO_LIST, options);
|
|
||||||
if (result.has("items") && !result.isNull("items")) {
|
|
||||||
JSONArray items = result.getJSONArray("items");
|
|
||||||
for (int i = 0; i < items.length(); i++) {
|
|
||||||
JSONObject item = items.getJSONObject(i);
|
|
||||||
String txid = Helper.getJSONString("txid", null, item);
|
|
||||||
if (!Helper.isNullOrEmpty(txid)) {
|
|
||||||
txids.add(txid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (txids.size() > 0) {
|
Lbry.genericApiCall(Lbry.METHOD_TXO_SPEND, options);
|
||||||
options = new HashMap<>();
|
|
||||||
options.put("txid", txids);
|
|
||||||
options.put("blocking", true);
|
|
||||||
Lbry.genericApiCall(Lbry.METHOD_TXO_SPEND, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (ApiCallException | ClassCastException | JSONException ex) {
|
} catch (ApiCallException | ClassCastException ex) {
|
||||||
error = ex;
|
error = ex;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,6 +246,8 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
// if this is set, scroll to the specific comment on load
|
// if this is set, scroll to the specific comment on load
|
||||||
private String commentHash;
|
private String commentHash;
|
||||||
|
|
||||||
|
private float floatingWalletPositionY;
|
||||||
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||||
ViewGroup container, Bundle savedInstanceState) {
|
ViewGroup container, Bundle savedInstanceState) {
|
||||||
View root = inflater.inflate(R.layout.fragment_file_view, container, false);
|
View root = inflater.inflate(R.layout.fragment_file_view, container, false);
|
||||||
|
@ -801,6 +803,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
activity.removeSdkStatusListener(this);
|
activity.removeSdkStatusListener(this);
|
||||||
activity.removeStoragePermissionListener(this);
|
activity.removeStoragePermissionListener(this);
|
||||||
activity.removeWalletBalanceListener(this);
|
activity.removeWalletBalanceListener(this);
|
||||||
|
activity.restoreWalletContainerPosition();
|
||||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1274,6 +1277,27 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
buttonUnfollow.setOnClickListener(followUnfollowListener);
|
buttonUnfollow.setOnClickListener(followUnfollowListener);
|
||||||
buttonBell.setOnClickListener(bellIconListener);
|
buttonBell.setOnClickListener(bellIconListener);
|
||||||
|
|
||||||
|
NestedScrollView scrollView = root.findViewById(R.id.file_view_scroll_view);
|
||||||
|
|
||||||
|
// Store floating wallet balance vertical position when fragment was created
|
||||||
|
// This is used for animate it when user scrolls to the bottom of the screen
|
||||||
|
View floatingBalance = getActivity().findViewById(R.id.floating_balance_main_container);
|
||||||
|
floatingWalletPositionY = floatingBalance.getY();
|
||||||
|
|
||||||
|
scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
|
||||||
|
Context ctx = getContext();
|
||||||
|
if (scrollY < oldScrollY && ctx instanceof MainActivity) {
|
||||||
|
// User has scrolled upwards
|
||||||
|
((MainActivity) ctx).restoreWalletContainerPosition();
|
||||||
|
} else if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight()) && ctx instanceof MainActivity) {
|
||||||
|
// User is at the bottom of the screen
|
||||||
|
((MainActivity) ctx).translateFloatingWallet(floatingWalletPositionY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
commentChannelSpinnerAdapter = new InlineChannelSpinnerAdapter(getContext(), R.layout.spinner_item_channel, new ArrayList<>());
|
commentChannelSpinnerAdapter = new InlineChannelSpinnerAdapter(getContext(), R.layout.spinner_item_channel, new ArrayList<>());
|
||||||
commentChannelSpinnerAdapter.addPlaceholder(false);
|
commentChannelSpinnerAdapter.addPlaceholder(false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue