| @@ -7,6 +7,8 @@ import android.app.Dialog; | |||
| import android.content.Context; | |||
| import android.content.Intent; | |||
| import android.content.pm.ActivityInfo; | |||
| import android.os.Bundle; | |||
| import android.os.Handler; | |||
| @@ -61,6 +63,9 @@ import ch.spherIC.recurvebowsight.model.IRiser; | |||
| import ch.spherIC.recurvebowsight.model.ISight; | |||
| import ch.spherIC.recurvebowsight.model.Riser; | |||
| import ch.spherIC.recurvebowsight.model.Sight; | |||
| import ch.spherIC.recurvebowsight.utilities.CompatibilityUtil; | |||
| import ch.spherIC.recurvebowsight.utilities.PlatformUtils; | |||
| import ch.spherIC.recurvebowsight.utilities.UnitConverter; | |||
| import org.achartengine.GraphicalView; | |||
| @@ -140,6 +145,11 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi | |||
| super.onCreate(savedInstanceState); | |||
| setContentView(R.layout.rbs_main); | |||
| PlatformUtils.getPlatformSelectionColor(getApplicationContext()); | |||
| if (CompatibilityUtil.isTablet(getApplicationContext())) { | |||
| setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); | |||
| } else { | |||
| setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | |||
| } | |||
| this.calculationAlert = new AlertDialog.Builder(this).create(); | |||
| this.calculationAlert.setCancelable(false); // This blocks the 'BACK' button | |||
| @@ -860,6 +870,7 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi | |||
| this.flightCurveChart.getDataSet().removeSeries(0); | |||
| this.flightCurveChart.getDataSet().addSeries(0, serie); | |||
| this.flightCurveChart.updateRendererAfterCalculation(flightCurve[flightCurve.length - 1][TrajectoryCalculator.IDX_X], flightCurve); | |||
| } | |||
| @@ -59,18 +59,12 @@ public class FlightCurveChart { | |||
| this.mRenderer.setLabelsTextSize(15); | |||
| this.mRenderer.setXTitle(context.getResources().getString(R.string.fcChart_TitleXAxis)); | |||
| this.mRenderer.setXLabels(18); /** TODO: Abhängig von Schiessdistanz */ | |||
| this.mRenderer.setXLabelsColor(Color.DKGRAY); | |||
| this.mRenderer.setYTitle(context.getResources().getString(R.string.fcChart_TitleYAxis)); | |||
| this.mRenderer.setYLabels(10); /** TODO: Abhängig von Schiessdistanz */ | |||
| this.mRenderer.setYLabelsPadding(20); | |||
| this.mRenderer.setYLabelsColor(0, Color.DKGRAY); | |||
| this.mRenderer.setYAxisMin(-0.9); /** TODO: Abhängig von Schiessdistanz */ | |||
| this.mRenderer.setYAxisMax(0.9); /** TODO: Abhängig von Schiessdistanz */ | |||
| // Zoom ausschalten | |||
| this.mRenderer.setZoomEnabled(false, false); | |||
| this.mRenderer.setZoomButtonsVisible(false); | |||
| @@ -109,4 +103,25 @@ public class FlightCurveChart { | |||
| public XYMultipleSeriesRenderer getMultiRenderer() { | |||
| return this.mRenderer; | |||
| } | |||
| public void updateRendererAfterCalculation(final Double shootingDistance, final Double[][] flightCurve) { | |||
| int xLbls = 1; | |||
| if (shootingDistance <= 18d) { | |||
| xLbls = (int) Math.round(shootingDistance); | |||
| } else if (shootingDistance <= 30d) { | |||
| xLbls = (int) Math.round(shootingDistance) / 2; | |||
| } else if (shootingDistance <= 90d) { | |||
| xLbls = (int) Math.round(shootingDistance) / 5; | |||
| } else { | |||
| xLbls = (int) Math.round(shootingDistance) / 10; | |||
| } | |||
| this.mRenderer.setXLabels(xLbls); | |||
| this.mRenderer.setYLabels(10); | |||
| this.mRenderer.setYAxisMin(-0.9); | |||
| this.mRenderer.setYAxisMax(0.9); | |||
| } | |||
| } | |||
| @@ -15,7 +15,7 @@ import android.util.Log; | |||
| import android.widget.EditText; | |||
| import ch.spherIC.recurvebowsight.R; | |||
| import ch.spherIC.recurvebowsight.UnitConverter; | |||
| import ch.spherIC.recurvebowsight.utilities.UnitConverter; | |||
| /** | |||
| @@ -0,0 +1,65 @@ | |||
| /** | |||
| * Copyright (C) 2005-2012 XELOG AG | |||
| */ | |||
| package ch.spherIC.recurvebowsight.utilities; | |||
| import android.content.Context; | |||
| import android.content.res.Configuration; | |||
| import android.os.Build; | |||
| /** | |||
| * @author FC Smilari | |||
| */ | |||
| public class CompatibilityUtil { | |||
| private static final int VERSION_CODES_HONEYCOMB = 11; | |||
| /** | |||
| * Get the current Android API level. | |||
| */ | |||
| public static int getSdkVersion() { | |||
| return Build.VERSION.SDK_INT; | |||
| } | |||
| /** | |||
| * Determine if the device is running API level 8 or higher. | |||
| */ | |||
| public static boolean isFroyo() { | |||
| return getSdkVersion() >= Build.VERSION_CODES.FROYO; | |||
| } | |||
| /** | |||
| * Determine if the device is running API level 11 or higher. | |||
| */ | |||
| public static boolean isHoneycomb() { | |||
| return getSdkVersion() >= VERSION_CODES_HONEYCOMB; | |||
| } | |||
| /** | |||
| * Determine if the device is a tablet (i.e. it has a large screen). | |||
| * | |||
| * @param context The calling context. | |||
| */ | |||
| public static boolean isTablet(final Context context) { | |||
| return (context.getResources().getConfiguration().screenLayout | |||
| & Configuration.SCREENLAYOUT_SIZE_MASK) | |||
| >= Configuration.SCREENLAYOUT_SIZE_LARGE; | |||
| } | |||
| /** | |||
| * Determine if the device is a HoneyComb tablet. | |||
| * | |||
| * @param context The calling context. | |||
| */ | |||
| public static boolean isHoneycombTablet(final Context context) { | |||
| return isHoneycomb() && isTablet(context); | |||
| } | |||
| /** | |||
| * This class can't be instantiated. | |||
| */ | |||
| private CompatibilityUtil() { } | |||
| } | |||
| @@ -1,7 +1,7 @@ | |||
| /** | |||
| * Copyright (C) 2005-2012 XELOG AG | |||
| */ | |||
| package ch.spherIC.recurvebowsight; | |||
| package ch.spherIC.recurvebowsight.utilities; | |||
| import android.content.Context; | |||
| @@ -1,7 +1,7 @@ | |||
| /** | |||
| * Copyright (C) 2005-2012 XELOG AG | |||
| */ | |||
| package ch.spherIC.recurvebowsight; | |||
| package ch.spherIC.recurvebowsight.utilities; | |||
| import android.app.Application; | |||