gitsvn 12 роки тому
джерело
коміт
da5e496c7a

+ 11
- 0
src/ch/spherIC/recurvebowsight/RBSMainActivity.java Переглянути файл

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

+ 21
- 6
src/ch/spherIC/recurvebowsight/components/FlightCurveChart.java Переглянути файл

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

+ 1
- 1
src/ch/spherIC/recurvebowsight/components/FontEditText.java Переглянути файл

@@ -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;
/**

+ 65
- 0
src/ch/spherIC/recurvebowsight/utilities/CompatibilityUtil.java Переглянути файл

@@ -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() { }
}

src/ch/spherIC/recurvebowsight/PlatformUtils.java → src/ch/spherIC/recurvebowsight/utilities/PlatformUtils.java Переглянути файл

@@ -1,7 +1,7 @@
/**
* Copyright (C) 2005-2012 XELOG AG
*/
package ch.spherIC.recurvebowsight;
package ch.spherIC.recurvebowsight.utilities;
import android.content.Context;

src/ch/spherIC/recurvebowsight/UnitConverter.java → src/ch/spherIC/recurvebowsight/utilities/UnitConverter.java Переглянути файл

@@ -1,7 +1,7 @@
/**
* Copyright (C) 2005-2012 XELOG AG
*/
package ch.spherIC.recurvebowsight;
package ch.spherIC.recurvebowsight.utilities;
import android.app.Application;

Завантаження…
Відмінити
Зберегти