mirror of
https://github.com/sismics/docs.git
synced 2024-11-26 07:34:55 +01:00
Android: display shared status
This commit is contained in:
parent
407564f28c
commit
a6c123ad03
@ -20,7 +20,9 @@ public class MainApplication extends Application {
|
|||||||
JSONObject json = PreferenceUtil.getCachedJson(getApplicationContext(), PreferenceUtil.PREF_CACHED_USER_INFO_JSON);
|
JSONObject json = PreferenceUtil.getCachedJson(getApplicationContext(), PreferenceUtil.PREF_CACHED_USER_INFO_JSON);
|
||||||
ApplicationContext.getInstance().setUserInfo(getApplicationContext(), 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 Error feedback (all REST request, even login)
|
||||||
// TODO Fullscreen preview
|
// TODO Fullscreen preview
|
||||||
// TODO Caching preferences
|
// TODO Caching preferences
|
||||||
|
@ -40,6 +40,7 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
private ActionBarDrawerToggle drawerToggle;
|
private ActionBarDrawerToggle drawerToggle;
|
||||||
private MenuItem searchItem;
|
private MenuItem searchItem;
|
||||||
|
private DrawerLayout drawerLayout;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(final Bundle args) {
|
protected void onCreate(final Bundle args) {
|
||||||
@ -56,7 +57,7 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
setContentView(R.layout.main_activity);
|
setContentView(R.layout.main_activity);
|
||||||
|
|
||||||
// Enable ActionBar app icon to behave as action to toggle nav drawer
|
// 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) {
|
if (getSupportActionBar() != null) {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setHomeButtonEnabled(true);
|
getSupportActionBar().setHomeButtonEnabled(true);
|
||||||
@ -92,11 +93,7 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
if (adapter == null) return;
|
if (adapter == null) return;
|
||||||
JSONObject tag = adapter.getItem(position);
|
JSONObject tag = adapter.getItem(position);
|
||||||
if (tag == null) return;
|
if (tag == null) return;
|
||||||
SearchView searchView = (SearchView) searchItem.getActionView();
|
searchQuery("tag:" + tag.optString("name"));
|
||||||
searchView.setQuery("tag:" + tag.optString("name"), true);
|
|
||||||
searchView.setIconified(false);
|
|
||||||
searchView.clearFocus();
|
|
||||||
drawerLayout.closeDrawers();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -105,11 +102,16 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
allDocumentsLayout.setOnClickListener(new View.OnClickListener() {
|
allDocumentsLayout.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
SearchView searchView = (SearchView) searchItem.getActionView();
|
searchQuery(null);
|
||||||
searchView.setQuery(null, true);
|
}
|
||||||
searchView.setIconified(true);
|
});
|
||||||
drawerLayout.closeDrawers();
|
|
||||||
|
|
||||||
|
// 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));
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -5,6 +5,7 @@ import android.text.format.DateFormat;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.sismics.docs.R;
|
import com.sismics.docs.R;
|
||||||
@ -33,12 +34,14 @@ public class DocListAdapter extends RecyclerView.Adapter<DocListAdapter.ViewHold
|
|||||||
public TextView titleTextView;
|
public TextView titleTextView;
|
||||||
public TextView subtitleTextView;
|
public TextView subtitleTextView;
|
||||||
public TextView dateTextView;
|
public TextView dateTextView;
|
||||||
|
public ImageView sharedImageView;
|
||||||
|
|
||||||
public ViewHolder(View v) {
|
public ViewHolder(View v) {
|
||||||
super(v);
|
super(v);
|
||||||
titleTextView = (TextView) v.findViewById(R.id.titleTextView);
|
titleTextView = (TextView) v.findViewById(R.id.titleTextView);
|
||||||
subtitleTextView = (TextView) v.findViewById(R.id.subtitleTextView);
|
subtitleTextView = (TextView) v.findViewById(R.id.subtitleTextView);
|
||||||
dateTextView = (TextView) v.findViewById(R.id.dateTextView);
|
dateTextView = (TextView) v.findViewById(R.id.dateTextView);
|
||||||
|
sharedImageView = (ImageView) v.findViewById(R.id.sharedImageView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +67,8 @@ public class DocListAdapter extends RecyclerView.Adapter<DocListAdapter.ViewHold
|
|||||||
|
|
||||||
String date = DateFormat.getDateFormat(holder.dateTextView.getContext()).format(new Date(document.optLong("create_date")));
|
String date = DateFormat.getDateFormat(holder.dateTextView.getContext()).format(new Date(document.optLong("create_date")));
|
||||||
holder.dateTextView.setText(date);
|
holder.dateTextView.setText(date);
|
||||||
|
|
||||||
|
holder.sharedImageView.setVisibility(document.optBoolean("shared") ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -10,13 +10,13 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.loopj.android.http.JsonHttpResponseHandler;
|
import com.loopj.android.http.JsonHttpResponseHandler;
|
||||||
import com.sismics.docs.DividerItemDecoration;
|
|
||||||
import com.sismics.docs.R;
|
import com.sismics.docs.R;
|
||||||
import com.sismics.docs.activity.DocumentActivity;
|
import com.sismics.docs.activity.DocumentActivity;
|
||||||
import com.sismics.docs.adapter.DocListAdapter;
|
import com.sismics.docs.adapter.DocListAdapter;
|
||||||
import com.sismics.docs.event.SearchEvent;
|
import com.sismics.docs.event.SearchEvent;
|
||||||
import com.sismics.docs.listener.RecyclerItemClickListener;
|
import com.sismics.docs.listener.RecyclerItemClickListener;
|
||||||
import com.sismics.docs.resource.DocumentResource;
|
import com.sismics.docs.resource.DocumentResource;
|
||||||
|
import com.sismics.docs.ui.view.DividerItemDecoration;
|
||||||
|
|
||||||
import org.apache.http.Header;
|
import org.apache.http.Header;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.sismics.docs;
|
package com.sismics.docs.ui.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
@ -36,6 +36,9 @@
|
|||||||
android:id="@+id/subtitleTextView"
|
android:id="@+id/subtitleTextView"
|
||||||
android:layout_below="@+id/titleTextView"
|
android:layout_below="@+id/titleTextView"
|
||||||
android:layout_toRightOf="@+id/folderImageView"
|
android:layout_toRightOf="@+id/folderImageView"
|
||||||
|
android:layout_toEndOf="@id/folderImageView"
|
||||||
|
android:layout_toLeftOf="@+id/sharedImageView"
|
||||||
|
android:layout_toStartOf="@id/sharedImageView"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -46,6 +49,15 @@
|
|||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:ellipsize="end"/>
|
android:ellipsize="end"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/sharedImageView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_folder_shared_grey600_24dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentEnd="true"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/dateTextView"
|
android:id="@+id/dateTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -61,6 +61,8 @@
|
|||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:src="@drawable/ic_folder_shared_grey600_24dp"
|
android:src="@drawable/ic_folder_shared_grey600_24dp"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_toLeftOf="@+id/languageImageView"
|
android:layout_toLeftOf="@+id/languageImageView"
|
||||||
android:layout_toStartOf="@+id/languageImageView"/>
|
android:layout_toStartOf="@+id/languageImageView"/>
|
||||||
|
|
||||||
|
@ -82,6 +82,40 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<!-- Shared documents -->
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/sharedDocumentsLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:background="?android:attr/selectableItemBackground">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/sharedDocumentsImageView"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_folder_shared_grey600_24dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_toRightOf="@+id/sharedDocumentsImageView"
|
||||||
|
android:layout_toEndOf="@+id/sharedDocumentsImageView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="sans-serif"
|
||||||
|
android:textColor="#212121"
|
||||||
|
android:text="@string/shared_documents"
|
||||||
|
android:textSize="14sp"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<!-- Separator -->
|
<!-- Separator -->
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
@ -33,5 +33,6 @@
|
|||||||
<string name="validate_error_length_max">Too long (max. %d)</string>
|
<string name="validate_error_length_max">Too long (max. %d)</string>
|
||||||
<string name="validate_error_required">Required</string>
|
<string name="validate_error_required">Required</string>
|
||||||
<string name="validate_error_alphanumeric">Only letters and numbers</string>
|
<string name="validate_error_alphanumeric">Only letters and numbers</string>
|
||||||
|
<string name="shared_documents">Shared documents</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user