Show last updated time

This commit is contained in:
M66B 2021-03-24 12:26:42 +01:00
parent cce1875c0f
commit a29402895d
3 changed files with 31 additions and 2 deletions

View File

@ -20,6 +20,8 @@ package eu.faircode.email;
*/
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
@ -39,6 +41,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.widget.TextViewCompat;
import java.text.DateFormat;
import java.util.List;
public class FragmentAbout extends FragmentBase {
@ -52,6 +55,7 @@ public class FragmentAbout extends FragmentBase {
TextView tvVersion = view.findViewById(R.id.tvVersion);
TextView tvRelease = view.findViewById(R.id.tvRelease);
TextView tvUpdated = view.findViewById(R.id.tvUpdated);
ImageButton ibUpdate = view.findViewById(R.id.ibUpdate);
TextView tvGplV3 = view.findViewById(R.id.tvGplV3);
LinearLayout llContributors = view.findViewById(R.id.llContributors);
@ -59,6 +63,18 @@ public class FragmentAbout extends FragmentBase {
tvVersion.setText(getString(R.string.title_version, BuildConfig.VERSION_NAME));
tvRelease.setText(BuildConfig.RELEASE_NAME);
long last = 0;
try {
PackageManager pm = getContext().getPackageManager();
PackageInfo pi = pm.getPackageInfo(BuildConfig.APPLICATION_ID, 0);
last = pi.lastUpdateTime;
} catch (Throwable ex) {
Log.e(ex);
}
DateFormat DF = Helper.getDateTimeInstance(getContext(), DateFormat.SHORT, DateFormat.SHORT);
tvUpdated.setText(getString(R.string.app_updated, last == 0 ? "-" : DF.format(last)));
ibUpdate.setVisibility(
Helper.hasValidFingerprint(getContext()) || BuildConfig.DEBUG
? View.VISIBLE : View.GONE);

View File

@ -34,16 +34,28 @@
app:layout_constraintStart_toEndOf="@id/tvVersion"
app:layout_constraintTop_toTopOf="@id/tvVersion" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvUpdated"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="@string/app_updated"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toStartOf="@+id/ibUpdate"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRelease" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvCopyright"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/app_copyright"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toStartOf="@+id/ibUpdate"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvVersion" />
app:layout_constraintTop_toBottomOf="@id/tvUpdated" />
<ImageButton
android:id="@+id/ibUpdate"
@ -54,7 +66,7 @@
android:contentDescription="@string/title_more"
android:padding="6dp"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="@+id/tvCopyright"
app:layout_constraintBottom_toBottomOf="@+id/tvUpdated"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/tvVersion"
app:srcCompat="@drawable/twotone_cached_24" />

View File

@ -9,6 +9,7 @@
<string name="app_crash">FairEmail is not supported on this device because bugs in Android cause crashes</string>
<string name="app_exit">Go \'back\' again to exit</string>
<string name="app_cake">Insufficient storage space left</string>
<string name="app_updated">Last update: %1$s</string>
<string name="channel_service">Receive</string>
<string name="channel_send">Send</string>