Skip to content

Commit

Permalink
Made OnSearchActionListener public and updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
mancj committed Jul 29, 2016
1 parent c7267e1 commit c38f4da
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This beautiful and easy to use library will help to add Lollipop Material Desing

add the dependency to the the app level build.gradle file

'com.github.mancj:MaterialSearchBar:0.1.0'
compile 'com.github.mancj:MaterialSearchBar:0.1.0'


then add SearchBar to your activity:
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/com/mancj/example/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.mancj.materialsearchbar.MaterialSearchBar;
Expand All @@ -11,12 +14,15 @@
public class MainActivity extends AppCompatActivity implements MaterialSearchBar.OnSearchActionListener {
private List<String> lastSearches;
private MaterialSearchBar searchBar;
private FrameLayout dim;

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

dim = (FrameLayout) findViewById(R.id.dim);

searchBar = (MaterialSearchBar) findViewById(R.id.searchBar);
searchBar.setHint("Custom hint");
searchBar.setSpeechMode(true);
Expand All @@ -39,6 +45,11 @@ protected void onDestroy() {
public void onSearchStateChanged(boolean enabled) {
String s = enabled ? "enabled" : "disabled";
Toast.makeText(MainActivity.this, "Search " + s, Toast.LENGTH_SHORT).show();
if (enabled){
dim.setVisibility(View.VISIBLE);
}else {
dim.setVisibility(View.GONE);
}
}

//called when user confirms request
Expand Down
29 changes: 17 additions & 12 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.mancj.example.MainActivity">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/round_corners"
android:layout_marginTop="65dp"
android:visibility="visible"></RelativeLayout>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparentBlack"
android:visibility="gone"
android:id="@+id/dim"></FrameLayout>

<com.mancj.materialsearchbar.MaterialSearchBar
app:speechMode="true"
app:hint="Custom hint"
Expand All @@ -15,16 +32,4 @@
android:layout_height="wrap_content"
android:id="@+id/searchBar" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="@drawable/round_corners"
android:id="@+id/reveal"
android:elevation="3dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_below="@+id/searchBar" />

</RelativeLayout>
2 changes: 1 addition & 1 deletion library/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="transparentBlack">#BE000000</color>
<color name="transparentBlack">#96000000</color>
</resources>

0 comments on commit c38f4da

Please sign in to comment.