Skip to content

Visibile/Hidden state is not restored correctly at first app start #293

@AndroidSuggest

Description

@AndroidSuggest

When you close the app(swipe it out of the recently open apps) and then open the app, the app always starts in the "visible" mode, regardless what mode was displayed before.

The code itself suggests it different in the "MainActivity.java" https://github.com/amarradi/leafpad/blob/development/app/src/main/java/com/git/amarradi/leafpad/MainActivity.java#L231:

        boolean savedShowHidden = Leafpad.getInstance().getSavedShowHidden();
        noteViewModel.setShowHidden(savedShowHidden);

This happens directly after the load/creation of the viewmodel, where setShowHidden loads the current list.

In theory, since you use a shared preference value it should start in the mode (visible or hidden) in that the app was running when it got swiped out of the recent apps, but it does not.
This problem also exists in older versions of the app.

    public boolean getSavedShowHidden() {
        SharedPreferences prefs = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
        return prefs.getBoolean(PREF_SHOW_HIDDEN, false);
    }

    public void saveShowHidden(boolean showHidden) {
        SharedPreferences prefs = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
        prefs.edit().putBoolean(PREF_SHOW_HIDDEN, showHidden).apply();
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions