| import android.content.Context; | import android.content.Context; | ||||
| import android.content.Intent; | import android.content.Intent; | ||||
| import android.content.pm.ActivityInfo; | |||||
| import android.os.Bundle; | import android.os.Bundle; | ||||
| import android.os.Handler; | import android.os.Handler; | ||||
| import ch.spherIC.recurvebowsight.model.ISight; | import ch.spherIC.recurvebowsight.model.ISight; | ||||
| import ch.spherIC.recurvebowsight.model.Riser; | import ch.spherIC.recurvebowsight.model.Riser; | ||||
| import ch.spherIC.recurvebowsight.model.Sight; | 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; | import org.achartengine.GraphicalView; | ||||
| super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
| setContentView(R.layout.rbs_main); | setContentView(R.layout.rbs_main); | ||||
| PlatformUtils.getPlatformSelectionColor(getApplicationContext()); | 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 = new AlertDialog.Builder(this).create(); | ||||
| this.calculationAlert.setCancelable(false); // This blocks the 'BACK' button | this.calculationAlert.setCancelable(false); // This blocks the 'BACK' button | ||||
| this.flightCurveChart.getDataSet().removeSeries(0); | this.flightCurveChart.getDataSet().removeSeries(0); | ||||
| this.flightCurveChart.getDataSet().addSeries(0, serie); | this.flightCurveChart.getDataSet().addSeries(0, serie); | ||||
| this.flightCurveChart.updateRendererAfterCalculation(flightCurve[flightCurve.length - 1][TrajectoryCalculator.IDX_X], flightCurve); | |||||
| } | } | ||||
| this.mRenderer.setLabelsTextSize(15); | this.mRenderer.setLabelsTextSize(15); | ||||
| this.mRenderer.setXTitle(context.getResources().getString(R.string.fcChart_TitleXAxis)); | 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.setXLabelsColor(Color.DKGRAY); | ||||
| this.mRenderer.setYTitle(context.getResources().getString(R.string.fcChart_TitleYAxis)); | 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.setYLabelsPadding(20); | ||||
| this.mRenderer.setYLabelsColor(0, Color.DKGRAY); | 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 | // Zoom ausschalten | ||||
| this.mRenderer.setZoomEnabled(false, false); | this.mRenderer.setZoomEnabled(false, false); | ||||
| this.mRenderer.setZoomButtonsVisible(false); | this.mRenderer.setZoomButtonsVisible(false); | ||||
| public XYMultipleSeriesRenderer getMultiRenderer() { | public XYMultipleSeriesRenderer getMultiRenderer() { | ||||
| return this.mRenderer; | 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); | |||||
| } | |||||
| } | } |
| import android.widget.EditText; | import android.widget.EditText; | ||||
| import ch.spherIC.recurvebowsight.R; | import ch.spherIC.recurvebowsight.R; | ||||
| import ch.spherIC.recurvebowsight.UnitConverter; | |||||
| import ch.spherIC.recurvebowsight.utilities.UnitConverter; | |||||
| /** | /** |
| /** | |||||
| * 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() { } | |||||
| } |
| /** | /** | ||||
| * Copyright (C) 2005-2012 XELOG AG | * Copyright (C) 2005-2012 XELOG AG | ||||
| */ | */ | ||||
| package ch.spherIC.recurvebowsight; | |||||
| package ch.spherIC.recurvebowsight.utilities; | |||||
| import android.content.Context; | import android.content.Context; | ||||
| /** | /** | ||||
| * Copyright (C) 2005-2012 XELOG AG | * Copyright (C) 2005-2012 XELOG AG | ||||
| */ | */ | ||||
| package ch.spherIC.recurvebowsight; | |||||
| package ch.spherIC.recurvebowsight.utilities; | |||||
| import android.app.Application; | import android.app.Application; | ||||