-
-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from michaelschattgen/feature-about
Add AboutActivity
- Loading branch information
Showing
19 changed files
with
1,106 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<html> | ||
<head> | ||
<style type="text/css"> | ||
* { | ||
word-wrap: break-word; | ||
} | ||
body { | ||
background-color: #%1$s; | ||
color: #%2$s; | ||
} | ||
ul { | ||
list-style-position: inside; | ||
padding: 0; | ||
padding-left: 5px; | ||
} | ||
li { | ||
padding-bottom: 8px; | ||
list-style-position: outside; | ||
margin-left: 1em; | ||
} | ||
h3 { | ||
padding-bottom: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div></div> | ||
<h3>Version 1.0</h3> | ||
<h4>New</h4> | ||
<ul> | ||
<li>New icon</li> | ||
<li>Overhaul of interaction with the entry list</li> | ||
<li>Persistent notification while the vault is unlocked</li> | ||
<li>Language override option</li> | ||
<li>Support for importing from FreeOTP+</li> | ||
<li>Ability to toggle password visibility during unlock</li> | ||
<li>Support for deeplinking otpauth URIs</li> | ||
</ul> | ||
<h4>Fixes</h4> | ||
<ul> | ||
<li>Bad overall performance and high battery usage</li> | ||
<li>Codes with an uneven number of digits are displayed incorrectly</li> | ||
<li>Crash when entering a large value for OTP period</li> | ||
</ul> | ||
</body> |
121 changes: 121 additions & 0 deletions
121
app/src/main/java/com/beemdevelopment/aegis/ui/AboutActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package com.beemdevelopment.aegis.ui; | ||
|
||
import android.content.Intent; | ||
import android.content.pm.PackageManager; | ||
import android.content.res.Resources; | ||
import android.graphics.Color; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import com.beemdevelopment.aegis.Preferences; | ||
import com.beemdevelopment.aegis.R; | ||
import com.beemdevelopment.aegis.Theme; | ||
import com.beemdevelopment.aegis.helpers.ThemeHelper; | ||
import com.beemdevelopment.aegis.ui.glide.GlideLicense; | ||
import com.mikepenz.iconics.Iconics; | ||
import com.mikepenz.iconics.context.IconicsLayoutInflater2; | ||
import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic; | ||
|
||
import androidx.core.view.LayoutInflaterCompat; | ||
|
||
import de.psdev.licensesdialog.LicenseResolver; | ||
import de.psdev.licensesdialog.LicensesDialog; | ||
import de.psdev.licensesdialog.licenses.License; | ||
|
||
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 = "[email protected]"; | ||
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); | ||
|
||
Iconics.init(getApplicationContext()); | ||
Iconics.registerFont(new MaterialDesignIconic()); | ||
|
||
View btnLicenses = findViewById(R.id.btn_licenses); | ||
btnLicenses.setOnClickListener(v -> showLicenseDialog()); | ||
|
||
TextView appVersion = findViewById(R.id.app_version); | ||
appVersion.setText(getCurrentVersion()); | ||
|
||
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 -> { | ||
ChangelogDialog.create().setTheme(getCurrentTheme()).show(getSupportFragmentManager(), "CHANGELOG_DIALOG"); | ||
}); | ||
} | ||
|
||
private String getCurrentVersion() { | ||
try { | ||
return getPackageManager().getPackageInfo(getPackageName(), 0).versionName; | ||
} catch (PackageManager.NameNotFoundException e) { | ||
e.printStackTrace(); | ||
} | ||
return "Unknown version"; | ||
} | ||
|
||
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); | ||
} | ||
|
||
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); | ||
int backgroundColorResource = getCurrentTheme() == Theme.AMOLED ? R.attr.cardBackgroundFocused : R.attr.cardBackground; | ||
String backgroundColor = String.format("%06X", (0xFFFFFF & ThemeHelper.getThemeColor(backgroundColorResource, getTheme()))); | ||
String textColor = String.format("%06X", (0xFFFFFF & ThemeHelper.getThemeColor(R.attr.primaryText, getTheme()))); | ||
String licenseColor = String.format("%06X", (0xFFFFFF & ThemeHelper.getThemeColor(R.attr.cardBackgroundFocused, getTheme()))); | ||
|
||
stylesheet = String.format(stylesheet, backgroundColor, textColor, licenseColor); | ||
|
||
LicenseResolver.registerLicense(new GlideLicense()); | ||
new LicensesDialog.Builder(this) | ||
.setNotices(R.raw.notices) | ||
.setTitle(R.string.licenses) | ||
.setNoticesCssStyle(stylesheet) | ||
.setIncludeOwnLicense(true) | ||
.build() | ||
.show(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
app/src/main/java/com/beemdevelopment/aegis/ui/ChangelogDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.beemdevelopment.aegis.ui; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.app.Dialog; | ||
import android.content.Context; | ||
import android.content.pm.PackageInfo; | ||
import android.content.pm.PackageManager; | ||
import android.graphics.Color; | ||
import android.os.Bundle; | ||
import android.view.InflateException; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.webkit.WebView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.AlertDialog; | ||
import androidx.fragment.app.DialogFragment; | ||
|
||
import com.beemdevelopment.aegis.R; | ||
import com.beemdevelopment.aegis.Theme; | ||
import com.beemdevelopment.aegis.helpers.ThemeHelper; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.io.UnsupportedEncodingException; | ||
|
||
public class ChangelogDialog extends DialogFragment { | ||
private Theme _themeStyle; | ||
|
||
public static ChangelogDialog create() { | ||
return new ChangelogDialog(); | ||
} | ||
|
||
@SuppressLint("InflateParams") | ||
@NonNull | ||
@Override | ||
public Dialog onCreateDialog(Bundle savedInstanceState) { | ||
final View customView; | ||
try { | ||
customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_web_view, null); | ||
} catch (InflateException e) { | ||
e.printStackTrace(); | ||
return new AlertDialog.Builder(getActivity()) | ||
.setTitle(android.R.string.dialog_alert_title) | ||
.setMessage(getString(R.string.webview_error)) | ||
.setPositiveButton(android.R.string.ok, null) | ||
.show(); | ||
} | ||
AlertDialog dialog = new AlertDialog.Builder(getActivity()) | ||
.setTitle("Changelog") | ||
.setView(customView) | ||
.setPositiveButton(android.R.string.ok, null) | ||
.show(); | ||
|
||
final WebView webView = customView.findViewById(R.id.web_view); | ||
StringBuilder buf = new StringBuilder(); | ||
|
||
try (InputStream html = getActivity().getAssets().open("changelog.html")) { | ||
BufferedReader in = new BufferedReader(new InputStreamReader(html, "UTF-8")); | ||
String str; | ||
while ((str = in.readLine()) != null) | ||
buf.append(str); | ||
|
||
in.close(); | ||
String changelog = buf.toString(); | ||
changelog = replaceStylesheet(changelog); | ||
webView.loadData(changelog, "text/html", "UTF-8"); | ||
} catch (IOException e) { | ||
webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8"); | ||
} | ||
return dialog; | ||
} | ||
|
||
private String replaceStylesheet(String changelog) { | ||
int backgroundColorResource = _themeStyle == Theme.AMOLED ? R.attr.cardBackgroundFocused : R.attr.cardBackground; | ||
String backgroundColor = String.format("%06X", (0xFFFFFF & ThemeHelper.getThemeColor(backgroundColorResource, getContext().getTheme()))); | ||
String textColor = String.format("%06X", (0xFFFFFF & ThemeHelper.getThemeColor(R.attr.primaryText, getContext().getTheme()))); | ||
|
||
return String.format(changelog, backgroundColor, textColor); | ||
} | ||
|
||
public ChangelogDialog setTheme(Theme theme) { | ||
_themeStyle = theme; | ||
|
||
return this; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.