Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kontalk devteam committed Aug 21, 2018
2 parents 0d897ba + e91beec commit cf259e3
Show file tree
Hide file tree
Showing 29 changed files with 263 additions and 145 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Changelog

## [Next]
### Fixed
- Fix messages stuck in sending state
- Fix push notifications not working

### Changed
- Notification channels (aka notification categoris)
- Opt-out of server administrator messages (#1132)

## [4.2.0-beta1] - 2018-08-06
### Changed
- Badge indicators for OEMs supporting it (#292)
- Migrate to Firebase Cloud Messaging (#779)
Expand All @@ -24,7 +33,7 @@
### Fixed
- Temporarily revert to stable emoji version
- Fix public key retrieval
- Fix attachment panel close icon (#1184)
- Fix attachment panel close icon (#1184)

## [4.1.5] - 2018-06-19
### Changed
Expand Down Expand Up @@ -494,7 +503,8 @@
- Fix draft saving on incoming message (#448)
- Fix crash during sync (#454)

[Next]: https://github.com/kontalk/androidclient/compare/v4.1.6...HEAD
[Next]: https://github.com/kontalk/androidclient/compare/v4.2.0-beta1...HEAD
[4.2.0-beta1]: https://github.com/kontalk/androidclient/compare/v4.1.6...v4.2.0-beta1
[4.1.6]: https://github.com/kontalk/androidclient/compare/v4.1.5...v4.1.6
[4.1.5]: https://github.com/kontalk/androidclient/compare/v4.1.4...v4.1.5
[4.1.4]: https://github.com/kontalk/androidclient/compare/v4.1.3...v4.1.4
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ dependencies {

googleplayImplementation "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
googleplayImplementation "com.google.firebase:firebase-core:16.0.1"
googleplayImplementation "com.google.firebase:firebase-messaging:17.1.0"
googleplayImplementation "com.google.firebase:firebase-messaging:17.3.0"
googleplayImplementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
transitive = true
}
Expand Down
2 changes: 2 additions & 0 deletions app/proguard.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
-dontwarn org.xmlpull.v1.**
-dontwarn java.lang.management.**

-keepattributes *Annotation*, Signature, Exception

# keep all of Kontalk
-keep class org.kontalk.** { *; }

Expand Down
9 changes: 8 additions & 1 deletion app/src/googleplay/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyDwaCo60RpTZGSItEJznAwXd5tolLZijc4"/>
android:value="AIzaSyDwaCo60RpTZGSItEJznAwXd5tolLZijc4" />

<meta-data
android:name="firebase_analytics_collection_deactivated"
android:value="true" />
<meta-data
android:name="google_analytics_adid_collection_enabled"
android:value="false" />

</application>
</manifest>
24 changes: 0 additions & 24 deletions app/src/main/java/org/kontalk/Kontalk.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.kontalk.reporting.ReportingManager;
import org.kontalk.service.DownloadService;
import org.kontalk.service.NetworkStateReceiver;
import org.kontalk.service.ServerListUpdater;
import org.kontalk.service.SystemBootStartup;
import org.kontalk.service.UploadService;
import org.kontalk.service.msgcenter.IPushService;
Expand All @@ -61,7 +60,6 @@
import org.kontalk.ui.ComposeMessage;
import org.kontalk.ui.MessagingNotification;
import org.kontalk.ui.SearchActivity;
import org.kontalk.util.MediaStorage;
import org.kontalk.util.Preferences;


Expand All @@ -79,15 +77,6 @@ public class Kontalk extends Application {
*/
private static Kontalk sInstance;

// @deprecated
static {
try {
Class.forName(MediaStorage.class.getName());
}
catch (ClassNotFoundException ignored) {
}
}

private PersonalKey mDefaultKey;

/**
Expand Down Expand Up @@ -212,12 +201,6 @@ public void onCreate() {
AccountManager am = AccountManager.get(this);
Account account = Authenticator.getDefaultAccount(am);
if (account != null) {
if (!Authenticator.hasPersonalKey(am, account))
xmppUpgrade();

// update notifications from locally unread messages
MessagingNotification.delayedUpdateMessagesNotification(this, false);

// register account change listener
final OnAccountsUpdateListener listener = new OnAccountsUpdateListener() {
@Override
Expand Down Expand Up @@ -265,13 +248,6 @@ public void onAccountsUpdated(Account[] accounts) {
setBackendEnabled(this, false);
}

private void xmppUpgrade() {
// delete custom server
Preferences.setServerURI(null);
// delete cached server list
ServerListUpdater.deleteCachedList(this);
}

public PersonalKey getPersonalKey() throws PGPException, IOException, CertificateException {
try {
if (mDefaultKey == null)
Expand Down
7 changes: 0 additions & 7 deletions app/src/main/java/org/kontalk/client/NumberValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import org.kontalk.reporting.ReportingManager;
import org.kontalk.service.XMPPConnectionHelper;
import org.kontalk.service.XMPPConnectionHelper.ConnectionHelperListener;
import org.kontalk.service.msgcenter.PGPKeyPairRingProvider;


/**
Expand Down Expand Up @@ -221,12 +220,6 @@ public void setFallback(boolean fallback) {
mFallback = fallback;
}

@Override
public PGPKeyPairRingProvider getKeyPairRingProvider() {
// not supported
return null;
}

public void importKey(byte[] privateKeyData, byte[] publicKeyData) {
mImportedPrivateKey = privateKeyData;
mImportedPublicKey = publicKeyData;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/org/kontalk/client/XMPPTCPConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ protected synchronized void loginInternal(String username, String password, Reso
if (unacknowledgedStanzas != null) {
// There was a previous connection with SM enabled but that was either not resumable or
// failed to resume. Make sure that we (re-)send the unacknowledged stanzas.
unacknowledgedStanzas.drainTo(previouslyUnackedStanzas);
// HACK this line below was commented out to avoid re-sending lost stanzas automatically
// unacknowledgedStanzas.drainTo(previouslyUnackedStanzas);
// Reset unacknowledged stanzas to 'null' to signal that we never send 'enable' in this
// XMPP session (There maybe was an enabled in a previous XMPP session of this
// connection instance though). This is used in writePackets to decide if stanzas should
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/org/kontalk/service/DownloadService.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public void startForeground(long totalBytes) {

if (mNotificationBuilder == null) {
mNotificationBuilder = new ProgressNotificationBuilder(getApplicationContext(),
MessagingNotification.CHANNEL_MEDIA_DOWNLOAD,
R.layout.progress_notification,
getString(R.string.downloading_attachment),
R.drawable.ic_stat_notify,
Expand Down Expand Up @@ -343,13 +344,14 @@ public void completed(String url, String mime, File destination) {
NOTIFICATION_ID_DOWNLOAD_OK, i, 0);

// create notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext())
NotificationCompat.Builder builder = new NotificationCompat
.Builder(getApplicationContext(), MessagingNotification.CHANNEL_MEDIA_DOWNLOAD)
.setSmallIcon(R.drawable.ic_stat_notify)
.setContentTitle(getString(R.string.notify_title_download_completed))
.setContentText(getString(R.string.notify_text_download_completed))
.setTicker(getString(R.string.notify_ticker_download_completed))
.setContentIntent(pi)
.setPriority(NotificationCompat.PRIORITY_LOW)
.setPriority(NotificationCompat.PRIORITY_MIN)
.setAutoCancel(true);

// notify!!
Expand All @@ -376,12 +378,13 @@ private void errorNotification(String ticker, String text) {
NOTIFICATION_ID_DOWNLOAD_ERROR, i, 0);

// create notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext())
NotificationCompat.Builder builder = new NotificationCompat
.Builder(getApplicationContext(), MessagingNotification.CHANNEL_MEDIA_DOWNLOAD)
.setSmallIcon(R.drawable.ic_stat_notify)
.setContentTitle(getString(R.string.notify_title_download_error))
.setContentText(text)
.setTicker(ticker)
.setPriority(NotificationCompat.PRIORITY_LOW)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setCategory(NotificationCompat.CATEGORY_ERROR)
.setContentIntent(pi)
.setAutoCancel(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.kontalk.R;
import org.kontalk.crypto.PersonalKey;
import org.kontalk.ui.ConversationsActivity;
import org.kontalk.ui.MessagingNotification;

import static org.kontalk.ui.MessagingNotification.NOTIFICATION_ID_KEYPAIR_GEN;

Expand Down Expand Up @@ -108,13 +109,15 @@ private void startForeground() {
PendingIntent pi = PendingIntent.getActivity(getApplicationContext(),
NOTIFICATION_ID_KEYPAIR_GEN, ni, 0);

Notification no = new NotificationCompat.Builder(this)
Notification no = new NotificationCompat
.Builder(this, MessagingNotification.CHANNEL_OTHER)
.setOngoing(true)
.setTicker(getString(R.string.notify_gen_keypair_ticker))
.setSmallIcon(R.drawable.ic_stat_notify)
.setContentTitle(getString(R.string.notify_gen_keypair_title))
.setContentText(getString(R.string.notify_gen_keypair_text))
.setContentIntent(pi)
.setPriority(NotificationCompat.PRIORITY_MIN)
.build();

startForeground(NOTIFICATION_ID_KEYPAIR_GEN, no);
Expand Down
15 changes: 12 additions & 3 deletions app/src/main/java/org/kontalk/service/SystemBootStartup.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,30 @@
package org.kontalk.service;

import org.kontalk.Kontalk;
import org.kontalk.authenticator.Authenticator;
import org.kontalk.ui.MessagingNotification;

import android.accounts.Account;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;


/**
* Receiver for the BOOT_COMPLETED action.
* This is actually just a dummy to allow {@link Kontalk} do its jobs.
* Fires up any unread notifications before the last reboot.
* @author Daniele Ricci
* @version 1.0
*/
public class SystemBootStartup extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// nothing to do here
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Account account = Authenticator.getDefaultAccount(Kontalk.get());
if (account != null) {
// update notifications from locally unread messages
MessagingNotification
.delayedUpdateMessagesNotification(Kontalk.get(), false);
}
}
}
}
7 changes: 5 additions & 2 deletions app/src/main/java/org/kontalk/service/UploadService.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.kontalk.reporting.ReportingManager;
import org.kontalk.service.msgcenter.MessageCenterService;
import org.kontalk.ui.ConversationsActivity;
import org.kontalk.ui.MessagingNotification;
import org.kontalk.ui.ProgressNotificationBuilder;
import org.kontalk.upload.HTPPFileUploadConnection;
import org.kontalk.upload.UploadConnection;
Expand Down Expand Up @@ -234,6 +235,7 @@ public void startForeground(long totalBytes) {

if (mNotificationBuilder == null) {
mNotificationBuilder = new ProgressNotificationBuilder(getApplicationContext(),
MessagingNotification.CHANNEL_MEDIA_UPLOAD,
R.layout.progress_notification,
getString(R.string.sending_message),
R.drawable.ic_stat_notify,
Expand Down Expand Up @@ -300,13 +302,14 @@ private static void errorNotification(Context context, NotificationManager nm, S
NOTIFICATION_ID_UPLOAD_ERROR, i, 0);

// create notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(context.getApplicationContext())
NotificationCompat.Builder builder = new NotificationCompat
.Builder(context.getApplicationContext(), MessagingNotification.CHANNEL_MEDIA_UPLOAD)
.setSmallIcon(R.drawable.ic_stat_notify)
.setContentTitle(context.getString(R.string.notify_title_upload_error))
.setContentText(text)
.setTicker(ticker)
.setContentIntent(pi)
.setPriority(NotificationCompat.PRIORITY_LOW)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setCategory(NotificationCompat.CATEGORY_ERROR)
.setAutoCancel(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.kontalk.client.KontalkConnection;
import org.kontalk.crypto.PersonalKey;
import org.kontalk.service.msgcenter.MessageCenterService;
import org.kontalk.service.msgcenter.PGPKeyPairRingProvider;
import org.kontalk.util.InternalTrustStore;
import org.kontalk.util.Preferences;

Expand Down Expand Up @@ -371,8 +370,5 @@ public interface ConnectionHelperListener extends ConnectionListener {
void reconnectingIn(int seconds);

void authenticationFailed();

PGPKeyPairRingProvider getKeyPairRingProvider();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import android.widget.Toast;

import org.kontalk.Kontalk;
import org.kontalk.R;
import org.kontalk.crypto.PersonalKeyImporter;

Expand Down Expand Up @@ -92,7 +93,7 @@ public void processStanza(Stanza packet) {
protected void finish() {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplication(),
Toast.makeText(Kontalk.get(),
R.string.msg_import_keypair_complete,
Toast.LENGTH_LONG).show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3130,15 +3130,6 @@ void endKeyPairRegeneration() {
}
}

/**
* Used by {@link XMPPConnectionHelper} to retrieve the keyring that will
* be used for the next login while upgrading from legacy.
*/
@Override
public PGPKeyPairRingProvider getKeyPairRingProvider() {
return mKeyPairRegenerator;
}

private void beginKeyPairImport(Uri keypack, String passphrase) {
if (mKeyPairImporter == null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,14 @@ private void processChatMessage(Message m, Intent chatStateBroadcast) throws Sma
msgId = MessageUtils.messageId();

Jid from = m.getFrom();

// check if user opted out of server messages
if (!Preferences.isServerMessagesEnabled(getContext()) &&
from.asBareJid().toString().equalsIgnoreCase(getServer().getNetwork())) {
Log.w(TAG, "user opted out of server messages, message will be ignored");
return;
}

String body = m.getBody();

// create message
Expand Down

This file was deleted.

Loading

0 comments on commit cf259e3

Please sign in to comment.