Improved release type

pull/214/head
M66B 1 year ago
parent b867e38530
commit 5b50da3ca1

@ -64,17 +64,8 @@ public class FragmentAbout extends FragmentBase {
tvVersion.setText(getString(R.string.title_version, version));
tvRelease.setText(BuildConfig.RELEASE_NAME);
String source = Log.getReleaseType(context) + (BuildConfig.DEBUG ? "/Debug" : "");
try {
String installer = context.getPackageManager().getInstallerPackageName(BuildConfig.APPLICATION_ID);
if (installer != null && !"com.android.vending".equals(installer))
source += " (" + installer + ")";
} catch (Throwable ex) {
Log.w(ex);
}
tvDownloaded.setText(getString(R.string.app_download, source));
String type = Log.getReleaseType(context) + (BuildConfig.DEBUG ? " (Debug)" : "");
tvDownloaded.setText(getString(R.string.app_download, type));
long last = 0;
try {

@ -24,8 +24,13 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.StyleSpan;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@ -61,6 +66,7 @@ public class FragmentPro extends FragmentBase implements SharedPreferences.OnSha
private TextView tvPrice;
private TextView tvGoogle;
private TextView tvNoPlay;
private TextView tvDownloaded;
private TextView tvPriceHint;
private TextView tvFamilyHint;
private TextView tvRestoreHint;
@ -90,6 +96,7 @@ public class FragmentPro extends FragmentBase implements SharedPreferences.OnSha
tvPrice = view.findViewById(R.id.tvPrice);
tvGoogle = view.findViewById(R.id.tvGoogle);
tvNoPlay = view.findViewById(R.id.tvNoPlay);
tvDownloaded = view.findViewById(R.id.tvDownloaded);
tvPriceHint = view.findViewById(R.id.tvPriceHint);
tvFamilyHint = view.findViewById(R.id.tvFamilyHint);
tvRestoreHint = view.findViewById(R.id.tvRestoreHint);
@ -136,6 +143,16 @@ public class FragmentPro extends FragmentBase implements SharedPreferences.OnSha
}
});
String type = Log.getReleaseType(getContext());
String installer = Helper.getInstallerName(getContext());
tvDownloaded.setText(getString(R.string.app_download, type));
if (BuildConfig.PLAY_STORE_RELEASE)
tvDownloaded.setVisibility(
installer != null && !Helper.PLAY_PACKAGE_NAME.equals(installer)
? View.VISIBLE : View.GONE);
else
tvDownloaded.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
tvPriceHint.setPaintFlags(tvPriceHint.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
tvPriceHint.setOnClickListener(new View.OnClickListener() {
@Override

@ -188,6 +188,7 @@ public class Helper {
private static Boolean hasPlayStore = null;
private static Boolean hasValidFingerprint = null;
private static Boolean isSmartwatch = null;
private static String installerName = "?";
static final float LOW_LIGHT = 0.6f;
@ -200,6 +201,8 @@ public class Helper {
static final long PIN_FAILURE_DELAY_MAX = 20 * 60 * 1000L; // milliseconds
static final float BNV_LUMINANCE_THRESHOLD = 0.7f;
static final String PLAY_PACKAGE_NAME = "com.android.vending";
static final String PGP_OPENKEYCHAIN_PACKAGE = "org.sufficientlysecure.keychain";
static final String PGP_BEGIN_MESSAGE = "-----BEGIN PGP MESSAGE-----";
static final String PGP_END_MESSAGE = "-----END PGP MESSAGE-----";
@ -1367,6 +1370,18 @@ public class Helper {
return new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + BuildConfig.APPLICATION_ID));
}
static String getInstallerName(Context context) {
if ("?".equals(installerName))
try {
PackageManager pm = context.getPackageManager();
installerName = pm.getInstallerPackageName(BuildConfig.APPLICATION_ID);
} catch (Throwable ex) {
Log.e(ex);
installerName = null;
}
return installerName;
}
static long getInstallTime(Context context) {
try {
PackageManager pm = context.getPackageManager();

@ -492,7 +492,7 @@ public class Log {
String no_internet = context.getString(R.string.title_no_internet);
String installer = context.getPackageManager().getInstallerPackageName(BuildConfig.APPLICATION_ID);
String installer = Helper.getInstallerName(context);
config.addMetadata("extra", "revision", BuildConfig.REVISION);
config.addMetadata("extra", "installer", installer == null ? "-" : installer);
config.addMetadata("extra", "installed", new Date(Helper.getInstallTime(context)).toString());
@ -636,11 +636,15 @@ public class Log {
}
}
static String getReleaseType(Context context) {
static @NonNull String getReleaseType(Context context) {
if (Helper.hasValidFingerprint(context)) {
if (BuildConfig.PLAY_STORE_RELEASE)
return "Play Store";
else if (BuildConfig.FDROID_RELEASE)
if (BuildConfig.PLAY_STORE_RELEASE) {
String installer = Helper.getInstallerName(context);
String type = "Play Store";
if (installer != null && !Helper.PLAY_PACKAGE_NAME.equals(installer))
type += " (" + installer + ")";
return type;
} else if (BuildConfig.FDROID_RELEASE)
return "Reproducible";
else if (BuildConfig.AMAZON_RELEASE)
return "Amazon";
@ -2002,7 +2006,6 @@ public class Log {
long last_cleanup = prefs.getLong("last_cleanup", 0);
PackageManager pm = context.getPackageManager();
String installer = pm.getInstallerPackageName(BuildConfig.APPLICATION_ID);
// Get version info
sb.append(String.format("%s %s\r\n", context.getString(R.string.app_name), getVersionInfo(context)));
@ -2031,9 +2034,10 @@ public class Log {
Log.e(ex);
}
String installer = Helper.getInstallerName(context);
sb.append(String.format("Release: %s\r\n", getReleaseType(context)));
sb.append(String.format("Play Store: %s\r\n", Helper.hasPlayStore(context)));
sb.append(String.format("Installer: %s\r\n", installer));
sb.append(String.format("Installer: %s\r\n", installer == null ? "-" : installer));
sb.append(String.format("Installed: %s\r\n", new Date(Helper.getInstallTime(context))));
sb.append(String.format("Updated: %s\r\n", new Date(Helper.getUpdateTime(context))));
sb.append(String.format("Last cleanup: %s\r\n", new Date(last_cleanup)));

@ -135,6 +135,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvGoogle" />
<TextView
android:id="@+id/tvDownloaded"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/app_download"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvNoPlay" />
<TextView
android:id="@+id/tvHint"
android:layout_width="wrap_content"
@ -143,7 +153,7 @@
android:text="@string/title_pro_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNoPlay" />
app:layout_constraintTop_toBottomOf="@id/tvDownloaded" />
<TextView
android:id="@+id/tvPriceHint"

Loading…
Cancel
Save