cpp-120: Graph plotter looks bad with Material Light theme on tablets

Fixes #120
This commit is contained in:
serso 2015-02-12 21:10:50 +01:00
parent d1b45f8cb2
commit ddde5945c9
2 changed files with 10 additions and 8 deletions

View File

@ -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

View File

@ -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());