Browse Source

Add SearchType.OFFLINE_MODE

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 10 months ago
parent
commit
40b5821762

+ 7 - 1
app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -1382,7 +1382,13 @@ public class FileDisplayActivity extends FileActivity
                 if (MainApp.isOnlyOnDevice()) {
                     ocFileListFragment.setMessageForEmptyList(R.string.file_list_empty_headline, R.string.file_list_empty_on_device, R.drawable.ic_list_empty_folder, true);
                 } else {
-                    ocFileListFragment.setEmptyListMessage(SearchType.NO_SEARCH);
+                    connectivityService.isNetworkAndServerAvailable(result -> {
+                        if (result) {
+                            ocFileListFragment.setEmptyListMessage(SearchType.NO_SEARCH);
+                        } else {
+                            ocFileListFragment.setEmptyListMessage(SearchType.OFFLINE_MODE);
+                        }
+                    });
                 }
             }
         } else {

+ 64 - 61
app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java

@@ -43,6 +43,7 @@ import android.widget.TextView;
 import com.google.android.material.button.MaterialButton;
 import com.nextcloud.client.account.UserAccountManager;
 import com.nextcloud.client.di.Injectable;
+import com.nextcloud.client.network.ConnectivityService;
 import com.nextcloud.client.preferences.AppPreferences;
 import com.nextcloud.client.preferences.AppPreferencesImpl;
 import com.owncloud.android.MainApp;
@@ -52,6 +53,7 @@ import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.resources.files.SearchRemoteOperation;
 import com.owncloud.android.lib.resources.status.OwnCloudVersion;
 import com.owncloud.android.ui.EmptyRecyclerView;
+import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.ui.activity.FolderPickerActivity;
 import com.owncloud.android.ui.activity.OnEnforceableRefreshListener;
@@ -578,69 +580,67 @@ public class ExtendedListFragment extends Fragment implements
      */
     public void setMessageForEmptyList(@StringRes final int headline, @StringRes final int message,
                                        @DrawableRes final int icon, final boolean tintIcon) {
-        new Handler(Looper.getMainLooper()).post(new Runnable() {
-            @Override
-            public void run() {
-
-                if (mEmptyListContainer != null && mEmptyListMessage != null) {
-                    mEmptyListHeadline.setText(headline);
-                    mEmptyListMessage.setText(message);
-
-                    if (tintIcon) {
-                        if (getContext() != null) {
-                            mEmptyListIcon.setImageDrawable(
-                                viewThemeUtils.platform.tintPrimaryDrawable(getContext(), icon));
-                        }
-                    } else {
-                        mEmptyListIcon.setImageResource(icon);
-                    }
+        new Handler(Looper.getMainLooper()).post(() -> {
 
-                    mEmptyListIcon.setVisibility(View.VISIBLE);
-                    mEmptyListMessage.setVisibility(View.VISIBLE);
+            if (mEmptyListContainer != null && mEmptyListMessage != null) {
+                mEmptyListHeadline.setText(headline);
+                mEmptyListMessage.setText(message);
+
+                if (tintIcon) {
+                    if (getContext() != null) {
+                        mEmptyListIcon.setImageDrawable(
+                            viewThemeUtils.platform.tintPrimaryDrawable(getContext(), icon));
+                    }
+                } else {
+                    mEmptyListIcon.setImageResource(icon);
                 }
+
+                mEmptyListIcon.setVisibility(View.VISIBLE);
+                mEmptyListMessage.setVisibility(View.VISIBLE);
             }
         });
     }
 
     public void setEmptyListMessage(final SearchType searchType) {
-        new Handler(Looper.getMainLooper()).post(new Runnable() {
-            @Override
-            public void run() {
-
-                if (searchType == SearchType.NO_SEARCH) {
-                    setMessageForEmptyList(R.string.file_list_empty_headline,
-                                           R.string.file_list_empty,
-                                           R.drawable.ic_list_empty_folder,
-                                           true);
-                } else if (searchType == SearchType.FILE_SEARCH) {
-                    setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
-                                           R.string.file_list_empty,
-                                           R.drawable.ic_search_light_grey);
-                } else if (searchType == SearchType.FAVORITE_SEARCH) {
-                    setMessageForEmptyList(R.string.file_list_empty_favorite_headline,
-                                           R.string.file_list_empty_favorites_filter_list,
-                                           R.drawable.ic_star_light_yellow);
-                } else if (searchType == SearchType.RECENTLY_MODIFIED_SEARCH) {
-                    setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
-                                           R.string.file_list_empty_recently_modified,
-                                           R.drawable.ic_list_empty_recent);
-                } else if (searchType == SearchType.REGULAR_FILTER) {
-                    setMessageForEmptyList(R.string.file_list_empty_headline_search,
-                                           R.string.file_list_empty_search,
-                                           R.drawable.ic_search_light_grey);
-                } else if (searchType == SearchType.SHARED_FILTER) {
-                    setMessageForEmptyList(R.string.file_list_empty_shared_headline,
-                                           R.string.file_list_empty_shared,
-                                           R.drawable.ic_list_empty_shared);
-                } else if (searchType == SearchType.GALLERY_SEARCH) {
-                    setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
-                                           R.string.file_list_empty_gallery,
-                                           R.drawable.file_image);
-                } else if (searchType == SearchType.LOCAL_SEARCH) {
-                    setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
-                                           R.string.file_list_empty_local_search,
-                                           R.drawable.ic_search_light_grey);
-                }
+        new Handler(Looper.getMainLooper()).post(() -> {
+            if (searchType == SearchType.OFFLINE_MODE) {
+                setMessageForEmptyList(R.string.offline_mode_info_title,
+                                       R.string.offline_mode_info_description,
+                                       R.drawable.ic_cloud_sync,
+                                       true);
+            } else if (searchType == SearchType.NO_SEARCH) {
+                setMessageForEmptyList(R.string.file_list_empty_headline,
+                                       R.string.file_list_empty,
+                                       R.drawable.ic_list_empty_folder,
+                                       true);
+            } else if (searchType == SearchType.FILE_SEARCH) {
+                setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
+                                       R.string.file_list_empty,
+                                       R.drawable.ic_search_light_grey);
+            } else if (searchType == SearchType.FAVORITE_SEARCH) {
+                setMessageForEmptyList(R.string.file_list_empty_favorite_headline,
+                                       R.string.file_list_empty_favorites_filter_list,
+                                       R.drawable.ic_star_light_yellow);
+            } else if (searchType == SearchType.RECENTLY_MODIFIED_SEARCH) {
+                setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
+                                       R.string.file_list_empty_recently_modified,
+                                       R.drawable.ic_list_empty_recent);
+            } else if (searchType == SearchType.REGULAR_FILTER) {
+                setMessageForEmptyList(R.string.file_list_empty_headline_search,
+                                       R.string.file_list_empty_search,
+                                       R.drawable.ic_search_light_grey);
+            } else if (searchType == SearchType.SHARED_FILTER) {
+                setMessageForEmptyList(R.string.file_list_empty_shared_headline,
+                                       R.string.file_list_empty_shared,
+                                       R.drawable.ic_list_empty_shared);
+            } else if (searchType == SearchType.GALLERY_SEARCH) {
+                setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
+                                       R.string.file_list_empty_gallery,
+                                       R.drawable.file_image);
+            } else if (searchType == SearchType.LOCAL_SEARCH) {
+                setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
+                                       R.string.file_list_empty_local_search,
+                                       R.drawable.ic_search_light_grey);
             }
         });
     }
@@ -650,11 +650,14 @@ public class ExtendedListFragment extends Fragment implements
      */
     public void setEmptyListLoadingMessage() {
         new Handler(Looper.getMainLooper()).post(() -> {
-            if (mEmptyListContainer != null && mEmptyListMessage != null) {
-                mEmptyListHeadline.setText(R.string.file_list_loading);
-                mEmptyListMessage.setText("");
-
-                mEmptyListIcon.setVisibility(View.GONE);
+            if (requireActivity() instanceof FileActivity fileActivity) {
+                fileActivity.connectivityService.isNetworkAndServerAvailable(result -> {
+                    if (!result || mEmptyListContainer == null || mEmptyListMessage == null) return;
+
+                    mEmptyListHeadline.setText(R.string.file_list_loading);
+                    mEmptyListMessage.setText("");
+                    mEmptyListIcon.setVisibility(View.GONE);
+                });
             }
         });
     }

+ 2 - 1
app/src/main/java/com/owncloud/android/ui/fragment/SearchType.kt

@@ -22,5 +22,6 @@ enum class SearchType : Parcelable {
 
     // not a real filter, but nevertheless
     SHARED_FILTER,
-    GROUPFOLDER
+    GROUPFOLDER,
+    OFFLINE_MODE
 }

+ 5 - 0
app/src/main/res/drawable/ic_cloud_sync.xml

@@ -0,0 +1,5 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
+      
+    <path android:fillColor="@android:color/white" android:pathData="M21.5,14.98c-0.02,0 -0.03,0 -0.05,0.01C21.2,13.3 19.76,12 18,12c-1.4,0 -2.6,0.83 -3.16,2.02C13.26,14.1 12,15.4 12,17c0,1.66 1.34,3 3,3l6.5,-0.02c1.38,0 2.5,-1.12 2.5,-2.5S22.88,14.98 21.5,14.98zM10,4.26v2.09C7.67,7.18 6,9.39 6,12c0,1.77 0.78,3.34 2,4.44V14h2v6H4v-2h2.73C5.06,16.54 4,14.4 4,12C4,8.27 6.55,5.15 10,4.26zM20,6h-2.73c1.43,1.26 2.41,3.01 2.66,5l-2.02,0C17.68,9.64 16.98,8.45 16,7.56V10h-2V4h6V6z"/>
+    
+</vector>

+ 3 - 1
app/src/main/res/values/strings.xml

@@ -610,7 +610,8 @@
     <string name="confirmation_remove_folders_alert">Do you really want to delete the selected items and their contents?</string>
     <string name="maintenance_mode">Server is in maintenance mode</string>
     <string name="offline_mode">No internet connection</string>
-
+    <string name="offline_mode_info_title">You\'re Offline, But Work Continues</string>
+    <string name="offline_mode_info_description">Even without an internet connection, you can organize your folders, create files. Once you\'re back online, your pending actions will automatically sync.</string>
     <string name="uploads_view_upload_status_waiting_for_charging">Awaiting charge</string>
     <string name="actionbar_search">Search</string>
     <string name="drawer_synced_folders">Auto upload</string>
@@ -1176,6 +1177,7 @@
     <string name="pin_home">Pin to Home screen</string>
     <string name="pin_shortcut_label">Open %1$s</string>
     <string name="displays_mnemonic">Displays your 12 word passphrase</string>
+    <string name="encrypted_folder_setup_no_internet_error">You need an internet connection to set up the encrypted folder</string>
     <string name="prefs_setup_e2e">Set up end-to-end encryption</string>
     <string name="prefs_e2e_active">End-to-end encryption is set up!</string>
     <string name="prefs_remove_e2e">Remove encryption locally</string>