Эх сурвалжийг харах

Merge pull request #2804 from nextcloud/showMaintenanceInfo

Show maintenance info
Tobias Kaminsky 6 жил өмнө
parent
commit
4f7fcf2bb5

+ 3 - 0
src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java

@@ -289,6 +289,9 @@ public class RefreshFolderOperation extends RemoteOperation {
             if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
             if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
                 removeLocalFolder();
                 removeLocalFolder();
             }
             }
+            if (result.getCode() == ResultCode.MAINTENANCE_MODE) {
+                return result;
+            }
             if (result.isException()) {
             if (result.isException()) {
                 Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
                 Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
                         result.getLogMessage(), result.getException());
                         result.getLogMessage(), result.getException());

+ 14 - 14
src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -1333,21 +1333,21 @@ public class FileDisplayActivity extends HookActivity
                                 !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event);
                                 !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event);
 
 
                         if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.equals(event) &&
                         if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.equals(event) &&
-                                synchResult != null && !synchResult.isSuccess()) {
-
-                            /// TODO refactor and make common
-
-                            if (checkForRemoteOperationError(synchResult)) {
-
-                                requestCredentialsUpdate(context);
-
-                            } else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(
-                                    synchResult.getCode())) {
-
-                                showUntrustedCertDialog(synchResult);
+                                synchResult != null) {
+
+                            if (synchResult.isSuccess()) {
+                                hideInfoBox();
+                            } else {
+                                // TODO refactor and make common
+                                if (checkForRemoteOperationError(synchResult)) {
+                                    requestCredentialsUpdate(context);
+                                } else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(
+                                        synchResult.getCode())) {
+                                    showUntrustedCertDialog(synchResult);
+                                } else if (ResultCode.MAINTENANCE_MODE.equals(synchResult.getCode())) {
+                                    showInfoBox(R.string.maintenance_mode);
+                                }
                             }
                             }
-
-
                         }
                         }
                         removeStickyBroadcast(intent);
                         removeStickyBroadcast(intent);
                         DataHolderUtil.getInstance().delete(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
                         DataHolderUtil.getInstance().delete(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));

+ 25 - 0
src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java

@@ -27,11 +27,15 @@ import android.graphics.PorterDuff;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Bundle;
 import android.support.annotation.ColorInt;
 import android.support.annotation.ColorInt;
+import android.support.annotation.StringRes;
 import android.support.v4.content.ContextCompat;
 import android.support.v4.content.ContextCompat;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.ActionBar;
 import android.support.v7.widget.Toolbar;
 import android.support.v7.widget.Toolbar;
+import android.view.View;
 import android.widget.ImageView;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.ProgressBar;
 import android.widget.ProgressBar;
+import android.widget.TextView;
 
 
 import com.owncloud.android.R;
 import com.owncloud.android.R;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -44,6 +48,8 @@ import com.owncloud.android.utils.ThemeUtils;
 public abstract class ToolbarActivity extends BaseActivity {
 public abstract class ToolbarActivity extends BaseActivity {
     private ProgressBar mProgressBar;
     private ProgressBar mProgressBar;
     private ImageView mPreviewImage;
     private ImageView mPreviewImage;
+    private LinearLayout mInfoBox;
+    private TextView mInfoBoxMessage;
 
 
     @Override
     @Override
     protected void onCreate(Bundle savedInstanceState) {
     protected void onCreate(Bundle savedInstanceState) {
@@ -69,6 +75,8 @@ public abstract class ToolbarActivity extends BaseActivity {
 
 
             ThemeUtils.colorToolbarProgressBar(this, ThemeUtils.primaryColor(this, false));
             ThemeUtils.colorToolbarProgressBar(this, ThemeUtils.primaryColor(this, false));
         }
         }
+        mInfoBox = findViewById(R.id.info_box);
+        mInfoBoxMessage = findViewById(R.id.info_box_message);
 
 
         mPreviewImage = findViewById(R.id.preview_image);
         mPreviewImage = findViewById(R.id.preview_image);
 
 
@@ -144,6 +152,23 @@ public abstract class ToolbarActivity extends BaseActivity {
         return file == null || (file.isFolder() && file.getParentId() == FileDataStorageManager.ROOT_PARENT_ID);
         return file == null || (file.isFolder() && file.getParentId() == FileDataStorageManager.ROOT_PARENT_ID);
     }
     }
 
 
+    /**
+     * shows the toolbar's info box with the given text.
+     *
+     * @param text the text to be displayed
+     */
+    protected final void showInfoBox(@StringRes int text) {
+        mInfoBox.setVisibility(View.VISIBLE);
+        mInfoBoxMessage.setText(text);
+    }
+
+    /**
+     * Hides the toolbar's info box.
+     */
+    protected final void hideInfoBox() {
+        mInfoBox.setVisibility(View.GONE);
+    }
+
     /**
     /**
      * Change the indeterminate mode for the toolbar's progress bar.
      * Change the indeterminate mode for the toolbar's progress bar.
      *
      *

+ 24 - 0
src/main/res/drawable/ic_information_outline.xml

@@ -0,0 +1,24 @@
+<!--
+    @author Google LLC
+    Copyright (C) 2018 Google LLC
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:height="18dp"
+    android:width="18dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+    <path android:fillColor="#757575" android:pathData="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z" />
+</vector>

+ 46 - 0
src/main/res/layout/info_box.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Nextcloud Android client application
+
+  Copyright (C) 2018 Andy Scherzinger
+
+  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/>.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/info_box"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_gravity="center_horizontal|bottom"
+    android:background="@color/filelist_icon_backgorund"
+    android:gravity="center"
+    android:padding="@dimen/standard_half_padding"
+    android:visibility="visible">
+
+    <TextView
+        android:id="@+id/info_box_message"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:drawableLeft="@drawable/ic_information_outline"
+        android:drawablePadding="@dimen/standard_half_padding"
+        android:drawableStart="@drawable/ic_information_outline"
+        android:gravity="center"
+        android:paddingEnd="@dimen/standard_half_margin"
+        android:paddingLeft="@dimen/standard_half_padding"
+        android:paddingRight="@dimen/standard_half_padding"
+        android:paddingStart="@dimen/standard_half_margin"
+        android:textColor="@color/standard_grey"
+        tools:text="@string/offline_mode" />
+
+</LinearLayout>

+ 7 - 5
src/main/res/layout/toolbar_standard.xml

@@ -20,11 +20,11 @@
   License along with this program.  If not, see <http://www.gnu.org/licenses/>.
   License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
 -->
 <android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
 <android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:id="@+id/appbar"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+                                            xmlns:app="http://schemas.android.com/apk/res-auto"
+                                            android:id="@+id/appbar"
+                                            android:layout_width="match_parent"
+                                            android:layout_height="wrap_content"
+                                            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
 
 
     <RelativeLayout
     <RelativeLayout
         android:layout_width="match_parent"
         android:layout_width="match_parent"
@@ -57,4 +57,6 @@
             android:visibility="visible" />
             android:visibility="visible" />
     </RelativeLayout>
     </RelativeLayout>
 
 
+    <include layout="@layout/info_box"/>
+
 </android.support.design.widget.AppBarLayout>
 </android.support.design.widget.AppBarLayout>

+ 4 - 2
src/main/res/layout/toolbar_user_information.xml

@@ -115,7 +115,9 @@
 
 
             </RelativeLayout>
             </RelativeLayout>
 
 
-        </LinearLayout>
+        <include layout="@layout/info_box"/>
+
+    </LinearLayout>
     </RelativeLayout>
     </RelativeLayout>
 
 
-</android.support.design.widget.AppBarLayout>
+</android.support.design.widget.AppBarLayout>

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

@@ -535,6 +535,7 @@
     <string name="confirmation_remove_files_alert">Do you really want to delete the selected items?</string>
     <string name="confirmation_remove_files_alert">Do you really want to delete the selected items?</string>
     <string name="confirmation_remove_folders_alert">Do you really want to delete the selected items and their contents?</string>
     <string name="confirmation_remove_folders_alert">Do you really want to delete the selected items and their contents?</string>
     <string name="maintenance_mode">Server in maintenance mode</string>
     <string name="maintenance_mode">Server in maintenance mode</string>
+    <string name="offline_mode">No internet connection</string>
 
 
     <string name="uploads_view_upload_status_waiting_for_charging">Awaiting charge</string>
     <string name="uploads_view_upload_status_waiting_for_charging">Awaiting charge</string>
     <string name="actionbar_search">Search</string>
     <string name="actionbar_search">Search</string>