Browse Source

moved to switch instead of icon

AndyScherzinger 8 năm trước cách đây
mục cha
commit
34003e922f

+ 46 - 27
res/layout/folder_sync_settings_layout.xml

@@ -26,19 +26,54 @@
               android:orientation="vertical"
               android:padding="@dimen/standard_padding">
 
-    <TextView
-        android:id="@+id/folder_sync_settings_title"
+    <LinearLayout
+        android:id="@+id/top_title"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:text="@string/folder_sync_preferences"
-        android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
+        android:layout_height="wrap_content">
 
-    <TextView
-        android:id="@+id/folder_sync_settings_subtitle"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:text="@string/placeholder_filename"
-        android:textSize="@dimen/two_line_primary_text_size"/>
+        <LinearLayout
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:paddingBottom="@dimen/standard_padding"
+            android:paddingTop="@dimen/standard_padding"
+            android:orientation="vertical">
+
+            <TextView
+                android:id="@+id/folder_sync_settings_title"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/folder_sync_preferences"
+                android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
+
+            <TextView
+                android:id="@+id/folder_sync_settings_subtitle"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/placeholder_filename"
+                android:textSize="@dimen/two_line_primary_text_size"/>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:gravity="end|top"
+            android:orientation="vertical"
+            android:paddingTop="@dimen/standard_padding"
+            android:paddingLeft="@dimen/standard_padding">
+
+            <android.support.v7.widget.SwitchCompat
+                android:id="@+id/sync_enabled"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:background="@null"
+                android:clickable="false"
+                android:focusable="false"/>
+
+        </LinearLayout>
+
+    </LinearLayout>
 
     <ScrollView
         android:id="@+id/details_scroll"
@@ -88,22 +123,6 @@
 
                 </RelativeLayout>
 
-                <LinearLayout
-                    android:id="@+id/local_folder_frame"
-                    android:layout_width="wrap_content"
-                    android:layout_height="match_parent"
-                    android:gravity="end|center_vertical"
-                    android:orientation="vertical"
-                    android:paddingLeft="@dimen/standard_padding">
-
-                    <ImageView
-                        android:id="@+id/local_folder_status_icon"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:src="@drawable/ic_cloud_sync_off"/>
-
-                </LinearLayout>
-
             </LinearLayout>
 
             <LinearLayout

+ 5 - 9
src/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.java

@@ -28,12 +28,12 @@ import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.v4.app.DialogFragment;
 import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.SwitchCompat;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.widget.CheckBox;
-import android.widget.ImageView;
 import android.widget.TextView;
 
 import com.owncloud.android.R;
@@ -54,7 +54,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
     private CharSequence[] mUploadBehaviorItemStrings;
 
     protected View mView = null;
-    private ImageView mEnabledIcon;
+    private SwitchCompat mEnabledSwitch;
     private CheckBox mUploadOnWifiCheckbox;
     private CheckBox mUploadOnChargingCheckbox;
     private CheckBox mUploadUseSubfoldersCheckbox;
@@ -122,7 +122,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
     private void setupDialogElements(View view) {
         // find/saves UI elements
         mLocalFolderName = (TextView )view.findViewById(R.id.folder_sync_settings_subtitle);
-        mEnabledIcon = (ImageView) view.findViewById(R.id.local_folder_status_icon);
+        mEnabledSwitch = (SwitchCompat) view.findViewById(R.id.sync_enabled);
         mLocalFolderSummary = (TextView) view.findViewById(R.id.local_folder_summary);
         mRemoteFolderSummary = (TextView) view.findViewById(R.id.remote_folder_summary);
 
@@ -153,11 +153,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
      */
     private void setEnabled(boolean enabled) {
         mSyncedFolder.setEnabled(enabled);
-        if(enabled) {
-            mEnabledIcon.setImageResource(R.drawable.ic_cloud_sync_on);
-        } else {
-            mEnabledIcon.setImageResource(R.drawable.ic_cloud_sync_off);
-        }
+        mEnabledSwitch.setChecked(enabled);
     }
 
     /**
@@ -218,7 +214,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
             }
         });
 
-        view.findViewById(R.id.local_folder_container).setOnClickListener(new OnClickListener() {
+        view.findViewById(R.id.sync_enabled).setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View v) {
                 setEnabled(!mSyncedFolder.getEnabled());