Configurable clipboard autoclear timeout support - #353
Conversation
Depends on GmsCompat.
x86pup
left a comment
There was a problem hiding this comment.
Needs some changes, needs to be rebased, and I think we want this to be per-user instead of global unless due to some limitation.
I did type these suggestions on GitHub which may be incorrect / hard to understand, so if you want I can push my requested changes to my fork.
| * The amount of time in milliseconds before the clipboard is cleared. | ||
| * @hide | ||
| */ | ||
| public static final String CLIPBOARD_AUTO_CLEAR_TIMEOUT = "clipboard_auto_clear_timeout"; |
There was a problem hiding this comment.
ExtSettings infrastructure does not touch Settings.java, you need to define this in ExtSettings.java instead
| return DeviceConfig.getLong(DeviceConfig.NAMESPACE_CLIPBOARD, | ||
| PROPERTY_AUTO_CLEAR_TIMEOUT, | ||
| DEFAULT_CLIPBOARD_TIMEOUT_MILLIS); | ||
| return Settings.Global.getLong(mContext.getContentResolver(), Settings.Global.CLIPBOARD_AUTO_CLEAR_TIMEOUT, DEFAULT_CLIPBOARD_TIMEOUT_MILLIS); |
There was a problem hiding this comment.
ExtSettings checks should import import android.ext.settings.ExtSettings; and do:
ExtSettings.<key>.get(<context>)
In this case:
return ExtSettings.CLIPBOARD_AUTO_CLEAR_TIMEOUT.get(mContext)
As we're not using Settings.java.
| Setting.Scope.PER_USER, "lockscreen_scramble_pin_layout", false); | ||
|
|
||
| public static final IntSetting CLIPBOARD_AUTO_CLEAR_TIMEOUT = new IntSetting( | ||
| Setting.Scope.GLOBAL, "clipboard_auto_clear_timeout", DEFAULT_CLIPBOARD_TIMEOUT_MILLIS); |
There was a problem hiding this comment.
I think we also want this to be per-user instead of global
|
Should be ready for testing on a pixel. |
|
Still needs to be rebased |
|
Toggle doesn't seem to show up in my Pixel 6 after building. (See review in Settings for solution) |
x86pup
left a comment
There was a problem hiding this comment.
Need to replace mContext with getContext() method, and get the userId as the Context is not per-user
| @@ -429,9 +430,7 @@ private void scheduleAutoClear(@UserIdInt int userId, int intendingUid) { | |||
| } | |||
|
|
|||
| private long getTimeoutForAutoClear() { | |||
There was a problem hiding this comment.
Seems like this isn't a per-user Context (and mContext seems invalid here, build error) which will cause the settings in the Owner profile to apply across all profiles irrespective of the current profile's setting, so you'll need to specify the uid this is for.
| private long getTimeoutForAutoClear() { | |
| private long getTimeoutForAutoClear(int userId) { | |
| return ExtSettings.CLIPBOARD_AUTO_CLEAR_TIMEOUT.get(getContext(), userId); |
And where getTimeoutForAutoClear method is called, pass the userId argument:
getTimeoutForAutoClear(userId)
There was a problem hiding this comment.
Didn't catch that build error as I'm currently using m Settings. Waiting for a new SSD to arrive (don't have enough space on device).
|
Closing this pull request as it became messy. Will open a new one and send here. |
|
#357 @r3g-5z |
Dependent on: GrapheneOS/platform_packages_apps_Settings#158
Needs testing!