Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

day-piece-appfair

The App Fair group that every App Fair app built with Day carries in its settings. It says what the App Fair Project is, links to the donation page, and lists the other App Fair apps that are live on the store for the platform the app runs on.

Add it to an app

Add the dependency:

[dependencies]
day-piece-settings = "0.*"
day-piece-appfair = "0.*"

Name the provider where the app declares its settings:

use day_piece_settings::prelude::*;

let prefs = Preferences::new()
    .about(About::from_manifest())
    .group(general_group(res::locales::ALL))
    .provider(&day_piece_appfair::APP_FAIR)
    .install();

The App Fair lint (appfair-lint, rule appfair-module) checks for both lines, and the release pipeline checks that the built package contains the module.

What the app gets

The group. On a phone it is a card at the top of the settings root, under the About header and ahead of the app's groups. In a desktop Preferences window it is a page. Its route is settings/appfair, and the id appfair is reserved for it: day-piece-settings leaves out an app's group under the same id. It has three sections:

Section Rows
About the App Fair Two paragraphs about the project and a link to https://appfair.org/
Support the App Fair Donate, which opens https://appfair.org/donate/ in the system browser
More App Fair apps One row per app with its icon, name, and summary, and a link to https://appfair.net/

A row in the last section opens the app's App Store page on iOS and its Google Play page on Android. On the other platforms it opens the app's page on appfair.net. The list leaves out the app that is running.

Thirteen languages. The group's strings come from the crate's catalog (resource/locales/<lang>/app.ftl): ar, de, en, es, fr, hi, id, it, ja, ko, pt-BR, ru, and zh-CN. An app adds no keys to its catalog. App names and summaries come from the feed in the languages each app publishes.

A Donate entry point for the app. day_piece_appfair::donate() opens the donation page, for an app that also offers Donate in a menu or on one of its screens.

The lifecycle hook. Naming the provider also registers the module for the app's launch, foreground, and background moments (Moment, session()). This release counts them and does nothing else: it shows nothing and makes no request when the app starts. A later release can act on those moments, for example with a news sheet, and every app gets that with a dependency update.

Channel-specific features

Enable the distribution feature in apps that vary their catalog by installation source.

day-piece-appfair = { version = "0.*", features = ["distribution"] }
use day_piece_appfair::distribution::FeatureGate;

let enabled = FeatureGate::IndependentDistribution.is_enabled();

Use the same policy for the visible control and any route or action that opens the feature. Call is_enabled() on the Day UI thread, inside a reactive closure for controls that should update after launch. Debug builds enable every policy by default. OutsideAppStore and OutsideGooglePlay apply to one platform each. IndependentDistribution combines them. Other platforms allow all three.

  • On iOS and iPadOS, the feature starts hidden. The system can enable it by confirming an alternative marketplace installation through AppDistributor.current. The Swift bridge weak-links MarketplaceKit. Older systems, TestFlight, App Store installations and failed lookups keep the feature hidden.
  • On Android, an install initiated by Google Play or with Google Play as its installer of record keeps the feature hidden. A third-party installer or a successful lookup with no installer of record (common for adb sideloads) enables it. Lookup errors keep it hidden. Android versions before API 30 report only the installer of record. Android can lose or change installer attribution, so use this check for feature presentation only.

For store screenshots, pass --env APPFAIR_STORE_SCREENSHOTS=1 to a separate day launch of your screenshot walkthrough. In that debug process, iOS evaluates each gate for the App Store and Android evaluates it for Google Play. Launch the gameplay walkthroughs normally to exercise every feature. Release builds use the installation source.

Distribution::current() returns the reported channel even during a screenshot launch.

The feed

The list comes from https://appfair.net/api/v1/apps.json, which the App Fair site generates from its registry of published apps. The page draws from a copy of it and never waits for the network:

  1. The last download, kept in the app's cache directory.
  2. The copy bundled with the app, on a first run and offline. It is resource/assets/day-piece-appfair/ in this crate, which day build stages into the app's bundle; the code names its files by generated constants (res::assets::day_piece_appfair).

Opening the page starts a refresh in the background. When the new copy differs, the page is redrawn with it. The request is made only when the page is opened, at most once every 15 minutes. In a desktop Preferences window that is when the App Fair page is selected, and opening the window on another page makes no request. It is a GET of a public file, it carries neither cookies nor identifiers, and its User-Agent is day-piece-appfair/<version> from every app.

The request is conditional when the copy in hand came from a download: it names the validators the server sent with that copy, and a 304 keeps it. The bundled copy has no validators, so a client that fell back to it (a first run, or a cached feed that no longer parses) asks for the whole feed.

Under a dayscript (day launch --script) or an app test (day test) the page keeps to the bundled copy and makes no request, so walkthroughs, store screenshots, and tests show the same page on every run.

The feed's announcements array becomes a News section at the top of the live sections. An entry shows on the platforms it names, between its from and until dates.

Size

The crate adds its code and the 13 catalogs to the binary, and a 1.3 KB mark and the bundled feed copy (about 20 KB for three apps) to the app's bundle. It reads the feed with serde_json, which every Day app already compiles, and it fetches through day-part-http, which uses the platform's networking stack. On Android that part adds OkHttp and the INTERNET permission to an app that did not already use it. An app that used no network before now makes this one request, so its store listing should say so.

A binary built with bare cargo has no bundle. The group still shows its About and Support sections there, and lists the apps after its first download.

Develop

cargo test --features mock
cargo clippy --all-targets --features mock -- -D warnings
(cd demo && day launch -t ios-uikit --script dayscript/demo.yaml)
(cd demo && day test -t android-material)

The demo is an app whose only content is its settings. Its walkthrough opens Settings, opens the App Fair page from the card on the settings root (from the Preferences window on a desktop), and checks the donation row and the app list. It then runs the acceptance tests in demo/src/lib.rs, which day test also runs on their own: tapping Donate asks for https://appfair.org/donate/, tapping an app asks for its store page, and an app that already had a settings group named appfair still gets this page behind the card.

Before a release, refresh the bundled feed copy and review the diff:

scripts/snapshot.py

License

GPL-2.0-or-later: the GNU General Public License, version 2 or, at your option, any later version. Every App Fair app carries the same license.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages