|
25 | 25 | import org.greenrobot.eventbus.Subscribe;
|
26 | 26 |
|
27 | 27 | import java.util.List;
|
| 28 | +import java.util.Set; |
28 | 29 | import java.util.concurrent.TimeUnit;
|
29 | 30 |
|
| 31 | +import POGOProtos.Enums.PokemonIdOuterClass; |
| 32 | + |
30 | 33 |
|
31 | 34 | public class PokemonNotificationService extends Service{
|
32 | 35 |
|
@@ -136,15 +139,20 @@ public void onEvent(CatchablePokemonEvent event) {
|
136 | 139 | if(!catchablePokemon.isEmpty()){
|
137 | 140 | NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
|
138 | 141 | inboxStyle.setBigContentTitle(catchablePokemon.size() + getString(R.string.notification_service_pokemon_in_area));
|
| 142 | + Set<PokemonIdOuterClass.PokemonId> showablePokemonIDs = preffs.getShowablePokemonIDs(); |
| 143 | + |
139 | 144 | for(CatchablePokemon cp : catchablePokemon){
|
140 |
| - Location pokeLocation = new Location(""); |
141 |
| - pokeLocation.setLatitude(cp.getLatitude()); |
142 |
| - pokeLocation.setLongitude(cp.getLongitude()); |
143 |
| - long remainingTime = cp.getExpirationTimestampMs() - System.currentTimeMillis(); |
144 |
| - inboxStyle.addLine(cp.getPokemonId().name() + "(" + |
145 |
| - TimeUnit.MILLISECONDS.toMinutes(remainingTime) + |
146 |
| - " "+getString(R.string.minutes)+"," + Math.ceil(pokeLocation.distanceTo(myLoc)) + " "+getString( |
147 |
| - R.string.meters)+")"); |
| 145 | + //Only show the notification if the Pokemon is in the preference list |
| 146 | + if(showablePokemonIDs.contains(cp.getPokemonId())) { |
| 147 | + Location pokeLocation = new Location(""); |
| 148 | + pokeLocation.setLatitude(cp.getLatitude()); |
| 149 | + pokeLocation.setLongitude(cp.getLongitude()); |
| 150 | + long remainingTime = cp.getExpirationTimestampMs() - System.currentTimeMillis(); |
| 151 | + inboxStyle.addLine(cp.getPokemonId().name() + "(" + |
| 152 | + TimeUnit.MILLISECONDS.toMinutes(remainingTime) + |
| 153 | + " "+getString(R.string.minutes)+"," + Math.ceil(pokeLocation.distanceTo(myLoc)) + " "+getString( |
| 154 | + R.string.meters)+")"); |
| 155 | + } |
148 | 156 | }
|
149 | 157 |
|
150 | 158 | builder.setStyle(inboxStyle);
|
|
0 commit comments