Skip to content
Snippets Groups Projects
Commit 327073f5 authored by Torsten Grote's avatar Torsten Grote
Browse files

Put conversation view layout in XML file

and fix message divider background for lower API levels.
parent 2bd53f83
No related branches found
No related tags found
No related merge requests found
<?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>
\ No newline at end of file
......@@ -113,6 +113,7 @@
<string name="step">Step %1$d/%2$d</string>
<string name="online">Online</string>
<string name="offline">Offline</string>
<string name="send">Send</string>
<!-- Dialogs -->
<string name="dialog_title_lost_password">Lost password</string>
......
package org.briarproject.android.contact;
import static android.text.InputType.TYPE_CLASS_TEXT;
import static android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
import static android.view.Gravity.CENTER;
import static android.view.Gravity.CENTER_VERTICAL;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static android.widget.LinearLayout.HORIZONTAL;
import static android.widget.LinearLayout.VERTICAL;
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_MATCH;
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
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 android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import org.briarproject.R;
import org.briarproject.android.BriarActivity;
import org.briarproject.android.util.HorizontalBorder;
import org.briarproject.android.util.LayoutUtils;
import org.briarproject.android.util.ListLoadingProgressBar;
import org.briarproject.api.AuthorId;
import org.briarproject.api.Contact;
import org.briarproject.api.ContactId;
......@@ -66,21 +49,26 @@ import org.briarproject.api.messaging.MessageId;
import org.briarproject.api.plugins.ConnectionRegistry;
import org.briarproject.util.StringUtils;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.text.InputType;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
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 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
implements EventListener, OnClickListener, OnItemClickListener {
......@@ -96,7 +84,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
private TextView empty = null;
private ConversationAdapter adapter = null;
private ListView list = null;
private ListLoadingProgressBar loading = null;
private ProgressBar loading = null;
private EditText content = null;
private ImageButton sendButton = null;
......@@ -124,17 +112,9 @@ implements EventListener, OnClickListener, OnItemClickListener {
data.putExtra("briar.CONTACT_ID", id);
setResult(RESULT_OK, data);
LinearLayout layout = new LinearLayout(this);
layout.setLayoutParams(MATCH_MATCH);
layout.setOrientation(VERTICAL);
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);
setContentView(R.layout.activity_conversation);
ViewGroup layout = (ViewGroup) findViewById(R.id.layout);
empty = (TextView) findViewById(R.id.emptyView);
adapter = new ConversationAdapter(this);
list = new ListView(this) {
......@@ -151,46 +131,21 @@ implements EventListener, OnClickListener, OnItemClickListener {
list.setClipToPadding(false);
// Make the dividers the same colour as the background
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.setDividerHeight(pad);
list.setAdapter(adapter);
list.setOnItemClickListener(this);
list.setVisibility(GONE);
layout.addView(list);
list.setEmptyView(empty);
layout.addView(list, 0);
// Show a progress bar while the list is loading
loading = new ListLoadingProgressBar(this);
layout.addView(loading);
layout.addView(new HorizontalBorder(this));
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);
loading = (ProgressBar) findViewById(R.id.listLoadingProgressBar);
content = (EditText) findViewById(R.id.contentView);
sendButton = (ImageButton) findViewById(R.id.sendButton);
sendButton.setEnabled(false); // Enabled after loading the group
sendButton.setOnClickListener(this);
footer.addView(sendButton);
layout.addView(footer);
setContentView(layout);
}
@Override
......@@ -274,12 +229,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
displayContactDetails();
sendButton.setEnabled(true);
adapter.clear();
if (headers.isEmpty()) {
empty.setVisibility(VISIBLE);
list.setVisibility(GONE);
} else {
empty.setVisibility(GONE);
list.setVisibility(VISIBLE);
if (!headers.isEmpty()) {
for (MessageHeader h : headers) {
ConversationItem item = new ConversationItem(h);
byte[] body = bodyCache.get(h.getId());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment