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); final View root = activity.findViewById(R.id.main_layout);
if (root != null) { if (root != null) {
processButtons(activity, root); processButtons(activity, root);
fixFonts(root);
addHelpInfo(activity, root); addHelpInfo(activity, root);
} }
} }

View File

@ -47,8 +47,6 @@ import org.solovyev.common.math.Point2d;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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); private static final List<Integer> viewIds = new ArrayList<Integer>(200);
@Nonnull @Nonnull
private Preferences.Gui.Layout layout; protected Preferences.Gui.Layout layout;
@Nonnull @Nonnull
private Preferences.Gui.Theme theme; protected Preferences.Gui.Theme theme;
@Nullable
private Vibrator vibrator;
@Nonnull
private final JListeners<DragPreferencesChangeListener> dpclRegister = Listeners.newHardRefListeners();
@Nonnull @Nonnull
private String logTag = "CalculatorActivity"; private String logTag = "CalculatorActivity";
@Nullable
private Vibrator vibrator;
@Nullable @Nullable
private AngleUnitsButton angleUnitsButton; private AngleUnitsButton angleUnitsButton;
@Nullable @Nullable
private NumeralBasesButton clearButton; private NumeralBasesButton clearButton;
@Nonnull
private final JListeners<DragPreferencesChangeListener> dpclRegister = Listeners.newHardRefListeners();
protected BaseUi() { protected BaseUi() {
} }
@ -119,6 +117,28 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
Log.e(logTag, message); 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) { public void processButtons(@Nonnull final Activity activity, @Nonnull View root) {
dpclRegister.removeListeners(); 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); 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.toggleEqualsButton(preferences, activity);
CalculatorButtons.initMultiplicationButton(root); CalculatorButtons.initMultiplicationButton(root);
NumeralBaseButtons.toggleNumericDigits(activity, preferences); NumeralBaseButtons.toggleNumericDigits(activity, preferences);
// some devices ship own fonts which causes issues with rendering. Let's use our own font for all text views new ButtonOnClickListener().attachToViews(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);
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) { 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(); 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 @Nonnull
private static List<Integer> getViewIds() { private static List<Integer> getViewIds() {
if (viewIds.isEmpty()) { if (viewIds.isEmpty()) {
for (Field field : R.id.class.getDeclaredFields()) { viewIds.add(R.id.wizard_dragbutton);
int modifiers = field.getModifiers(); viewIds.add(R.id.cpp_button_vars);
if (Modifier.isFinal(modifiers) && Modifier.isStatic(modifiers)) { viewIds.add(R.id.cpp_button_round_brackets);
try { viewIds.add(R.id.cpp_button_right);
viewIds.add(field.getInt(R.id.class)); viewIds.add(R.id.cpp_button_plus);
} catch (IllegalAccessException e) { viewIds.add(R.id.cpp_button_operators);
Log.e(R.id.class.getName(), e.getMessage()); 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; return viewIds;
} }
@ -286,23 +316,8 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
return (T) views.findViewById(buttonId); 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 @Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) { 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 (angleUnit.isSameKey(key) || numeralBase.isSameKey(key)) {
if (angleUnitsButton != null) { if (angleUnitsButton != null) {
angleUnitsButton.setAngleUnit(angleUnit.getPreference(preferences)); 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.preference.PreferenceManager;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.*; import android.view.*;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import org.solovyev.android.Activities; import org.solovyev.android.Activities;
import org.solovyev.android.Android; 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.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; 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.Preferences.Gui.preventScreenFromFading;
import static org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment.hasReleaseNotes; import static org.solovyev.android.calculator.release.ReleaseNotes.hasReleaseNotes;
import static org.solovyev.android.wizard.WizardUi.continueWizard; import static org.solovyev.android.wizard.WizardUi.*;
import static org.solovyev.android.wizard.WizardUi.createLaunchIntent;
import static org.solovyev.android.wizard.WizardUi.startWizard;
public class CalculatorActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEventListener { 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); return super.onKeyDown(keyCode, event);
} }
@SuppressWarnings({"UnusedDeclaration"})
public void equalsButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.equals);
}
@Override @Override
protected void onResume() { protected void onResume() {
super.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 @Override
public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) { switch (calculatorEventType) {

View File

@ -59,7 +59,7 @@ public final class CalculatorButtons {
} }
public static void processButtons(@Nonnull Preferences.Gui.Theme theme, public static void fixButtonsTextSize(@Nonnull Preferences.Gui.Theme theme,
@Nonnull Preferences.Gui.Layout layout, @Nonnull Preferences.Gui.Layout layout,
@Nonnull View root) { @Nonnull View root) {
if (!layout.isOptimized()) { if (!layout.isOptimized()) {

View File

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

View File

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

View File

@ -22,23 +22,15 @@
package org.solovyev.android.calculator.about; package org.solovyev.android.calculator.about;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.text.Html; import android.text.Html;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import org.solovyev.android.calculator.CalculatorApplication;
import org.solovyev.android.calculator.CalculatorFragment; import org.solovyev.android.calculator.CalculatorFragment;
import org.solovyev.android.calculator.CalculatorFragmentType; import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import org.solovyev.common.text.Strings; import org.solovyev.android.calculator.release.ReleaseNotes;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import static org.solovyev.android.Android.getAppVersionCode;
/** /**
* User: serso * User: serso
@ -58,88 +50,6 @@ public class CalculatorReleaseNotesFragment extends CalculatorFragment {
final TextView releaseNotes = (TextView) root.findViewById(R.id.releaseNotesTextView); final TextView releaseNotes = (TextView) root.findViewById(R.id.releaseNotesTextView);
releaseNotes.setMovementMethod(LinkMovementMethod.getInstance()); releaseNotes.setMovementMethod(LinkMovementMethod.getInstance());
releaseNotes.setText(Html.fromHtml(getReleaseNotes(this.getActivity()))); releaseNotes.setText(Html.fromHtml(ReleaseNotes.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";
} }
} }

View File

@ -9,7 +9,6 @@ import android.widget.TextView;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import org.solovyev.android.calculator.CalculatorApplication; import org.solovyev.android.calculator.CalculatorApplication;
import org.solovyev.android.calculator.R; 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.about.TextHelper;
import org.solovyev.android.calculator.wizard.WizardFragment; import org.solovyev.android.calculator.wizard.WizardFragment;
@ -45,12 +44,12 @@ public class ReleaseNoteFragment extends WizardFragment {
@Nonnull @Nonnull
private String getReleaseNoteVersion(@Nonnull TextHelper textHelper) { private String getReleaseNoteVersion(@Nonnull TextHelper textHelper) {
return CalculatorReleaseNotesFragment.getVersionName(textHelper, version); return ReleaseNotes.getVersionName(textHelper, version);
} }
@Nonnull @Nonnull
private String getReleaseNote(@Nonnull TextHelper textHelper) { 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/>"); 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_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), on_screen_calculator(OnScreenCalculatorWizardStep.class, R.string.cpp_wizard_onscreen_calculator_title),
drag_button(DragButtonWizardStep.class, R.string.cpp_wizard_dragbutton_title), drag_button(DragButtonWizardStep.class, R.string.cpp_wizard_dragbutton_title),
last(FinalWizardStep.class, R.string.cpp_wizard_final_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.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment;
import org.solovyev.android.calculator.release.ReleaseNoteStep; import org.solovyev.android.calculator.release.ReleaseNoteStep;
import org.solovyev.android.calculator.release.ReleaseNotes;
import org.solovyev.android.wizard.*; import org.solovyev.android.wizard.*;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -79,13 +79,21 @@ public class CalculatorWizards implements Wizards {
static WizardFlow newReleaseNotesWizardFlow(@Nonnull Context context, @Nullable Bundle arguments) { static WizardFlow newReleaseNotesWizardFlow(@Nonnull Context context, @Nullable Bundle arguments) {
final List<WizardStep> wizardSteps = new ArrayList<WizardStep>(); final List<WizardStep> wizardSteps = new ArrayList<WizardStep>();
final int startVersion = arguments != null ? arguments.getInt(RELEASE_NOTES_VERSION, 0) : 0; 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(); final int size = versions.size();
if (size > 7) { if (size > 7) {
versions = versions.subList(0, 7); versions = versions.subList(0, 7);
} }
for (Integer version : versions) { for (Integer version : versions) {
switch (version) {
case 136:
wizardSteps.add(CalculatorWizardStep.choose_theme);
break;
default:
wizardSteps.add(new ReleaseNoteStep(version)); wizardSteps.add(new ReleaseNoteStep(version));
break;
}
} }
return new ListWizardFlow(wizardSteps); 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); image = (ImageView) root.findViewById(R.id.wizard_layout_image);
final Spinner spinner = (Spinner) root.findViewById(R.id.wizard_layout_spinner); 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.setSelection(layout == big_buttons ? 0 : 1);
spinner.setOnItemSelectedListener(this); 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 CalculatorMode mode = CalculatorMode.fromGuiLayout(Preferences.Gui.layout.getPreference(getPreferences()));
final Spinner spinner = (Spinner) root.findViewById(R.id.wizard_mode_spinner); 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.setSelection(mode == simple ? 0 : 1);
spinner.setOnItemSelectedListener(this); 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 android.widget.TextView;
import org.solovyev.android.calculator.R; 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) { final class WizardArrayAdapter<T> extends ArrayAdapter<T> {
super(context, R.layout.support_simple_spinner_dropdown_item, context.getResources().getStringArray(array));
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); setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
} }

View File

@ -34,21 +34,21 @@
a:baselineAligned="false" a:baselineAligned="false"
a:orientation="horizontal"> 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_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> </LinearLayout>
@ -59,21 +59,21 @@
a:baselineAligned="false" a:baselineAligned="false"
a:orientation="horizontal"> 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_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> </LinearLayout>
@ -84,21 +84,21 @@
a:baselineAligned="false" a:baselineAligned="false"
a:orientation="horizontal"> 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_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> </LinearLayout>

View File

@ -32,21 +32,21 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_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> </LinearLayout>
@ -55,21 +55,21 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_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> </LinearLayout>
@ -78,21 +78,21 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_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> </LinearLayout>

View File

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

View File

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

View File

@ -32,25 +32,25 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_erase"/>
<include layout="@layout/cpp_app_button_donate"/> <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> </LinearLayout>
@ -59,25 +59,25 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_app_button_copy"/>
<include layout="@layout/cpp_drag_button_equals"/> <include layout="@layout/cpp_app_button_equals"/>
</LinearLayout> </LinearLayout>
@ -86,25 +86,25 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_app_button_paste"/>
<include layout="@layout/cpp_drag_button_history"/> <include layout="@layout/cpp_app_button_history"/>
</LinearLayout> </LinearLayout>

View File

@ -32,19 +32,19 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_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> </LinearLayout>
@ -53,17 +53,17 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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"/> <include layout="@layout/cpp_app_button_copy"/>
@ -74,17 +74,17 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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"/> <include layout="@layout/cpp_app_button_paste"/>
@ -95,19 +95,19 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_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> </LinearLayout>

View File

@ -32,33 +32,33 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_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_app_button_donate"/>
<include layout="@layout/cpp_drag_button_right"/> <include layout="@layout/cpp_app_button_right"/>
</LinearLayout> </LinearLayout>
@ -69,31 +69,31 @@
<include layout="@layout/cpp_app_button_erase"/> <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_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> </LinearLayout>

View File

@ -32,21 +32,21 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_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> </LinearLayout>
@ -55,21 +55,21 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_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> </LinearLayout>
@ -78,21 +78,21 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_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> </LinearLayout>
@ -101,21 +101,21 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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_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> </LinearLayout>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -32,15 +32,15 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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> </LinearLayout>
@ -49,13 +49,13 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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"/> <include layout="@layout/cpp_app_button_erase"/>
@ -66,13 +66,13 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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"/> <include layout="@layout/cpp_app_button_copy"/>
@ -83,13 +83,13 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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"/> <include layout="@layout/cpp_app_button_paste"/>
@ -101,15 +101,15 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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> </LinearLayout>

View File

@ -32,15 +32,15 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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> </LinearLayout>
@ -49,13 +49,13 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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"/> <include layout="@layout/cpp_app_button_erase"/>
@ -66,13 +66,13 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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"/> <include layout="@layout/cpp_app_button_copy"/>
@ -83,13 +83,13 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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"/> <include layout="@layout/cpp_app_button_paste"/>
@ -101,15 +101,15 @@
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="0dp"> 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> </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"> a:baselineAligned="false">
<include <include
layout="@layout/cpp_drag_button_equals" layout="@layout/cpp_app_button_equals"
a:layout_width="0dp" a:layout_width="0dp"
a:layout_height="match_parent" a:layout_height="match_parent"
a:layout_weight="1" /> a:layout_weight="1" />

View File

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

View File

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

View File

@ -27,6 +27,7 @@
<string name="cpp_wizard_welcome_title">Welcome</string> <string name="cpp_wizard_welcome_title">Welcome</string>
<string name="cpp_wizard_layout_title">Choose layout</string> <string name="cpp_wizard_layout_title">Choose layout</string>
<string name="cpp_wizard_mode_title">Choose mode</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_onscreen_calculator_title">Calculator in a separate window</string>
<string name="cpp_wizard_dragbutton_title">Drag button basics</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> <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">@style/cpp_default_pane_style</item>
<item name="cpp_pane_style_transparent">@style/cpp_default_pane_style_transparent</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>
<style name="cpp_gray_dialog_theme" parent="Theme.Dialog"> <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">@style/cpp_default_pane_style</item>
<item name="cpp_pane_style_transparent">@style/cpp_default_pane_style_transparent</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>
</resources> </resources>

View File

@ -22,6 +22,8 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import org.solovyev.common.text.Strings;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -100,7 +102,13 @@ public enum CalculatorSpecialButton {
equals("=") { equals("=") {
@Override @Override
public void onClick(@Nonnull CalculatorKeyboard keyboard) { 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") { clear("clear") {