diff --git a/android-app/src/main/java/org/solovyev/android/calculator/ActivityUi.java b/android-app/src/main/java/org/solovyev/android/calculator/ActivityUi.java index bef6e466..89491290 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/ActivityUi.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/ActivityUi.java @@ -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); } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/BaseUi.java b/android-app/src/main/java/org/solovyev/android/calculator/BaseUi.java index 40bce812..aaf42a3f 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/BaseUi.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/BaseUi.java @@ -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 viewIds = new ArrayList(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 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 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() { + @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() { - @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 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 viewIds = getViewIds(); - for (Integer viewId : viewIds) { - final View view = views.findViewById(viewId); - if (view instanceof DragButton) { - ((DragButton) view).setOnDragListener(dragListener); - } - } - } - @Nonnull private static List 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); - } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/ButtonOnClickListener.java b/android-app/src/main/java/org/solovyev/android/calculator/ButtonOnClickListener.java new file mode 100644 index 00000000..c8ae9c65 --- /dev/null +++ b/android-app/src/main/java/org/solovyev/android/calculator/ButtonOnClickListener.java @@ -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); + } + } +} diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java index 939a0683..17a34ef7 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java @@ -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) { diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java index 1b8006b5..08fdb7b0 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java @@ -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); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/FragmentUi.java b/android-app/src/main/java/org/solovyev/android/calculator/FragmentUi.java index c2781e40..8fd3cfc0 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/FragmentUi.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/FragmentUi.java @@ -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); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/Preferences.java b/android-app/src/main/java/org/solovyev/android/calculator/Preferences.java index e5d50dcc..5eb1a880 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/Preferences.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/Preferences.java @@ -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; } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorReleaseNotesFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorReleaseNotesFragment.java index e97ff99f..e6ad659f 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorReleaseNotesFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorReleaseNotesFragment.java @@ -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("

"); - } else { - first = false; - } - releaseNotesForVersion = releaseNotesForVersion.replace("\n", "
"); - result.append("").append(releaseNotesForTitle).append(versionName).append("

"); - result.append(releaseNotesForVersion); - } - } - - return result.toString(); - } - - @Nonnull - public static List getReleaseNotesVersions(@Nonnull Context context, int minVersion) { - final List 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()))); } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/release/ReleaseNoteFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/release/ReleaseNoteFragment.java index 42aecdda..c35e0580 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/release/ReleaseNoteFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/release/ReleaseNoteFragment.java @@ -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", "
"); } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/release/ReleaseNotes.java b/android-app/src/main/java/org/solovyev/android/calculator/release/ReleaseNotes.java new file mode 100644 index 00000000..9e07798a --- /dev/null +++ b/android-app/src/main/java/org/solovyev/android/calculator/release/ReleaseNotes.java @@ -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("

"); + } else { + first = false; + } + releaseNotesForVersion = releaseNotesForVersion.replace("\n", "
"); + result.append("").append(releaseNotesForTitle).append(versionName).append("

"); + result.append(releaseNotesForVersion); + } + } + + return result.toString(); + } + + @Nonnull + public static List getReleaseNotesVersions(@Nonnull Context context, int minVersion) { + final List 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"; + } +} diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizardStep.java index f7e2bce5..c42af0ee 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizardStep.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizardStep.java @@ -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); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizards.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizards.java index 35880ab9..84d9cc93 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizards.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizards.java @@ -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 wizardSteps = new ArrayList(); final int startVersion = arguments != null ? arguments.getInt(RELEASE_NOTES_VERSION, 0) : 0; - List versions = CalculatorReleaseNotesFragment.getReleaseNotesVersions(context, startVersion); + List 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); } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseLayoutWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseLayoutWizardStep.java index 8cd96e8d..420fa7cd 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseLayoutWizardStep.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseLayoutWizardStep.java @@ -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); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java index c1ebf29d..2a72d693 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java @@ -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); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseThemeWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseThemeWizardStep.java new file mode 100644 index 00000000..6cf365e4 --- /dev/null +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseThemeWizardStep.java @@ -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 themes = new ArrayList<>(); + private WizardArrayAdapter 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; + } + } +} diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardArrayAdapter.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardArrayAdapter.java index 92fa6026..800af1d8 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardArrayAdapter.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardArrayAdapter.java @@ -7,10 +7,23 @@ import android.widget.ArrayAdapter; import android.widget.TextView; import org.solovyev.android.calculator.R; -final class WizardArrayAdapter extends ArrayAdapter { +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 extends ArrayAdapter { + + 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 create(@Nonnull Context context, int array) { + return new WizardArrayAdapter<>(context, context.getResources().getStringArray(array)); + } + + public WizardArrayAdapter(@Nonnull Context context, @Nonnull List items) { + super(context, R.layout.support_simple_spinner_dropdown_item, items); setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); } diff --git a/android-app/src/main/res/layout-land/cpp_app_keyboard.xml b/android-app/src/main/res/layout-land/cpp_app_keyboard.xml index bc434b57..b22a9194 100644 --- a/android-app/src/main/res/layout-land/cpp_app_keyboard.xml +++ b/android-app/src/main/res/layout-land/cpp_app_keyboard.xml @@ -34,21 +34,21 @@ a:baselineAligned="false" a:orientation="horizontal"> - + - + - + - + - + - + - + @@ -59,21 +59,21 @@ a:baselineAligned="false" a:orientation="horizontal"> - + - + - + - + - + - + - + @@ -84,21 +84,21 @@ a:baselineAligned="false" a:orientation="horizontal"> - + - + - + - + - + - + - + diff --git a/android-app/src/main/res/layout-land/cpp_app_keyboard_mobile.xml b/android-app/src/main/res/layout-land/cpp_app_keyboard_mobile.xml index 0dbc7132..94dd3cfa 100644 --- a/android-app/src/main/res/layout-land/cpp_app_keyboard_mobile.xml +++ b/android-app/src/main/res/layout-land/cpp_app_keyboard_mobile.xml @@ -32,21 +32,21 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + - + @@ -55,21 +55,21 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + - + @@ -78,21 +78,21 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + - + diff --git a/android-app/src/main/res/layout-land/main_first_pane.xml b/android-app/src/main/res/layout-land/main_first_pane.xml index 496e5bec..11537ac1 100644 --- a/android-app/src/main/res/layout-land/main_first_pane.xml +++ b/android-app/src/main/res/layout-land/main_first_pane.xml @@ -42,7 +42,7 @@ a:orientation="horizontal"> @@ -61,13 +61,13 @@ a:orientation="horizontal" /> diff --git a/android-app/src/main/res/layout-land/main_first_pane_mobile.xml b/android-app/src/main/res/layout-land/main_first_pane_mobile.xml index f3af4ef8..29c3c845 100644 --- a/android-app/src/main/res/layout-land/main_first_pane_mobile.xml +++ b/android-app/src/main/res/layout-land/main_first_pane_mobile.xml @@ -39,7 +39,7 @@ a:layout_height="0dp"> @@ -57,13 +57,13 @@ a:layout_weight="4"/> diff --git a/android-app/src/main/res/layout-large-land/cpp_app_keyboard.xml b/android-app/src/main/res/layout-large-land/cpp_app_keyboard.xml index b6cbb48c..189a3a0c 100644 --- a/android-app/src/main/res/layout-large-land/cpp_app_keyboard.xml +++ b/android-app/src/main/res/layout-large-land/cpp_app_keyboard.xml @@ -32,25 +32,25 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + - + - + @@ -59,25 +59,25 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + - + - + - + @@ -86,25 +86,25 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + - + - + - + diff --git a/android-app/src/main/res/layout-large/cpp_app_keyboard.xml b/android-app/src/main/res/layout-large/cpp_app_keyboard.xml index cccbd929..fcca4274 100644 --- a/android-app/src/main/res/layout-large/cpp_app_keyboard.xml +++ b/android-app/src/main/res/layout-large/cpp_app_keyboard.xml @@ -32,19 +32,19 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + @@ -53,17 +53,17 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + @@ -74,17 +74,17 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + @@ -95,19 +95,19 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + diff --git a/android-app/src/main/res/layout-xlarge-land/cpp_app_keyboard.xml b/android-app/src/main/res/layout-xlarge-land/cpp_app_keyboard.xml index 5d2506eb..e954b3fe 100644 --- a/android-app/src/main/res/layout-xlarge-land/cpp_app_keyboard.xml +++ b/android-app/src/main/res/layout-xlarge-land/cpp_app_keyboard.xml @@ -32,33 +32,33 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + - + - + - + - + - + - + @@ -69,31 +69,31 @@ - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/android-app/src/main/res/layout-xlarge/cpp_app_keyboard.xml b/android-app/src/main/res/layout-xlarge/cpp_app_keyboard.xml index c8298689..558a7aca 100644 --- a/android-app/src/main/res/layout-xlarge/cpp_app_keyboard.xml +++ b/android-app/src/main/res/layout-xlarge/cpp_app_keyboard.xml @@ -32,21 +32,21 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + - + @@ -55,21 +55,21 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + - + @@ -78,21 +78,21 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + - + @@ -101,21 +101,21 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + - + - + diff --git a/android-app/src/main/res/layout/cpp_drag_button_0.xml b/android-app/src/main/res/layout/cpp_app_button_0.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_0.xml rename to android-app/src/main/res/layout/cpp_app_button_0.xml index 208fc905..b127c190 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_0.xml +++ b/android-app/src/main/res/layout/cpp_app_button_0.xml @@ -29,5 +29,4 @@ a:text="0" c:textDown="000" c:directionTextScale="0.5" - style="?cpp_digit_button_style" - a:onClick="digitButtonClickHandler"/> \ No newline at end of file + style="?cpp_digit_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_1.xml b/android-app/src/main/res/layout/cpp_app_button_1.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_1.xml rename to android-app/src/main/res/layout/cpp_app_button_1.xml index 55ae855e..b26f801e 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_1.xml +++ b/android-app/src/main/res/layout/cpp_app_button_1.xml @@ -29,5 +29,4 @@ c:textUp="sin" c:textLeft="A" c:textDown="asin" - style="?cpp_digit_button_style" - a:onClick="digitButtonClickHandler"/> \ No newline at end of file + style="?cpp_digit_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_2.xml b/android-app/src/main/res/layout/cpp_app_button_2.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_2.xml rename to android-app/src/main/res/layout/cpp_app_button_2.xml index 63d47c0d..5aaf4526 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_2.xml +++ b/android-app/src/main/res/layout/cpp_app_button_2.xml @@ -29,5 +29,4 @@ c:textUp="cos" c:textLeft="B" c:textDown="acos" - style="?cpp_digit_button_style" - a:onClick="digitButtonClickHandler"/> \ No newline at end of file + style="?cpp_digit_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_3.xml b/android-app/src/main/res/layout/cpp_app_button_3.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_3.xml rename to android-app/src/main/res/layout/cpp_app_button_3.xml index e13aac4b..5ce477a1 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_3.xml +++ b/android-app/src/main/res/layout/cpp_app_button_3.xml @@ -29,5 +29,4 @@ c:textUp="tan" c:textLeft="C" c:textDown="atan" - style="?cpp_digit_button_style" - a:onClick="digitButtonClickHandler"/> \ No newline at end of file + style="?cpp_digit_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_4.xml b/android-app/src/main/res/layout/cpp_app_button_4.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_4.xml rename to android-app/src/main/res/layout/cpp_app_button_4.xml index 7cfd1a96..ff52122e 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_4.xml +++ b/android-app/src/main/res/layout/cpp_app_button_4.xml @@ -28,5 +28,4 @@ c:textUp="x" c:textLeft="D" c:textDown="y" - style="?cpp_digit_button_style" - a:onClick="digitButtonClickHandler"/> \ No newline at end of file + style="?cpp_digit_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_5.xml b/android-app/src/main/res/layout/cpp_app_button_5.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_5.xml rename to android-app/src/main/res/layout/cpp_app_button_5.xml index ec51c377..cead4e30 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_5.xml +++ b/android-app/src/main/res/layout/cpp_app_button_5.xml @@ -28,5 +28,4 @@ c:textUp="t" c:textLeft="E" c:textDown="j" - style="?cpp_digit_button_style" - a:onClick="digitButtonClickHandler"/> \ No newline at end of file + style="?cpp_digit_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_6.xml b/android-app/src/main/res/layout/cpp_app_button_6.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_6.xml rename to android-app/src/main/res/layout/cpp_app_button_6.xml index 62d0e788..595d1013 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_6.xml +++ b/android-app/src/main/res/layout/cpp_app_button_6.xml @@ -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"/> \ No newline at end of file + style="?cpp_digit_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_7.xml b/android-app/src/main/res/layout/cpp_app_button_7.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_7.xml rename to android-app/src/main/res/layout/cpp_app_button_7.xml index 44245691..f9476f18 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_7.xml +++ b/android-app/src/main/res/layout/cpp_app_button_7.xml @@ -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"/> \ No newline at end of file + style="?cpp_digit_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_8.xml b/android-app/src/main/res/layout/cpp_app_button_8.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_8.xml rename to android-app/src/main/res/layout/cpp_app_button_8.xml index 58a4d3f9..ecf5e237 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_8.xml +++ b/android-app/src/main/res/layout/cpp_app_button_8.xml @@ -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"/> \ No newline at end of file + style="?cpp_digit_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_9.xml b/android-app/src/main/res/layout/cpp_app_button_9.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_9.xml rename to android-app/src/main/res/layout/cpp_app_button_9.xml index 5db1bb67..e74543e8 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_9.xml +++ b/android-app/src/main/res/layout/cpp_app_button_9.xml @@ -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"/> \ No newline at end of file + style="?cpp_digit_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_clear.xml b/android-app/src/main/res/layout/cpp_app_button_clear.xml similarity index 91% rename from android-app/src/main/res/layout/cpp_drag_button_clear.xml rename to android-app/src/main/res/layout/cpp_app_button_clear.xml index 085b3e01..7f4814f7 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_clear.xml +++ b/android-app/src/main/res/layout/cpp_app_button_clear.xml @@ -30,5 +30,4 @@ c:textDown="bin" c:textLeft="hex" a:textStyle="bold" - style="?cpp_control_image_button_style" - a:onClick="clearButtonClickHandler"/> \ No newline at end of file + style="?cpp_control_image_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_app_button_copy.xml b/android-app/src/main/res/layout/cpp_app_button_copy.xml index 6308ebf9..4e6d97f3 100644 --- a/android-app/src/main/res/layout/cpp_app_button_copy.xml +++ b/android-app/src/main/res/layout/cpp_app_button_copy.xml @@ -25,5 +25,4 @@ \ No newline at end of file + style="?cpp_control_image_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_division.xml b/android-app/src/main/res/layout/cpp_app_button_division.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_division.xml rename to android-app/src/main/res/layout/cpp_app_button_division.xml index d8b1b017..07fe6c25 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_division.xml +++ b/android-app/src/main/res/layout/cpp_app_button_division.xml @@ -29,5 +29,4 @@ a:text="/" c:textDown="√" c:directionTextScale="0.5" - style="?cpp_operation_button_style" - a:onClick="digitButtonClickHandler"/> \ No newline at end of file + style="?cpp_operation_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_app_button_donate.xml b/android-app/src/main/res/layout/cpp_app_button_donate.xml index 0d0ab81e..4b3bf267 100644 --- a/android-app/src/main/res/layout/cpp_app_button_donate.xml +++ b/android-app/src/main/res/layout/cpp_app_button_donate.xml @@ -25,5 +25,4 @@ \ No newline at end of file + style="?cpp_control_image_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_dot.xml b/android-app/src/main/res/layout/cpp_app_button_dot.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_dot.xml rename to android-app/src/main/res/layout/cpp_app_button_dot.xml index f7ebdc8b..da2b9201 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_dot.xml +++ b/android-app/src/main/res/layout/cpp_app_button_dot.xml @@ -28,5 +28,4 @@ a:text="." c:textUp="," c:directionTextScale="0.5" - style="?cpp_digit_button_style" - a:onClick="digitButtonClickHandler"/> \ No newline at end of file + style="?cpp_digit_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_empty.xml b/android-app/src/main/res/layout/cpp_app_button_empty.xml similarity index 100% rename from android-app/src/main/res/layout/cpp_drag_button_empty.xml rename to android-app/src/main/res/layout/cpp_app_button_empty.xml diff --git a/android-app/src/main/res/layout/cpp_drag_button_equals.xml b/android-app/src/main/res/layout/cpp_app_button_equals.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_equals.xml rename to android-app/src/main/res/layout/cpp_app_button_equals.xml index 6e928580..03de2907 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_equals.xml +++ b/android-app/src/main/res/layout/cpp_app_button_equals.xml @@ -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"/> \ No newline at end of file + style="?cpp_control_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_app_button_erase.xml b/android-app/src/main/res/layout/cpp_app_button_erase.xml index 1390029f..66275c07 100644 --- a/android-app/src/main/res/layout/cpp_app_button_erase.xml +++ b/android-app/src/main/res/layout/cpp_app_button_erase.xml @@ -25,5 +25,4 @@ \ No newline at end of file + style="?cpp_control_image_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_functions.xml b/android-app/src/main/res/layout/cpp_app_button_functions.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_functions.xml rename to android-app/src/main/res/layout/cpp_app_button_functions.xml index 0f56ce07..a91df2a0 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_functions.xml +++ b/android-app/src/main/res/layout/cpp_app_button_functions.xml @@ -25,9 +25,8 @@ \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_history.xml b/android-app/src/main/res/layout/cpp_app_button_history.xml similarity index 93% rename from android-app/src/main/res/layout/cpp_drag_button_history.xml rename to android-app/src/main/res/layout/cpp_app_button_history.xml index df794e95..8db1a982 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_history.xml +++ b/android-app/src/main/res/layout/cpp_app_button_history.xml @@ -29,5 +29,4 @@ c:textDown="@string/c_redo" c:directionTextScale="0.27" style="?cpp_control_button_style" - a:textStyle="bold" - a:onClick="historyButtonClickHandler"/> \ No newline at end of file + a:textStyle="bold"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_left.xml b/android-app/src/main/res/layout/cpp_app_button_left.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_left.xml rename to android-app/src/main/res/layout/cpp_app_button_left.xml index 1033f86a..8b50fdf1 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_left.xml +++ b/android-app/src/main/res/layout/cpp_app_button_left.xml @@ -28,5 +28,4 @@ c:textUp="◁◁" a:text="◁" c:directionTextScale="0.5" - style="?cpp_control_button_style" - a:onClick="digitButtonClickHandler"/> \ No newline at end of file + style="?cpp_control_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_subtraction.xml b/android-app/src/main/res/layout/cpp_app_button_minus.xml similarity index 88% rename from android-app/src/main/res/layout/cpp_drag_button_subtraction.xml rename to android-app/src/main/res/layout/cpp_app_button_minus.xml index e9288510..1a788f36 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_subtraction.xml +++ b/android-app/src/main/res/layout/cpp_app_button_minus.xml @@ -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"/> \ No newline at end of file + c:directionTextScale="0.4" + style="?cpp_operation_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_multiplication.xml b/android-app/src/main/res/layout/cpp_app_button_multiplication.xml similarity index 93% rename from android-app/src/main/res/layout/cpp_drag_button_multiplication.xml rename to android-app/src/main/res/layout/cpp_app_button_multiplication.xml index f2b36136..e1ad1f11 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_multiplication.xml +++ b/android-app/src/main/res/layout/cpp_app_button_multiplication.xml @@ -30,5 +30,4 @@ c:textDown="^2" c:textLeft="Π" style="?cpp_operation_button_style" - c:directionTextScale="0.5" - a:onClick="digitButtonClickHandler"/> \ No newline at end of file + c:directionTextScale="0.5"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_operators.xml b/android-app/src/main/res/layout/cpp_app_button_operators.xml similarity index 95% rename from android-app/src/main/res/layout/cpp_drag_button_operators.xml rename to android-app/src/main/res/layout/cpp_app_button_operators.xml index 5ad88728..73d260e3 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_operators.xml +++ b/android-app/src/main/res/layout/cpp_app_button_operators.xml @@ -25,5 +25,4 @@ \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_app_button_paste.xml b/android-app/src/main/res/layout/cpp_app_button_paste.xml index 7544b59e..c184b789 100644 --- a/android-app/src/main/res/layout/cpp_app_button_paste.xml +++ b/android-app/src/main/res/layout/cpp_app_button_paste.xml @@ -25,5 +25,4 @@ \ No newline at end of file + style="?cpp_control_image_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_plus.xml b/android-app/src/main/res/layout/cpp_app_button_plus.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_plus.xml rename to android-app/src/main/res/layout/cpp_app_button_plus.xml index f9ce8dab..221e9c29 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_plus.xml +++ b/android-app/src/main/res/layout/cpp_app_button_plus.xml @@ -28,5 +28,4 @@ c:textUp="°" c:textDown="E" a:text="+" - style="?cpp_operation_button_style" - a:onClick="digitButtonClickHandler"/> \ No newline at end of file + style="?cpp_operation_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_right.xml b/android-app/src/main/res/layout/cpp_app_button_right.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_right.xml rename to android-app/src/main/res/layout/cpp_app_button_right.xml index 5f470863..8d4524d4 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_right.xml +++ b/android-app/src/main/res/layout/cpp_app_button_right.xml @@ -28,5 +28,4 @@ c:textUp="▷▷" a:text="▷" c:directionTextScale="0.5" - style="?cpp_control_button_style" - a:onClick="digitButtonClickHandler"/> \ No newline at end of file + style="?cpp_control_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_round_brackets.xml b/android-app/src/main/res/layout/cpp_app_button_round_brackets.xml similarity index 92% rename from android-app/src/main/res/layout/cpp_drag_button_round_brackets.xml rename to android-app/src/main/res/layout/cpp_app_button_round_brackets.xml index 5f9a1ee7..919e47cc 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_round_brackets.xml +++ b/android-app/src/main/res/layout/cpp_app_button_round_brackets.xml @@ -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"/> \ No newline at end of file + style="?cpp_digit_button_style"/> \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_drag_button_vars.xml b/android-app/src/main/res/layout/cpp_app_button_vars.xml similarity index 93% rename from android-app/src/main/res/layout/cpp_drag_button_vars.xml rename to android-app/src/main/res/layout/cpp_app_button_vars.xml index 8b809720..e8ec4c3a 100644 --- a/android-app/src/main/res/layout/cpp_drag_button_vars.xml +++ b/android-app/src/main/res/layout/cpp_app_button_vars.xml @@ -25,9 +25,8 @@ \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_app_keyboard.xml b/android-app/src/main/res/layout/cpp_app_keyboard.xml index 633a98c9..4f3ce878 100644 --- a/android-app/src/main/res/layout/cpp_app_keyboard.xml +++ b/android-app/src/main/res/layout/cpp_app_keyboard.xml @@ -32,15 +32,15 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + @@ -49,13 +49,13 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + @@ -66,13 +66,13 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + @@ -83,13 +83,13 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + @@ -101,15 +101,15 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + diff --git a/android-app/src/main/res/layout/cpp_app_keyboard_mobile.xml b/android-app/src/main/res/layout/cpp_app_keyboard_mobile.xml index 633a98c9..4f3ce878 100644 --- a/android-app/src/main/res/layout/cpp_app_keyboard_mobile.xml +++ b/android-app/src/main/res/layout/cpp_app_keyboard_mobile.xml @@ -32,15 +32,15 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + @@ -49,13 +49,13 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + @@ -66,13 +66,13 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + @@ -83,13 +83,13 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + @@ -101,15 +101,15 @@ a:layout_width="match_parent" a:layout_height="0dp"> - + - + - + - + - + diff --git a/android-app/src/main/res/layout/cpp_wizard_step_choose_theme.xml b/android-app/src/main/res/layout/cpp_wizard_step_choose_theme.xml new file mode 100644 index 00000000..798aa352 --- /dev/null +++ b/android-app/src/main/res/layout/cpp_wizard_step_choose_theme.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + diff --git a/android-app/src/main/res/layout/cpp_wizard_step_choose_theme_preview.xml b/android-app/src/main/res/layout/cpp_wizard_step_choose_theme_preview.xml new file mode 100644 index 00000000..dc17bb4e --- /dev/null +++ b/android-app/src/main/res/layout/cpp_wizard_step_choose_theme_preview.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android-app/src/main/res/layout/drag_button_calibration.xml b/android-app/src/main/res/layout/drag_button_calibration.xml deleted file mode 100644 index 468a1e00..00000000 --- a/android-app/src/main/res/layout/drag_button_calibration.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -