Default settings (like Form Management - AutoSend etc), in Custom Collect App

Hi,

I need to build custom APK of ODK Collect with pre-configured settings (like Form Management, User settings etc) and options (hide button on Main Menu). I am able to perform changes as per requirements apart from settings default values of Form Management & User Settings, User interface etc. I have made changes in form_management_preferences.xml and added android:defaultvalue but its not working.

Kindly assist and guide from where we can change default settings values.

Regards
Saumya

Hi @Saumya_Garg
what do you mean by

its not working

it's too little details to help you. Ideally you should share the code you have changed and but to no avail.

Hi,

What we need is to set Default value of General Settings --> Form Management --> Auto Send to wifi_cellular_autosend. So i have modified form_management.xml file and added android:defaultValue="@string/wifi_cellular_autosend" in section

When when we load the newly compiled app value is still "Off". Below is the code and settings page on app

Regards
Saumya

Try in GeneralKeys class where we store default values.

Thanks!! it worked. Just another help. Please guide me the location / filename where default values of other settings are. We need for"Main Menu Settings" and "User Settings" as in attached image

There is reloadSharedPreferences() method in Collect class. According to the comment above it loads default values:
This method reloads shared preferences in order to load default values for new preferences
that's why what you did for general settings works.
You can do the same for AdminSettings as well:
Collect.reloadSharedPreferences() -> AdminSharedPreferences.getInstance().reloadPreferences() -> get(key) -> getDefault()

So for example if you want to make the Edit Saved Form button not visible by default you can add there:

        if (key.equals(KEY_EDIT_SAVED)) {
            return false;
        }

the whole method would be like:

    public Object getDefault(String key) {
        if (key.equals(KEY_EDIT_SAVED)) {
            return false;
        }
        if (key.equals(KEY_ADMIN_PW)) {
            return "";
        } else {
            return true;
        }
    }

Hi,

Thank you so much for your help!! It worked.
Regards
Saumya