Add more UI demo
This commit is contained in:
parent
6c4d022b37
commit
6067d70189
|
@ -24,7 +24,7 @@
|
|||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package de.vanitasvitae.slam.activity;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import de.vanitasvitae.slam.R;
|
||||
import de.vanitasvitae.slam.ui.ChatMessageEntry;
|
||||
|
||||
/**
|
||||
* Created by Paul Schaub on 30.01.18.
|
||||
*/
|
||||
public class ChatFragment extends Fragment {
|
||||
|
||||
@BindView(R.id.recycler_chat)
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_chat, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(final View view, Bundle savedInstanceState) {
|
||||
final String[] messages = new String[] {"This is an example message.", "null","This is a very long message. Its purpose is to demonstrate Slam!s ability to render longer messages in a sane way without looking too crowded."};
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
recyclerView.setAdapter(new RecyclerView.Adapter<ChatMessageEntry>() {
|
||||
@Override
|
||||
public ChatMessageEntry onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view1 = LayoutInflater.from(getActivity()).inflate(R.layout.item_chatmessage, parent, false);
|
||||
return new ChatMessageEntry(view1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ChatMessageEntry holder, int position) {
|
||||
View content;
|
||||
if (position != 1) {
|
||||
content = new TextView(getActivity());
|
||||
((TextView)content).setText(messages[position]);
|
||||
} else {
|
||||
content = new ImageView(getActivity());
|
||||
((ImageView)content).setImageResource(R.drawable.ic_add_a_photo_black_48dp);
|
||||
}
|
||||
holder.bind("alice@wonderland.lit",
|
||||
"Member", content, "just now");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return messages.length;
|
||||
}
|
||||
});
|
||||
recyclerView.getAdapter().notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package de.vanitasvitae.slam.activity;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import de.vanitasvitae.slam.R;
|
||||
import de.vanitasvitae.slam.ui.ChatListEntry;
|
||||
|
||||
/**
|
||||
* Created by Paul Schaub on 30.01.18.
|
||||
*/
|
||||
public class ChatListFragment extends Fragment {
|
||||
|
||||
@BindView(R.id.recycler_chatlist)
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_chatlist, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(final View view, Bundle savedInstanceState) {
|
||||
final String[] usernames = {"alice@wonderland.lit", "Bob the Builder", "Marvin"};
|
||||
final String[] messages = {"But I don’t want to go among mad people", "Yes we can!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "My name is Marvin!"};
|
||||
final String[] dates = {"13:37", "yesterday", "24.12.2018"};
|
||||
final boolean[] reads = {true, false, true};
|
||||
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
recyclerView.setAdapter(new RecyclerView.Adapter<ChatListEntry>() {
|
||||
@Override
|
||||
public ChatListEntry onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view1 = LayoutInflater.from(getActivity()).inflate(R.layout.chatlist_singlechat, parent, false);
|
||||
view1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.fragment_container, new ChatFragment()).commit();
|
||||
}
|
||||
});
|
||||
return new ChatListEntry(view1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ChatListEntry holder, int position) {
|
||||
holder.bind(
|
||||
usernames[position],
|
||||
messages[position],
|
||||
dates[position],
|
||||
reads[position]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return usernames.length;
|
||||
}
|
||||
});
|
||||
recyclerView.getAdapter().notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,18 @@
|
|||
package de.vanitasvitae.slam.activity;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
@ -16,6 +23,8 @@ import de.vanitasvitae.slam.R;
|
|||
*/
|
||||
public class MainActivity extends ThemedAppCompatActivity {
|
||||
|
||||
public static final String TAG = "Slam!";
|
||||
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
|
||||
|
@ -25,6 +34,9 @@ public class MainActivity extends ThemedAppCompatActivity {
|
|||
@BindView(R.id.drawer_layout)
|
||||
DrawerLayout drawerLayout;
|
||||
|
||||
@BindView(R.id.fragment_container)
|
||||
FrameLayout fragmentContainer;
|
||||
|
||||
private ActionBarDrawerToggle drawerToggle;
|
||||
|
||||
@Override
|
||||
|
@ -38,6 +50,10 @@ public class MainActivity extends ThemedAppCompatActivity {
|
|||
drawerToggle = new ActionBarDrawerToggle(
|
||||
this, drawerLayout, toolbar, R.string.error_incorrect_password, R.string.error_invalid_jid);
|
||||
drawerLayout.addDrawerListener(drawerToggle);
|
||||
|
||||
Fragment chatListFragment = new ChatListFragment();
|
||||
Log.d(TAG, "Begin Transaction");
|
||||
getFragmentManager().beginTransaction().add(R.id.fragment_container, chatListFragment).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,5 +67,4 @@ public class MainActivity extends ThemedAppCompatActivity {
|
|||
super.onPostCreate(savedInstanceState);
|
||||
drawerToggle.syncState();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package de.vanitasvitae.slam.ui;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.vanitasvitae.slam.R;
|
||||
|
||||
/**
|
||||
* Created by Paul Schaub on 30.01.18.
|
||||
*/
|
||||
public class ChatListEntry extends RecyclerView.ViewHolder {
|
||||
|
||||
private View view;
|
||||
|
||||
public ChatListEntry(View itemView) {
|
||||
super(itemView);
|
||||
this.view = itemView;
|
||||
}
|
||||
|
||||
public void bind(String username, String message, String date, boolean read) {
|
||||
View v = view;
|
||||
((TextView)v.findViewById(R.id.contact_name)).setText(username);
|
||||
((TextView)v.findViewById(R.id.contact_textcontent)).setText(message);
|
||||
((TextView)v.findViewById(R.id.contact_date)).setText(date);
|
||||
v.findViewById(R.id.send_indicator).setVisibility(read ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package de.vanitasvitae.slam.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import de.vanitasvitae.slam.R;
|
||||
|
||||
/**
|
||||
* Created by Paul Schaub on 29.01.18.
|
||||
*/
|
||||
public class ChatMessage extends ViewGroup {
|
||||
|
||||
public ChatMessage(Context context) {
|
||||
super(context);
|
||||
inflate(context, R.layout.item_chatmessage, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package de.vanitasvitae.slam.ui;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.vanitasvitae.slam.R;
|
||||
|
||||
/**
|
||||
* Created by Paul Schaub on 30.01.18.
|
||||
*/
|
||||
public class ChatMessageEntry extends RecyclerView.ViewHolder {
|
||||
|
||||
private View view;
|
||||
|
||||
public ChatMessageEntry(View itemView) {
|
||||
super(itemView);
|
||||
this.view = itemView;
|
||||
}
|
||||
|
||||
public void bind(String sender, String role, View content, String date) {
|
||||
((TextView)view.findViewById(R.id.message_sender)).setText(sender);
|
||||
((TextView)view.findViewById(R.id.message_sender_role)).setText(role);
|
||||
((RelativeLayout)view.findViewById(R.id.message_content)).addView(content);
|
||||
((TextView)view.findViewById(R.id.message_date)).setText(date);
|
||||
}
|
||||
}
|
|
@ -16,15 +16,10 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:openDrawer="start">
|
||||
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/item_chatmessage" />
|
||||
<include layout="@layout/chatlist_singlechat" />
|
||||
|
||||
</LinearLayout>
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<android.support.design.widget.NavigationView
|
||||
android:id="@+id/navigation_view"
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
android:layout_alignParentEnd="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/send_indicator"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_check_black_48dp"/>
|
||||
|
@ -63,6 +64,7 @@
|
|||
android:layout_toStartOf="@+id/lower_meta">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contact_textcontent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Ich war letzte Woche noch da und habe mir einen eigenen Eindruck von der Lage verschafft."/>
|
||||
|
@ -73,11 +75,12 @@
|
|||
android:id="@+id/lower_meta"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:orientation="horizontal"
|
||||
android:layout_alignParentEnd="true">
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contact_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="13:37"/>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/recycler_chat"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="10dp">
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/recycler_chatlist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="10dp">
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
|
@ -50,13 +50,14 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<!--
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="?attr/textSizeMessageContent"
|
||||
android:text="This is an example text."
|
||||
/>
|
||||
|
||||
-->
|
||||
<!--
|
||||
<ImageView
|
||||
android:layout_width="300dp"
|
||||
|
@ -84,7 +85,7 @@
|
|||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sender_date"
|
||||
android:id="@+id/message_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
Loading…
Reference in New Issue