package com.example.dutest.stub; import android.app.Activity; import android.content.pm.PackageInfo; import android.os.Bundle; import android.view.Gravity; import android.widget.TextView; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; /** * The whole of every test app: one screen naming which app this is and when * the installed copy landed. * * One class shared by all of them rather than one per project, because what * differs between the test projects is what Dev Updater has to *do* with * them -- how many variants they build, whether the build fails, whether * they declare a service -- and none of that is a difference in the app. * The manifest names this class fully qualified, so each APK can carry its * own application id while the code keeps one package. * * It shows lastUpdateTime deliberately: that is the exact value Dev * Updater's freshness check compares an APK's mtime against, so the screen * shows what the card is reasoning about rather than a separate version * string that could agree with it by luck. */ public class StubActivity extends Activity { @Override protected void onCreate(Bundle state) { super.onCreate(state); TextView view = new TextView(this); view.setGravity(Gravity.CENTER); view.setTextSize(20f); view.setLineSpacing(0f, 1.3f); view.setPadding(64, 64, 64, 64); // Catppuccin Mocha Base and Text, matching the updater's own theme // so a screenshot of one does not look like a different machine. view.setBackgroundColor(0xFF1E1E2E); view.setTextColor(0xFFCDD6F4); view.setText(describe()); setContentView(view); } private String describe() { CharSequence label = getApplicationInfo().loadLabel(getPackageManager()); return label + "\n\n" + getPackageName() + "\n\ninstalled " + installedAt(); } /** * When the package manager says this copy was installed, or why that * could not be read -- never a stand-in that reads like an answer. */ private String installedAt() { try { PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0); return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US) .format(new Date(info.lastUpdateTime)); } catch (Exception failure) { return "unknown (" + failure.getClass().getSimpleName() + ")"; } } }