From 04e52f0a8a5ca07abb175de7e293b68a3e89f94e Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Mon, 23 Nov 2020 02:17:18 +0100 Subject: [PATCH] Move About dialog into own activity --- CHANGELOG.md | 6 + app/build.gradle | 1 - app/src/main/AndroidManifest.xml | 5 + .../protect/card_locker/AboutActivity.java | 125 ++++++++++++++++++ .../protect/card_locker/MainActivity.java | 107 +-------------- app/src/main/res/layout/about_activity.xml | 41 ++++++ .../res/layout/manage_groups_activity.xml | 2 +- 7 files changed, 180 insertions(+), 107 deletions(-) create mode 100644 app/src/main/java/protect/card_locker/AboutActivity.java create mode 100644 app/src/main/res/layout/about_activity.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index c1ff807be..cd992058b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +Changes: + +- Move About screen into its own activity + ## v1.3.0 (2020-11-22) Changes: diff --git a/app/build.gradle b/app/build.gradle index 09b96f6ab..cfcd3df69 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -53,7 +53,6 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.jaredrummler:colorpicker:1.0.2' implementation group: 'com.google.guava', name: 'guava', version: '20.0' - implementation 'com.github.apl-devs:appintro:v4.2.0' implementation "com.vanniktech:vntnumberpickerpreference:1.0.0" implementation 'androidx.cardview:cardview:1.0.0' testImplementation 'junit:junit:4.12' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 82a908124..771c54445 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,6 +33,11 @@ + + USED_LIBRARIES = new ImmutableMap.Builder() + .put("Commons CSV", "https://commons.apache.org/proper/commons-csv/") + .put("Guava", "https://github.com/google/guava") + .put("ZXing", "https://github.com/zxing/zxing") + .put("ZXing Android Embedded", "https://github.com/journeyapps/zxing-android-embedded") + .put("Color Picker", "https://github.com/jaredrummler/ColorPicker") + .put("VNTNumberPickerPreference", "https://github.com/vanniktech/VNTNumberPickerPreference") + .build(); + + final Map USED_ASSETS = ImmutableMap.of + ( + "Save by Bernar Novalyi", "https://thenounproject.com/term/save/716011" + ); + + StringBuilder libs = new StringBuilder().append("
"); + for (Map.Entry entry : USED_LIBRARIES.entrySet()) + { + libs.append("
").append(entry.getKey()).append("
"); + } + + StringBuilder resources = new StringBuilder().append("
"); + for (Map.Entry entry : USED_ASSETS.entrySet()) + { + resources.append("
").append(entry.getKey()).append("
"); + } + + String appName = getString(R.string.app_name); + int year = Calendar.getInstance().get(Calendar.YEAR); + + String version = "?"; + try + { + PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0); + version = pi.versionName; + } + catch (PackageManager.NameNotFoundException e) + { + Log.w(TAG, "Package name not found", e); + } + + setTitle(String.format(getString(R.string.about_title_fmt), appName)); + + TextView aboutTextView = findViewById(R.id.aboutText); + aboutTextView.setText(HtmlCompat.fromHtml(String.format(getString(R.string.debug_version_fmt), version) + + "

" + + String.format(getString(R.string.app_revision_fmt), + "" + + "GitHub" + + "") + + "

" + + String.format(getString(R.string.app_copyright_fmt), year) + + "

" + + getString(R.string.app_copyright_old) + + "

" + + getString(R.string.app_license) + + "

" + + String.format(getString(R.string.app_libraries), appName, libs.toString()) + + "

" + + String.format(getString(R.string.app_resources), appName, resources.toString()), HtmlCompat.FROM_HTML_MODE_COMPACT)); + aboutTextView.setMovementMethod(LinkMovementMethod.getInstance()); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) + { + int id = item.getItemId(); + + if (id == android.R.id.home) { + finish(); + } + + return super.onOptionsItemSelected(item); + } +} \ No newline at end of file diff --git a/app/src/main/java/protect/card_locker/MainActivity.java b/app/src/main/java/protect/card_locker/MainActivity.java index e75c93d9d..e3f5d3b6f 100644 --- a/app/src/main/java/protect/card_locker/MainActivity.java +++ b/app/src/main/java/protect/card_locker/MainActivity.java @@ -4,15 +4,11 @@ import android.app.SearchManager; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; import android.content.res.Configuration; import android.database.Cursor; import android.os.Bundle; -import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.Toolbar; @@ -24,18 +20,14 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; -import android.webkit.WebView; import android.widget.AdapterView; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.tabs.TabLayout; -import com.google.common.collect.ImmutableMap; -import java.util.Calendar; import java.util.List; -import java.util.Map; import protect.card_locker.preferences.SettingsActivity; public class MainActivity extends AppCompatActivity implements GestureDetector.OnGestureListener @@ -396,109 +388,14 @@ public class MainActivity extends AppCompatActivity implements GestureDetector.O if(id == R.id.action_about) { - displayAboutDialog(); + Intent i = new Intent(getApplicationContext(), AboutActivity.class); + startActivityForResult(i, MAIN_REQUEST_CODE); return true; } return super.onOptionsItemSelected(item); } - private void displayAboutDialog() - { - final Map USED_LIBRARIES = new ImmutableMap.Builder() - .put("Commons CSV", "https://commons.apache.org/proper/commons-csv/") - .put("Guava", "https://github.com/google/guava") - .put("ZXing", "https://github.com/zxing/zxing") - .put("ZXing Android Embedded", "https://github.com/journeyapps/zxing-android-embedded") - .put("AppIntro", "https://github.com/apl-devs/AppIntro") - .put("Color Picker", "https://github.com/jaredrummler/ColorPicker") - .put("VNTNumberPickerPreference", "https://github.com/vanniktech/VNTNumberPickerPreference") - .build(); - - final Map USED_ASSETS = ImmutableMap.of - ( - "Save by Bernar Novalyi", "https://thenounproject.com/term/save/716011" - ); - - StringBuilder libs = new StringBuilder().append(""); - - StringBuilder resources = new StringBuilder().append(""); - - String appName = getString(R.string.app_name); - int year = Calendar.getInstance().get(Calendar.YEAR); - - String version = "?"; - try - { - PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0); - version = pi.versionName; - } - catch (PackageManager.NameNotFoundException e) - { - Log.w(TAG, "Package name not found", e); - } - - WebView wv = new WebView(this); - - // Set CSS for dark mode if dark mode - String css = ""; - if(isDarkModeEnabled(this)) - { - css = ""; - } - - String html = - "" + - css + - "

" + - String.format(getString(R.string.about_title_fmt), - "" + - appName + - "" + - "

" + - appName + - " " + - String.format(getString(R.string.debug_version_fmt), version) + - "

" + - String.format(getString(R.string.app_revision_fmt), - "" + - "GitHub" + - "") + - "


" + - String.format(getString(R.string.app_copyright_fmt), year) + - "

" + - getString(R.string.app_copyright_old) + - "


" + - getString(R.string.app_license) + - "


" + - String.format(getString(R.string.app_libraries), appName, libs.toString()) + - "


" + - String.format(getString(R.string.app_resources), appName, resources.toString()); - - wv.loadDataWithBaseURL("file:///android_res/drawable/", html, "text/html", "utf-8", null); - new AlertDialog.Builder(this) - .setView(wv) - .setCancelable(true) - .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() - { - public void onClick(DialogInterface dialog, int which) - { - dialog.dismiss(); - } - }) - .show(); - } - protected static boolean isDarkModeEnabled(Context inputContext) { Configuration config = inputContext.getResources().getConfiguration(); diff --git a/app/src/main/res/layout/about_activity.xml b/app/src/main/res/layout/about_activity.xml new file mode 100644 index 000000000..2e29a7804 --- /dev/null +++ b/app/src/main/res/layout/about_activity.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/manage_groups_activity.xml b/app/src/main/res/layout/manage_groups_activity.xml index 8c43fba53..5c472ccb0 100644 --- a/app/src/main/res/layout/manage_groups_activity.xml +++ b/app/src/main/res/layout/manage_groups_activity.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" - tools:context="protect.card_locker.MainActivity"> + tools:context="protect.card_locker.ManageGroupsActivity">