From 23d5441b99ec88e50f66fb9e17128493fc17e914 Mon Sep 17 00:00:00 2001 From: Sergey Solovyev Date: Wed, 26 Jun 2013 12:01:26 +0400 Subject: [PATCH] expand button --- android-app-core/res/values/text_strings.xml | 2 +- android-app/res/menu/functions_menu.xml | 8 +-- android-app/res/menu/history_menu.xml | 22 ++++--- android-app/res/menu/plot_menu.xml | 2 +- android-app/res/menu/vars_menu.xml | 8 +-- .../AbstractCalculatorHistoryFragment.java | 32 ++++++++++- .../edit/AbstractMathEntityListFragment.java | 57 +++++++------------ .../edit/CalculatorFunctionsFragment.java | 2 +- .../math/edit/CalculatorVarsFragment.java | 2 +- 9 files changed, 77 insertions(+), 58 deletions(-) diff --git a/android-app-core/res/values/text_strings.xml b/android-app-core/res/values/text_strings.xml index 5a6e7b25..7e0655aa 100644 --- a/android-app-core/res/values/text_strings.xml +++ b/android-app-core/res/values/text_strings.xml @@ -357,7 +357,7 @@ Unable to plot empty function! Unable to plot: too many variables! Graph range - Fullscreen plot + Fullscreen X Min X Max Y Min diff --git a/android-app/res/menu/functions_menu.xml b/android-app/res/menu/functions_menu.xml index acd9c695..c294ad03 100644 --- a/android-app/res/menu/functions_menu.xml +++ b/android-app/res/menu/functions_menu.xml @@ -9,8 +9,8 @@ + a:id="@+id/menu_functions_add_function" + a:title="@string/c_add" + a:icon="@drawable/kb_plus" + a:showAsAction="always"/> \ No newline at end of file diff --git a/android-app/res/menu/history_menu.xml b/android-app/res/menu/history_menu.xml index c4e7e913..97017c87 100644 --- a/android-app/res/menu/history_menu.xml +++ b/android-app/res/menu/history_menu.xml @@ -9,15 +9,21 @@ + a:id="@+id/menu_history_fullscreen" + a:title="@string/cpp_fullscreen" + a:icon="@drawable/kb_expand" + a:showAsAction="always"/> + a:id="@+id/menu_history_toggle_datetime" + a:icon="@drawable/kb_clock" + a:title="@string/c_toggle_datetime" + a:showAsAction="always"/> + + \ No newline at end of file diff --git a/android-app/res/menu/plot_menu.xml b/android-app/res/menu/plot_menu.xml index d1ae7ced..827c28b6 100644 --- a/android-app/res/menu/plot_menu.xml +++ b/android-app/res/menu/plot_menu.xml @@ -22,7 +22,7 @@ diff --git a/android-app/res/menu/vars_menu.xml b/android-app/res/menu/vars_menu.xml index 3cc8eeb2..3546b177 100644 --- a/android-app/res/menu/vars_menu.xml +++ b/android-app/res/menu/vars_menu.xml @@ -9,8 +9,8 @@ + a:id="@+id/menu_vars_add_var" + a:title="@string/c_add" + a:icon="@drawable/kb_plus" + a:showAsAction="always"/> \ No newline at end of file diff --git a/android-app/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java index 12340de3..5eb27fd8 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java @@ -7,6 +7,7 @@ package org.solovyev.android.calculator.history; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; @@ -90,7 +91,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag @Nonnull private CalculatorFragmentHelper fragmentHelper; - private ActivityMenu menu = ListActivityMenu.fromResource(R.menu.history_menu, HistoryMenu.class, SherlockMenuHelper.getInstance()); + private final ActivityMenu menu = ListActivityMenu.fromResource(R.menu.history_menu, HistoryMenu.class, SherlockMenuHelper.getInstance(), new HistoryMenuFilter()); @Nonnull private final SharedPreferences.OnSharedPreferenceChangeListener preferencesListener = new HistoryOnPreferenceChangeListener(); @@ -346,20 +347,27 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag private static enum HistoryMenu implements IdentifiableMenuItem { - clear_history(R.id.history_menu_clear_history) { + clear_history(R.id.menu_history_clear_history) { @Override public void onClick(@Nonnull MenuItem data, @Nonnull Context context) { Locator.getInstance().getCalculator().fireCalculatorEvent(clear_history_requested, null); } }, - toggle_datetime(R.id.history_menu_toggle_datetime) { + toggle_datetime(R.id.menu_history_toggle_datetime) { @Override public void onClick(@Nonnull MenuItem data, @Nonnull Context context) { final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(CalculatorApplication.getInstance()); final Boolean showDatetime = CalculatorPreferences.History.showDatetime.getPreference(preferences); CalculatorPreferences.History.showDatetime.putPreference(preferences, !showDatetime); } + }, + + fullscreen(R.id.menu_history_fullscreen) { + @Override + public void onClick(@Nonnull MenuItem data, @Nonnull Context context) { + context.startActivity(new Intent(context, CalculatorHistoryActivity.class)); + } }; private final int itemId; @@ -375,6 +383,24 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag } } + private class HistoryMenuFilter implements JPredicate> { + + @Override + public boolean apply(@Nullable AMenuItem menuItem) { + boolean result = false; + + if (menuItem instanceof IdentifiableMenuItem) { + switch (((IdentifiableMenuItem) menuItem).getItemId()) { + case R.id.menu_history_fullscreen: + result = !fragmentHelper.isPane(AbstractCalculatorHistoryFragment.this); + break; + } + } + + return result; + } + } + /* ********************************************************************** * diff --git a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/AbstractMathEntityListFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/AbstractMathEntityListFragment.java index aa2d868e..c0864974 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/AbstractMathEntityListFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/AbstractMathEntityListFragment.java @@ -6,17 +6,33 @@ package org.solovyev.android.calculator.math.edit; -import android.app.Activity; import android.content.Context; -import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.*; -import com.actionbarsherlock.app.SherlockListFragment; -import org.solovyev.android.calculator.*; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.ListView; +import android.widget.TextView; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.solovyev.android.calculator.CalculatorApplication; +import org.solovyev.android.calculator.CalculatorEventData; +import org.solovyev.android.calculator.CalculatorEventListener; +import org.solovyev.android.calculator.CalculatorEventType; +import org.solovyev.android.calculator.CalculatorFragmentHelper; +import org.solovyev.android.calculator.CalculatorFragmentType; +import org.solovyev.android.calculator.CalculatorMathRegistry; +import org.solovyev.android.calculator.Locator; +import org.solovyev.android.calculator.R; import org.solovyev.android.menu.AMenuItem; import org.solovyev.android.menu.ContextMenuBuilder; import org.solovyev.android.menu.LabeledMenuItem; @@ -27,11 +43,7 @@ import org.solovyev.common.filter.Filter; import org.solovyev.common.math.MathEntity; import org.solovyev.common.text.Strings; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; +import com.actionbarsherlock.app.SherlockListFragment; import static org.solovyev.android.calculator.CalculatorEventType.show_wiki_description; @@ -318,31 +330,6 @@ public abstract class AbstractMathEntityListFragment exten ********************************************************************** */ - static void createTab(@Nonnull Context context, - @Nonnull TabHost tabHost, - @Nonnull String tabId, - @Nonnull String categoryId, - int tabCaptionId, - @Nonnull Class activityClass, - @Nullable Intent parentIntent) { - - TabHost.TabSpec spec; - - final Intent intent; - if (parentIntent != null) { - intent = new Intent(parentIntent); - } else { - intent = new Intent(); - } - intent.setClass(context, activityClass); - intent.putExtra(MATH_ENTITY_CATEGORY_EXTRA_STRING, categoryId); - - // Initialize a TabSpec for each tab and add it to the TabHost - spec = tabHost.newTabSpec(tabId).setIndicator(context.getString(tabCaptionId)).setContent(intent); - - tabHost.addTab(spec); - } - @Nonnull public static Bundle createBundleFor(@Nonnull String categoryId) { final Bundle result = new Bundle(1); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsFragment.java index 72121de1..2ba05719 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsFragment.java @@ -200,7 +200,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment< boolean result; switch (item.getItemId()) { - case R.id.functions_menu_add_function: + case R.id.menu_functions_add_function: FunctionEditDialogFragment.showDialog(FunctionEditDialogFragment.Input.newInstance(), this.getActivity().getSupportFragmentManager()); result = true; break; diff --git a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java index 90e01499..d5fdba1d 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java @@ -146,7 +146,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment