X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/a70c4c658fa261a1944c7ca12ee3cea3e58e7ad5..6701c9842d326a37fc98efd98945a502a6aa8641:/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java index cf13ba37..96ed2090 100644 --- a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java +++ b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java @@ -42,6 +42,8 @@ import org.json.JSONObject; import android.accounts.Account; import android.accounts.AccountManager; +import android.app.AlertDialog; +import android.app.Dialog; import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.Context; @@ -57,6 +59,7 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; +import android.os.Handler; import android.preference.PreferenceActivity.Header; import android.util.Log; import android.view.Display; @@ -93,7 +96,7 @@ import eu.alefzero.webdav.WebdavClient; * */ public class FileDetailFragment extends SherlockFragment implements - OnClickListener { + OnClickListener, ConfirmationDialogFragment.ConfirmationDialogFragmentListener { public static final String EXTRA_FILE = "FILE"; public static final String EXTRA_ACCOUNT = "ACCOUNT"; @@ -221,6 +224,12 @@ public class FileDetailFragment extends SherlockFragment implements dialog.show(getFragmentManager(), "nameeditdialog"); dialog.setOnDismissListener(this); break; + } + case R.id.fdRemoveBtn: { + ConfirmationDialogFragment confDialog = ConfirmationDialogFragment.newInstance("remove " + mFile.getFileName()); + confDialog.setOnConfirmationListener(this); + confDialog.show(getFragmentManager(), "REMOVE_CONFIRMATION_FRAGMENT"); + break; } default: Log.e(TAG, "Incorrect view clicked!"); @@ -231,8 +240,16 @@ public class FileDetailFragment extends SherlockFragment implements t.start(); }*/ } - - + + + @Override + public void onConfirmation(boolean confirmation, String callerTag) { + if (confirmation && callerTag.equals("REMOVE_CONFIRMATION_FRAGMENT")) { + // TODO remove in a separated thread + } + } + + /** * Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced. * @@ -501,7 +518,7 @@ public class FileDetailFragment extends SherlockFragment implements } - // this is a temporary class for sharing purposes, it need to be replacead in transfer service + // this is a temporary class for sharing purposes, it need to be replaced in transfer service private class ShareRunnable implements Runnable { private String mPath; @@ -634,11 +651,9 @@ public class FileDetailFragment extends SherlockFragment implements newFile.setModificationTimestamp(mFile.getModificationTimestamp()); newFile.setParentId(mFile.getParentId()); newFile.setStoragePath(mFile.getStoragePath()); - fdsm.removeFile(mFile); - fdsm.saveFile(newFile); - new Thread(new RenameRunnable(mFile, newFile, mAccount)).start(); - mFile = newFile; - updateFileDetails(mFile, mAccount); + + new Thread(new RenameRunnable(mFile, newFile, mAccount, new Handler())).start(); + } } } @@ -652,11 +667,13 @@ public class FileDetailFragment extends SherlockFragment implements Account mAccount; OCFile mOld, mNew; + Handler mHandler; - public RenameRunnable(OCFile oldFile, OCFile newFile, Account account) { + public RenameRunnable(OCFile oldFile, OCFile newFile, Account account, Handler handler) { mOld = oldFile; mNew = newFile; mAccount = account; + mHandler = handler; } public void run() { @@ -667,13 +684,22 @@ public class FileDetailFragment extends SherlockFragment implements String webdav_path = AccountUtils.getWebdavPath(ocv); Log.d("ASD", ""+baseUrl + webdav_path + mOld.getRemotePath()); - Log.e("ASD", Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + mNew.getRemotePath()); LocalMoveMethod move = new LocalMoveMethod(baseUrl + webdav_path + mOld.getRemotePath(), Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + mNew.getRemotePath()); try { int status = wc.executeMethod(move); + if (move.succeeded()) { + FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver()); + fdsm.removeFile(mOld); + fdsm.saveFile(mNew); + mFile = mNew; + mHandler.post(new Runnable() { + @Override + public void run() { updateFileDetails(mFile, mAccount); } + }); + } Log.e("ASD", ""+move.getQueryString()); Log.d("move", "returned status " + status); } catch (HttpException e) { @@ -762,4 +788,5 @@ public class FileDetailFragment extends SherlockFragment implements } } + }