separate App-ID for PS Builds and show popup
for users having PAM installed
This commit is contained in:
parent
5f46e3fdc8
commit
0e154f50ca
5 changed files with 67 additions and 11 deletions
|
@ -153,9 +153,13 @@ android {
|
|||
playstore {
|
||||
dimension "distribution"
|
||||
versionNameSuffix "-playstore"
|
||||
applicationId "im.blabber.messenger"
|
||||
buildConfigField("boolean", "SHOW_MIGRATION_INFO", 'false')
|
||||
resValue "string", "applicationId", applicationId
|
||||
}
|
||||
git {
|
||||
dimension "distribution"
|
||||
buildConfigField("boolean", "SHOW_MIGRATION_INFO", 'true')
|
||||
}
|
||||
}
|
||||
if (project.hasProperty('mStoreFile') &&
|
||||
|
|
|
@ -58,6 +58,7 @@ public final class Config {
|
|||
public static final String CHANNEL_DISCOVERY = "https://search.jabber.network";
|
||||
public static final boolean DISALLOW_REGISTRATION_IN_UI = false; //hide the register checkbox
|
||||
public static final boolean SHOW_INTRO = BuildConfig.SHOW_INTRO;
|
||||
public static final boolean SHOW_MIGRATION_INFO = BuildConfig.SHOW_MIGRATION_INFO;
|
||||
|
||||
public static final boolean USE_RANDOM_RESOURCE_ON_EVERY_BIND = false;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.siacs.conversations.ui;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
|
@ -29,6 +30,7 @@ import eu.siacs.conversations.databinding.WelcomeBinding;
|
|||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.ui.util.IntroHelper;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
import eu.siacs.conversations.ui.util.UpdateHelper;
|
||||
import eu.siacs.conversations.utils.Compatibility;
|
||||
import eu.siacs.conversations.utils.InstallReferrerUtils;
|
||||
import eu.siacs.conversations.utils.SignupUtils;
|
||||
|
@ -124,6 +126,7 @@ public class WelcomeActivity extends XmppActivity implements XmppConnectionServi
|
|||
ab.setDisplayHomeAsUpEnabled(false);
|
||||
}
|
||||
IntroHelper.showIntro(this, false);
|
||||
UpdateHelper.showPopup(this);
|
||||
if (hasStoragePermission(REQUEST_IMPORT_BACKUP)) {
|
||||
binding.importDatabase.setVisibility(View.VISIBLE);
|
||||
binding.importText.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
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;
|
||||
|
@ -23,15 +19,11 @@ 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";
|
||||
private static final String INSTALL_DATE = "2020-11-01";
|
||||
|
||||
public static void showPopup(Activity activity) {
|
||||
Thread t = new Thread(() -> {
|
||||
|
@ -40,7 +32,7 @@ public class UpdateHelper {
|
|||
String Message = "message_shown_" + blabber_message;
|
||||
boolean SHOW_MESSAGE = getPrefs.getBoolean(Message, true);
|
||||
|
||||
if (SHOW_MESSAGE && updateInstalled(activity)) {
|
||||
if (SHOW_MESSAGE && updateInstalled(activity) && Config.SHOW_MIGRATION_INFO) {
|
||||
activity.runOnUiThread(() -> {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle(activity.getString(R.string.title_activity_updater));
|
||||
|
@ -50,6 +42,27 @@ public class UpdateHelper {
|
|||
);
|
||||
builder.create().show();
|
||||
});
|
||||
} else if (SHOW_MESSAGE && newInstalled(activity) && !Config.SHOW_MIGRATION_INFO && PAMInstalled(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_google));
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton(R.string.link, (dialog, which) -> {
|
||||
SaveMessageShown(activity, blabber_message);
|
||||
try {
|
||||
final Uri uri = Uri.parse(Config.migrationURL);
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
activity.startActivity(browserIntent);
|
||||
} catch (Exception e) {
|
||||
ToastCompat.makeText(activity, R.string.no_application_found_to_open_link, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
);
|
||||
builder.setNegativeButton(R.string.cancel, (dialog, which) -> SaveMessageShown(activity, blabber_message)
|
||||
);
|
||||
builder.create().show();
|
||||
});
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
|
@ -70,7 +83,7 @@ public class UpdateHelper {
|
|||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
updateDate = DATE_FORMAT.parse(UPDATE_DATE);
|
||||
updateDate = DATE_FORMAT.parse(INSTALL_DATE);
|
||||
if (lastUpdate != null) {
|
||||
lastUpdateDate = DATE_FORMAT.parse(lastUpdate);
|
||||
}
|
||||
|
@ -80,6 +93,39 @@ public class UpdateHelper {
|
|||
return updateDate != null && lastUpdateDate != null && !firstInstalled.equals(lastUpdate) && lastUpdateDate.getTime() >= updateDate.getTime();
|
||||
}
|
||||
|
||||
private static boolean newInstalled(Activity activity) {
|
||||
PackageManager pm = activity.getPackageManager();
|
||||
PackageInfo packageInfo;
|
||||
String firstInstalled = null;
|
||||
Date installDate = null;
|
||||
Date firstInstalledDate = null;
|
||||
try {
|
||||
packageInfo = pm.getPackageInfo(activity.getPackageName(), PackageManager.GET_SIGNATURES);
|
||||
firstInstalled = DATE_FORMAT.format(new Date(packageInfo.firstInstallTime));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
installDate = DATE_FORMAT.parse(INSTALL_DATE);
|
||||
if (firstInstalled != null) {
|
||||
firstInstalledDate = DATE_FORMAT.parse(firstInstalled);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return installDate != null && firstInstalledDate != null && firstInstalledDate.getTime() >= installDate.getTime();
|
||||
}
|
||||
|
||||
private static boolean PAMInstalled(Activity activity) {
|
||||
PackageManager pm = activity.getPackageManager();
|
||||
try {
|
||||
pm.getPackageInfo("de.pixart.messenger", 0);
|
||||
return true;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveMessageShown(Context context, String message) {
|
||||
SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String Message = "message_shown_" + message;
|
||||
|
|
|
@ -1067,4 +1067,6 @@
|
|||
<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 was 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>
|
||||
<string name="updated_to_blabber_google">We have to apologize that we could not update directly to blabber.im. Under the following link you will receive instructions on how to transfer all your profiles from Pix-Art Messenger to blabber.im.</string>
|
||||
<string name="link">Link</string>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Reference in a new issue