2019-09-05 00:24:33 +02:00
|
|
|
package com.beemdevelopment.aegis.ui;
|
|
|
|
|
2019-09-07 21:37:06 +02:00
|
|
|
import android.content.ClipData;
|
|
|
|
import android.content.ClipboardManager;
|
|
|
|
import android.content.Context;
|
2019-09-05 00:24:33 +02:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Bundle;
|
2020-05-24 15:09:54 +02:00
|
|
|
import android.view.MenuItem;
|
2019-09-05 00:24:33 +02:00
|
|
|
import android.view.View;
|
|
|
|
import android.widget.TextView;
|
2019-09-07 21:37:06 +02:00
|
|
|
import android.widget.Toast;
|
2019-09-05 00:24:33 +02:00
|
|
|
|
2020-05-06 17:48:48 -07:00
|
|
|
import androidx.annotation.AttrRes;
|
2019-09-14 15:20:02 +02:00
|
|
|
import androidx.annotation.StringRes;
|
|
|
|
import androidx.core.view.LayoutInflaterCompat;
|
|
|
|
|
2019-09-07 21:17:32 +02:00
|
|
|
import com.beemdevelopment.aegis.BuildConfig;
|
2019-09-05 00:24:33 +02:00
|
|
|
import com.beemdevelopment.aegis.R;
|
|
|
|
import com.beemdevelopment.aegis.Theme;
|
|
|
|
import com.beemdevelopment.aegis.helpers.ThemeHelper;
|
2020-08-10 18:49:53 +02:00
|
|
|
import com.beemdevelopment.aegis.licenses.GlideLicense;
|
|
|
|
import com.beemdevelopment.aegis.licenses.ProtobufLicense;
|
2019-09-05 00:24:33 +02:00
|
|
|
import com.mikepenz.iconics.context.IconicsLayoutInflater2;
|
|
|
|
|
|
|
|
import de.psdev.licensesdialog.LicenseResolver;
|
|
|
|
import de.psdev.licensesdialog.LicensesDialog;
|
|
|
|
|
|
|
|
public class AboutActivity extends AegisActivity {
|
|
|
|
|
|
|
|
private static String GITHUB = "https://github.com/beemdevelopment/Aegis";
|
|
|
|
private static String WEBSITE_ALEXANDER = "https://alexbakker.me";
|
|
|
|
private static String GITHUB_MICHAEL = "https://github.com/michaelschattgen";
|
|
|
|
|
|
|
|
private static String MAIL_BEEMDEVELOPMENT = "beemdevelopment@gmail.com";
|
|
|
|
private static String WEBSITE_BEEMDEVELOPMENT = "https://beem.dev/";
|
|
|
|
private static String PLAYSTORE_BEEMDEVELOPMENT = "https://play.google.com/store/apps/details?id=com.beemdevelopment.aegis";
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
LayoutInflaterCompat.setFactory2(getLayoutInflater(), new IconicsLayoutInflater2(getDelegate()));
|
|
|
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_about);
|
|
|
|
|
2020-05-24 15:09:54 +02:00
|
|
|
if (getSupportActionBar() != null) {
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
|
|
|
}
|
|
|
|
|
2019-09-05 00:24:33 +02:00
|
|
|
View btnLicenses = findViewById(R.id.btn_licenses);
|
|
|
|
btnLicenses.setOnClickListener(v -> showLicenseDialog());
|
|
|
|
|
|
|
|
TextView appVersion = findViewById(R.id.app_version);
|
2019-09-07 21:17:32 +02:00
|
|
|
appVersion.setText(getCurrentAppVersion());
|
2019-09-05 00:24:33 +02:00
|
|
|
|
2019-09-07 21:37:06 +02:00
|
|
|
View btnAppVersion = findViewById(R.id.btn_app_version);
|
|
|
|
btnAppVersion.setOnClickListener(v -> {
|
|
|
|
copyToClipboard(getCurrentAppVersion(), R.string.version_copied);
|
|
|
|
});
|
|
|
|
|
2019-09-05 00:24:33 +02:00
|
|
|
View btnGithub = findViewById(R.id.btn_github);
|
|
|
|
btnGithub.setOnClickListener(v -> openUrl(GITHUB));
|
|
|
|
|
|
|
|
View btnAlexander = findViewById(R.id.btn_alexander);
|
|
|
|
btnAlexander.setOnClickListener(v -> openUrl(WEBSITE_ALEXANDER));
|
|
|
|
|
|
|
|
View btnMichael = findViewById(R.id.btn_michael);
|
|
|
|
btnMichael.setOnClickListener(v -> openUrl(GITHUB_MICHAEL));
|
|
|
|
|
|
|
|
View btnMail = findViewById(R.id.btn_email);
|
|
|
|
btnMail.setOnClickListener(v -> openMail(MAIL_BEEMDEVELOPMENT));
|
|
|
|
|
|
|
|
View btnWebsite = findViewById(R.id.btn_website);
|
|
|
|
btnWebsite.setOnClickListener(v -> openUrl(WEBSITE_BEEMDEVELOPMENT));
|
|
|
|
|
|
|
|
View btnRate = findViewById(R.id.btn_rate);
|
|
|
|
btnRate.setOnClickListener(v -> openUrl(PLAYSTORE_BEEMDEVELOPMENT ));
|
|
|
|
|
|
|
|
View btnChangelog = findViewById(R.id.btn_changelog);
|
|
|
|
btnChangelog.setOnClickListener(v -> {
|
2020-07-11 18:42:44 +02:00
|
|
|
ChangelogDialog.create().setTheme(getConfiguredTheme()).show(getSupportFragmentManager(), "CHANGELOG_DIALOG");
|
2019-09-05 00:24:33 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-09-07 21:17:32 +02:00
|
|
|
private static String getCurrentAppVersion() {
|
|
|
|
if (BuildConfig.DEBUG) {
|
|
|
|
return String.format("%s-%s (%s)", BuildConfig.VERSION_NAME, BuildConfig.GIT_HASH, BuildConfig.GIT_BRANCH);
|
2019-09-05 00:24:33 +02:00
|
|
|
}
|
2019-09-07 21:17:32 +02:00
|
|
|
|
|
|
|
return BuildConfig.VERSION_NAME;
|
2019-09-05 00:24:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void openUrl(String url) {
|
|
|
|
Intent browserIntent = new Intent(Intent.ACTION_VIEW);
|
|
|
|
browserIntent.setData(Uri.parse(url));
|
|
|
|
browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
|
|
|
|
startActivity(browserIntent);
|
|
|
|
}
|
|
|
|
|
2019-09-07 21:37:06 +02:00
|
|
|
private void copyToClipboard(String text, @StringRes int messageId) {
|
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
|
|
|
ClipData data = ClipData.newPlainText("text/plain", text);
|
|
|
|
clipboard.setPrimaryClip(data);
|
|
|
|
Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
|
2019-09-05 00:24:33 +02:00
|
|
|
private void openMail(String mailaddress) {
|
|
|
|
Intent mailIntent = new Intent(Intent.ACTION_SENDTO);
|
|
|
|
mailIntent.setData(Uri.parse("mailto:" + mailaddress));
|
|
|
|
mailIntent.putExtra(Intent.EXTRA_EMAIL, mailaddress);
|
|
|
|
mailIntent.putExtra(Intent.EXTRA_SUBJECT, R.string.app_name_full);
|
|
|
|
|
|
|
|
startActivity(Intent.createChooser(mailIntent, this.getString(R.string.email)));
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showLicenseDialog() {
|
|
|
|
String stylesheet = getString(R.string.custom_notices_format_style);
|
2020-07-11 18:42:44 +02:00
|
|
|
int backgroundColorResource = getConfiguredTheme() == Theme.AMOLED ? R.attr.cardBackgroundFocused : R.attr.cardBackground;
|
2020-05-06 17:48:48 -07:00
|
|
|
String backgroundColor = getThemeColorAsHex(backgroundColorResource);
|
|
|
|
String textColor = getThemeColorAsHex(R.attr.primaryText);
|
|
|
|
String licenseColor = getThemeColorAsHex(R.attr.cardBackgroundFocused);
|
|
|
|
String linkColor = getThemeColorAsHex(R.attr.colorAccent);
|
2019-09-05 00:24:33 +02:00
|
|
|
|
2020-05-06 17:48:48 -07:00
|
|
|
stylesheet = String.format(stylesheet, backgroundColor, textColor, licenseColor, linkColor);
|
2019-09-05 00:24:33 +02:00
|
|
|
|
|
|
|
LicenseResolver.registerLicense(new GlideLicense());
|
2020-08-10 18:49:53 +02:00
|
|
|
LicenseResolver.registerLicense(new ProtobufLicense());
|
|
|
|
|
2019-09-05 00:24:33 +02:00
|
|
|
new LicensesDialog.Builder(this)
|
|
|
|
.setNotices(R.raw.notices)
|
|
|
|
.setTitle(R.string.licenses)
|
|
|
|
.setNoticesCssStyle(stylesheet)
|
|
|
|
.setIncludeOwnLicense(true)
|
|
|
|
.build()
|
|
|
|
.show();
|
|
|
|
}
|
2020-05-06 17:48:48 -07:00
|
|
|
|
|
|
|
private String getThemeColorAsHex(@AttrRes int attributeId) {
|
|
|
|
return String.format("%06X", (0xFFFFFF & ThemeHelper.getThemeColor(attributeId, getTheme())));
|
|
|
|
}
|
2020-05-24 15:09:54 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case android.R.id.home:
|
|
|
|
onBackPressed();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2019-09-05 00:24:33 +02:00
|
|
|
}
|