Browse Source

Fix all issues

Mario Danic 8 years ago
parent
commit
3522d28fbf

+ 13 - 1
src/main/java/com/owncloud/android/ui/activity/ContactsPreferenceActivity.java

@@ -37,9 +37,12 @@ import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.services.ContactsBackupJob;
 import com.owncloud.android.ui.fragment.FileFragment;
+import com.owncloud.android.ui.fragment.contactsbackup.ContactListFragment;
 import com.owncloud.android.ui.fragment.contactsbackup.ContactsBackupFragment;
 import com.owncloud.android.utils.DisplayUtils;
 
+import org.parceler.Parcels;
+
 import java.util.Set;
 
 /**
@@ -64,9 +67,18 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag
         // setup drawer
         setupDrawer(R.id.nav_contacts);
 
+        Intent intent = getIntent();
         if (savedInstanceState == null) {
             FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
-            transaction.add(R.id.frame_container, new ContactsBackupFragment());
+            if (intent == null || intent.getParcelableExtra(ContactListFragment.FILE_NAME) == null ||
+                    intent.getParcelableExtra(ContactListFragment.ACCOUNT) == null) {
+                transaction.add(R.id.frame_container, new ContactsBackupFragment());
+            } else {
+                OCFile file = Parcels.unwrap(intent.getParcelableExtra(ContactListFragment.FILE_NAME));
+                Account account = Parcels.unwrap(intent.getParcelableExtra(ContactListFragment.ACCOUNT));
+                ContactListFragment contactListFragment = ContactListFragment.newInstance(file, account);
+                transaction.add(R.id.frame_container, contactListFragment);
+            }
             transaction.commit();
         }
 

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

@@ -102,6 +102,7 @@ import com.owncloud.android.utils.MimeTypeUtil;
 import com.owncloud.android.utils.PermissionUtil;
 
 import org.greenrobot.eventbus.EventBus;
+import org.parceler.Parcels;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -1952,12 +1953,10 @@ public class FileDisplayActivity extends HookActivity
     }
 
     public void startContactListFragment(OCFile file) {
-        Fragment contactListFragment = ContactListFragment.newInstance(file, getAccount());
-
-        setSecondFragment(contactListFragment);
-        updateFragmentsVisibility(true);
-        updateActionBarTitleAndHomeButton(file);
-        setFile(file);
+        Intent intent = new Intent(this, ContactsPreferenceActivity.class);
+        intent.putExtra(ContactListFragment.FILE_NAME, Parcels.wrap(file));
+        intent.putExtra(ContactListFragment.ACCOUNT, Parcels.wrap(getAccount()));
+        startActivity(intent);
     }
 
     /**

+ 6 - 2
src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java

@@ -286,9 +286,13 @@ public class ContactListFragment extends FileFragment {
         handler.postDelayed(new Runnable() {
             @Override
             public void run() {
-                getFragmentManager().popBackStack();
+                if (getFragmentManager().getBackStackEntryCount() > 0) {
+                    getFragmentManager().popBackStack();
+                } else {
+                    getActivity().finish();
+                }
             }
-        }, 2500);
+        }, 1750);
     }
 
     private void getAccountForImport() {

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

@@ -87,13 +87,11 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
 
     private DatePickerDialog datePickerDialog;
 
-
     private static final String KEY_CALENDAR_PICKER_OPEN = "IS_CALENDAR_PICKER_OPEN";
     private static final String KEY_CALENDAR_DAY = "CALENDAR_DAY";
     private static final String KEY_CALENDAR_MONTH = "CALENDAR_MONTH";
     private static final String KEY_CALENDAR_YEAR = "CALENDAR_YEAR";
 
-
     @Override
     public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {