diff options
| author | Benjamin Linskey | 2025-11-04 01:55:24 -0500 |
|---|---|---|
| committer | Benjamin Linskey | 2025-11-04 01:57:09 -0500 |
| commit | ab3401657fa5d428929ad183073a75d1e2bc2ee6 (patch) | |
| tree | 0c5d2e5600cdf21fbc163706652afd970ca7cd68 | |
| parent | cd574f922fa804f58465efc02557e74ace46d26a (diff) | |
| download | greek-reference-ab3401657fa5d428929ad183073a75d1e2bc2ee6.tar.gz | |
Improve license display
- Created new Licenses option in settings view.
- Moved license info from About dialog to Licenses dialog.
- Improved license text.
- Fixed bug that caused Apache license text to be poorly displayed on smaller devices.
7 files changed, 178 insertions, 18 deletions
diff --git a/GreekReference/src/main/java/LicensesPreference.java b/GreekReference/src/main/java/LicensesPreference.java new file mode 100644 index 0000000..08bafa3 --- /dev/null +++ b/GreekReference/src/main/java/LicensesPreference.java @@ -0,0 +1,61 @@ +/* + * Copyright 2014 Benjamin Linskey + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.benlinskey.greekreference; + +import android.content.Context; +import android.preference.DialogPreference; +import androidx.annotation.NonNull; +import android.text.Html; +import android.text.method.LinkMovementMethod; +import android.util.AttributeSet; +import android.view.View; +import android.webkit.WebSettings; +import android.webkit.WebView; +import android.widget.TextView; + +/** + * A {@link android.preference.DialogPreference} containing license information. + */ +public class LicensesPreference extends DialogPreference { + + public LicensesPreference(Context context, AttributeSet attrs) { + super(context, attrs); + setDialogLayoutResource(R.layout.license_preference_layout); + setPositiveButtonText(R.string.ok); + setNegativeButtonText(null); + setDialogIcon(null); + } + + @Override + protected void onBindDialogView(@NonNull View view) { + super.onBindDialogView(view); + + TextView textView = (TextView) view.findViewById(R.id.licenseDialogTextView); + String licenseStr = getContext().getString(R.string.message_licenses); + textView.setText(Html.fromHtml(licenseStr)); + textView.setMovementMethod(LinkMovementMethod.getInstance()); + + WebView webView = (WebView) view.findViewById(R.id.licenseDialogWebView); + webView.setInitialScale(1); + WebSettings settings = webView.getSettings(); + settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING); + settings.setUseWideViewPort(true); + settings.setLoadWithOverviewMode(true); + String licenseString = getContext().getString(R.string.apache_license); + webView.loadDataWithBaseURL(null, licenseString, "text/html", "utf-8", null); + } +}
\ No newline at end of file diff --git a/GreekReference/src/main/java/com/benlinskey/greekreference/AboutPreference.java b/GreekReference/src/main/java/com/benlinskey/greekreference/AboutPreference.java index 3aa0ede..9f5d127 100644 --- a/GreekReference/src/main/java/com/benlinskey/greekreference/AboutPreference.java +++ b/GreekReference/src/main/java/com/benlinskey/greekreference/AboutPreference.java @@ -23,7 +23,6 @@ import android.text.Html; import android.text.method.LinkMovementMethod; import android.util.AttributeSet; import android.view.View; -import android.webkit.WebView; import android.widget.TextView; /** @@ -42,18 +41,9 @@ public class AboutPreference extends DialogPreference { @Override protected void onBindDialogView(@NonNull View view) { super.onBindDialogView(view); - TextView textView = (TextView) view.findViewById(R.id.aboutDialogTextView); String aboutString = getContext().getString(R.string.message_about); textView.setText(Html.fromHtml(aboutString)); textView.setMovementMethod(LinkMovementMethod.getInstance()); - - // TODO: Find a better way to display this license. At the very least, make sure it's - // always properly sized. - WebView webView = (WebView) view.findViewById(R.id.aboutDialogWebView); - webView.getSettings().setUseWideViewPort(true); - webView.getSettings().setLoadWithOverviewMode(true); - String licenseString = getContext().getString(R.string.apache_license); - webView.loadDataWithBaseURL(null, licenseString, "text/html", null, null); } } diff --git a/GreekReference/src/main/res/layout/about_preference_layout.xml b/GreekReference/src/main/res/layout/about_preference_layout.xml index bdda589..b7c681a 100644 --- a/GreekReference/src/main/res/layout/about_preference_layout.xml +++ b/GreekReference/src/main/res/layout/about_preference_layout.xml @@ -31,11 +31,5 @@ android:padding="25dp" style="@android:style/TextAppearance.Medium" android:textColor="@color/primary_text_default_material_light"/> - <!-- NOTE: Putting a WebView in a ScrollView shouldn't be a problem here if we can ensure - that the WebView will always be properly sized. --> - <WebView - android:id="@+id/aboutDialogWebView" - android:layout_width="wrap_content" - android:layout_height="wrap_content"/> </LinearLayout> </ScrollView> diff --git a/GreekReference/src/main/res/layout/license_preference_layout.xml b/GreekReference/src/main/res/layout/license_preference_layout.xml new file mode 100644 index 0000000..04cd59c --- /dev/null +++ b/GreekReference/src/main/res/layout/license_preference_layout.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + ~ Copyright 2014 Benjamin Linskey + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<ScrollView + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + <TextView + android:id="@+id/licenseDialogTextView" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="25dp" + style="@android:style/TextAppearance.Medium" + android:textColor="@color/primary_text_default_material_light"/> + <WebView + android:id="@+id/licenseDialogWebView" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + </LinearLayout> +</ScrollView> diff --git a/GreekReference/src/main/res/values/pref_orders.xml b/GreekReference/src/main/res/values/pref_orders.xml index bbbc60f..5b9c8af 100644 --- a/GreekReference/src/main/res/values/pref_orders.xml +++ b/GreekReference/src/main/res/values/pref_orders.xml @@ -23,4 +23,5 @@ <integer name="pref_perseus_tool">3</integer> <integer name="pref_one_pane">4</integer> <integer name="pref_about">5</integer> + <integer name="pref_licenses">6</integer> </resources> diff --git a/GreekReference/src/main/res/values/strings.xml b/GreekReference/src/main/res/values/strings.xml index 0a40d4a..54020ad 100644 --- a/GreekReference/src/main/res/values/strings.xml +++ b/GreekReference/src/main/res/values/strings.xml @@ -72,6 +72,7 @@ ]]> </string> <string name="title_about">About</string> + <string name="title_licenses">Licenses</string> <!-- NOTE: I'm currently displaying the following string in a TextView, not a WebView, so some of these tags are ignored, and I've added a few extra <br> tags in the list at the end. @@ -125,7 +126,69 @@ <li><a href="http://www.tristanwaddington.com/2012/09/android-textview-with-custom-font-support/">TypefaceTextView</a></li> </ul> </p> + ]]> + </string> + <string name="message_licenses"> + <![CDATA[ + <p> + This app includes the contents of the text "An Intermediate Greek-English Lexicon," + by Henry George Liddell and Robert Scott. Text provided by Perseus Digital Library, + with funding from The Annenberg CPB/Project. Original version available for viewing + and download at http://www.perseus.tufts.edu/hopper/. The text is licensed under + the Creative Commons Attribution-ShareAlike 3.0 United States License + (https://creativecommons.org/licenses/by-sa/3.0/us/). + </p> + <p> + The text also includes the following terms: + </p> + <p> + This text may be freely distributed, subject to the following restrictions: + </p> + <ul> + <li> + <p>You credit Perseus, as follows, whenever you use the document:</p> + <p>"Text provided by Perseus Digital Library, with funding from The Annenberg + CPB/Project. Original version available for viewing and download at + http://www.perseus.tufts.edu/hopper/."</p> + </li> + <li>You leave this availability statement intact.</li> + <li>You use it for non-commercial purposes only.</li> + <li>You offer Perseus any modifications you make.</li> + </ul> + <hr> + <p> + This app includes the contents of the text "Overview of Greek Syntax," + by Jeffrey A. Rydberg-Cox. Text provided by Perseus Digital Library, + with funding from The Annenberg CPB/Project. Original version available for viewing + and download at http://www.perseus.tufts.edu/hopper/. The text is licensed under + the Creative Commons Attribution-ShareAlike 3.0 United States License + (https://creativecommons.org/licenses/by-sa/3.0/us/). + </p> + <p> + The text also includes the following terms: + </p> + <p> + This text may be freely distributed, subject to the following restrictions: + </p> + <ul> + <li> + <p>You credit Perseus, as follows, whenever you use the document:</p> + <p>"Text provided by Perseus Digital Library, with funding from The Annenberg + CPB/Project. Original version available for viewing and download at + http://www.perseus.tufts.edu/hopper/."</p> + </li> + <li>You leave this availability statement intact.</li> + <li>You use it for non-commercial purposes only.</li> + <li>You offer Perseus any modifications you make.</li> + </ul> <hr> + <p> + The icons used in this app are taken from the <a href="https://github.com/google/material-design-icons"> + Google Material Design Icons</a> set, licensed under the <a href="http://creativecommons.org/licenses/by-sa/4.0/"> + Creative Common Attribution 4.0 International license</a>. + </p> + <hr> + <p> The following resources distributed under the Apache License, Version 2.0, are used in this app: the androidx appcompat, core, and drawerlayout libraries, the Material Components for Android library, the SQLiteAssetHelper library, source code from the @@ -133,6 +196,7 @@ abc_search_dropdown_item_icons_2line.xml), source code from Simple Finance Corporation (used in the file GreekTextView.java), and the Noto Serif font. The text of the license is below. + </p> ]]> </string> <string name="syntax_footer"> @@ -149,7 +213,12 @@ <string name="apache_license" tools:ignore="TypographyOther"> <![CDATA[ " -<pre style="word-wrap: break-word; white-space: pre-wrap;"> +<html> +<head> +<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> +</head> +<body> +<pre style="font-size: 20px; word-wrap: break-word; white-space: pre-wrap;"> Apache License Version 2.0, January 2004 @@ -352,7 +421,8 @@ distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -</pre>" +</pre> +</body>" ]]> </string> <string name="pref_textSize">Font size</string> @@ -364,6 +434,7 @@ limitations under the License. <string name="pref_textSize_key">PREF_TEXT_SIZE_KEY</string> <string name="version">"Version "</string> <string name="pref_about_key">PREF_ABOUT_KEY</string> + <string name="pref_licenses_key">PREF_LICENSES_KEY</string> <string name="pref_onePane_key">PREF_ONE_PANE_KEY</string> <string name="pref_onePane">Hide lexicon word list</string> <string name="pref_onePane_summary"> diff --git a/GreekReference/src/main/res/xml/preferences.xml b/GreekReference/src/main/res/xml/preferences.xml index 643b918..1e221e6 100644 --- a/GreekReference/src/main/res/xml/preferences.xml +++ b/GreekReference/src/main/res/xml/preferences.xml @@ -18,4 +18,8 @@ android:key="@string/pref_about_key" android:title="@string/title_about" android:order="@integer/pref_about"/> + <com.benlinskey.greekreference.LicensesPreference + android:key="@string/pref_licenses_key" + android:title="@string/title_licenses" + android:order="@integer/pref_licenses"/> </PreferenceScreen> |