浏览代码

enable/disable save button depending on local/remote folder paths present/chosen

AndyScherzinger 8 年之前
父节点
当前提交
aff8a86b37

+ 13 - 0
src/main/java/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.java

@@ -155,6 +155,9 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
             // switch text to create headline
             ((TextView)view.findViewById(R.id.folder_sync_settings_title))
                     .setText(R.string.autoupload_create_new_custom_folder);
+
+            // disable save button
+            view.findViewById(R.id.save).setEnabled(false);
         }
 
         // find/saves UI elements
@@ -234,6 +237,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
     public void setRemoteFolderSummary(String path) {
         mSyncedFolder.setRemotePath(path);
         mRemoteFolderSummary.setText(path);
+        checkAndUpdateSaveButtonState();
     }
 
     /**
@@ -253,6 +257,15 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
                                 mSyncedFolder.getLocalPath()),
                         new File(mSyncedFolder.getLocalPath()).getName(),
                         new StyleSpan(Typeface.BOLD)));
+        checkAndUpdateSaveButtonState();
+    }
+
+    private void checkAndUpdateSaveButtonState() {
+        if(mSyncedFolder.getLocalPath() != null && mSyncedFolder.getRemotePath() != null) {
+            mView.findViewById(R.id.save).setEnabled(true);
+        } else {
+            mView.findViewById(R.id.save).setEnabled(false);
+        }
     }
 
     /**

+ 29 - 0
src/main/res/drawable/borderless_btn.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Nextcloud Android client application
+
+  Copyright (C) 2017 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/>.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item
+        android:state_enabled="false"
+        android:color="@color/half_black" />
+
+    <item
+        android:color="@color/color_accent"/>
+        
+</selector>

+ 1 - 1
src/main/res/values/styles.xml

@@ -116,7 +116,7 @@
 	</style>
 
 	<style name="Button.Borderless" parent="Base.Widget.AppCompat.Button.Borderless">
-		<item name="android:textColor">@color/color_accent</item>
+		<item name="android:textColor">@drawable/borderless_btn</item>
 	</style>
 
 	<style name="Button.Borderless.Destructive" parent="Base.Widget.AppCompat.Button.Borderless">