Fix dialog theme issues

pull/413/head
Alex Baker 8 years ago
parent 255e015a3c
commit 1539feb252

@ -168,7 +168,7 @@ public class TasksXmlImporter {
r.getQuantityString(R.plurals.Ntasks, importCount, importCount),
r.getQuantityString(R.plurals.Ntasks, skipCount, skipCount),
r.getQuantityString(R.plurals.Ntasks, errorCount, errorCount)))
.setPositiveButton(context.getString(android.R.string.ok), new DialogInterface.OnClickListener() {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();

@ -7,7 +7,6 @@ package com.todoroo.astrid.core;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.support.v7.app.AlertDialog;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.MenuItem;
@ -24,6 +23,7 @@ import com.todoroo.astrid.api.TextInputCriterion;
import com.todoroo.astrid.core.CustomFilterActivity.CriterionInstance;
import org.tasks.R;
import org.tasks.dialogs.AlertDialogBuilder;
import org.tasks.dialogs.DialogBuilder;
import java.util.List;
@ -104,7 +104,7 @@ public class CustomFilterAdapter extends ArrayAdapter<CriterionInstance> {
* Show options menu for the given criterioninstance
*/
public void showOptionsFor(final CriterionInstance item, final Runnable onComplete) {
AlertDialog.Builder dialog = dialogBuilder.newDialog()
AlertDialogBuilder dialog = dialogBuilder.newDialog()
.setTitle(item.criterion.name);
if(item.criterion instanceof MultipleSelectCriterion) {

@ -310,13 +310,13 @@ public class RepeatControlSet extends TaskEditControlFragment {
@OnClick(R.id.display_row_edit)
void openPopup(View view) {
if (dialog == null) {
buildDialog();
dialog = buildDialog();
}
dialog.show();
}
protected Dialog buildDialog() {
AlertDialog.Builder builder = dialogBuilder.newDialog()
private AlertDialog buildDialog() {
return dialogBuilder.newDialog()
.setView(dialogView)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
@ -333,9 +333,8 @@ public class RepeatControlSet extends TaskEditControlFragment {
public void onCancel(DialogInterface dialog) {
refreshDisplayView();
}
});
dialog = builder.show();
return dialog;
})
.create();
}
@Override
@ -442,14 +441,15 @@ public class RepeatControlSet extends TaskEditControlFragment {
}
ContextThemeWrapper wrapper = new ContextThemeWrapper(getActivity(), themeManager.getDialogThemeResId());
themeManager.applyThemeToContext(wrapper);
new NumberPickerDialog(wrapper, new OnNumberPickedListener() {
NumberPickerDialog dialog = new NumberPickerDialog(wrapper, new OnNumberPickedListener() {
@Override
public void onNumberPicked(int number) {
setRepeatValue(number);
}
}, getResources().getString(R.string.repeat_interval_prompt),
dialogValue, 1, 1, 365).show();
dialogValue, 1, 1, 365);
themeManager.applyThemeToContext(dialog.getContext());
dialog.show();
}
private void repeatUntilClick() {

@ -42,6 +42,7 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.utility.Flags;
import org.tasks.R;
import org.tasks.dialogs.AlertDialogBuilder;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.FragmentComponent;
import org.tasks.ui.TaskEditControlFragment;
@ -162,13 +163,13 @@ public final class TagsControlSet extends TaskEditControlFragment {
@OnClick(R.id.display_row_edit)
void openPopup(View view) {
if (dialog == null) {
buildDialog();
dialog = buildDialog();
}
dialog.show();
}
protected Dialog buildDialog() {
android.support.v7.app.AlertDialog.Builder builder = dialogBuilder.newDialog()
private AlertDialog buildDialog() {
return dialogBuilder.newDialog()
.setView(dialogView)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
@ -182,9 +183,8 @@ public final class TagsControlSet extends TaskEditControlFragment {
public void onCancel(DialogInterface dialog) {
refreshDisplayView();
}
});
dialog = builder.show();
return dialog;
})
.create();
}
private void setTagSelected(String tag) {

@ -28,6 +28,7 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.ui.TimeDurationControlSet;
import org.tasks.R;
import org.tasks.dialogs.AlertDialogBuilder;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.ForActivity;
import org.tasks.injection.FragmentComponent;
@ -118,13 +119,13 @@ public class TimerControlSet extends TaskEditControlFragment {
@OnClick(R.id.display_row_edit)
void openPopup(View view) {
if (dialog == null) {
buildDialog();
dialog = buildDialog();
}
dialog.show();
}
protected Dialog buildDialog() {
AlertDialog.Builder builder = dialogBuilder.newDialog()
private AlertDialog buildDialog() {
return dialogBuilder.newDialog()
.setView(dialogView)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
@ -137,9 +138,8 @@ public class TimerControlSet extends TaskEditControlFragment {
public void onCancel(DialogInterface dialog) {
refreshDisplayView();
}
});
dialog = builder.show();
return dialog;
})
.create();
}
@OnClick(R.id.timer_container)

@ -70,7 +70,6 @@ public class TimeDurationControlSet implements OnNNumberPickedListener, View.OnC
public void onClick(View v) {
if(dialog == null) {
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, themeManager.getDialogThemeResId());
themeManager.applyThemeToContext(contextThemeWrapper);
dialog = new NNumberPickerDialog(contextThemeWrapper, this,
context.getResources().getString(R.string.DLG_hour_minutes),
new int[] {0, 0}, new int[] {1, 5}, new int[] {0, 0},
@ -105,6 +104,7 @@ public class TimeDurationControlSet implements OnNNumberPickedListener, View.OnC
dialog.setInitialValues(initialValues);
}
themeManager.applyThemeToContext(dialog.getContext());
dialog.show();
}

@ -4,13 +4,13 @@ import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import com.google.common.base.Function;
import org.tasks.R;
import org.tasks.calendars.AndroidCalendar;
import org.tasks.calendars.CalendarProvider;
import org.tasks.dialogs.AlertDialogBuilder;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
@ -53,7 +53,7 @@ public class CalendarSelectionDialog extends InjectingDialogFragment {
}
});
AlertDialog.Builder builder = dialogBuilder.newDialog()
AlertDialogBuilder builder = dialogBuilder.newDialog()
.setItems(calendarNames.toArray(new String[calendarNames.size()]), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

@ -0,0 +1,118 @@
package org.tasks.dialogs;
import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.view.View;
import android.widget.ListAdapter;
import org.tasks.preferences.ThemeManager;
public class AlertDialogBuilder {
private final AlertDialog.Builder builder;
private final Context context;
private final ThemeManager themeManager;
public AlertDialogBuilder(Context context, ThemeManager themeManager) {
this.context = context;
this.themeManager = themeManager;
ContextThemeWrapper wrapper = new ContextThemeWrapper(context, themeManager.getDialogThemeResId());
themeManager.applyThemeToContext(wrapper);
builder = new AlertDialog.Builder(wrapper);
}
public AlertDialogBuilder setMessage(int message, Object... formatArgs) {
return setMessage(context.getString(message, formatArgs));
}
public AlertDialogBuilder setMessage(String message) {
builder.setMessage(message);
return this;
}
public AlertDialogBuilder setPositiveButton(int ok, DialogInterface.OnClickListener onClickListener) {
builder.setPositiveButton(ok, onClickListener);
return this;
}
public AlertDialogBuilder setNegativeButton(int cancel, DialogInterface.OnClickListener onClickListener) {
builder.setNegativeButton(cancel, onClickListener);
return this;
}
public AlertDialogBuilder setTitle(int title) {
builder.setTitle(title);
return this;
}
public AlertDialogBuilder setItems(String[] strings, DialogInterface.OnClickListener onClickListener) {
builder.setItems(strings, onClickListener);
return this;
}
public AlertDialogBuilder setView(View dialogView) {
builder.setView(dialogView);
return this;
}
public AlertDialogBuilder setOnCancelListener(DialogInterface.OnCancelListener onCancelListener) {
builder.setOnCancelListener(onCancelListener);
return this;
}
public AlertDialogBuilder setAdapter(ListAdapter adapter, DialogInterface.OnClickListener listener) {
builder.setAdapter(adapter, listener);
return this;
}
public AlertDialogBuilder setSingleChoiceItems(String[] strings, int selectedIndex, DialogInterface.OnClickListener onClickListener) {
builder.setSingleChoiceItems(strings, selectedIndex, onClickListener);
return this;
}
public AlertDialogBuilder setSingleChoiceItems(ListAdapter adapter, int selectedIndex, DialogInterface.OnClickListener onClickListener) {
builder.setSingleChoiceItems(adapter, selectedIndex, onClickListener);
return this;
}
public AlertDialogBuilder setNeutralButton(int reverse, DialogInterface.OnClickListener onClickListener) {
builder.setNeutralButton(reverse, onClickListener);
return this;
}
public AlertDialogBuilder setTitle(String title) {
builder.setTitle(title);
return this;
}
public AlertDialogBuilder setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
builder.setOnDismissListener(onDismissListener);
return this;
}
public AlertDialogBuilder setCancelable(boolean b) {
builder.setCancelable(b);
return this;
}
public AlertDialog create() {
AlertDialog dialog = builder.create();
themeManager.applyThemeToContext(dialog.getContext());
return dialog;
}
public AlertDialog showThemedListView() {
AlertDialog dialog = create();
themeManager.applyThemeToContext(dialog.getListView().getContext());
dialog.show();
return dialog;
}
public AlertDialog show() {
AlertDialog dialog = create();
dialog.show();
return dialog;
}
}

@ -4,10 +4,8 @@ import android.app.Activity;
import android.app.ProgressDialog;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import com.todoroo.andlib.data.Callback;
import com.todoroo.andlib.utility.AndroidUtilities;
import org.tasks.preferences.ThemeManager;
@ -24,16 +22,18 @@ public class DialogBuilder {
this.themeManager = themeManager;
}
public AlertDialog.Builder newDialog() {
return new AlertDialog.Builder(buildDialogWrapper());
public AlertDialogBuilder newDialog() {
return new AlertDialogBuilder(activity, themeManager);
}
public AlertDialog.Builder newMessageDialog(int message, Object... formatArgs) {
return newDialog().setMessage(activity.getString(message, formatArgs));
@Deprecated
public AlertDialogBuilder newMessageDialog(int message, Object... formatArgs) {
return newDialog().setMessage(message, formatArgs);
}
public ProgressDialog newProgressDialog() {
ProgressDialog progressDialog = new ProgressDialog(buildDialogWrapper());
ProgressDialog progressDialog = new ProgressDialog(activity, themeManager.getDialogThemeResId());
themeManager.applyThemeToContext(progressDialog.getContext());
if (AndroidUtilities.preLollipop()) {
progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.R.color.transparent));
}

@ -99,7 +99,7 @@ public class SortDialog extends InjectingDialogFragment {
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
.showThemedListView();
enableReverse();

@ -3,31 +3,24 @@
<style name="DarkBase" parent="Theme.AppCompat.NoActionBar">
<item name="popup_theme">@style/ThemeOverlay.AppCompat</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowBackground">@color/md_dark_background</item>
<item name="asEditTextBackground">@null</item>
<item name="windowActionModeOverlay">true</item>
<item name="drawer_background">@color/drawer_background_dark</item>
<item name="drawer_background_selected">@color/drawer_background_selected_dark</item>
<item name="asDueDateCompletedColor">#ff777777</item>
<item name="asSeparator">@android:color/transparent</item>
<item name="android:actionModeBackground">?attr/colorPrimary</item>
<item name="separatorHeight">1px</item>
<item name="asContentBackground">@color/md_dark_background</item>
<item name="asTextColor">@android:color/white</item>
<item name="asTextColorHint">@android:color/darker_gray</item>
<item name="task_edit_divider">@color/task_edit_divider</item>
<item name="asDueDateColor">#c3c3c3</item>
<item name="asEditTextBackground">@null</item>
<item name="asDueDateCompletedColor">#ff777777</item>
<item name="separatorHeight">1px</item>
<item name="asDetailsColor">#6666aa</item>
<item name="asDueDateColor">#c3c3c3</item>
<item name="asListDividerColor">#dddddd</item>
<item name="asThemeTextColor">@color/dark_blue_theme_color</item>
<item name="task_edit_divider">@color/task_edit_divider</item>
<item name="android:spinnerItemStyle">@style/SpinnerNoPadding</item>
<item name="android:actionModeBackground">?attr/colorPrimary</item>
<item name="alertDialogTheme">@style/DialogBaseDark</item>
</style>

@ -27,7 +27,7 @@
<style name="LightOverride" parent="LightBase">
</style>
<style name="LightDialogBase" parent="Theme.AppCompat.Light.Dialog">
<style name="LightDialogBase" parent="@style/Theme.AppCompat.Light.Dialog">
<item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
<item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
<item name="asThemeTextColor">@color/dark_blue_theme_color</item>

Loading…
Cancel
Save