Skip to content

Commit

Permalink
Merge pull request #2388 from owncloud/feature/folder_warning_camera_…
Browse files Browse the repository at this point in the history
…uploads

Warning to properly set camera folder when enabling camera uploads
  • Loading branch information
davigonz authored Dec 20, 2018
2 parents ff62a1b + 386a145 commit 415f88f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ public void onCreate(Bundle savedInstanceState) {
/**
* Camera uploads
*/

// Pictures
mPrefCameraPictureUploadsPath = findPreference("camera_picture_uploads_path");
if (mPrefCameraPictureUploadsPath != null) {
Expand Down Expand Up @@ -492,38 +491,32 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
/**
* Handle the toggles from the different camera uploads for pictures options
*
* @param initializing to avoid showing the dialog to confirm camera uploads disabling in the first load of the
* @param initializing avoid showing the dialog to confirm camera uploads by disabling it in the first load of the
* view and showing it when the user just unchecked the feature checkbox
* @param isChecked camera uploads for pictures is checked
*/
private void toggleCameraUploadsPictureOptions(Boolean initializing, Boolean isChecked) {
if (isChecked) {
mPrefCameraUploadsCategory.addPreference(mPrefCameraPictureUploadsWiFi);
mPrefCameraUploadsCategory.addPreference(mPrefCameraPictureUploadsPath);


if (!initializing) {
showSimpleDialog(getString(R.string.proper_pics_folder_warning_camera_upload));
}
} else {

if (!initializing) {

final AlertDialog builder = new AlertDialog.Builder(this).create();

showConfirmationDialog(builder, getString(R.string.confirmation_disable_pictures_upload_message),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_NEGATIVE) {
((CheckBoxPreference) mPrefCameraPictureUploads).setChecked(true);
mPrefCameraUploadsCategory.addPreference(mPrefCameraPictureUploadsWiFi);
mPrefCameraUploadsCategory.addPreference(mPrefCameraPictureUploadsPath);

} else if (which == DialogInterface.BUTTON_POSITIVE) {
mPrefCameraUploadsCategory.removePreference(mPrefCameraPictureUploadsWiFi);
mPrefCameraUploadsCategory.removePreference(mPrefCameraPictureUploadsPath);
mCameraUploadsHandler.updatePicturesLastSync(getApplicationContext(), 0);
}
dismissConfirmationDialog(builder);
showConfirmationDialog(getString(R.string.confirmation_disable_pictures_upload_message),
(dialog, which) -> {
if (which == DialogInterface.BUTTON_NEGATIVE) {
((CheckBoxPreference) mPrefCameraPictureUploads).setChecked(true);
mPrefCameraUploadsCategory.addPreference(mPrefCameraPictureUploadsWiFi);
mPrefCameraUploadsCategory.addPreference(mPrefCameraPictureUploadsPath);

} else if (which == DialogInterface.BUTTON_POSITIVE) {
mPrefCameraUploadsCategory.removePreference(mPrefCameraPictureUploadsWiFi);
mPrefCameraUploadsCategory.removePreference(mPrefCameraPictureUploadsPath);
mCameraUploadsHandler.updatePicturesLastSync(getApplicationContext(), 0);
}
dialog.dismiss();
});
} else {
mPrefCameraUploadsCategory.removePreference(mPrefCameraPictureUploadsWiFi);
Expand All @@ -543,27 +536,23 @@ private void toggleCameraUploadsVideoOptions(Boolean initializing, Boolean isChe
if (isChecked) {
mPrefCameraUploadsCategory.addPreference(mPrefCameraVideoUploadsWiFi);
mPrefCameraUploadsCategory.addPreference(mPrefCameraVideoUploadsPath);
if (!initializing) {
showSimpleDialog(getString(R.string.proper_videos_folder_warning_camera_upload));
}
} else {

if (!initializing) {

final AlertDialog builder = new AlertDialog.Builder(this).create();

showConfirmationDialog(builder, getString(R.string.confirmation_disable_videos_upload_message),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_NEGATIVE) {
((CheckBoxPreference) mPrefCameraVideoUploads).setChecked(true);
mPrefCameraUploadsCategory.addPreference(mPrefCameraVideoUploadsWiFi);
mPrefCameraUploadsCategory.addPreference(mPrefCameraVideoUploadsPath);
} else if (which == DialogInterface.BUTTON_POSITIVE) {
mPrefCameraUploadsCategory.removePreference(mPrefCameraVideoUploadsWiFi);
mPrefCameraUploadsCategory.removePreference(mPrefCameraVideoUploadsPath);
mCameraUploadsHandler.updateVideosLastSync(getApplicationContext(), 0);
}
dismissConfirmationDialog(builder);
showConfirmationDialog(getString(R.string.confirmation_disable_videos_upload_message),
(dialog, which) -> {
if (which == DialogInterface.BUTTON_NEGATIVE) {
((CheckBoxPreference) mPrefCameraVideoUploads).setChecked(true);
mPrefCameraUploadsCategory.addPreference(mPrefCameraVideoUploadsWiFi);
mPrefCameraUploadsCategory.addPreference(mPrefCameraVideoUploadsPath);
} else if (which == DialogInterface.BUTTON_POSITIVE) {
mPrefCameraUploadsCategory.removePreference(mPrefCameraVideoUploadsWiFi);
mPrefCameraUploadsCategory.removePreference(mPrefCameraVideoUploadsPath);
mCameraUploadsHandler.updateVideosLastSync(getApplicationContext(), 0);
}
dialog.dismiss();
});

} else {
Expand Down Expand Up @@ -929,24 +918,29 @@ private void showSnackMessage(int messageResource) {

/**
* Show a confirmation dialog to disable camera uploads
* @param builder alert dialog to show
* @param message message to show in the dialog
* @param listener to handle button clicks
*/
private void showConfirmationDialog(AlertDialog builder, String message, DialogInterface.OnClickListener listener) {

builder.setTitle(R.string.confirmation_disable_camera_uploads_title);
builder.setMessage(message);
builder.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.common_no), listener);
builder.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.common_yes), listener);
builder.show();
private void showConfirmationDialog(String message, DialogInterface.OnClickListener listener) {
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle(R.string.confirmation_disable_camera_uploads_title);
alertDialog.setMessage(message);
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.common_no), listener);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.common_yes), listener);
alertDialog.show();
}

/**
* Dismiss a confirmation dialog
* @param builder alert dialog to dismiss
* Show a simple dialog with a message
* @param message message to show in the dialog
*/
private void dismissConfirmationDialog(AlertDialog builder) {
builder.dismiss();
private void showSimpleDialog(String message) {
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle(R.string.common_important);
alertDialog.setMessage(message);
alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getString(android.R.string.ok), (dialog, which) -> {
dialog.dismiss();
});
alertDialog.show();
}
}
}
3 changes: 3 additions & 0 deletions owncloudApp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
<string name="common_unknown">unknown</string>
<string name="common_error_unknown">Unknown error</string>
<string name="common_pending">Pending</string>
<string name="common_important">Important</string>
<string name="about_title">About</string>
<string name="change_password">Change password</string>
<string name="delete_account">Remove account</string>
Expand Down Expand Up @@ -345,6 +346,8 @@
<string name="confirmation_disable_camera_uploads_title">Confirm</string>
<string name="confirmation_disable_pictures_upload_message">Are you sure you want to disable this feature? The pending pictures will not be uploaded</string>
<string name="confirmation_disable_videos_upload_message">Are you sure you want to disable this feature? The pending videos will not be uploaded</string>
<string name="proper_pics_folder_warning_camera_upload">"Please make sure the folder selected is where the camera you are using saves the pictures taken. Otherwise, the feature will not be able to detect your pictures. Keep in mind that pictures will be uploaded in at least 15 minutes after taking them."</string>
<string name="proper_videos_folder_warning_camera_upload">"Please make sure the folder selected is where the camera you are using saves the videos recorded. Otherwise, the feature will not be able to detect your videos. Keep in mind that videos will be uploaded in at least 15 minutes after recording them."</string>
<string name="conflict_title">File conflict</string>
<string name="conflict_description">There is a conflict in file %1$s, tap to solve it</string>
<string name="conflict_message">Which files do you want to keep? If you select both versions, the local file will have a number added to its name.</string>
Expand Down

0 comments on commit 415f88f

Please sign in to comment.