Skip to content

Conversation

@RemiRigal
Copy link
Contributor

I've added a setting to fulfill one of the improvements proposed by @alekna in #145.

The setting allows the user to choose whether the default display mode for dates should be absolute or relative. Note that the toggle between the two modes is still working when the TextView is clicked.

Here is the settings activity:

And here is the main activity:

I've modified the way the precise date is formatted using the DateFormat java module.

<string name="settings_appearance">Appearance</string>
<string name="setting_theme">Theme</string>
<string name="setting_key_theme">theme</string>
<string name="setting_precise_date">Precise date by default</string>
Copy link

@alekna alekna Feb 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's unprecise about relative timestamps?

As I understand it the difference here is between relative and absolute timestamps. So for me it would make more sense naming this option Show absolute timestamps instead of Precise date by default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely agree with you, to be honest I named it like that only because the boolean variable that was already there was named preciseDate and I just wanted to stay coherent.

If it's fine to everyone it can be changed to be relative/absolute time instead of precise.

android:key="@string/setting_key_theme"
android:title="@string/setting_theme" />

<CheckBoxPreference
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for your contribution! Could we change this to a list preference with the label "time format" and values "absolute time" and "relative time"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll take care of this !

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given there are only two choices wouldn't it be better to keep a checkbox? Check-box offers single-click solution while selecting from a list would require two clicks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think changing settings isn't something that is done frequently, thus, I
prefer ui elements that are more descriptive than click efficient.

Presenting a user two options from which they can choose is IMO better than
hiding the default option.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using check-box would be consistent with other places in Android. Not saying it's a convention but at least that's what I noticed. For example Date and time settings:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with both of you on this, on the one hand as @jmattheis said you don't change settings frequently so an extra click for configuration isn't that much in my opinion. On the other hand, the default time displayed in the web app is always relative and there is no way to change it, making it the default one, so a checkbox overriding that default setup makes sense too.

I think I will do it with a ListPreference though, it's definitely more explicit, and user still have the possibility to toggle between the two modes just by clicking on the TextView.

@RemiRigal
Copy link
Contributor Author

I've made the change to a ListPreference, here is the result:

Let me know if any additional changes should be made !

holder.setDateTime(message.message.getDate());
holder.date.setOnClickListener((ignored) -> holder.switchPreciseDate());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String timeFormat = prefs.getString(TIME_FORMAT_PREFS_KEY, TIME_FORMAT_RELATIVE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I've found one little bug. If no time format is configured, and the settings for time format is opened but dismissed, then the absolute time format is shown. The shared preferences get "Relative time" as value, and not the key relative_time_format.

screencast

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I set the default value in the ListPreference as the time_format_entry_relative instead of time_format_value_relative, my bad.

Thanks for the thorough review, it should be fine now.

Copy link
Member

@jmattheis jmattheis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@jmattheis jmattheis merged commit 21e49d0 into gotify:master Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants