Skip to content

Commit 1197a67

Browse files
committed
Reverting to old blockchain code
The notification code requiring the new support library broke the app in production. Going back to the way it was, but keeping all the other changes to the app. Production ready signed APK tested on one of my devices.
1 parent 7b8252c commit 1197a67

3 files changed

Lines changed: 23 additions & 38 deletions

File tree

wallet/libs/android-support-v4.jar

-613 KB
Binary file not shown.

wallet/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939
<dependency>
4040
<groupId>com.google.android</groupId>
4141
<artifactId>support-v4</artifactId>
42-
<version>r13</version>
43-
<scope>system</scope>
44-
<systemPath>${basedir}/libs/android-support-v4.jar</systemPath>
42+
<version>r7</version>
4543
</dependency>
4644

4745
<!-- com.actionbarsherlock.* -->

wallet/src/de/schildbach/wallet/service/BlockchainServiceImpl.java

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private void notifyCoinsReceived(@Nullable final Address from, @Nonnull final Bi
234234
notification.setNumber(notificationCount == 1 ? 0 : notificationCount);
235235
notification.setWhen(System.currentTimeMillis());
236236
notification.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.coins_received));
237-
nm.notify(NOTIFICATION_ID_COINS_RECEIVED, notification.build());
237+
nm.notify(NOTIFICATION_ID_COINS_RECEIVED, notification.getNotification());
238238
}
239239

240240
private final class PeerConnectivityListener extends AbstractPeerEventListener implements OnSharedPreferenceChangeListener
@@ -287,31 +287,25 @@ private void changed(final int numPeers)
287287
@Override
288288
public void run()
289289
{
290-
if (numPeers == 0 || GenericUtils.isBlackberry())
291-
{
292-
nm.cancel(NOTIFICATION_ID_CONNECTED);
293-
}
294-
else
295-
{
296-
final NotificationCompat.Builder notification = new NotificationCompat.Builder(BlockchainServiceImpl.this)
297-
.setSmallIcon(R.drawable.stat_sys_peers, numPeers > 4 ? 4 : numPeers)
298-
.setContentTitle(getString(R.string.app_name))
299-
.setContentText(getString(R.string.notification_peers_connected_msg, numPeers))
300-
.setContentIntent(PendingIntent.getActivity(BlockchainServiceImpl.this, 0, new Intent(BlockchainServiceImpl.this,
301-
WalletActivity.class), 0))
302-
.setWhen(System.currentTimeMillis())
303-
.setOngoing(true)
304-
/*
305-
* These calls are ignored by the support library for
306-
* pre-4.1 devices.
307-
*/
308-
.addAction(R.drawable.ic_action_clear,
309-
getString(R.string.wallet_options_disconnect),
310-
PendingIntent.getService(BlockchainServiceImpl.this, 0,
311-
new Intent(BlockchainServiceImpl.this, BlockchainServiceImpl.class)
312-
.setAction(BlockchainService.ACTION_STOP_SERVICE), 0));
313-
nm.notify(NOTIFICATION_ID_CONNECTED, notification.build());
314-
}
290+
final boolean connectivityNotification = prefs.getBoolean(Constants.PREFS_KEY_CONNECTIVITY_NOTIFICATION, false);
291+
292+
if (!connectivityNotification || numPeers == 0)
293+
{
294+
nm.cancel(NOTIFICATION_ID_CONNECTED);
295+
}
296+
else
297+
{
298+
final NotificationCompat.Builder notification = new NotificationCompat.Builder(BlockchainServiceImpl.this);
299+
notification.setSmallIcon(R.drawable.stat_sys_peers, numPeers > 4 ? 4 : numPeers);
300+
notification.setContentTitle(getString(R.string.app_name));
301+
notification.setContentText(getString(R.string.notification_peers_connected_msg, numPeers));
302+
notification.setContentIntent(PendingIntent.getActivity(BlockchainServiceImpl.this, 0, new Intent(BlockchainServiceImpl.this,
303+
WalletActivity.class), 0));
304+
notification.setWhen(System.currentTimeMillis());
305+
notification.setOngoing(true);
306+
nm.notify(NOTIFICATION_ID_CONNECTED, notification.getNotification());
307+
}
308+
315309
// send broadcast
316310
sendBroadcastPeerState(numPeers);
317311
}
@@ -569,7 +563,6 @@ public void onReceive(final Context context, final Intent intent)
569563
if (isIdle)
570564
{
571565
log.info("idling detected, stopping service");
572-
WalletApplication.scheduleStartBlockchainService(BlockchainServiceImpl.this);
573566
stopSelf();
574567
}
575568
}
@@ -715,7 +708,6 @@ else if (BlockchainService.ACTION_RESET_BLOCKCHAIN.equals(action))
715708
log.info("will remove blockchain on service shutdown");
716709

717710
resetBlockchainOnShutdown = true;
718-
WalletApplication.scheduleStartBlockchainService(this);
719711
stopSelf();
720712
}
721713
else if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action))
@@ -733,12 +725,6 @@ else if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action))
733725
log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString());
734726
}
735727
}
736-
else if (BlockchainService.ACTION_STOP_SERVICE.equals(action))
737-
{
738-
log.info("stopping self");
739-
// deliberate stop command, so don't schedule restart
740-
stopSelf();
741-
}
742728

743729
return START_NOT_STICKY;
744730
}
@@ -748,6 +734,8 @@ public void onDestroy()
748734
{
749735
log.debug(".onDestroy()");
750736

737+
WalletApplication.scheduleStartBlockchainService(this);
738+
751739
unregisterReceiver(tickReceiver);
752740

753741
application.getWallet().removeEventListener(walletEventListener);
@@ -804,7 +792,6 @@ public void onDestroy()
804792
public void onLowMemory()
805793
{
806794
log.warn("low memory detected, stopping service");
807-
WalletApplication.scheduleStartBlockchainService(this);
808795
stopSelf();
809796
}
810797

0 commit comments

Comments
 (0)