Przeglądaj źródła

show "contacts backup" eithen in drawer or settings

tobiasKaminsky 7 lat temu
rodzic
commit
e049b56c66

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

@@ -354,7 +354,8 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
             navigationView.getMenu().removeItem(R.id.nav_shared);
         }
 
-        if (!getResources().getBoolean(R.bool.contacts_backup)) {
+        if (!getResources().getBoolean(R.bool.contacts_backup)
+                || !getResources().getBoolean(R.bool.show_drawer_contacts_backup)) {
             navigationView.getMenu().removeItem(R.id.nav_contacts);
         }
 

+ 18 - 0
src/main/java/com/owncloud/android/ui/activity/Preferences.java

@@ -335,6 +335,24 @@ public class Preferences extends PreferenceActivity
             }
         }
 
+        boolean contactsBackupEnabled = !getResources().getBoolean(R.bool.show_drawer_contacts_backup)
+                && getResources().getBoolean(R.bool.contacts_backup);
+        Preference pContactsBackup = findPreference("contacts");
+        if (pCalendarContacts != null) {
+            if (contactsBackupEnabled) {
+                pContactsBackup.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+                    @Override
+                    public boolean onPreferenceClick(Preference preference) {
+                        Intent contactsIntent = new Intent(getApplicationContext(), ContactsPreferenceActivity.class);
+                        startActivity(contactsIntent);
+                        return true;
+                    }
+                });
+            } else {
+                preferenceCategoryMore.removePreference(pContactsBackup);
+            }
+        }
+
         if (!fShowHiddenFilesEnabled && !fPrintEnabled && !fPassCodeEnabled) {
             preferenceScreen.removePreference(preferenceCategoryDetails);
         }

+ 0 - 5
src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactsBackupFragment.java

@@ -74,9 +74,6 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
     @BindView(R.id.contacts_automatic_backup)
     public SwitchCompat backupSwitch;
 
-    @BindView(R.id.contacts_header_restore)
-    public TextView contactsRestoreHeader;
-
     @BindView(R.id.contacts_datepicker)
     public AppCompatButton contactsDatePickerBtn;
 
@@ -202,10 +199,8 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
                             .getFolderContent(backupFolder, false);
 
                     if (backupFiles == null || backupFiles.size() == 0) {
-                        contactsRestoreHeader.setVisibility(View.GONE);
                         contactsDatePickerBtn.setVisibility(View.GONE);
                     } else {
-                        contactsRestoreHeader.setVisibility(View.VISIBLE);
                         contactsDatePickerBtn.setVisibility(View.VISIBLE);
                     }
                 }

+ 22 - 26
src/main/res/layout/contacts_backup_fragment.xml

@@ -73,34 +73,30 @@
                 android:textAppearance="?android:attr/textAppearanceMedium"/>
         </LinearLayout>
 
-        <android.support.v7.widget.AppCompatButton
-            android:id="@+id/contacts_backup_now"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/standard_margin"
-            android:text="@string/contacts_backup_button"
-            android:theme="@style/Button.Primary"/>
-
-        <TextView
-            android:id="@+id/contacts_header_restore"
+        <LinearLayout
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginLeft="@dimen/standard_margin"
-            android:layout_marginRight="@dimen/standard_margin"
-            android:layout_marginTop="@dimen/standard_margin"
-            android:text="@string/contacts_header_restore"
-            android:textColor="@color/primary"
-            android:textStyle="bold"
-            android:visibility="gone"/>
+            android:layout_height="match_parent"
+            android:orientation="horizontal">
 
-        <android.support.v7.widget.AppCompatButton
-            android:id="@+id/contacts_datepicker"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/standard_margin"
-            android:text="@string/contacts_preference_choose_date"
-            android:theme="@style/Button.Primary"
-            android:visibility="gone"/>
+            <android.support.v7.widget.AppCompatButton
+                android:id="@+id/contacts_backup_now"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/standard_margin"
+                android:layout_weight="1"
+                android:text="@string/contacts_backup_button"
+                android:theme="@style/Button.Primary"/>
+
+            <android.support.v7.widget.AppCompatButton
+                android:id="@+id/contacts_datepicker"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/standard_margin"
+                android:layout_weight="1"
+                android:text="@string/contacts_preference_choose_date"
+                android:theme="@style/Button"
+                android:visibility="gone"/>
+        </LinearLayout>
 
     </LinearLayout>
 

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

@@ -83,6 +83,7 @@
     <bool name="shared_enabled">true</bool>
     <bool name="videos_enabled">false</bool>
     <bool name="show_drawer_logout">false</bool>
+    <bool name="show_drawer_contacts_backup">false</bool> <!-- if false it will shown in settings -->
 
     <!-- Various other options -->
     <bool name="allow_profile_click">true</bool>

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

@@ -648,7 +648,7 @@
     <string name="contacts_restore_button">Restore last backup</string>
     <string name="contacts_header_restore">Restore</string>
     <string name="contacts_header_backup">Backup</string>
-    <string name="contacts_automatic_backup">Contacts backup</string>
+    <string name="contacts_automatic_backup">Automatic backup</string>
     <string name="contacts_last_backup">Last backup</string>
     <string name="contacts_read_permission">Permission to read contact list needed</string>
     <string name="contacts_write_permission">Permission to change contact list needed</string>

+ 4 - 0
src/main/res/xml/preferences.xml

@@ -102,6 +102,10 @@
 		<Preference android:title="@string/prefs_calendar_contacts"
 					android:key="calendar_contacts"
 					android:summary="@string/prefs_calendar_contacts_summary" />
+		<Preference
+			android:title="@string/actionbar_contacts"
+			android:key="contacts"
+			android:summary="Daily backup of your contacts"/>
 		<Preference android:title="@string/prefs_help" android:key="help" />
 		<Preference android:title="@string/prefs_recommend" android:key="recommend" />
 		<Preference android:title="@string/prefs_feedback" android:key="feedback" />