Skip to content

Commit

Permalink
Version 1.0.1 roll-out
Browse files Browse the repository at this point in the history
  • Loading branch information
mecoFarid committed Oct 13, 2019
1 parent dc1a478 commit b94fe98
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 14 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ dependencies {
app:ds_iconColor_openSearchView="@color/default_color_open_searchview_icon"
app:ds_iconColor_closeSearcView="@color/default_color_open_searchview_icon"
app:ds_isSearchable="true"
app:ds_textSelectionMode="end"/>
app:ds_textSelectionMode="end"
app:cardElevation="@dimen/cardview_default_elevation"
app:cardCornerRadius="@dimen/cardview_default_radius"
app:cardUseCompatPadding="true"/>
```
**Step 4.** Add your `DynamicSpinner` view to `xml` file where you want it
```
Expand Down Expand Up @@ -92,4 +95,7 @@ class MainActivity : AppCompatActivity(), DynamicSpinnerAdapter.SpinnerItemSelec
| app:ds_iconColor_openSearchView | #808080 | any color | - |
| app:ds_iconColor_closeSearcView | #808080 | any color | - |
| app:ds_isSearchable | true | true \| false | if `true` content is searchable |
| app:ds_textSelectionMode | end | start \| all \| end | position of cursor when SearchableView opened, `all` means all text will be selected |
| app:ds_textSelectionMode | end | start \| all \| end | position of cursor when SearchableView opened, `all` means all text will be selected |
| app:cardCornerRadius | 2dp | any dimension | radius on the edges |
| app:cardElevation | 2dp | any dimension | layout elevation |
| app:cardUseCompatPadding | true | true \| false | padding between spinner items |
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "com.mecofarid.dynamicspinnersample"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/item_spinner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
app:ds_iconColor_openSearchView="@color/default_color_open_searchview_icon"
app:ds_iconColor_closeSearcView="@color/default_color_open_searchview_icon"
app:ds_isSearchable="true"
app:ds_textSelectionMode="end"/>
app:ds_textSelectionMode="end"
app:cardElevation="@dimen/cardview_default_elevation"
app:cardCornerRadius="@dimen/cardview_default_radius"/>
4 changes: 2 additions & 2 deletions dynamicspinner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta04'
api 'androidx.cardview:cardview:1.0.0'
api 'androidx.recyclerview:recyclerview:1.1.0-beta04'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class NoFilterAutoCompleteTextView: AppCompatAutoCompleteTextView {
*/
dismissDropDown()


println("meco click ")

return super.performClick()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package com.mecofarid.dynamicspinner.view

import android.content.Context
import android.util.AttributeSet
import android.view.ActionMode
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.*
Expand Down Expand Up @@ -59,7 +62,6 @@ class SearchableView @JvmOverloads constructor(
mAutoCompleteTextView = view.findViewById(R.id.autocomplete_textview)
mOpenSearchViewIcon = view.findViewById(R.id.search)
mCloseSearchViewIcon = view.findViewById(R.id.close)
// val rel = view.findViewById(R.id.searchable_view_content) as RelativeLayout

//Set values from attributes or default
with(context.obtainStyledAttributes(attrs, R.styleable.SearchableView, defStyleAttr, 0)){
Expand Down Expand Up @@ -88,14 +90,11 @@ class SearchableView @JvmOverloads constructor(
recycle()
}

// rel.requestFocus()
//
// rel.setOnFocusChangeListener { view, b ->
// println("meoc multi self down $b}")
// }

mAutoCompleteTextView.showSoftInputOnFocus = false

// Disables system to pop-up copy-paste window
disableCopyPastePopup()

//Initializes adapter with empty item list
initializeAndSetAdapter()

Expand All @@ -108,6 +107,25 @@ class SearchableView @JvmOverloads constructor(
addView(view)
}

private fun disableCopyPastePopup(){
mAutoCompleteTextView.customSelectionActionModeCallback = object :ActionMode.Callback{
override fun onActionItemClicked(p0: ActionMode?, p1: MenuItem?): Boolean {
return false
}

override fun onCreateActionMode(p0: ActionMode?, p1: Menu?): Boolean {
return false
}

override fun onPrepareActionMode(p0: ActionMode?, p1: Menu?): Boolean {
return false
}

override fun onDestroyActionMode(p0: ActionMode?) {
}
}
}

private fun initializeAndSetAdapter(){
// Items will added later
val arrayAdapter = ArrayAdapter(context, R.layout.support_simple_spinner_dropdown_item, mSpinnerItemList)
Expand Down Expand Up @@ -144,6 +162,9 @@ class SearchableView @JvmOverloads constructor(
closeSearchIfOpen()
// When search stopped halfway through, show the last selected item's 'toString()' in AutoCompleteTextView
setAutoCompleteText(mSelectedItem.toString())

// Clear focus as soon as focus is lost from
requestFocusOnAutocompleteTextView(false, false)
}
}
}
Expand Down Expand Up @@ -228,6 +249,8 @@ class SearchableView @JvmOverloads constructor(

if (requestFocus){
requestFocus()
}else{
clearFocus()
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions dynamicspinner/src/main/res/layout/item_searchable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
android:focusable="false"
android:focusableInTouchMode="false"
android:cursorVisible="false"
android:longClickable="false"
android:textIsSelectable="false"
android:layout_centerVertical="true"
android:layout_toStartOf="@id/close" />

Expand Down

0 comments on commit b94fe98

Please sign in to comment.