Browse Source

Change ShareActivity type, now it is a FileActivity

masensio 9 years ago
parent
commit
de93a66763

+ 16 - 8
src/com/owncloud/android/files/FileOperationsHelper.java

@@ -167,7 +167,8 @@ public class FileOperationsHelper {
     public void shareFileWithLinkToApp(OCFile file, String password, Intent sendIntent) {
         
         if (file != null) {
-            mFileActivity.showLoadingDialog();
+            mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+                    getString(R.string.wait_a_moment));
 
             Intent service = new Intent(mFileActivity, OperationsService.class);
             service.setAction(OperationsService.ACTION_CREATE_SHARE);
@@ -213,7 +214,8 @@ public class FileOperationsHelper {
             service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
             mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
             
-            mFileActivity.showLoadingDialog();
+            mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+                    getString(R.string.wait_a_moment));
 
         } else {
             // Show a Message
@@ -267,7 +269,8 @@ public class FileOperationsHelper {
             intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
             intent.putExtra(OperationsService.EXTRA_SYNC_FILE_CONTENTS, true);
             mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(intent);
-            mFileActivity.showLoadingDialog();
+            mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+                    getString(R.string.wait_a_moment));
             
         } else {
             Intent intent = new Intent(mFileActivity, OperationsService.class);
@@ -306,7 +309,8 @@ public class FileOperationsHelper {
         service.putExtra(OperationsService.EXTRA_NEWNAME, newFilename);
         mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
         
-        mFileActivity.showLoadingDialog();
+        mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+                getString(R.string.wait_a_moment));
     }
 
 
@@ -319,7 +323,8 @@ public class FileOperationsHelper {
         service.putExtra(OperationsService.EXTRA_REMOVE_ONLY_LOCAL, onlyLocalCopy);
         mWaitingForOpId =  mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
         
-        mFileActivity.showLoadingDialog();
+        mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+                getString(R.string.wait_a_moment));
     }
 
 
@@ -332,7 +337,8 @@ public class FileOperationsHelper {
         service.putExtra(OperationsService.EXTRA_CREATE_FULL_PATH, createFullPath);
         mWaitingForOpId =  mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
         
-        mFileActivity.showLoadingDialog();
+        mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+                getString(R.string.wait_a_moment));
     }
 
     /**
@@ -375,7 +381,8 @@ public class FileOperationsHelper {
         service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
         mWaitingForOpId =  mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
 
-        mFileActivity.showLoadingDialog();
+        mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+                getString(R.string.wait_a_moment));
     }
 
     /**
@@ -393,7 +400,8 @@ public class FileOperationsHelper {
         service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
         mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
 
-        mFileActivity.showLoadingDialog();
+        mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+                getString(R.string.wait_a_moment));
     }
 
     public long getOpIdWaitingFor() {

+ 6 - 4
src/com/owncloud/android/ui/activity/FileActivity.java

@@ -183,7 +183,9 @@ public class FileActivity extends AppCompatActivity
                     savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE)
                     );
             mTryShareAgain = savedInstanceState.getBoolean(KEY_TRY_SHARE_AGAIN);
-            getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE));
+            if (getSupportActionBar() != null) {
+                getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE));
+            }
         } else {
             account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
             mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
@@ -552,7 +554,7 @@ public class FileActivity extends AppCompatActivity
         outState.putBoolean(FileActivity.EXTRA_FROM_NOTIFICATION, mFromNotification);
         outState.putLong(KEY_WAITING_FOR_OP_ID, mFileOperationsHelper.getOpIdWaitingFor());
         outState.putBoolean(KEY_TRY_SHARE_AGAIN, mTryShareAgain);
-        if(getSupportActionBar().getTitle() != null) {
+        if(getSupportActionBar() != null && getSupportActionBar().getTitle() != null) {
             // Null check in case the actionbar is used in ActionBar.NAVIGATION_MODE_LIST
             // since it doesn't have a title then
             outState.putString(KEY_ACTION_BAR_TITLE, getSupportActionBar().getTitle().toString());
@@ -846,9 +848,9 @@ public class FileActivity extends AppCompatActivity
     /**
      * Show loading dialog
      */
-    public void showLoadingDialog() {
+    public void showLoadingDialog(String message) {
         // Construct dialog
-        LoadingDialog loading = new LoadingDialog(getResources().getString(R.string.wait_a_moment));
+        LoadingDialog loading = new LoadingDialog(message);
         FragmentManager fm = getSupportFragmentManager();
         FragmentTransaction ft = fm.beginTransaction();
         loading.show(ft, DIALOG_WAIT_TAG);

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

@@ -44,7 +44,7 @@ import com.owncloud.android.ui.fragment.ShareFileFragment;
  * Activity for sharing files
  */
 
-public class ShareActivity extends AppCompatActivity
+public class ShareActivity extends FileActivity
         implements ShareFileFragment.OnShareFragmentInteractionListener,
         SearchFragment.OnSearchFragmentInteractionListener {
 
@@ -55,9 +55,6 @@ public class ShareActivity extends AppCompatActivity
 
     private static final String DIALOG_WAIT_LOAD_DATA = "DIALOG_WAIT_LOAD_DATA";
 
-    private Account mAccount;
-    private OCFile mFile;
-
     private ShareFileFragment mShareFileFragment;
     private SearchFragment mSearchFragment;
 
@@ -69,8 +66,6 @@ public class ShareActivity extends AppCompatActivity
         FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
 
         if (savedInstanceState != null) {
-            mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
-            mAccount = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT);
 
             mShareFileFragment = (ShareFileFragment) getSupportFragmentManager().
                     getFragment(savedInstanceState, TAG_SHARE_FRAGMENT);
@@ -89,12 +84,8 @@ public class ShareActivity extends AppCompatActivity
             }
 
         } else {
-            // Read Extras
-            mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
-            mAccount = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
-
             // Add Share fragment
-            mShareFileFragment = ShareFileFragment.newInstance(mFile, mAccount);
+            mShareFileFragment = ShareFileFragment.newInstance(getFile(), getAccount());
             ft.replace(R.id.share_fragment_container, mShareFileFragment, TAG_SHARE_FRAGMENT);
             ft.commit();
 
@@ -148,9 +139,6 @@ public class ShareActivity extends AppCompatActivity
     @Override
     protected void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
-        outState.putParcelable(FileActivity.EXTRA_FILE, mFile);
-        outState.putParcelable(FileActivity.EXTRA_ACCOUNT, mAccount);
-
         //Save the fragment's instance
         getSupportFragmentManager().putFragment(outState, TAG_SHARE_FRAGMENT, mShareFileFragment);
         if (mSearchFragment != null) {
@@ -162,7 +150,7 @@ public class ShareActivity extends AppCompatActivity
     @Override
     public void showSearchUsersAndGroups() {
         FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
-        mSearchFragment = SearchFragment.newInstance(mFile, mAccount);
+        mSearchFragment = SearchFragment.newInstance(getFile(), getAccount());
         ft.hide(mShareFileFragment);
         ft.add(R.id.share_fragment_container, mSearchFragment, TAG_SEARCH_FRAGMENT);
         ft.addToBackStack(TAG_SEARCH_FRAGMENT);
@@ -187,29 +175,4 @@ public class ShareActivity extends AppCompatActivity
     public void onSearchFragmentInteraction(Uri uri) {
 
     }
-
-    /**
-     * Show waiting for loading data
-     */
-    public void showWaitingLoadDialog() {
-        // Construct dialog
-        LoadingDialog loading = new LoadingDialog(
-                getResources().getString(R.string.common_loading));
-        FragmentManager fm = getSupportFragmentManager();
-        FragmentTransaction ft = fm.beginTransaction();
-        loading.show(ft, DIALOG_WAIT_LOAD_DATA);
-
-    }
-
-
-    /**
-     * Dismiss waiting for loading data
-     */
-    public void dismissWaitingLoadDialog(){
-        Fragment frag = getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_LOAD_DATA);
-        if (frag != null) {
-            LoadingDialog loading = (LoadingDialog) frag;
-            loading.dismiss();
-        }
-    }
 }

+ 3 - 2
src/com/owncloud/android/ui/fragment/ShareFileFragment.java

@@ -252,7 +252,8 @@ public class ShareFileFragment extends Fragment
     }
 
     private void unshareWith(int shareId){
-        ( (ShareActivity) getActivity()).showWaitingLoadDialog();
+        ( (ShareActivity) getActivity()).showLoadingDialog(getActivity().getApplicationContext().
+                getString(R.string.common_loading));
         // Remove Share with id
         UnshareWithUserAsyncTask unshareTask = new UnshareWithUserAsyncTask(this);
         FileDataStorageManager fileDataStorageManager =
@@ -264,7 +265,7 @@ public class ShareFileFragment extends Fragment
     @Override
     public void onUnshareWithFinish(RemoteOperationResult result) {
         // Remove loading
-        ((ShareActivity) getActivity()).dismissWaitingLoadDialog();
+        ((ShareActivity) getActivity()).dismissLoadingDialog();
 
         if (result != null && result.isSuccess()) {
             // Refresh data