diff --git a/docs-android/app/src/main/java/com/sismics/docs/MainApplication.java b/docs-android/app/src/main/java/com/sismics/docs/MainApplication.java index 727b8b4e..df113ebf 100644 --- a/docs-android/app/src/main/java/com/sismics/docs/MainApplication.java +++ b/docs-android/app/src/main/java/com/sismics/docs/MainApplication.java @@ -20,7 +20,9 @@ public class MainApplication extends Application { JSONObject json = PreferenceUtil.getCachedJson(getApplicationContext(), PreferenceUtil.PREF_CACHED_USER_INFO_JSON); ApplicationContext.getInstance().setUserInfo(getApplicationContext(), json); - // TODO Sharing + // TODO Edit sharing + // TODO Tags loading feedback + // TODO Redraw flags // TODO Error feedback (all REST request, even login) // TODO Fullscreen preview // TODO Caching preferences diff --git a/docs-android/app/src/main/java/com/sismics/docs/activity/MainActivity.java b/docs-android/app/src/main/java/com/sismics/docs/activity/MainActivity.java index f87762bc..28a5866c 100644 --- a/docs-android/app/src/main/java/com/sismics/docs/activity/MainActivity.java +++ b/docs-android/app/src/main/java/com/sismics/docs/activity/MainActivity.java @@ -40,6 +40,7 @@ public class MainActivity extends ActionBarActivity { private ActionBarDrawerToggle drawerToggle; private MenuItem searchItem; + private DrawerLayout drawerLayout; @Override protected void onCreate(final Bundle args) { @@ -56,7 +57,7 @@ public class MainActivity extends ActionBarActivity { setContentView(R.layout.main_activity); // Enable ActionBar app icon to behave as action to toggle nav drawer - final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); + drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); @@ -92,11 +93,7 @@ public class MainActivity extends ActionBarActivity { if (adapter == null) return; JSONObject tag = adapter.getItem(position); if (tag == null) return; - SearchView searchView = (SearchView) searchItem.getActionView(); - searchView.setQuery("tag:" + tag.optString("name"), true); - searchView.setIconified(false); - searchView.clearFocus(); - drawerLayout.closeDrawers(); + searchQuery("tag:" + tag.optString("name")); } }); @@ -105,11 +102,16 @@ public class MainActivity extends ActionBarActivity { allDocumentsLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - SearchView searchView = (SearchView) searchItem.getActionView(); - searchView.setQuery(null, true); - searchView.setIconified(true); - drawerLayout.closeDrawers(); + searchQuery(null); + } + }); + // Click on Shared documents + View sharedDocumentsLayout = findViewById(R.id.sharedDocumentsLayout); + sharedDocumentsLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + searchQuery("shared:yes"); } }); @@ -200,4 +202,17 @@ public class MainActivity extends ActionBarActivity { EventBus.getDefault().post(new SearchEvent(query)); } } + + /** + * Perform a search query. + * + * @param query Query + */ + private void searchQuery(String query) { + SearchView searchView = (SearchView) searchItem.getActionView(); + searchView.setQuery(query, true); + searchView.setIconified(query == null); + searchView.clearFocus(); + drawerLayout.closeDrawers(); + } } \ No newline at end of file diff --git a/docs-android/app/src/main/java/com/sismics/docs/adapter/DocListAdapter.java b/docs-android/app/src/main/java/com/sismics/docs/adapter/DocListAdapter.java index 9da23c57..13d3555f 100644 --- a/docs-android/app/src/main/java/com/sismics/docs/adapter/DocListAdapter.java +++ b/docs-android/app/src/main/java/com/sismics/docs/adapter/DocListAdapter.java @@ -5,6 +5,7 @@ import android.text.format.DateFormat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; import com.sismics.docs.R; @@ -33,12 +34,14 @@ public class DocListAdapter extends RecyclerView.Adapter + + diff --git a/docs-android/app/src/main/res/layout/main_activity.xml b/docs-android/app/src/main/res/layout/main_activity.xml index 58832008..6ac39265 100644 --- a/docs-android/app/src/main/res/layout/main_activity.xml +++ b/docs-android/app/src/main/res/layout/main_activity.xml @@ -82,6 +82,40 @@ + + + + + + + + + + Too long (max. %d) Required Only letters and numbers + Shared documents