Add privacy policy; update README; incorporate both into Settings app

This commit is contained in:
James Babcock committed 2026-07-31 22:19:51 -07:00
1 parent 65c73ad144
commit 4d1182599b
4 files changed
+115 -27

No files matched your search

+40 -11
View File
@@ -1,6 +1,10 @@
import { knownFolders } from "@nativescript/core";
import { getDefaultSmallFont } from "../../graphics/bdffont";
import type { GrayImage } from "../../graphics/image";
import { getDashboardLogo } from "../../graphics/logo";
import { wrapText } from "../../graphics/textwrap";
import { TextViewerLayer } from "../apps/text-viewer";
import type { MenuItem } from "../menu";
import { shell } from "../shell/shell";
import {
anthropicApiKeySetting,
@@ -100,7 +104,13 @@ function settingsSections(): SettingsSection[] {
},
{
label: "About",
items: [],
// The version/license blurb (renderDetail) draws above the bundled
// project docs, in both the preview and the focused states.
items: [
bundledDocMenuItem("README", "README"),
bundledDocMenuItem("LICENSE", "License"),
bundledDocMenuItem("PRIVACY", "Privacy policy"),
],
renderDetail: renderAbout,
},
{
@@ -119,7 +129,27 @@ function settingsSections(): SettingsSection[] {
];
}
function renderAbout(args: { image: GrayImage; x: number; y: number; width: number }): void {
/** A row that opens one of the project docs (copied into the bundle under
* about/ by webpack.config.js) in the paged text viewer. */
function bundledDocMenuItem(fileName: string, label: string): MenuItem {
return {
label,
onSelect: (ctx) => {
ctx.stack.push(new TextViewerLayer(readBundledDoc(fileName), label));
},
};
}
function readBundledDoc(fileName: string): string {
try {
const text = knownFolders.currentApp().getFile(`about/${fileName}`).readTextSync();
return text || `(${fileName} is missing from this build)`;
} catch {
return `(${fileName} is missing from this build)`;
}
}
function renderAbout(args: { image: GrayImage; x: number; y: number; width: number }): number {
const { image, x, y, width } = args;
const font = getDefaultSmallFont();
const logo = getDashboardLogo();
@@ -128,13 +158,12 @@ function renderAbout(args: { image: GrayImage; x: number; y: number; width: numb
}
const textX = logo ? x + logo.width + 12 : x;
image.drawText(font, textX, y + 8, "Faceclaw", 220);
image.drawText(font, textX, y + 24, "v0.2.0", 170);
image.drawTextWrapped({
font,
x,
y: y + 64,
width,
text: "By James Babcock. Distributed under the GNU General Public License, version 3.",
value: 170,
});
image.drawText(font, textX, y + 24, "v0.3.0", 170);
const blurb = "By James Babcock. Distributed under the GNU General Public License, version 3.";
const blurbY = y + Math.max(64, logo ? logo.height + 12 : 0);
const blurbLines = wrapText(font, blurb, width);
for (let i = 0; i < blurbLines.length; i++) {
image.drawText(font, x, blurbY + i * font.lineHeight, blurbLines[i]!, 170);
}
return blurbY - y + blurbLines.length * font.lineHeight + 10;
}
+12 -7
View File
@@ -9,8 +9,10 @@ import { shell } from "../shell/shell";
/**
* One left-column entry. `items` are the right-column rows (reusing the shared
* MenuItem builders). `renderDetail`, when set, replaces the row list with
* custom informational content (e.g. About) and makes the pane non-interactive.
* MenuItem builders). `renderDetail`, when set, draws custom informational
* content (e.g. About) at the top of the pane and returns the pixel height it
* consumed; the row list renders below it. Returning nothing claims the whole
* pane (an info-only section).
*/
export type SettingsSection = {
label: string;
@@ -22,7 +24,7 @@ export type SettingsSection = {
width: number;
height: number;
ctx: LayerContext;
}) => void;
}) => number | void;
};
const PAD = 8;
@@ -94,9 +96,12 @@ export class SettingsPanelLayer implements Layer {
// Right column: the highlighted section's contents.
const rightX = divX + 14;
const rightW = width - rightX - PAD;
let rightTop = top;
if (section.renderDetail) {
section.renderDetail({ image, x: rightX, y: top, width: rightW, height: listBottom - top, ctx });
} else if (rightItems.length) {
const used = section.renderDetail({ image, x: rightX, y: top, width: rightW, height: listBottom - top, ctx });
rightTop = typeof used === "number" ? Math.min(top + used, listBottom) : listBottom;
}
if (rightItems.length && rightTop < listBottom) {
// Once focus is in the right column, the bottom of the pane shows the
// selected item's extended description (when it has one), with the row
// list shrunk to make room.
@@ -106,11 +111,11 @@ export class SettingsPanelLayer implements Layer {
: [];
const descriptionH = descriptionLines.length ? descriptionLines.length * font.lineHeight + 10 : 0;
const rightListBottom = listBottom - descriptionH;
const rightRows = Math.max(1, ((rightListBottom - top) / ROW_H) | 0);
const rightRows = Math.max(1, ((rightListBottom - rightTop) / ROW_H) | 0);
this.rightScroll = clampScroll(this.rightIndex, this.rightScroll, rightRows, rightItems.length);
for (let i = this.rightScroll; i < Math.min(rightItems.length, this.rightScroll + rightRows); i++) {
const item = rightItems[i]!;
const rowY = top + (i - this.rightScroll) * ROW_H;
const rowY = rightTop + (i - this.rightScroll) * ROW_H;
// A selection only appears once focus is in the right column; before
// that the pane is a preview of what tapping would open.
const selected = this.focus === "right" && i === this.rightIndex;