Don't use android.appAlertDialog

This commit is contained in:
serso 2016-02-09 15:52:43 +01:00
parent 47075b0c10
commit a327a9b97b
4 changed files with 51 additions and 28 deletions

View File

@ -22,8 +22,16 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import static android.os.Build.VERSION_CODES.GINGERBREAD_MR1;
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
import static org.solovyev.android.calculator.Preferences.Gui.preventScreenFromFading;
import static org.solovyev.android.calculator.release.ReleaseNotes.hasReleaseNotes;
import static org.solovyev.android.wizard.WizardUi.continueWizard;
import static org.solovyev.android.wizard.WizardUi.createLaunchIntent;
import static org.solovyev.android.wizard.WizardUi.startWizard;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
@ -31,11 +39,15 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.view.*; import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.Window;
import android.widget.TextView; import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;
import org.solovyev.android.Activities; import org.solovyev.android.Activities;
import org.solovyev.android.Android; import org.solovyev.android.Android;
import org.solovyev.android.calculator.history.History; import org.solovyev.android.calculator.history.History;
@ -47,17 +59,13 @@ import org.solovyev.android.wizard.Wizard;
import org.solovyev.android.wizard.Wizards; import org.solovyev.android.wizard.Wizards;
import org.solovyev.common.Objects; import org.solovyev.common.Objects;
import butterknife.Bind;
import butterknife.ButterKnife;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
import static android.os.Build.VERSION_CODES.GINGERBREAD_MR1;
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
import static org.solovyev.android.calculator.Preferences.Gui.preventScreenFromFading;
import static org.solovyev.android.calculator.release.ReleaseNotes.hasReleaseNotes;
import static org.solovyev.android.wizard.WizardUi.*;
public class CalculatorActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener { public class CalculatorActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
@Nonnull @Nonnull
@ -141,7 +149,7 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
final TextView feedbackTextView = (TextView) view.findViewById(textViewId); final TextView feedbackTextView = (TextView) view.findViewById(textViewId);
feedbackTextView.setMovementMethod(LinkMovementMethod.getInstance()); feedbackTextView.setMovementMethod(LinkMovementMethod.getInstance());
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setView(view); final AlertDialog.Builder builder = new AlertDialog.Builder(context, App.getTheme().alertDialogTheme).setView(view);
builder.setPositiveButton(android.R.string.ok, null); builder.setPositiveButton(android.R.string.ok, null);
builder.create().show(); builder.create().show();

View File

@ -22,10 +22,14 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import static org.solovyev.android.calculator.BaseFragment.addMenu;
import static org.solovyev.android.calculator.CalculatorEventType.conversion_failed;
import static org.solovyev.android.calculator.CalculatorEventType.conversion_result;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.app.Application; import android.app.Application;
import android.content.Context; import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
@ -43,18 +47,14 @@ import org.solovyev.android.calculator.errors.FixableErrorsActivity;
import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.android.calculator.view.NumeralBaseConverterDialog; import org.solovyev.android.calculator.view.NumeralBaseConverterDialog;
import dagger.Lazy;
import jscl.math.Generic;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import dagger.Lazy;
import jscl.math.Generic;
import static org.solovyev.android.calculator.BaseFragment.addMenu;
import static org.solovyev.android.calculator.CalculatorEventType.conversion_failed;
import static org.solovyev.android.calculator.CalculatorEventType.conversion_result;
@Singleton @Singleton
public class Display implements CalculatorEventListener, View.OnClickListener, View.OnCreateContextMenuListener, MenuItem.OnMenuItemClickListener { public class Display implements CalculatorEventListener, View.OnClickListener, View.OnCreateContextMenuListener, MenuItem.OnMenuItemClickListener {
@ -210,7 +210,7 @@ public class Display implements CalculatorEventListener, View.OnClickListener, V
final View errorMessageView = layoutInflater.inflate(R.layout.display_error_message, null); final View errorMessageView = layoutInflater.inflate(R.layout.display_error_message, null);
((TextView) errorMessageView.findViewById(R.id.error_message_text_view)).setText(errorMessage); ((TextView) errorMessageView.findViewById(R.id.error_message_text_view)).setText(errorMessage);
final AlertDialog.Builder builder = new AlertDialog.Builder(context) final AlertDialog.Builder builder = new AlertDialog.Builder(context, App.getTheme().alertDialogTheme)
.setPositiveButton(R.string.c_cancel, null) .setPositiveButton(R.string.c_cancel, null)
.setView(errorMessageView); .setView(errorMessageView);

View File

@ -22,10 +22,12 @@
package org.solovyev.android.calculator.view; package org.solovyev.android.calculator.view;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.ParseException; import org.solovyev.android.calculator.ParseException;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
@ -36,9 +38,10 @@ import org.solovyev.common.text.Strings;
import org.solovyev.common.units.Unit; import org.solovyev.common.units.Unit;
import org.solovyev.common.units.UnitImpl; import org.solovyev.common.units.UnitImpl;
import java.util.Arrays;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Arrays;
public class NumeralBaseConverterDialog { public class NumeralBaseConverterDialog {
@ -96,7 +99,7 @@ public class NumeralBaseConverterDialog {
} }
})); }));
final AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context); final AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context, App.getTheme().alertDialogTheme);
alertBuilder.setView(b.build(context)); alertBuilder.setView(b.build(context));
alertBuilder.setTitle(R.string.c_conversion_tool); alertBuilder.setTitle(R.string.c_conversion_tool);

View File

@ -1,6 +1,5 @@
package org.solovyev.android.calculator.wizard; package org.solovyev.android.calculator.wizard;
import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
@ -8,9 +7,22 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import com.viewpagerindicator.PageIndicator; import com.viewpagerindicator.PageIndicator;
import org.solovyev.android.calculator.*;
import org.solovyev.android.wizard.*; import org.solovyev.android.calculator.ActivityUi;
import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
import org.solovyev.android.wizard.ListWizardFlow;
import org.solovyev.android.wizard.Wizard;
import org.solovyev.android.wizard.WizardFlow;
import org.solovyev.android.wizard.WizardStep;
import org.solovyev.android.wizard.WizardUi;
import org.solovyev.android.wizard.Wizards;
import org.solovyev.android.wizard.WizardsAware;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -109,7 +121,7 @@ public class WizardActivity extends BaseActivity implements WizardsAware, Shared
return; return;
} }
final AlertDialog.Builder b = new AlertDialog.Builder(this); final AlertDialog.Builder b = new AlertDialog.Builder(this, App.getTheme().alertDialogTheme);
b.setTitle(getString(R.string.cpp_wizard_finish_confirmation_title)). b.setTitle(getString(R.string.cpp_wizard_finish_confirmation_title)).
setMessage(R.string.cpp_wizard_finish_confirmation). setMessage(R.string.cpp_wizard_finish_confirmation).
setNegativeButton(R.string.c_no, dialogListener). setNegativeButton(R.string.c_no, dialogListener).