فهرست منبع

When user goes to set the upload path, the folder list view is shown in the current path set

jabarros 10 سال پیش
والد
کامیت
c2ec3f783d

+ 0 - 2
src/com/owncloud/android/ui/PreferenceWithLongSummary.java

@@ -21,9 +21,7 @@ import android.content.Context;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.View;
-import android.webkit.WebSettings.TextSize;
 import android.widget.TextView;
-import android.preference.CheckBoxPreference;
 import android.preference.Preference;
 
 public class PreferenceWithLongSummary extends Preference{

+ 3 - 3
src/com/owncloud/android/ui/activity/FolderPickerActivity.java

@@ -62,7 +62,7 @@ import com.owncloud.android.utils.DisplayUtils;
 import com.owncloud.android.utils.ErrorMessageAdapter;
 import com.owncloud.android.lib.common.utils.Log_OC;
 
-public class FolderPickerActivity extends HookActivity implements FileFragment.ContainerActivity, 
+public class FolderPickerActivity extends FileActivity implements FileFragment.ContainerActivity, 
     OnClickListener, OnEnforceableRefreshListener {
 
     public static final String EXTRA_CURRENT_FOLDER = UploadFilesActivity.class.getCanonicalName() + ".EXTRA_CURRENT_FOLDER";
@@ -180,7 +180,7 @@ public class FolderPickerActivity extends HookActivity implements FileFragment.C
         }
     }
 
-    private OCFileListFragment getListOfFilesFragment() {
+    protected OCFileListFragment getListOfFilesFragment() {
         Fragment listOfFiles = getSupportFragmentManager().findFragmentByTag(FolderPickerActivity.TAG_LIST_OF_FOLDERS);
         if (listOfFiles != null) {
             return (OCFileListFragment)listOfFiles;
@@ -341,7 +341,7 @@ public class FolderPickerActivity extends HookActivity implements FileFragment.C
         }
     }
 
-    private void updateNavigationElementsInActionBar() {
+    protected void updateNavigationElementsInActionBar() {
         ActionBar actionBar = getSupportActionBar();
         OCFile currentDir = getCurrentFolder();
         boolean atRoot = (currentDir == null || currentDir.getParentId() == 0);

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

@@ -41,7 +41,6 @@ import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemLongClickListener;
 import android.widget.ListAdapter;
 import android.widget.ListView;
-import android.widget.Toast;
 
 import com.actionbarsherlock.app.ActionBar;
 import com.actionbarsherlock.app.SherlockPreferenceActivity;
@@ -253,7 +252,7 @@ public class Preferences extends SherlockPreferenceActivity implements AccountMa
                     @Override
                     public boolean onPreferenceClick(Preference preference) {
                         Intent intent = new Intent(Preferences.this, UploadPathActivity.class);
-                        intent.putExtra("instant_upload_path", mUploadPath);
+                        intent.putExtra(UploadPathActivity.KEY_INSTANT_UPLOAD_PATH, mUploadPath);
                         startActivityForResult(intent, ACTION_SELECT_UPLOAD_PATH);
                         return true;
                     }

+ 40 - 14
src/com/owncloud/android/ui/activity/UploadPathActivity.java

@@ -17,39 +17,65 @@
 
 package com.owncloud.android.ui.activity;
 
+import android.accounts.Account;
 import android.content.Intent;
 
 import android.os.Bundle;
 import android.view.View;
 import android.view.View.OnClickListener;
-import android.widget.Toast;
-
-
 
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.ui.fragment.FileFragment;
+import com.owncloud.android.ui.fragment.OCFileListFragment;
 
+public class UploadPathActivity extends FolderPickerActivity implements FileFragment.ContainerActivity,
+        OnClickListener, OnEnforceableRefreshListener {
 
-public class UploadPathActivity extends FolderPickerActivity implements FileFragment.ContainerActivity, 
-    OnClickListener, OnEnforceableRefreshListener {
+    public static final String KEY_INSTANT_UPLOAD_PATH = "INSTANT_UPLOAD_PATH";
 
     public static final int RESULT_OK_SET_UPLOAD_PATH = 1;
 
-
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        
-        Intent intent = getIntent();
-        String instantUploadPath = intent.getStringExtra("instant_upload_path");
-        
+
+        String instantUploadPath = getIntent().getStringExtra(KEY_INSTANT_UPLOAD_PATH);
+
         OCFile folder = new OCFile(instantUploadPath);
-        
-        Toast.makeText(getApplicationContext(), instantUploadPath, Toast.LENGTH_LONG).show();
-        
-//        onBrowsedDownTo(folder);
+
+        setFile(folder);
     }
 
+    /**
+     * Called when the ownCloud {@link Account} associated to the Activity was
+     * just updated.
+     */
+    @Override
+    protected void onAccountSet(boolean stateWasRecovered) {
+        super.onAccountSet(stateWasRecovered);
+        if (getAccount() != null) {
+
+            updateFileFromDB();
+
+            OCFile folder = getFile();
+            if (folder == null || !folder.isFolder()) {
+                // fall back to root folder
+                setFile(getStorageManager().getFileByPath(OCFile.ROOT_PATH));
+                folder = getFile();
+            }
+
+            onBrowsedDownTo(folder);
+
+            if (!stateWasRecovered) {
+                OCFileListFragment listOfFolders = getListOfFilesFragment();
+                listOfFolders.listDirectory(folder);
+
+                startSyncFolderOperation(folder, false);
+            }
+
+            updateNavigationElementsInActionBar();
+        }
+    }
 
     @Override
     public void onClick(View v) {