Fixed notification and made code slightly simpler

This commit is contained in:
Christian Basler 2016-04-27 17:30:05 +02:00
parent 0ecfbd3fb8
commit f705e13d0b
5 changed files with 12 additions and 12 deletions

View File

@ -48,7 +48,7 @@
</activity>
<activity
android:name=".ComposeMessageActivity"
android:label="Compose"
android:label="@string/compose_message"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"

View File

@ -32,7 +32,7 @@ public class ProofOfWorkNotification extends AbstractNotification {
public ProofOfWorkNotification(Context ctx) {
super(ctx);
update(1);
update(0);
}
@Override
@ -52,7 +52,9 @@ public class ProofOfWorkNotification extends AbstractNotification {
.setOngoing(true)
.setSmallIcon(R.drawable.ic_notification_proof_of_work)
.setContentTitle(ctx.getString(R.string.proof_of_work_title))
.setContentText(ctx.getString(R.string.proof_of_work_text, numberOfItems))
.setContentText(numberOfItems == 0
? ctx.getString(R.string.proof_of_work_text_0)
: ctx.getString(R.string.proof_of_work_text_n, numberOfItems))
.setContentIntent(pendingIntent);
notification = builder.build();

View File

@ -37,19 +37,13 @@ import static ch.dissem.apps.abit.notification.ProofOfWorkNotification.ONGOING_N
*/
public class ProofOfWorkService extends Service {
// Object to use as a thread-safe lock
private static final Object lock = new Object();
private static ProofOfWorkEngine engine;
private static ProofOfWorkEngine engine = new MultiThreadedPOWEngine();
private static boolean calculating;
private static final Queue<PowItem> queue = new LinkedList<>();
private static ProofOfWorkNotification notification;
@Override
public void onCreate() {
synchronized (lock) {
if (engine == null) {
engine = new MultiThreadedPOWEngine();
}
}
notification = new ProofOfWorkNotification(this);
}

View File

@ -42,7 +42,8 @@
<string name="connection_info_n">Stream %1$d: %2$d Verbindungen</string>
<string name="connection_info_disconnected">Getrennt</string>
<string name="connection_info_pending">Verbindung wird aufgebaut…</string>
<string name="proof_of_work_text">Arbeite am Versenden (%1$d in Warteschlange)</string>
<string name="proof_of_work_text_0">Arbeite am Versenden</string>
<string name="proof_of_work_text_n">Arbeite am Versenden (%1$d in Warteschlange)</string>
<string name="proof_of_work_title">Proof of Work</string>
<string name="error_invalid_sync_host">Synchronisation fehlgeschlagen: der vertrauenswürdige Knoten konnte nicht erreicht werden.</string>
<string name="error_invalid_sync_port">Ungültiger Port in den Synchronisationseinstellungen: %s</string>
@ -73,4 +74,5 @@ Als Alternative kann in den Einstellungen ein vertrauenswürdiger Knoten konfigu
<string name="error_illegal_address">Vielleicht hat es einen Tippfehler</string>
<string name="export">Exportieren</string>
<string name="confirm_export">Identität wirklich exportieren? Der Export wird die privaten Schlüssel unverschlüsselt enthalten.</string>
<string name="compose_message">Schreiben</string>
</resources>

View File

@ -44,7 +44,8 @@
<string name="connection_info_disconnected">Disconnected</string>
<string name="connection_info_pending">Connecting…</string>
<string name="proof_of_work_title">Proof of Work</string>
<string name="proof_of_work_text">Doing work to send message (%1$d queued)</string>
<string name="proof_of_work_text_0">Doing work to send message</string>
<string name="proof_of_work_text_n">Doing work to send message (%1$d queued)</string>
<string name="error_invalid_sync_port">Invalid port in synchronization settings: %s</string>
<string name="error_invalid_sync_host">Synchronization failed: Trusted node could not be reached.</string>
<string name="compose_body_hint">Write message</string>
@ -76,4 +77,5 @@ As an alternative you could configure a trusted node in the settings, but as of
<string name="error_illegal_address">There might be a typo</string>
<string name="export">Export</string>
<string name="confirm_export">Do you really want to export your identity? The export will contain the unencrypted private keys.</string>
<string name="compose_message">Compose</string>
</resources>