mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 04:39:54 +01:00
Put conversation view layout in XML file
and fix message divider background for lower API levels.
This commit is contained in:
63
briar-android/res/layout/activity_conversation.xml
Normal file
63
briar-android/res/layout/activity_conversation.xml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/layout"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<!-- ListView will get inserted here -->
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/listLoadingProgressBar"
|
||||||
|
style="?android:attr/progressBarStyleLarge"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:indeterminate="true"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/emptyView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:padding="@dimen/margin_large"
|
||||||
|
android:textSize="@dimen/text_size_large"
|
||||||
|
android:text="@string/no_private_messages"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1px"
|
||||||
|
android:background="@color/horizontal_border"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/button_bar_background"
|
||||||
|
android:paddingLeft="@dimen/margin_medium"
|
||||||
|
android:paddingStart="@dimen/margin_medium"
|
||||||
|
android:paddingRight="@dimen/margin_medium"
|
||||||
|
android:paddingEnd="@dimen/margin_medium">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/contentView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/private_message_hint"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:inputType="text|textMultiLine|textCapSentences"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/sendButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/social_send_now"
|
||||||
|
android:background="@color/button_bar_background"
|
||||||
|
android:contentDescription="@string/send"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -113,6 +113,7 @@
|
|||||||
<string name="step">Step %1$d/%2$d</string>
|
<string name="step">Step %1$d/%2$d</string>
|
||||||
<string name="online">Online</string>
|
<string name="online">Online</string>
|
||||||
<string name="offline">Offline</string>
|
<string name="offline">Offline</string>
|
||||||
|
<string name="send">Send</string>
|
||||||
|
|
||||||
<!-- Dialogs -->
|
<!-- Dialogs -->
|
||||||
<string name="dialog_title_lost_password">Lost password</string>
|
<string name="dialog_title_lost_password">Lost password</string>
|
||||||
|
|||||||
@@ -1,41 +1,24 @@
|
|||||||
package org.briarproject.android.contact;
|
package org.briarproject.android.contact;
|
||||||
|
|
||||||
import static android.text.InputType.TYPE_CLASS_TEXT;
|
import android.content.Intent;
|
||||||
import static android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
|
import android.content.res.Resources;
|
||||||
import static android.view.Gravity.CENTER;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import static android.view.Gravity.CENTER_VERTICAL;
|
import android.os.Bundle;
|
||||||
import static android.view.View.GONE;
|
import android.support.v7.app.ActionBar;
|
||||||
import static android.view.View.VISIBLE;
|
import android.view.View;
|
||||||
import static android.widget.LinearLayout.HORIZONTAL;
|
import android.view.View.OnClickListener;
|
||||||
import static android.widget.LinearLayout.VERTICAL;
|
import android.view.ViewGroup;
|
||||||
import static java.util.logging.Level.INFO;
|
import android.widget.AdapterView;
|
||||||
import static java.util.logging.Level.WARNING;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import static org.briarproject.android.contact.ReadPrivateMessageActivity.RESULT_PREV_NEXT;
|
import android.widget.EditText;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
import android.widget.ImageButton;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
import android.widget.ListView;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
import android.widget.ProgressBar;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.security.GeneralSecurityException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
import org.briarproject.android.BriarActivity;
|
import org.briarproject.android.BriarActivity;
|
||||||
import org.briarproject.android.util.HorizontalBorder;
|
|
||||||
import org.briarproject.android.util.LayoutUtils;
|
import org.briarproject.android.util.LayoutUtils;
|
||||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
|
||||||
import org.briarproject.api.AuthorId;
|
import org.briarproject.api.AuthorId;
|
||||||
import org.briarproject.api.Contact;
|
import org.briarproject.api.Contact;
|
||||||
import org.briarproject.api.ContactId;
|
import org.briarproject.api.ContactId;
|
||||||
@@ -66,21 +49,26 @@ import org.briarproject.api.messaging.MessageId;
|
|||||||
import org.briarproject.api.plugins.ConnectionRegistry;
|
import org.briarproject.api.plugins.ConnectionRegistry;
|
||||||
import org.briarproject.util.StringUtils;
|
import org.briarproject.util.StringUtils;
|
||||||
|
|
||||||
import android.content.Intent;
|
import java.io.IOException;
|
||||||
import android.content.res.Resources;
|
import java.security.GeneralSecurityException;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import java.util.ArrayList;
|
||||||
import android.os.Bundle;
|
import java.util.Collection;
|
||||||
import android.support.v7.app.ActionBar;
|
import java.util.Collections;
|
||||||
import android.text.InputType;
|
import java.util.HashMap;
|
||||||
import android.view.View;
|
import java.util.HashSet;
|
||||||
import android.view.View.OnClickListener;
|
import java.util.List;
|
||||||
import android.widget.AdapterView;
|
import java.util.Map;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import java.util.Set;
|
||||||
import android.widget.EditText;
|
import java.util.concurrent.Executor;
|
||||||
import android.widget.ImageButton;
|
import java.util.logging.Logger;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ListView;
|
import javax.inject.Inject;
|
||||||
import android.widget.TextView;
|
|
||||||
|
import static android.view.View.GONE;
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
import static java.util.logging.Level.WARNING;
|
||||||
|
import static org.briarproject.android.contact.ReadPrivateMessageActivity.RESULT_PREV_NEXT;
|
||||||
|
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
||||||
|
|
||||||
public class ConversationActivity extends BriarActivity
|
public class ConversationActivity extends BriarActivity
|
||||||
implements EventListener, OnClickListener, OnItemClickListener {
|
implements EventListener, OnClickListener, OnItemClickListener {
|
||||||
@@ -96,7 +84,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
private TextView empty = null;
|
private TextView empty = null;
|
||||||
private ConversationAdapter adapter = null;
|
private ConversationAdapter adapter = null;
|
||||||
private ListView list = null;
|
private ListView list = null;
|
||||||
private ListLoadingProgressBar loading = null;
|
private ProgressBar loading = null;
|
||||||
private EditText content = null;
|
private EditText content = null;
|
||||||
private ImageButton sendButton = null;
|
private ImageButton sendButton = null;
|
||||||
|
|
||||||
@@ -124,17 +112,9 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
data.putExtra("briar.CONTACT_ID", id);
|
data.putExtra("briar.CONTACT_ID", id);
|
||||||
setResult(RESULT_OK, data);
|
setResult(RESULT_OK, data);
|
||||||
|
|
||||||
LinearLayout layout = new LinearLayout(this);
|
setContentView(R.layout.activity_conversation);
|
||||||
layout.setLayoutParams(MATCH_MATCH);
|
ViewGroup layout = (ViewGroup) findViewById(R.id.layout);
|
||||||
layout.setOrientation(VERTICAL);
|
empty = (TextView) findViewById(R.id.emptyView);
|
||||||
|
|
||||||
empty = new TextView(this);
|
|
||||||
empty.setLayoutParams(MATCH_WRAP_1);
|
|
||||||
empty.setGravity(CENTER);
|
|
||||||
empty.setTextSize(18);
|
|
||||||
empty.setText(R.string.no_private_messages);
|
|
||||||
empty.setVisibility(GONE);
|
|
||||||
layout.addView(empty);
|
|
||||||
|
|
||||||
adapter = new ConversationAdapter(this);
|
adapter = new ConversationAdapter(this);
|
||||||
list = new ListView(this) {
|
list = new ListView(this) {
|
||||||
@@ -151,46 +131,21 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
list.setClipToPadding(false);
|
list.setClipToPadding(false);
|
||||||
// Make the dividers the same colour as the background
|
// Make the dividers the same colour as the background
|
||||||
Resources res = getResources();
|
Resources res = getResources();
|
||||||
int background = res.getColor(R.color.window_background);
|
int background = res.getColor(android.R.color.transparent);
|
||||||
list.setDivider(new ColorDrawable(background));
|
list.setDivider(new ColorDrawable(background));
|
||||||
list.setDividerHeight(pad);
|
list.setDividerHeight(pad);
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
list.setOnItemClickListener(this);
|
list.setOnItemClickListener(this);
|
||||||
list.setVisibility(GONE);
|
list.setEmptyView(empty);
|
||||||
layout.addView(list);
|
layout.addView(list, 0);
|
||||||
|
|
||||||
// Show a progress bar while the list is loading
|
// Show a progress bar while the list is loading
|
||||||
loading = new ListLoadingProgressBar(this);
|
loading = (ProgressBar) findViewById(R.id.listLoadingProgressBar);
|
||||||
layout.addView(loading);
|
|
||||||
|
|
||||||
layout.addView(new HorizontalBorder(this));
|
content = (EditText) findViewById(R.id.contentView);
|
||||||
|
sendButton = (ImageButton) findViewById(R.id.sendButton);
|
||||||
LinearLayout footer = new LinearLayout(this);
|
|
||||||
footer.setLayoutParams(MATCH_WRAP);
|
|
||||||
footer.setOrientation(HORIZONTAL);
|
|
||||||
footer.setGravity(CENTER_VERTICAL);
|
|
||||||
footer.setPadding(pad, 0, 0, 0);
|
|
||||||
footer.setBackgroundColor(res.getColor(R.color.button_bar_background));
|
|
||||||
|
|
||||||
content = new EditText(this);
|
|
||||||
content.setId(1);
|
|
||||||
content.setLayoutParams(WRAP_WRAP_1);
|
|
||||||
int inputType = TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
|
||||||
| TYPE_TEXT_FLAG_CAP_SENTENCES;
|
|
||||||
content.setInputType(inputType);
|
|
||||||
content.setHint(R.string.private_message_hint);
|
|
||||||
footer.addView(content);
|
|
||||||
|
|
||||||
sendButton = new ImageButton(this);
|
|
||||||
sendButton.setId(2);
|
|
||||||
sendButton.setBackgroundResource(0);
|
|
||||||
sendButton.setImageResource(R.drawable.social_send_now);
|
|
||||||
sendButton.setEnabled(false); // Enabled after loading the group
|
sendButton.setEnabled(false); // Enabled after loading the group
|
||||||
sendButton.setOnClickListener(this);
|
sendButton.setOnClickListener(this);
|
||||||
footer.addView(sendButton);
|
|
||||||
layout.addView(footer);
|
|
||||||
|
|
||||||
setContentView(layout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -274,12 +229,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
displayContactDetails();
|
displayContactDetails();
|
||||||
sendButton.setEnabled(true);
|
sendButton.setEnabled(true);
|
||||||
adapter.clear();
|
adapter.clear();
|
||||||
if (headers.isEmpty()) {
|
if (!headers.isEmpty()) {
|
||||||
empty.setVisibility(VISIBLE);
|
|
||||||
list.setVisibility(GONE);
|
|
||||||
} else {
|
|
||||||
empty.setVisibility(GONE);
|
|
||||||
list.setVisibility(VISIBLE);
|
|
||||||
for (MessageHeader h : headers) {
|
for (MessageHeader h : headers) {
|
||||||
ConversationItem item = new ConversationItem(h);
|
ConversationItem item = new ConversationItem(h);
|
||||||
byte[] body = bodyCache.get(h.getId());
|
byte[] body = bodyCache.get(h.getId());
|
||||||
|
|||||||
Reference in New Issue
Block a user