soonmyeong2

검색창 디자인 및 앱 종료 최적화

......@@ -34,7 +34,7 @@ dependencies {
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta05'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
......
......@@ -23,7 +23,7 @@
<activity android:name=".SignInActivity" />
<activity android:name=".SignUpActivity" />
<activity android:name=".MainActivity" />
<activity android:name=".SearchActivity" />
<activity android:name=".SearchActivity" android:windowSoftInputMode="adjustNothing"/>
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
......
......@@ -28,7 +28,6 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
//onboarding start
//onboarding end
setContentView(R.layout.activity_main)
......
package com.example.vip
import android.content.Context
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
//import androidx.appcompat.widget.SearchView
import android.widget.SearchView
import android.widget.Toast
import androidx.core.app.ComponentActivity.ExtraData
import androidx.core.content.ContextCompat.getSystemService
import android.icu.lang.UCharacter.GraphemeClusterBreak.T
import android.view.View
import android.widget.Button
import android.content.Intent
import android.util.Log
import android.view.inputmethod.InputMethodManager
import android.widget.*
import androidx.core.content.ContextCompat
import com.google.firebase.database.*
import com.google.firebase.database.DatabaseReference
......@@ -35,21 +35,43 @@ class SearchActivity : AppCompatActivity() {
setContentView(R.layout.search)
val searchList = ArrayList<SearchItem>()
val no_search : ImageView = findViewById(R.id.no_matching) // 노서치이미지
val searchView: SearchView
searchView = findViewById(R.id.searchForm)
//searchView.onActionViewExpanded(); //new Added line
searchView.setIconifiedByDefault(false)
fun CloseKeyboard()
{
var view = this.currentFocus
if(view != null)
{
val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
}
}
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
// 검색 버튼이 눌러졌을 때 이벤트 처리
val layout : LinearLayout = findViewById(R.id.hashtag_linear)
layout.setVisibility(View.GONE)
CloseKeyboard()
database.orderByChild("Policy").startAt("$query").endAt("$query"+"\uf8ff").addListenerForSingleValueEvent(object : ValueEventListener {
override fun onCancelled(p0: DatabaseError) {
Toast.makeText(this@SearchActivity, "실패부분 : $query", Toast.LENGTH_SHORT).show()
}
override fun onDataChange(dataSnapshot: DataSnapshot) {
if (dataSnapshot.exists() == false){ // 값 없을 때
no_search.setVisibility(View.VISIBLE)
}
else {
no_search.setVisibility(View.GONE)
}
for (memoSnapshot in dataSnapshot.children){
val memo = memoSnapshot.getValue(MemoItem::class.java)
......
......@@ -4,6 +4,7 @@ import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
......@@ -90,6 +91,20 @@ class SignInActivity : AppCompatActivity() {
return true
}
var back_pressed: Long = 0 // 뒤로가기 종료
override fun onBackPressed() {
if (back_pressed + 2000 > System.currentTimeMillis()) {
finishAffinity()
System.runFinalization()
System.exit(0)
}
//super.onBackPressed()
else
Toast.makeText(getBaseContext(), "\'뒤로\' 버튼을 한번 더 누르시면 종료됩니다.", Toast.LENGTH_SHORT).show()
back_pressed = System.currentTimeMillis()
}
// 4.툴바 메뉴 버튼이 클릭 됐을 때 콜백
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
// 클릭된 메뉴 아이템의 아이디 마다 when 구절로 클릭시 동작을 설정한다.
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@android:color/transparent" />
<stroke
android:width="3dp"
android:color="#C029ABE2" />
<corners android:radius="30dp"/>
<!--<padding
android:top="8dp"/>-->
</shape>
\ No newline at end of file
......@@ -2,24 +2,260 @@
<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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2">
<SearchView
android:id="@+id/searchForm"
android:queryHint="복지 정책 입력"
app:showAsAction="always"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="11dp"
android:background="#FFF"
android:elevation="5dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
</SearchView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="모든 정책 검색"
android:textSize="20dp"
android:textColor="#000"
android:layout_gravity="center"
android:layout_centerHorizontal="true" />
</androidx.appcompat.widget.Toolbar>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/searchRecyclerView"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_search" />
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="1"
android:orientation="vertical">
<SearchView
android:id="@+id/searchForm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="9dp"
android:layout_marginTop="30dp"
android:layout_marginRight="9dp"
android:layout_marginBottom="9dp"
android:background="@drawable/searchview_edge"
android:focusable="false"
android:layoutDirection="rtl"
android:paddingStart="7dp"
android:queryHint=" 정책명, 대상, 키워드를 입력하세요"
app:iconifiedByDefault="false"
app:showAsAction="always" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/searchRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_search">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
<ImageView
android:id="@+id/no_matching"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="img"
android:visibility="gone"
app:srcCompat="@drawable/not_matching"
tools:srcCompat="@drawable/not_matching" />
<LinearLayout
android:id="@+id/hashtag_linear"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="1.1"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View
android:id="@+id/view2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#6629ABE2" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|center_horizontal|center_vertical"
android:layout_marginStart="17dp"
android:foregroundGravity="center_vertical|center|center_horizontal">
<com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="가구상황별" />
<com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
app:chipBackgroundColor="#C6FFFFFF"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:checkable="false"
android:text="# 장애인"
android:textAppearance="@style/TextAppearance.AppCompat" />
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:checkable="false"
app:chipBackgroundColor="#C6FFFFFF"
android:text="# 한부모"
android:textAppearance="@style/TextAppearance.AppCompat" />
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:checkable="false"
app:chipBackgroundColor="#C6FFFFFF"
android:text="# 다문화"
android:textAppearance="@style/TextAppearance.AppCompat" />
</com.google.android.material.chip.ChipGroup>
<com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkable="false"
app:chipBackgroundColor="#C6FFFFFF"
android:text="# 저소득층"
android:textAppearance="@style/TextAppearance.AppCompat"
app:chipIcon="@drawable/image01" />
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkable="false"
app:chipBackgroundColor="#C6FFFFFF"
android:text="# 임신/출산"
android:textAppearance="@style/TextAppearance.AppCompat" />
</com.google.android.material.chip.ChipGroup>
</com.google.android.material.chip.ChipGroup>
<com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|center_horizontal|center_vertical"
android:foregroundGravity="center_vertical|center|center_horizontal">
<TextView
android:id="@+id/textVㅇiew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="\n생애주기별" />
<com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:checkable="false"
app:chipBackgroundColor="#C6FFFFFF"
android:text="# 아동"
android:textAppearance="@style/TextAppearance.AppCompat" />
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:checkable="false"
app:chipBackgroundColor="#C6FFFFFF"
android:text="# 청소년"
android:textAppearance="@style/TextAppearance.AppCompat" />
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:checkable="false"
app:chipBackgroundColor="#C6FFFFFF"
android:text="# 청년"
android:textAppearance="@style/TextAppearance.AppCompat" />
</com.google.android.material.chip.ChipGroup>
<com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkable="false"
app:chipBackgroundColor="#C6FFFFFF"
android:text="# 중장년"
android:textAppearance="@style/TextAppearance.AppCompat"
app:chipIcon="@drawable/image01" />
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkable="false"
app:chipBackgroundColor="#C6FFFFFF"
android:text="# 노년"
android:textAppearance="@style/TextAppearance.AppCompat" />
</com.google.android.material.chip.ChipGroup>
</com.google.android.material.chip.ChipGroup>
</com.google.android.material.chip.ChipGroup>
</FrameLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......