mirror of
https://gitlab.com/xynngh/YetAnotherCallBlocker.git
synced 2025-01-27 07:46:13 +01:00
Add "About" screen
This commit is contained in:
parent
e545365c66
commit
74b2df76e4
@ -98,6 +98,14 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".AboutActivity"
|
||||
android:label="@string/about_activity"
|
||||
android:parentActivityName=".MainActivity">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".MainActivity" />
|
||||
</activity>
|
||||
|
||||
<receiver
|
||||
android:name=".StartupReceiver"
|
||||
|
@ -0,0 +1,163 @@
|
||||
package dummydomain.yetanothercallblocker;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.text.format.DateUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||
import dummydomain.yetanothercallblocker.event.MainDbDownloadFinishedEvent;
|
||||
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdateFinished;
|
||||
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdatingEvent;
|
||||
import dummydomain.yetanothercallblocker.sia.model.database.CommunityDatabase;
|
||||
import dummydomain.yetanothercallblocker.work.TaskService;
|
||||
|
||||
public class AboutActivity extends AppCompatActivity {
|
||||
|
||||
private final Settings settings = App.getSettings();
|
||||
private final CommunityDatabase communityDatabase = YacbHolder.getCommunityDatabase();
|
||||
|
||||
private TextView dbInfoTv;
|
||||
|
||||
private boolean checkingForUpdates;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
|
||||
setLink(R.id.homepage, R.string.url_repo, R.string.homepage);
|
||||
setLink(R.id.faq, R.string.url_faq, R.string.faq);
|
||||
setLink(R.id.translate, R.string.url_translate, R.string.translate);
|
||||
setLink(R.id.issues, R.string.url_issues, R.string.issues);
|
||||
|
||||
((TextView) findViewById(R.id.app_version)).setText(
|
||||
getString(R.string.version_string, BuildConfig.VERSION_NAME));
|
||||
|
||||
dbInfoTv = findViewById(R.id.db_info);
|
||||
|
||||
dbInfoTv.setOnLongClickListener(this::onDbInfoLongClicked);
|
||||
|
||||
if (EventUtils.bus().getStickyEvent(SecondaryDbUpdatingEvent.class) != null) {
|
||||
checkingForUpdates = true;
|
||||
}
|
||||
|
||||
updateDbInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
EventUtils.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
EventUtils.unregister(this);
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
|
||||
public void onMainDbDownloadFinished(MainDbDownloadFinishedEvent event) {
|
||||
updateDbInfo();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
|
||||
public void onSecondaryDbUpdating(SecondaryDbUpdatingEvent event) {
|
||||
checkingForUpdates = true;
|
||||
updateDbInfo();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
|
||||
public void onSecondaryDbUpdateFinished(SecondaryDbUpdateFinished event) {
|
||||
checkingForUpdates = false;
|
||||
updateDbInfo();
|
||||
}
|
||||
|
||||
private void updateDbInfo() {
|
||||
// TODO: async?
|
||||
|
||||
boolean clickable;
|
||||
|
||||
String dbVersionValue;
|
||||
if (communityDatabase.isOperational()) {
|
||||
dbVersionValue = String.valueOf(communityDatabase.getEffectiveDbVersion());
|
||||
clickable = true;
|
||||
} else {
|
||||
dbVersionValue = getString(R.string.db_version_not_available);
|
||||
clickable = false;
|
||||
}
|
||||
|
||||
if (clickable && checkingForUpdates) clickable = false;
|
||||
|
||||
setUpdateClickable(clickable);
|
||||
|
||||
String lastCheckValue;
|
||||
if (checkingForUpdates) {
|
||||
lastCheckValue = getString(R.string.db_last_update_check_checking);
|
||||
} else {
|
||||
long lastUpdateCheckTime = settings.getLastUpdateCheckTime();
|
||||
lastCheckValue = lastUpdateCheckTime != 0 ?
|
||||
DateUtils.getRelativeTimeSpanString(lastUpdateCheckTime).toString()
|
||||
: getString(R.string.db_last_update_check_never);
|
||||
}
|
||||
|
||||
String dbInfoString = getString(R.string.db_version, dbVersionValue)
|
||||
+ "\n" + getString(R.string.db_last_update_check, lastCheckValue);
|
||||
|
||||
dbInfoTv.setText(dbInfoString);
|
||||
}
|
||||
|
||||
private void setUpdateClickable(boolean clickable) {
|
||||
dbInfoTv.setClickable(clickable);
|
||||
}
|
||||
|
||||
public void onUpdateDbClicked(View view) {
|
||||
setUpdateClickable(false);
|
||||
|
||||
TaskService.start(this, TaskService.TASK_UPDATE_SECONDARY_DB);
|
||||
}
|
||||
|
||||
private boolean onDbInfoLongClicked(View view) {
|
||||
startActivity(new Intent(this, DbManagementActivity.class));
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setLink(@IdRes int textView, @StringRes int url, @StringRes int text) {
|
||||
setLink(findViewById(textView), getString(url), getString(text));
|
||||
}
|
||||
|
||||
private void setLink(TextView textView, String url, String text) {
|
||||
textView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
textView.setText(fromHtml("<a href=\"" + url + "\">" + text + "</a>"));
|
||||
}
|
||||
|
||||
private static Spanned fromHtml(String s) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
return Html.fromHtml(s, Html.FROM_HTML_MODE_LEGACY);
|
||||
} else {
|
||||
return fromHtmlLegacy(s);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"deprecation", "RedundantSuppression"})
|
||||
private static Spanned fromHtmlLegacy(String s) {
|
||||
return Html.fromHtml(s);
|
||||
}
|
||||
|
||||
}
|
@ -280,6 +280,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
startActivity(new Intent(this, SettingsActivity.class));
|
||||
}
|
||||
|
||||
public void onOpenAbout(MenuItem item) {
|
||||
startActivity(new Intent(this, AboutActivity.class));
|
||||
}
|
||||
|
||||
private void onCallLogItemClicked(CallLogItemGroup item) {
|
||||
InfoDialogHelper.showDialog(this, item.getItems().get(0).numberInfo, null);
|
||||
}
|
||||
|
15
app/src/main/res/drawable/logo.xml
Normal file
15
app/src/main/res/drawable/logo.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="#01579B" />
|
||||
<corners android:radius="4dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
android:bottom="-18dp"
|
||||
android:drawable="@drawable/ic_launcher_foreground"
|
||||
android:left="-18dp"
|
||||
android:right="-18dp"
|
||||
android:top="-18dp" />
|
||||
</layer-list>
|
99
app/src/main/res/layout/activity_about.xml
Normal file
99
app/src/main/res/layout/activity_about.xml
Normal file
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".AboutActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/text_margin">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:contentDescription="@string/logo_description"
|
||||
app:srcCompat="@drawable/logo" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="26dp"
|
||||
android:text="@string/app_name"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/motto" />
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/homepage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
tools:text="@string/homepage" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/faq"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
tools:text="@string/faq" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/translate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
tools:text="@string/translate" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/issues"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
tools:text="@string/issues" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/license" />
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
tools:text="v0.5.8" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/db_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:longClickable="true"
|
||||
android:onClick="onUpdateDbClicked"
|
||||
tools:text="Database version: 1800\nLast update check: 1 minute ago" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -41,4 +41,8 @@
|
||||
android:onClick="onOpenSettings"
|
||||
android:title="@string/open_settings_activity" />
|
||||
|
||||
<item
|
||||
android:onClick="onOpenAbout"
|
||||
android:title="@string/open_about_activity" />
|
||||
|
||||
</menu>
|
@ -184,4 +184,21 @@
|
||||
<string name="duration_h_m_s">%1$dч %2$dм %3$dс</string>
|
||||
<string name="duration_m_s">%1$dм %2$dс</string>
|
||||
<string name="duration_s">%dс</string>
|
||||
|
||||
<string name="open_about_activity">О приложении</string>
|
||||
<string name="about_activity">О приложении</string>
|
||||
<string name="version_string">v%s</string>
|
||||
<string name="db_version">Версия базы: %s</string>
|
||||
<string name="db_version_not_available">Н/Д</string>
|
||||
<string name="db_last_update_check">Последняя проверка: %s</string>
|
||||
<string name="db_last_update_check_never">никогда</string>
|
||||
<string name="db_last_update_check_checking">проверяем…</string>
|
||||
|
||||
<string name="motto">Без труда блокируйте нежелательные вызовы</string>
|
||||
<string name="logo_description">Логотип</string>
|
||||
<string name="homepage">Домашняя страница проекта</string>
|
||||
<string name="faq">Часто задаваемые вопросы</string>
|
||||
<string name="translate">Перевести приложение на Weblate</string>
|
||||
<string name="issues">Получить поддержку / сообщить о проблеме</string>
|
||||
<string name="license">Это приложение распространяется под лицензией AGPL-3.0-only.</string>
|
||||
</resources>
|
@ -204,4 +204,25 @@
|
||||
<string name="duration_h_m_s">%1$dh %2$dm %3$ds</string>
|
||||
<string name="duration_m_s">%1$dm %2$ds</string>
|
||||
<string name="duration_s">%ds</string>
|
||||
|
||||
<string name="open_about_activity">About</string>
|
||||
<string name="about_activity">About</string>
|
||||
<string name="version_string">v%s</string>
|
||||
<string name="db_version">Database version: %s</string>
|
||||
<string name="db_version_not_available">n/a</string>
|
||||
<string name="db_last_update_check">Last update check: %s</string>
|
||||
<string name="db_last_update_check_never">never</string>
|
||||
<string name="db_last_update_check_checking">checking…</string>
|
||||
|
||||
<string name="motto">Block unwanted calls effortlessly</string>
|
||||
<string name="logo_description">Logo</string>
|
||||
<string name="homepage">Project homepage</string>
|
||||
<string name="faq">Frequently Asked Questions</string>
|
||||
<string name="translate">Translate the app on Weblate</string>
|
||||
<string name="issues">Get support / report a problem</string>
|
||||
<string name="license">This application is licensed under AGPL-3.0-only.</string>
|
||||
<string name="url_repo" translatable="false">https://gitlab.com/xynngh/YetAnotherCallBlocker</string>
|
||||
<string name="url_faq" translatable="false">https://gitlab.com/xynngh/YetAnotherCallBlocker/-/blob/master/FAQ.md</string>
|
||||
<string name="url_translate" translatable="false">https://hosted.weblate.org/engage/yet-another-call-blocker/</string>
|
||||
<string name="url_issues" translatable="false">https://gitlab.com/xynngh/YetAnotherCallBlocker/-/issues</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user