\r
import android.accounts.Account;\r
import android.accounts.AccountManager;\r
+import android.app.AlertDialog;\r
+import android.app.Dialog;\r
import android.content.ActivityNotFoundException;\r
import android.content.BroadcastReceiver;\r
import android.content.Context;\r
import android.graphics.drawable.Drawable;\r
import android.net.Uri;\r
import android.os.Bundle;\r
+import android.os.Handler;\r
import android.preference.PreferenceActivity.Header;\r
import android.util.Log;\r
import android.view.Display;\r
* \r
*/\r
public class FileDetailFragment extends SherlockFragment implements\r
- OnClickListener {\r
+ OnClickListener, ConfirmationDialogFragment.ConfirmationDialogFragmentListener {\r
\r
public static final String EXTRA_FILE = "FILE";\r
public static final String EXTRA_ACCOUNT = "ACCOUNT";\r
dialog.show(getFragmentManager(), "nameeditdialog");\r
dialog.setOnDismissListener(this);\r
break;\r
+ } \r
+ case R.id.fdRemoveBtn: {\r
+ ConfirmationDialogFragment confDialog = ConfirmationDialogFragment.newInstance("remove " + mFile.getFileName());\r
+ confDialog.setOnConfirmationListener(this);\r
+ confDialog.show(getFragmentManager(), "REMOVE_CONFIRMATION_FRAGMENT");\r
+ break;\r
}\r
default:\r
Log.e(TAG, "Incorrect view clicked!");\r
t.start();\r
}*/\r
}\r
-\r
-\r
+ \r
+ \r
+ @Override\r
+ public void onConfirmation(boolean confirmation, String callerTag) {\r
+ if (confirmation && callerTag.equals("REMOVE_CONFIRMATION_FRAGMENT")) {\r
+ // TODO remove in a separated thread\r
+ }\r
+ }\r
+ \r
+ \r
/**\r
* Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced.\r
* \r
\r
}\r
\r
- // this is a temporary class for sharing purposes, it need to be replacead in transfer service\r
+ // this is a temporary class for sharing purposes, it need to be replaced in transfer service\r
private class ShareRunnable implements Runnable {\r
private String mPath;\r
\r
newFile.setModificationTimestamp(mFile.getModificationTimestamp());\r
newFile.setParentId(mFile.getParentId());\r
newFile.setStoragePath(mFile.getStoragePath());\r
- fdsm.removeFile(mFile);\r
- fdsm.saveFile(newFile);\r
- new Thread(new RenameRunnable(mFile, newFile, mAccount)).start();\r
- mFile = newFile;\r
- updateFileDetails(mFile, mAccount);\r
+ \r
+ new Thread(new RenameRunnable(mFile, newFile, mAccount, new Handler())).start();\r
+\r
}\r
}\r
}\r
\r
Account mAccount;\r
OCFile mOld, mNew;\r
+ Handler mHandler;\r
\r
- public RenameRunnable(OCFile oldFile, OCFile newFile, Account account) {\r
+ public RenameRunnable(OCFile oldFile, OCFile newFile, Account account, Handler handler) {\r
mOld = oldFile;\r
mNew = newFile;\r
mAccount = account;\r
+ mHandler = handler;\r
}\r
\r
public void run() {\r
String webdav_path = AccountUtils.getWebdavPath(ocv);\r
Log.d("ASD", ""+baseUrl + webdav_path + mOld.getRemotePath());\r
\r
- \r
Log.e("ASD", Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + mNew.getRemotePath());\r
LocalMoveMethod move = new LocalMoveMethod(baseUrl + webdav_path + mOld.getRemotePath(),\r
Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + mNew.getRemotePath());\r
\r
try {\r
int status = wc.executeMethod(move);\r
+ if (move.succeeded()) {\r
+ FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());\r
+ fdsm.removeFile(mOld);\r
+ fdsm.saveFile(mNew);\r
+ mFile = mNew;\r
+ mHandler.post(new Runnable() {\r
+ @Override\r
+ public void run() { updateFileDetails(mFile, mAccount); }\r
+ });\r
+ }\r
Log.e("ASD", ""+move.getQueryString());\r
Log.d("move", "returned status " + status);\r
} catch (HttpException e) {\r
}\r
\r
}\r
+\r
}\r