<string name="main_tit_accsetup">Setup Account</string>
<string name="main_wrn_accsetup">There are no ownCloud accounts on your device. In order to use this App, you need to create one.</string>
- <string name="actionbar_sync">Sync account</string>
+ <string name="actionbar_sync">Refresh</string>
<string name="actionbar_upload">Upload file</string>
<string name="actionbar_mkdir">Create directory</string>
<string name="actionbar_search">Search</string>
<string name="common_rename">Rename</string>
<string name="common_remove">Remove</string>
- <string name="confirmation_remove_alert">"Do you really want to remove %1$s ?"</string>
+ <string name="confirmation_remove_alert">"Do you really want to remove %1$s ?"</string>
+ <string name="confirmation_remove_local">Local only</string>
+ <string name="confirmation_remove_remote">Remove form server</string>
+ <string name="confirmation_remove_remote_and_local">Both remote and local</string>
<string name="remove_success_msg">"Successful removal"</string>
<string name="remove_fail_msg">"Removal could not be completed"</string>
public final static String ARG_CONF_RESOURCE_ID = "resource_id";
public final static String ARG_CONF_ARGUMENTS = "string_array";
- ConfirmationDialogFragmentListener mListener;
+ public final static String ARG_POSITIVE_BTN_RES = "positive_btn_res";
+ public final static String ARG_NEUTRAL_BTN_RES = "neutral_btn_res";
+ public final static String ARG_NEGATIVE_BTN_RES = "negative_btn_res";
- public static ConfirmationDialogFragment newInstance(int string_id, String[] arguments) {
+ private ConfirmationDialogFragmentListener mListener;
+
+ public static ConfirmationDialogFragment newInstance(int string_id, String[] arguments, int posBtn, int neuBtn, int negBtn) {
ConfirmationDialogFragment frag = new ConfirmationDialogFragment();
Bundle args = new Bundle();
args.putInt(ARG_CONF_RESOURCE_ID, string_id);
args.putStringArray(ARG_CONF_ARGUMENTS, arguments);
+ args.putInt(ARG_POSITIVE_BTN_RES, posBtn);
+ args.putInt(ARG_NEUTRAL_BTN_RES, neuBtn);
+ args.putInt(ARG_NEGATIVE_BTN_RES, negBtn);
frag.setArguments(args);
return frag;
}
public Dialog onCreateDialog(Bundle savedInstanceState) {
Object[] confirmationTarget = getArguments().getStringArray(ARG_CONF_ARGUMENTS);
int resourceId = getArguments().getInt(ARG_CONF_RESOURCE_ID, -1);
+ int posBtn = getArguments().getInt(ARG_POSITIVE_BTN_RES, -1);
+ int neuBtn = getArguments().getInt(ARG_NEUTRAL_BTN_RES, -1);
+ int negBtn = getArguments().getInt(ARG_NEGATIVE_BTN_RES, -1);
+
if (confirmationTarget == null || resourceId == -1) {
Log.wtf(getTag(), "Calling confirmation dialog without resource or arguments");
return null;
}
- return new AlertDialog.Builder(getActivity())
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setMessage(String.format(getString(resourceId), confirmationTarget))
- .setPositiveButton(R.string.common_ok,
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setMessage(String.format(getString(resourceId), confirmationTarget))
+ .setIconAttribute(android.R.attr.alertDialogIcon)
+ .setTitle(android.R.string.dialog_alert_title);
+
+ if (posBtn != -1)
+ builder.setPositiveButton(posBtn,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
- mListener.onConfirmation(true, getTag());
+ mListener.onConfirmation(getTag());
}
- }
- )
- .setNegativeButton(R.string.common_cancel,
+ });
+ if (neuBtn != -1)
+ builder.setNeutralButton(neuBtn,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
- mListener.onConfirmation(false, getTag());
+ mListener.onNeutral(getTag());
+ }
+ });
+ if (negBtn != -1)
+ builder.setNegativeButton(negBtn,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mListener.onCancel(getTag());
}
- }
- )
- .create();
+ });
+ return builder.create();
}
public interface ConfirmationDialogFragmentListener {
- public void onConfirmation(boolean confirmation, String callerTag);
+ public void onConfirmation(String callerTag);
+ public void onNeutral(String callerTag);
+ public void onCancel(String callerTag);
}
}
break;\r
} \r
case R.id.fdRemoveBtn: {\r
- ConfirmationDialogFragment confDialog = ConfirmationDialogFragment.newInstance(R.string.confirmation_remove_alert, new String[]{mFile.getFileName()});\r
+ ConfirmationDialogFragment confDialog = ConfirmationDialogFragment.newInstance(\r
+ R.string.confirmation_remove_alert,\r
+ new String[]{mFile.getFileName()},\r
+ mFile.isDown() ? R.string.confirmation_remove_remote_and_local : R.string.confirmation_remove_remote,\r
+ mFile.isDown() ? R.string.confirmation_remove_local : -1,\r
+ R.string.common_cancel);\r
confDialog.setOnConfirmationListener(this);\r
confDialog.show(getFragmentManager(), FTAG_CONFIRMATION);\r
break;\r
\r
\r
@Override\r
- public void onConfirmation(boolean confirmation, String callerTag) {\r
- if (confirmation && callerTag.equals(FTAG_CONFIRMATION)) {\r
+ public void onConfirmation(String callerTag) {\r
+ if (callerTag.equals(FTAG_CONFIRMATION)) {\r
Log.e("ASD","onConfirmation");\r
FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());\r
if (fdsm.getFileById(mFile.getFileId()) != null) {\r
new Thread(new RemoveRunnable(mFile, mAccount, new Handler())).start();\r
}\r
- } else if (!confirmation) Log.d(TAG, "REMOVAL CANCELED");\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public void onNeutral(String callerTag) {\r
+ FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver());\r
+ File f = null;\r
+ if (mFile.isDown() && (f = new File(mFile.getStoragePath())).exists()) {\r
+ f.delete();\r
+ mFile.setStoragePath(null);\r
+ fdsm.saveFile(mFile);\r
+ updateFileDetails(mFile, mAccount);\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public void onCancel(String callerTag) {\r
+ Log.d(TAG, "REMOVAL CANCELED");\r
}\r
\r
\r