mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 03:11:10 +01:00
Track the first time a megaphone appeared.
This commit is contained in:
@@ -9,7 +9,7 @@ final class ForeverSchedule implements MegaphoneSchedule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDisplay(int seenCount, long lastSeen, long currentTime) {
|
||||
public boolean shouldDisplay(int seenCount, long lastSeen, long firstVisible, long currentTime) {
|
||||
return enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,18 @@ public class MegaphoneRepository {
|
||||
});
|
||||
}
|
||||
|
||||
@MainThread
|
||||
public void markVisible(@NonNull Megaphones.Event event) {
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
executor.execute(() -> {
|
||||
if (getRecord(event).getFirstVisible() == 0) {
|
||||
database.markFirstVisible(event, time);
|
||||
resetDatabaseCache();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@MainThread
|
||||
public void markSeen(@NonNull Megaphone megaphone) {
|
||||
long lastSeen = System.currentTimeMillis();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package org.thoughtcrime.securesms.megaphone;
|
||||
|
||||
public interface MegaphoneSchedule {
|
||||
boolean shouldDisplay(int seenCount, long lastSeen, long currentTime);
|
||||
boolean shouldDisplay(int seenCount, long lastSeen, long firstVisible, long currentTime);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public final class Megaphones {
|
||||
MegaphoneRecord record = Objects.requireNonNull(records.get(e.getKey()));
|
||||
MegaphoneSchedule schedule = e.getValue();
|
||||
|
||||
return !record.isFinished() && schedule.shouldDisplay(record.getSeenCount(), record.getLastSeen(), currentTime);
|
||||
return !record.isFinished() && schedule.shouldDisplay(record.getSeenCount(), record.getLastSeen(), record.getFirstVisible(), currentTime);
|
||||
})
|
||||
.map(Map.Entry::getKey)
|
||||
.map(records::get)
|
||||
|
||||
@@ -9,7 +9,7 @@ class RecurringSchedule implements MegaphoneSchedule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDisplay(int seenCount, long lastSeen, long currentTime) {
|
||||
public boolean shouldDisplay(int seenCount, long lastSeen, long firstVisible, long currentTime) {
|
||||
if (seenCount == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user