This commit is contained in:
serso 2015-10-16 16:02:47 +02:00
parent d1aeb7f458
commit 821e3727f2
7 changed files with 247 additions and 5 deletions

View File

@ -75,6 +75,7 @@
<orderEntry type="library" exported="" scope="TEST" name="support-annotations-22.1.1" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="support-annotations-22.1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="simple-xml-2.6.1" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="simple-xml-2.6.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_plotter_jars_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="core" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="core" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="commons-cli-1.2" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="commons-cli-1.2" level="project" />
@ -91,20 +92,21 @@
<orderEntry type="library" exported="" scope="TEST" name="guava-11.0.2" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="guava-11.0.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="library-2.4.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="common-text-1.0.7" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="common-text-1.0.7" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="library-2.4.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="acra-4.5.0" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="acra-4.5.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="leakcanary-analyzer-1.3.1" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="leakcanary-analyzer-1.3.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="common-core-1.0.7" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="common-core-1.0.7" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_com_android_support_support_v4_23_1_0_jars_classes_jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="common-security-1.0.7" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="common-security-1.0.7" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_com_android_support_appcompat_v7_23_1_0_jars_classes_jar" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="jscl-1.0.11" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="jscl-1.0.11" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="leakcanary-watcher-1.3.1" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="leakcanary-watcher-1.3.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="haha-1.3" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="haha-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="internal_impl-23.1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="support-annotations-23.1.0" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="support-annotations-23.1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_classes_debug" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_classes_debug" level="project" />

View File

@ -87,6 +87,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/android-common-views/1.1.18/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/android-common-views/1.1.18/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/checkout/0.7.2/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/checkout/0.7.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/material/0.1.3/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.solovyev.android/material/0.1.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/plotter/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
@ -134,6 +135,7 @@
<orderEntry type="library" exported="" name="guava-11.0.2" level="project" /> <orderEntry type="library" exported="" name="guava-11.0.2" level="project" />
<orderEntry type="library" exported="" name="commons-cli-1.2" level="project" /> <orderEntry type="library" exported="" name="commons-cli-1.2" level="project" />
<orderEntry type="library" exported="" name="leakcanary-android-1.3.1" level="project" /> <orderEntry type="library" exported="" name="leakcanary-android-1.3.1" level="project" />
<orderEntry type="library" exported="" name="plotter-" level="project" />
<orderEntry type="library" exported="" name="simple-xml-2.6.1" level="project" /> <orderEntry type="library" exported="" name="simple-xml-2.6.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" /> <orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-7.5.0" level="project" /> <orderEntry type="library" exported="" name="play-services-ads-7.5.0" level="project" />

View File

@ -50,6 +50,12 @@ android {
} }
} }
repositories {
flatDir{
dirs 'misc/libs'
}
}
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':core') compile project(':core')
@ -76,6 +82,7 @@ dependencies {
compile 'com.google.android.gms:play-services-base:7.5.0@aar' compile 'com.google.android.gms:play-services-base:7.5.0@aar'
compile 'com.google.android.gms:play-services-analytics:7.5.0@aar' compile 'com.google.android.gms:play-services-analytics:7.5.0@aar'
compile 'com.melnykov:floatingactionbutton:1.1.0' compile 'com.melnykov:floatingactionbutton:1.1.0'
compile(name:'plotter', ext:'aar')
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1' debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1' releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'

View File

@ -55,6 +55,8 @@ import org.solovyev.android.checkout.ProductTypes;
import org.solovyev.android.checkout.Products; import org.solovyev.android.checkout.Products;
import org.solovyev.android.checkout.RobotmediaDatabase; import org.solovyev.android.checkout.RobotmediaDatabase;
import org.solovyev.android.checkout.RobotmediaInventory; import org.solovyev.android.checkout.RobotmediaInventory;
import org.solovyev.android.plotter.Plot;
import org.solovyev.android.plotter.Plotter;
import org.solovyev.common.listeners.JEvent; import org.solovyev.common.listeners.JEvent;
import org.solovyev.common.listeners.JEventListener; import org.solovyev.common.listeners.JEventListener;
import org.solovyev.common.listeners.JEventListeners; import org.solovyev.common.listeners.JEventListeners;
@ -120,6 +122,9 @@ public final class App {
@Nonnull @Nonnull
private static volatile ScreenMetrics screenMetrics; private static volatile ScreenMetrics screenMetrics;
@Nonnull
private static volatile Plotter plotter;
@Nonnull @Nonnull
private static final Languages languages = new Languages(); private static final Languages languages = new Languages();
@ -184,6 +189,7 @@ public final class App {
} }
} }
App.languages.init(App.preferences); App.languages.init(App.preferences);
App.plotter = Plot.newPlotter(application);
App.initialized = true; App.initialized = true;
} else { } else {
@ -342,4 +348,9 @@ public final class App {
// Create and show the dialog. // Create and show the dialog.
dialogFragment.show(ft, fragmentTag); dialogFragment.show(ft, fragmentTag);
} }
@Nonnull
public static Plotter getPlotter() {
return plotter;
}
} }

View File

@ -23,6 +23,7 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import org.solovyev.android.calculator.about.CalculatorAboutFragment; import org.solovyev.android.calculator.about.CalculatorAboutFragment;
import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment; import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment;
import org.solovyev.android.calculator.history.HistoryFragment; import org.solovyev.android.calculator.history.HistoryFragment;
@ -31,10 +32,10 @@ import org.solovyev.android.calculator.math.edit.CalculatorFunctionsFragment;
import org.solovyev.android.calculator.math.edit.CalculatorOperatorsFragment; import org.solovyev.android.calculator.math.edit.CalculatorOperatorsFragment;
import org.solovyev.android.calculator.math.edit.CalculatorVarsFragment; import org.solovyev.android.calculator.math.edit.CalculatorVarsFragment;
import org.solovyev.android.calculator.matrix.CalculatorMatrixEditFragment; import org.solovyev.android.calculator.matrix.CalculatorMatrixEditFragment;
import org.solovyev.android.calculator.plot.CalculatorPlotFragment;
import org.solovyev.android.calculator.plot.CalculatorPlotFunctionSettingsActivity; import org.solovyev.android.calculator.plot.CalculatorPlotFunctionSettingsActivity;
import org.solovyev.android.calculator.plot.CalculatorPlotFunctionsActivity; import org.solovyev.android.calculator.plot.CalculatorPlotFunctionsActivity;
import org.solovyev.android.calculator.plot.CalculatorPlotRangeActivity; import org.solovyev.android.calculator.plot.CalculatorPlotRangeActivity;
import org.solovyev.android.calculator.plot.PlotterFragment;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -53,7 +54,7 @@ public enum CalculatorFragmentType {
variables(CalculatorVarsFragment.class, R.layout.vars_fragment, R.string.c_vars), variables(CalculatorVarsFragment.class, R.layout.vars_fragment, R.string.c_vars),
functions(CalculatorFunctionsFragment.class, R.layout.math_entities_fragment, R.string.c_functions), functions(CalculatorFunctionsFragment.class, R.layout.math_entities_fragment, R.string.c_functions),
operators(CalculatorOperatorsFragment.class, R.layout.math_entities_fragment, R.string.c_operators), operators(CalculatorOperatorsFragment.class, R.layout.math_entities_fragment, R.string.c_operators),
plotter(CalculatorPlotFragment.class, R.layout.cpp_plot_fragment, R.string.c_graph), plotter(PlotterFragment.class, R.layout.cpp_plotter_fragment, R.string.c_graph),
plotter_functions(CalculatorPlotFunctionsActivity.CalculatorPlotFunctionsFragment.class, R.layout.cpp_plot_functions_fragment, R.string.cpp_plot_functions), plotter_functions(CalculatorPlotFunctionsActivity.CalculatorPlotFunctionsFragment.class, R.layout.cpp_plot_functions_fragment, R.string.cpp_plot_functions),
plotter_function_settings(CalculatorPlotFunctionSettingsActivity.CalculatorPlotFunctionSettingsFragment.class, R.layout.cpp_plot_function_settings_fragment, R.string.cpp_plot_function_settings), plotter_function_settings(CalculatorPlotFunctionSettingsActivity.CalculatorPlotFunctionSettingsFragment.class, R.layout.cpp_plot_function_settings_fragment, R.string.cpp_plot_function_settings),
plotter_range(CalculatorPlotRangeActivity.CalculatorPlotRangeFragment.class, R.layout.cpp_plot_range_fragment, R.string.cpp_plot_range), plotter_range(CalculatorPlotRangeActivity.CalculatorPlotRangeFragment.class, R.layout.cpp_plot_range_fragment, R.string.cpp_plot_range),

View File

@ -0,0 +1,141 @@
package org.solovyev.android.calculator.plot;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.ColorInt;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.CalculatorFragment;
import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.preferences.PreferencesActivity;
import org.solovyev.android.plotter.PlotView;
import org.solovyev.android.plotter.Plotter;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class PlotterFragment extends CalculatorFragment {
@Nonnull
private final Plotter plotter = App.getPlotter();
private PlotView plotView;
public PlotterFragment() {
super(CalculatorFragmentType.plotter);
}
@Override
public void onCreate(@Nullable Bundle in) {
super.onCreate(in);
setHasOptionsMenu(true);
}
@ColorInt
private int getBgColor() {
if (isPaneFragment()) {
return getBgColor(R.color.cpp_pane_bg_light, R.color.cpp_pane_bg);
} else {
return getBgColor(R.color.cpp_main_bg_light, R.color.cpp_main_bg);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = super.onCreateView(inflater, container, savedInstanceState);
plotView = (PlotView) view.findViewById(R.id.plotview);
plotView.setPlotter(plotter);
plotView.setBackgroundColor(getBgColor());
if (savedInstanceState != null) {
final Parcelable plotviewState = savedInstanceState.getParcelable("plotview");
if (plotviewState != null) {
plotView.onRestoreInstanceState(plotviewState);
}
}
final View zoomOutButton = view.findViewById(R.id.zoom_out_button);
zoomOutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plotView.zoom(false);
}
});
final View zoom0Button = view.findViewById(R.id.zoom_0_button);
zoom0Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plotView.resetCamera();
plotView.resetZoom();
}
});
final View zoomInButton = view.findViewById(R.id.zoom_in_button);
zoomInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plotView.zoom(true);
}
});
final View plotModeButton = view.findViewById(R.id.plot_mode_button);
plotModeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plotter.set3d(!plotter.is3d());
}
});
return view;
}
@ColorInt
@SuppressWarnings("deprecation")
private int getBgColor(int lightColor, int darkColor) {
return getResources().getColor(App.getTheme().isLight() ? lightColor : darkColor);
}
@Override
public void onSaveInstanceState(@Nonnull Bundle out) {
super.onSaveInstanceState(out);
final Parcelable plotViewState = plotView.onSaveInstanceState();
out.putParcelable("plotview", plotViewState);
}
@Override
public void onPause() {
plotView.onPause();
super.onPause();
}
@Override
public void onResume() {
super.onResume();
plotView.onResume();
}
@Override
public void onCreateOptionsMenu(final Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.plot_menu, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_plot_functions:
startActivity(new Intent(getActivity(), CalculatorPlotFunctionsActivity.class));
return true;
case R.id.menu_plot_settings:
PreferencesActivity.start(getActivity(), R.xml.preferences_plot, R.string.prefs_graph_screen_title);
return true;
}
return super.onOptionsItemSelected(item);
}
}

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2013 serso aka se.solovyev
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Contact details
~
~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org
-->
<LinearLayout
a:id="@+id/main_fragment_layout"
style="@style/CppFragment"
xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="match_parent"
a:layout_height="match_parent">
<TextView
a:id="@+id/fragment_title"
style="@style/CppFragmentTitle"
a:layout_width="match_parent"
a:layout_height="wrap_content"/>
<include layout="@layout/ad"/>
<org.solovyev.android.plotter.PlotView
a:id="@+id/plotview"
a:layout_width="match_parent"
a:layout_height="0dp"
a:layout_weight="1"/>
<LinearLayout
a:layout_width="match_parent"
a:layout_height="wrap_content"
a:background="@android:color/black"
a:gravity="center"
a:orientation="horizontal">
<Button
a:id="@+id/zoom_out_button"
a:layout_width="wrap_content"
a:layout_height="wrap_content"
a:text="-"/>
<Button
a:id="@+id/zoom_0_button"
a:layout_width="wrap_content"
a:layout_height="wrap_content"
a:text="0"/>
<Button
a:id="@+id/zoom_in_button"
a:layout_width="wrap_content"
a:layout_height="wrap_content"
a:text="+"/>
<Button
a:id="@+id/plot_mode_button"
a:layout_width="wrap_content"
a:layout_height="wrap_content"
a:text="2D/3D"/>
</LinearLayout>
</LinearLayout>