Android: Bypassing AppPreferences in BaseActivity

Created on 3 Nov 2019  路  3Comments  路  Source: nextcloud/android

Actual behaviour

BaseActivity uses SharedPreferences directly and cherry-picks private implementation details from AppPreferencesImpl.

Expected behaviour

Application should use application abstraction AppPreferences.
AppPreferencesImpl is private implementation and shall not be touched.

Steps to reproduce

This regression has been introduced in 1615130093d382211c3c84d33ff2b6206d5f5728 and c1aa005db929d08af4453489de603938e9d0c9c2

bug Theming high pr exists

Most helpful comment

@AndyScherzinger @tobiasKaminsky @dan0xii

I think this should be addressed. This change is against design principles we try to introduce.

The only reason we still have AppPreferencesImpl accessible is that we can't close it due to some tech debt in other places, but this will change.

  1. Private implemenation shall not be accessed - all calls should be done via relevant interfaces
  2. SharedPreferences shall not be accessed directly as it is unmanageable from data migration perspective

All 3 comments

@AndyScherzinger @tobiasKaminsky @dan0xii

I think this should be addressed. This change is against design principles we try to introduce.

The only reason we still have AppPreferencesImpl accessible is that we can't close it due to some tech debt in other places, but this will change.

  1. Private implemenation shall not be accessed - all calls should be done via relevant interfaces
  2. SharedPreferences shall not be accessed directly as it is unmanageable from data migration perspective

You are absolutely right 馃憤
I haven't had much sleep lately...

This should be addressed and be fixed before 3.10. While I don't know how to remove the change listener (I guess you have an idea 馃槉)

We shall just extend the AppPreferences interface and delegate to the shared preferences inside the *Impl insntance. Pretty trivial refactoring.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ikke-t picture ikke-t  路  3Comments

JSoko picture JSoko  路  3Comments

daywalk3r666 picture daywalk3r666  路  3Comments

JSoko picture JSoko  路  3Comments

tobiasKaminsky picture tobiasKaminsky  路  3Comments