Skip to content

Commit cdc7436

Browse files
pallav12atm1504
authored andcommitted
Enhanced UI of searchView and added animation (#2432)
1 parent 8bc3e0d commit cdc7436

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

app/src/main/java/org/fossasia/susi/ai/chat/ChatActivity.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import android.speech.tts.UtteranceProgressListener
2424
import android.support.design.widget.Snackbar
2525
import android.support.v4.app.ActivityCompat
2626
import android.support.v4.view.GestureDetectorCompat
27+
import android.support.v4.view.ViewCompat
2728
import android.support.v7.app.AppCompatActivity
2829
import android.support.v7.widget.LinearLayoutManager
2930
import android.support.v7.widget.RecyclerView
@@ -35,6 +36,7 @@ import android.view.KeyEvent
3536
import android.view.MotionEvent
3637
import android.view.View
3738
import android.view.WindowManager
39+
import android.view.animation.OvershootInterpolator
3840
import android.view.inputmethod.EditorInfo
3941
import android.view.inputmethod.InputMethodManager
4042
import android.widget.Toast
@@ -163,10 +165,23 @@ class ChatActivity : AppCompatActivity(), IChatView {
163165
}
164166

165167
fun openChatSearch(view: View) {
168+
val interpolator = OvershootInterpolator()
166169
if (isSearching == false || chatSearchInput.getVisibility() == View.VISIBLE) {
167-
chatSearchInput.setVisibility(View.INVISIBLE)
170+
ViewCompat.animate(view)
171+
.rotation(0f)
172+
.withLayer()
173+
.setDuration(300)
174+
.setInterpolator(interpolator)
175+
.start()
176+
chatSearchInput.setVisibility(View.GONE)
168177
hideSoftKeyboard(this, window.decorView)
169178
} else {
179+
ViewCompat.animate(view)
180+
.rotation(90f)
181+
.withLayer()
182+
.setDuration(300)
183+
.setInterpolator(interpolator)
184+
.start()
170185
chatSearchInput.setVisibility(View.VISIBLE)
171186
handleSearch()
172187
}

app/src/main/res/layout/activity_chat.xml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,42 @@
44
android:id="@+id/coordinator_layout"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7-
android:background="@color/default_bg">
7+
android:background="@color/md_white_1000">
88

99
<RelativeLayout
1010
android:layout_width="match_parent"
1111
android:layout_height="match_parent"
1212
app:layout_behavior="org.fossasia.susi.ai.helper.SnackbarBehavior"
1313
tools:context=".chat.ChatActivity">
1414

15-
<android.support.v7.widget.RecyclerView
16-
android:id="@+id/rv_chat_feed"
17-
android:layout_width="match_parent"
18-
android:layout_height="match_parent"
19-
android:layout_above="@+id/sendMessageLayout"
20-
android:layout_alignParentTop="true"
21-
android:scrollbars="vertical" />
22-
2315
<EditText
24-
android:layout_width="match_parent"
2516
android:id="@+id/chatSearchInput"
26-
android:textColor="@color/md_white_1000"
27-
android:layout_height="40dp"
28-
android:layout_marginRight="@dimen/margin_extremely_large"
29-
android:hint="Search Chat Messages"
17+
android:layout_width="match_parent"
18+
android:layout_height="@dimen/height_large"
3019
android:layout_marginLeft="@dimen/margin_medium"
3120
android:layout_marginTop="@dimen/margin_medium"
32-
android:visibility="invisible"
21+
android:layout_marginRight="@dimen/margin_extremely_large"
22+
android:hint="Search Chat Messages"
23+
android:imeOptions="actionSearch"
3324
android:paddingLeft="@dimen/padding_moderate"
34-
android:background="@color/colorPrimaryDark"
35-
android:textSize="@dimen/text_size_normal"
3625
android:singleLine="true"
37-
android:imeOptions="actionSearch"/>
26+
android:textSize="@dimen/text_size_normal"
27+
android:visibility="gone" />
28+
29+
<FrameLayout
30+
android:layout_width="match_parent"
31+
android:layout_height="1dp"
32+
android:layout_above="@id/rv_chat_feed"
33+
android:background="@color/md_grey_300" />
34+
35+
<android.support.v7.widget.RecyclerView
36+
android:id="@+id/rv_chat_feed"
37+
android:layout_width="match_parent"
38+
android:layout_height="match_parent"
39+
android:layout_above="@+id/sendMessageLayout"
40+
android:layout_below="@+id/chatSearchInput"
41+
android:background="@color/default_bg"
42+
android:scrollbars="vertical" />
3843

3944
<android.support.design.widget.FloatingActionButton
4045
android:id="@+id/searchChat"

0 commit comments

Comments
 (0)