add loading notification
MODIFY
bither-android/res/layout/activity_hot.xml
bither-android/res/layout/activity_hot.xml
android:layout_height="match_parent"
android:layout_marginTop="@dimen/title_bar_below_margin" >
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:id="@+id/ll_alert"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="10dp"
+ android:background="@color/dropdown_message_background_color"
+ android:visibility="gone"
+ android:orientation="horizontal" >
+
+ <ProgressBar
+ android:id="@+id/pb_alert"
+ android:layout_width="20dp"
+ android:layout_height="20dp"
+ android:layout_gravity="center"
+ android:indeterminateDrawable="@drawable/check_progress_bar"
+ android:indeterminateDuration="600"
+ android:layout_marginRight="8dp"
+ android:visibility="gone"
+ android:indeterminateOnly="true" />
+
+ <TextView
+ android:id="@+id/tv_alert"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:gravity="center_vertical"
+ android:textColor="@color/white"
+ android:textSize="15sp" />
+
+ </LinearLayout>
+
<net.bither.ui.base.OverScrollableViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
+ </LinearLayout>
+
<include layout="@layout/layout_dropdown_message" />
<net.bither.ui.base.SyncProgressView

MODIFY
bither-android/src/net/bither/NotificationAndroidImpl.java
bither-android/src/net/bither/NotificationAndroidImpl.java
@@ -35,6 +35,7 @@ public class NotificationAndroidImpl implements NotificationService {
public static final String ACTION_ADDRESS_BALANCE = "net.bither.bitherj.balance";
public static final String ACTION_PEER_STATE = "net.bither.bitherj.peer_state";
public static final String ACTION_ADDRESS_LOAD_COMPLETE_STATE = "net.bither.bitherj.load_complete";
+ public static final String ACTION_ADDRESS_TX_LOADING_STATE = "net.bither.bitherj.address_tx_loading";
public static final String ACTION_PEER_STATE_NUM_PEERS = "num_peers";
@@ -46,6 +47,8 @@ public class NotificationAndroidImpl implements NotificationService {
public static final String ACTION_SYNC_BLOCK_AND_WALLET_STATE = R.class.getPackage().getName
() + ".sync_block_wallet";
public static final String ACTION_PROGRESS_INFO = "progress_info";
+ public static final String ACTION_UNSYNC_BLOCK_NUMBER_INFO = "unsync_block_number_info";
+ public static final String ACTION_ADDRESS_TX_LOADING_INFO = "address_tx_loading_info";
@Override
public void sendBroadcastSyncSPVFinished(boolean isFinished) {
@@ -123,9 +126,10 @@ public class NotificationAndroidImpl implements NotificationService {
}
@Override
- public void sendBroadcastProgressState(double value) {
+ public void sendBroadcastProgressState(double value, long unsyncBlockNumber) {
final Intent broadcast = new Intent(ACTION_SYNC_BLOCK_AND_WALLET_STATE);
broadcast.putExtra(ACTION_PROGRESS_INFO, value);
+ broadcast.putExtra(ACTION_UNSYNC_BLOCK_NUMBER_INFO, unsyncBlockNumber);
BitherApplication.mContext.sendBroadcast(broadcast);
}
@@ -133,6 +137,18 @@ public class NotificationAndroidImpl implements NotificationService {
public void removeProgressState() {
BitherApplication.mContext.removeStickyBroadcast(new Intent
(ACTION_SYNC_BLOCK_AND_WALLET_STATE));
+ }
+ @Override
+ public void sendBroadcastAddressTxLoading(String address) {
+ final Intent broadcast = new Intent(ACTION_ADDRESS_TX_LOADING_STATE);
+ broadcast.putExtra(ACTION_ADDRESS_TX_LOADING_INFO, address);
+ BitherApplication.mContext.sendStickyBroadcast(broadcast);
}
+
+ @Override
+ public void removeAddressTxLoading() {
+ BitherApplication.mContext.removeStickyBroadcast(new Intent(ACTION_ADDRESS_TX_LOADING_STATE));
+ }
+
}

MODIFY
bither-android/src/net/bither/activity/hot/HotActivity.java
bither-android/src/net/bither/activity/hot/HotActivity.java
@@ -30,6 +30,9 @@ import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.TextView;
import net.bither.BitherApplication;
import net.bither.BitherSetting;
@@ -59,8 +62,8 @@ import net.bither.ui.base.SyncProgressView;
import net.bither.ui.base.TabButton;
import net.bither.ui.base.dialog.DialogFirstRunWarning;
import net.bither.ui.base.dialog.DialogGenerateAddressFinalConfirm;
-import net.bither.ui.base.dialog.DialogProgress;
import net.bither.util.LogUtil;
+import net.bither.util.NetworkUtil;
import net.bither.util.StringUtil;
import net.bither.util.UIUtil;
import net.bither.util.WalletUtils;
@@ -69,6 +72,8 @@ import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
+import static net.bither.NotificationAndroidImpl.ACTION_UNSYNC_BLOCK_NUMBER_INFO;
+
public class HotActivity extends BaseFragmentActivity {
private TabButton tbtnMessage;
private TabButton tbtnMain;
@@ -77,15 +82,19 @@ public class HotActivity extends BaseFragmentActivity {
private HotFragmentPagerAdapter mAdapter;
private ViewPager mPager;
private SyncProgressView pbSync;
- private DialogProgress dp;
+ private LinearLayout llAlert;
+ private TextView tvAlert;
+ private ProgressBar pbAlert;
private final TxAndBlockBroadcastReceiver txAndBlockBroadcastReceiver = new
TxAndBlockBroadcastReceiver();
private final ProgressBroadcastReceiver broadcastReceiver = new ProgressBroadcastReceiver();
private final AddressIsLoadedReceiver addressIsLoadedReceiver = new AddressIsLoadedReceiver();
+ private final AddressTxLoadingReceiver addressIsLoadingReceiver = new AddressTxLoadingReceiver();
protected void onCreate(Bundle savedInstanceState) {
AbstractApp.notificationService.removeProgressState();
+ AbstractApp.notificationService.removeAddressTxLoading();
initAppState();
super.onCreate(savedInstanceState);
BitherApplication.hotActivity = this;
@@ -111,6 +120,14 @@ public class HotActivity extends BaseFragmentActivity {
}
}, 500);
DialogFirstRunWarning.show(this);
+ if (!NetworkUtil.isConnected()) {
+ tvAlert.setText(R.string.tip_network_error);
+ llAlert.setVisibility(View.VISIBLE);
+ } else if (PeerManager.instance().getConnectedPeers().size() == 0) {
+ tvAlert.setText(R.string.tip_no_peers_connected_scan);
+ pbAlert.setVisibility(View.VISIBLE);
+ llAlert.setVisibility(View.VISIBLE);
+ }
}
private void registerReceiver() {
@@ -122,6 +139,7 @@ public class HotActivity extends BaseFragmentActivity {
registerReceiver(txAndBlockBroadcastReceiver, intentFilter);
registerReceiver(addressIsLoadedReceiver,
new IntentFilter(NotificationAndroidImpl.ACTION_ADDRESS_LOAD_COMPLETE_STATE));
+ registerReceiver(addressIsLoadingReceiver, new IntentFilter(NotificationAndroidImpl.ACTION_ADDRESS_TX_LOADING_STATE));
}
@Override
@@ -129,6 +147,7 @@ public class HotActivity extends BaseFragmentActivity {
unregisterReceiver(broadcastReceiver);
unregisterReceiver(txAndBlockBroadcastReceiver);
unregisterReceiver(addressIsLoadedReceiver);
+ unregisterReceiver(addressIsLoadingReceiver);
super.onDestroy();
BitherApplication.hotActivity = null;
@@ -182,6 +201,9 @@ public class HotActivity extends BaseFragmentActivity {
tbtnMain = (TabButton) findViewById(R.id.tbtn_main);
tbtnMessage = (TabButton) findViewById(R.id.tbtn_message);
tbtnMe = (TabButton) findViewById(R.id.tbtn_me);
+ llAlert = findViewById(R.id.ll_alert);
+ tvAlert = findViewById(R.id.tv_alert);
+ pbAlert = findViewById(R.id.pb_alert);
configureTopBarSize();
configureTabMainIcons();
@@ -450,11 +472,25 @@ public class HotActivity extends BaseFragmentActivity {
private final class ProgressBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
- if (intent != null && intent.hasExtra(NotificationAndroidImpl.ACTION_PROGRESS_INFO)) {
+ if (intent != null) {
+ if (intent.hasExtra(NotificationAndroidImpl.ACTION_PROGRESS_INFO)) {
double progress = intent.getDoubleExtra(NotificationAndroidImpl.ACTION_PROGRESS_INFO, 0);
LogUtil.d("progress", "BlockchainBroadcastReceiver" + progress);
pbSync.setProgress(progress);
}
+ if (intent.hasExtra(ACTION_UNSYNC_BLOCK_NUMBER_INFO)) {
+ long unsyncBlockNumber = intent.getLongExtra(ACTION_UNSYNC_BLOCK_NUMBER_INFO, 0);
+ if (unsyncBlockNumber > 0) {
+ tvAlert.setText(getString(R.string.tip_sync_block_height, unsyncBlockNumber));
+ if (llAlert.getVisibility() == View.GONE) {
+ pbAlert.setVisibility(View.VISIBLE);
+ llAlert.setVisibility(View.VISIBLE);
+ }
+ } else {
+ llAlert.setVisibility(View.GONE);
+ }
+ }
+ }
}
}
@@ -462,7 +498,6 @@ public class HotActivity extends BaseFragmentActivity {
@Override
public void onReceive(Context context, Intent intent) {
-
if (intent == null ||
(!Utils.compareString(NotificationAndroidImpl.ACTION_ADDRESS_BALANCE, intent.getAction())
&& !Utils.compareString(NotificationAndroidImpl.ACTION_SYNC_LAST_BLOCK_CHANGE, intent.getAction()))) {
@@ -492,6 +527,28 @@ public class HotActivity extends BaseFragmentActivity {
}
}
+ private final class AddressTxLoadingReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent == null || !Utils.compareString(intent.getAction(), NotificationAndroidImpl.ACTION_ADDRESS_TX_LOADING_STATE)) {
+ return;
+ }
+ if (!intent.hasExtra(NotificationAndroidImpl.ACTION_ADDRESS_TX_LOADING_INFO)) {
+ return;
+ }
+ String address = intent.getStringExtra(NotificationAndroidImpl.ACTION_ADDRESS_TX_LOADING_INFO);
+ if (Utils.isEmpty(address)) {
+ llAlert.setVisibility(View.GONE);
+ return;
+ }
+ tvAlert.setText(getString(R.string.tip_sync_address_tx, address));
+ if (llAlert.getVisibility() == View.GONE) {
+ pbAlert.setVisibility(View.VISIBLE);
+ llAlert.setVisibility(View.VISIBLE);
+ }
+ }
+ }
+
// private void addNewPrivateKey() {
// final AppSharedPreference preference = AppSharedPreference.getInstance();
// if (!preference.hasPrivateKey()) {

MODIFY
bither-android/src/net/bither/activity/hot/HotAdvanceActivity.java
bither-android/src/net/bither/activity/hot/HotAdvanceActivity.java
package net.bither.activity.hot;
import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@@ -31,10 +34,12 @@ import android.widget.TextView;
import net.bither.BitherApplication;
import net.bither.BitherSetting;
+import net.bither.NotificationAndroidImpl;
import net.bither.R;
import net.bither.TrashCanActivity;
import net.bither.VerifyMessageSignatureActivity;
import net.bither.activity.cold.HdmImportWordListActivity;
+import net.bither.bitherj.AbstractApp;
import net.bither.bitherj.BitherjSettings;
import net.bither.bitherj.core.Address;
import net.bither.bitherj.core.AddressManager;
@@ -125,13 +130,16 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
private HDMResetServerPasswordUtil hdmResetServerPasswordUtil;
private TextView tvVserion;
public static final String SplitCoinKey = "SplitCoin";
+ private final AddressTxLoadingReceiver addressIsLoadingReceiver = new AddressTxLoadingReceiver();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.slide_in_right, 0);
setContentView(R.layout.activity_hot_advance_options);
+ AbstractApp.notificationService.removeAddressTxLoading();
initView();
+ registerReceiver();
}
private void initView() {
@@ -189,6 +197,18 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
signHash.setOnClickListener(signHashClick);
}
+ private void registerReceiver() {
+ registerReceiver(addressIsLoadingReceiver, new IntentFilter(NotificationAndroidImpl.ACTION_ADDRESS_TX_LOADING_STATE));
+ }
+
+ @Override
+ protected void onDestroy() {
+ unregisterReceiver(addressIsLoadingReceiver);
+ super.onDestroy();
+ BitherApplication.hotActivity = null;
+
+ }
+
@Override
protected void onResume() {
super.onResume();
@@ -197,6 +217,25 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
configureHDMServerPasswordReset();
}
+ private final class AddressTxLoadingReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent == null || !Utils.compareString(intent.getAction(), NotificationAndroidImpl.ACTION_ADDRESS_TX_LOADING_STATE)) {
+ return;
+ }
+ if (!intent.hasExtra(NotificationAndroidImpl.ACTION_ADDRESS_TX_LOADING_INFO)) {
+ return;
+ }
+ String address = intent.getStringExtra(NotificationAndroidImpl.ACTION_ADDRESS_TX_LOADING_INFO);
+ if (Utils.isEmpty(address)) {
+ return;
+ }
+ if (dp != null) {
+ dp.setMessage(getString(R.string.tip_sync_address_tx, address));
+ }
+ }
+ }
+
private View.OnClickListener signHashClick = new View.OnClickListener() {
@Override
public void onClick(View v) {

MODIFY
bither-android/src/net/bither/ui/base/AddressDetailHeader.java
bither-android/src/net/bither/ui/base/AddressDetailHeader.java
@@ -53,6 +53,7 @@ import net.bither.ui.base.dialog.DialogBalanceDetail;
import net.bither.ui.base.dialog.DialogFragmentFancyQrCodePager;
import net.bither.ui.base.dialog.DialogProgress;
import net.bither.util.KeyUtil;
+import net.bither.util.SendUtil;
import net.bither.util.StringUtil;
import net.bither.util.UIUtil;
import net.bither.util.WalletUtils;
@@ -247,6 +248,9 @@ public class AddressDetailHeader extends FrameLayout implements DialogFragmentFa
@Override
public void onClick(View v) {
if (address != null) {
+ if (!SendUtil.isCanSend(activity, address.isSyncComplete())) {
+ return;
+ }
if (address.getBalance() <= 0) {
DropdownMessage.showDropdownMessage(activity,
R.string.address_detail_send_balance_zero);

ADD
bither-android/src/net/bither/util/SendUtil.java
+package net.bither.util;
+
+import android.app.Activity;
+
+import net.bither.R;
+import net.bither.bitherj.core.PeerManager;
+import net.bither.ui.base.DropdownMessage;
+
+public class SendUtil {
+
+ static public boolean isCanSend(Activity activity, boolean isSyncComplete) {
+ if (!NetworkUtil.isConnected()) {
+ DropdownMessage.showDropdownMessage(activity, R.string.tip_network_error);
+ return false;
+ }
+ if (!isSyncComplete) {
+ DropdownMessage.showDropdownMessage(activity, activity.getString(R.string.no_sync_complete));
+ return false;
+ }
+ if (PeerManager.instance().getConnectedPeers().size() == 0) {
+ DropdownMessage.showDropdownMessage(activity, R.string.tip_no_peers_connected);
+ return false;
+ }
+ long displayLastBlockHeight = PeerManager.instance().getConnectedPeers().get(0).getDisplayLastBlockHeight();
+ if (PeerManager.instance().getLastBlockHeight() < displayLastBlockHeight) {
+ DropdownMessage.showDropdownMessage(activity, activity.getString(R.string.tip_sync_block_height, displayLastBlockHeight - PeerManager.instance().getLastBlockHeight()));
+ return false;
+ }
+ return true;
+ }
+}

MODIFY
bitherj
bitherj
-Subproject commit a80307d402a40730ff59f9914fe1fc8d8a1bd739
+Subproject commit 23c09f6d6ffd186ed8e4284a6de70902849ce232

add loading notification