1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-21 16:35:09 -05:00

ConversationActivity: Cardify UI. Add send button. Trigger nick completion on send button long press.

This commit is contained in:
Sebastian Kaspari 2015-03-24 22:19:25 +01:00
parent 0a539c3a04
commit b1fe1b09a0
9 changed files with 73 additions and 62 deletions

View File

@ -49,6 +49,7 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;
import org.yaaic.R;
@ -101,6 +102,7 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo
private ConversationReceiver channelReceiver;
private ServerReceiver serverReceiver;
private EditText input;
private ViewPager pager;
private ConversationPagerAdapter pagerAdapter;
private ConversationTabLayout tabLayout;
@ -148,14 +150,7 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo
}
if (keyCode == KeyEvent.KEYCODE_ENTER) {
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());
sendCurrentMessage();
return true;
}
@ -199,7 +194,7 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo
boolean isLandscape = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
EditText input = (EditText) findViewById(R.id.input);
input = (EditText) findViewById(R.id.input);
input.setOnKeyListener(inputKeyListener);
pager = (ViewPager) findViewById(R.id.pager);
@ -220,9 +215,6 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo
server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
}
input.setTextSize(settings.getFontSize());
input.setTypeface(Typeface.MONOSPACE);
// Optimization : cache field lookups
Collection<Conversation> mConversations = server.getConversations();
@ -253,6 +245,23 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo
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
scrollback = new Scrollback();
}
@ -602,7 +611,7 @@ public class ConversationActivity extends ActionBarActivity implements ServiceCo
}
binder.getService().getConnection(server.getId()).setAutojoinChannels(
server.getCurrentChannelNames()
);
);
server.setStatus(Status.CONNECTING);
binder.connect(server);
reconnectDialogActive = false;
@ -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
*

View File

@ -331,9 +331,6 @@ public class Message
canvas.setLinkTextColor(COLOR_BLUE);
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) {
setupViewForHoneycombAndLater(canvas);

View File

@ -47,9 +47,8 @@ public class MessageListView extends ListView
setDivider(null);
setCacheColorHint(0x000000);
setCacheColorHint(0xFFFFFFFF);
setVerticalFadingEdgeEnabled(false);
setBackgroundResource(R.drawable.conversation_background);
setScrollBarStyle(SCROLLBARS_OUTSIDE_INSET);
// 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

View File

@ -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>

View File

@ -38,27 +38,54 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
android:layout_height="wrap_content"
android:background="@color/primary" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
<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_margin="0px"
android:layout_width="match_parent"
android:layout_weight="1"
android:padding="0dp"
android:unselectedAlpha="100" />
android:layout_margin="4dp"
card_view:cardBackgroundColor="@color/cardview_background">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:padding="0dp" />
</android.support.v7.widget.CardView>
<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
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
android:gravity="center_vertical">
<EditText
android:id="@+id/input"
android:layout_width="0dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
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
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:visibility="gone" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<include layout="@layout/item_drawer" />