-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Volume buttons: implement Weechat-like input history rather than sent history #557
Conversation
I don't think this is a real issue since we don't have per-buffer history. What do you suggest instead?
That's correct. I don't think I want to fix that, that would basically mean introducing some kind of forking history. I don't want to persist changes to
Fixed. When sending, if user was then navigating the history, I restore the previous input. |
app/src/main/res/values/strings.xml
Outdated
<string name="pref_buttons_volume__actions__none">Do nothing</string> | ||
<string name="pref_buttons_volume__actions__text_size">Change text size</string> | ||
<string name="pref_buttons_volume__actions__history">Navigate sent history</string> | ||
<string name="pref__buttons_volume__actions__none">Do nothing</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way this can be taken as we make volume buttons do nothing at all, perhaps we could say “Change volume” or some sort of a “bypass” or “no special action” variant? Maybe
private var userInput: Editable? = null | ||
private var selectionStart: Int? = null | ||
private var selectionEnd: Int? = null | ||
private val presentIndex = -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a constant so should be all caps
app/src/main/java/com/ubergeek42/WeechatAndroid/utils/History.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/ubergeek42/WeechatAndroid/utils/History.kt
Outdated
Show resolved
Hide resolved
val newIndex = sentMessageIndex + when (direction) { | ||
Direction.Older -> 1 | ||
Direction.Newer -> -1 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be easier to read
val newIndex = when (direction) {
Direction.Older -> sentMessageIndex + 1
Direction.Newer -> sentMessageIndex - 1
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
app/src/main/java/com/ubergeek42/WeechatAndroid/utils/History.kt
Outdated
Show resolved
Hide resolved
this.value = value; | ||
} | ||
|
||
static VolumeRole valueOfName(String value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, what is value of name
?... What change_text_size
is to ChangeTextSize
is ”a string representation of enum value” (for the purpose of storage). (CMIIW: VolumeRole
is “an enum” and ChangeTextSize
is “an enum value”.) I'd use stringRepresentation
, or just string
for shirt and because it pairs nicely with factory methods from*
.
And this is a kind of a factory methods and I prefer naming them all from*
, here it would be fromStringRepresentation()
or fromStoredString()
or fromPersistedString()
or just fromString()
, like here:
weechat-android/relay/src/main/java/com/ubergeek42/weechat/relay/connection/Handshake.kt
Lines 121 to 137 in 822ceb7
private enum class Algorithm( | |
val string: String, | |
val shaSize: Int, | |
val fast: Boolean, | |
val canHandleEmptyPassword: Boolean, | |
) { | |
Plain("plain", 0, true, true), | |
Sha256("sha256", 256, true, true), | |
Sha512("sha512", 512, true, true), | |
Pbkdf2Sha256("pbkdf2+sha256", 256, false, false), | |
Pbkdf2Sha512("pbkdf2+sha512", 512, false, false); | |
companion object { | |
fun fromString(string: String) = Algorithm::string.find(string) | |
?: throw IllegalArgumentException("Unsupported password hash algorithm: '$string'") | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
First of all let's see how WeeChat does it. We are not keeping per-buffer history and I think doing that would be overkill, and thus we can't follow WeeChat's algorithm exactly, but it should be a good reference point.
I think we can keep buffer indexes valid. That is, if you have
Forked history is awful but we could:
It's a bit weird to have your previous input pop up like that. I'd prefer the WeeChat way, pushing user input into history instead of restoring it. |
Some thoughts. Placing current input into history is going to be a bit problematic. Current input can currently have images, but sent messages are text-only objects. The Paste dialog should not have issues with this, but:
|
I don't think this has to be perfect. We can get it mostly right and iterate from there. I don't think we need to restore image previews/thumbnails. If I've posted an image to a previous channel and want to repost to another, I can use the up arrow and there will be the URL to that image, for example. |
Even if we aren't putting thumbnails into history, we have to do something with them don't we |
I'm confused. When I send an image in Weechat-Android it changes the image to a URL. Then I go to another buffer with this feature enabled and I hit the up arrow and get the URL. It works as expected. So I don't understand what needs to be done here? There are no image previews in my history so far as I can see. |
Yes, but if we are following the WeeChat way we will also want to put unsent messages to history, and these can contain images. Like if you have an image in current input and you press down. (Or up) |
Let's just not do that for now? It sounds complicated, and is not really how I would be using this feature. |
I think I previously missed the fact @oakkitten and I were just not on the same page as to what this feature is about. @oakkitten wants to replicate Weechat native local input edit history (including stuff like pushing unsent messages when pushing ↓) whereas from the get go, my goal was simply to make the sent messages (the modal that appears with a long-tap) easily accessible using volume keys. That difference in intended goals explains a lot of the comments. Now that I've laid that down, I suppose we can actually bite the bullet and implement a proper Weechat-like input history just like @oakkitten wants. Here is what this would look like, I believe I've addressed all edge-cases (while ignoring image uploads):
Making this history app-global versus buffer-local is a trivial change (if global I would store it in If you're fine with the described behavior, I'll update this PR for review. weechatvolume.mp4 |
1025c5a
to
ecff40e
Compare
ecff40e
to
faedd5e
Compare
Haven't looked at the code yet, but here's my thoughts from running the code
|
This is Weechat behavior. If you insert foo, then bar, then foo, foo is there twice. If you want consistency with Weechat, let's not change that.
Sure let's do that.
That sounds annoying but OK I guess. How do I detect there is an image? |
More than that I want to have consistency within the app itself. 😛 And it would simplify things no? Right now you need to maintain several lists
Probably less annoying than having them images replaced with spaces. You can use |
faedd5e
to
1a4b908
Compare
1a4b908
to
37c0a5b
Compare
I think fixed it. The updated code can't reach
OK so it seems like I can make this work with What do you prefer?
|
…igate input history The deprecated preference is migrated to the correspondig volume role.
37c0a5b
to
24a6c21
Compare
This is working pretty well for me. If there are further changes we'd like to make we could do those as a follow up. Any objections to merging? |
I mean this PR is definitely better (functionally wise) compared to master. @oakkitten might have code nits we can address when they're back online. OK to merge as-is. |
Please see #554 comments.