changeset 40:cfb19d4ccf78

About screen (but it has broken Edit screen).
author David Barts <n5jrn@me.com>
date Mon, 05 Apr 2021 09:08:31 -0700
parents d723d07d5bc0
children 9231f1a41a59
files app/src/main/AndroidManifest.xml app/src/main/assets/about_body.html app/src/main/assets/about_copyright.html app/src/main/assets/about_promo.html app/src/main/java/com/bartsent/simpleresizer/About.kt app/src/main/java/com/bartsent/simpleresizer/EditImage.kt app/src/main/res/drawable-anydpi/ic_action_about.xml app/src/main/res/drawable-hdpi/ic_action_about.png app/src/main/res/drawable-mdpi/ic_action_about.png app/src/main/res/drawable-xhdpi/ic_action_about.png app/src/main/res/drawable-xxhdpi/ic_action_about.png app/src/main/res/layout/activity_about.xml app/src/main/res/menu/menu_edit.xml app/src/main/res/values/strings.xml
diffstat 14 files changed, 144 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/app/src/main/AndroidManifest.xml	Sat Apr 03 09:24:30 2021 -0700
+++ b/app/src/main/AndroidManifest.xml	Mon Apr 05 09:08:31 2021 -0700
@@ -13,8 +13,20 @@
         android:supportsRtl="true"
         android:theme="@style/Theme.SimpleResizer">
 
-        <activity android:name=".SettingsActivity" android:label="@string/title_activity_settings">
-            <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".EditImage" />
+        <activity
+            android:name=".About"
+            android:label="@string/title_activity_about">
+            <meta-data
+                android:name="android.support.PARENT_ACTIVITY"
+                android:value=".EditImage" />
+        </activity>
+
+        <activity
+            android:name=".SettingsActivity"
+            android:label="@string/title_activity_settings">
+            <meta-data
+                android:name="android.support.PARENT_ACTIVITY"
+                android:value=".EditImage" />
             <intent-filter>
                 <action android:name="android.intent.action.APPLICATION_PREFERENCES" />
                 <category android:name="android.intent.category.PREFERENCE" />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/assets/about_body.html	Mon Apr 05 09:08:31 2021 -0700
@@ -0,0 +1,10 @@
+<!-- html fragment containing a brief description of this program -->
+<p>This program lets you downsample and rotate image files. Doing so
+    makes for smaller images that get sent faster and which always
+    display right-side-up.</p>
+<p>It also strips out the metadata (such as phone make and model) that your
+    camera app silently puts into each image, thus helping to protect your
+    privacy.</p>
+<p>It <i>does not</i> modify any existing files; it writes new files, leaving
+    your original images alone.</p>
+<p>More information may be found <a href="https://bartsent.com/simple_resizer.pspx">here</a>.</p>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/assets/about_copyright.html	Mon Apr 05 09:08:31 2021 -0700
@@ -0,0 +1,4 @@
+<!-- html fragment containing copyright message -->
+<p>Simple Resizer<br/>
+© MMXXI, David W. Barts<br/>
+<a href="https://bartsent.com/cgi-bin/hgweb.cgi/SimpleResizer/file/tip/LICENSE.txt">MIT License</a></p>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/assets/about_promo.html	Mon Apr 05 09:08:31 2021 -0700
@@ -0,0 +1,2 @@
+<!-- html fragment containing a promo message -->
+<p><a href="https://notyouraveragetechie.com/">Hire me</a>?</p>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/bartsent/simpleresizer/About.kt	Mon Apr 05 09:08:31 2021 -0700
@@ -0,0 +1,36 @@
+package com.bartsent.simpleresizer
+
+import android.os.Bundle
+import android.text.Html
+import android.text.Spanned
+import android.text.method.LinkMovementMethod
+import android.widget.TextView
+import androidx.appcompat.app.AppCompatActivity
+import com.bartsent.simpleresizer.databinding.ActivityAboutBinding
+import java.io.InputStreamReader
+
+class About : AppCompatActivity() {
+
+    private lateinit var binding: ActivityAboutBinding
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        binding = ActivityAboutBinding.inflate(layoutInflater)
+        setContentView(binding.root)
+        binding.aboutCopyright.setFromAsset("about_copyright.html")
+        binding.aboutBody.setFromAsset("about_body.html")
+        binding.aboutPromo.setFromAsset("about_promo.html")
+    }
+
+    private fun TextView.setFromAsset(name:String): Unit {
+        text = fromHtml(InputStreamReader(assets.open(name)).use { it.readText() })
+        movementMethod = LinkMovementMethod.getInstance()
+    }
+
+    private fun fromHtml(s: String): Spanned =
+        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N)
+            Html.fromHtml(s, Html.FROM_HTML_MODE_LEGACY)
+        else
+            Html.fromHtml(s)
+
+}
--- a/app/src/main/java/com/bartsent/simpleresizer/EditImage.kt	Sat Apr 03 09:24:30 2021 -0700
+++ b/app/src/main/java/com/bartsent/simpleresizer/EditImage.kt	Mon Apr 05 09:08:31 2021 -0700
@@ -62,13 +62,19 @@
     }
 
     override fun onOptionsItemSelected(item: MenuItem): Boolean {
-        if (item.itemId == R.id.settings_item) {
-            startActivity(
-                Intent(Intent.ACTION_APPLICATION_PREFERENCES, null, this,
-                    SettingsActivity::class.java))
-            return true
+        when (item.itemId) {
+            R.id.settings_item -> {
+                startActivity(
+                    Intent(Intent.ACTION_APPLICATION_PREFERENCES, null, this,
+                        SettingsActivity::class.java))
+                return true
+            }
+            R.id.about_item -> {
+                startActivity(Intent(this, About::class.java ))
+                return true
+            }
+            else -> return false
         }
-        return false
     }
 
     // Cribbed from: https://stackoverflow.com/questions/5568874/how-to-extract-the-file-name-from-uri-returned-from-intent-action-get-content
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/res/drawable-anydpi/ic_action_about.xml	Mon Apr 05 09:08:31 2021 -0700
@@ -0,0 +1,11 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="#FFFFFF"
+    android:alpha="0.8">
+  <path
+      android:fillColor="@android:color/white"
+      android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
+</vector>
Binary file app/src/main/res/drawable-hdpi/ic_action_about.png has changed
Binary file app/src/main/res/drawable-mdpi/ic_action_about.png has changed
Binary file app/src/main/res/drawable-xhdpi/ic_action_about.png has changed
Binary file app/src/main/res/drawable-xxhdpi/ic_action_about.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/res/layout/activity_about.xml	Mon Apr 05 09:08:31 2021 -0700
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".About">
+
+    <ScrollView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:padding="15dp">
+
+            <TextView
+                android:id="@+id/about_copyright"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:linksClickable="true"
+                android:text="This is the copyright message." />
+
+            <TextView
+                android:id="@+id/about_body"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:linksClickable="true"
+                android:text="This is the main body." />
+
+           <TextView
+                android:id="@+id/about_promo"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:linksClickable="true"
+                android:text="This is the promo message." />
+
+        </LinearLayout>
+
+    </ScrollView>
+    
+</LinearLayout>
--- a/app/src/main/res/menu/menu_edit.xml	Sat Apr 03 09:24:30 2021 -0700
+++ b/app/src/main/res/menu/menu_edit.xml	Mon Apr 05 09:08:31 2021 -0700
@@ -3,6 +3,12 @@
     xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <item
+        android:id="@+id/about_item"
+        android:icon="@drawable/ic_action_about"
+        android:title="@string/about_title"
+        app:showAsAction="ifRoom" />
+
+    <item
         android:id="@+id/settings_item"
         android:icon="@drawable/ic_action_settings"
         android:title="@string/settings_title"
--- a/app/src/main/res/values/strings.xml	Sat Apr 03 09:24:30 2021 -0700
+++ b/app/src/main/res/values/strings.xml	Mon Apr 05 09:08:31 2021 -0700
@@ -32,4 +32,9 @@
     <string name="scale_type_title">Scale Type</string>
     <string name="jpeg_quality_title">JPEG Output Quality</string>
     <string name="settings_title">Settings</string>
+    <string name="about_title">About</string>
+
+    <!-- About -->
+    <string name="title_activity_about">About</string>
+
 </resources>
\ No newline at end of file