mirror of
https://github.com/sismics/docs.git
synced 2024-11-14 18:27:58 +01:00
Android: advanced search UI
This commit is contained in:
parent
f7f5f93a9e
commit
4c24e7921a
@ -84,8 +84,10 @@ public class DocumentEditActivity extends AppCompatActivity {
|
||||
|
||||
// Setup the activity
|
||||
setContentView(R.layout.document_edit_activity);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
}
|
||||
languageSpinner = (Spinner) findViewById(R.id.languageSpinner);
|
||||
tagsEditText = (TagsCompleteTextView) findViewById(R.id.tagsEditText);
|
||||
datePickerView = (DatePickerView) findViewById(R.id.dateEditText);
|
||||
@ -93,7 +95,7 @@ public class DocumentEditActivity extends AppCompatActivity {
|
||||
descriptionEditText = (EditText) findViewById(R.id.descriptionEditText);
|
||||
|
||||
// Language spinner
|
||||
LanguageAdapter languageAdapter = new LanguageAdapter(this);
|
||||
LanguageAdapter languageAdapter = new LanguageAdapter(this, false);
|
||||
languageSpinner.setAdapter(languageAdapter);
|
||||
|
||||
// Tags auto-complete
|
||||
|
@ -25,9 +25,12 @@ public class LanguageAdapter extends BaseAdapter {
|
||||
|
||||
private List<Language> languageList;
|
||||
|
||||
public LanguageAdapter(Context context) {
|
||||
public LanguageAdapter(Context context, boolean noValue) {
|
||||
this.context = context;
|
||||
this.languageList = new ArrayList<>();
|
||||
if (noValue) {
|
||||
languageList.add(new Language("", R.string.all_languages, 0));
|
||||
}
|
||||
languageList.add(new Language("fra", R.string.language_french, R.drawable.fra));
|
||||
languageList.add(new Language("eng", R.string.language_english, R.drawable.eng));
|
||||
languageList.add(new Language("jpn", R.string.language_japanese, R.drawable.jpn));
|
||||
|
@ -8,9 +8,20 @@ import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import com.sismics.docs.R;
|
||||
import com.sismics.docs.adapter.LanguageAdapter;
|
||||
import com.sismics.docs.adapter.TagAutoCompleteAdapter;
|
||||
import com.sismics.docs.event.SearchEvent;
|
||||
import com.sismics.docs.ui.view.TagsCompleteTextView;
|
||||
import com.sismics.docs.util.PreferenceUtil;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
@ -38,6 +49,29 @@ public class SearchFragment extends DialogFragment {
|
||||
// Setup the view
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.search_dialog, null);
|
||||
Spinner languageSpinner = (Spinner) view.findViewById(R.id.languageSpinner);
|
||||
TagsCompleteTextView tagsEditText = (TagsCompleteTextView) view.findViewById(R.id.tagsEditText);
|
||||
|
||||
// Language spinner
|
||||
LanguageAdapter languageAdapter = new LanguageAdapter(getActivity(), true);
|
||||
languageSpinner.setAdapter(languageAdapter);
|
||||
|
||||
// Tags auto-complete
|
||||
JSONObject tags = PreferenceUtil.getCachedJson(getActivity(), PreferenceUtil.PREF_CACHED_TAGS_JSON);
|
||||
if (tags == null) {
|
||||
Dialog dialog = builder.create();
|
||||
dialog.cancel();
|
||||
return dialog;
|
||||
}
|
||||
JSONArray tagArray = tags.optJSONArray("stats");
|
||||
|
||||
List<JSONObject> tagList = new ArrayList<>();
|
||||
for (int i = 0; i < tagArray.length(); i++) {
|
||||
tagList.add(tagArray.optJSONObject(i));
|
||||
}
|
||||
|
||||
tagsEditText.allowDuplicates(false);
|
||||
tagsEditText.setAdapter(new TagAutoCompleteAdapter(getActivity(), 0, tagList));
|
||||
|
||||
// Build the dialog
|
||||
builder.setView(view)
|
||||
|
@ -11,112 +11,112 @@
|
||||
|
||||
<!-- Simple search -->
|
||||
<EditText
|
||||
android:id="@+id/searchEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:textSize="18sp"
|
||||
android:hint="Simple search"/>
|
||||
android:hint="@string/simple_search"/>
|
||||
|
||||
<!-- Fulltext search -->
|
||||
<EditText
|
||||
android:id="@+id/fulltextEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:textSize="18sp"
|
||||
android:hint="Fulltext search"/>
|
||||
android:hint="@string/fulltext_search"/>
|
||||
|
||||
<!-- Language -->
|
||||
<Spinner
|
||||
android:id="@+id/languageSpinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:padding="16dp"/>
|
||||
android:layout_margin="8dp"/>
|
||||
|
||||
<!-- Shared -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:text="Shared documents"
|
||||
android:text="@string/shared_documents"
|
||||
android:textColor="#9f9f9f"
|
||||
android:fontFamily="sans-serif"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:textSize="18sp"
|
||||
android:padding="16dp"/>
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/sharedCheckbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"/>
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Before date -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_margin="8dp">
|
||||
|
||||
<TextView
|
||||
android:layout_weight="0.5"
|
||||
android:text="After date"
|
||||
android:text="@string/after_date"
|
||||
android:textColor="#9f9f9f"
|
||||
android:fontFamily="sans-serif"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:textSize="18sp"
|
||||
android:padding="16dp"/>
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<com.sismics.docs.ui.view.DatePickerView
|
||||
style="@android:style/Widget.DeviceDefault.Light.Spinner"
|
||||
android:id="@+id/afterDatePicker"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:textSize="18sp"
|
||||
android:padding="16dp"
|
||||
android:text="15/05/2014"/>
|
||||
android:textSize="18sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- After date -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_weight="0.5"
|
||||
android:text="Before date"
|
||||
android:text="@string/before_date"
|
||||
android:textColor="#9f9f9f"
|
||||
android:fontFamily="sans-serif"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:textSize="18sp"
|
||||
android:padding="16dp"/>
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<com.sismics.docs.ui.view.DatePickerView
|
||||
style="@android:style/Widget.DeviceDefault.Light.Spinner"
|
||||
android:id="@+id/beforeDatePicker"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:textSize="18sp"
|
||||
android:padding="16dp"
|
||||
android:text="15/05/2014"/>
|
||||
android:textSize="18sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Tags -->
|
||||
<com.sismics.docs.ui.view.TagsCompleteTextView
|
||||
android:id="@+id/tagsEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:layout_margin="8dp"
|
||||
android:hint="Search tags"/>
|
||||
android:hint="@string/search_tags"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -99,6 +99,12 @@
|
||||
<string name="creation_date">Creation date</string>
|
||||
<string name="description">Description</string>
|
||||
<string name="title">Title</string>
|
||||
<string name="simple_search">Simple search</string>
|
||||
<string name="fulltext_search">Fulltext search</string>
|
||||
<string name="after_date">After date</string>
|
||||
<string name="before_date">Before date</string>
|
||||
<string name="search_tags">Search tags</string>
|
||||
<string name="all_languages">All languages</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user