From ddde5945c97b3db812ab06afd984a85645f310ad Mon Sep 17 00:00:00 2001 From: serso Date: Thu, 12 Feb 2015 21:10:50 +0100 Subject: [PATCH] cpp-120: Graph plotter looks bad with Material Light theme on tablets Fixes #120 --- .../plot/AbstractCalculatorPlotFragment.java | 13 +++++++------ .../calculator/plot/CalculatorPlotFragment.java | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java index 3f0e462e..3d8098eb 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java @@ -27,6 +27,7 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Bitmap; +import android.graphics.Color; import android.graphics.Paint; import android.os.Build; import android.os.Bundle; @@ -109,13 +110,11 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment @Override public void onCreate(@Nullable Bundle in) { super.onCreate(in); - if (isPaneFragment()) { - this.bgColor = getResources().getColor(R.color.cpp_pane_bg); + bgColor = getResources().getColor(App.getTheme().isLight() ? R.color.cpp_pane_bg_light : R.color.cpp_pane_bg); } else { - this.bgColor = getResources().getColor(android.R.color.transparent); + bgColor = getResources().getColor(App.getTheme().isLight() ? R.color.cpp_main_bg_light : R.color.cpp_main_bg); } - setHasOptionsMenu(true); } @@ -206,8 +205,10 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment ********************************************************************** */ - public int getBgColor() { - return bgColor; + public int getBgColor(boolean d3) { + // 3d plotter should always set a background color + // 2d plotter can leave with transparent background + return !d3 ? Color.TRANSPARENT : bgColor; } @Nonnull diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java index df4e3f34..b2975c26 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java @@ -63,14 +63,15 @@ public class CalculatorPlotFragment extends AbstractCalculatorPlotFragment { graphContainer.removeView((View) graphView); } - if (plotData.isPlot3d()) { + final boolean d3 = plotData.isPlot3d(); + if (d3) { graphView = new CalculatorGraph3dView(getActivity()); } else { graphView = new CalculatorGraph2dView(getActivity()); } final int color = App.getTheme().getTextColor(getActivity()).normal; - graphView.init(PlotViewDef.newInstance(color, color, Color.DKGRAY, getBgColor())); + graphView.init(PlotViewDef.newInstance(color, color, Color.DKGRAY, getBgColor(d3))); final PlotBoundaries boundaries = plotData.getBoundaries(); graphView.setXRange(boundaries.getXMin(), boundaries.getXMax());