This commit is contained in:
Niels Andriesse 2020-01-15 16:13:28 +11:00
parent bfb6435d72
commit 8aa214bd7d
29 changed files with 169 additions and 93 deletions

View File

@ -307,7 +307,8 @@
<activity
android:name="org.thoughtcrime.securesms.MessageDetailsActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:label="@string/AndroidManifest__message_details"
android:label="Message Details"
android:theme="@style/Session.DarkTheme"
android:launchMode="singleTask"
android:windowSoftInputMode="stateHidden" />
<activity
@ -414,13 +415,14 @@
android:name="org.thoughtcrime.securesms.MediaPreviewActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:label="@string/AndroidManifest__media_preview"
android:theme="@style/Session.DarkTheme.SubtitleActionBar"
android:launchMode="singleTask"
android:windowSoftInputMode="stateHidden" />
<activity
android:name="org.thoughtcrime.securesms.MediaOverviewActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:launchMode="singleTask"
android:theme="@style/TextSecure.LightNoActionBar"
android:theme="@style/Session.DarkTheme.NoActionBar"
android:windowSoftInputMode="stateHidden" />
<activity
android:name="org.thoughtcrime.securesms.DummyActivity"

View File

@ -12,20 +12,17 @@
android:paddingStart="16dp"
android:paddingEnd="8dp">
<org.thoughtcrime.securesms.components.AvatarImageView
android:id="@+id/contact_photo_image"
android:layout_width="40dp"
android:layout_height="40dp"
android:foreground="@drawable/contact_photo_background"
android:cropToPadding="true"
tools:src="@color/blue_600"
android:contentDescription="@string/SingleContactSelectionActivity_contact_photo" />
<org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView
android:id="@+id/profilePictureView"
android:layout_width="@dimen/medium_profile_picture_size"
android:layout_height="@dimen/medium_profile_picture_size" />
<LinearLayout android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="16dp"
android:paddingEnd="16dp"
android:gravity="center_vertical"
android:orientation="vertical">
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
@ -35,14 +32,16 @@
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="16sp"
android:textSize="@dimen/medium_font_size"
android:textColor="@color/text"
android:textStyle="bold"
tools:text="Frieeeeeeedrich Nieeeeeeeeeetzsche" />
<LinearLayout android:id="@+id/number_container"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:visibility="gone">
<TextView android:id="@+id/number"
android:layout_width="wrap_content"

View File

@ -6,7 +6,7 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="24dp"
android:paddingBottom="20dp">
android:paddingBottom="18dp">
<View
android:layout_width="match_parent"

View File

@ -18,7 +18,6 @@
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/conversation_individual_right_gutter"
android:paddingStart="@dimen/large_spacing"
android:clipToPadding="false"
android:clipChildren="false">
@ -58,7 +57,7 @@
android:id="@+id/body_bubble"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/message_bubble_edge_margin"
android:layout_marginEnd="@dimen/massive_spacing"
android:layout_marginStart="@dimen/large_spacing"
android:paddingTop="@dimen/medium_spacing"
android:paddingBottom="@dimen/medium_spacing"
@ -163,7 +162,7 @@
android:layout="@layout/conversation_item_received_document"
android:layout_width="210dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/medium_spacing"
android:layout_marginBottom="4dp"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" />

View File

@ -36,7 +36,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="@dimen/message_bubble_edge_margin"
android:layout_marginStart="@dimen/massive_spacing"
android:paddingTop="@dimen/medium_spacing"
android:paddingBottom="@dimen/medium_spacing"
android:layout_gravity="end"
@ -99,7 +99,7 @@
android:layout_width="210dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="@dimen/medium_spacing"
android:layout_marginBottom="4dp"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" />
<org.thoughtcrime.securesms.components.emoji.EmojiTextView

View File

@ -4,9 +4,9 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingStart="@dimen/large_spacing"
android:paddingEnd="8dp"
android:paddingTop="2dp"
android:paddingBottom="@dimen/small_spacing"
android:gravity="center_vertical">
<org.thoughtcrime.securesms.components.AvatarImageView
@ -21,7 +21,6 @@
android:id="@+id/typing_bubble"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:padding="12dp"
android:background="@drawable/message_bubble_background">

View File

@ -82,7 +82,7 @@
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:layout_marginStart="6dp"
android:orientation="vertical"
android:focusable="false"
android:clickable="false">
@ -91,6 +91,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Signal.Text.Body"
android:textSize="@dimen/medium_font_size"
android:singleLine="true"
android:maxLines="1"
android:clickable="false"

View File

@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@drawable/default_session_background"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
@ -14,8 +15,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="?attr/media_overview_toolbar_background"
android:titleTextColor="?attr/media_overview_toolbar_foreground"
style="@style/Session.DarkActionBar"
app:layout_scrollFlags="scroll|enterAlways"/>
<org.thoughtcrime.securesms.components.ControllableTabLayout
@ -23,6 +23,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
style="@style/Session.DarkTabLayout"
android:background="?attr/media_overview_toolbar_background"
app:tabBackground="?attr/media_overview_toolbar_background"
app:tabIndicatorColor="@color/textsecure_primary"

View File

@ -11,8 +11,6 @@
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:textColor="?attr/media_overview_header_foreground"
android:textSize="14sp"
android:textStyle="bold"
android:textAllCaps="true"
android:textSize="@dimen/small_font_size"
tools:text="March 1, 2015" />
</FrameLayout>

View File

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/media_overview_toolbar_background">
android:background="@drawable/default_session_background">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"

View File

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/media_overview_toolbar_background">
android:background="@drawable/default_session_background">
<android.support.v7.widget.RecyclerView
android:id="@+id/media_grid"

View File

@ -11,8 +11,6 @@
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:textColor="?attr/media_overview_header_foreground"
android:textSize="14sp"
android:textStyle="bold"
android:textAllCaps="true"
android:textSize="@dimen/small_font_size"
tools:text="March 1, 2015" />
</FrameLayout>

View File

@ -6,7 +6,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray95">
android:background="@drawable/default_session_background">
<org.thoughtcrime.securesms.components.viewpager.HackyViewPager
android:id="@+id/media_pager"

View File

@ -4,5 +4,7 @@
android:layout_width="@dimen/media_bubble_remove_button_size"
android:layout_height="@dimen/media_bubble_remove_button_size"
android:layout_gravity="top|end"
android:src="@drawable/conversation_attachment_close_circle"
android:background="@drawable/circle_alpha"
android:src="@drawable/ic_close_white_18dp"
android:tint="#99FFFFFF"
android:visibility="gone"/>

View File

@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:background="@drawable/default_session_background"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

View File

@ -3,22 +3,23 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:background="@drawable/default_session_background"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout android:id="@+id/item_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:elevation="2dp" />
android:paddingTop="@dimen/medium_spacing"
android:paddingBottom="@dimen/medium_spacing"
android:elevation="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="10dp"
android:paddingEnd="10dp">
android:paddingStart="@dimen/medium_spacing"
android:paddingEnd="@dimen/medium_spacing">
<LinearLayout
android:layout_width="match_parent"
@ -30,10 +31,10 @@
android:layout_weight="1"
android:visibility="gone"
android:textSize="16sp"
android:padding="5dp"
android:drawablePadding="12dp"
tools:visibility="visible"
android:text="@string/message_details_header__issues_need_your_attention"
android:drawableStart="@drawable/ic_info_outline_light"
android:drawableStart="@drawable/ic_error"
android:gravity="center_vertical" />
<Button

View File

@ -10,10 +10,6 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/search_toolbar_background"/>
<View android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@drawable/search_toolbar_shadow"/>
android:background="@color/action_bar_background"/>
</merge>

View File

@ -5,7 +5,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@drawable/default_session_background">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
@ -13,9 +14,9 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="?attr/actionBarStyle">
android:background="@color/action_bar_background"
android:elevation="0dp"
android:theme="@style/Session.DarkActionBar">
<RelativeLayout
android:layout_width="match_parent"
@ -23,9 +24,10 @@
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ShareActivity_share_with"
android:text="Share"
android:textColor="@color/white"
android:textSize="20sp"
android:fontFamily="sans-serif-medium"
android:textSize="@dimen/very_large_font_size"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/search_action"/>
@ -34,6 +36,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_search_white_24dp"
android:visibility="gone"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"/>

View File

@ -33,8 +33,8 @@
<color name="loki_darkest_gray">#0a0a0a</color>
<!-- Loki -->
<color name="signal_primary">@color/loki_green</color>
<color name="signal_primary_dark">@color/loki_green</color>
<color name="signal_primary">@color/accent</color>
<color name="signal_primary_dark">@color/accent</color>
<color name="signal_primary_alpha33">#5578be20</color>
<color name="signal_primary_alpha_focus">#882090ea</color>

View File

@ -11,11 +11,35 @@
<item name="android:elevation">0dp</item>
</style>
<style name="Session.DarkSubtitleActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="background">@color/action_bar_background</item>
<item name="android:background">@color/action_bar_background</item>
<item name="titleTextStyle">@style/Session.DarkSubtitleActionBar.TitleTextStyle</item>
<item name="android:titleTextStyle">@style/Session.DarkSubtitleActionBar.TitleTextStyle</item>
<item name="subtitleTextStyle">@style/Session.DarkSubtitleActionBar.SubtitleTextStyle</item>
<item name="android:subtitleTextStyle">@style/Session.DarkSubtitleActionBar.SubtitleTextStyle</item>
<item name="elevation">0dp</item>
<item name="android:elevation">0dp</item>
</style>
<style name="Session.DarkActionBar.TitleTextStyle" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/text</item>
<item name="android:textSize">@dimen/very_large_font_size</item>
</style>
<style name="Session.DarkSubtitleActionBar.TitleTextStyle" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/text</item>
<item name="android:textSize">@dimen/large_font_size</item>
<item name="android:fontFamily">sans-serif-medium</item>
</style>
<style name="Session.DarkSubtitleActionBar.SubtitleTextStyle" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/text</item>
<item name="android:textSize">@dimen/small_font_size</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:textStyle">normal</item>
</style>
<style name="Session.AlertDialog" parent="ThemeOverlay.AppCompat.Dialog.Alert">
<item name="buttonBarNegativeButtonStyle">@style/Session.AlertDialog.NegativeButtonStyle</item>
<item name="buttonBarPositiveButtonStyle">@style/Session.AlertDialog.PositiveButtonStyle</item>

View File

@ -24,6 +24,17 @@
<item name="preferenceTheme">@style/Session.SettingsTheme</item>
<item name="colorAccent">@color/accent</item>
</style>
<style name="Session.DarkTheme.SubtitleActionBar" parent="@style/Theme.AppCompat">
<item name="actionBarStyle">@style/Session.DarkSubtitleActionBar</item>
<item name="colorPrimary">@color/action_bar_background</item>
<item name="colorPrimaryDark">@color/action_bar_background</item>
<item name="android:navigationBarColor">@color/navigation_bar_background</item>
<item name="alertDialogTheme">@style/Session.AlertDialog</item>
<item name="android:windowBackground">@drawable/default_session_background</item>
<item name="preferenceTheme">@style/Session.SettingsTheme</item>
<item name="colorAccent">@color/accent</item>
</style>
<!-- Session -->
<style name="TextSecure.LightNoActionBar" parent="@style/TextSecure.LightTheme">
@ -45,9 +56,9 @@
<item name="media_overview_toolbar_background">@color/white</item>
<item name="media_overview_toolbar_foreground">@color/gray70</item>
<item name="media_overview_header_foreground">@color/gray50</item>
<item name="media_overview_header_foreground">@color/text</item>
<item name="media_overview_document_primary">@color/core_grey_90</item>
<item name="media_overview_document_secondary">@color/core_grey_60</item>
<item name="media_overview_document_secondary">#99FFFFFF</item>
</style>
<style name="TextSecure.DarkNoActionBar" parent="@style/TextSecure.BaseDarkNoActionBar">
@ -72,11 +83,11 @@
<item name="contact_selection_lay_user">#afeeeeee</item>
<item name="contact_selection_header_text">#66eeeeee</item>
<item name="media_overview_toolbar_background">@color/black</item>
<item name="media_overview_toolbar_background">@color/transparent</item>
<item name="media_overview_toolbar_foreground">@color/white</item>
<item name="media_overview_header_foreground">@color/gray10</item>
<item name="media_overview_header_foreground">@color/text</item>
<item name="media_overview_document_primary">@color/core_grey_05</item>
<item name="media_overview_document_secondary">@color/core_grey_25</item>
<item name="media_overview_document_secondary">#99FFFFFF</item>
</style>
<style name="TextSecure.HighlightTheme" parent="@style/TextSecure.LightTheme">

View File

@ -104,6 +104,7 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity {
@Override
protected void onCreate(Bundle bundle, boolean ready) {
setContentView(R.layout.media_overview_activity);
getWindow().setNavigationBarColor(getResources().getColor(R.color.navigation_bar_background));
initializeResources();
initializeToolbar();
@ -142,7 +143,6 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity {
private void initializeToolbar() {
setSupportActionBar(this.toolbar);
getSupportActionBar().setTitle(recipient.toShortString());
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
this.recipient.addListener(recipient -> {
Util.runOnMain(() -> getSupportActionBar().setTitle(recipient.toShortString()));
});

View File

@ -47,7 +47,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
@ -120,16 +119,10 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle bundle, boolean ready) {
this.setTheme(R.style.TextSecure_DarkTheme);
dynamicLanguage.onCreate(this);
viewModel = ViewModelProviders.of(this).get(MediaPreviewViewModel.class);
setFullscreenIfPossible();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.media_preview_activity);
initializeViews();

View File

@ -114,11 +114,13 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
@Override
public void onCreate(Bundle bundle, boolean ready) {
super.onCreate(bundle, ready);
setContentView(R.layout.message_details_activity);
running = true;
initializeResources();
initializeActionBar();
getWindow().setNavigationBarColor(getResources().getColor(R.color.navigation_bar_background));
getSupportLoaderManager().initLoader(0, null, this);
}
@ -129,7 +131,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
dynamicLanguage.onResume(this);
assert getSupportActionBar() != null;
getSupportActionBar().setTitle(R.string.AndroidManifest__message_details);
getSupportActionBar().setTitle("Message Details");
MessageNotifier.setVisibleThread(threadId);
}
@ -148,12 +150,9 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
private void initializeActionBar() {
assert getSupportActionBar() != null;
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Recipient recipient = Recipient.from(this, getIntent().getParcelableExtra(ADDRESS_EXTRA), true);
recipient.addListener(this);
setActionBarColor(recipient.getColor());
}
private void setActionBarColor(MaterialColor color) {

View File

@ -30,7 +30,6 @@ import android.provider.OpenableColumns;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
@ -112,6 +111,8 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity
initializeResources();
initializeSearch();
initializeMedia();
getWindow().setNavigationBarColor(getResources().getColor(R.color.navigation_bar_background));
}
@Override
@ -161,12 +162,6 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity
private void initializeToolbar() {
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
private void initializeResources() {

View File

@ -8,12 +8,13 @@ import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import network.loki.messenger.R;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.recipients.Recipient;
import java.util.List;
import network.loki.messenger.R;
public class ConversationTypingView extends LinearLayout {
private AvatarImageView avatar;
@ -40,7 +41,7 @@ public class ConversationTypingView extends LinearLayout {
}
Recipient typist = typists.get(0);
bubble.getBackground().setColorFilter(typist.getColor().toConversationColor(getContext()), PorterDuff.Mode.MULTIPLY);
bubble.getBackground().setColorFilter(getResources().getColor(R.color.received_message_background), PorterDuff.Mode.MULTIPLY);
if (isGroupThread) {
avatar.setAvatar(glideRequests, typist, false);

View File

@ -56,7 +56,7 @@ public class RemovableEditableMediaView extends FrameLayout {
if (current != null) current.setVisibility(View.GONE);
if (view != null) {
view.setPadding(view.getPaddingLeft(), removeSize / 2, removeSize / 2, view.getPaddingRight());
view.setPadding(view.getPaddingLeft(), removeSize / 2, removeSize / 2, (int)(8 * getResources().getDisplayMetrics().density));
edit.setPadding(0, 0, removeSize / 2, 0);
view.setVisibility(View.VISIBLE);

View File

@ -9,22 +9,30 @@ import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;
import network.loki.messenger.R;
import org.thoughtcrime.securesms.components.AvatarImageView;
import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
import org.thoughtcrime.securesms.util.GroupUtil;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil;
import org.whispersystems.signalservice.loki.api.LokiAPI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import network.loki.messenger.R;
public class ContactSelectionListItem extends LinearLayout implements RecipientModifiedListener {
@SuppressWarnings("unused")
private static final String TAG = ContactSelectionListItem.class.getSimpleName();
private AvatarImageView contactPhotoImage;
private ProfilePictureView profilePictureView;
private TextView numberView;
private TextView nameView;
private TextView labelView;
@ -33,6 +41,7 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientM
private String number;
private Recipient recipient;
private GlideRequests glideRequests;
private long threadID;
public ContactSelectionListItem(Context context) {
super(context);
@ -45,7 +54,7 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientM
@Override
protected void onFinishInflate() {
super.onFinishInflate();
this.contactPhotoImage = findViewById(R.id.contact_photo_image);
this.profilePictureView = findViewById(R.id.profilePictureView);
this.numberView = findViewById(R.id.number);
this.labelView = findViewById(R.id.label);
this.nameView = findViewById(R.id.name);
@ -60,7 +69,6 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientM
if (type == ContactsDatabase.NEW_TYPE) {
this.recipient = null;
this.contactPhotoImage.setAvatar(glideRequests, Recipient.from(getContext(), Address.UNKNOWN, true), false);
} else if (!TextUtils.isEmpty(number)) {
Address address = Address.fromExternal(getContext(), number);
this.recipient = Recipient.from(getContext(), address, true);
@ -71,9 +79,10 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientM
}
}
this.nameView.setTextColor(color);
threadID = DatabaseFactory.getThreadDatabase(getContext()).getThreadIdFor(recipient);
this.numberView.setTextColor(color);
this.contactPhotoImage.setAvatar(glideRequests, recipient, false);
updateProfilePicture(glideRequests, name, threadID);
if (!multiSelect && recipient != null && recipient.isLocalNumber()) {
name = getContext().getString(R.string.note_to_self);
@ -94,8 +103,6 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientM
recipient.removeListener(this);
recipient = null;
}
contactPhotoImage.clear(glideRequests);
}
private void setText(int type, String name, String number, String label) {
@ -125,9 +132,30 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientM
public void onModified(final Recipient recipient) {
if (this.recipient == recipient) {
Util.runOnMain(() -> {
contactPhotoImage.setAvatar(glideRequests, recipient, false);
threadID = DatabaseFactory.getThreadDatabase(getContext()).getThreadIdFor(recipient);
updateProfilePicture(glideRequests, recipient.getName(), threadID);
nameView.setText(recipient.toShortString());
});
}
}
private void updateProfilePicture(GlideRequests glide, String name, long threadID) {
if (this.recipient.isGroupRecipient()) {
Set<String> usersAsSet = LokiAPI.Companion.getUserHexEncodedPublicKeyCache().get(threadID);
if (usersAsSet == null) {
usersAsSet = new HashSet<>();
}
ArrayList<String> users = new ArrayList<>(usersAsSet);
Collections.sort(users); // Sort to provide a level of stability
profilePictureView.setHexEncodedPublicKey(users.size() > 0 ? users.get(0) : "");
profilePictureView.setAdditionalHexEncodedPublicKey(users.size() > 1 ? users.get(1) : "");
profilePictureView.setRSSFeed(name.equals("Loki News") || name.equals("Loki Messenger Updates"));
} else {
profilePictureView.setHexEncodedPublicKey(this.number);
profilePictureView.setAdditionalHexEncodedPublicKey(null);
profilePictureView.setRSSFeed(false);
}
profilePictureView.glide = glide;
profilePictureView.update();
}
}

View File

@ -267,10 +267,10 @@ public class ConversationItem extends LinearLayout
setGroupAuthorColor(messageRecord);
setAuthor(messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
setQuote(messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
adjustMarginsIfNeeded(messageRecord);
setMessageSpacing(context, messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
setFooter(messageRecord, nextMessageRecord, locale, groupThread);
setFriendRequestView(messageRecord);
adjustMarginsIfNeeded(messageRecord);
}
@Override
@ -424,6 +424,16 @@ public class ConversationItem extends LinearLayout
!hasSticker(messageRecord);
}
private boolean hasOnlyDocument(MessageRecord messageRecord) {
return messageRecord.getBody().length() == 0 &&
!hasThumbnail(messageRecord) &&
!hasAudio(messageRecord) &&
hasDocument(messageRecord) &&
!hasSharedContact(messageRecord) &&
!hasSticker(messageRecord) &&
!hasQuote(messageRecord);
}
private boolean hasOnlyText(MessageRecord messageRecord) {
return messageRecord.getBody().length() != 0 &&
!hasThumbnail(messageRecord) &&
@ -515,6 +525,21 @@ public class ConversationItem extends LinearLayout
senderHolderLayoutParams.bottomMargin = (int)getResources().getDimension(R.dimen.medium_spacing);
}
groupSenderHolder.setLayoutParams(senderHolderLayoutParams);
if (documentViewStub.resolved()) {
LinearLayout.LayoutParams documentViewLayoutParams = (LinearLayout.LayoutParams)documentViewStub.get().getLayoutParams();
int bottomMargin = 0;
if (hasOnlyDocument(messageRecord)) {
if (footer.getVisibility() == VISIBLE) {
bottomMargin = (int)(4 * getResources().getDisplayMetrics().density);
} else {
bottomMargin = (int)(-4 * getResources().getDisplayMetrics().density);
}
} else {
bottomMargin = (int)(4 * getResources().getDisplayMetrics().density);
}
documentViewLayoutParams.bottomMargin = bottomMargin;
documentViewStub.get().setLayoutParams(documentViewLayoutParams);
}
}
private void setMediaAttributes(@NonNull MessageRecord messageRecord,