Commit 70393e1f authored by Donald's avatar Donald

clean dialogs

parent 779c1f43
......@@ -192,21 +192,19 @@ public class SelectAlbumBuilder extends BottomSheetDialogFragment {
@Override
public void onClick(View view) {
final EditText editText = new EditText(getContext());
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), theme.getDialogStyle());
AlertDialogsHelper.getInsertTextDialog(((ThemedActivity) getActivity()), builder,
editText, R.string.new_folder);
builder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
AlertDialog insertTextDialog = AlertDialogsHelper.getInsertTextDialog(((ThemedActivity) getActivity()), editText, R.string.new_folder);
insertTextDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
File folderPath = new File(currentFolderPath.getText().toString() + File.separator + editText.getText().toString());
if (folderPath.mkdir()) displayContentFolder(folderPath);
}
});
builder.setNegativeButton(getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
insertTextDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {}
});
builder.show();
insertTextDialog.show();
}
});
contentView.findViewById(R.id.rl_bottom_sheet_title).setOnClickListener(new View.OnClickListener() {
......
......@@ -92,13 +92,12 @@ public class AboutActivity extends ThemedActivity {
findViewById(R.id.ll_about_changelog).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(AboutActivity.this, getDialogStyle());
AlertDialogsHelper.changelogDialog(AboutActivity.this, dialogBuilder);
dialogBuilder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
AlertDialog alertDialog = AlertDialogsHelper.changelogDialog(AboutActivity.this);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {}
});
dialogBuilder.show();
alertDialog.show();
}
});
......
......@@ -416,12 +416,14 @@ public class SingleMediaActivity extends SharedMediaActivity {
break;
case R.id.action_delete:
final AlertDialog.Builder deleteDialog = new AlertDialog.Builder(SingleMediaActivity.this, getDialogStyle());
AlertDialogsHelper.getTextDialog(SingleMediaActivity.this,deleteDialog,
R.string.delete, R.string.delete_photo_message);
deleteDialog.setNegativeButton(this.getString(R.string.cancel).toUpperCase(), null);
deleteDialog.setPositiveButton(this.getString(R.string.delete).toUpperCase(), new DialogInterface.OnClickListener() {
final AlertDialog textDialog = AlertDialogsHelper.getTextDialog(SingleMediaActivity.this, R.string.delete, R.string.delete_photo_message);
textDialog.setButton(DialogInterface.BUTTON_POSITIVE, this.getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
textDialog.dismiss();
}
});
textDialog.setButton(DialogInterface.BUTTON_NEGATIVE, this.getString(R.string.delete).toUpperCase(), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if (Security.isPasswordOnDelete(getApplicationContext())) {
......@@ -440,7 +442,7 @@ public class SingleMediaActivity extends SharedMediaActivity {
deleteCurrentMedia();
}
});
deleteDialog.show();
textDialog.show();
return true;
case R.id.action_move:
......@@ -466,13 +468,10 @@ public class SingleMediaActivity extends SharedMediaActivity {
return true;
case R.id.action_rename:
AlertDialog.Builder renameDialogBuilder = new AlertDialog.Builder(SingleMediaActivity.this, getDialogStyle());
final EditText editTextNewName = new EditText(getApplicationContext());
editTextNewName.setText(StringUtils.getPhotoNameByPath(getAlbum().getCurrentMedia().getPath()));
AlertDialog renameDialog =
AlertDialogsHelper.getInsertTextDialog(
this,renameDialogBuilder, editTextNewName, R.string.rename_photo_action);
AlertDialog renameDialog = AlertDialogsHelper.getInsertTextDialog(this, editTextNewName, R.string.rename_photo_action);
renameDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
......@@ -484,7 +483,7 @@ public class SingleMediaActivity extends SharedMediaActivity {
}});
renameDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) { } });
public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } });
renameDialog.show();
break;
......@@ -496,14 +495,13 @@ public class SingleMediaActivity extends SharedMediaActivity {
break;
case R.id.action_details:
AlertDialog.Builder detailsDialogBuilder = new AlertDialog.Builder(SingleMediaActivity.this, getDialogStyle());
final AlertDialog detailsDialog =
AlertDialogsHelper.getDetailsDialog(this, detailsDialogBuilder,getAlbum().getCurrentMedia());
final AlertDialog detailsDialog = AlertDialogsHelper.getDetailsDialog(this, getAlbum().getCurrentMedia());
detailsDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string
.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) { }});
public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); }});
detailsDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getString(R.string.fix_date).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
......
......@@ -30,18 +30,15 @@ public abstract class SharedMediaActivity extends ThemedActivity {
}
public void requestSdCardPermissions() {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this, getDialogStyle());
AlertDialogsHelper.getTextDialog(this, dialogBuilder,
R.string.sd_card_write_permission_title, R.string.sd_card_permissions_message);
dialogBuilder.setPositiveButton(getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
AlertDialog textDialog = AlertDialogsHelper.getTextDialog(this, R.string.sd_card_write_permission_title, R.string.sd_card_permissions_message);
textDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP)
startActivityForResult(new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE), REQUEST_CODE_SD_CARD_PERMISSIONS);
}
});
dialogBuilder.show();
textDialog.show();
}
@Override
......
......@@ -7,6 +7,7 @@ import android.net.Uri;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.text.Spanned;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
......@@ -36,8 +37,9 @@ import java.util.Locale;
*/
public class AlertDialogsHelper {
public static AlertDialog getInsertTextDialog(final ThemedActivity activity, AlertDialog.Builder dialogBuilder , EditText editText, @StringRes int title) {
public static AlertDialog getInsertTextDialog(final ThemedActivity activity, EditText editText, @StringRes int title) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
View dialogLayout = activity.getLayoutInflater().inflate(org.horaapps.leafpic.R.layout.dialog_insert_text, null);
TextView textViewTitle = (TextView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.rename_title);
......@@ -64,7 +66,8 @@ public class AlertDialogsHelper {
return dialogBuilder.create();
}
public static AlertDialog getTextDialog(final ThemedActivity activity, AlertDialog.Builder textDialogBuilder, @StringRes int title, @StringRes int Message){
public static AlertDialog getTextDialog(final ThemedActivity activity, @StringRes int title, @StringRes int Message){
AlertDialog.Builder builder = new AlertDialog.Builder(activity,activity.getDialogStyle());
View dialogLayout = activity.getLayoutInflater().inflate(org.horaapps.leafpic.R.layout.dialog_text, null);
TextView dialogTitle = (TextView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.text_dialog_title);
......@@ -75,11 +78,12 @@ public class AlertDialogsHelper {
dialogTitle.setText(title);
dialogMessage.setText(Message);
dialogMessage.setTextColor(activity.getTextColor());
textDialogBuilder.setView(dialogLayout);
return textDialogBuilder.create();
builder.setView(dialogLayout);
return builder.create();
}
public static AlertDialog getProgressDialog(final ThemedActivity activity, AlertDialog.Builder progressDialog, String title, String message){
public static AlertDialog getProgressDialog(final ThemedActivity activity, String title, String message){
AlertDialog.Builder progressDialog = new AlertDialog.Builder(activity, activity.getDialogStyle());
View dialogLayout = activity.getLayoutInflater().inflate(org.horaapps.leafpic.R.layout.dialog_progress, null);
TextView dialogTitle = (TextView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.progress_dialog_title);
TextView dialogMessage = (TextView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.progress_dialog_text);
......@@ -98,7 +102,8 @@ public class AlertDialogsHelper {
return progressDialog.create();
}
public static AlertDialog getDetailsDialog(final ThemedActivity activity, AlertDialog.Builder detailsDialogBuilder, final Media f) {
public static AlertDialog getDetailsDialog(final ThemedActivity activity, final Media f) {
AlertDialog.Builder detailsDialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
MediaDetailsMap<String, String> mainDetails = f.getMainDetails(activity.getApplicationContext());
final View dialogLayout = activity.getLayoutInflater().inflate(org.horaapps.leafpic.R.layout.dialog_media_detail, null);
ImageView imgMap = (ImageView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.photo_map);
......@@ -180,7 +185,8 @@ public class AlertDialogsHelper {
loadDetails(dialogLayout ,activity , metadata);
}
public static AlertDialog changelogDialog(final ThemedActivity activity, AlertDialog.Builder changelogDialogBuilder){
public static AlertDialog changelogDialog(final ThemedActivity activity) {
AlertDialog.Builder changelogDialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
View dialogLayout = activity.getLayoutInflater().inflate(R.layout.dialog_changelog, null);
TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.dialog_changelog_title);
......@@ -192,23 +198,17 @@ public class AlertDialogsHelper {
dialogTitle.setBackgroundColor(activity.getPrimaryColor());
activity.getThemeHelper().setScrollViewColor(scrChangelog);
String titleHtml = activity.getString(R.string.changelog) + " <font color='" + activity.getAccentColor()+ "'>" + BuildConfig.VERSION_NAME + "</font>";
dialogTitle.setText(StringUtils.html(titleHtml));
//TODO: TRY TO FIND A BETTER WAY PLZ, I BELIVE IN YOU! <3
//Spanned changelogText = StringUtils.html(activity.getString(R.string.changelog_text));
//dialogMessage.setText(changelogText);
dialogMessage.setText("");
String[] changeLogMessage = activity.getResources().getStringArray(R.array.changelog_message);
StringBuilder builder = new StringBuilder();
for(String s: changeLogMessage){
builder.append(s);
builder.append("\n");
}
dialogTitle.setText(StringUtils.html(String.format(Locale.ENGLISH,"%s <font color='%d'>%s</font>", activity.getString(R.string.changelog), activity.getAccentColor(), BuildConfig.VERSION_NAME )));
dialogMessage.setText(builder.toString().trim());
Spanned changelogText = StringUtils.html("<b>#Fixed</b><br/>\n" +
" &#8226; Fixed crash on startup and some random crash<br/>\n" +
" &#8226; FIied crash opening video (Nougat)<br/>\n" +
" &#8226; Fixed zoom out issue with SubScaling ImageView enabled<br/>\n" +
" <b>#Update</b><br/>\n" +
" &#8226; Updated translations<br/>\n" +
" &#8226; General improvements<br/>");
dialogMessage.setTextColor(activity.getTextColor());
dialogMessage.setText(changelogText);
changelogDialogBuilder.setView(dialogLayout);
return changelogDialogBuilder.create();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment