Choose theme wizard step

This commit is contained in:
serso 2015-02-07 17:31:56 +01:00
parent 2540ec0b37
commit 323011391c
64 changed files with 813 additions and 609 deletions

View File

@ -86,6 +86,7 @@ public class ActivityUi extends BaseUi {
final View root = activity.findViewById(R.id.main_layout);
if (root != null) {
processButtons(activity, root);
fixFonts(root);
addHelpInfo(activity, root);
}
}

View File

@ -47,8 +47,6 @@ import org.solovyev.common.math.Point2d;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
@ -68,26 +66,26 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
private static final List<Integer> viewIds = new ArrayList<Integer>(200);
@Nonnull
private Preferences.Gui.Layout layout;
protected Preferences.Gui.Layout layout;
@Nonnull
private Preferences.Gui.Theme theme;
@Nullable
private Vibrator vibrator;
@Nonnull
private final JListeners<DragPreferencesChangeListener> dpclRegister = Listeners.newHardRefListeners();
protected Preferences.Gui.Theme theme;
@Nonnull
private String logTag = "CalculatorActivity";
@Nullable
private Vibrator vibrator;
@Nullable
private AngleUnitsButton angleUnitsButton;
@Nullable
private NumeralBasesButton clearButton;
@Nonnull
private final JListeners<DragPreferencesChangeListener> dpclRegister = Listeners.newHardRefListeners();
protected BaseUi() {
}
@ -119,6 +117,28 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
Log.e(logTag, message);
}
public void onDestroy(@Nonnull Activity activity) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
preferences.unregisterOnSharedPreferenceChangeListener(this);
}
protected void fixFonts(@Nonnull View root) {
// some devices ship own fonts which causes issues with rendering. Let's use our own font for all text views
final Typeface typeFace = CalculatorApplication.getInstance().getTypeFace();
Views.processViewsOfType(root, TextView.class, new Views.ViewProcessor<TextView>() {
@Override
public void process(@Nonnull TextView view) {
int style = Typeface.NORMAL;
final Typeface oldTypeface = view.getTypeface();
if (oldTypeface != null) {
style = oldTypeface.getStyle();
}
view.setTypeface(typeFace, style);
}
});
}
public void processButtons(@Nonnull final Activity activity, @Nonnull View root) {
dpclRegister.removeListeners();
@ -211,24 +231,32 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
toggleButtonDirectionText(views, R.id.cpp_button_plus, false, DragDirection.down, DragDirection.up);
}
CalculatorButtons.processButtons(theme, layout, root);
CalculatorButtons.fixButtonsTextSize(theme, layout, root);
CalculatorButtons.toggleEqualsButton(preferences, activity);
CalculatorButtons.initMultiplicationButton(root);
NumeralBaseButtons.toggleNumericDigits(activity, preferences);
// some devices ship own fonts which causes issues with rendering. Let's use our own font for all text views
final Typeface typeFace = CalculatorApplication.getInstance().getTypeFace();
Views.processViewsOfType(root, TextView.class, new Views.ViewProcessor<TextView>() {
@Override
public void process(@Nonnull TextView view) {
int style = Typeface.NORMAL;
final Typeface oldTypeface = view.getTypeface();
if (oldTypeface != null) {
style = oldTypeface.getStyle();
}
view.setTypeface(typeFace, style);
new ButtonOnClickListener().attachToViews(views);
}
private void setOnDragListeners(@Nonnull ViewsCache views, @Nonnull SimpleDragListener.Preferences dragPreferences, @Nonnull SharedPreferences preferences) {
final DragListener dragListener = new DragListenerVibrator(newOnDragListener(new DigitButtonDragProcessor(getKeyboard()), dragPreferences), vibrator, preferences);
final List<Integer> viewIds = getViewIds();
for (Integer viewId : viewIds) {
final View view = views.findViewById(viewId);
if (view instanceof DragButton) {
((DragButton) view).setOnDragListener(dragListener);
}
});
}
}
@Nonnull
private SimpleDragListener newOnDragListener(@Nonnull SimpleDragListener.DragProcessor dragProcessor,
@Nonnull SimpleDragListener.Preferences dragPreferences) {
final SimpleDragListener onDragListener = new SimpleDragListener(dragProcessor, dragPreferences);
dpclRegister.addListener(onDragListener);
return onDragListener;
}
private void toggleButtonDirectionText(@Nonnull ViewsCache views, int id, boolean showDirectionText, @Nonnull DragDirection... dragDirections) {
@ -246,32 +274,34 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
return Locator.getInstance().getCalculator();
}
private void setOnDragListeners(@Nonnull ViewsCache views, @Nonnull SimpleDragListener.Preferences dragPreferences, @Nonnull SharedPreferences preferences) {
final DragListener dragListener = new DragListenerVibrator(newOnDragListener(new DigitButtonDragProcessor(getKeyboard()), dragPreferences), vibrator, preferences);
final List<Integer> viewIds = getViewIds();
for (Integer viewId : viewIds) {
final View view = views.findViewById(viewId);
if (view instanceof DragButton) {
((DragButton) view).setOnDragListener(dragListener);
}
}
}
@Nonnull
private static List<Integer> getViewIds() {
if (viewIds.isEmpty()) {
for (Field field : R.id.class.getDeclaredFields()) {
int modifiers = field.getModifiers();
if (Modifier.isFinal(modifiers) && Modifier.isStatic(modifiers)) {
try {
viewIds.add(field.getInt(R.id.class));
} catch (IllegalAccessException e) {
Log.e(R.id.class.getName(), e.getMessage());
}
}
}
viewIds.add(R.id.wizard_dragbutton);
viewIds.add(R.id.cpp_button_vars);
viewIds.add(R.id.cpp_button_round_brackets);
viewIds.add(R.id.cpp_button_right);
viewIds.add(R.id.cpp_button_plus);
viewIds.add(R.id.cpp_button_operators);
viewIds.add(R.id.cpp_button_multiplication);
viewIds.add(R.id.cpp_button_subtraction);
viewIds.add(R.id.cpp_button_left);
viewIds.add(R.id.cpp_button_history);
viewIds.add(R.id.cpp_button_functions);
viewIds.add(R.id.cpp_button_equals);
viewIds.add(R.id.cpp_button_period);
viewIds.add(R.id.cpp_button_division);
viewIds.add(R.id.cpp_button_9);
viewIds.add(R.id.cpp_button_8);
viewIds.add(R.id.cpp_button_7);
viewIds.add(R.id.cpp_button_6);
viewIds.add(R.id.cpp_button_5);
viewIds.add(R.id.cpp_button_4);
viewIds.add(R.id.cpp_button_3);
viewIds.add(R.id.cpp_button_2);
viewIds.add(R.id.cpp_button_1);
viewIds.add(R.id.cpp_button_0);
viewIds.add(R.id.cpp_button_clear);
}
return viewIds;
}
@ -286,23 +316,8 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
return (T) views.findViewById(buttonId);
}
@Nonnull
private SimpleDragListener newOnDragListener(@Nonnull SimpleDragListener.DragProcessor dragProcessor,
@Nonnull SimpleDragListener.Preferences dragPreferences) {
final SimpleDragListener onDragListener = new SimpleDragListener(dragProcessor, dragPreferences);
dpclRegister.addListener(onDragListener);
return onDragListener;
}
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
if (key.startsWith("org.solovyev.android.calculator.DragButtonCalibrationActivity")) {
final SimpleDragListener.Preferences dragPreferences = SimpleDragListener.getPreferences(preferences, CalculatorApplication.getInstance());
for (DragPreferencesChangeListener dragPreferencesChangeListener : dpclRegister.getListeners()) {
dragPreferencesChangeListener.onDragPreferencesChange(dragPreferences);
}
}
if (angleUnit.isSameKey(key) || numeralBase.isSameKey(key)) {
if (angleUnitsButton != null) {
angleUnitsButton.setAngleUnit(angleUnit.getPreference(preferences));
@ -313,10 +328,4 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
}
}
}
public void onDestroy(@Nonnull Activity activity) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
preferences.unregisterOnSharedPreferenceChangeListener(this);
}
}

View File

@ -0,0 +1,113 @@
package org.solovyev.android.calculator;
import android.support.annotation.IdRes;
import android.view.View;
import android.widget.Button;
import org.solovyev.android.calculator.view.ViewsCache;
import javax.annotation.Nonnull;
final class ButtonOnClickListener implements View.OnClickListener {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cpp_button_0:
case R.id.cpp_button_1:
case R.id.cpp_button_2:
case R.id.cpp_button_3:
case R.id.cpp_button_4:
case R.id.cpp_button_5:
case R.id.cpp_button_6:
case R.id.cpp_button_7:
case R.id.cpp_button_8:
case R.id.cpp_button_9:
case R.id.cpp_button_division:
case R.id.cpp_button_period:
case R.id.cpp_button_left:
case R.id.cpp_button_subtraction:
case R.id.cpp_button_multiplication:
case R.id.cpp_button_plus:
case R.id.cpp_button_right:
case R.id.cpp_button_round_brackets:
onClick(((Button) v).getText().toString());
break;
case R.id.cpp_button_clear:
onClick(CalculatorSpecialButton.clear);
break;
case R.id.cpp_button_functions:
onClick(CalculatorSpecialButton.functions);
break;
case R.id.cpp_button_history:
onClick(CalculatorSpecialButton.history);
break;
case R.id.cpp_button_erase:
onClick(CalculatorSpecialButton.erase);
break;
case R.id.cpp_button_paste:
onClick(CalculatorSpecialButton.paste);
break;
case R.id.cpp_button_copy:
onClick(CalculatorSpecialButton.copy);
break;
case R.id.cpp_button_like:
onClick(CalculatorSpecialButton.like);
break;
case R.id.cpp_button_operators:
onClick(CalculatorSpecialButton.operators);
break;
case R.id.cpp_button_vars:
onClick(CalculatorSpecialButton.vars);
break;
case R.id.cpp_button_equals:
onClick(CalculatorSpecialButton.equals);
break;
}
}
private void onClick(@Nonnull CalculatorSpecialButton b) {
onClick(b.getActionCode());
}
private void onClick(@Nonnull String s) {
Locator.getInstance().getKeyboard().buttonPressed(s);
}
public void attachToViews(@Nonnull ViewsCache views) {
attachToView(views, R.id.cpp_button_0);
attachToView(views, R.id.cpp_button_1);
attachToView(views, R.id.cpp_button_2);
attachToView(views, R.id.cpp_button_3);
attachToView(views, R.id.cpp_button_4);
attachToView(views, R.id.cpp_button_5);
attachToView(views, R.id.cpp_button_6);
attachToView(views, R.id.cpp_button_7);
attachToView(views, R.id.cpp_button_8);
attachToView(views, R.id.cpp_button_9);
attachToView(views, R.id.cpp_button_division);
attachToView(views, R.id.cpp_button_period);
attachToView(views, R.id.cpp_button_left);
attachToView(views, R.id.cpp_button_subtraction);
attachToView(views, R.id.cpp_button_multiplication);
attachToView(views, R.id.cpp_button_plus);
attachToView(views, R.id.cpp_button_right);
attachToView(views, R.id.cpp_button_round_brackets);
attachToView(views, R.id.cpp_button_clear);
attachToView(views, R.id.cpp_button_functions);
attachToView(views, R.id.cpp_button_history);
attachToView(views, R.id.cpp_button_erase);
attachToView(views, R.id.cpp_button_paste);
attachToView(views, R.id.cpp_button_copy);
attachToView(views, R.id.cpp_button_like);
attachToView(views, R.id.cpp_button_operators);
attachToView(views, R.id.cpp_button_vars);
attachToView(views, R.id.cpp_button_equals);
}
private void attachToView(@Nonnull ViewsCache views, @IdRes int viewId) {
final View view = views.findViewById(viewId);
if (view != null) {
view.setOnClickListener(this);
}
}
}

View File

@ -32,9 +32,7 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBar;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.*;
import android.widget.Button;
import android.widget.TextView;
import org.solovyev.android.Activities;
import org.solovyev.android.Android;
@ -55,10 +53,8 @@ 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.about.CalculatorReleaseNotesFragment.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 static org.solovyev.android.calculator.release.ReleaseNotes.hasReleaseNotes;
import static org.solovyev.android.wizard.WizardUi.*;
public class CalculatorActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEventListener {
@ -215,11 +211,6 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
return super.onKeyDown(keyCode, event);
}
@SuppressWarnings({"UnusedDeclaration"})
public void equalsButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.equals);
}
@Override
protected void onResume() {
super.onResume();
@ -265,80 +256,6 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
}
}
/*
**********************************************************************
*
* BUTTON HANDLERS
*
**********************************************************************
*/
@SuppressWarnings({"UnusedDeclaration"})
public void elementaryButtonClickHandler(@Nonnull View v) {
throw new UnsupportedOperationException("Not implemented yet!");
}
public void historyButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.history);
}
public void eraseButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.erase);
}
public void simplifyButtonClickHandler(@Nonnull View v) {
throw new UnsupportedOperationException("Not implemented yet!");
}
public void pasteButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.paste);
}
public void copyButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.copy);
}
@Nonnull
private static CalculatorKeyboard getKeyboard() {
return Locator.getInstance().getKeyboard();
}
public void clearButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.clear);
}
public void digitButtonClickHandler(@Nonnull View v) {
Log.d(String.valueOf(v.getId()), "digitButtonClickHandler() for: " + v.getId() + ". Pressed: " + v.isPressed());
if (v instanceof Button) {
buttonPressed(((Button) v).getText().toString());
}
}
private void buttonPressed(@Nonnull CalculatorSpecialButton button) {
buttonPressed(button.getActionCode());
}
private void buttonPressed(@Nonnull String text) {
getKeyboard().buttonPressed(text);
}
public void functionsButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.functions);
}
public void operatorsButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.operators);
}
public void varsButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.vars);
}
public void likeButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.like);
}
@Override
public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) {

View File

@ -59,9 +59,9 @@ public final class CalculatorButtons {
}
public static void processButtons(@Nonnull Preferences.Gui.Theme theme,
@Nonnull Preferences.Gui.Layout layout,
@Nonnull View root) {
public static void fixButtonsTextSize(@Nonnull Preferences.Gui.Theme theme,
@Nonnull Preferences.Gui.Layout layout,
@Nonnull View root) {
if (!layout.isOptimized()) {
final float textSize = root.getContext().getResources().getDimension(R.dimen.cpp_keyboard_button_text_size_mobile);

View File

@ -158,7 +158,10 @@ public class FragmentUi extends BaseUi {
}
}
processButtons(fragment.getActivity(), root);
if (fragment instanceof CalculatorKeyboardFragment) {
processButtons(fragment.getActivity(), root);
}
fixFonts(root);
if (titleResId >= 0) {
this.setPaneTitle(fragment, titleResId);

View File

@ -101,31 +101,30 @@ public final class Preferences {
public static enum Theme {
default_theme(R.style.cpp_gray_theme),
violet_theme(R.style.cpp_violet_theme),
light_blue_theme(R.style.cpp_light_blue_theme),
metro_blue_theme(R.style.cpp_metro_blue_theme),
metro_purple_theme(R.style.cpp_metro_purple_theme),
metro_green_theme(R.style.cpp_metro_green_theme),
material_theme(R.style.cpp_material_theme),
default_theme(R.style.cpp_gray_theme, R.style.Theme_Wizard),
violet_theme(R.style.cpp_violet_theme, R.style.Theme_Wizard),
light_blue_theme(R.style.cpp_light_blue_theme, R.style.Theme_Wizard),
metro_blue_theme(R.style.cpp_metro_blue_theme, R.style.Theme_Wizard),
metro_purple_theme(R.style.cpp_metro_purple_theme, R.style.Theme_Wizard),
metro_green_theme(R.style.cpp_metro_green_theme, R.style.Theme_Wizard),
material_theme(R.style.cpp_material_theme, R.style.Theme_Wizard),
;
@Nonnull
private final Integer themeId;
private final int themeId;
private final int wizardThemeId;
Theme(@Nonnull Integer themeId) {
Theme(int themeId, int wizardThemeId) {
this.themeId = themeId;
this.wizardThemeId = wizardThemeId;
}
@Nonnull
public Integer getThemeId() {
public int getThemeId() {
return getThemeId(null);
}
@Nonnull
public Integer getThemeId(@Nullable Activity activity) {
public int getThemeId(@Nullable Activity activity) {
if (activity instanceof WizardActivity) {
return R.style.Theme_Wizard;
return wizardThemeId;
}
return themeId;
}

View File

@ -22,23 +22,15 @@
package org.solovyev.android.calculator.about;
import android.content.Context;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.TextView;
import org.solovyev.android.calculator.CalculatorApplication;
import org.solovyev.android.calculator.CalculatorFragment;
import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R;
import org.solovyev.common.text.Strings;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import static org.solovyev.android.Android.getAppVersionCode;
import org.solovyev.android.calculator.release.ReleaseNotes;
/**
* User: serso
@ -58,88 +50,6 @@ public class CalculatorReleaseNotesFragment extends CalculatorFragment {
final TextView releaseNotes = (TextView) root.findViewById(R.id.releaseNotesTextView);
releaseNotes.setMovementMethod(LinkMovementMethod.getInstance());
releaseNotes.setText(Html.fromHtml(getReleaseNotes(this.getActivity())));
}
@Nonnull
public static String getReleaseNotes(@Nonnull Context context) {
return getReleaseNotesString(context, 0);
}
@Nonnull
public static String getReleaseNotesString(@Nonnull Context context, int minVersion) {
final StringBuilder result = new StringBuilder();
final String releaseNotesForTitle = context.getString(R.string.c_release_notes_for_title);
final int currentVersionCode = getAppVersionCode(context);
final TextHelper textHelper = new TextHelper(context.getResources(), CalculatorApplication.class.getPackage().getName());
boolean first = true;
for (int versionCode = currentVersionCode; versionCode >= minVersion; versionCode--) {
final String versionName = getVersionName(textHelper, versionCode);
String releaseNotesForVersion = textHelper.getText(makeReleaseNotesResourceId(versionCode));
if (!Strings.isEmpty(releaseNotesForVersion)) {
if (!first) {
result.append("<br/><br/>");
} else {
first = false;
}
releaseNotesForVersion = releaseNotesForVersion.replace("\n", "<br/>");
result.append("<b>").append(releaseNotesForTitle).append(versionName).append("</b><br/><br/>");
result.append(releaseNotesForVersion);
}
}
return result.toString();
}
@Nonnull
public static List<Integer> getReleaseNotesVersions(@Nonnull Context context, int minVersion) {
final List<Integer> releaseNotes = new ArrayList<>();
final int currentVersionCode = getAppVersionCode(context);
final TextHelper textHelper = new TextHelper(context.getResources(), CalculatorApplication.class.getPackage().getName());
for (int versionCode = currentVersionCode; versionCode >= minVersion; versionCode--) {
final String releaseNotesForVersion = textHelper.getText(makeReleaseNotesResourceId(versionCode));
if (!Strings.isEmpty(releaseNotesForVersion)) {
releaseNotes.add(versionCode);
}
}
return releaseNotes;
}
public static boolean hasReleaseNotes(@Nonnull Context context, int minVersion) {
final int currentVersionCode = getAppVersionCode(context);
final TextHelper textHelper = new TextHelper(context.getResources(), CalculatorApplication.class.getPackage().getName());
for (int versionCode = currentVersionCode; versionCode >= minVersion; versionCode--) {
String releaseNotesForVersion = textHelper.getText(makeReleaseNotesResourceId(versionCode));
if (!Strings.isEmpty(releaseNotesForVersion)) {
return true;
}
}
return false;
}
@Nonnull
public static String getVersionName(@Nonnull TextHelper textHelper, int versionCode) {
final String versionName = textHelper.getText(makeVersionResourceId(versionCode));
if (versionName != null) {
return versionName;
} else {
return String.valueOf(versionCode);
}
}
public static String makeReleaseNotesResourceId(int versionCode) {
return "c_release_notes_for_" + versionCode;
}
private static String makeVersionResourceId(int versionCode) {
return "c_release_notes_for_" + versionCode + "_version";
releaseNotes.setText(Html.fromHtml(ReleaseNotes.getReleaseNotes(this.getActivity())));
}
}

View File

@ -9,7 +9,6 @@ import android.widget.TextView;
import com.google.common.base.Strings;
import org.solovyev.android.calculator.CalculatorApplication;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment;
import org.solovyev.android.calculator.about.TextHelper;
import org.solovyev.android.calculator.wizard.WizardFragment;
@ -45,12 +44,12 @@ public class ReleaseNoteFragment extends WizardFragment {
@Nonnull
private String getReleaseNoteVersion(@Nonnull TextHelper textHelper) {
return CalculatorReleaseNotesFragment.getVersionName(textHelper, version);
return ReleaseNotes.getVersionName(textHelper, version);
}
@Nonnull
private String getReleaseNote(@Nonnull TextHelper textHelper) {
final String resourceId = CalculatorReleaseNotesFragment.makeReleaseNotesResourceId(version);
final String resourceId = ReleaseNotes.makeReleaseNotesResourceId(version);
return Strings.nullToEmpty(textHelper.getText(resourceId)).replace("\n", "<br/>");
}
}

View File

@ -0,0 +1,103 @@
package org.solovyev.android.calculator.release;
import android.content.Context;
import org.solovyev.android.calculator.CalculatorApplication;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.about.TextHelper;
import org.solovyev.common.text.Strings;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import static org.solovyev.android.Android.getAppVersionCode;
public final class ReleaseNotes {
@Nonnull
public static String getReleaseNotes(@Nonnull Context context) {
return getReleaseNotesString(context, 0);
}
@Nonnull
public static String getReleaseNotesString(@Nonnull Context context, int minVersion) {
final StringBuilder result = new StringBuilder();
final String releaseNotesForTitle = context.getString(R.string.c_release_notes_for_title);
final int currentVersionCode = getAppVersionCode(context);
final TextHelper textHelper = new TextHelper(context.getResources(), CalculatorApplication.class.getPackage().getName());
boolean first = true;
for (int versionCode = currentVersionCode; versionCode >= minVersion; versionCode--) {
final String versionName = getVersionName(textHelper, versionCode);
String releaseNotesForVersion = textHelper.getText(makeReleaseNotesResourceId(versionCode));
if (!Strings.isEmpty(releaseNotesForVersion)) {
if (!first) {
result.append("<br/><br/>");
} else {
first = false;
}
releaseNotesForVersion = releaseNotesForVersion.replace("\n", "<br/>");
result.append("<b>").append(releaseNotesForTitle).append(versionName).append("</b><br/><br/>");
result.append(releaseNotesForVersion);
}
}
return result.toString();
}
@Nonnull
public static List<Integer> getReleaseNotesVersions(@Nonnull Context context, int minVersion) {
final List<Integer> releaseNotes = new ArrayList<>();
final int currentVersionCode = getAppVersionCode(context);
final TextHelper textHelper = new TextHelper(context.getResources(), CalculatorApplication.class.getPackage().getName());
for (int versionCode = currentVersionCode; versionCode >= minVersion; versionCode--) {
if (versionCode == 136) {
releaseNotes.add(136);
}
final String releaseNotesForVersion = textHelper.getText(makeReleaseNotesResourceId(versionCode));
if (!Strings.isEmpty(releaseNotesForVersion)) {
releaseNotes.add(versionCode);
}
}
return releaseNotes;
}
public static boolean hasReleaseNotes(@Nonnull Context context, int minVersion) {
final int currentVersionCode = getAppVersionCode(context);
final TextHelper textHelper = new TextHelper(context.getResources(), CalculatorApplication.class.getPackage().getName());
for (int versionCode = currentVersionCode; versionCode >= minVersion; versionCode--) {
if (versionCode == 136) {
return true;
}
String releaseNotesForVersion = textHelper.getText(makeReleaseNotesResourceId(versionCode));
if (!Strings.isEmpty(releaseNotesForVersion)) {
return true;
}
}
return false;
}
@Nonnull
public static String getVersionName(@Nonnull TextHelper textHelper, int versionCode) {
final String versionName = textHelper.getText(makeVersionResourceId(versionCode));
if (versionName != null) {
return versionName;
} else {
return String.valueOf(versionCode);
}
}
public static String makeReleaseNotesResourceId(int versionCode) {
return "c_release_notes_for_" + versionCode;
}
private static String makeVersionResourceId(int versionCode) {
return "c_release_notes_for_" + versionCode + "_version";
}
}

View File

@ -41,6 +41,7 @@ enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep {
}
},
choose_mode(ChooseModeWizardStep.class, R.string.cpp_wizard_mode_title),
choose_theme(ChooseThemeWizardStep.class, R.string.cpp_wizard_theme_title),
on_screen_calculator(OnScreenCalculatorWizardStep.class, R.string.cpp_wizard_onscreen_calculator_title),
drag_button(DragButtonWizardStep.class, R.string.cpp_wizard_dragbutton_title),
last(FinalWizardStep.class, R.string.cpp_wizard_final_title);

View File

@ -3,8 +3,8 @@ package org.solovyev.android.calculator.wizard;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment;
import org.solovyev.android.calculator.release.ReleaseNoteStep;
import org.solovyev.android.calculator.release.ReleaseNotes;
import org.solovyev.android.wizard.*;
import javax.annotation.Nonnull;
@ -79,13 +79,21 @@ public class CalculatorWizards implements Wizards {
static WizardFlow newReleaseNotesWizardFlow(@Nonnull Context context, @Nullable Bundle arguments) {
final List<WizardStep> wizardSteps = new ArrayList<WizardStep>();
final int startVersion = arguments != null ? arguments.getInt(RELEASE_NOTES_VERSION, 0) : 0;
List<Integer> versions = CalculatorReleaseNotesFragment.getReleaseNotesVersions(context, startVersion);
List<Integer> versions = ReleaseNotes.getReleaseNotesVersions(context, startVersion);
final int size = versions.size();
if (size > 7) {
versions = versions.subList(0, 7);
}
for (Integer version : versions) {
wizardSteps.add(new ReleaseNoteStep(version));
switch (version) {
case 136:
wizardSteps.add(CalculatorWizardStep.choose_theme);
break;
default:
wizardSteps.add(new ReleaseNoteStep(version));
break;
}
}
return new ListWizardFlow(wizardSteps);
}

View File

@ -58,7 +58,7 @@ public class ChooseLayoutWizardStep extends WizardFragment implements AdapterVie
image = (ImageView) root.findViewById(R.id.wizard_layout_image);
final Spinner spinner = (Spinner) root.findViewById(R.id.wizard_layout_spinner);
spinner.setAdapter(new WizardArrayAdapter(getActivity(), R.array.cpp_layouts));
spinner.setAdapter(WizardArrayAdapter.create(getActivity(), R.array.cpp_layouts));
spinner.setSelection(layout == big_buttons ? 0 : 1);
spinner.setOnItemSelectedListener(this);

View File

@ -55,7 +55,7 @@ public class ChooseModeWizardStep extends WizardFragment implements AdapterView.
final CalculatorMode mode = CalculatorMode.fromGuiLayout(Preferences.Gui.layout.getPreference(getPreferences()));
final Spinner spinner = (Spinner) root.findViewById(R.id.wizard_mode_spinner);
spinner.setAdapter(new WizardArrayAdapter(getActivity(), R.array.cpp_modes));
spinner.setAdapter(WizardArrayAdapter.create(getActivity(), R.array.cpp_modes));
spinner.setSelection(mode == simple ? 0 : 1);
spinner.setOnItemSelectedListener(this);

View File

@ -0,0 +1,117 @@
/*
* Copyright 2013 serso aka se.solovyev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Contact details
*
* Email: se.solovyev@gmail.com
* Site: http://se.solovyev.org
*/
package org.solovyev.android.calculator.wizard;
import android.os.Bundle;
import android.support.annotation.StringRes;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.Spinner;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import static org.solovyev.android.calculator.CalculatorApplication.getPreferences;
public class ChooseThemeWizardStep extends WizardFragment implements AdapterView.OnItemSelectedListener {
private FrameLayout preview;
@Nonnull
private final List<ThemeUi> themes = new ArrayList<>();
private WizardArrayAdapter<ThemeUi> adapter;
@Override
protected int getViewResId() {
return R.layout.cpp_wizard_step_choose_theme;
}
@Override
public void onViewCreated(View root, Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState);
final Preferences.Gui.Theme theme = Preferences.Gui.getTheme(getPreferences());
final Spinner spinner = (Spinner) root.findViewById(R.id.wizard_theme_spinner);
themes.clear();
themes.add(new ThemeUi(Preferences.Gui.Theme.material_theme, R.string.p_material_theme));
themes.add(new ThemeUi(Preferences.Gui.Theme.metro_blue_theme, R.string.p_metro_blue_theme));
themes.add(new ThemeUi(Preferences.Gui.Theme.metro_green_theme, R.string.p_metro_green_theme));
themes.add(new ThemeUi(Preferences.Gui.Theme.metro_purple_theme, R.string.p_metro_purple_theme));
adapter = new WizardArrayAdapter<>(getActivity(), themes);
spinner.setAdapter(adapter);
spinner.setSelection(findPosition(theme));
spinner.setOnItemSelectedListener(this);
preview = (FrameLayout) root.findViewById(R.id.wizard_theme_preview);
updateImage(theme);
}
private int findPosition(@Nonnull Preferences.Gui.Theme theme) {
for (int i = 0; i < themes.size(); i++) {
if (theme.equals(themes.get(i).theme)) {
return i;
}
}
return 0;
}
private void updateImage(@Nonnull Preferences.Gui.Theme theme) {
preview.removeAllViews();
final ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), theme.getThemeId());
LayoutInflater.from(context).inflate(R.layout.cpp_wizard_step_choose_theme_preview, preview);
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
final ThemeUi theme = adapter.getItem(position);
Preferences.Gui.theme.putPreference(getPreferences(), theme.theme);
updateImage(theme.theme);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
private final class ThemeUi {
@Nonnull
final Preferences.Gui.Theme theme;
@Nonnull
final String name;
public ThemeUi(@Nonnull Preferences.Gui.Theme theme, @StringRes int name) {
this.theme = theme;
this.name = getString(name);
}
@Override
public String toString() {
return name;
}
}
}

View File

@ -7,10 +7,23 @@ import android.widget.ArrayAdapter;
import android.widget.TextView;
import org.solovyev.android.calculator.R;
final class WizardArrayAdapter extends ArrayAdapter<String> {
import javax.annotation.Nonnull;
import java.util.List;
public WizardArrayAdapter(Context context, int array) {
super(context, R.layout.support_simple_spinner_dropdown_item, context.getResources().getStringArray(array));
final class WizardArrayAdapter<T> extends ArrayAdapter<T> {
public WizardArrayAdapter(@Nonnull Context context, @Nonnull T[] items) {
super(context, R.layout.support_simple_spinner_dropdown_item, items);
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}
@Nonnull
public static WizardArrayAdapter<String> create(@Nonnull Context context, int array) {
return new WizardArrayAdapter<>(context, context.getResources().getStringArray(array));
}
public WizardArrayAdapter(@Nonnull Context context, @Nonnull List<T> items) {
super(context, R.layout.support_simple_spinner_dropdown_item, items);
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}

View File

@ -34,21 +34,21 @@
a:baselineAligned="false"
a:orientation="horizontal">
<include layout="@layout/cpp_drag_button_vars" />
<include layout="@layout/cpp_app_button_vars" />
<include layout="@layout/cpp_app_button_copy" />
<include layout="@layout/cpp_drag_button_7" />
<include layout="@layout/cpp_app_button_7" />
<include layout="@layout/cpp_drag_button_8" />
<include layout="@layout/cpp_app_button_8" />
<include layout="@layout/cpp_drag_button_9" />
<include layout="@layout/cpp_app_button_9" />
<include layout="@layout/cpp_drag_button_multiplication" />
<include layout="@layout/cpp_app_button_multiplication" />
<include layout="@layout/cpp_drag_button_division" />
<include layout="@layout/cpp_app_button_division" />
<include layout="@layout/cpp_drag_button_equals" />
<include layout="@layout/cpp_app_button_equals" />
</LinearLayout>
@ -59,21 +59,21 @@
a:baselineAligned="false"
a:orientation="horizontal">
<include layout="@layout/cpp_drag_button_functions" />
<include layout="@layout/cpp_app_button_functions" />
<include layout="@layout/cpp_app_button_paste" />
<include layout="@layout/cpp_drag_button_4" />
<include layout="@layout/cpp_app_button_4" />
<include layout="@layout/cpp_drag_button_5" />
<include layout="@layout/cpp_app_button_5" />
<include layout="@layout/cpp_drag_button_6" />
<include layout="@layout/cpp_app_button_6" />
<include layout="@layout/cpp_drag_button_plus" />
<include layout="@layout/cpp_app_button_plus" />
<include layout="@layout/cpp_drag_button_subtraction" />
<include layout="@layout/cpp_app_button_minus" />
<include layout="@layout/cpp_drag_button_round_brackets" />
<include layout="@layout/cpp_app_button_round_brackets" />
</LinearLayout>
@ -84,21 +84,21 @@
a:baselineAligned="false"
a:orientation="horizontal">
<include layout="@layout/cpp_drag_button_operators" />
<include layout="@layout/cpp_app_button_operators" />
<include layout="@layout/cpp_app_button_donate" />
<include layout="@layout/cpp_drag_button_1" />
<include layout="@layout/cpp_app_button_1" />
<include layout="@layout/cpp_drag_button_2" />
<include layout="@layout/cpp_app_button_2" />
<include layout="@layout/cpp_drag_button_3" />
<include layout="@layout/cpp_app_button_3" />
<include layout="@layout/cpp_drag_button_0" />
<include layout="@layout/cpp_app_button_0" />
<include layout="@layout/cpp_drag_button_dot" />
<include layout="@layout/cpp_app_button_dot" />
<include layout="@layout/cpp_drag_button_history" />
<include layout="@layout/cpp_app_button_history" />
</LinearLayout>

View File

@ -32,21 +32,21 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_vars"/>
<include layout="@layout/cpp_app_button_vars"/>
<include layout="@layout/cpp_app_button_copy"/>
<include layout="@layout/cpp_drag_button_7"/>
<include layout="@layout/cpp_app_button_7"/>
<include layout="@layout/cpp_drag_button_8"/>
<include layout="@layout/cpp_app_button_8"/>
<include layout="@layout/cpp_drag_button_9"/>
<include layout="@layout/cpp_app_button_9"/>
<include layout="@layout/cpp_drag_button_multiplication"/>
<include layout="@layout/cpp_app_button_multiplication"/>
<include layout="@layout/cpp_drag_button_division"/>
<include layout="@layout/cpp_app_button_division"/>
<include layout="@layout/cpp_drag_button_equals"/>
<include layout="@layout/cpp_app_button_equals"/>
</LinearLayout>
@ -55,21 +55,21 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_functions"/>
<include layout="@layout/cpp_app_button_functions"/>
<include layout="@layout/cpp_app_button_paste"/>
<include layout="@layout/cpp_drag_button_4"/>
<include layout="@layout/cpp_app_button_4"/>
<include layout="@layout/cpp_drag_button_5"/>
<include layout="@layout/cpp_app_button_5"/>
<include layout="@layout/cpp_drag_button_6"/>
<include layout="@layout/cpp_app_button_6"/>
<include layout="@layout/cpp_drag_button_plus"/>
<include layout="@layout/cpp_app_button_plus"/>
<include layout="@layout/cpp_drag_button_subtraction"/>
<include layout="@layout/cpp_app_button_minus"/>
<include layout="@layout/cpp_drag_button_round_brackets"/>
<include layout="@layout/cpp_app_button_round_brackets"/>
</LinearLayout>
@ -78,21 +78,21 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_operators"/>
<include layout="@layout/cpp_app_button_operators"/>
<include layout="@layout/cpp_app_button_donate"/>
<include layout="@layout/cpp_drag_button_1"/>
<include layout="@layout/cpp_app_button_1"/>
<include layout="@layout/cpp_drag_button_2"/>
<include layout="@layout/cpp_app_button_2"/>
<include layout="@layout/cpp_drag_button_3"/>
<include layout="@layout/cpp_app_button_3"/>
<include layout="@layout/cpp_drag_button_0"/>
<include layout="@layout/cpp_app_button_0"/>
<include layout="@layout/cpp_drag_button_dot"/>
<include layout="@layout/cpp_app_button_dot"/>
<include layout="@layout/cpp_drag_button_history"/>
<include layout="@layout/cpp_app_button_history"/>
</LinearLayout>

View File

@ -42,7 +42,7 @@
a:orientation="horizontal">
<include
layout="@layout/cpp_drag_button_left"
layout="@layout/cpp_app_button_left"
a:layout_width="0dp"
a:layout_height="match_parent"
a:layout_weight="1"/>
@ -61,13 +61,13 @@
a:orientation="horizontal" />
<include
layout="@layout/cpp_drag_button_clear"
layout="@layout/cpp_app_button_clear"
a:layout_width="0dp"
a:layout_height="match_parent"
a:layout_weight="1"/>
<include
layout="@layout/cpp_drag_button_right"
layout="@layout/cpp_app_button_right"
a:layout_width="0dp"
a:layout_height="match_parent"
a:layout_weight="1"/>

View File

@ -39,7 +39,7 @@
a:layout_height="0dp">
<include
layout="@layout/cpp_drag_button_left"
layout="@layout/cpp_app_button_left"
a:layout_width="0dp"
a:layout_height="match_parent"
a:layout_weight="1"/>
@ -57,13 +57,13 @@
a:layout_weight="4"/>
<include
layout="@layout/cpp_drag_button_clear"
layout="@layout/cpp_app_button_clear"
a:layout_width="0dp"
a:layout_height="match_parent"
a:layout_weight="1"/>
<include
layout="@layout/cpp_drag_button_right"
layout="@layout/cpp_app_button_right"
a:layout_width="0dp"
a:layout_height="match_parent"
a:layout_weight="1"/>

View File

@ -32,25 +32,25 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_left"/>
<include layout="@layout/cpp_app_button_left"/>
<include layout="@layout/cpp_app_button_erase"/>
<include layout="@layout/cpp_app_button_donate"/>
<include layout="@layout/cpp_drag_button_7"/>
<include layout="@layout/cpp_app_button_7"/>
<include layout="@layout/cpp_drag_button_8"/>
<include layout="@layout/cpp_app_button_8"/>
<include layout="@layout/cpp_drag_button_9"/>
<include layout="@layout/cpp_app_button_9"/>
<include layout="@layout/cpp_drag_button_multiplication"/>
<include layout="@layout/cpp_app_button_multiplication"/>
<include layout="@layout/cpp_drag_button_division"/>
<include layout="@layout/cpp_app_button_division"/>
<include layout="@layout/cpp_drag_button_clear"/>
<include layout="@layout/cpp_app_button_clear"/>
<include layout="@layout/cpp_drag_button_right"/>
<include layout="@layout/cpp_app_button_right"/>
</LinearLayout>
@ -59,25 +59,25 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_vars"/>
<include layout="@layout/cpp_app_button_vars"/>
<include layout="@layout/cpp_drag_button_functions"/>
<include layout="@layout/cpp_app_button_functions"/>
<include layout="@layout/cpp_drag_button_empty"/>
<include layout="@layout/cpp_app_button_empty"/>
<include layout="@layout/cpp_drag_button_4"/>
<include layout="@layout/cpp_app_button_4"/>
<include layout="@layout/cpp_drag_button_5"/>
<include layout="@layout/cpp_app_button_5"/>
<include layout="@layout/cpp_drag_button_6"/>
<include layout="@layout/cpp_app_button_6"/>
<include layout="@layout/cpp_drag_button_plus"/>
<include layout="@layout/cpp_app_button_plus"/>
<include layout="@layout/cpp_drag_button_subtraction"/>
<include layout="@layout/cpp_app_button_minus"/>
<include layout="@layout/cpp_app_button_copy"/>
<include layout="@layout/cpp_drag_button_equals"/>
<include layout="@layout/cpp_app_button_equals"/>
</LinearLayout>
@ -86,25 +86,25 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_empty"/>
<include layout="@layout/cpp_app_button_empty"/>
<include layout="@layout/cpp_drag_button_operators"/>
<include layout="@layout/cpp_app_button_operators"/>
<include layout="@layout/cpp_drag_button_dot"/>
<include layout="@layout/cpp_app_button_dot"/>
<include layout="@layout/cpp_drag_button_1"/>
<include layout="@layout/cpp_app_button_1"/>
<include layout="@layout/cpp_drag_button_2"/>
<include layout="@layout/cpp_app_button_2"/>
<include layout="@layout/cpp_drag_button_3"/>
<include layout="@layout/cpp_app_button_3"/>
<include layout="@layout/cpp_drag_button_0"/>
<include layout="@layout/cpp_app_button_0"/>
<include layout="@layout/cpp_drag_button_round_brackets"/>
<include layout="@layout/cpp_app_button_round_brackets"/>
<include layout="@layout/cpp_app_button_paste"/>
<include layout="@layout/cpp_drag_button_history"/>
<include layout="@layout/cpp_app_button_history"/>
</LinearLayout>

View File

@ -32,19 +32,19 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_left"/>
<include layout="@layout/cpp_app_button_left"/>
<include layout="@layout/cpp_app_button_erase"/>
<include layout="@layout/cpp_drag_button_7"/>
<include layout="@layout/cpp_app_button_7"/>
<include layout="@layout/cpp_drag_button_8"/>
<include layout="@layout/cpp_app_button_8"/>
<include layout="@layout/cpp_drag_button_9"/>
<include layout="@layout/cpp_app_button_9"/>
<include layout="@layout/cpp_drag_button_multiplication"/>
<include layout="@layout/cpp_app_button_multiplication"/>
<include layout="@layout/cpp_drag_button_right"/>
<include layout="@layout/cpp_app_button_right"/>
</LinearLayout>
@ -53,17 +53,17 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_vars"/>
<include layout="@layout/cpp_app_button_vars"/>
<include layout="@layout/cpp_drag_button_clear"/>
<include layout="@layout/cpp_app_button_clear"/>
<include layout="@layout/cpp_drag_button_4"/>
<include layout="@layout/cpp_app_button_4"/>
<include layout="@layout/cpp_drag_button_5"/>
<include layout="@layout/cpp_app_button_5"/>
<include layout="@layout/cpp_drag_button_6"/>
<include layout="@layout/cpp_app_button_6"/>
<include layout="@layout/cpp_drag_button_division"/>
<include layout="@layout/cpp_app_button_division"/>
<include layout="@layout/cpp_app_button_copy"/>
@ -74,17 +74,17 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_functions"/>
<include layout="@layout/cpp_app_button_functions"/>
<include layout="@layout/cpp_drag_button_equals"/>
<include layout="@layout/cpp_app_button_equals"/>
<include layout="@layout/cpp_drag_button_1"/>
<include layout="@layout/cpp_app_button_1"/>
<include layout="@layout/cpp_drag_button_2"/>
<include layout="@layout/cpp_app_button_2"/>
<include layout="@layout/cpp_drag_button_3"/>
<include layout="@layout/cpp_app_button_3"/>
<include layout="@layout/cpp_drag_button_plus"/>
<include layout="@layout/cpp_app_button_plus"/>
<include layout="@layout/cpp_app_button_paste"/>
@ -95,19 +95,19 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_operators"/>
<include layout="@layout/cpp_app_button_operators"/>
<include layout="@layout/cpp_app_button_donate"/>
<include layout="@layout/cpp_drag_button_round_brackets"/>
<include layout="@layout/cpp_app_button_round_brackets"/>
<include layout="@layout/cpp_drag_button_0"/>
<include layout="@layout/cpp_app_button_0"/>
<include layout="@layout/cpp_drag_button_dot"/>
<include layout="@layout/cpp_app_button_dot"/>
<include layout="@layout/cpp_drag_button_subtraction"/>
<include layout="@layout/cpp_app_button_minus"/>
<include layout="@layout/cpp_drag_button_history"/>
<include layout="@layout/cpp_app_button_history"/>
</LinearLayout>

View File

@ -32,33 +32,33 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_left"/>
<include layout="@layout/cpp_app_button_left"/>
<include layout="@layout/cpp_drag_button_vars"/>
<include layout="@layout/cpp_app_button_vars"/>
<include layout="@layout/cpp_app_button_copy"/>
<include layout="@layout/cpp_drag_button_6"/>
<include layout="@layout/cpp_app_button_6"/>
<include layout="@layout/cpp_drag_button_7"/>
<include layout="@layout/cpp_app_button_7"/>
<include layout="@layout/cpp_drag_button_8"/>
<include layout="@layout/cpp_app_button_8"/>
<include layout="@layout/cpp_drag_button_9"/>
<include layout="@layout/cpp_app_button_9"/>
<include layout="@layout/cpp_drag_button_0"/>
<include layout="@layout/cpp_app_button_0"/>
<include layout="@layout/cpp_drag_button_multiplication"/>
<include layout="@layout/cpp_app_button_multiplication"/>
<include layout="@layout/cpp_drag_button_division"/>
<include layout="@layout/cpp_app_button_division"/>
<include layout="@layout/cpp_drag_button_equals"/>
<include layout="@layout/cpp_app_button_equals"/>
<include layout="@layout/cpp_drag_button_operators"/>
<include layout="@layout/cpp_app_button_operators"/>
<include layout="@layout/cpp_app_button_donate"/>
<include layout="@layout/cpp_drag_button_right"/>
<include layout="@layout/cpp_app_button_right"/>
</LinearLayout>
@ -69,31 +69,31 @@
<include layout="@layout/cpp_app_button_erase"/>
<include layout="@layout/cpp_drag_button_functions"/>
<include layout="@layout/cpp_app_button_functions"/>
<include layout="@layout/cpp_app_button_paste"/>
<include layout="@layout/cpp_drag_button_1"/>
<include layout="@layout/cpp_app_button_1"/>
<include layout="@layout/cpp_drag_button_2"/>
<include layout="@layout/cpp_app_button_2"/>
<include layout="@layout/cpp_drag_button_3"/>
<include layout="@layout/cpp_app_button_3"/>
<include layout="@layout/cpp_drag_button_4"/>
<include layout="@layout/cpp_app_button_4"/>
<include layout="@layout/cpp_drag_button_5"/>
<include layout="@layout/cpp_app_button_5"/>
<include layout="@layout/cpp_drag_button_plus"/>
<include layout="@layout/cpp_app_button_plus"/>
<include layout="@layout/cpp_drag_button_subtraction"/>
<include layout="@layout/cpp_app_button_minus"/>
<include layout="@layout/cpp_drag_button_round_brackets"/>
<include layout="@layout/cpp_app_button_round_brackets"/>
<include layout="@layout/cpp_drag_button_dot"/>
<include layout="@layout/cpp_app_button_dot"/>
<include layout="@layout/cpp_drag_button_history"/>
<include layout="@layout/cpp_app_button_history"/>
<include layout="@layout/cpp_drag_button_clear"/>
<include layout="@layout/cpp_app_button_clear"/>
</LinearLayout>

View File

@ -32,21 +32,21 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_left"/>
<include layout="@layout/cpp_app_button_left"/>
<include layout="@layout/cpp_app_button_erase"/>
<include layout="@layout/cpp_drag_button_empty"/>
<include layout="@layout/cpp_app_button_empty"/>
<include layout="@layout/cpp_drag_button_empty"/>
<include layout="@layout/cpp_app_button_empty"/>
<include layout="@layout/cpp_drag_button_empty"/>
<include layout="@layout/cpp_app_button_empty"/>
<include layout="@layout/cpp_drag_button_empty"/>
<include layout="@layout/cpp_app_button_empty"/>
<include layout="@layout/cpp_drag_button_clear"/>
<include layout="@layout/cpp_app_button_clear"/>
<include layout="@layout/cpp_drag_button_right"/>
<include layout="@layout/cpp_app_button_right"/>
</LinearLayout>
@ -55,21 +55,21 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_vars"/>
<include layout="@layout/cpp_app_button_vars"/>
<include layout="@layout/cpp_app_button_copy"/>
<include layout="@layout/cpp_drag_button_7"/>
<include layout="@layout/cpp_app_button_7"/>
<include layout="@layout/cpp_drag_button_8"/>
<include layout="@layout/cpp_app_button_8"/>
<include layout="@layout/cpp_drag_button_9"/>
<include layout="@layout/cpp_app_button_9"/>
<include layout="@layout/cpp_drag_button_multiplication"/>
<include layout="@layout/cpp_app_button_multiplication"/>
<include layout="@layout/cpp_drag_button_division"/>
<include layout="@layout/cpp_app_button_division"/>
<include layout="@layout/cpp_drag_button_equals"/>
<include layout="@layout/cpp_app_button_equals"/>
</LinearLayout>
@ -78,21 +78,21 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_functions"/>
<include layout="@layout/cpp_app_button_functions"/>
<include layout="@layout/cpp_app_button_paste"/>
<include layout="@layout/cpp_drag_button_4"/>
<include layout="@layout/cpp_app_button_4"/>
<include layout="@layout/cpp_drag_button_5"/>
<include layout="@layout/cpp_app_button_5"/>
<include layout="@layout/cpp_drag_button_6"/>
<include layout="@layout/cpp_app_button_6"/>
<include layout="@layout/cpp_drag_button_plus"/>
<include layout="@layout/cpp_app_button_plus"/>
<include layout="@layout/cpp_drag_button_subtraction"/>
<include layout="@layout/cpp_app_button_minus"/>
<include layout="@layout/cpp_drag_button_round_brackets"/>
<include layout="@layout/cpp_app_button_round_brackets"/>
</LinearLayout>
@ -101,21 +101,21 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_operators"/>
<include layout="@layout/cpp_app_button_operators"/>
<include layout="@layout/cpp_app_button_donate"/>
<include layout="@layout/cpp_drag_button_1"/>
<include layout="@layout/cpp_app_button_1"/>
<include layout="@layout/cpp_drag_button_2"/>
<include layout="@layout/cpp_app_button_2"/>
<include layout="@layout/cpp_drag_button_3"/>
<include layout="@layout/cpp_app_button_3"/>
<include layout="@layout/cpp_drag_button_0"/>
<include layout="@layout/cpp_app_button_0"/>
<include layout="@layout/cpp_drag_button_dot"/>
<include layout="@layout/cpp_app_button_dot"/>
<include layout="@layout/cpp_drag_button_history"/>
<include layout="@layout/cpp_app_button_history"/>
</LinearLayout>

View File

@ -29,5 +29,4 @@
a:text="0"
c:textDown="000"
c:directionTextScale="0.5"
style="?cpp_digit_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_digit_button_style"/>

View File

@ -29,5 +29,4 @@
c:textUp="sin"
c:textLeft="A"
c:textDown="asin"
style="?cpp_digit_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_digit_button_style"/>

View File

@ -29,5 +29,4 @@
c:textUp="cos"
c:textLeft="B"
c:textDown="acos"
style="?cpp_digit_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_digit_button_style"/>

View File

@ -29,5 +29,4 @@
c:textUp="tan"
c:textLeft="C"
c:textDown="atan"
style="?cpp_digit_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_digit_button_style"/>

View File

@ -28,5 +28,4 @@
c:textUp="x"
c:textLeft="D"
c:textDown="y"
style="?cpp_digit_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_digit_button_style"/>

View File

@ -28,5 +28,4 @@
c:textUp="t"
c:textLeft="E"
c:textDown="j"
style="?cpp_digit_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_digit_button_style"/>

View File

@ -30,5 +30,4 @@
c:textLeft="F"
c:textDown="rad"
c:directionTextScale="0.33;0.30;0.33;0.33"
style="?cpp_digit_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_digit_button_style"/>

View File

@ -30,5 +30,4 @@
c:textLeft="0b:"
c:textDown="!"
c:directionTextScale="0.5;0.5;0.5;0.33"
style="?cpp_digit_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_digit_button_style"/>

View File

@ -30,5 +30,4 @@
c:textLeft="0d:"
c:textDown="lg"
c:directionTextScale="0.5;0.5;0.5;0.33"
style="?cpp_digit_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_digit_button_style"/>

View File

@ -30,5 +30,4 @@
c:textLeft="0x:"
c:textUp="π"
c:directionTextScale="0.5;0.5;0.5;0.33"
style="?cpp_digit_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_digit_button_style"/>

View File

@ -30,5 +30,4 @@
c:textDown="bin"
c:textLeft="hex"
a:textStyle="bold"
style="?cpp_control_image_button_style"
a:onClick="clearButtonClickHandler"/>
style="?cpp_control_image_button_style"/>

View File

@ -25,5 +25,4 @@
<ImageButton xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@id/cpp_button_copy"
a:src="@drawable/kb_copy"
style="?cpp_control_image_button_style"
a:onClick="copyButtonClickHandler"/>
style="?cpp_control_image_button_style"/>

View File

@ -29,5 +29,4 @@
a:text="/"
c:textDown="√"
c:directionTextScale="0.5"
style="?cpp_operation_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_operation_button_style"/>

View File

@ -25,5 +25,4 @@
<ImageButton xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@id/cpp_button_like"
a:src="@drawable/kb_share"
style="?cpp_control_image_button_style"
a:onClick="likeButtonClickHandler"/>
style="?cpp_control_image_button_style"/>

View File

@ -28,5 +28,4 @@
a:text="."
c:textUp=","
c:directionTextScale="0.5"
style="?cpp_digit_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_digit_button_style"/>

View File

@ -28,5 +28,4 @@
a:text="="
c:textDown="@string/cpp_plot_button_text"
c:directionTextScale="0.5;0.5;0.33;0.5"
style="?cpp_control_button_style"
a:onClick="equalsButtonClickHandler"/>
style="?cpp_control_button_style"/>

View File

@ -25,5 +25,4 @@
<ImageButton xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@id/cpp_button_erase"
a:src="@drawable/kb_erase"
style="?cpp_control_image_button_style"
a:onClick="eraseButtonClickHandler"/>
style="?cpp_control_image_button_style"/>

View File

@ -25,9 +25,8 @@
<org.solovyev.android.calculator.drag.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:c="http://schemas.android.com/apk/res-auto"
a:id="@id/cpp_button_functions"
c:directionTextScale="0.5"
c:directionTextScale="0.4"
c:textUp="+ƒ"
a:text="ƒ(x)"
a:textStyle="italic"
a:onClick="functionsButtonClickHandler"
style="?cpp_control_button_style"/>

View File

@ -29,5 +29,4 @@
c:textDown="@string/c_redo"
c:directionTextScale="0.27"
style="?cpp_control_button_style"
a:textStyle="bold"
a:onClick="historyButtonClickHandler"/>
a:textStyle="bold"/>

View File

@ -28,5 +28,4 @@
c:textUp="◁◁"
a:text="◁"
c:directionTextScale="0.5"
style="?cpp_control_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_control_button_style"/>

View File

@ -26,6 +26,5 @@
a:id="@id/cpp_button_subtraction"
c:textDown="∂,…"
a:text="-"
c:directionTextScale="0.5"
style="?cpp_operation_button_style"
a:onClick="digitButtonClickHandler"/>
c:directionTextScale="0.4"
style="?cpp_operation_button_style"/>

View File

@ -30,5 +30,4 @@
c:textDown="^2"
c:textLeft="Π"
style="?cpp_operation_button_style"
c:directionTextScale="0.5"
a:onClick="digitButtonClickHandler"/>
c:directionTextScale="0.5"/>

View File

@ -25,5 +25,4 @@
<org.solovyev.android.calculator.drag.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@id/cpp_button_operators"
a:text="∂,…"
a:onClick="operatorsButtonClickHandler"
style="?cpp_control_button_style"/>

View File

@ -25,5 +25,4 @@
<ImageButton xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@id/cpp_button_paste"
a:src="@drawable/kb_paste"
style="?cpp_control_image_button_style"
a:onClick="pasteButtonClickHandler"/>
style="?cpp_control_image_button_style"/>

View File

@ -28,5 +28,4 @@
c:textUp="°"
c:textDown="E"
a:text="+"
style="?cpp_operation_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_operation_button_style"/>

View File

@ -28,5 +28,4 @@
c:textUp="▷▷"
a:text="▷"
c:directionTextScale="0.5"
style="?cpp_control_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_control_button_style"/>

View File

@ -30,5 +30,4 @@
c:textDown=")"
c:textLeft="(…)"
c:directionTextScale="0.5;0.5;0.5;0.33"
style="?cpp_digit_button_style"
a:onClick="digitButtonClickHandler"/>
style="?cpp_digit_button_style"/>

View File

@ -25,9 +25,8 @@
<org.solovyev.android.calculator.drag.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:c="http://schemas.android.com/apk/res-auto"
a:id="@id/cpp_button_vars"
c:directionTextScale="0.5"
c:directionTextScale="0.4"
c:textUp="+π"
a:text="π,…"
a:textStyle="italic"
a:onClick="varsButtonClickHandler"
style="?cpp_control_button_style"/>

View File

@ -32,15 +32,15 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_7"/>
<include layout="@layout/cpp_app_button_7"/>
<include layout="@layout/cpp_drag_button_8"/>
<include layout="@layout/cpp_app_button_8"/>
<include layout="@layout/cpp_drag_button_9"/>
<include layout="@layout/cpp_app_button_9"/>
<include layout="@layout/cpp_drag_button_multiplication"/>
<include layout="@layout/cpp_app_button_multiplication"/>
<include layout="@layout/cpp_drag_button_clear"/>
<include layout="@layout/cpp_app_button_clear"/>
</LinearLayout>
@ -49,13 +49,13 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_4"/>
<include layout="@layout/cpp_app_button_4"/>
<include layout="@layout/cpp_drag_button_5"/>
<include layout="@layout/cpp_app_button_5"/>
<include layout="@layout/cpp_drag_button_6"/>
<include layout="@layout/cpp_app_button_6"/>
<include layout="@layout/cpp_drag_button_division"/>
<include layout="@layout/cpp_app_button_division"/>
<include layout="@layout/cpp_app_button_erase"/>
@ -66,13 +66,13 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_1"/>
<include layout="@layout/cpp_app_button_1"/>
<include layout="@layout/cpp_drag_button_2"/>
<include layout="@layout/cpp_app_button_2"/>
<include layout="@layout/cpp_drag_button_3"/>
<include layout="@layout/cpp_app_button_3"/>
<include layout="@layout/cpp_drag_button_plus"/>
<include layout="@layout/cpp_app_button_plus"/>
<include layout="@layout/cpp_app_button_copy"/>
@ -83,13 +83,13 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_round_brackets"/>
<include layout="@layout/cpp_app_button_round_brackets"/>
<include layout="@layout/cpp_drag_button_0"/>
<include layout="@layout/cpp_app_button_0"/>
<include layout="@layout/cpp_drag_button_dot"/>
<include layout="@layout/cpp_app_button_dot"/>
<include layout="@layout/cpp_drag_button_subtraction"/>
<include layout="@layout/cpp_app_button_minus"/>
<include layout="@layout/cpp_app_button_paste"/>
@ -101,15 +101,15 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_left"/>
<include layout="@layout/cpp_app_button_left"/>
<include layout="@layout/cpp_drag_button_right"/>
<include layout="@layout/cpp_app_button_right"/>
<include layout="@layout/cpp_drag_button_vars"/>
<include layout="@layout/cpp_app_button_vars"/>
<include layout="@layout/cpp_drag_button_functions"/>
<include layout="@layout/cpp_app_button_functions"/>
<include layout="@layout/cpp_drag_button_history"/>
<include layout="@layout/cpp_app_button_history"/>
</LinearLayout>

View File

@ -32,15 +32,15 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_7"/>
<include layout="@layout/cpp_app_button_7"/>
<include layout="@layout/cpp_drag_button_8"/>
<include layout="@layout/cpp_app_button_8"/>
<include layout="@layout/cpp_drag_button_9"/>
<include layout="@layout/cpp_app_button_9"/>
<include layout="@layout/cpp_drag_button_multiplication"/>
<include layout="@layout/cpp_app_button_multiplication"/>
<include layout="@layout/cpp_drag_button_clear"/>
<include layout="@layout/cpp_app_button_clear"/>
</LinearLayout>
@ -49,13 +49,13 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_4"/>
<include layout="@layout/cpp_app_button_4"/>
<include layout="@layout/cpp_drag_button_5"/>
<include layout="@layout/cpp_app_button_5"/>
<include layout="@layout/cpp_drag_button_6"/>
<include layout="@layout/cpp_app_button_6"/>
<include layout="@layout/cpp_drag_button_division"/>
<include layout="@layout/cpp_app_button_division"/>
<include layout="@layout/cpp_app_button_erase"/>
@ -66,13 +66,13 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_1"/>
<include layout="@layout/cpp_app_button_1"/>
<include layout="@layout/cpp_drag_button_2"/>
<include layout="@layout/cpp_app_button_2"/>
<include layout="@layout/cpp_drag_button_3"/>
<include layout="@layout/cpp_app_button_3"/>
<include layout="@layout/cpp_drag_button_plus"/>
<include layout="@layout/cpp_app_button_plus"/>
<include layout="@layout/cpp_app_button_copy"/>
@ -83,13 +83,13 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_round_brackets"/>
<include layout="@layout/cpp_app_button_round_brackets"/>
<include layout="@layout/cpp_drag_button_0"/>
<include layout="@layout/cpp_app_button_0"/>
<include layout="@layout/cpp_drag_button_dot"/>
<include layout="@layout/cpp_app_button_dot"/>
<include layout="@layout/cpp_drag_button_subtraction"/>
<include layout="@layout/cpp_app_button_minus"/>
<include layout="@layout/cpp_app_button_paste"/>
@ -101,15 +101,15 @@
a:layout_width="match_parent"
a:layout_height="0dp">
<include layout="@layout/cpp_drag_button_left"/>
<include layout="@layout/cpp_app_button_left"/>
<include layout="@layout/cpp_drag_button_right"/>
<include layout="@layout/cpp_app_button_right"/>
<include layout="@layout/cpp_drag_button_vars"/>
<include layout="@layout/cpp_app_button_vars"/>
<include layout="@layout/cpp_drag_button_functions"/>
<include layout="@layout/cpp_app_button_functions"/>
<include layout="@layout/cpp_drag_button_history"/>
<include layout="@layout/cpp_app_button_history"/>
</LinearLayout>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 serso aka se.solovyev
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Contact details
~
~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org
-->
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="match_parent"
a:layout_height="match_parent"
a:orientation="vertical"
a:gravity="center">
<TextView
a:layout_width="wrap_content"
a:layout_height="wrap_content"
a:textAppearance="@android:style/TextAppearance.Large"
style="@style/WizardLabel"
a:text="@string/cpp_wizard_theme_title" />
<Spinner
a:id="@+id/wizard_theme_spinner"
a:layout_width="wrap_content"
a:layout_height="wrap_content"
style="@style/WizardLabel" />
<FrameLayout
a:id="@+id/wizard_theme_preview"
a:layout_width="wrap_content"
a:layout_height="wrap_content"
style="@style/WizardLabel.Last"
a:orientation="vertical"
/>
</LinearLayout>

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 serso aka se.solovyev
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Contact details
~
~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org
-->
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="wrap_content"
a:layout_height="wrap_content"
a:orientation="vertical"
a:padding="3dp"
a:background="?attr/cpp_main_bg">
<LinearLayout
a:layout_width="match_parent"
a:layout_height="wrap_content"
a:orientation="horizontal">
<include layout="@layout/cpp_app_button_0" />
<include layout="@layout/cpp_app_button_copy" />
<include layout="@layout/cpp_app_button_plus" />
</LinearLayout>
<LinearLayout
a:layout_width="match_parent"
a:layout_height="wrap_content"
a:orientation="horizontal">
<include layout="@layout/cpp_app_button_1" />
<include layout="@layout/cpp_app_button_paste" />
<include layout="@layout/cpp_app_button_minus" />
</LinearLayout>
</LinearLayout>

View File

@ -1,82 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 serso aka se.solovyev
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Contact details
~
~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org
-->
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:c="http://schemas.android.com/apk/res-auto"
a:orientation="vertical"
a:layout_width="fill_parent"
a:layout_height="fill_parent"
a:background="#ff000000">
<LinearLayout
a:id="@+id/simplePad"
a:layout_width="fill_parent"
a:layout_height="fill_parent"
a:orientation="vertical"
a:layout_gravity="center">
<LinearLayout
a:layout_weight="1"
a:layout_width="fill_parent"
a:layout_height="0dp">
<ImageView
a:id="@+id/calibrationArrowLeft"
a:layout_gravity="left"
a:layout_width="80dp"
a:layout_height="80dp"/>
<org.solovyev.android.calculator.drag.DirectionDragButton
a:id="@+id/calibrationButtonLeft"
a:text=""
c:textUp="@string/c_up"
c:textDown="@string/c_down"
a:layout_width="80dp"
a:layout_height="80dp"
style="?cpp_digit_button_style"/>
<org.solovyev.android.calculator.drag.DirectionDragButton
a:id="@+id/calibrationButtonRight"
a:text=""
c:textUp="@string/c_up"
c:textDown="@string/c_down"
a:layout_width="80dp"
a:layout_height="80dp"
style="?cpp_digit_button_style"/>
<ImageView
a:id="@+id/calibrationArrowRight"
a:layout_gravity="right"
a:layout_width="80dp"
a:layout_height="80dp"/>
</LinearLayout>
</LinearLayout>
<Button
a:id="@+id/calibrationStart"
a:text="@string/c_restart"
a:layout_width="wrap_content"
a:layout_height="wrap_content"
a:layout_gravity="bottom"/>
</LinearLayout>

View File

@ -43,7 +43,7 @@
a:baselineAligned="false">
<include
layout="@layout/cpp_drag_button_equals"
layout="@layout/cpp_app_button_equals"
a:layout_width="0dp"
a:layout_height="match_parent"
a:layout_weight="1" />

View File

@ -42,7 +42,7 @@
a:layout_height="0dp">
<include
layout="@layout/cpp_drag_button_equals"
layout="@layout/cpp_app_button_equals"
a:layout_weight="1"
a:layout_width="0dp"
a:layout_height="match_parent"/>

View File

@ -34,5 +34,6 @@
<attr name="cpp_pane_style_transparent" format="reference"/>
<attr name="cpp_main_layout_style" format="reference"/>
<attr name="cpp_main_multi_pane_layout_style" format="reference"/>
<attr name="cpp_main_bg" format="reference"/>
</resources>

View File

@ -27,6 +27,7 @@
<string name="cpp_wizard_welcome_title">Welcome</string>
<string name="cpp_wizard_layout_title">Choose layout</string>
<string name="cpp_wizard_mode_title">Choose mode</string>
<string name="cpp_wizard_theme_title">Choose theme</string>
<string name="cpp_wizard_onscreen_calculator_title">Calculator in a separate window</string>
<string name="cpp_wizard_dragbutton_title">Drag button basics</string>
<string name="cpp_wizard_final_done">The app is set up and ready to use.</string>

View File

@ -145,6 +145,7 @@
<item name="cpp_pane_style">@style/cpp_default_pane_style</item>
<item name="cpp_pane_style_transparent">@style/cpp_default_pane_style_transparent</item>
<item name="cpp_main_bg">@color/cpp_main_bg</item>
</style>
<style name="cpp_gray_dialog_theme" parent="Theme.Dialog">
@ -166,6 +167,7 @@
<item name="cpp_pane_style">@style/cpp_default_pane_style</item>
<item name="cpp_pane_style_transparent">@style/cpp_default_pane_style_transparent</item>
<item name="cpp_main_bg">@color/cpp_main_bg</item>
</style>
</resources>

View File

@ -22,6 +22,8 @@
package org.solovyev.android.calculator;
import org.solovyev.common.text.Strings;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -100,7 +102,13 @@ public enum CalculatorSpecialButton {
equals("=") {
@Override
public void onClick(@Nonnull CalculatorKeyboard keyboard) {
Locator.getInstance().getCalculator().evaluate();
final CalculatorDisplayViewState displayViewState = Locator.getInstance().getDisplay().getViewState();
if (displayViewState.isValid()) {
final CharSequence text = displayViewState.getText();
if (!Strings.isEmpty(text)) {
Locator.getInstance().getEditor().setText(text.toString());
}
}
}
},
clear("clear") {