mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +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
|
// Setup the activity
|
||||||
setContentView(R.layout.document_edit_activity);
|
setContentView(R.layout.document_edit_activity);
|
||||||
|
if (getSupportActionBar() != null) {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setHomeButtonEnabled(true);
|
getSupportActionBar().setHomeButtonEnabled(true);
|
||||||
|
}
|
||||||
languageSpinner = (Spinner) findViewById(R.id.languageSpinner);
|
languageSpinner = (Spinner) findViewById(R.id.languageSpinner);
|
||||||
tagsEditText = (TagsCompleteTextView) findViewById(R.id.tagsEditText);
|
tagsEditText = (TagsCompleteTextView) findViewById(R.id.tagsEditText);
|
||||||
datePickerView = (DatePickerView) findViewById(R.id.dateEditText);
|
datePickerView = (DatePickerView) findViewById(R.id.dateEditText);
|
||||||
@ -93,7 +95,7 @@ public class DocumentEditActivity extends AppCompatActivity {
|
|||||||
descriptionEditText = (EditText) findViewById(R.id.descriptionEditText);
|
descriptionEditText = (EditText) findViewById(R.id.descriptionEditText);
|
||||||
|
|
||||||
// Language spinner
|
// Language spinner
|
||||||
LanguageAdapter languageAdapter = new LanguageAdapter(this);
|
LanguageAdapter languageAdapter = new LanguageAdapter(this, false);
|
||||||
languageSpinner.setAdapter(languageAdapter);
|
languageSpinner.setAdapter(languageAdapter);
|
||||||
|
|
||||||
// Tags auto-complete
|
// Tags auto-complete
|
||||||
|
@ -25,9 +25,12 @@ public class LanguageAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
private List<Language> languageList;
|
private List<Language> languageList;
|
||||||
|
|
||||||
public LanguageAdapter(Context context) {
|
public LanguageAdapter(Context context, boolean noValue) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.languageList = new ArrayList<>();
|
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("fra", R.string.language_french, R.drawable.fra));
|
||||||
languageList.add(new Language("eng", R.string.language_english, R.drawable.eng));
|
languageList.add(new Language("eng", R.string.language_english, R.drawable.eng));
|
||||||
languageList.add(new Language("jpn", R.string.language_japanese, R.drawable.jpn));
|
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.support.v4.app.DialogFragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
import com.sismics.docs.R;
|
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.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;
|
import de.greenrobot.event.EventBus;
|
||||||
|
|
||||||
@ -38,6 +49,29 @@ public class SearchFragment extends DialogFragment {
|
|||||||
// Setup the view
|
// Setup the view
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
View view = inflater.inflate(R.layout.search_dialog, null);
|
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
|
// Build the dialog
|
||||||
builder.setView(view)
|
builder.setView(view)
|
||||||
|
@ -11,112 +11,112 @@
|
|||||||
|
|
||||||
<!-- Simple search -->
|
<!-- Simple search -->
|
||||||
<EditText
|
<EditText
|
||||||
|
android:id="@+id/searchEditText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:hint="Simple search"/>
|
android:hint="@string/simple_search"/>
|
||||||
|
|
||||||
<!-- Fulltext search -->
|
<!-- Fulltext search -->
|
||||||
<EditText
|
<EditText
|
||||||
|
android:id="@+id/fulltextEditText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:hint="Fulltext search"/>
|
android:hint="@string/fulltext_search"/>
|
||||||
|
|
||||||
<!-- Language -->
|
<!-- Language -->
|
||||||
<Spinner
|
<Spinner
|
||||||
|
android:id="@+id/languageSpinner"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"/>
|
||||||
android:padding="16dp"/>
|
|
||||||
|
|
||||||
<!-- Shared -->
|
<!-- Shared -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:text="Shared documents"
|
android:text="@string/shared_documents"
|
||||||
android:textColor="#9f9f9f"
|
android:textColor="#9f9f9f"
|
||||||
android:fontFamily="sans-serif"
|
android:fontFamily="sans-serif"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"/>
|
||||||
android:padding="16dp"/>
|
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
|
android:id="@+id/sharedCheckbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"/>
|
||||||
android:layout_margin="8dp"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Before date -->
|
<!-- Before date -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_margin="8dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:text="After date"
|
android:text="@string/after_date"
|
||||||
android:textColor="#9f9f9f"
|
android:textColor="#9f9f9f"
|
||||||
android:fontFamily="sans-serif"
|
android:fontFamily="sans-serif"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:textSize="18sp"/>
|
||||||
android:textSize="18sp"
|
|
||||||
android:padding="16dp"/>
|
|
||||||
|
|
||||||
<com.sismics.docs.ui.view.DatePickerView
|
<com.sismics.docs.ui.view.DatePickerView
|
||||||
style="@android:style/Widget.DeviceDefault.Light.Spinner"
|
style="@android:style/Widget.DeviceDefault.Light.Spinner"
|
||||||
|
android:id="@+id/afterDatePicker"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:textSize="18sp"/>
|
||||||
android:textSize="18sp"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:text="15/05/2014"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- After date -->
|
<!-- After date -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:text="Before date"
|
android:text="@string/before_date"
|
||||||
android:textColor="#9f9f9f"
|
android:textColor="#9f9f9f"
|
||||||
android:fontFamily="sans-serif"
|
android:fontFamily="sans-serif"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:textSize="18sp"/>
|
||||||
android:textSize="18sp"
|
|
||||||
android:padding="16dp"/>
|
|
||||||
|
|
||||||
<com.sismics.docs.ui.view.DatePickerView
|
<com.sismics.docs.ui.view.DatePickerView
|
||||||
style="@android:style/Widget.DeviceDefault.Light.Spinner"
|
style="@android:style/Widget.DeviceDefault.Light.Spinner"
|
||||||
|
android:id="@+id/beforeDatePicker"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:textSize="18sp"/>
|
||||||
android:textSize="18sp"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:text="15/05/2014"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Tags -->
|
<!-- Tags -->
|
||||||
<com.sismics.docs.ui.view.TagsCompleteTextView
|
<com.sismics.docs.ui.view.TagsCompleteTextView
|
||||||
|
android:id="@+id/tagsEditText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:hint="Search tags"/>
|
android:hint="@string/search_tags"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -99,6 +99,12 @@
|
|||||||
<string name="creation_date">Creation date</string>
|
<string name="creation_date">Creation date</string>
|
||||||
<string name="description">Description</string>
|
<string name="description">Description</string>
|
||||||
<string name="title">Title</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>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user