فهرست منبع

Working on everything

Mario Danic 8 سال پیش
والد
کامیت
a57cb2e368

+ 1 - 1
src/main/AndroidManifest.xml

@@ -77,7 +77,7 @@
         <activity android:name=".ui.activity.ManageAccountsActivity" />
         <activity android:name=".ui.activity.UserInfoActivity" />
         <activity android:name=".ui.activity.ParticipateActivity" />
-        <activity android:name=".ui.activity.ActivityListActivity" />
+        <activity android:name=".ui.activity.ActivitiesListActivity"/>
         <activity android:name=".ui.activity.FolderSyncActivity" />
         <activity android:name=".ui.activity.UploadFilesActivity" />
         <activity android:name=".ui.activity.ReceiveExternalFilesActivity"

+ 63 - 14
src/main/java/com/owncloud/android/ui/activity/ActivityListActivity.java → src/main/java/com/owncloud/android/ui/activity/ActivitiesListActivity.java

@@ -2,7 +2,9 @@
  * Nextcloud Android client application
  *
  * @author Andy Scherzinger
+ * @author Mario Danic
  * Copyright (C) 2017 Andy Scherzinger
+ * Copyright (C) 2017 Mario Danic
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -22,10 +24,14 @@ package com.owncloud.android.ui.activity;
 
 import android.accounts.Account;
 import android.os.Bundle;
+import android.support.v7.widget.DividerItemDecoration;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.view.MenuItem;
 import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
 import android.widget.TextView;
 
 import com.owncloud.android.R;
@@ -34,12 +40,12 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.resources.activities.GetRemoteActivitiesOperation;
-import com.owncloud.android.lib.resources.activities.models.Activity;
 import com.owncloud.android.ui.adapter.ActivityListAdapter;
 
 import java.util.ArrayList;
 import java.util.List;
 
+import butterknife.BindString;
 import butterknife.BindView;
 import butterknife.ButterKnife;
 import butterknife.Unbinder;
@@ -47,16 +53,33 @@ import butterknife.Unbinder;
 /**
  * Activity displaying all server side stored activity items.
  */
-public class ActivityListActivity extends FileActivity {
+public class ActivitiesListActivity extends FileActivity {
 
-    private static final String TAG = ActivityListActivity.class.getSimpleName();
+    private static final String TAG = ActivitiesListActivity.class.getSimpleName();
 
+    @BindView(R.id.empty_list_view)
+    public LinearLayout emptyContentContainer;
+
+    @BindView(R.id.empty_list_view_text)
+    public TextView emptyContentMessage;
+
+    @BindView(R.id.empty_list_view_headline)
+    public TextView emptyContentHeadline;
+
+    @BindView(R.id.empty_list_icon)
+    public ImageView emptyContentIcon;
+
+    @BindView(R.id.empty_list_progress)
+    public ProgressBar emptyContentProgressBar;
 
     @BindView(android.R.id.list)
     public RecyclerView recyclerView;
 
-    @BindView((android.R.id.empty))
-    public TextView empty;
+    @BindString(R.string.activities_no_results_headline)
+    public String noResultsHeadline;
+
+    @BindString(R.string.activities_no_results_message)
+    public String noResultsMessage;
 
     private ActivityListAdapter adapter;
     private Unbinder unbinder;
@@ -66,14 +89,14 @@ public class ActivityListActivity extends FileActivity {
         Log_OC.v(TAG, "onCreate() start");
         super.onCreate(savedInstanceState);
 
-        setContentView(R.layout.activitiy_list_layout);
+        setContentView(R.layout.activity_list_layout);
         unbinder = ButterKnife.bind(this);
         // setup toolbar
         setupToolbar();
 
         // setup drawer
         setupDrawer(R.id.nav_activity);
-        getSupportActionBar().setTitle(getString(R.string.drawer_item_activity));
+        getSupportActionBar().setTitle(getString(R.string.drawer_item_activities));
 
         setupContent();
     }
@@ -87,11 +110,18 @@ public class ActivityListActivity extends FileActivity {
      * sets up the UI elements and loads all activity items.
      */
     private void setupContent() {
-        // TODO add all (recycler) view relevant code + data loading + adapter etc.
+        emptyContentIcon.setImageResource(R.drawable.ic_activity_light_grey);
+        setLoadingMessage();
 
         adapter = new ActivityListAdapter(this);
         recyclerView.setAdapter(adapter);
-        recyclerView.setLayoutManager(new LinearLayoutManager(this));
+
+        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
+        DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
+                layoutManager.getOrientation());
+
+        recyclerView.setLayoutManager(layoutManager);
+        recyclerView.addItemDecoration(dividerItemDecoration);
 
         fetchAndSetData();
     }
@@ -99,11 +129,11 @@ public class ActivityListActivity extends FileActivity {
     private void fetchAndSetData() {
         Thread t = new Thread(new Runnable() {
             public void run() {
-                Account account = AccountUtils.getCurrentOwnCloudAccount(ActivityListActivity.this);
+                Account account = AccountUtils.getCurrentOwnCloudAccount(ActivitiesListActivity.this);
                 RemoteOperation getRemoteNotificationOperation = new GetRemoteActivitiesOperation();
                 Log_OC.d(TAG, "BEFORE getRemoteActivitiesOperation.execute");
                 final RemoteOperationResult result =
-                        getRemoteNotificationOperation.execute(account, ActivityListActivity.this);
+                        getRemoteNotificationOperation.execute(account, ActivitiesListActivity.this);
 
                 if (result.isSuccess() && result.getData() != null) {
                     final ArrayList<Object> activities = result.getData();
@@ -113,10 +143,10 @@ public class ActivityListActivity extends FileActivity {
                         public void run() {
                             if (activities.size() > 0) {
                                 populateList(activities);
-                                empty.setVisibility(View.GONE);
+                                emptyContentContainer.setVisibility(View.GONE);
                                 recyclerView.setVisibility(View.VISIBLE);
                             } else {
-                                empty.setVisibility(View.VISIBLE);
+                                setEmptyContent(noResultsHeadline, noResultsMessage);
                             }
                         }
                     });
@@ -126,7 +156,7 @@ public class ActivityListActivity extends FileActivity {
                     runOnUiThread(new Runnable() {
                         @Override
                         public void run() {
-                            empty.setVisibility(View.VISIBLE);
+                            setEmptyContent(noResultsHeadline, result.getLogMessage());
                         }
                     });
                 }
@@ -159,4 +189,23 @@ public class ActivityListActivity extends FileActivity {
 
         return retval;
     }
+
+    private void setLoadingMessage() {
+        emptyContentHeadline.setText(R.string.file_list_loading);
+        emptyContentMessage.setText("");
+
+        emptyContentIcon.setVisibility(View.GONE);
+        emptyContentProgressBar.setVisibility(View.VISIBLE);
+    }
+
+    private void setEmptyContent(String headline, String message) {
+        if (emptyContentContainer != null && emptyContentMessage != null) {
+            emptyContentHeadline.setText(headline);
+            emptyContentMessage.setText(message);
+
+            emptyContentProgressBar.setVisibility(View.GONE);
+            emptyContentIcon.setVisibility(View.VISIBLE);
+        }
+    }
+
 }

+ 1 - 1
src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java

@@ -306,7 +306,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
                 startActivity(uploadListIntent);
                 break;
             case R.id.nav_activity:
-                Intent activityIntent = new Intent(getApplicationContext(), ActivityListActivity.class);
+                Intent activityIntent = new Intent(getApplicationContext(), ActivitiesListActivity.class);
                 startActivity(activityIntent);
                 break;
             case R.id.nav_folder_sync:

+ 25 - 19
src/main/java/com/owncloud/android/ui/adapter/ActivityListAdapter.java

@@ -1,3 +1,22 @@
+/**
+ * Nextcloud Android client application
+ *
+ * @author Alejandro Bautista
+ * Copyright (C) 2017 Alejandro Bautista
+ *
+ * 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/>.
+ */
 package com.owncloud.android.ui.adapter;
 
 import android.content.Context;
@@ -19,16 +38,16 @@ import com.caverock.androidsvg.SVG;
 import com.owncloud.android.R;
 import com.owncloud.android.lib.resources.activities.models.Activity;
 import com.owncloud.android.utils.DisplayUtils;
-import com.owncloud.android.utils.SvgDecoder;
-import com.owncloud.android.utils.SvgDrawableTranscoder;
-import com.owncloud.android.utils.SvgSoftwareLayerSetter;
+import com.owncloud.android.utils.svg.SvgDecoder;
+import com.owncloud.android.utils.svg.SvgDrawableTranscoder;
+import com.owncloud.android.utils.svg.SvgSoftwareLayerSetter;
 
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 
 /**
- * Created by alejandro on 28/03/17.
+ * Adapter for the activity view
  */
 
 public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@@ -60,10 +79,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
         ((ActivityViewHolder)holder).subject.setText(activity.getSubject());
         ((ActivityViewHolder)holder).message.setText(activity.getMessage());
 
-        // Todo set proper action icon (to be clarified how to pick)
-
         downloadIcon(activity.getIcon(),((ActivityViewHolder)holder).activityIcon);
-        //((ActivityViewHolder)holder).activityIcon.setImageResource(R.drawable.ic_action_share);
     }
 
     private void downloadIcon(String icon, ImageView itemViewType) {
@@ -75,8 +91,8 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
                 .sourceEncoder(new StreamEncoder())
                 .cacheDecoder(new FileToStreamDecoder<SVG>(new SvgDecoder()))
                 .decoder(new SvgDecoder())
-                .placeholder(R.drawable.ic_menu_archive)
-                .error(R.drawable.ic_web)
+                .placeholder(R.drawable.ic_activity)
+                .error(R.drawable.ic_activity)
                 .animate(android.R.anim.fade_in)
                 .listener(new SvgSoftwareLayerSetter<Uri>());
 
@@ -84,7 +100,6 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
         Uri uri = Uri.parse(icon);
         requestBuilder
                 .diskCacheStrategy(DiskCacheStrategy.SOURCE)
-                // SVG cannot be serialized so it's not worth to cache it
                 .load(uri)
                 .into(itemViewType);
     }
@@ -94,15 +109,6 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
         return mValues.size();
     }
 
-
-    class HeaderViewHolder extends RecyclerView.ViewHolder {
-
-        public HeaderViewHolder(View v) {
-            super(v);
-        }
-
-    }
-
     class ActivityViewHolder extends RecyclerView.ViewHolder {
 
         private final ImageView activityIcon;

+ 0 - 2
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -999,6 +999,4 @@ public class OCFileListFragment extends ExtendedListFragment implements Extended
         editor.putBoolean(String.valueOf(mFile.getFileId()), setGrid);
         editor.apply();
     }
-
-
 }

+ 11 - 2
src/main/java/com/owncloud/android/utils/SvgDecoder.java → src/main/java/com/owncloud/android/utils/svg/SvgDecoder.java

@@ -1,6 +1,15 @@
-package com.owncloud.android.utils;
-
+/*
+ * Nextcloud Android client application
+ *
+ * Copyright 2014 Google, Inc. All rights reserved.
+ * Licenced under the BSD licence
+ *
+ * Borrowed from:
+ * https://github.com/bumptech/glide/blob/master/samples/svg/src/main/java/com/bumptech/glide/samples/svg/
+ * SvgDecoder.java
+ */
 
+package com.owncloud.android.utils.svg;
 
 import com.bumptech.glide.load.ResourceDecoder;
 import com.bumptech.glide.load.engine.Resource;

+ 10 - 4
src/main/java/com/owncloud/android/utils/SvgDrawableTranscoder.java → src/main/java/com/owncloud/android/utils/svg/SvgDrawableTranscoder.java

@@ -1,8 +1,14 @@
-package com.owncloud.android.utils;
-
-/**
- * Created by alejandro on 29/03/17.
+/*
+ * Nextcloud Android client application
+ *
+ * Copyright 2014 Google, Inc. All rights reserved.
+ * Licenced under the BSD licence
+ *
+ * Borrowed from:
+ * https://github.com/bumptech/glide/blob/master/samples/svg/src/main/java/com/bumptech/glide/samples/svg/
+ * SvgDrawableTranscoder.java
  */
+package com.owncloud.android.utils.svg;
 
 import android.graphics.Picture;
 import android.graphics.drawable.PictureDrawable;

+ 11 - 8
src/main/java/com/owncloud/android/utils/SvgSoftwareLayerSetter.java → src/main/java/com/owncloud/android/utils/svg/SvgSoftwareLayerSetter.java

@@ -1,4 +1,14 @@
-package com.owncloud.android.utils;
+/*
+ * Nextcloud Android client application
+ *
+ * Copyright 2014 Google, Inc. All rights reserved.
+ * Licenced under the BSD licence
+ *
+ * Borrowed from:
+ * https://github.com/bumptech/glide/blob/master/samples/svg/src/main/java/com/bumptech/glide/samples/svg/
+ * SvgSoftwareLayerSetter.java
+ */
+package com.owncloud.android.utils.svg;
 
 import android.annotation.TargetApi;
 import android.graphics.drawable.PictureDrawable;
@@ -9,13 +19,6 @@ import com.bumptech.glide.request.RequestListener;
 import com.bumptech.glide.request.target.ImageViewTarget;
 import com.bumptech.glide.request.target.Target;
 
-/**
- * Listener which updates the {@link ImageView} to be software rendered,
- * because {@link com.caverock.androidsvg.SVG SVG}/{@link android.graphics.Picture Picture}
- * can't render on a hardware backed {@link android.graphics.Canvas Canvas}.
- *
- * @param <T> not used, here to prevent unchecked warnings at usage
- */
 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
 public class SvgSoftwareLayerSetter<T> implements RequestListener<T, PictureDrawable> {
 

+ 1 - 33
src/main/res/layout/activitiy_list_layout.xml → src/main/res/layout/activity_list_layout.xml

@@ -49,39 +49,7 @@
                 android:layout_marginLeft="-3dp"
                 android:layout_marginBottom="-3dp"/>
 
-            <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/activitySyncProgressBar"
-                    android:layout_width="72dp"
-                    android:layout_height="72dp"
-                    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/activity_list_loading_activity"
-                    android:textSize="26sp"/>
-            </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:text="@string/activity_list_no_results"
-                android:visibility="visible" />
+            <include layout="@layout/empty_list"/>
         </FrameLayout>
 
     </LinearLayout>

+ 1 - 1
src/main/res/menu/drawer_menu.xml

@@ -41,7 +41,7 @@
             android:orderInCategory="0"
             android:id="@+id/nav_activity"
             android:icon="@drawable/ic_activity"
-            android:title="@string/drawer_item_activity"/>
+            android:title="@string/drawer_item_activities"/>
         <item
             android:orderInCategory="0"
             android:id="@+id/nav_folder_sync"

+ 6 - 1
src/main/res/values/strings.xml

@@ -25,7 +25,7 @@
     <string name="drawer_item_on_device">On device</string>
     <string name="drawer_item_settings">Settings</string>
     <string name="drawer_item_uploads_list">Uploads</string>
-    <string name="drawer_item_activity">Activity</string>
+    <string name="drawer_item_activities">Activities</string>
     <string name="drawer_quota">%1$s of %2$s used</string>
 	<string name="drawer_close">Close</string>
     <string name="drawer_open">Open</string>
@@ -587,4 +587,9 @@
 
     <string name="user_information_description">User information</string>
 
+    <!-- Activities -->
+    <string name="activities_no_results_headline">No activities</string>
+    <string name="activities_no_results_message">Please check back later.</string>
+
+
 </resources>