layout tweaking, better listener support, loading visualization

This commit is contained in:
Andy Scherzinger 2016-09-26 23:12:20 +02:00
parent 25117bc0e3
commit dc1b7b3958
7 changed files with 133 additions and 107 deletions

View file

@ -21,9 +21,9 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/standard_padding"
android:paddingTop="@dimen/standard_padding"
android:paddingBottom="@dimen/standard_padding">
android:paddingTop="@dimen/standard_half_padding"
android:paddingBottom="@dimen/standard_half_padding"
android:paddingLeft="@dimen/standard_padding">
<TextView
android:id="@+id/title"
@ -33,35 +33,37 @@
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/buttonBar"
android:layout_toLeftOf="@+id/buttonBar"
android:ellipsize="middle"
android:gravity="start|center_vertical"
android:text="Header Text"
android:textStyle="bold"
android:ellipsize="middle"
android:textColor="?android:textColorPrimary"/>
android:textColor="?android:textColorPrimary"
android:textStyle="bold"/>
<LinearLayout android:id="@+id/buttonBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
<ImageButton
android:id="@+id/syncStatusButton"
<LinearLayout
android:id="@+id/buttonBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/standard_half_padding"
android:background="@color/transparent"
android:clickable="true"
android:src="@drawable/ic_cloud_sync_off"/>
android:layout_alignParentRight="true">
<ImageButton
android:id="@+id/syncStatusButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:clickable="true"
android:padding="@dimen/standard_half_padding"
android:src="@drawable/ic_cloud_sync_off"/>
<ImageButton
android:id="@+id/settingsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/standard_half_padding"
android:paddingTop="@dimen/standard_half_padding"
android:paddingBottom="@dimen/standard_half_padding"
android:paddingRight="@dimen/standard_padding"
android:background="@color/transparent"
android:clickable="true"
android:paddingBottom="@dimen/standard_half_padding"
android:paddingLeft="@dimen/standard_half_padding"
android:paddingRight="@dimen/standard_padding"
android:paddingTop="@dimen/standard_half_padding"
android:src="@drawable/ic_dots_vertical"/>
</LinearLayout>

View file

@ -34,13 +34,55 @@
<include
layout="@layout/toolbar_standard"/>
<android.support.v7.widget.RecyclerView
android:id="@android:id/list"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"/>
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:visibility="visible"/>
<LinearLayout
android:id="@android:id/progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ProgressBar
android:id="@+id/folderSyncProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
<TextView
android:id="@+id/progressText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="@dimen/standard_half_margin"
android:text="@string/folder_sync_loading_folders"
android:textColor="@color/secondaryTextColor"
android:textStyle="italic"/>
</LinearLayout>
<TextView
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="@dimen/standard_margin"
android:gravity="center"
android:textColor="@color/secondaryTextColor"
android:text="@string/folder_sync_no_results"
android:visibility="gone" />
</FrameLayout>
</LinearLayout>

View file

@ -494,6 +494,8 @@
<string name="participate_contribute_github_text">Contribute as a developer, see &lt;a href="https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md">CONTRIBUTING.md&lt;/a> for details</string>
<string name="move_to">Move to&#8230;</string>
<string name="copy_to">Copy to&#8230;</string>
<string name="folder_sync_loading_folders">Loading folders&#8230;</string>
<string name="folder_sync_no_results">No results</string>
<plurals name="items_selected_count">
<!--
As a developer, you should always supply "one" and "other"

View file

@ -8,8 +8,8 @@ import java.util.List;
*/
public class MediaFolder {
public String folder;
public String path;
public String folderName;
public String absolutePath;
public List<String> filePaths = new ArrayList<>();
public long numberOfFiles;
}

View file

@ -34,6 +34,7 @@ import java.util.List;
* media queries to gain access to media lists for the device.
*/
public class MediaProvider {
private static final String TAG = MediaProvider.class.getSimpleName();
private static final Uri MEDIA_URI = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
/**
@ -72,8 +73,10 @@ public class MediaProvider {
MediaFolder mediaFolder = new MediaFolder();
absolutePathOfImage = cursor.getString(column_index_data);
folderName = cursor.getString(column_index_folder_name);
mediaFolder.path = folderName;
mediaFolder.folder = absolutePathOfImage.substring(0, absolutePathOfImage.lastIndexOf(folderName) + folderName.length());
mediaFolder.folderName = folderName;
mediaFolder.absolutePath = absolutePathOfImage.substring(0, absolutePathOfImage.lastIndexOf(folderName) +
folderName
.length());
mediaFolder.filePaths = new ArrayList<>();
// TODO: This can be done with one query, no limit, but only adding the 8 to the list and still get the
@ -83,7 +86,7 @@ public class MediaProvider {
absolutePathOfImage.substring(0, absolutePathOfImage.lastIndexOf("/")) + "/%'", null,
fileSortOrder);
column_index_data_image = cursorImages.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
Log.e("READ IMAGES", "Reading images for --> " + mediaFolder.folder);
Log.d(TAG, "Reading images for --> " + mediaFolder.absolutePath);
while (cursorImages.moveToNext()) {
mediaFolder.filePaths.add(cursorImages.getString(column_index_data_image));
}

View file

@ -1,37 +1,37 @@
/**
* Nextcloud Android client application
* Nextcloud Android client application
*
* @author Andy Scherzinger
* Copyright (C) 2016 Andy Scherzinger
* Copyright (C) 2016 Nextcloud
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
* @author Andy Scherzinger
* Copyright (C) 2016 Andy Scherzinger
* Copyright (C) 2016 Nextcloud
* <p>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
* <p>
* You should have received a copy of the GNU Affero General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.owncloud.android.ui.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
@ -41,15 +41,16 @@ import com.owncloud.android.ui.adapter.FolderSyncAdapter;
import java.util.List;
import java.util.TimerTask;
import com.owncloud.android.ui.adapter.FolderSyncAdapter;
/**
* Activity displaying all auto-synced folders and/or instant upload media folders.
*/
public class FolderSyncActivity extends FileActivity {
public class FolderSyncActivity extends FileActivity implements FolderSyncAdapter.ClickListener {
private static final String TAG = FolderSyncActivity.class.getSimpleName();
private RecyclerView mRecyclerView;
private FolderSyncAdapter mAdapter;
private LinearLayout mProgress;
private TextView mEmpty;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -69,16 +70,13 @@ public class FolderSyncActivity extends FileActivity {
private void setupContent() {
// TODO setup/initialize UI
mRecyclerView = (RecyclerView) findViewById(android.R.id.list);
mProgress = (LinearLayout) findViewById(android.R.id.progress);
mEmpty = (TextView) findViewById(android.R.id.empty);
final int gridWidth = 4;
mAdapter = new FolderSyncAdapter(this, gridWidth, new FolderSyncAdapter.ClickListener() {
@Override
public void onClick(View view, int section, int relative, int absolute) {
selectItem(FolderSyncActivity.this);
}
}, mRecyclerView);
mAdapter = new FolderSyncAdapter(this, gridWidth, this, mRecyclerView);
final GridLayoutManager lm = new GridLayoutManager(this, gridWidth);
mAdapter.setLayoutManager(lm);
@ -88,11 +86,6 @@ public class FolderSyncActivity extends FileActivity {
load();
}
public static void selectItem(final Activity context) {
// TODO implement selectItem()
return;
}
private void load() {
if (mAdapter.getItemCount() > 0) return;
setListShown(false);
@ -103,7 +96,7 @@ public class FolderSyncActivity extends FileActivity {
final List<MediaFolder> mediaFolders = MediaProvider.getAllShownImagesPath(FolderSyncActivity.this);
for (MediaFolder mediaFolder : mediaFolders) {
Log.d(TAG, mediaFolder.path);
Log.d(TAG, mediaFolder.absolutePath);
}
mHandler.post(new TimerTask() {
@ -119,16 +112,9 @@ public class FolderSyncActivity extends FileActivity {
void setListShown(boolean shown) {
if (mRecyclerView != null) {
mRecyclerView.setVisibility(shown ?
View.VISIBLE : View.GONE);
// TODO show/hide loading visuals
/**
mProgress.setVisibility(shown ?
View.GONE : View.VISIBLE);
mEmpty.setVisibility(shown && mAdapter.getItemCount() == 0 ?
View.VISIBLE : View.GONE);
**/
mRecyclerView.setVisibility(shown ? View.VISIBLE : View.GONE);
mProgress.setVisibility(shown ? View.GONE : View.VISIBLE);
mEmpty.setVisibility(shown && mAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
}
}
@ -164,4 +150,14 @@ public class FolderSyncActivity extends FileActivity {
fileDisplayActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(fileDisplayActivity);
}
@Override
public void onSyncStatusToggleClick(int section, MediaFolder mediaFolder) {
Toast.makeText(this,"Sync Status Clicked for " + mediaFolder.absolutePath,Toast.LENGTH_SHORT).show();
}
@Override
public void onSyncFolderSettingsClick(int section, MediaFolder mediaFolder) {
Toast.makeText(this,"Menu Clicked for " + mediaFolder.absolutePath,Toast.LENGTH_SHORT).show();
}
}

View file

@ -25,14 +25,12 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter;
import com.owncloud.android.R;
@ -49,8 +47,7 @@ import java.util.List;
/**
* Adapter to display all auto-synced folders and/or instant upload media folders.
*/
public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAdapter.MainViewHolder>
implements View.OnClickListener, View.OnTouchListener {
public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAdapter.MainViewHolder> {
private static final String TAG = FolderSyncAdapter.class.getSimpleName();
@ -74,16 +71,6 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
notifyDataSetChanged();
}
@Override
public void onClick(View v) {
}
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
@Override
public int getSectionCount() {
return mMediaFolders.size();
@ -95,29 +82,22 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
}
@Override
public void onBindHeaderViewHolder(MainViewHolder holder, int section) {
final int sectionId = section;
holder.title.setText(mMediaFolders.get(section).folder.substring(mMediaFolders.get(section).folder
.lastIndexOf("/") + 1, mMediaFolders.get(section).folder.length()));
public void onBindHeaderViewHolder(MainViewHolder holder, final int section) {
holder.title.setText(mMediaFolders.get(section).folderName);
holder.syncStatusButton.setVisibility(View.VISIBLE);
holder.syncStatusButton.setTag(section);
holder.syncStatusButton.setOnTouchListener(new View.OnTouchListener() {
holder.syncStatusButton.setOnClickListener(new View.OnClickListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Toast.makeText(mContext, "Sync Status Clicked for " + mMediaFolders.get(sectionId).folder, Toast
.LENGTH_SHORT)
.show();
return true;
public void onClick(View v) {
mListener.onSyncStatusToggleClick(section,mMediaFolders.get(section));
}
});
holder.menuButton.setVisibility(View.VISIBLE);
holder.menuButton.setTag(section);
holder.menuButton.setOnTouchListener(new View.OnTouchListener() {
holder.menuButton.setOnClickListener(new View.OnClickListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Toast.makeText(mContext, "Menu Clicked for " + mMediaFolders.get(sectionId).folder, Toast.LENGTH_SHORT)
.show();
return true;
public void onClick(View v) {
mListener.onSyncFolderSettingsClick(section,mMediaFolders.get(section));
}
});
}
@ -188,7 +168,7 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
}
//holder.itemView.setTag(String.format(Locale.getDefault(), "%d:%d:%d", section, relativePos, absolutePos));
holder.itemView.setOnClickListener(this);
//holder.itemView.setOnClickListener(this);
}
@Override
@ -200,7 +180,8 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
}
public interface ClickListener {
void onClick(View view, int section, int relative, int absolute);
void onSyncStatusToggleClick(int section, MediaFolder mediaFolder);
void onSyncFolderSettingsClick(int section, MediaFolder mediaFolder);
}
static class MainViewHolder extends RecyclerView.ViewHolder {