Bill Farmer

Random thoughts on random subjects

Questionnaire Maker

by Bill Farmer. Categories: Hacking .

Introduction

Questionnaire Maker is a WordPress and Hugo plugin that asks a series of questions and produces a PDF report. The project is on Github.

Documentation

The plugin uses the shortcodes [questionnaire-questions] and [questionnaire-report], or {{< questionnaire-questions >}} and {{< questionnaire-report >}}. The shortcode will be replaced on the page with a series of panels containing the questions and options for the answers, or a panel with a preview of the report.

Read more →

Handling Resizing in Windows

by Bill Farmer. Categories: Hacking .

I have a windows app where I want the app window to maintain it’s aspect ratio when it is resized. Windows provides two mechanisms for this, the WM_SIZE message and the WM_SIZING message. The WM_SIZE message is sent when a window has been resized to allow child windows to be resized, the WM_SIZING message is sent while the user is resizing it to allow the size to be adjusted. The messages are handled in the WindowProc callback function.

Read more →

Swift

by Bill Farmer. Categories: Hacking .

Some years ago I wrote an OSX app in C using Carbon because my Hackintosh would only run OSX 10.4 (Tiger). The most difficult part was dealing with the Core Audio API.

I recently decided to port it to Swift to avoid having to attempt to learn Objective C. A derivation of C that sends selectors to targets using the syntax [target selector arguments...] I don’t want to know about.

Core Audio

Having translated the Core Audio part of the app to Swift, I discovered that part of it refused to work. The same code originally written in C works fine.

Read more →

Android Custom Attributes

by Bill Farmer. Categories: Hacking .

I had resisted adding a dark theme to my Diary app until now because it uses a custom calendar with built in customisable styles and preferences with icons. So I had to work out how to make the custom styles of the calendar revert to styles from the current theme, and how to switch icons for the preferences according to the theme.

Calendar custom styles

The custom calendar has a list of styles that are customisable in a attrs.xml file.

Read more →

Android Recent Files

by Bill Farmer. Categories: Hacking .

There are several parts to this - creating the list of files, saving the list in the preferences, restoring the list on startup and creating the list in the menu.


    // onCreate
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        SharedPreferences preferences =
            PreferenceManager.getDefaultSharedPreferences(this);

        // Create a map of scroll positions by file name
        Set<String> pathSet = preferences.getStringSet(PREF_PATHS, null);
        pathMap = new HashMap<String, Integer>();

        if (pathSet != null)
            for (String path : pathSet)
                pathMap.put(path, preferences.getInt(path, 0));

        removeList = new ArrayList<String>();

        // ...
    }

The android preference system only allows a list of strings to be stored as a set, so the last modified date of each file is used below to order the list. The code also saves the scroll position of each file using the file name as a key. The remove list is used to remove old entries.

Read more →
Previous page Next page