ConversationActivity: Cardify UI. Add send button. Trigger nick completion on send button long press.
This commit is contained in:
parent
0a539c3a04
commit
b1fe1b09a0
|
@ -49,6 +49,7 @@ import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.yaaic.R;
|
import org.yaaic.R;
|
||||||
|
@ -101,6 +102,7 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo
|
||||||
private ConversationReceiver channelReceiver;
|
private ConversationReceiver channelReceiver;
|
||||||
private ServerReceiver serverReceiver;
|
private ServerReceiver serverReceiver;
|
||||||
|
|
||||||
|
private EditText input;
|
||||||
private ViewPager pager;
|
private ViewPager pager;
|
||||||
private ConversationPagerAdapter pagerAdapter;
|
private ConversationPagerAdapter pagerAdapter;
|
||||||
private ConversationTabLayout tabLayout;
|
private ConversationTabLayout tabLayout;
|
||||||
|
@ -148,14 +150,7 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
||||||
sendMessage(input.getText().toString());
|
sendCurrentMessage();
|
||||||
|
|
||||||
// Workaround for a race condition in EditText
|
|
||||||
// Instead of calling input.setText("");
|
|
||||||
// See:
|
|
||||||
// - https://github.com/pocmo/Yaaic/issues/67
|
|
||||||
// - http://code.google.com/p/android/issues/detail?id=17508
|
|
||||||
TextKeyListener.clear(input.getText());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +194,7 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo
|
||||||
|
|
||||||
boolean isLandscape = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
|
boolean isLandscape = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
|
||||||
|
|
||||||
EditText input = (EditText) findViewById(R.id.input);
|
input = (EditText) findViewById(R.id.input);
|
||||||
input.setOnKeyListener(inputKeyListener);
|
input.setOnKeyListener(inputKeyListener);
|
||||||
|
|
||||||
pager = (ViewPager) findViewById(R.id.pager);
|
pager = (ViewPager) findViewById(R.id.pager);
|
||||||
|
@ -220,9 +215,6 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo
|
||||||
server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
|
server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
input.setTextSize(settings.getFontSize());
|
|
||||||
input.setTypeface(Typeface.MONOSPACE);
|
|
||||||
|
|
||||||
// Optimization : cache field lookups
|
// Optimization : cache field lookups
|
||||||
Collection<Conversation> mConversations = server.getConversations();
|
Collection<Conversation> mConversations = server.getConversations();
|
||||||
|
|
||||||
|
@ -253,6 +245,23 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo
|
||||||
|
|
||||||
input.setInputType(input.getInputType() | setInputTypeFlags);
|
input.setInputType(input.getInputType() | setInputTypeFlags);
|
||||||
|
|
||||||
|
ImageButton sendButton = (ImageButton) findViewById(R.id.send);
|
||||||
|
sendButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (input.getText().length() > 0) {
|
||||||
|
sendCurrentMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sendButton.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
doNickCompletion(input);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Create a new scrollback history
|
// Create a new scrollback history
|
||||||
scrollback = new Scrollback();
|
scrollback = new Scrollback();
|
||||||
}
|
}
|
||||||
|
@ -737,6 +746,17 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendCurrentMessage() {
|
||||||
|
sendMessage(input.getText().toString());
|
||||||
|
|
||||||
|
// Workaround for a race condition in EditText
|
||||||
|
// Instead of calling input.setText("");
|
||||||
|
// See:
|
||||||
|
// - https://github.com/pocmo/Yaaic/issues/67
|
||||||
|
// - http://code.google.com/p/android/issues/detail?id=17508
|
||||||
|
TextKeyListener.clear(input.getText());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message in this conversation
|
* Send a message in this conversation
|
||||||
*
|
*
|
||||||
|
|
|
@ -331,9 +331,6 @@ public class Message
|
||||||
canvas.setLinkTextColor(COLOR_BLUE);
|
canvas.setLinkTextColor(COLOR_BLUE);
|
||||||
|
|
||||||
canvas.setText(this.render(context));
|
canvas.setText(this.render(context));
|
||||||
canvas.setTextSize(settings.getFontSize());
|
|
||||||
canvas.setTypeface(Typeface.MONOSPACE);
|
|
||||||
canvas.setTextColor(COLOR_DEFAULT);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
setupViewForHoneycombAndLater(canvas);
|
setupViewForHoneycombAndLater(canvas);
|
||||||
|
|
|
@ -47,9 +47,8 @@ public class MessageListView extends ListView
|
||||||
|
|
||||||
setDivider(null);
|
setDivider(null);
|
||||||
|
|
||||||
setCacheColorHint(0x000000);
|
setCacheColorHint(0xFFFFFFFF);
|
||||||
setVerticalFadingEdgeEnabled(false);
|
setVerticalFadingEdgeEnabled(false);
|
||||||
setBackgroundResource(R.drawable.conversation_background);
|
|
||||||
setScrollBarStyle(SCROLLBARS_OUTSIDE_INSET);
|
setScrollBarStyle(SCROLLBARS_OUTSIDE_INSET);
|
||||||
|
|
||||||
// Scale padding by screen density
|
// Scale padding by screen density
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 486 B |
Binary file not shown.
After Width: | Height: | Size: 356 B |
Binary file not shown.
After Width: | Height: | Size: 742 B |
Binary file not shown.
After Width: | Height: | Size: 808 B |
|
@ -1,35 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
Yaaic - Yet Another Android IRC Client
|
|
||||||
|
|
||||||
Copyright 2009-2013 Sebastian Kaspari
|
|
||||||
|
|
||||||
This file is part of Yaaic.
|
|
||||||
|
|
||||||
Yaaic is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Yaaic is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
<shape
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<stroke
|
|
||||||
android:width="1dp"
|
|
||||||
android:color="#FF181818" />
|
|
||||||
<padding
|
|
||||||
android:left="3dp"
|
|
||||||
android:top="3dp"
|
|
||||||
android:right="3dp"
|
|
||||||
android:bottom="3dp" />
|
|
||||||
<solid
|
|
||||||
android:color="#FF000000" />
|
|
||||||
</shape>
|
|
|
@ -38,27 +38,54 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/primary" />
|
android:background="@color/primary" />
|
||||||
|
|
||||||
|
|
||||||
|
<android.support.v7.widget.CardView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_margin="4dp"
|
||||||
|
card_view:cardBackgroundColor="@color/cardview_background">
|
||||||
<android.support.v4.view.ViewPager
|
<android.support.v4.view.ViewPager
|
||||||
android:id="@+id/pager"
|
android:id="@+id/pager"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_margin="0px"
|
android:layout_margin="0dp"
|
||||||
android:layout_weight="1"
|
android:padding="0dp" />
|
||||||
android:padding="0dp"
|
</android.support.v7.widget.CardView>
|
||||||
android:unselectedAlpha="100" />
|
|
||||||
|
<android.support.v7.widget.CardView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_margin="4dp"
|
||||||
|
card_view:cardBackgroundColor="@color/cardview_background">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/input"
|
android:id="@+id/input"
|
||||||
android:layout_width="0dp"
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:imeOptions="actionSend"
|
android:imeOptions="actionSend"
|
||||||
android:inputType="textImeMultiLine" />
|
android:background="@android:color/transparent"
|
||||||
|
android:inputType="textShortMessage" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/send"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:src="@drawable/ic_action_send"
|
||||||
|
style="?android:attr/borderlessButtonStyle" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/speech"
|
android:id="@+id/speech"
|
||||||
|
@ -67,6 +94,9 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||||
android:drawableLeft="@android:drawable/ic_btn_speak_now"
|
android:drawableLeft="@android:drawable/ic_btn_speak_now"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</android.support.v7.widget.CardView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<include layout="@layout/item_drawer" />
|
<include layout="@layout/item_drawer" />
|
||||||
|
|
Loading…
Reference in New Issue