new ui category in expert settings

This commit is contained in:
kosyak 2023-12-27 01:10:23 +01:00
parent bef39f7e0c
commit 6284ee12af
9 changed files with 58 additions and 17 deletions

View file

@ -1175,7 +1175,7 @@ public class ConversationFragment extends XmppFragment
case ATTACHMENT_CHOICE_CHOOSE_IMAGE:
final List<Attachment> imageUris =
Attachment.extractAttachments(getActivity(), data, Attachment.Type.IMAGE);
if (imageUris.size() == 1) {
if (imageUris.size() == 1 && !skipImageEditor()) {
editImage(imageUris.get(0).getUri());
} else {
mediaPreviewAdapter.addMediaPreviews(imageUris);
@ -1184,7 +1184,7 @@ public class ConversationFragment extends XmppFragment
break;
case ATTACHMENT_CHOICE_TAKE_PHOTO:
final Uri takePhotoUri = pendingTakePhotoUri.pop();
if (takePhotoUri != null) {
if (takePhotoUri != null && !skipImageEditor()) {
editImage(takePhotoUri);
} else {
Log.d(Config.LOGTAG, "lost take photo uri. unable to to attach");
@ -3943,6 +3943,11 @@ public class ConversationFragment extends XmppFragment
return p.getBoolean("enter_is_send", getResources().getBoolean(R.bool.enter_is_send));
}
private boolean skipImageEditor() {
final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(getActivity());
return p.getBoolean("skip_image_editor_screen", getResources().getBoolean(R.bool.skip_image_editor_screen));
}
public boolean onArrowUpCtrlPressed() {
final Message lastEditableMessage =
conversation == null ? null : conversation.getLastEditableMessage();

View file

@ -1070,7 +1070,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
boolean showDataSaverWarning = isAffectedByDataSaver();
showOsOptimizationWarning(showBatteryWarning, showDataSaverWarning);
this.binding.sessionEst.setText(UIHelper.readableTimeDifferenceFull(this, this.mAccount.getXmppConnection()
.getLastSessionEstablished()));
.getLastSessionEstablished(), allowRelativeTimestamps()));
if (features.rosterVersioning()) {
this.binding.serverInfoRosterVersion.setText(R.string.server_info_available);
} else {
@ -1401,4 +1401,9 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
public void OnUpdateBlocklist(Status status) {
refreshUi();
}
private boolean allowRelativeTimestamps() {
final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(this);
return !p.getBoolean("always_full_timestamps", getResources().getBoolean(R.bool.always_full_timestamps));
}
}

View file

@ -1,6 +1,8 @@
package eu.siacs.conversations.ui.adapter;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.preference.PreferenceManager;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
@ -37,9 +39,14 @@ public class ConversationAdapter
private final List<Conversation> conversations;
private OnConversationClickListener listener;
private boolean allowRelativeTimestamps = true;
public ConversationAdapter(XmppActivity activity, List<Conversation> conversations) {
this.activity = activity;
this.conversations = conversations;
final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(activity);
allowRelativeTimestamps = !p.getBoolean("always_full_timestamps", activity.getResources().getBoolean(R.bool.always_full_timestamps));
}
@NonNull
@ -280,7 +287,7 @@ public class ConversationAdapter
? View.VISIBLE
: View.GONE);
viewHolder.binding.conversationLastupdate.setText(
UIHelper.readableTimeDifference(activity, timestamp));
UIHelper.readableTimeDifference(activity, timestamp, allowRelativeTimestamps));
AvatarWorkerTask.loadAvatar(
conversation,
viewHolder.binding.conversationImage,

View file

@ -117,6 +117,8 @@ public class MessageAdapter extends ArrayAdapter<Message> {
@ColorInt
private int primaryColor = -1;
private boolean allowRelativeTimestamps = true;
public MessageAdapter(final XmppActivity activity, final List<Message> messages, final boolean forceNames) {
super(activity, 0, messages);
this.audioPlayer = new AudioPlayer(this);
@ -126,6 +128,9 @@ public class MessageAdapter extends ArrayAdapter<Message> {
this.mForceNames = forceNames;
allowedSwipeActions = new HashSet<>();
allowedSwipeActions.add(SwipeDetector.Action.RL);
final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(activity);
allowRelativeTimestamps = !p.getBoolean("always_full_timestamps", activity.getResources().getBoolean(R.bool.always_full_timestamps));
}
public MessageAdapter(final XmppActivity activity, final List<Message> messages) {
@ -352,7 +357,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.indicator.setVisibility(View.VISIBLE);
}
final String formattedTime = UIHelper.readableTimeDifferenceFull(getContext(), message.getMergedTimeSent());
final String formattedTime = UIHelper.readableTimeDifferenceFull(getContext(), message.getMergedTimeSent(), allowRelativeTimestamps);
final String bodyLanguage = message.getBodyLanguage();
final String bodyLanguageInfo = bodyLanguage == null ? "" : String.format(" \u00B7 %s", bodyLanguage.toUpperCase(Locale.US));
if (message.getStatus() <= Message.STATUS_RECEIVED) {
@ -847,17 +852,17 @@ public class MessageAdapter extends ArrayAdapter<Message> {
final long duration = rtpSessionStatus.duration;
if (received) {
if (duration > 0) {
viewHolder.status_message.setText(activity.getString(R.string.incoming_call_duration_timestamp, TimeFrameUtils.resolve(activity, duration), UIHelper.readableTimeDifferenceFull(activity, message.getTimeSent())));
viewHolder.status_message.setText(activity.getString(R.string.incoming_call_duration_timestamp, TimeFrameUtils.resolve(activity, duration), UIHelper.readableTimeDifferenceFull(activity, message.getTimeSent(), allowRelativeTimestamps)));
} else if (rtpSessionStatus.successful) {
viewHolder.status_message.setText(R.string.incoming_call);
} else {
viewHolder.status_message.setText(activity.getString(R.string.missed_call_timestamp, UIHelper.readableTimeDifferenceFull(activity, message.getTimeSent())));
viewHolder.status_message.setText(activity.getString(R.string.missed_call_timestamp, UIHelper.readableTimeDifferenceFull(activity, message.getTimeSent(), allowRelativeTimestamps)));
}
} else {
if (duration > 0) {
viewHolder.status_message.setText(activity.getString(R.string.outgoing_call_duration_timestamp, TimeFrameUtils.resolve(activity, duration), UIHelper.readableTimeDifferenceFull(activity, message.getTimeSent())));
viewHolder.status_message.setText(activity.getString(R.string.outgoing_call_duration_timestamp, TimeFrameUtils.resolve(activity, duration), UIHelper.readableTimeDifferenceFull(activity, message.getTimeSent(), allowRelativeTimestamps)));
} else {
viewHolder.status_message.setText(activity.getString(R.string.outgoing_call_timestamp, UIHelper.readableTimeDifferenceFull(activity, message.getTimeSent())));
viewHolder.status_message.setText(activity.getString(R.string.outgoing_call_timestamp, UIHelper.readableTimeDifferenceFull(activity, message.getTimeSent(), allowRelativeTimestamps)));
}
}
viewHolder.indicatorReceived.setImageResource(RtpSessionStatus.getDrawable(received, rtpSessionStatus.successful, isDarkTheme));

View file

@ -136,26 +136,26 @@ public class UIHelper {
private static final int FULL_DATE_FLAGS = DateUtils.FORMAT_SHOW_TIME
| DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_DATE;
public static String readableTimeDifference(Context context, long time) {
return readableTimeDifference(context, time, false);
public static String readableTimeDifference(Context context, long time, boolean allowRelative) {
return readableTimeDifference(context, time, false, allowRelative);
}
public static String readableTimeDifferenceFull(Context context, long time) {
return readableTimeDifference(context, time, true);
public static String readableTimeDifferenceFull(Context context, long time, boolean allowRelative) {
return readableTimeDifference(context, time, true, allowRelative);
}
private static String readableTimeDifference(Context context, long time,
boolean fullDate) {
boolean fullDate, boolean allowRelative) {
if (time == 0) {
return context.getString(R.string.just_now);
}
Date date = new Date(time);
long difference = (System.currentTimeMillis() - time) / 1000;
if (difference < 60) {
if (difference < 60 && allowRelative) {
return context.getString(R.string.just_now);
} else if (difference < 60 * 2) {
} else if (difference < 60 * 2 && allowRelative) {
return context.getString(R.string.minute_ago);
} else if (difference < 60 * 15) {
} else if (difference < 60 * 15 && allowRelative) {
return context.getString(R.string.minutes_ago, Math.round(difference / 60.0));
} else if (today(date)) {
java.text.DateFormat df = DateFormat.getTimeFormat(context);

View file

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="enter_is_send">true</bool>
<bool name="display_enter_key">true</bool>
</resources>

View file

@ -48,4 +48,6 @@
<bool name="prevent_screenshots">false</bool>
<string name="default_push_server">up.conversations.im</string>
<string name="default_push_account">none</string>
<bool name="always_full_timestamps">false</bool>
<bool name="skip_image_editor_screen">false</bool>
</resources>

View file

@ -592,6 +592,10 @@
<string name="pref_theme_dark">Dark</string>
<string name="pref_use_green_background">Green Background</string>
<string name="pref_use_green_background_summary">Use green background for received messages</string>
<string name="pref_always_show_full_timestamps">Show full timestamps</string>
<string name="pref_always_show_full_timestamps_summary">Always show full messages timestamps without "now", "1 min ago", etc</string>
<string name="pref_skip_image_editor_screen">Skip image editor</string>
<string name="pref_skip_image_editor_screen_summary">Dont open image editor screen automatically for single image attachments</string>
<string name="unable_to_connect_to_keychain">Could not connect to OpenKeychain</string>
<string name="this_device_is_no_longer_in_use">This device is no longer in use</string>
<string name="type_pc">Computer</string>

View file

@ -380,6 +380,18 @@
android:summary="@string/pref_channel_discovery_summary"
android:title="@string/pref_channel_discovery" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_ui_options">
<CheckBoxPreference
android:defaultValue="@bool/always_full_timestamps"
android:key="always_full_timestamps"
android:summary="@string/pref_always_show_full_timestamps_summary"
android:title="@string/pref_always_show_full_timestamps" />
<CheckBoxPreference
android:defaultValue="@bool/skip_image_editor_screen"
android:key="skip_image_editor_screen"
android:summary="@string/pref_skip_image_editor_screen_summary"
android:title="@string/pref_skip_image_editor_screen" />
</PreferenceCategory>
<intent
android:action="android.intent.action.VIEW"
android:targetClass="eu.siacs.conversations.ui.SettingsActivity"