migrate to blabber.im

This commit is contained in:
Christian Schneppe 2020-11-02 20:23:22 +01:00
parent a1b47ce242
commit 3508e566a6
No known key found for this signature in database
GPG key ID: F30B8D686B44D87E
5 changed files with 95 additions and 2 deletions

View file

@ -105,7 +105,7 @@ android {
versionCode 310
versionName "3.0.0"
versionNameSuffix " beta_(2020-10-29)" // " beta_(XXXX-XX-XX)" // activate for beta versions
versionNameSuffix " beta_(2020-11-02)" // " beta_(XXXX-XX-XX)" // activate for beta versions
//resConfigs "en"
archivesBaseName += "-$versionName"

View file

@ -137,7 +137,7 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="jabber.pix-art.de" />
<data android:host="blabber.im" />
<data android:pathPrefix="/i/" />
<data android:pathPrefix="/j/" />
</intent-filter>

View file

@ -86,6 +86,7 @@ import eu.siacs.conversations.ui.util.ConversationMenuConfigurator;
import eu.siacs.conversations.ui.util.IntroHelper;
import eu.siacs.conversations.ui.util.PendingItem;
import eu.siacs.conversations.ui.util.StyledAttributes;
import eu.siacs.conversations.ui.util.UpdateHelper;
import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.ExceptionHelper;
import eu.siacs.conversations.utils.MenuDoubleTabUtil;
@ -442,6 +443,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
pendingViewIntent.push(intent);
setIntent(createLauncherIntent(this));
}
UpdateHelper.showPopup(this);
}
@Override

View file

@ -0,0 +1,90 @@
package eu.siacs.conversations.ui.util;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.ui.IntroActivity;
import me.drakeet.support.toast.ToastCompat;
import static eu.siacs.conversations.ui.IntroActivity.ACTIVITY;
import static eu.siacs.conversations.ui.IntroActivity.MULTICHAT;
public class UpdateHelper {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
private static final String UPDATE_DATE = "2020-11-01";
public static void showPopup(Activity activity) {
Thread t = new Thread(() -> {
String blabber_message = "BLABBER.IM_UPDATE_MESSAGE";
SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(activity.getBaseContext());
String Message = "message_shown_" + blabber_message;
boolean SHOW_MESSAGE = getPrefs.getBoolean(Message, true);
if (SHOW_MESSAGE && updateInstalled(activity)) {
activity.runOnUiThread(() -> {
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(activity.getString(R.string.title_activity_updater));
builder.setMessage(activity.getString(R.string.updated_to_blabber));
builder.setCancelable(false);
builder.setPositiveButton(R.string.ok, (dialog, which) -> SaveMessageShown(activity, blabber_message)
);
builder.create().show();
});
}
});
t.start();
}
private static boolean updateInstalled(Activity activity) {
PackageManager pm = activity.getPackageManager();
PackageInfo packageInfo;
String firstInstalled = null;
String lastUpdate = null;
Date updateDate = null;
Date lastUpdateDate = null;
try {
packageInfo = pm.getPackageInfo(activity.getPackageName(), PackageManager.GET_SIGNATURES);
firstInstalled = DATE_FORMAT.format(new Date(packageInfo.firstInstallTime));
lastUpdate = DATE_FORMAT.format(new Date(packageInfo.lastUpdateTime));
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
try {
updateDate = DATE_FORMAT.parse(UPDATE_DATE);
if (lastUpdate != null) {
lastUpdateDate = DATE_FORMAT.parse(lastUpdate);
}
} catch (ParseException e) {
e.printStackTrace();
}
return updateDate != null && lastUpdateDate != null && !firstInstalled.equals(lastUpdate) && lastUpdateDate.getTime() >= updateDate.getTime();
}
public static void SaveMessageShown(Context context, String message) {
SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(context);
String Message = "message_shown_" + message;
SharedPreferences.Editor e = getPrefs.edit();
e.putBoolean(Message, false);
e.apply();
}
}

View file

@ -1066,4 +1066,5 @@
<string name="n_missed_calls_from_m_contacts">%1$d missed calls from %2$d contacts</string>
<string name="pref_invidious_host_summary">Use a custom invidious host</string>
<string name="pref_invidious_host">Invidious host</string>
<string name="updated_to_blabber">We have successfully updated Pix-Art Messenger to blabber.im\n\nThe cooperation of the two projects blabber.im and Pix-Art Messenger were expanded in November 2020. In the future, the Android app Pix-Art Messenger will be continued under the name blabber.im.\n\nWhat you can expect:\n- Range of functions remains the same\n- Support chat rooms are merged\n- Colors and logos are adapted to blabber.im\n- App is still available for free in Google Play Store and F-Droid Store\n\nYour blabber.im Team</string>
</resources>