2017-08-15 01:38:07 -06:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 m2049r
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.m2049r.xmrwallet;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.os.Bundle;
|
2017-11-21 12:55:31 -07:00
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Looper;
|
2017-09-02 02:05:50 -06:00
|
|
|
import android.support.annotation.Nullable;
|
2017-08-30 17:00:27 -06:00
|
|
|
import android.support.v4.app.Fragment;
|
2017-08-15 01:38:07 -06:00
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
|
import android.view.LayoutInflater;
|
2017-09-02 02:05:50 -06:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuInflater;
|
2017-08-15 01:38:07 -06:00
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2017-10-31 15:35:23 -06:00
|
|
|
import android.widget.AdapterView;
|
|
|
|
import android.widget.ArrayAdapter;
|
2017-08-18 05:51:24 -06:00
|
|
|
import android.widget.Button;
|
2017-10-31 15:35:23 -06:00
|
|
|
import android.widget.FrameLayout;
|
|
|
|
import android.widget.ImageView;
|
2017-08-15 01:38:07 -06:00
|
|
|
import android.widget.ProgressBar;
|
2017-10-31 15:35:23 -06:00
|
|
|
import android.widget.Spinner;
|
2017-08-15 01:38:07 -06:00
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import com.m2049r.xmrwallet.layout.TransactionInfoAdapter;
|
|
|
|
import com.m2049r.xmrwallet.model.TransactionInfo;
|
|
|
|
import com.m2049r.xmrwallet.model.Wallet;
|
2017-11-21 12:55:31 -07:00
|
|
|
import com.m2049r.xmrwallet.service.exchange.api.ExchangeApi;
|
|
|
|
import com.m2049r.xmrwallet.service.exchange.api.ExchangeCallback;
|
|
|
|
import com.m2049r.xmrwallet.service.exchange.api.ExchangeRate;
|
|
|
|
import com.m2049r.xmrwallet.service.exchange.kraken.ExchangeApiImpl;
|
2017-08-31 01:04:32 -06:00
|
|
|
import com.m2049r.xmrwallet.util.Helper;
|
2017-11-23 00:23:23 -07:00
|
|
|
import com.m2049r.xmrwallet.util.OkHttpClientSingleton;
|
2017-12-03 14:17:28 -07:00
|
|
|
import com.m2049r.xmrwallet.widget.Toolbar;
|
2017-08-15 01:38:07 -06:00
|
|
|
|
2017-08-16 11:39:53 -06:00
|
|
|
import java.text.NumberFormat;
|
2017-08-15 01:38:07 -06:00
|
|
|
import java.util.List;
|
|
|
|
|
2017-11-25 07:49:07 -07:00
|
|
|
import timber.log.Timber;
|
2017-11-21 12:55:31 -07:00
|
|
|
|
2017-10-31 15:35:23 -06:00
|
|
|
public class WalletFragment extends Fragment
|
2017-11-21 12:55:31 -07:00
|
|
|
implements TransactionInfoAdapter.OnInteractionListener {
|
2017-08-15 01:38:07 -06:00
|
|
|
private TransactionInfoAdapter adapter;
|
2017-08-16 11:39:53 -06:00
|
|
|
private NumberFormat formatter = NumberFormat.getInstance();
|
2017-08-15 01:38:07 -06:00
|
|
|
|
2017-11-01 12:47:24 -06:00
|
|
|
private FrameLayout flExchange;
|
|
|
|
private TextView tvBalance;
|
|
|
|
private TextView tvUnconfirmedAmount;
|
|
|
|
private TextView tvProgress;
|
|
|
|
private ImageView ivSynced;
|
|
|
|
private ProgressBar pbProgress;
|
|
|
|
private Button bReceive;
|
|
|
|
private Button bSend;
|
2017-08-18 05:51:24 -06:00
|
|
|
|
2017-11-01 12:47:24 -06:00
|
|
|
private Spinner sCurrency;
|
2017-10-31 15:35:23 -06:00
|
|
|
|
2017-09-02 02:05:50 -06:00
|
|
|
@Override
|
|
|
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setHasOptionsMenu(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
|
if (activityCallback.hasWallet())
|
2017-09-08 15:59:50 -06:00
|
|
|
inflater.inflate(R.menu.wallet_menu, menu);
|
2017-09-02 02:05:50 -06:00
|
|
|
super.onCreateOptionsMenu(menu, inflater);
|
|
|
|
}
|
|
|
|
|
2017-08-15 01:38:07 -06:00
|
|
|
@Override
|
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
|
Bundle savedInstanceState) {
|
2017-10-31 15:35:23 -06:00
|
|
|
View view = inflater.inflate(R.layout.fragment_wallet, container, false);
|
|
|
|
|
|
|
|
flExchange = (FrameLayout) view.findViewById(R.id.flExchange);
|
|
|
|
((ProgressBar) view.findViewById(R.id.pbExchange)).getIndeterminateDrawable().
|
|
|
|
setColorFilter(getResources().getColor(R.color.trafficGray),
|
|
|
|
android.graphics.PorterDuff.Mode.MULTIPLY);
|
2017-08-15 01:38:07 -06:00
|
|
|
|
2017-08-18 05:51:24 -06:00
|
|
|
tvProgress = (TextView) view.findViewById(R.id.tvProgress);
|
|
|
|
pbProgress = (ProgressBar) view.findViewById(R.id.pbProgress);
|
|
|
|
tvBalance = (TextView) view.findViewById(R.id.tvBalance);
|
2017-10-31 15:35:23 -06:00
|
|
|
tvBalance.setText(Helper.getDisplayAmount(0));
|
2017-08-23 14:55:47 -06:00
|
|
|
tvUnconfirmedAmount = (TextView) view.findViewById(R.id.tvUnconfirmedAmount);
|
2017-09-08 15:59:50 -06:00
|
|
|
tvUnconfirmedAmount.setText(getResources().getString(R.string.xmr_unconfirmed_amount, Helper.getDisplayAmount(0)));
|
2017-10-31 15:35:23 -06:00
|
|
|
ivSynced = (ImageView) view.findViewById(R.id.ivSynced);
|
|
|
|
|
|
|
|
sCurrency = (Spinner) view.findViewById(R.id.sCurrency);
|
2017-11-03 03:14:19 -06:00
|
|
|
sCurrency.setAdapter(ArrayAdapter.createFromResource(getContext(), R.array.currency, R.layout.item_spinner_balance));
|
2017-08-19 05:27:26 -06:00
|
|
|
|
|
|
|
bSend = (Button) view.findViewById(R.id.bSend);
|
2017-10-31 15:35:23 -06:00
|
|
|
bReceive = (Button) view.findViewById(R.id.bReceive);
|
2017-08-18 05:51:24 -06:00
|
|
|
|
2017-08-15 01:38:07 -06:00
|
|
|
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
|
|
|
|
|
2017-09-08 15:59:50 -06:00
|
|
|
this.adapter = new TransactionInfoAdapter(getActivity(), this);
|
2017-08-15 01:38:07 -06:00
|
|
|
recyclerView.setAdapter(adapter);
|
|
|
|
|
2017-10-31 15:35:23 -06:00
|
|
|
bSend.setOnClickListener(new View.OnClickListener() {
|
2017-08-18 05:51:24 -06:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
activityCallback.onSendRequest();
|
|
|
|
}
|
|
|
|
});
|
2017-10-31 15:35:23 -06:00
|
|
|
bReceive.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
activityCallback.onWalletReceive();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
sCurrency.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
|
@Override
|
|
|
|
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
|
|
|
|
refreshBalance();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onNothingSelected(AdapterView<?> parentView) {
|
|
|
|
// nothing (yet?)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-08-19 05:27:26 -06:00
|
|
|
if (activityCallback.isSynced()) {
|
|
|
|
onSynced();
|
|
|
|
}
|
|
|
|
|
2017-08-18 05:51:24 -06:00
|
|
|
activityCallback.forceUpdate();
|
|
|
|
|
2017-08-15 01:38:07 -06:00
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
2017-11-21 12:55:31 -07:00
|
|
|
void updateBalance() {
|
|
|
|
if (isExchanging) return; // wait for exchange to finish - it will fire this itself then.
|
|
|
|
// at this point selection is XMR in case of error
|
|
|
|
String displayB;
|
2017-11-23 00:23:23 -07:00
|
|
|
double amountA = Double.parseDouble(Wallet.getDisplayAmount(unlockedBalance)); // crash if this fails!
|
2017-11-21 12:55:31 -07:00
|
|
|
if (!"XMR".equals(balanceCurrency)) { // not XMR
|
|
|
|
double amountB = amountA * balanceRate;
|
|
|
|
displayB = Helper.getFormattedAmount(amountB, false);
|
|
|
|
} else { // XMR
|
|
|
|
displayB = Helper.getFormattedAmount(amountA, true);
|
|
|
|
}
|
|
|
|
tvBalance.setText(displayB);
|
|
|
|
}
|
|
|
|
|
2017-10-31 15:35:23 -06:00
|
|
|
String balanceCurrency = "XMR";
|
|
|
|
double balanceRate = 1.0;
|
|
|
|
|
2017-11-23 00:23:23 -07:00
|
|
|
private final ExchangeApi exchangeApi = new ExchangeApiImpl(OkHttpClientSingleton.getOkHttpClient());
|
2017-11-21 12:55:31 -07:00
|
|
|
|
2017-10-31 15:35:23 -06:00
|
|
|
void refreshBalance() {
|
|
|
|
if (sCurrency.getSelectedItemPosition() == 0) { // XMR
|
|
|
|
double amountXmr = Double.parseDouble(Wallet.getDisplayAmount(unlockedBalance)); // assume this cannot fail!
|
|
|
|
tvBalance.setText(Helper.getFormattedAmount(amountXmr, true));
|
|
|
|
} else { // not XMR
|
|
|
|
String currency = (String) sCurrency.getSelectedItem();
|
|
|
|
if (!currency.equals(balanceCurrency) || (balanceRate <= 0)) {
|
|
|
|
showExchanging();
|
2017-11-21 12:55:31 -07:00
|
|
|
exchangeApi.queryExchangeRate("XMR", currency,
|
|
|
|
new ExchangeCallback() {
|
|
|
|
@Override
|
|
|
|
public void onSuccess(final ExchangeRate exchangeRate) {
|
|
|
|
if (isAdded())
|
|
|
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
exchange(exchangeRate);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onError(final Exception e) {
|
2017-11-25 07:49:07 -07:00
|
|
|
Timber.e(e.getLocalizedMessage());
|
2017-11-21 12:55:31 -07:00
|
|
|
if (isAdded())
|
|
|
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
exchangeFailed();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2017-10-31 15:35:23 -06:00
|
|
|
} else {
|
2017-11-21 12:55:31 -07:00
|
|
|
updateBalance();
|
2017-10-31 15:35:23 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean isExchanging = false;
|
|
|
|
|
|
|
|
void showExchanging() {
|
|
|
|
isExchanging = true;
|
|
|
|
tvBalance.setVisibility(View.GONE);
|
|
|
|
flExchange.setVisibility(View.VISIBLE);
|
2017-11-21 12:55:31 -07:00
|
|
|
sCurrency.setEnabled(false);
|
2017-10-31 15:35:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void hideExchanging() {
|
|
|
|
isExchanging = false;
|
|
|
|
tvBalance.setVisibility(View.VISIBLE);
|
|
|
|
flExchange.setVisibility(View.GONE);
|
2017-11-21 12:55:31 -07:00
|
|
|
sCurrency.setEnabled(true);
|
2017-10-31 15:35:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
public void exchangeFailed() {
|
|
|
|
sCurrency.setSelection(0, true); // default to XMR
|
|
|
|
double amountXmr = Double.parseDouble(Wallet.getDisplayAmount(unlockedBalance)); // assume this cannot fail!
|
|
|
|
tvBalance.setText(Helper.getFormattedAmount(amountXmr, true));
|
|
|
|
hideExchanging();
|
|
|
|
}
|
|
|
|
|
2017-11-21 12:55:31 -07:00
|
|
|
public void exchange(final ExchangeRate exchangeRate) {
|
2017-10-31 15:35:23 -06:00
|
|
|
hideExchanging();
|
2017-11-21 12:55:31 -07:00
|
|
|
if (!"XMR".equals(exchangeRate.getBaseCurrency())) {
|
2017-11-25 07:49:07 -07:00
|
|
|
Timber.e("Not XMR");
|
2017-10-31 15:35:23 -06:00
|
|
|
sCurrency.setSelection(0, true);
|
|
|
|
balanceCurrency = "XMR";
|
|
|
|
balanceRate = 1.0;
|
|
|
|
} else {
|
2017-11-21 12:55:31 -07:00
|
|
|
int spinnerPosition = ((ArrayAdapter) sCurrency.getAdapter()).getPosition(exchangeRate.getQuoteCurrency());
|
2017-10-31 15:35:23 -06:00
|
|
|
if (spinnerPosition < 0) { // requested currency not in list
|
2017-11-25 07:49:07 -07:00
|
|
|
Timber.e("Requested currency not in list %s", exchangeRate.getQuoteCurrency());
|
2017-10-31 15:35:23 -06:00
|
|
|
sCurrency.setSelection(0, true);
|
|
|
|
} else {
|
|
|
|
sCurrency.setSelection(spinnerPosition, true);
|
|
|
|
}
|
2017-11-21 12:55:31 -07:00
|
|
|
balanceCurrency = exchangeRate.getQuoteCurrency();
|
|
|
|
balanceRate = exchangeRate.getRate();
|
2017-10-31 15:35:23 -06:00
|
|
|
}
|
|
|
|
updateBalance();
|
|
|
|
}
|
|
|
|
|
2017-08-15 01:38:07 -06:00
|
|
|
// Callbacks from TransactionInfoAdapter
|
|
|
|
@Override
|
|
|
|
public void onInteraction(final View view, final TransactionInfo infoItem) {
|
2017-08-19 11:40:48 -06:00
|
|
|
activityCallback.onTxDetailsRequest(infoItem);
|
2017-08-15 01:38:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// called from activity
|
2017-10-31 15:35:23 -06:00
|
|
|
|
2017-08-15 01:38:07 -06:00
|
|
|
public void onRefreshed(final Wallet wallet, final boolean full) {
|
2017-11-25 07:49:07 -07:00
|
|
|
Timber.d("onRefreshed()");
|
2017-08-15 01:38:07 -06:00
|
|
|
if (full) {
|
|
|
|
List<TransactionInfo> list = wallet.getHistory().getAll();
|
|
|
|
adapter.setInfos(list);
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
updateStatus(wallet);
|
|
|
|
}
|
|
|
|
|
2017-08-20 08:18:59 -06:00
|
|
|
public void onSynced() {
|
2017-08-29 14:22:07 -06:00
|
|
|
if (!activityCallback.isWatchOnly()) {
|
2017-08-19 08:20:10 -06:00
|
|
|
bSend.setVisibility(View.VISIBLE);
|
|
|
|
bSend.setEnabled(true);
|
|
|
|
}
|
2017-08-19 05:27:26 -06:00
|
|
|
}
|
|
|
|
|
2017-11-04 08:31:34 -06:00
|
|
|
boolean walletLoaded = false;
|
|
|
|
|
|
|
|
public void onLoaded() {
|
|
|
|
walletLoaded = true;
|
|
|
|
showReceive();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showReceive() {
|
|
|
|
if (walletLoaded) {
|
|
|
|
bReceive.setVisibility(View.VISIBLE);
|
|
|
|
bReceive.setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-08 15:04:01 -07:00
|
|
|
private String syncText = null;
|
|
|
|
|
|
|
|
public void setProgress(final String text) {
|
|
|
|
syncText = text;
|
2017-10-31 15:35:23 -06:00
|
|
|
tvProgress.setText(text);
|
|
|
|
}
|
|
|
|
|
2017-11-08 15:04:01 -07:00
|
|
|
private int syncProgress = -1;
|
2017-08-15 01:38:07 -06:00
|
|
|
|
2017-11-08 15:04:01 -07:00
|
|
|
public void setProgress(final int n) {
|
|
|
|
syncProgress = n;
|
|
|
|
if (n > 100) {
|
|
|
|
pbProgress.setIndeterminate(true);
|
|
|
|
pbProgress.setVisibility(View.VISIBLE);
|
|
|
|
} else if (n >= 0) {
|
2017-08-18 05:51:24 -06:00
|
|
|
pbProgress.setIndeterminate(false);
|
|
|
|
pbProgress.setProgress(n);
|
2017-11-08 15:04:01 -07:00
|
|
|
pbProgress.setVisibility(View.VISIBLE);
|
|
|
|
} else { // <0
|
|
|
|
pbProgress.setVisibility(View.INVISIBLE);
|
2017-08-15 01:38:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-31 15:35:23 -06:00
|
|
|
void setActivityTitle(Wallet wallet) {
|
|
|
|
if (wallet == null) return;
|
|
|
|
walletTitle = wallet.getName();
|
|
|
|
String watchOnly = (wallet.isWatchOnly() ? getString(R.string.label_watchonly) : "");
|
2017-12-22 00:47:12 -07:00
|
|
|
walletSubtitle = wallet.getAddress().substring(0, 10) + "…" + watchOnly;
|
2017-10-31 15:35:23 -06:00
|
|
|
activityCallback.setTitle(walletTitle, walletSubtitle);
|
2017-11-25 07:49:07 -07:00
|
|
|
Timber.d("wallet title is %s", walletTitle);
|
2017-08-15 01:38:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
private long firstBlock = 0;
|
|
|
|
private String walletTitle = null;
|
2017-10-31 15:35:23 -06:00
|
|
|
private String walletSubtitle = null;
|
|
|
|
private long unlockedBalance = 0;
|
2017-08-15 01:38:07 -06:00
|
|
|
|
|
|
|
private void updateStatus(Wallet wallet) {
|
2017-10-03 11:04:45 -06:00
|
|
|
if (!isAdded()) return;
|
2017-11-25 07:49:07 -07:00
|
|
|
Timber.d("updateStatus()");
|
2017-08-15 01:38:07 -06:00
|
|
|
if (walletTitle == null) {
|
2017-10-31 15:35:23 -06:00
|
|
|
setActivityTitle(wallet);
|
2017-08-15 01:38:07 -06:00
|
|
|
}
|
2017-08-23 14:55:47 -06:00
|
|
|
long balance = wallet.getBalance();
|
2017-10-31 15:35:23 -06:00
|
|
|
unlockedBalance = wallet.getUnlockedBalance();
|
|
|
|
refreshBalance();
|
|
|
|
double amountXmr = Double.parseDouble(Helper.getDisplayAmount(balance - unlockedBalance)); // assume this cannot fail!
|
|
|
|
String unconfirmed = Helper.getFormattedAmount(amountXmr, true);
|
|
|
|
tvUnconfirmedAmount.setText(getResources().getString(R.string.xmr_unconfirmed_amount, unconfirmed));
|
2017-08-15 01:38:07 -06:00
|
|
|
String sync = "";
|
|
|
|
if (!activityCallback.hasBoundService())
|
|
|
|
throw new IllegalStateException("WalletService not bound.");
|
|
|
|
Wallet.ConnectionStatus daemonConnected = activityCallback.getConnectionStatus();
|
|
|
|
if (daemonConnected == Wallet.ConnectionStatus.ConnectionStatus_Connected) {
|
|
|
|
long daemonHeight = activityCallback.getDaemonHeight();
|
|
|
|
if (!wallet.isSynchronized()) {
|
|
|
|
long n = daemonHeight - wallet.getBlockChainHeight();
|
2017-11-02 15:48:20 -06:00
|
|
|
sync = getString(R.string.status_syncing) + " " + formatter.format(n) + " " + getString(R.string.status_remaining);
|
2017-08-15 01:38:07 -06:00
|
|
|
if (firstBlock == 0) {
|
|
|
|
firstBlock = wallet.getBlockChainHeight();
|
|
|
|
}
|
|
|
|
int x = 100 - Math.round(100f * n / (1f * daemonHeight - firstBlock));
|
2017-11-08 15:04:01 -07:00
|
|
|
if (x == 0) x = 101; // indeterminate
|
|
|
|
setProgress(x);
|
2017-10-31 15:35:23 -06:00
|
|
|
ivSynced.setVisibility(View.GONE);
|
2017-08-15 01:38:07 -06:00
|
|
|
} else {
|
2018-04-22 03:26:46 -06:00
|
|
|
sync = getString(R.string.status_synced) + " " + formatter.format(wallet.getBlockChainHeight());
|
2017-10-31 15:35:23 -06:00
|
|
|
ivSynced.setVisibility(View.VISIBLE);
|
2017-08-15 01:38:07 -06:00
|
|
|
}
|
2017-11-08 15:04:01 -07:00
|
|
|
} else {
|
|
|
|
sync = getString(R.string.status_wallet_connecting);
|
|
|
|
setProgress(101);
|
2017-08-15 01:38:07 -06:00
|
|
|
}
|
2017-11-08 15:04:01 -07:00
|
|
|
setProgress(sync);
|
2017-08-23 14:55:47 -06:00
|
|
|
// TODO show connected status somewhere
|
2017-08-15 01:38:07 -06:00
|
|
|
}
|
|
|
|
|
2017-08-15 15:59:41 -06:00
|
|
|
Listener activityCallback;
|
2017-08-15 01:38:07 -06:00
|
|
|
|
|
|
|
// Container Activity must implement this interface
|
2017-08-15 15:59:41 -06:00
|
|
|
public interface Listener {
|
2017-08-15 01:38:07 -06:00
|
|
|
boolean hasBoundService();
|
|
|
|
|
2017-08-18 05:51:24 -06:00
|
|
|
void forceUpdate();
|
|
|
|
|
2017-08-15 01:38:07 -06:00
|
|
|
Wallet.ConnectionStatus getConnectionStatus();
|
|
|
|
|
|
|
|
long getDaemonHeight(); //mBoundService.getDaemonHeight();
|
|
|
|
|
2017-08-18 05:51:24 -06:00
|
|
|
void onSendRequest();
|
|
|
|
|
2017-08-19 11:40:48 -06:00
|
|
|
void onTxDetailsRequest(TransactionInfo info);
|
|
|
|
|
2017-08-19 05:27:26 -06:00
|
|
|
boolean isSynced();
|
2017-08-19 08:20:10 -06:00
|
|
|
|
|
|
|
boolean isWatchOnly();
|
|
|
|
|
|
|
|
String getTxKey(String txId);
|
2017-09-02 02:05:50 -06:00
|
|
|
|
|
|
|
void onWalletReceive();
|
|
|
|
|
|
|
|
boolean hasWallet();
|
2017-10-31 15:35:23 -06:00
|
|
|
|
|
|
|
void setToolbarButton(int type);
|
|
|
|
|
|
|
|
void setTitle(String title, String subtitle);
|
|
|
|
|
|
|
|
void setSubtitle(String subtitle);
|
2017-08-15 01:38:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAttach(Context context) {
|
|
|
|
super.onAttach(context);
|
2017-08-15 15:59:41 -06:00
|
|
|
if (context instanceof Listener) {
|
|
|
|
this.activityCallback = (Listener) context;
|
2017-08-15 01:38:07 -06:00
|
|
|
} else {
|
|
|
|
throw new ClassCastException(context.toString()
|
2017-08-15 15:59:41 -06:00
|
|
|
+ " must implement Listener");
|
2017-08-15 01:38:07 -06:00
|
|
|
}
|
|
|
|
}
|
2017-10-31 15:35:23 -06:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
2017-11-25 07:49:07 -07:00
|
|
|
Timber.d("onResume()");
|
2017-10-31 15:35:23 -06:00
|
|
|
activityCallback.setTitle(walletTitle, walletSubtitle);
|
|
|
|
activityCallback.setToolbarButton(Toolbar.BUTTON_CLOSE);
|
2017-11-08 15:04:01 -07:00
|
|
|
setProgress(syncProgress);
|
|
|
|
setProgress(syncText);
|
2017-11-04 08:31:34 -06:00
|
|
|
showReceive();
|
2017-10-31 15:35:23 -06:00
|
|
|
}
|
2017-08-15 01:38:07 -06:00
|
|
|
}
|