mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 07:32:19 +00:00
WIP
This commit is contained in:
@@ -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()));
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user