Skip to content

Commit c50f6f1

Browse files
committed
Merge branch 'notification-disconnect' of github.com:santa4nt/litecoin-wallet into santa4nt-notification-disconnect
Conflicts: wallet/src/de/schildbach/wallet/service/BlockchainServiceImpl.java
2 parents 4f1d99c + 64b855c commit c50f6f1

File tree

7 files changed

+43
-27
lines changed

7 files changed

+43
-27
lines changed

integration-android/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
1212

1313
# Project target.
14-
target=android-16
14+
target=android-10
1515
android.library=true

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
<groupId>org.apache.maven.plugins</groupId>
2424
<artifactId>maven-compiler-plugin</artifactId>
2525
<configuration>
26-
<source>1.5</source>
27-
<target>1.5</target>
26+
<source>1.6</source>
27+
<target>1.6</target>
2828
</configuration>
2929
</plugin>
3030
<plugin>

sample-integration-android/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
1212

1313
# Project target.
14-
target=android-16
14+
target=android-10
1515
android.library.reference.1=../integration-android

wallet/libs/android-support-v4.jar

613 KB
Binary file not shown.

wallet/pom.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@
3434
<scope>provided</scope>
3535
</dependency>
3636

37-
<!-- android.support.v4.* -->
37+
38+
<!-- android.support.v4.* -->
3839
<dependency>
3940
<groupId>com.google.android</groupId>
4041
<artifactId>support-v4</artifactId>
41-
<version>r7</version>
42-
</dependency>
42+
<version>r13</version>
43+
<scope>system</scope>
44+
<systemPath>${basedir}/libs/android-support-v4.jar</systemPath>
45+
</dependency>
4346

4447
<!-- com.actionbarsherlock.* -->
4548
<dependency>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public interface BlockchainService
4747
public static final String ACTION_RESET_BLOCKCHAIN = R.class.getPackage().getName() + ".reset_blockchain";
4848
public static final String ACTION_BROADCAST_TRANSACTION = R.class.getPackage().getName() + ".broadcast_transaction";
4949
public static final String ACTION_BROADCAST_TRANSACTION_HASH = "hash";
50+
public static final String ACTION_STOP_SERVICE = "stop_service";
5051

5152
@CheckForNull
5253
List<Peer> getConnectedPeers();

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

Lines changed: 32 additions & 20 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.getNotification());
237+
nm.notify(NOTIFICATION_ID_COINS_RECEIVED, notification.build());
238238
}
239239

240240
private final class PeerConnectivityListener extends AbstractPeerEventListener implements OnSharedPreferenceChangeListener
@@ -287,25 +287,31 @@ private void changed(final int numPeers)
287287
@Override
288288
public void run()
289289
{
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-
290+
if (numPeers == 0)
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+
}
309315
// send broadcast
310316
sendBroadcastPeerState(numPeers);
311317
}
@@ -727,6 +733,12 @@ else if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action))
727733
log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString());
728734
}
729735
}
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+
}
730742

731743
return START_NOT_STICKY;
732744
}

0 commit comments

Comments
 (0)