Skip to content

Commit 67ed04c

Browse files
committed
Adding a documentation browser to the config utility.
Also got trapped into a gradle update. Java changes and browser interface are made mainly by Gemini.
1 parent 3d64d5d commit 67ed04c

File tree

10 files changed

+126
-7
lines changed

10 files changed

+126
-7
lines changed

app/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ else {
88
}
99

1010
android {
11-
namespace 'org.tuxpaint'
11+
namespace = 'org.tuxpaint'
1212
compileSdkVersion 35
1313
defaultConfig {
1414
minSdkVersion 21
@@ -24,7 +24,7 @@ android {
2424
}
2525
packagingOptions {
2626
jniLibs {
27-
useLegacyPackaging true
27+
useLegacyPackaging = true
2828
}
2929
}
3030
buildTypes {
@@ -53,10 +53,10 @@ android {
5353
}
5454
}
5555
androidResources {
56-
ignoreAssetsPattern 'nonexisting.file'
56+
ignoreAssetsPattern = 'nonexisting.file'
5757
}
5858
lint {
59-
abortOnError false
59+
abortOnError = false
6060
}
6161
if (!project.hasProperty('EXCLUDE_NATIVE_LIBS')) {
6262
sourceSets.main {
@@ -87,7 +87,7 @@ task copyDataFiles(type: Copy) {
8787
from('src/main/jni/tuxpaint/data') {
8888
include '**/*.*'
8989
}
90-
destinationDir(new File('src/main/assets/data'))
90+
destinationDir = (new File('src/main/assets/data'))
9191
}
9292
task copyConfigFile(type: Copy) {
9393
from 'src/main/jni/tuxpaint/src/tuxpaint.cfg-android'

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
</activity>
4646
<activity android:name=".reqpermsActivity" />
4747
<activity android:name=".reqBTpermsActivity" />
48+
<activity android:name=".DocViewerActivity" />
4849
</application> <!-- SDL asks for bluetooth in the default SDLActivity.java they provide -->
4950
<uses-feature android:glEsVersion="0x00020000" />
5051
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />

app/src/main/java/org/tuxpaint/ConfigActivity.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public class ConfigActivity extends Activity {
9999
Spinner osklayoutSpinner = null;
100100
ToggleButton stamprotationToggle = null;
101101
Button requestrevoquebtButton = null;
102+
Button Docsbutton = null;
102103
Button okButton = null;
103104
Button cancelButton = null;
104105
AssetManager mgr;
@@ -455,6 +456,14 @@ public void onClick(View buttonView) {
455456
}
456457
});
457458

459+
Docsbutton = (Button)this.findViewById(R.id.buttonDocs);
460+
Docsbutton.setOnClickListener(new View.OnClickListener() {
461+
public void onClick(View buttonView) {
462+
startActivity(new Intent(ConfigActivity.this, DocViewerActivity.class));
463+
}
464+
});
465+
466+
458467
okButton = (Button)this.findViewById(R.id.buttonOk);
459468

460469
okButton.setOnClickListener(new View.OnClickListener() {
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package org.tuxpaint;
2+
3+
import android.app.Activity;
4+
import android.os.Bundle;
5+
import android.webkit.WebSettings;
6+
import android.webkit.WebView;
7+
import android.webkit.WebViewClient;
8+
import android.view.KeyEvent;
9+
import java.util.Locale;
10+
import java.io.IOException;
11+
12+
public class DocViewerActivity extends Activity {
13+
14+
@Override
15+
protected void onCreate(Bundle savedInstanceState) {
16+
super.onCreate(savedInstanceState);
17+
setContentView(R.layout.doc_viewer);
18+
19+
WebView webView = (WebView) findViewById(R.id.webView);
20+
WebSettings webSettings = webView.getSettings();
21+
webSettings.setBuiltInZoomControls(true);
22+
webSettings.setDisplayZoomControls(false);
23+
webSettings.setLoadWithOverviewMode(true);
24+
webSettings.setUseWideViewPort(true);
25+
26+
webView.setWebViewClient(new WebViewClient());
27+
28+
String lang = Locale.getDefault().getLanguage();
29+
String url = "file:///android_asset/docs/en/html/README.html";
30+
String targetFolder = null;
31+
32+
if (lang.equals("es")) targetFolder = "es_ES.UTF-8";
33+
else if (lang.equals("fr")) targetFolder = "fr_FR.UTF-8";
34+
else if (lang.equals("gl")) targetFolder = "gl_ES.UTF-8";
35+
else if (lang.equals("is")) targetFolder = "is_IS.UTF-8";
36+
else if (lang.equals("ja")) targetFolder = "ja_JP.UTF-8";
37+
else if (lang.equals("sq")) targetFolder = "sq_AL.UTF-8";
38+
else if (lang.equals("sv")) targetFolder = "sv_SE.UTF-8";
39+
40+
if (targetFolder != null) {
41+
try {
42+
String[] list = getAssets().list("docs/" + targetFolder);
43+
if (list != null && list.length > 0) {
44+
url = "file:///android_asset/docs/" + targetFolder + "/html/README.html";
45+
}
46+
} catch (IOException e) {
47+
// Folder doesn't exist or error, fallback to en
48+
}
49+
}
50+
51+
webView.loadUrl(url);
52+
}
53+
54+
@Override
55+
public boolean onKeyDown(int keyCode, KeyEvent event) {
56+
if (event.getAction() == KeyEvent.ACTION_DOWN) {
57+
switch (keyCode) {
58+
case KeyEvent.KEYCODE_BACK:
59+
WebView webView = (WebView) findViewById(R.id.webView);
60+
if (webView.canGoBack()) {
61+
webView.goBack();
62+
} else {
63+
finish();
64+
}
65+
return true;
66+
}
67+
68+
}
69+
return super.onKeyDown(keyCode, event);
70+
}
71+
}

app/src/main/jni/tuxpaint/mkzip_assets.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ then
4848

4949
make LOCALE_PREFIX=tmpzip/locale install-gettext && \
5050
cp -r data tmpzip/data && \
51+
cp -r docs tmpzip/docs && \
52+
cd magic/magic-docs && \
53+
for langdir in *; do if [ -d $langdir ]; then mkdir ../../tmpzip/docs/$langdir/magic-docs && cp -r $langdir/html ../../tmpzip/docs/$langdir/magic-docs/; fi ; done && \
54+
cd ../.. && \
5155
cp -r fonts/locale tmpzip/data/fonts/locale && \
5256
cp -r im tmpzip/data/im && \
5357
cp -r osk tmpzip/data/osk && \

app/src/main/res/layout/config.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,5 +543,26 @@
543543
android:text="@string/ok" />
544544

545545
</LinearLayout>
546+
547+
548+
<LinearLayout
549+
android:id="@+id/layoutDocs"
550+
android:layout_width="wrap_content"
551+
android:layout_height="wrap_content"
552+
android:gravity="center"
553+
android:orientation="horizontal" >
554+
555+
<TextView
556+
android:id="@+id/viewDocs"
557+
android:layout_width="wrap_content"
558+
android:layout_height="wrap_content"
559+
android:text="@string/Documentation" />
560+
<Button
561+
android:id="@+id/buttonDocs"
562+
android:layout_width="wrap_content"
563+
android:layout_height="wrap_content"
564+
android:text="@string/explore_documentation" />
565+
566+
</LinearLayout>
546567
</LinearLayout>
547568
</ScrollView>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:fitsSystemWindows="true">
6+
7+
<WebView
8+
android:id="@+id/webView"
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent" />
11+
</FrameLayout>

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@
121121
<string name="Groupmagictools">Magic tools in one BIG list.</string>
122122
<string name="groupmagictools">Put the magic tools in sections.</string>
123123
<string name="ungroupmagictools">Put all the magic tools together.</string>
124+
<string name="Documentation">Documentation</string>
125+
<string name="explore_documentation">Browse</string>
124126

125127

126128
</resources>

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
google()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:8.7.3'
9+
classpath 'com.android.tools.build:gradle:8.13.1'
1010

1111
// NOTE: Do not place your application dependencies here; they belong
1212
// in the individual module build.gradle files
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Mon Nov 13 22:58:21 EST 2023
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)