Skip to content

Commit

Permalink
Merge branch 'release/v1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelCatalan committed Sep 27, 2015
2 parents f4aa589 + 80d36f4 commit 16da0fe
Show file tree
Hide file tree
Showing 13 changed files with 588 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Cute library to implement SearchView in a Material Design Approach. *Works from
**Add the dependencies to your gradle file:**
```javascript
dependencies {
compile 'com.miguelcatalan:materialsearchview:1.1.0'
compile 'com.miguelcatalan:materialsearchview:1.2.0'
}
```
**Add MaterialSearchView to your layout file along with the Toolbar** *(Add this block at the bottom of your layout, in order to display it over the rest of the view)*:
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.1.0"
versionName "1.2.0"
}
buildTypes {
release {
Expand All @@ -37,7 +37,7 @@ publish {
userOrg = 'miguelcatalan'
groupId = 'com.miguelcatalan'
artifactId = 'materialsearchview'
publishVersion = '1.1.0'
publishVersion = '1.2.0'
desc = 'Cute library to implement SearchView in a Material Design Approach'
website = 'https://github.com/MiguelCatalan/MaterialSearchView'
}
18 changes: 3 additions & 15 deletions library/src/main/res/layout/search_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,20 @@

<ImageButton
android:id="@+id/action_up_btn"
android:layout_width="wrap_content"
android:layout_height="match_parent"
style="@style/MSV_ImageButton"
android:layout_centerVertical="true"
android:background="?android:attr/selectableItemBackground"
android:paddingLeft="@dimen/search_icon_padding"
android:paddingRight="@dimen/search_icon_padding"
android:src="@drawable/ic_action_navigation_arrow_back" />

<ImageButton
android:id="@+id/action_voice_btn"
android:layout_width="wrap_content"
android:layout_height="match_parent"
style="@style/MSV_ImageButton"
android:layout_alignParentRight="true"
android:background="?android:attr/selectableItemBackground"
android:paddingLeft="@dimen/search_icon_padding"
android:paddingRight="@dimen/search_icon_padding"
android:src="@drawable/ic_action_voice_search" />

<ImageButton
android:id="@+id/action_empty_btn"
android:layout_width="wrap_content"
android:layout_height="match_parent"
style="@style/MSV_ImageButton"
android:layout_alignParentRight="true"
android:background="?android:attr/selectableItemBackground"
android:paddingLeft="@dimen/search_icon_padding"
android:paddingRight="@dimen/search_icon_padding"
android:src="@drawable/ic_action_navigation_close"
android:visibility="gone" />

Expand Down
10 changes: 10 additions & 0 deletions library/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MSV_ImageButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
<item name="android:background">?android:attr/selectableItemBackgroundBorderless</item>
<item name="android:paddingLeft">@dimen/search_icon_padding</item>
<item name="android:paddingRight">@dimen/search_icon_padding</item>
</style>
</resources>
10 changes: 10 additions & 0 deletions library/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MSV_ImageButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
<item name="android:background">?android:attr/selectableItemBackground</item>
<item name="android:paddingLeft">@dimen/search_icon_padding</item>
<item name="android:paddingRight">@dimen/search_icon_padding</item>
</style>
</resources>
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.miguelcatalan.materialsearchview.sample"
minSdkVersion 14
targetSdkVersion 23
versionCode 3
versionName "1.0.2"
versionCode 4
versionName "1.2.0"
}
buildTypes {
release {
Expand Down
5 changes: 5 additions & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
android:name=".VoiceActivity"
android:label="@string/title_activity_voice" >
</activity>
<activity
android:name=".StickyActivity"
android:label="@string/title_activity_sticky"
android:theme="@style/AppTheme" >
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private Button defaultButton;
private Button themedButton;
private Button voiceButton;
private Button stickyButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -23,7 +24,8 @@ protected void onCreate(Bundle savedInstanceState) {
themedButton.setOnClickListener(this);
voiceButton = (Button) findViewById(R.id.button_voice);
voiceButton.setOnClickListener(this);

stickyButton = (Button) findViewById(R.id.button_sticky);
stickyButton.setOnClickListener(this);
}

@Override
Expand All @@ -39,6 +41,9 @@ public void onClick(View view) {
case R.id.button_voice:
intent = new Intent(this, VoiceActivity.class);
break;
case R.id.button_sticky:
intent = new Intent(this, StickyActivity.class);
break;
}
if (intent != null) {
startActivity(intent);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.miguelcatalan.materialsearchview.sample;

import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;

import com.miguelcatalan.materialsearchview.MaterialSearchView;

import java.util.ArrayList;

public class StickyActivity extends AppCompatActivity {

private MaterialSearchView searchView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_default);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

searchView = (MaterialSearchView) findViewById(R.id.search_view);
searchView.setVoiceSearch(false);
searchView.setCursorDrawable(R.drawable.custom_cursor);
searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Snackbar.make(findViewById(R.id.container), "Query: " + query, Snackbar.LENGTH_LONG)
.show();
return false;
}

@Override
public boolean onQueryTextChange(String newText) {
//Do some magic
return false;
}
});

searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
@Override
public void onSearchViewShown() {
//Do some magic
}

@Override
public void onSearchViewClosed() {
//Do some magic
}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);

MenuItem item = menu.findItem(R.id.action_search);
searchView.setMenuItem(item);

return true;
}

@Override
public void onBackPressed() {
if (searchView.isSearchOpen()) {
searchView.closeSearch();
} else {
super.onBackPressed();
}
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == MaterialSearchView.REQUEST_VOICE && resultCode == RESULT_OK) {
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
if (matches != null && matches.size() > 0) {
String searchWrd = matches.get(0);
if (!TextUtils.isEmpty(searchWrd)) {
searchView.setQuery(searchWrd, false);
}
}

return;
}
super.onActivityResult(requestCode, resultCode, data);
}
}
7 changes: 7 additions & 0 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
android:layout_height="wrap_content"
android:text="Voice"
android:textColor="@color/theme_secondary_text" />

<Button
android:id="@+id/button_sticky"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sticky"
android:textColor="@color/theme_secondary_text" />
</LinearLayout>

</RelativeLayout>
Expand Down
31 changes: 31 additions & 0 deletions sample/src/main/res/layout/activity_sticky.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">

<!-- Irrelevant stuff -->
<include
layout="@layout/mok_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize" />

<!-- Must be last for right layering display -->
<FrameLayout
android:id="@+id/toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/theme_primary" />

<com.miguelcatalan.materialsearchview.MaterialSearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>

</FrameLayout>
Loading

0 comments on commit 16da0fe

Please sign in to comment.