From dc1b7b3958ceee6cdf7d64b701a01ae466b65f5e Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 26 Sep 2016 23:12:20 +0200 Subject: [PATCH] layout tweaking, better listener support, loading visualization --- res/layout/folder_sync_item_header.xml | 42 ++++----- res/layout/folder_sync_layout.xml | 54 ++++++++++-- res/values/strings.xml | 2 + .../android/datamodel/MediaFolder.java | 4 +- .../android/datamodel/MediaProvider.java | 9 +- .../ui/activity/FolderSyncActivity.java | 86 +++++++++---------- .../android/ui/adapter/FolderSyncAdapter.java | 43 +++------- 7 files changed, 133 insertions(+), 107 deletions(-) diff --git a/res/layout/folder_sync_item_header.xml b/res/layout/folder_sync_item_header.xml index 49f7593bc9..be6b16a5cf 100644 --- a/res/layout/folder_sync_item_header.xml +++ b/res/layout/folder_sync_item_header.xml @@ -21,9 +21,9 @@ + android:paddingTop="@dimen/standard_half_padding" + android:paddingBottom="@dimen/standard_half_padding" + android:paddingLeft="@dimen/standard_padding"> + android:textColor="?android:textColorPrimary" + android:textStyle="bold"/> - - + android:layout_alignParentRight="true"> + + diff --git a/res/layout/folder_sync_layout.xml b/res/layout/folder_sync_layout.xml index da581448d0..dc124ff602 100644 --- a/res/layout/folder_sync_layout.xml +++ b/res/layout/folder_sync_layout.xml @@ -34,13 +34,55 @@ - + android:layout_height="match_parent"> + + + + + + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index f4d0c0c97a..6e27d69048 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -494,6 +494,8 @@ Contribute as a developer, see <a href="https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md">CONTRIBUTING.md</a> for details Move to… Copy to… + Loading folders… + No results " + mediaFolder.folder); + Log.d(TAG, "Reading images for --> " + mediaFolder.absolutePath); while (cursorImages.moveToNext()) { mediaFolder.filePaths.add(cursorImages.getString(column_index_data_image)); } diff --git a/src/com/owncloud/android/ui/activity/FolderSyncActivity.java b/src/com/owncloud/android/ui/activity/FolderSyncActivity.java index f2ba8198c9..080b57e83d 100644 --- a/src/com/owncloud/android/ui/activity/FolderSyncActivity.java +++ b/src/com/owncloud/android/ui/activity/FolderSyncActivity.java @@ -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 . + * @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 . */ 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 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(); + } } diff --git a/src/com/owncloud/android/ui/adapter/FolderSyncAdapter.java b/src/com/owncloud/android/ui/adapter/FolderSyncAdapter.java index 99fe8b40a6..f7a1ed5236 100644 --- a/src/com/owncloud/android/ui/adapter/FolderSyncAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FolderSyncAdapter.java @@ -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 - implements View.OnClickListener, View.OnTouchListener { +public class FolderSyncAdapter extends SectionedRecyclerViewAdapter { private static final String TAG = FolderSyncAdapter.class.getSimpleName(); @@ -74,16 +71,6 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter