Emoji Support for all user input

All text that can be generated by users will show emoji from the
shipped sprites.

For all messages and posts, the custom emoji keyboard is now available.

This also disables menu actions rather than hiding them and thus
closes #677

Included is a fix for a regression that was not showing the keyboard
automatically in forums and thus
closes #676
This commit is contained in:
Torsten Grote
2016-09-26 17:58:26 -03:00
parent a422c626b3
commit f8e0441de8
42 changed files with 587 additions and 435 deletions

View File

@@ -93,7 +93,7 @@
android:label="@string/app_name"
android:theme="@style/BriarThemeNoActionBar.Default"
android:parentActivityName=".android.NavDrawerActivity"
android:windowSoftInputMode="stateHidden">
android:windowSoftInputMode="stateHidden|adjustResize">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".android.NavDrawerActivity"
@@ -145,7 +145,8 @@
<activity
android:name=".android.sharing.ShareForumActivity"
android:label="@string/activity_share_toolbar_header"
android:parentActivityName=".android.forum.ForumActivity">
android:parentActivityName=".android.forum.ForumActivity"
android:windowSoftInputMode="adjustResize|stateHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".android.forum.ForumActivity"
@@ -155,7 +156,8 @@
<activity
android:name=".android.sharing.ShareBlogActivity"
android:label="@string/activity_share_toolbar_header"
android:parentActivityName=".android.blogs.BlogActivity">
android:parentActivityName=".android.blogs.BlogActivity"
android:windowSoftInputMode="adjustResize|stateHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".android.blogs.BlogActivity"

View File

@@ -24,7 +24,7 @@
<include layout="@layout/contact_avatar_status"/>
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/contactName"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse"
android:layout_width="wrap_content"
@@ -50,6 +50,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/button_bar_background"
android:elevation="@dimen/margin_tiny"/>
android:elevation="@dimen/margin_tiny"
app:hint="@string/message_hint"/>
</LinearLayout>

View File

@@ -18,6 +18,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/button_bar_background"
android:elevation="@dimen/margin_tiny"/>
android:elevation="@dimen/margin_tiny"
app:hint="@string/forum_new_message_hint"/>
</LinearLayout>

View File

@@ -1,56 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/margin_small"
tools:context=".android.blogs.WriteBlogPostActivity">
<android.support.design.widget.TextInputLayout
android:id="@+id/titleLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:counterEnabled="true"
app:counterOverflowTextAppearance="@style/BriarTextCounter.Overflow">
<android.support.design.widget.TextInputEditText
android:id="@+id/titleInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/blogs_write_blog_post_title_hint"
android:inputType="textCapWords|textCapSentences|textAutoCorrect"/>
</android.support.design.widget.TextInputLayout>
<EditText
<org.briarproject.android.view.LargeTextInputView
android:id="@+id/bodyInput"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="bottom"
android:hint="@string/blogs_write_blog_post_body_hint"
android:inputType="textMultiLine|textLongMessage|textCapSentences|textAutoCorrect">
<requestFocus/>
</EditText>
<Button
android:id="@+id/publishButton"
style="@style/BriarButton"
android:enabled="false"
android:text="@string/blogs_publish_blog_post"/>
app:buttonText="@string/blogs_publish_blog_post"
app:hint="@string/blogs_write_blog_post_body_hint"
app:fillHeight="true"/>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"/>
android:visibility="invisible"/>
</LinearLayout>
</FrameLayout>

View File

@@ -26,7 +26,7 @@
android:visibility="invisible"
tools:ignore="ContentDescription"/>
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/authorName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -1,46 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@+id/scrollView"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/window_background">
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/window_background">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/postLayout"
layout="@layout/list_item_blog_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_small"/>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
</ScrollView>
<org.briarproject.android.view.LargeTextInputView
android:id="@+id/inputText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/margin_small">
android:gravity="bottom"
app:buttonText="@string/blogs_reblog_button"
app:maxLines="5"
app:hint="@string/blogs_reblog_comment_hint"/>
<include
android:id="@+id/postLayout"
layout="@layout/list_item_blog_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<EditText
android:id="@+id/inputText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/postLayout"
android:layout_margin="@dimen/listitem_vertical_margin"
android:gravity="bottom"
android:hint="@string/blogs_reblog_comment_hint"
android:inputType="textShortMessage|textMultiLine|textCapSentences|textAutoCorrect"/>
<Button
android:id="@+id/publishButton"
style="@style/BriarButton"
android:layout_below="@+id/inputText"
android:enabled="false"
android:text="@string/blogs_reblog_button"/>
</RelativeLayout>
</ScrollView>
</LinearLayout>

View File

@@ -1,41 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
android:orientation="vertical">
<LinearLayout
<TextView
android:id="@+id/introductionText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/margin_activity_horizontal"
android:orientation="vertical">
android:text="@string/forum_share_message"
android:textColor="@color/briar_text_primary"
android:textSize="@dimen/text_size_medium"/>
<TextView
android:id="@+id/introductionText"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_medium"
android:layout_weight="1"
android:gravity="top"
android:textSize="@dimen/text_size_medium"
android:textColor="@color/briar_text_primary"
android:text="@string/forum_share_message"/>
<org.briarproject.android.view.LargeTextInputView
android:id="@+id/invitationMessageView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="bottom"
app:buttonText="@string/forum_share_button"
app:fillHeight="true"
app:hint="@string/introduction_message_hint"/>
<EditText
android:id="@+id/invitationMessageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_medium"
android:gravity="bottom"
android:hint="@string/introduction_message_hint"
android:inputType="text|textMultiLine|textCapSentences"/>
<Button
android:id="@+id/shareForumButton"
style="@style/BriarButton"
android:text="@string/forum_share_button"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>

View File

@@ -1,128 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
android:orientation="vertical">
<LinearLayout
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/margin_activity_horizontal">
android:layout_height="0dp"
android:layout_weight="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/introductionIcon"
android:gravity="top|center_horizontal"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/avatarContact1"
style="@style/BriarAvatar"
android:layout_width="@dimen/listitem_picture_size"
android:layout_height="@dimen/listitem_picture_size"
android:layout_marginEnd="@dimen/listitem_horizontal_margin"
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
android:layout_marginRight="@dimen/listitem_horizontal_margin"
android:layout_marginStart="@dimen/listitem_horizontal_margin"
tools:src="@drawable/ic_launcher"/>
<TextView
android:id="@+id/nameContact1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small"
android:gravity="center"
android:textColor="@color/briar_text_primary"
android:textSize="@dimen/text_size_tiny"
tools:text="Contact 1"/>
</LinearLayout>
<ImageView
android:id="@+id/introductionIcon"
android:layout_width="@dimen/listitem_picture_size"
android:layout_height="@dimen/listitem_picture_size"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_contact_introduction"
tools:ignore="ContentDescription"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/introductionIcon"
android:layout_toRightOf="@+id/introductionIcon"
android:gravity="top|center_horizontal"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/avatarContact2"
style="@style/BriarAvatar"
android:layout_width="@dimen/listitem_picture_size"
android:layout_height="@dimen/listitem_picture_size"
android:layout_marginEnd="@dimen/listitem_horizontal_margin"
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
android:layout_marginRight="@dimen/listitem_horizontal_margin"
android:layout_marginStart="@dimen/listitem_horizontal_margin"
android:transitionName="avatar"
tools:src="@drawable/ic_launcher"/>
<TextView
android:id="@+id/nameContact2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small"
android:gravity="center"
android:textColor="@color/briar_text_primary"
android:textSize="@dimen/text_size_tiny"
tools:text="Contact 2"/>
</LinearLayout>
</RelativeLayout>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:visibility="gone"/>
<TextView
android:id="@+id/introductionText"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_medium"
android:layout_weight="1"
android:gravity="top"
android:textColor="@color/briar_text_secondary"
android:textSize="@dimen/text_size_medium"
tools:text="@string/introduction_message_text"/>
<EditText
android:id="@+id/introductionMessageView"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_medium"
android:gravity="bottom"
android:hint="@string/introduction_message_hint"
android:inputType="text|textMultiLine|textCapSentences"
android:textColor="@color/briar_text_primary"
android:textColorHint="@color/briar_text_tertiary"/>
android:layout_margin="@dimen/margin_activity_horizontal"
android:orientation="vertical">
<Button
android:id="@+id/makeIntroductionButton"
style="@style/BriarButton"
android:text="@string/introduction_button"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/introductionIcon"
android:gravity="top|center_horizontal"
android:orientation="vertical">
</android.support.v4.widget.NestedScrollView>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/avatarContact1"
style="@style/BriarAvatar"
android:layout_width="@dimen/listitem_picture_size"
android:layout_height="@dimen/listitem_picture_size"
android:layout_marginEnd="@dimen/listitem_horizontal_margin"
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
android:layout_marginRight="@dimen/listitem_horizontal_margin"
android:layout_marginStart="@dimen/listitem_horizontal_margin"
tools:src="@drawable/ic_launcher"/>
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/nameContact1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small"
android:gravity="center"
android:textColor="@color/briar_text_primary"
android:textSize="@dimen/text_size_tiny"
tools:text="Contact 1"/>
</LinearLayout>
<ImageView
android:id="@+id/introductionIcon"
android:layout_width="@dimen/listitem_picture_size"
android:layout_height="@dimen/listitem_picture_size"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_contact_introduction"
tools:ignore="ContentDescription"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/introductionIcon"
android:layout_toRightOf="@+id/introductionIcon"
android:gravity="top|center_horizontal"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/avatarContact2"
style="@style/BriarAvatar"
android:layout_width="@dimen/listitem_picture_size"
android:layout_height="@dimen/listitem_picture_size"
android:layout_marginEnd="@dimen/listitem_horizontal_margin"
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
android:layout_marginRight="@dimen/listitem_horizontal_margin"
android:layout_marginStart="@dimen/listitem_horizontal_margin"
android:transitionName="avatar"
tools:src="@drawable/ic_launcher"/>
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/nameContact2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small"
android:gravity="center"
android:textColor="@color/briar_text_primary"
android:textSize="@dimen/text_size_tiny"
tools:text="Contact 2"/>
</LinearLayout>
</RelativeLayout>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:visibility="gone"/>
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/introductionText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_activity_horizontal"
android:textColor="@color/briar_text_secondary"
android:textSize="@dimen/text_size_medium"
tools:text="@string/introduction_message_text"/>
</LinearLayout>
</ScrollView>
<org.briarproject.android.view.LargeTextInputView
android:id="@+id/introductionMessageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:buttonText="@string/introduction_button"
app:hint="@string/introduction_message_hint"
app:maxLines="5"/>
</LinearLayout>

View File

@@ -18,7 +18,7 @@
android:layout_marginRight="@dimen/listitem_horizontal_margin"
android:layout_marginTop="@dimen/margin_medium"/>
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/nameView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -20,7 +20,7 @@
android:padding="@dimen/listitem_vertical_margin"
app:persona="commenter"/>
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/bodyView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -50,7 +50,7 @@
android:padding="@dimen/margin_small"
android:src="@drawable/ic_repeat"/>
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/bodyView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -59,7 +59,7 @@
android:layout_toRightOf="@+id/avatarFrameView"
android:orientation="vertical">
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/nameView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -17,7 +17,7 @@
android:layout_marginStart="@dimen/listitem_horizontal_margin"
tools:src="@drawable/ic_launcher"/>
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/nameView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -17,7 +17,7 @@
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/listitem_horizontal_margin"/>
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/forumNameView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -63,7 +63,6 @@
android:visibility="gone"
/>
</RelativeLayout>
<RelativeLayout

View File

@@ -26,7 +26,7 @@
android:layout_marginRight="@dimen/message_bubble_margin_non_tail"
android:background="@drawable/notice_in_bottom">
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/introductionText"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@@ -18,7 +18,7 @@
android:layout_marginRight="@dimen/listitem_horizontal_margin"
/>
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/forumNameView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -31,7 +31,7 @@
android:textSize="@dimen/text_size_medium"
tools:text="This is a name of a forum that is available"/>
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/sharedByView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -26,7 +26,7 @@
android:layout_marginRight="@dimen/message_bubble_margin_tail"
android:background="@drawable/notice_out_bottom">
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/introductionText"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@@ -9,7 +9,7 @@
android:layout_marginLeft="@dimen/message_bubble_margin_tail"
android:layout_marginRight="@dimen/message_bubble_margin_non_tail">
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/noticeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -14,7 +14,7 @@
android:layout_marginLeft="@dimen/message_bubble_margin_non_tail"
android:layout_marginRight="@dimen/message_bubble_margin_tail">
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/noticeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -9,7 +9,7 @@
android:layout_marginTop="@dimen/listitem_horizontal_margin"
android:background="?attr/selectableItemBackground">
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/titleView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -41,7 +41,7 @@
android:textColor="@color/briar_text_secondary"
android:textSize="@dimen/text_size_small"/>
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/authorView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -100,7 +100,7 @@
android:textSize="@dimen/text_size_small"
tools:text="5 min. ago"/>
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/descriptionView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -34,7 +34,7 @@
android:layout_toRightOf="@+id/avatarView"
android:orientation="vertical">
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/nameView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -27,7 +27,7 @@
android:layout_marginRight="@dimen/message_bubble_margin_non_tail"
android:background="@drawable/notice_in_bottom">
<TextView
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/introductionText"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@@ -10,41 +10,43 @@
style="@style/Divider.Horizontal"
android:layout_alignParentTop="true"/>
<org.thoughtcrime.securesms.components.emoji.EmojiToggle
android:id="@+id/emoji_toggle"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_above="@+id/emoji_drawer"
android:layout_alignBottom="@+id/input_text"
android:layout_alignParentLeft="true"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/margin_small"
android:scaleType="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/input_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/btn_send"
android:layout_toRightOf="@+id/emoji_toggle"
android:inputType="textMultiLine|textCapSentences"
android:maxLines="5"
android:minHeight="42dp"/>
<org.thoughtcrime.securesms.components.emoji.EmojiToggle
android:id="@+id/emoji_toggle"
android:layout_width="@dimen/text_input_height"
android:layout_height="@dimen/text_input_height"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/margin_small"
android:scaleType="center"/>
<ImageButton
android:id="@+id/btn_send"
android:layout_width="wrap_content"
android:layout_height="42dp"
android:layout_above="@+id/emoji_drawer"
android:layout_alignBottom="@+id/input_text"
android:layout_alignParentRight="true"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:contentDescription="@string/send"
android:enabled="false"
android:padding="@dimen/margin_small"
android:src="@drawable/social_send_now_white"
android:tint="@color/briar_primary"/>
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/input_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:inputType="textMultiLine|textCapSentences"
android:maxLines="5"
android:minHeight="@dimen/text_input_height"
android:textColor="@color/briar_text_primary"
android:textColorHint="@color/briar_text_tertiary"/>
<ImageButton
android:id="@+id/btn_send"
android:layout_width="@dimen/text_input_height"
android:layout_height="@dimen/text_input_height"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:contentDescription="@string/send"
android:enabled="false"
android:padding="@dimen/margin_small"
android:src="@drawable/social_send_now_white"
android:tint="@color/briar_primary"/>
</LinearLayout>
<org.thoughtcrime.securesms.components.emoji.EmojiDrawer
android:id="@+id/emoji_drawer"

View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:showIn="@layout/fragment_reblog">
<LinearLayout
android:id="@+id/input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/margin_medium"
android:layout_marginLeft="@dimen/margin_medium"
android:layout_marginRight="@dimen/margin_medium"
android:layout_marginStart="@dimen/margin_medium"
android:layout_marginTop="@dimen/margin_medium"
android:background="@android:color/white"
android:elevation="@dimen/cardview_default_elevation"
android:minHeight="@dimen/text_input_height"
android:orientation="horizontal">
<org.thoughtcrime.securesms.components.emoji.EmojiToggle
android:id="@+id/emoji_toggle"
android:layout_width="@dimen/text_input_height"
android:layout_height="@dimen/text_input_height"
android:layout_gravity="bottom"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/margin_small"
android:scaleType="center"/>
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
android:id="@+id/input_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:gravity="bottom"
android:inputType="textMultiLine|textLongMessage|textCapSentences|textAutoCorrect"
android:minHeight="@dimen/text_input_height"
android:paddingBottom="10dp"
android:paddingEnd="@dimen/margin_small"
android:paddingRight="@dimen/margin_small"
android:paddingTop="@dimen/margin_small"
android:textColor="@color/briar_text_primary"
android:textColorHint="@color/briar_text_tertiary"
tools:ignore="RtlSymmetry"/>
</LinearLayout>
<Button
android:id="@+id/btn_send"
style="@style/BriarButton"
android:layout_marginEnd="@dimen/margin_small"
android:layout_marginLeft="@dimen/margin_small"
android:layout_marginRight="@dimen/margin_small"
android:layout_marginStart="@dimen/margin_small"/>
<org.thoughtcrime.securesms.components.emoji.EmojiDrawer
android:id="@+id/emoji_drawer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
</merge>

View File

@@ -27,8 +27,7 @@
android:id="@+id/action_blog_delete"
android:icon="@drawable/action_delete_white"
android:title="@string/blogs_remove_blog"
android:visible="false"
app:showAsAction="never"
tools:visible="true"/>
android:enabled="false"
app:showAsAction="never"/>
</menu>

View File

@@ -1,16 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_introduction"
android:icon="@drawable/introduction_white"
android:title="@string/introduction_button"
android:visible="false"
app:showAsAction="never"
tools:visible="true"/>
android:enabled="false"
app:showAsAction="never"/>
<item
android:id="@+id/action_social_remove_person"

View File

@@ -14,4 +14,14 @@
</attr>
</declare-styleable>
<declare-styleable name="TextInputView">
<attr name="hint" format="string"/>
</declare-styleable>
<declare-styleable name="LargeTextInputView">
<attr name="buttonText" format="string"/>
<attr name="maxLines" format="integer"/>
<attr name="fillHeight" format="boolean"/>
</declare-styleable>
</resources>

View File

@@ -47,6 +47,7 @@
<dimen name="blogs_avatar_comment_size">20dp</dimen>
<!-- Emoji -->
<dimen name="text_input_height">42dp</dimen>
<dimen name="conversation_item_body_text_size">16sp</dimen>
<dimen name="emoji_drawer_size">32sp</dimen>
<dimen name="emoji_drawer_indicator_height">2dp</dimen>

View File

@@ -79,6 +79,7 @@
<string name="no_contacts">It seems that you are new here and have no contacts yet.\n\nTap the + icon at the top and follow the instructions to add some friends to your list.\n\nPlease remember: You can only add new contacts face-to-face to prevent anyone from impersonating you or reading your messages in the future.</string>
<string name="date_no_private_messages">No messages.</string>
<string name="no_private_messages">This is the conversation view.\n\nThere seems to be a lack of conversation.\n\nJust tap the input field at the bottom to start a conversation.</string>
<string name="message_hint">Type message</string>
<string name="delete_contact">Delete contact</string>
<string name="dialog_title_delete_contact">Confirm Contact Deletion</string>
<string name="dialog_message_delete_contact">Are you sure that you want to remove this contact and all messages exchanged with this contact?</string>

View File

@@ -144,7 +144,7 @@ public class BlogFragment extends BaseFragment implements
writeButton = menu.findItem(R.id.action_write_blog_post);
if (isMyBlog) writeButton.setVisible(true);
deleteButton = menu.findItem(R.id.action_blog_delete);
if (canDeleteBlog) deleteButton.setVisible(true);
if (canDeleteBlog) deleteButton.setEnabled(true);
super.onCreateOptionsMenu(menu, inflater);
}
@@ -196,7 +196,7 @@ public class BlogFragment extends BaseFragment implements
displaySnackbar(R.string.blogs_blog_post_created, true);
loadBlogPosts(true);
} else if (request == REQUEST_SHARE && result == RESULT_OK) {
displaySnackbar(R.string.blogs_sharing_snackbar, true);
displaySnackbar(R.string.blogs_sharing_snackbar, false);
}
}
@@ -261,7 +261,7 @@ public class BlogFragment extends BaseFragment implements
if (blog.isOurs())
showWriteButton();
if (blog.canBeRemoved())
showDeleteButton();
enableDeleteButton();
}
@Override
@@ -287,10 +287,10 @@ public class BlogFragment extends BaseFragment implements
writeButton.setVisible(true);
}
private void showDeleteButton() {
private void enableDeleteButton() {
canDeleteBlog = true;
if (deleteButton != null)
deleteButton.setVisible(true);
deleteButton.setEnabled(true);
}
private void displaySnackbar(int stringId, boolean scroll) {

View File

@@ -5,10 +5,7 @@ import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.ScrollView;
@@ -16,6 +13,8 @@ import org.briarproject.R;
import org.briarproject.android.ActivityComponent;
import org.briarproject.android.controller.handler.UiResultExceptionHandler;
import org.briarproject.android.fragment.BaseFragment;
import org.briarproject.android.view.TextInputView;
import org.briarproject.android.view.TextInputView.TextInputListener;
import org.briarproject.api.db.DbException;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId;
@@ -29,7 +28,7 @@ import static android.view.View.VISIBLE;
import static org.briarproject.android.BriarActivity.GROUP_ID;
import static org.briarproject.android.blogs.BasePostPagerFragment.POST_ID;
public class ReblogFragment extends BaseFragment {
public class ReblogFragment extends BaseFragment implements TextInputListener {
public static final String TAG = ReblogFragment.class.getName();
@@ -88,6 +87,7 @@ public class ReblogFragment extends BaseFragment {
false);
ui = new ViewHolder(v);
ui.post.setTransitionName(postId);
ui.input.setSendButtonEnabled(false);
showProgressBar();
return v;
@@ -129,14 +129,8 @@ public class ReblogFragment extends BaseFragment {
ui.post.bindItem(item);
ui.post.hideReblogButton();
ui.publish.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
send();
finish();
}
});
ui.publish.setEnabled(true);
ui.input.setListener(this);
ui.input.setSendButtonEnabled(true);
ui.scrollView.post(new Runnable() {
@Override
public void run() {
@@ -145,7 +139,8 @@ public class ReblogFragment extends BaseFragment {
});
}
private void send() {
@Override
public void onSendClick(String text) {
String comment = getComment();
feedController.repeatPost(item, comment,
new UiResultExceptionHandler<Void, DbException>(listener) {
@@ -159,6 +154,7 @@ public class ReblogFragment extends BaseFragment {
// do nothing, this fragment is gone already
}
});
finish();
}
@Nullable
@@ -170,13 +166,11 @@ public class ReblogFragment extends BaseFragment {
private void showProgressBar() {
ui.progressBar.setVisibility(VISIBLE);
ui.input.setVisibility(GONE);
ui.publish.setVisibility(GONE);
}
private void hideProgressBar() {
ui.progressBar.setVisibility(INVISIBLE);
ui.input.setVisibility(VISIBLE);
ui.publish.setVisibility(VISIBLE);
}
private static class ViewHolder {
@@ -184,15 +178,13 @@ public class ReblogFragment extends BaseFragment {
private final ScrollView scrollView;
private final ProgressBar progressBar;
private final BlogPostViewHolder post;
private final EditText input;
private final Button publish;
private final TextInputView input;
private ViewHolder(View v) {
scrollView = (ScrollView) v.findViewById(R.id.scrollView);
progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
post = new BlogPostViewHolder(v.findViewById(R.id.postLayout));
input = (EditText) v.findViewById(R.id.inputText);
publish = (Button) v.findViewById(R.id.publishButton);
input = (TextInputView) v.findViewById(R.id.inputText);
}
}
}

View File

@@ -6,9 +6,6 @@ import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
@@ -17,6 +14,8 @@ import org.briarproject.R;
import org.briarproject.android.ActivityComponent;
import org.briarproject.android.BriarActivity;
import org.briarproject.android.api.AndroidNotificationManager;
import org.briarproject.android.view.TextInputView;
import org.briarproject.android.view.TextInputView.TextInputListener;
import org.briarproject.api.FormatException;
import org.briarproject.api.blogs.BlogManager;
import org.briarproject.api.blogs.BlogPost;
@@ -39,7 +38,7 @@ import static java.util.logging.Level.WARNING;
import static org.briarproject.api.blogs.BlogConstants.MAX_BLOG_POST_BODY_LENGTH;
public class WriteBlogPostActivity extends BriarActivity
implements OnEditorActionListener {
implements OnEditorActionListener, TextInputListener {
private static final Logger LOG =
Logger.getLogger(WriteBlogPostActivity.class.getName());
@@ -47,8 +46,7 @@ public class WriteBlogPostActivity extends BriarActivity
@Inject
protected AndroidNotificationManager notificationManager;
private EditText bodyInput;
private Button publishButton;
private TextInputView input;
private ProgressBar progressBar;
// Fields that are accessed from background threads must be volatile
@@ -60,6 +58,7 @@ public class WriteBlogPostActivity extends BriarActivity
@Inject
volatile BlogManager blogManager;
@SuppressWarnings("ConstantConditions")
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
@@ -71,8 +70,9 @@ public class WriteBlogPostActivity extends BriarActivity
setContentView(R.layout.activity_write_blog_post);
bodyInput = (EditText) findViewById(R.id.bodyInput);
bodyInput.addTextChangedListener(new TextWatcher() {
input = (TextInputView) findViewById(R.id.bodyInput);
input.setSendButtonEnabled(false);
input.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
@@ -88,14 +88,7 @@ public class WriteBlogPostActivity extends BriarActivity
enableOrDisablePublishButton();
}
});
publishButton = (Button) findViewById(R.id.publishButton);
publishButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
publish();
}
});
input.setListener(this);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
}
@@ -130,25 +123,23 @@ public class WriteBlogPostActivity extends BriarActivity
@Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
bodyInput.requestFocus();
input.requestFocus();
return true;
}
private void enableOrDisablePublishButton() {
int bodyLength =
StringUtils.toUtf8(bodyInput.getText().toString()).length;
StringUtils.toUtf8(input.getText().toString()).length;
if (bodyLength > 0 && bodyLength <= MAX_BLOG_POST_BODY_LENGTH)
publishButton.setEnabled(true);
input.setSendButtonEnabled(true);
else
publishButton.setEnabled(false);
input.setSendButtonEnabled(false);
}
private void publish() {
// body
String body = bodyInput.getText().toString();
@Override
public void onSendClick(String body) {
// hide publish button, show progress bar
publishButton.setVisibility(GONE);
input.setVisibility(GONE);
progressBar.setVisibility(VISIBLE);
storePost(body);
@@ -192,10 +183,9 @@ public class WriteBlogPostActivity extends BriarActivity
public void run() {
// hide progress bar, show publish button
progressBar.setVisibility(GONE);
publishButton.setVisibility(VISIBLE);
input.setVisibility(VISIBLE);
// TODO show error
}
});
}
}

View File

@@ -235,7 +235,7 @@ public class ConversationActivity extends BriarActivity
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.conversation_actions, menu);
showIntroductionActionIfAvailable(
enableIntroductionActionIfAvailable(
menu.findItem(R.id.action_introduction));
return super.onCreateOptionsMenu(menu);
@@ -269,10 +269,6 @@ public class ConversationActivity extends BriarActivity
@Override
public void onBackPressed() {
if (textInputView.isEmojiDrawerOpen()) {
textInputView.hideEmojiDrawer();
return;
}
// FIXME disabled exit transition, because it doesn't work for some reason #318
//supportFinishAfterTransition();
finish();
@@ -755,13 +751,13 @@ public class ConversationActivity extends BriarActivity
});
}
private void showIntroductionActionIfAvailable(final MenuItem item) {
private void enableIntroductionActionIfAvailable(final MenuItem item) {
runOnDbThread(new Runnable() {
@Override
public void run() {
try {
if (contactManager.getActiveContacts().size() > 1) {
showIntroductionAction(item);
enableIntroductionAction(item);
Settings settings =
settingsManager.getSettings(SETTINGS_NAMESPACE);
if (settings.getBoolean(SHOW_ONBOARDING_INTRODUCTION,
@@ -777,11 +773,11 @@ public class ConversationActivity extends BriarActivity
});
}
private void showIntroductionAction(final MenuItem item) {
private void enableIntroductionAction(final MenuItem item) {
runOnUiThread(new Runnable() {
@Override
public void run() {
item.setVisible(true);
item.setEnabled(true);
}
});
}

View File

@@ -174,9 +174,7 @@ public class ForumActivity extends BriarActivity implements
@Override
public void onBackPressed() {
if (textInput.isEmojiDrawerOpen()) {
textInput.hideEmojiDrawer();
} else if (textInput.getVisibility() == VISIBLE) {
if (textInput.getVisibility() == VISIBLE) {
textInput.setVisibility(GONE);
forumAdapter.setReplyEntry(null);
} else {
@@ -193,9 +191,9 @@ public class ForumActivity extends BriarActivity implements
textInput.setText("");
}
textInput.requestFocus();
textInput.showSoftKeyboard();
textInput.setHint(replyEntry == null ? R.string.forum_new_message_hint :
R.string.forum_message_reply_hint);
showSoftKeyboardForced(textInput);
forumAdapter.setReplyEntry(replyEntry);
}
@@ -273,7 +271,7 @@ public class ForumActivity extends BriarActivity implements
.createPost(StringUtils.toUtf8(text), replyEntry.getId(),
resultHandler);
}
hideSoftKeyboard(textInput);
textInput.hideSoftKeyboard();
textInput.setVisibility(GONE);
forumAdapter.setReplyEntry(null);
}

View File

@@ -6,8 +6,6 @@ import android.support.v7.app.ActionBar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -15,6 +13,7 @@ import android.widget.Toast;
import org.briarproject.R;
import org.briarproject.android.ActivityComponent;
import org.briarproject.android.fragment.BaseFragment;
import org.briarproject.android.view.TextInputView;
import org.briarproject.api.FormatException;
import org.briarproject.api.contact.Contact;
import org.briarproject.api.contact.ContactId;
@@ -35,7 +34,8 @@ import static android.view.View.VISIBLE;
import static android.widget.Toast.LENGTH_SHORT;
import static java.util.logging.Level.WARNING;
public class IntroductionMessageFragment extends BaseFragment {
public class IntroductionMessageFragment extends BaseFragment
implements TextInputView.TextInputListener {
public final static String TAG = "IntroductionMessageFragment";
@@ -46,6 +46,7 @@ public class IntroductionMessageFragment extends BaseFragment {
private IntroductionActivity introductionActivity;
private ViewHolder ui;
private Contact contact1, contact2;
// Fields that are accessed from background threads must be volatile
@Inject
@@ -96,7 +97,7 @@ public class IntroductionMessageFragment extends BaseFragment {
// show progress bar until contacts have been loaded
ui = new ViewHolder(v);
ui.text.setVisibility(GONE);
ui.button.setEnabled(false);
ui.message.setSendButtonEnabled(false);
return v;
}
@@ -144,6 +145,9 @@ public class IntroductionMessageFragment extends BaseFragment {
introductionActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
contact1 = c1;
contact2 = c2;
// set avatars
ui.avatar1.setImageDrawable(new IdenticonDrawable(
c1.getAuthor().getId().getBytes()));
@@ -160,27 +164,24 @@ public class IntroductionMessageFragment extends BaseFragment {
c1.getAuthor().getName(), c2.getAuthor().getName()));
// set button action
ui.button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onButtonClick(c1, c2);
}
});
ui.message.setListener(IntroductionMessageFragment.this);
// hide progress bar and show views
ui.progressBar.setVisibility(GONE);
ui.text.setVisibility(VISIBLE);
ui.button.setEnabled(true);
ui.message.setSendButtonEnabled(true);
ui.message.showSoftKeyboard();
}
});
}
private void onButtonClick(final Contact c1, final Contact c2) {
@Override
public void onSendClick(String text) {
// disable button to prevent accidental double invitations
ui.button.setEnabled(false);
ui.message.setSendButtonEnabled(false);
String msg = ui.message.getText().toString();
makeIntroduction(c1, c2, msg);
makeIntroduction(contact1, contact2, msg);
// don't wait for the introduction to be made before finishing activity
introductionActivity.hideSoftKeyboard(ui.message);
@@ -223,18 +224,17 @@ public class IntroductionMessageFragment extends BaseFragment {
private final CircleImageView avatar1, avatar2;
private final TextView contactName1, contactName2;
private final TextView text;
private final EditText message;
private final Button button;
private final TextInputView message;
ViewHolder(View v) {
private ViewHolder(View v) {
progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
avatar1 = (CircleImageView) v.findViewById(R.id.avatarContact1);
avatar2 = (CircleImageView) v.findViewById(R.id.avatarContact2);
contactName1 = (TextView) v.findViewById(R.id.nameContact1);
contactName2 = (TextView) v.findViewById(R.id.nameContact2);
text = (TextView) v.findViewById(R.id.introductionText);
message = (EditText) v.findViewById(R.id.introductionMessageView);
button = (Button) v.findViewById(R.id.makeIntroductionButton);
message = (TextInputView) v
.findViewById(R.id.introductionMessageView);
}
}
}

View File

@@ -43,7 +43,7 @@ public class ShareBlogMessageFragment extends ShareMessageFragment {
setTitle(R.string.blogs_sharing_share);
View v = super.onCreateView(inflater, container, savedInstanceState);
ui.button.setText(getString(R.string.blogs_sharing_button));
ui.message.setButtonText(getString(R.string.blogs_sharing_button));
return v;
}

View File

@@ -6,11 +6,11 @@ import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import org.briarproject.R;
import org.briarproject.android.fragment.BaseFragment;
import org.briarproject.android.view.LargeTextInputView;
import org.briarproject.android.view.TextInputView.TextInputListener;
import org.briarproject.api.blogs.BlogSharingManager;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.forum.ForumSharingManager;
@@ -26,7 +26,8 @@ import static org.briarproject.android.sharing.ShareActivity.CONTACTS;
import static org.briarproject.android.sharing.ShareActivity.getContactsFromIds;
import static org.briarproject.api.sharing.SharingConstants.GROUP_ID;
abstract class ShareMessageFragment extends BaseFragment {
abstract class ShareMessageFragment extends BaseFragment
implements TextInputListener {
public final static String TAG = ShareMessageFragment.class.getName();
@@ -81,16 +82,17 @@ abstract class ShareMessageFragment extends BaseFragment {
View v = inflater.inflate(R.layout.fragment_share_message, container,
false);
ui = new ViewHolder(v);
ui.button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onButtonClick();
}
});
ui.message.setListener(this);
return v;
}
@Override
public void onStart() {
super.onStart();
ui.message.showSoftKeyboard();
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
@@ -111,11 +113,11 @@ abstract class ShareMessageFragment extends BaseFragment {
shareActivity.setTitle(res);
}
private void onButtonClick() {
@Override
public void onSendClick(String msg) {
// disable button to prevent accidental double invitations
ui.button.setEnabled(false);
ui.message.setSendButtonEnabled(false);
String msg = ui.message.getText().toString();
share(msg);
// don't wait for the invitation to be made before finishing activity
@@ -139,12 +141,11 @@ abstract class ShareMessageFragment extends BaseFragment {
}
protected static class ViewHolder {
protected final EditText message;
protected final Button button;
protected final LargeTextInputView message;
ViewHolder(View v) {
message = (EditText) v.findViewById(R.id.invitationMessageView);
button = (Button) v.findViewById(R.id.shareForumButton);
private ViewHolder(View v) {
message = (LargeTextInputView) v
.findViewById(R.id.invitationMessageView);
}
}
}

View File

@@ -0,0 +1,77 @@
package org.briarproject.android.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import org.briarproject.R;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
@UiThread
public class LargeTextInputView extends TextInputView {
public LargeTextInputView(Context context) {
this(context, null);
}
public LargeTextInputView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public LargeTextInputView(Context context, @Nullable AttributeSet attrs,
int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void inflateLayout(Context context) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.text_input_view_large, this, true);
}
@Override
protected void setUpViews(Context context, @Nullable AttributeSet attrs) {
super.setUpViews(context, attrs);
// get attributes
TypedArray attributes = context.obtainStyledAttributes(attrs,
R.styleable.LargeTextInputView);
String buttonText =
attributes.getString(R.styleable.LargeTextInputView_buttonText);
int maxLines =
attributes
.getInteger(R.styleable.LargeTextInputView_maxLines, 0);
boolean fillHeight = attributes
.getBoolean(R.styleable.LargeTextInputView_fillHeight,
false);
attributes.recycle();
if (buttonText != null) setButtonText(buttonText);
if (maxLines > 0) ui.editText.setMaxLines(maxLines);
if (fillHeight) {
LinearLayout layout =
(LinearLayout) findViewById(R.id.input_layout);
LayoutParams params = (LayoutParams) layout.getLayoutParams();
params.height = 0;
params.weight = 1;
layout.setLayoutParams(params);
ViewGroup.LayoutParams editParams = ui.editText.getLayoutParams();
editParams.height = MATCH_PARENT;
ui.editText.setLayoutParams(editParams);
}
}
public void setButtonText(String text) {
((Button) ui.sendButton).setText(text);
}
}

View File

@@ -1,18 +1,29 @@
package org.briarproject.android.view;
import android.animation.LayoutTransition;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.os.IBinder;
import android.support.annotation.CallSuper;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.annotation.UiThread;
import android.support.v7.widget.AppCompatImageButton;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import org.briarproject.R;
import org.thoughtcrime.securesms.components.KeyboardAwareRelativeLayout;
import org.thoughtcrime.securesms.components.KeyboardAwareLinearLayout;
import org.thoughtcrime.securesms.components.emoji.EmojiDrawer;
import org.thoughtcrime.securesms.components.emoji.EmojiDrawer.EmojiEventListener;
import org.thoughtcrime.securesms.components.emoji.EmojiEditText;
@@ -21,19 +32,17 @@ import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
import java.util.logging.Logger;
import static android.content.Context.INPUT_METHOD_SERVICE;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
@UiThread
public class TextInputView extends KeyboardAwareRelativeLayout
public class TextInputView extends KeyboardAwareLinearLayout
implements EmojiEventListener {
private static final String TAG = TextInputView.class.getName();
private static final Logger LOG = Logger.getLogger(TAG);
private EmojiEditText editText;
private View sendButton;
private EmojiDrawer emojiDrawer;
private TextInputListener listener;
protected final ViewHolder ui;
protected TextInputListener listener;
public TextInputView(Context context) {
this(context, null);
@@ -46,50 +55,80 @@ public class TextInputView extends KeyboardAwareRelativeLayout
public TextInputView(Context context, @Nullable AttributeSet attrs,
int defStyleAttr) {
super(context, attrs, defStyleAttr);
setOrientation(VERTICAL);
setLayoutTransition(new LayoutTransition());
inflateLayout(context);
ui = new ViewHolder();
setUpViews(context, attrs);
}
protected void inflateLayout(Context context) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.text_input_view, this, true);
}
// find views
EmojiToggle emojiToggle = (EmojiToggle) findViewById(R.id.emoji_toggle);
editText = (EmojiEditText) findViewById(R.id.input_text);
emojiDrawer = (EmojiDrawer) findViewById(R.id.emoji_drawer);
sendButton = findViewById(R.id.btn_send);
@CallSuper
protected void setUpViews(Context context, @Nullable AttributeSet attrs) {
// get attributes
TypedArray attributes = context.obtainStyledAttributes(attrs,
R.styleable.TextInputView);
String hint = attributes.getString(R.styleable.TextInputView_hint);
attributes.recycle();
emojiToggle.attach(emojiDrawer);
emojiToggle.setOnClickListener(new OnClickListener() {
if (hint != null) {
ui.editText.setHint(hint);
}
ui.emojiToggle.attach(ui.emojiDrawer);
ui.emojiToggle.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onEmojiToggleClicked();
}
});
editText.setOnClickListener(new OnClickListener() {
ui.editText.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showSoftKeyboard();
}
});
sendButton.setOnClickListener(new OnClickListener() {
ui.editText.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && isEmojiDrawerOpen()) {
hideEmojiDrawer();
return true;
}
return false;
}
});
ui.sendButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onSendClick(editText.getText().toString());
editText.setText("");
listener.onSendClick(ui.editText.getText().toString());
ui.editText.setText("");
}
}
});
emojiDrawer.setEmojiEventListener(this);
ui.emojiDrawer.setEmojiEventListener(this);
}
@Override
public void onKeyEvent(KeyEvent keyEvent) {
editText.dispatchKeyEvent(keyEvent);
ui.editText.dispatchKeyEvent(keyEvent);
}
@Override
public void onEmojiSelected(String emoji) {
editText.insertEmoji(emoji);
ui.editText.insertEmoji(emoji);
}
@Override
public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
return ui.editText.requestFocus(direction, previouslyFocusedRect);
}
private void onEmojiToggleClicked() {
@@ -101,29 +140,33 @@ public class TextInputView extends KeyboardAwareRelativeLayout
}
public void setText(String text) {
editText.setText(text);
ui.editText.setText(text);
}
public Editable getText() {
return ui.editText.getText();
}
public void setHint(@StringRes int res) {
editText.setHint(res);
ui.editText.setHint(res);
}
public void setSendButtonEnabled(boolean enabled) {
sendButton.setEnabled(enabled);
ui.sendButton.setEnabled(enabled);
}
public void addTextChangedListener(TextWatcher watcher) {
ui.editText.addTextChangedListener(watcher);
}
public void setListener(TextInputListener listener) {
this.listener = listener;
}
public interface TextInputListener {
void onSendClick(String text);
}
public void showSoftKeyboard() {
if (isKeyboardOpen()) return;
if (emojiDrawer.isShowing()) {
if (ui.emojiDrawer.isShowing()) {
postOnKeyboardOpen(new Runnable() {
@Override
public void run() {
@@ -131,18 +174,18 @@ public class TextInputView extends KeyboardAwareRelativeLayout
}
});
}
editText.post(new Runnable() {
ui.editText.post(new Runnable() {
@Override
public void run() {
editText.requestFocus();
ui.editText.requestFocus();
Object o = getContext().getSystemService(INPUT_METHOD_SERVICE);
((InputMethodManager) o).showSoftInput(editText, 0);
((InputMethodManager) o).showSoftInput(ui.editText, 0);
}
});
}
public void hideSoftKeyboard() {
IBinder token = editText.getWindowToken();
IBinder token = ui.editText.getWindowToken();
Object o = getContext().getSystemService(INPUT_METHOD_SERVICE);
((InputMethodManager) o).hideSoftInputFromWindow(token, 0);
}
@@ -151,21 +194,40 @@ public class TextInputView extends KeyboardAwareRelativeLayout
if (isKeyboardOpen()) {
postOnKeyboardClose(new Runnable() {
@Override public void run() {
emojiDrawer.show(getKeyboardHeight());
ui.emojiDrawer.show(getKeyboardHeight());
}
});
hideSoftKeyboard();
} else {
emojiDrawer.show(getKeyboardHeight());
ui.emojiDrawer.show(getKeyboardHeight());
ui.editText.requestFocus();
}
}
public void hideEmojiDrawer() {
emojiDrawer.hide();
ui.emojiDrawer.hide();
}
public boolean isEmojiDrawerOpen() {
return emojiDrawer.isShowing();
return ui.emojiDrawer.isShowing();
}
protected class ViewHolder {
private final EmojiToggle emojiToggle;
protected final EmojiEditText editText;
protected final View sendButton;
protected final EmojiDrawer emojiDrawer;
private ViewHolder() {
emojiToggle = (EmojiToggle) findViewById(R.id.emoji_toggle);
editText = (EmojiEditText) findViewById(R.id.input_text);
emojiDrawer = (EmojiDrawer) findViewById(R.id.emoji_drawer);
sendButton = findViewById(R.id.btn_send);
}
}
public interface TextInputListener {
void onSendClick(String text);
}
}

View File

@@ -11,7 +11,7 @@ import android.support.annotation.UiThread;
import android.util.AttributeSet;
import android.view.View;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.LinearLayout;
import org.briarproject.R;
@@ -31,10 +31,10 @@ import static java.util.logging.Level.WARNING;
* a soft keyboard has been opened and what its height would be.
*/
@UiThread
public class KeyboardAwareRelativeLayout extends RelativeLayout {
public class KeyboardAwareLinearLayout extends LinearLayout {
private static final Logger LOG =
Logger.getLogger(KeyboardAwareRelativeLayout.class.getName());
Logger.getLogger(KeyboardAwareLinearLayout.class.getName());
private final Rect rect = new Rect();
private final Set<OnKeyboardHiddenListener> hiddenListeners =
@@ -51,16 +51,16 @@ public class KeyboardAwareRelativeLayout extends RelativeLayout {
private boolean keyboardOpen = false;
private int rotation = -1;
public KeyboardAwareRelativeLayout(Context context) {
public KeyboardAwareLinearLayout(Context context) {
this(context, null);
}
public KeyboardAwareRelativeLayout(Context context,
public KeyboardAwareLinearLayout(Context context,
@Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public KeyboardAwareRelativeLayout(Context context,
public KeyboardAwareLinearLayout(Context context,
@Nullable AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
final int statusBarRes = getResources()

View File

@@ -41,6 +41,7 @@ public class EmojiTextView extends TextView {
@Override
public void setText(@Nullable CharSequence text, BufferType type) {
source = EmojiProvider.getInstance(getContext()).emojify(text, this);
setTextEllipsized(source);
}