1
0
Fork 0

added the Privacy Policy document to the app

This commit is contained in:
sspanak 2025-04-22 13:24:54 +03:00 committed by Dimo Karaivanov
parent 75ebfc1f3b
commit d32ea80c9a
25 changed files with 144 additions and 60 deletions

View file

@ -24,8 +24,8 @@ jobs:
uses: gradle/gradle-build-action@v3
# validate and build
- name: Validate Help
run: ./gradlew convertHelp
- name: Generate Documents
run: ./gradlew generateDocs
- name: Validate Dictionaries
run: ./gradlew validateLanguages
- name: Build Languages

View file

@ -53,12 +53,13 @@ tasks.register('copyDownloadsToAssets', Copy) {
}
tasks.register('convertHelp') {
tasks.register('generateDocs') {
inputs.dir HELP_MARKDOWN_DIR
outputs.dir HELP_HTML_DIR
inputs.file PRIVACY_POLICY_MARKDOWN
outputs.dir DOCS_HTML_DIR
doLast {
convertHelpDocs(HELP_MARKDOWN_DIR, HELP_HTML_DIR)
convertDocs(HELP_MARKDOWN_DIR, PRIVACY_POLICY_MARKDOWN, DOCS_HTML_DIR)
}
}
@ -72,7 +73,7 @@ clean {
delete LANGUAGES_OUTPUT_DIR
delete DICTIONARIES_OUTPUT_DIR
delete DICTIONARIES_DOWNLOAD_DIR
delete HELP_HTML_DIR
delete DOCS_HTML_DIR
}
// using the exported Closures directly causes weird values, hence the extra wrappers here
@ -98,23 +99,18 @@ android {
versionCode getVerCode()
versionName getVerName()
buildConfigField 'String', 'DICTIONARY_EXTENSION', "\"${DICTIONARY_OUTPUT_EXTENSION}\""
buildConfigField 'String', 'DOCS_DIR', "\"${DOCS_DIR_NAME}\""
buildConfigField 'String', 'DONATION_URL', "\"${getDonationUrl()}\""
buildConfigField 'String', 'VERSION_FULL', "\"${getVersionString('debug')}\""
// F-droid hacks
dependenciesInfo.includeInApk false
vectorDrawables.generatedDensities = []
}
buildTypes {
debug {
buildConfigField 'String', 'DONATION_URL', "\"${getDonationUrl()}\""
buildConfigField 'String', 'DICTIONARY_EXTENSION', "\"${DICTIONARY_OUTPUT_EXTENSION}\""
buildConfigField 'String', 'VERSION_FULL', "\"${getVersionString('debug')}\""
}
release {
buildConfigField 'String', 'DONATION_URL', "\"${getDonationUrl()}\""
buildConfigField 'String', 'DICTIONARY_EXTENSION', "\"${DICTIONARY_OUTPUT_EXTENSION}\""
buildConfigField 'String', 'VERSION_FULL', "\"${getVersionString('release')}\""
debuggable false
jniDebuggable false
minifyEnabled true
@ -150,7 +146,7 @@ android {
].each { taskName ->
try {
tasks.named(taskName)?.configure {
dependsOn(buildDefinition, convertHelp, validateLanguages, buildDictionaryDownloads)
dependsOn(buildDefinition, generateDocs, validateLanguages, buildDictionaryDownloads)
}
if (taskName.toLowerCase().contains("full")) {

View file

@ -13,8 +13,10 @@ def FULL_VERSION_ASSETS_DIR = "${APP_ROOT_DIR}/src/full/assets"
ext.FUNDING_FILE = "${project.rootDir}/.github/FUNDING.yml"
ext.HELP_MARKDOWN_DIR = "${project.rootDir}/docs/help"
ext.HELP_HTML_DIR = "${MAIN_ASSETS_DIR}/help"
ext.DOCS_DIR_NAME = "docs"
ext.HELP_MARKDOWN_DIR = "${project.rootDir}/${DOCS_DIR_NAME}/help"
ext.PRIVACY_POLICY_MARKDOWN = "${project.rootDir}/${DOCS_DIR_NAME}/privacy.md"
ext.DOCS_HTML_DIR = "${MAIN_ASSETS_DIR}/${DOCS_DIR_NAME}"
ext.LANGUAGES_INPUT_DIR = "${APP_ROOT_DIR}/${LANGUAGES_DIR_NAME}"
ext.DEFINITIONS_INPUT_DIR = "${LANGUAGES_INPUT_DIR}/${DEFINITIONS_DIR_NAME}"

View file

@ -1,18 +1,23 @@
ext.convertHelpDocs = {markdownDir, htmlDir ->
fileTree(markdownDir).getFiles().parallelStream().forEach { File markdownPath ->
markdownToHtml(markdownPath.path, "${htmlDir}/${markdownPath.name.replaceAll("\\.md\$", ".html")}")
ext.convertDocs = {String DOCS_MARKDOWN_DIR, String PRIVACY_POLICY_MARKDOWN, String HTML_DIR ->
Set<File> docs = fileTree(DOCS_MARKDOWN_DIR).getFiles()
docs.add(new File(PRIVACY_POLICY_MARKDOWN))
docs.parallelStream().forEach { File markdownPath ->
markdownToHtml(markdownPath.path, "${HTML_DIR}/${markdownPath.name.replaceAll("\\.md\$", ".html")}", !PRIVACY_POLICY_MARKDOWN.contains(markdownPath.name))
}
}
static markdownToHtml(markdownPath, htmlPath) {
static markdownToHtml(markdownPath, htmlPath, addIndex) {
def text = new File(markdownPath).text
text = convertHeaders(text)
text = convertHorizontalRules(text)
text = convertOrderedLists(text)
text = convertUnorderedLists(text)
text = convertInlineTags(text)
text = addStylesToTags(text)
text = insertIndex(text, generateIndex(text))
if (addIndex) {
text = insertIndex(text, generateIndex(text))
}
text = removeWhitespace(text)
new File(htmlPath).text = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><style>${getStyles()}</style><title>Help</title></head><body>${text}</body></html>"
@ -76,6 +81,10 @@ static convertHeaders(markdown) {
}
static convertHorizontalRules(markdown) {
return markdown.replaceAll("\\-{3,}", "<hr>")
}
static convertOrderedLists(markdown) {
def html = markdown.split("\n").collect { line ->
if (line.matches("^\\d+\\..*")) {
@ -100,7 +109,7 @@ static convertUnorderedLists(markdown) {
def innerLi = line.replaceAll("^\\s*-\\s*", "")
if (line.matches("^-.*")) {
if (line.matches("^-(?!-).*")) {
if (!inList) {
convertedLine += "<ul>"
inList = true

View file

@ -69,6 +69,17 @@
</intent-filter>
</activity>
<activity
android:label="@string/pref_privacy_policy"
android:name="io.github.sspanak.tt9.preferences.PrivacyPolicyActivity"
android:exported="true"
android:theme="@style/TTheme.Preferences">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:excludeFromRecents="true"
android:label=""

View file

@ -3,41 +3,12 @@ package io.github.sspanak.tt9.preferences;
import java.io.BufferedReader;
import java.io.IOException;
import io.github.sspanak.tt9.ui.WebViewActivity;
import io.github.sspanak.tt9.util.Logger;
import io.github.sspanak.tt9.util.colors.AccentSystemColor;
import io.github.sspanak.tt9.util.colors.TextSystemColor;
import io.github.sspanak.tt9.ui.DocumentActivity;
import io.github.sspanak.tt9.util.sys.SystemSettings;
public class HelpActivity extends WebViewActivity {
public HelpActivity() {
transparentBackground = true;
}
public class HelpActivity extends DocumentActivity {
@Override
protected String getMimeType() {
return "text/html";
}
@Override
protected String getText() {
try {
BufferedReader reader = getHelpFileReader();
StringBuilder builder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
return builder.toString()
.replaceFirst("color: default;", (new TextSystemColor(this)).toCssColor())
.replaceFirst("color: accent;", (new AccentSystemColor(this)).toCssColor());
} catch (Exception e) {
Logger.e(getClass().getSimpleName(), "Failed opening the help HTML document.");
return "";
}
}
private BufferedReader getHelpFileReader() throws IOException {
protected BufferedReader getDocumentReader() throws IOException {
String systemLanguage = SystemSettings.getLocale().replaceFirst("_\\w+$", "");
HelpFile file = new HelpFile(this, systemLanguage);
file = file.exists() ? file : new HelpFile(this);

View file

@ -4,14 +4,15 @@ import android.content.Context;
import androidx.annotation.NonNull;
import io.github.sspanak.tt9.BuildConfig;
import io.github.sspanak.tt9.util.AssetFile;
public class HelpFile extends AssetFile {
public HelpFile(@NonNull Context context, String language) {
super(context.getAssets(), "help/help." + language + ".html");
super(context.getAssets(), BuildConfig.DOCS_DIR + "/help." + language + ".html");
}
public HelpFile(@NonNull Context context) {
super(context.getAssets(), "help/help.en.html");
super(context.getAssets(), BuildConfig.DOCS_DIR + "/help.en.html");
}
}

View file

@ -0,0 +1,13 @@
package io.github.sspanak.tt9.preferences;
import java.io.BufferedReader;
import java.io.IOException;
import io.github.sspanak.tt9.ui.DocumentActivity;
public class PrivacyPolicyActivity extends DocumentActivity {
@Override
protected BufferedReader getDocumentReader() throws IOException {
return new PrivacyPolicyFile(this).getReader();
}
}

View file

@ -0,0 +1,14 @@
package io.github.sspanak.tt9.preferences;
import android.content.Context;
import androidx.annotation.NonNull;
import io.github.sspanak.tt9.BuildConfig;
import io.github.sspanak.tt9.util.AssetFile;
public class PrivacyPolicyFile extends AssetFile {
public PrivacyPolicyFile(@NonNull Context context) {
super(context.getAssets(), BuildConfig.DOCS_DIR + "/privacy.html");
}
}

View file

@ -60,7 +60,11 @@ public class MainSettingsScreen extends BaseScreenFragment {
}
String systemLanguage = SystemSettings.getLocale().replaceAll("_\\w+$", "");
help.setSummary(new HelpFile(activity, systemLanguage).exists() ? "" : "English only");
if (new HelpFile(activity, systemLanguage).exists()) {
help.setSummary("");
} else {
help.setSummary(R.string.english_only);
}
}

View file

@ -0,0 +1,39 @@
package io.github.sspanak.tt9.ui;
import java.io.BufferedReader;
import java.io.IOException;
import io.github.sspanak.tt9.util.Logger;
import io.github.sspanak.tt9.util.colors.AccentSystemColor;
import io.github.sspanak.tt9.util.colors.TextSystemColor;
abstract public class DocumentActivity extends WebViewActivity {
public DocumentActivity() {
transparentBackground = true;
}
@Override
protected String getText() {
try {
BufferedReader reader = getDocumentReader();
StringBuilder builder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
return builder.toString()
.replaceFirst("color: default;", (new TextSystemColor(this)).toCssColor())
.replaceFirst("color: accent;", (new AccentSystemColor(this)).toCssColor());
} catch (Exception e) {
Logger.e(getClass().getSimpleName(), "Failed opening the HTML document.");
return "";
}
}
@Override
protected String getMimeType() {
return "text/html";
}
abstract protected BufferedReader getDocumentReader() throws IOException;
}

View file

@ -30,6 +30,7 @@
<string name="pref_numpad_width">Ширина</string>
<string name="pref_predict_word_pairs">Запомняне на двойки думи</string>
<string name="pref_predict_word_pairs_summary">Запомняй често ползвани фрази, за по-точно подсказване на думи.</string>
<string name="pref_privacy_policy">Политика за поверителност</string>
<string name="pref_status_icon">Икона за състояние</string>
<string name="pref_status_icon_summary">Показвай икона, когато въвеждането с клавиатура е активно.</string>
<string name="dictionary_cancel_load">Отмени зареждането</string>

View file

@ -46,6 +46,7 @@
<string name="pref_numpad_width">Breite</string>
<string name="pref_predict_word_pairs">Wortpaare lernen</string>
<string name="pref_predict_word_pairs_summary">Häufig verwendete Phrasen merken, um die Genauigkeit der Vorschläge zu verbessern.</string>
<string name="pref_privacy_policy">Datenschutzerklärung</string>
<string name="pref_status_icon">Statusicon</string>
<string name="pref_status_icon_summary">Ein Icon anzeigen, wenn die Tastatureingabe aktiv ist.</string>
<string name="pref_suggestion_smooth_scroll">Sanftes Scrollen der Wortliste</string>

View file

@ -54,6 +54,7 @@
<string name="pref_numpad_width">Anchura</string>
<string name="pref_predict_word_pairs">Aprender pares de palabras</string>
<string name="pref_predict_word_pairs_summary">Recordar frases de uso común para mejorar las sugerencias de palabras.</string>
<string name="pref_privacy_policy">Política de privacidad</string>
<string name="pref_status_icon">Icono de estado</string>
<string name="pref_status_icon_summary">Mostrar un icono cuando la escritura esté activa.</string>
<string name="dictionary_cancel_load">Cancelar la carga</string>

View file

@ -31,6 +31,7 @@
<string name="pref_numpad_width">Largeur</string>
<string name="pref_predict_word_pairs">Mémoriser les paires de mots</string>
<string name="pref_predict_word_pairs_summary">Apprendre des phrases couramment utilisées pour améliorer les suggestions.</string>
<string name="pref_privacy_policy">Politique de confidentialité</string>
<string name="pref_status_icon">Icône d\'état</string>
<string name="pref_status_icon_summary">Afficher une icône lorsque la saisie au clavier est active</string>
<string name="dictionary_cancel_load">Annuler le chargement</string>

View file

@ -49,6 +49,7 @@
<string name="pref_numpad_width">Larghezza</string>
<string name="pref_predict_word_pairs">Memorizzare coppie di parole</string>
<string name="pref_predict_word_pairs_summary">Ricordare frasi comunemente usate per migliorare i suggerimenti di parole.</string>
<string name="pref_privacy_policy">Informativa sulla privacy</string>
<string name="pref_status_icon">Icona di stato</string>
<string name="pref_status_icon_summary">Mostrare un\'icona quando la digitazione è attiva.</string>
<string name="dictionary_cancel_load">Annullare il caricamento</string>

View file

@ -60,6 +60,7 @@
<string name="pref_numpad_width">רוחב</string>
<string name="pref_predict_word_pairs">ללמוד צמדי מילים</string>
<string name="pref_predict_word_pairs_summary">לזכור ביטויים נפוצים כדי לשפר את דיוק ההצעות.</string>
<string name="pref_privacy_policy">מדיניות פרטיות</string>
<string name="pref_status_icon">סמל מצב</string>
<string name="pref_status_icon_summary">הצגת סמל כאשר קלט המקלדת פעיל.</string>
<string name="pref_suggestion_smooth_scroll">גלילה חלקה של הצעות</string>

View file

@ -66,6 +66,7 @@
<string name="pref_numpad_width">Plotis</string>
<string name="pref_predict_word_pairs">Išmokti žodžių poras</string>
<string name="pref_predict_word_pairs_summary">Įsiminti dažnai naudojamas frazes, kad pagerintumėte žodžių pasiūlymus.</string>
<string name="pref_privacy_policy">Privatumo politika</string>
<string name="pref_status_icon">Būsenos piktograma</string>
<string name="pref_status_icon_summary">Rodyti piktogramą, kai aktyvus klaviatūros įvedimas</string>
<string name="dictionary_cancel_load">Atšaukti įkėlimą</string>

View file

@ -46,6 +46,7 @@
<string name="pref_numpad_width">Breedte</string>
<string name="pref_predict_word_pairs">Woordenparen leren</string>
<string name="pref_predict_word_pairs_summary">Veelgebruikte zinnen onthouden om de nauwkeurigheid van suggesties te verbeteren.</string>
<string name="pref_privacy_policy">Privacybeleid</string>
<string name="pref_status_icon">Statusicoon</string>
<string name="pref_status_icon_summary">Een icoon tonen wanneer toetsenbordinvoer actief is.</string>
<string name="pref_suggestion_smooth_scroll">Vloeiend suggesties scrollen</string>

View file

@ -61,6 +61,7 @@
<string name="pref_numpad_width">Largura</string>
<string name="pref_predict_word_pairs">Aprender pares de palavras</string>
<string name="pref_predict_word_pairs_summary">Lembrar de frases comumente usadas para melhorar as sugestões de palavras.</string>
<string name="pref_privacy_policy">Política de privacidade</string>
<string name="pref_status_icon">Ícone de status</string>
<string name="pref_status_icon_summary">Mostrar um ícone quando a digitação estiver ativa.</string>
<string name="dictionary_cancel_load">Cancelar Carregamento</string>

View file

@ -31,6 +31,7 @@
<string name="pref_numpad_width">Ширина</string>
<string name="pref_predict_word_pairs">Запоминать пары слов</string>
<string name="pref_predict_word_pairs_summary">Запоминать часто используемые фразы для улучшения предложений слов.</string>
<string name="pref_privacy_policy">Политика конфиденциальности</string>
<string name="pref_status_icon">Иконка состояния</string>
<string name="pref_status_icon_summary">Показывать иконку, когда активен режим ввода с клавиатуры.</string>
<string name="dictionary_cancel_load">Отменить загрузку</string>

View file

@ -47,6 +47,7 @@
<string name="pref_numpad_width">Genişlik</string>
<string name="pref_predict_word_pairs">Kelime çiftlerini öğren</string>
<string name="pref_predict_word_pairs_summary">Öneri doğruluğunu artırmak için sık kullanılan ifadeleri hatırla.</string>
<string name="pref_privacy_policy">Gizlilik politikası</string>
<string name="pref_status_icon">Durum</string>
<string name="pref_status_icon_summary">Klavye girişi etkin olduğunda bir simge göster.</string>
<string name="dictionary_cancel_load">Yüklemeyi İptal Et</string>

View file

@ -72,6 +72,7 @@
<string name="pref_numpad_width">Ширина</string>
<string name="pref_predict_word_pairs">Запам’ятовувати пари слів</string>
<string name="pref_predict_word_pairs_summary">Запам\'ятовувати часто вживані фрази для покращення пропозицій слів.</string>
<string name="pref_privacy_policy">Політика конфіденційності</string>
<string name="pref_status_icon">Іконка статусу</string>
<string name="pref_status_icon_summary">Показати іконку, коли активне введення з клавіатури.</string>
<string name="dictionary_cancel_load">Скасувати завантаження</string>

View file

@ -5,6 +5,7 @@
<string name="app_name_short" translatable="false">TT9</string>
<string name="app_settings">TT9 Settings</string>
<string name="completed">Completed</string>
<string name="english_only" translatable="false">English only</string>
<string name="loading">Loading…</string>
<string name="language">Language</string>
<string name="search_results">Search Results</string>
@ -97,6 +98,7 @@
<string name="pref_numpad_width">Width</string>
<string name="pref_predict_word_pairs">Learn Word Pairs</string>
<string name="pref_predict_word_pairs_summary">Remember commonly used phrases to improve the suggestions accuracy.</string>
<string name="pref_privacy_policy">Privacy Policy</string>
<string name="pref_status_icon">Status Icon</string>
<string name="pref_status_icon_summary">Show an icon when keyboard input is active.</string>
<string name="pref_suggestion_smooth_scroll">Smooth Suggestion Scrolling</string>

View file

@ -41,6 +41,16 @@
app:title="@string/donate_title"
app:isPreferenceVisible="false" />
<Preference
app:key="screen_privacy_policy"
app:title="@string/pref_privacy_policy"
app:summary="@string/english_only">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="io.github.sspanak.tt9"
android:targetClass="io.github.sspanak.tt9.preferences.PrivacyPolicyActivity" />
</Preference>
<Preference
app:key="version_info"
app:title="@string/app_name" />