Tablet support

This commit is contained in:
serso 2016-02-22 15:12:48 +01:00
parent 282d17ad1c
commit a68e08201f
17 changed files with 292 additions and 79 deletions

View File

@ -60,10 +60,20 @@
android:name=".preferences.PreferencesActivity" android:name=".preferences.PreferencesActivity"
android:label="@string/c_app_settings" /> android:label="@string/c_app_settings" />
<activity
android:name=".preferences.PreferencesActivity$Dialog"
android:label="@string/c_app_settings"
android:theme="@style/Cpp.Theme.Dialog" />
<activity <activity
android:name=".history.HistoryActivity" android:name=".history.HistoryActivity"
android:label="@string/c_history" /> android:label="@string/c_history" />
<activity
android:name=".history.HistoryActivity$Dialog"
android:label="@string/c_history"
android:theme="@style/Cpp.Theme.Dialog" />
<activity <activity
android:name=".errors.FixableErrorsActivity" android:name=".errors.FixableErrorsActivity"
android:excludeFromRecents="true" android:excludeFromRecents="true"
@ -75,17 +85,38 @@
android:name=".about.AboutActivity" android:name=".about.AboutActivity"
android:label="@string/c_about" /> android:label="@string/c_about" />
<activity
android:name=".about.AboutActivity$Dialog"
android:label="@string/c_about"
android:theme="@style/Cpp.Theme.Dialog" />
<activity <activity
android:name=".functions.FunctionsActivity" android:name=".functions.FunctionsActivity"
android:label="@string/c_functions" /> android:label="@string/c_functions" />
<activity
android:name=".functions.FunctionsActivity$Dialog"
android:label="@string/c_functions"
android:theme="@style/Cpp.Theme.Dialog" />
<activity <activity
android:name=".operators.OperatorsActivity" android:name=".operators.OperatorsActivity"
android:label="@string/c_operators" /> android:label="@string/c_operators" />
<activity
android:name=".operators.OperatorsActivity$Dialog"
android:label="@string/c_operators"
android:theme="@style/Cpp.Theme.Dialog" />
<activity <activity
android:name=".variables.VariablesActivity" android:name=".variables.VariablesActivity"
android:label="@string/c_vars_and_constants" /> android:label="@string/c_vars_and_constants" />
<activity
android:name=".variables.VariablesActivity$Dialog"
android:label="@string/c_vars_and_constants"
android:theme="@style/Cpp.Theme.Dialog" />
<activity <activity
android:name=".wizard.WizardActivity" android:name=".wizard.WizardActivity"
android:launchMode="singleTop" android:launchMode="singleTop"

View File

@ -47,6 +47,9 @@ import org.solovyev.android.calculator.variables.VariablesFragment;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
import org.solovyev.common.text.Strings; import org.solovyev.common.text.Strings;
import jscl.math.Generic;
import jscl.math.function.Constant;
import java.util.Set; import java.util.Set;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -54,9 +57,6 @@ import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import jscl.math.Generic;
import jscl.math.function.Constant;
@Singleton @Singleton
public final class ActivityLauncher implements CalculatorEventListener { public final class ActivityLauncher implements CalculatorEventListener {
@ -150,11 +150,11 @@ public final class ActivityLauncher implements CalculatorEventListener {
} }
public void showHistory() { public void showHistory() {
show(getContext(), HistoryActivity.class); show(getContext(), HistoryActivity.getClass(getContext()));
} }
public void showSettings() { public void showSettings() {
show(getContext(), PreferencesActivity.class); show(getContext(), PreferencesActivity.getClass(getContext()));
} }
public void showWidgetSettings() { public void showWidgetSettings() {
@ -163,11 +163,11 @@ public final class ActivityLauncher implements CalculatorEventListener {
} }
public void showOperators() { public void showOperators() {
show(getContext(), OperatorsActivity.class); show(getContext(), OperatorsActivity.getClass(getContext()));
} }
public void showAbout() { public void showAbout() {
show(getContext(), AboutActivity.class); show(getContext(), AboutActivity.getClass(getContext()));
} }
public void openFacebook() { public void openFacebook() {
@ -239,11 +239,11 @@ public final class ActivityLauncher implements CalculatorEventListener {
} }
public void showFunctions() { public void showFunctions() {
show(getContext(), FunctionsActivity.class); show(getContext(), FunctionsActivity.getClass(getContext()));
} }
public void showVariables() { public void showVariables() {
show(getContext(), VariablesActivity.class); show(getContext(), VariablesActivity.getClass(getContext()));
} }
public void openApp() { public void openApp() {

View File

@ -22,6 +22,8 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import static org.solovyev.android.calculator.App.cast;
import android.app.Activity; import android.app.Activity;
import android.app.KeyguardManager; import android.app.KeyguardManager;
import android.content.Context; import android.content.Context;
@ -29,11 +31,9 @@ import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.LayoutRes; import android.support.annotation.LayoutRes;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
@ -41,8 +41,7 @@ import android.util.DisplayMetrics;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;
import org.solovyev.android.Activities; import org.solovyev.android.Activities;
import org.solovyev.android.Check; import org.solovyev.android.Check;
import org.solovyev.android.Views; import org.solovyev.android.Views;
@ -51,12 +50,12 @@ import org.solovyev.android.calculator.language.Language;
import org.solovyev.android.calculator.language.Languages; import org.solovyev.android.calculator.language.Languages;
import org.solovyev.android.calculator.view.Tabs; import org.solovyev.android.calculator.view.Tabs;
import butterknife.Bind;
import butterknife.ButterKnife;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import static org.solovyev.android.calculator.App.cast;
public class ActivityUi { public class ActivityUi {
@ -157,10 +156,6 @@ public class ActivityUi {
App.getLanguages().updateContextLocale(activity, false); App.getLanguages().updateContextLocale(activity, false);
if (activity instanceof CalculatorEventListener) {
Locator.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) activity);
}
activity.setContentView(layoutId); activity.setContentView(layoutId);
ButterKnife.bind(this, activity); ButterKnife.bind(this, activity);
@ -189,22 +184,6 @@ public class ActivityUi {
public void onDestroy() { public void onDestroy() {
} }
public void addTab(@Nonnull Class<? extends Fragment> fragmentClass,
@Nullable Bundle fragmentArgs,
int title) {
addTab(fragmentClass, fragmentArgs, activity.getString(title));
}
public void addTab(@Nonnull Class<? extends Fragment> fragmentClass,
@Nullable Bundle fragmentArgs,
@Nonnull CharSequence title) {
tabs.addTab(fragmentClass, fragmentArgs, title);
}
public void addTab(@Nonnull FragmentTab tab, @Nullable Bundle fragmentArgs) {
addTab(tab.type, fragmentArgs, tab.title);
}
@Nonnull @Nonnull
public Language getLanguage() { public Language getLanguage() {
return language; return language;

View File

@ -41,8 +41,14 @@ import android.util.SparseArray;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import org.solovyev.android.Check; import org.solovyev.android.Check;
import org.solovyev.android.calculator.about.AboutActivity;
import org.solovyev.android.calculator.functions.FunctionsActivity;
import org.solovyev.android.calculator.history.HistoryActivity;
import org.solovyev.android.calculator.language.Languages; import org.solovyev.android.calculator.language.Languages;
import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.operators.OperatorsActivity;
import org.solovyev.android.calculator.preferences.PreferencesActivity;
import org.solovyev.android.calculator.variables.VariablesActivity;
import org.solovyev.android.calculator.wizard.WizardActivity; import org.solovyev.android.calculator.wizard.WizardActivity;
import org.solovyev.android.prefs.BooleanPreference; import org.solovyev.android.prefs.BooleanPreference;
import org.solovyev.android.prefs.IntegerPreference; import org.solovyev.android.prefs.IntegerPreference;
@ -334,7 +340,24 @@ public final class Preferences {
if (context instanceof WizardActivity) { if (context instanceof WizardActivity) {
return wizardTheme; return wizardTheme;
} }
final boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet); if (context instanceof FunctionsActivity.Dialog) {
return dialogTheme;
}
if (context instanceof PreferencesActivity.Dialog) {
return dialogTheme;
}
if (context instanceof VariablesActivity.Dialog) {
return dialogTheme;
}
if (context instanceof OperatorsActivity.Dialog) {
return dialogTheme;
}
if (context instanceof HistoryActivity.Dialog) {
return dialogTheme;
}
if (context instanceof AboutActivity.Dialog) {
return dialogTheme;
}
return theme; return theme;
} }

View File

@ -22,14 +22,28 @@
package org.solovyev.android.calculator.about; package org.solovyev.android.calculator.about;
import android.content.Context;
import android.support.annotation.NonNull;
import org.solovyev.android.calculator.BaseActivity; import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.FragmentTab; import org.solovyev.android.calculator.FragmentTab;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.view.Tabs; import org.solovyev.android.calculator.view.Tabs;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public class AboutActivity extends BaseActivity { public class AboutActivity extends BaseActivity {
public static class Dialog extends AboutActivity {
}
@Nonnull
public static Class<? extends AboutActivity> getClass(@NonNull Context context) {
boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet);
return tablet ? Dialog.class : AboutActivity.class;
}
@Override @Override
protected void populateTabs(@Nonnull Tabs tabs) { protected void populateTabs(@Nonnull Tabs tabs) {
super.populateTabs(tabs); super.populateTabs(tabs);

View File

@ -22,6 +22,8 @@
package org.solovyev.android.calculator.functions; package org.solovyev.android.calculator.functions;
import static org.solovyev.android.calculator.functions.CppFunction.NO_ID;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -35,26 +37,47 @@ import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.*; import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import butterknife.Bind;
import butterknife.ButterKnife;
import jscl.math.function.Function;
import org.solovyev.android.Activities; import org.solovyev.android.Activities;
import org.solovyev.android.Check; import org.solovyev.android.Check;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.AppComponent;
import org.solovyev.android.calculator.BaseDialogFragment;
import org.solovyev.android.calculator.Calculator;
import org.solovyev.android.calculator.Engine;
import org.solovyev.android.calculator.FloatingCalculatorKeyboard;
import org.solovyev.android.calculator.Keyboard;
import org.solovyev.android.calculator.ParseException;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.VariablesRegistry;
import org.solovyev.android.calculator.entities.EntityRemovalDialog; import org.solovyev.android.calculator.entities.EntityRemovalDialog;
import org.solovyev.android.calculator.keyboard.FloatingKeyboardWindow; import org.solovyev.android.calculator.keyboard.FloatingKeyboardWindow;
import org.solovyev.android.calculator.view.EditTextCompat; import org.solovyev.android.calculator.view.EditTextCompat;
import org.solovyev.common.math.MathRegistry; import org.solovyev.common.math.MathRegistry;
import butterknife.Bind;
import butterknife.ButterKnife;
import jscl.math.function.Function;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.*;
import static org.solovyev.android.calculator.functions.CppFunction.NO_ID;
public class EditFunctionFragment extends BaseDialogFragment implements View.OnClickListener, View.OnFocusChangeListener, View.OnKeyListener { public class EditFunctionFragment extends BaseDialogFragment implements View.OnClickListener, View.OnFocusChangeListener, View.OnKeyListener {
@ -107,7 +130,7 @@ public class EditFunctionFragment extends BaseDialogFragment implements View.OnC
public static void show(@Nullable CppFunction function, @Nonnull Context context) { public static void show(@Nullable CppFunction function, @Nonnull Context context) {
if (!(context instanceof FunctionsActivity)) { if (!(context instanceof FunctionsActivity)) {
final Intent intent = new Intent(context, FunctionsActivity.class); final Intent intent = new Intent(context, FunctionsActivity.getClass(context));
Activities.addIntentFlags(intent, false, context); Activities.addIntentFlags(intent, false, context);
intent.putExtra(FunctionsActivity.EXTRA_FUNCTION, function); intent.putExtra(FunctionsActivity.EXTRA_FUNCTION, function);
context.startActivity(intent); context.startActivity(intent);

View File

@ -22,8 +22,11 @@
package org.solovyev.android.calculator.functions; package org.solovyev.android.calculator.functions;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View; import android.view.View;
import org.solovyev.android.calculator.BaseActivity; import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.FragmentTab; import org.solovyev.android.calculator.FragmentTab;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
@ -36,6 +39,12 @@ public class FunctionsActivity extends BaseActivity {
public static final String EXTRA_FUNCTION = "function"; public static final String EXTRA_FUNCTION = "function";
@Nonnull
public static Class<? extends FunctionsActivity> getClass(@NonNull Context context) {
boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet);
return tablet ? Dialog.class : FunctionsActivity.class;
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -74,4 +83,7 @@ public class FunctionsActivity extends BaseActivity {
tabs.addTab(category, FragmentTab.operators, title); tabs.addTab(category, FragmentTab.operators, title);
} }
} }
public static final class Dialog extends FunctionsActivity {
}
} }

View File

@ -22,21 +22,38 @@
package org.solovyev.android.calculator.history; package org.solovyev.android.calculator.history;
import static org.solovyev.android.calculator.FragmentTab.saved_history;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.view.View; import android.view.View;
import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.AppComponent;
import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.FragmentTab;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.view.Tabs; import org.solovyev.android.calculator.view.Tabs;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.inject.Inject; import javax.inject.Inject;
import static org.solovyev.android.calculator.FragmentTab.saved_history;
public class HistoryActivity extends BaseActivity { public class HistoryActivity extends BaseActivity {
public static class Dialog extends HistoryActivity {
}
@Nonnull
public static Class<? extends HistoryActivity> getClass(@NonNull Context context) {
boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet);
return tablet ? Dialog.class : HistoryActivity.class;
}
@Inject @Inject
History history; History history;

View File

@ -22,14 +22,27 @@
package org.solovyev.android.calculator.operators; package org.solovyev.android.calculator.operators;
import android.content.Context;
import android.support.annotation.NonNull;
import org.solovyev.android.calculator.BaseActivity; import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.FragmentTab; import org.solovyev.android.calculator.FragmentTab;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.view.Tabs; import org.solovyev.android.calculator.view.Tabs;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public class OperatorsActivity extends BaseActivity { public class OperatorsActivity extends BaseActivity {
public static class Dialog extends OperatorsActivity {
}
@Nonnull
public static Class<? extends OperatorsActivity> getClass(@NonNull Context context) {
boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet);
return tablet ? Dialog.class : OperatorsActivity.class;
}
@Override @Override
protected void populateTabs(@Nonnull Tabs tabs) { protected void populateTabs(@Nonnull Tabs tabs) {
super.populateTabs(tabs); super.populateTabs(tabs);

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.annotation.XmlRes; import android.support.annotation.XmlRes;
import android.util.SparseArray; import android.util.SparseArray;
@ -30,6 +31,11 @@ public class PreferencesActivity extends BaseActivity implements SharedPreferenc
@Nonnull @Nonnull
private static final SparseArray<PrefDef> preferences = new SparseArray<>(); private static final SparseArray<PrefDef> preferences = new SparseArray<>();
public static Class<? extends PreferencesActivity> getClass(@NonNull Context context) {
final boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet);
return tablet ? Dialog.class : PreferencesActivity.class;
}
static { static {
preferences.append(R.xml.preferences, new PrefDef("screen-main", R.string.c_app_settings)); preferences.append(R.xml.preferences, new PrefDef("screen-main", R.string.c_app_settings));
preferences.append(R.xml.preferences_calculations, new PrefDef("screen-calculations", R.string.c_prefs_calculations_category)); preferences.append(R.xml.preferences_calculations, new PrefDef("screen-calculations", R.string.c_prefs_calculations_category));
@ -68,7 +74,7 @@ public class PreferencesActivity extends BaseActivity implements SharedPreferenc
@Nonnull @Nonnull
public static Intent makeIntent(@Nonnull Context context, @XmlRes int preference, @StringRes int title) { public static Intent makeIntent(@Nonnull Context context, @XmlRes int preference, @StringRes int title) {
final Intent intent = new Intent(context, PreferencesActivity.class); final Intent intent = new Intent(context, getClass(context));
intent.putExtra(EXTRA_PREFERENCE, preference); intent.putExtra(EXTRA_PREFERENCE, preference);
if (title != 0) { if (title != 0) {
intent.putExtra(EXTRA_PREFERENCE_TITLE, title); intent.putExtra(EXTRA_PREFERENCE_TITLE, title);
@ -150,4 +156,7 @@ public class PreferencesActivity extends BaseActivity implements SharedPreferenc
this.title = title; this.title = title;
} }
} }
public static final class Dialog extends PreferencesActivity {
}
} }

View File

@ -1,15 +1,24 @@
package org.solovyev.android.calculator.preferences; package org.solovyev.android.calculator.preferences;
import static org.solovyev.android.calculator.wizard.CalculatorWizards.DEFAULT_WIZARD_FLOW;
import static org.solovyev.android.wizard.WizardUi.startWizard;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.support.v4.app.FragmentActivity;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.View; import android.view.View;
import android.widget.ListView; import android.widget.ListView;
import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.AdView;
import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.Engine;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.language.Language; import org.solovyev.android.calculator.language.Language;
import org.solovyev.android.calculator.language.Languages; import org.solovyev.android.calculator.language.Languages;
import org.solovyev.android.checkout.BillingRequests; import org.solovyev.android.checkout.BillingRequests;
@ -17,12 +26,10 @@ import org.solovyev.android.checkout.Checkout;
import org.solovyev.android.checkout.ProductTypes; import org.solovyev.android.checkout.ProductTypes;
import org.solovyev.android.checkout.RequestListener; import org.solovyev.android.checkout.RequestListener;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List; import java.util.List;
import static org.solovyev.android.calculator.wizard.CalculatorWizards.DEFAULT_WIZARD_FLOW; import javax.annotation.Nonnull;
import static org.solovyev.android.wizard.WizardUi.startWizard; import javax.annotation.Nullable;
public class PreferencesFragment extends org.solovyev.android.material.preferences.PreferencesFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public class PreferencesFragment extends org.solovyev.android.material.preferences.PreferencesFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -49,7 +56,8 @@ public class PreferencesFragment extends org.solovyev.android.material.preferenc
private void setPreferenceIntent(int xml, @Nonnull PreferencesActivity.PrefDef def) { private void setPreferenceIntent(int xml, @Nonnull PreferencesActivity.PrefDef def) {
final Preference preference = findPreference(def.id); final Preference preference = findPreference(def.id);
if (preference != null) { if (preference != null) {
final Intent intent = new Intent(getActivity(), PreferencesActivity.class); final FragmentActivity context = getActivity();
final Intent intent = new Intent(context, PreferencesActivity.getClass(context));
intent.putExtra(PreferencesActivity.EXTRA_PREFERENCE, xml); intent.putExtra(PreferencesActivity.EXTRA_PREFERENCE, xml);
intent.putExtra(PreferencesActivity.EXTRA_PREFERENCE_TITLE, def.title); intent.putExtra(PreferencesActivity.EXTRA_PREFERENCE_TITLE, def.title);
preference.setIntent(intent); preference.setIntent(intent);

View File

@ -22,6 +22,8 @@
package org.solovyev.android.calculator.variables; package org.solovyev.android.calculator.variables;
import static org.solovyev.android.calculator.variables.CppVariable.NO_ID;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -41,12 +43,17 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import butterknife.Bind;
import butterknife.ButterKnife;
import jscl.math.function.IConstant;
import org.solovyev.android.Activities; import org.solovyev.android.Activities;
import org.solovyev.android.Check; import org.solovyev.android.Check;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.AppComponent;
import org.solovyev.android.calculator.BaseDialogFragment;
import org.solovyev.android.calculator.Calculator;
import org.solovyev.android.calculator.Engine;
import org.solovyev.android.calculator.Keyboard;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.VariablesRegistry;
import org.solovyev.android.calculator.entities.EntityRemovalDialog; import org.solovyev.android.calculator.entities.EntityRemovalDialog;
import org.solovyev.android.calculator.functions.FunctionsRegistry; import org.solovyev.android.calculator.functions.FunctionsRegistry;
import org.solovyev.android.calculator.keyboard.FloatingKeyboard; import org.solovyev.android.calculator.keyboard.FloatingKeyboard;
@ -55,13 +62,16 @@ import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.view.EditTextCompat; import org.solovyev.android.calculator.view.EditTextCompat;
import org.solovyev.common.text.Strings; import org.solovyev.common.text.Strings;
import javax.annotation.Nonnull; import butterknife.Bind;
import javax.annotation.Nullable; import butterknife.ButterKnife;
import javax.inject.Inject; import jscl.math.function.IConstant;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import static org.solovyev.android.calculator.variables.CppVariable.NO_ID; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
public class EditVariableFragment extends BaseDialogFragment implements View.OnFocusChangeListener, View.OnKeyListener, View.OnClickListener { public class EditVariableFragment extends BaseDialogFragment implements View.OnFocusChangeListener, View.OnKeyListener, View.OnClickListener {
@ -119,7 +129,7 @@ public class EditVariableFragment extends BaseDialogFragment implements View.OnF
public static void showDialog(@Nullable CppVariable variable, @Nonnull Context context) { public static void showDialog(@Nullable CppVariable variable, @Nonnull Context context) {
if (!(context instanceof VariablesActivity)) { if (!(context instanceof VariablesActivity)) {
final Intent intent = new Intent(context, VariablesActivity.class); final Intent intent = new Intent(context, VariablesActivity.getClass(context));
Activities.addIntentFlags(intent, false, context); Activities.addIntentFlags(intent, false, context);
intent.putExtra(VariablesActivity.EXTRA_VARIABLE, variable); intent.putExtra(VariablesActivity.EXTRA_VARIABLE, variable);
context.startActivity(intent); context.startActivity(intent);

View File

@ -22,7 +22,9 @@
package org.solovyev.android.calculator.variables; package org.solovyev.android.calculator.variables;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View; import android.view.View;
import org.solovyev.android.calculator.BaseActivity; import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.FragmentTab; import org.solovyev.android.calculator.FragmentTab;
@ -36,6 +38,12 @@ public class VariablesActivity extends BaseActivity {
public static final String EXTRA_VARIABLE = "variable"; public static final String EXTRA_VARIABLE = "variable";
@Nonnull
public static Class<? extends VariablesActivity> getClass(@NonNull Context context) {
boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet);
return tablet ? Dialog.class : VariablesActivity.class;
}
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -63,4 +71,7 @@ public class VariablesActivity extends BaseActivity {
tabs.addTab(category, FragmentTab.variables); tabs.addTab(category, FragmentTab.variables);
} }
} }
public static final class Dialog extends VariablesActivity {
}
} }

View File

@ -0,0 +1,66 @@
<?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
-->
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main"
style="@style/CppMain"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="?cpp_toolbar_style"
android:layout_width="match_parent"
android:layout_height="?actionBarSize" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
style="?cpp_toolbar_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabMode="fixed" />
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
app:layout_behavior="org.solovyev.android.calculator.view.PagerViewFabBehavior"
android:id="@+id/fab"
style="@style/CppFab" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -3,6 +3,4 @@
<ListView <ListView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list" android:id="@android:id/list"
style="@style/CppListView" style="@style/CppListView"/>
android:layout_width="match_parent"
android:layout_height="match_parent" />

View File

@ -322,7 +322,7 @@
<item name="android:dividerHeight">1px</item> <item name="android:dividerHeight">1px</item>
<item name="android:divider">@drawable/divider</item> <item name="android:divider">@drawable/divider</item>
<item name="android:cacheColorHint">@android:color/transparent</item> <item name="android:cacheColorHint">@android:color/transparent</item>
<item name="android:layout_height">match_parent</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>
<item name="android:layout_weight">1</item> <item name="android:layout_weight">1</item>
<item name="android:fadingEdge">none</item> <item name="android:fadingEdge">none</item>

View File

@ -40,22 +40,19 @@
<item name="android:listDivider">@drawable/divider_dark</item> <item name="android:listDivider">@drawable/divider_dark</item>
</style> </style>
<style name="Cpp.Theme.Translucent" parent="Cpp.Theme.Dialog"> <style name="Cpp.Theme.Translucent" parent="Cpp.Theme.Dialog"/>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item> <style name="Cpp.Theme.Dialog" parent="@style/Theme.AppCompat.DialogWhenLarge">
<item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@color/cpp_main_bg</item>
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="Cpp.Theme.Dialog" parent="@style/Theme.AppCompat.Dialog">
<item name="colorPrimary">@color/cpp_metro_button</item> <item name="colorPrimary">@color/cpp_metro_button</item>
<item name="colorPrimaryDark">@color/cpp_metro_button_dark</item> <item name="colorPrimaryDark">@color/cpp_metro_button_dark</item>
<item name="colorAccent">@color/cpp_material_accent</item> <item name="colorAccent">@color/cpp_material_accent</item>
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>
<item name="android:windowTitleBackgroundStyle">@android:color/transparent</item>
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="cpp_main_bg">@color/cpp_main_bg</item> <item name="cpp_main_bg">@color/cpp_main_bg</item>
<item name="cpp_pane_bg">@drawable/pane</item> <item name="cpp_pane_bg">@drawable/pane</item>
@ -100,15 +97,17 @@
<item name="android:listDivider">@drawable/divider</item> <item name="android:listDivider">@drawable/divider</item>
</style> </style>
<style name="Cpp.Theme.Light.Dialog" parent="@style/Theme.AppCompat.Light.Dialog"> <style name="Cpp.Theme.Light.Dialog" parent="@style/Theme.AppCompat.Light.DialogWhenLarge">
<item name="android:windowBackground">@color/cpp_main_bg_light</item>
<item name="colorPrimary">@color/cpp_material_light</item> <item name="colorPrimary">@color/cpp_material_light</item>
<item name="colorPrimaryDark">@color/cpp_material_light</item> <item name="colorPrimaryDark">@color/cpp_material_light</item>
<item name="colorAccent">@color/cpp_material_light</item> <item name="colorAccent">@color/cpp_material_light</item>
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>
<item name="android:windowTitleBackgroundStyle">@android:color/transparent</item>
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="cpp_main_bg">@color/cpp_main_bg_light</item> <item name="cpp_main_bg">@color/cpp_main_bg_light</item>
<item name="cpp_pane_bg">@drawable/pane_light</item> <item name="cpp_pane_bg">@drawable/pane_light</item>