| @@ -148,7 +148,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="0123456789" | |||
| android:textSize="18sp" | |||
| android:typeface="sans" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| @@ -181,7 +180,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -213,7 +211,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -245,7 +242,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -277,7 +273,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -331,7 +326,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -363,7 +357,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -417,7 +410,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -449,7 +441,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -481,7 +472,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -652,8 +642,8 @@ | |||
| android:textColor="@color/black" | |||
| app:font="@string/TitilliumWeb_Regular" /> | |||
| <ch.spherIC.recurvebowsight.components.XSpinner | |||
| android:id="@+id/scRiserTxtFld" | |||
| <ch.spherIC.recurvebowsight.components.RiserSpinner | |||
| android:id="@+id/scRiserSpinner" | |||
| style="@style/GlassSpinner" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="40dp" | |||
| @@ -691,12 +681,8 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textAppearance="?android:attr/textAppearanceMediumInverse" | |||
| app:txtFont="@string/TitilliumWeb_Regular" > | |||
| <requestFocus /> | |||
| </ch.spherIC.recurvebowsight.components.FontEditText> | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| <TableRow | |||
| @@ -726,7 +712,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textAppearance="?android:attr/textAppearanceMediumInverse" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -747,7 +732,7 @@ | |||
| android:textColor="@color/black" | |||
| app:font="@string/TitilliumWeb_Regular" /> | |||
| <ch.spherIC.recurvebowsight.components.XSpinner | |||
| <ch.spherIC.recurvebowsight.components.SightSpinner | |||
| android:id="@+id/scSightSpinner" | |||
| style="@style/GlassSpinner" | |||
| android:layout_width="wrap_content" | |||
| @@ -775,16 +760,32 @@ | |||
| android:textColor="@color/black" | |||
| app:font="@string/TitilliumWeb_Regular" /> | |||
| <ch.spherIC.recurvebowsight.components.XSpinner | |||
| android:id="@+id/scHeVSSpinner" | |||
| style="@style/GlassSpinner" | |||
| android:layout_width="wrap_content" | |||
| <LinearLayout | |||
| android:id="@+id/heVSWrapper" | |||
| android:layout_width="0dp" | |||
| android:layout_height="40dp" | |||
| android:layout_marginLeft="4dp" | |||
| android:layout_weight="1" | |||
| android:gravity="center_vertical" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" /> | |||
| android:layout_weight="1" > | |||
| <ch.spherIC.recurvebowsight.components.XSpinner | |||
| android:id="@+id/scHeVSSpinner" | |||
| style="@style/GlassSpinner" | |||
| android:layout_width="0dp" | |||
| android:layout_height="40dp" | |||
| android:layout_weight="1" | |||
| android:gravity="center_vertical" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" /> | |||
| <ch.spherIC.recurvebowsight.components.FontEditText | |||
| android:id="@+id/scHeVSTxtFld" | |||
| android:layout_width="0dp" | |||
| android:layout_height="40dp" | |||
| android:ems="10" | |||
| android:textSize="18sp" | |||
| android:visibility="invisible" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </LinearLayout> | |||
| </TableRow> | |||
| <TableRow | |||
| @@ -814,7 +815,20 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| <ch.spherIC.recurvebowsight.components.FontEditText | |||
| android:id="@+id/scaHTxtFld" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="40dp" | |||
| android:layout_marginLeft="4dp" | |||
| android:layout_weight="1" | |||
| android:ems="10" | |||
| android:gravity="center_vertical" | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -846,7 +860,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -879,7 +892,6 @@ | |||
| android:inputType="numberDecimal" | |||
| android:paddingBottom="9dp" | |||
| android:paddingTop="9dp" | |||
| android:text="22" | |||
| android:textSize="18sp" | |||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||
| </TableRow> | |||
| @@ -910,7 +922,6 @@ | |||
| android:background="@drawable/evs_ok_background" | |||
| android:gravity="left|center_vertical" | |||
| android:paddingLeft="9dp" | |||
| android:text="22" | |||
| android:textAppearance="?android:attr/textAppearanceMediumInverse" | |||
| app:txtFont="@string/TitilliumWeb_Bold" /> | |||
| </TableRow> | |||
| @@ -10,6 +10,7 @@ | |||
| android:id="@+id/spinner_view" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:ellipsize="end" | |||
| android:gravity="bottom|left" | |||
| android:lines="1" | |||
| android:paddingLeft="2dp" | |||
| @@ -0,0 +1,56 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:app="http://schemas.android.com/apk/res/ch.spherIC.recurvebowsight" | |||
| android:id="@+id/riserLayout" | |||
| android:layout_width="fill_parent" | |||
| android:layout_height="wrap_content" | |||
| android:orientation="vertical" > | |||
| <LinearLayout | |||
| android:layout_width="fill_parent" | |||
| android:layout_height="wrap_content" | |||
| android:gravity="center" | |||
| android:orientation="horizontal" > | |||
| <ch.spherIC.recurvebowsight.components.FontTextView | |||
| android:id="@+id/spinner_view" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:gravity="bottom|left" | |||
| android:lines="1" | |||
| android:paddingLeft="2dp" | |||
| android:text="Riser" | |||
| android:textColor="@color/white" | |||
| android:textSize="18sp" | |||
| android:typeface="sans" | |||
| app:font="@string/TitilliumWeb_Regular" /> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| android:layout_width="fill_parent" | |||
| android:layout_height="wrap_content" | |||
| android:gravity="center" | |||
| android:orientation="horizontal" | |||
| android:padding="8dp" > | |||
| <ch.spherIC.recurvebowsight.components.FontTextView | |||
| android:id="@+id/spinner_item_view" | |||
| android:layout_width="0dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_weight="1" | |||
| android:gravity="bottom|left" | |||
| android:lines="1" | |||
| android:paddingLeft="2dp" | |||
| android:textAppearance="?android:attr/textAppearanceMediumInverse" | |||
| android:textColor="@color/white" | |||
| android:textSize="18sp" | |||
| app:font="@string/TitilliumWeb_Regular" /> | |||
| <ImageView | |||
| android:id="@+id/spinner_item_checkBox" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:src="@drawable/btn_check_on" /> | |||
| </LinearLayout> | |||
| </LinearLayout> | |||
| @@ -1,34 +1,22 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <resources> | |||
| <color | |||
| name="translucent">#00000000</color> | |||
| <color | |||
| name="semi_translucent_black">#80000000</color> | |||
| <color | |||
| name="black">#FF000000</color> | |||
| <color | |||
| name="yellow">#AAFFFFAA</color> | |||
| <color | |||
| name="white">#FFFFFFFF</color> | |||
| <color | |||
| name="android_blue">#FF33B5E5</color> | |||
| <color | |||
| name="android_blue_dark">#FF0099CC</color> | |||
| <color | |||
| name="android_violet">#FFAA66CC</color> | |||
| <color | |||
| name="android_violet_dark">#FF9933CC</color> | |||
| <color | |||
| name="android_green">#FF99CC00</color> | |||
| <color | |||
| name="android_green_dark">#FF669900</color> | |||
| <color | |||
| name="android_yellow">#FFFFBB33</color> | |||
| <color | |||
| name="android_yellow_dark">#FFFF8800</color> | |||
| <color | |||
| name="android_red">#FFFF4444</color> | |||
| <color | |||
| name="android_red_dark">#FFCC0000</color> | |||
| <color name="translucent">#00000000</color> | |||
| <color name="semi_translucent_black">#80000000</color> | |||
| <color name="black">#FF000000</color> | |||
| <color name="yellow">#AAFFFFAA</color> | |||
| <color name="white">#FFFFFFFF</color> | |||
| <color name="gray_lite">#FFC8C8C8</color> | |||
| <color name="gray_dark">#FF7F7F7F</color> | |||
| <color name="android_blue">#FF33B5E5</color> | |||
| <color name="android_blue_dark">#FF0099CC</color> | |||
| <color name="android_violet">#FFAA66CC</color> | |||
| <color name="android_violet_dark">#FF9933CC</color> | |||
| <color name="android_green">#FF99CC00</color> | |||
| <color name="android_green_dark">#FF669900</color> | |||
| <color name="android_yellow">#FFFFBB33</color> | |||
| <color name="android_yellow_dark">#FFFF8800</color> | |||
| <color name="android_red">#FFFF4444</color> | |||
| <color name="android_red_dark">#FFCC0000</color> | |||
| </resources> | |||
| @@ -8,6 +8,7 @@ import android.content.Intent; | |||
| import android.os.Bundle; | |||
| import android.os.Handler; | |||
| import android.view.Gravity; | |||
| import android.view.Menu; | |||
| import android.view.MenuItem; | |||
| import android.view.MotionEvent; | |||
| @@ -16,25 +17,43 @@ import android.view.View; | |||
| import android.view.View.OnTouchListener; | |||
| import android.widget.AdapterView; | |||
| import android.widget.AdapterView.OnItemSelectedListener; | |||
| import android.widget.ArrayAdapter; | |||
| import android.widget.LinearLayout; | |||
| import android.widget.ListView; | |||
| import android.widget.ScrollView; | |||
| import android.widget.TextView; | |||
| import android.widget.ViewFlipper; | |||
| import ch.spherIC.recurvebowsight.components.FontArrayAdapter; | |||
| import ch.spherIC.recurvebowsight.components.RiserSpinner; | |||
| import ch.spherIC.recurvebowsight.components.SightSpinner; | |||
| import ch.spherIC.recurvebowsight.components.XSpinner; | |||
| import ch.spherIC.recurvebowsight.components.XTextView; | |||
| import ch.spherIC.recurvebowsight.database.RBSDatabaseHelper; | |||
| import ch.spherIC.recurvebowsight.database.dao.RiserDao; | |||
| import ch.spherIC.recurvebowsight.database.dao.SightDao; | |||
| import ch.spherIC.recurvebowsight.dialog.ChooseArcherySetupDlg.ChooseArcherySetupDlgDismissListener; | |||
| import ch.spherIC.recurvebowsight.model.IArcherySetup; | |||
| 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 java.text.DecimalFormat; | |||
| import java.util.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| import java.util.StringTokenizer; | |||
| public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDismissListener { | |||
| public static final DecimalFormat DF = new DecimalFormat("0.###"); | |||
| public static final int DLG_CHOOSE_ARCHERYSETUP = 0; | |||
| public static final int DLG_USERGUIDE_PARAMS = 1; | |||
| public static final int DLG_USERGUIDE_SIGHT = 2; | |||
| @@ -64,16 +83,19 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi | |||
| private XSpinner calcTimeIntervalCboBox; | |||
| private XSpinner calcAccuracyCboBox; | |||
| private XSpinner scRiserSpinner; | |||
| private RiserSpinner scRiserSpinner; | |||
| private TextView scVvisHTxtFld; | |||
| private TextView scVvisVTxtFld; | |||
| private XSpinner scSightSpinner; | |||
| private SightSpinner scSightSpinner; | |||
| private XSpinner scHeVSSpinner; | |||
| private TextView scHeVSTxtFld; | |||
| private TextView scaVTxtFld; | |||
| private TextView scaHTxtFld; | |||
| private TextView scVertScaleRngTxtFld; | |||
| private TextView scVertSkalaMiddleTxtFld; | |||
| private TextView scEvSValue; | |||
| private IArcherySetup selectedArcherySetup; | |||
| private Activity riserSightConfigActivity; | |||
| @@ -85,6 +107,7 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi | |||
| super.onCreate(savedInstanceState); | |||
| setContentView(R.layout.rbs_main); | |||
| UnitConverter.setApplication(getApplication()); | |||
| RBSDatabaseHelper.setContext(this); | |||
| RBSDatabaseHelper.getInstance().initializeDB(); | |||
| @@ -100,6 +123,16 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi | |||
| getResources().getStringArray(R.array.CalculationAccuracies), | |||
| this.calcAccuracyCboBox)); | |||
| List<IRiser> risers = RiserDao.getInstance().loadAll(); | |||
| risers.add(0, new Riser(-999, getResources().getString(R.string.caption_NoSelection), "", null, null, null)); | |||
| this.scRiserSpinner.setAdapter(new FontArrayAdapter<IRiser>(this, R.layout.rbs_spinner, risers, this.scRiserSpinner)); | |||
| List<ISight> sights = SightDao.getInstance().loadAll(); | |||
| sights.add(0, new Sight(-999, getResources().getString(R.string.caption_NoSelection), "", null, null, "", null, null)); | |||
| this.scSightSpinner.setAdapter(new FontArrayAdapter<ISight>(this, R.layout.rbs_spinner, sights, this.scSightSpinner)); | |||
| addRiserAndSightSpinnerListeners(); | |||
| // ************************************************************************ | |||
| // ** TEST WEISE AB HIER*************************************************** | |||
| @@ -148,17 +181,108 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi | |||
| this.calcTimeIntervalCboBox = (XSpinner) findViewById(R.id.deltaTimeCboBox); | |||
| this.calcAccuracyCboBox = (XSpinner) findViewById(R.id.calcPrecisionCboBox); | |||
| this.scRiserSpinner = (XSpinner) findViewById(R.id.scRiserTxtFld); | |||
| this.scRiserSpinner = (RiserSpinner) findViewById(R.id.scRiserSpinner); | |||
| this.scVvisHTxtFld = (TextView) findViewById(R.id.scVvisHTxtFld); | |||
| this.scVvisVTxtFld = (TextView) findViewById(R.id.scVvisVTxtFld); | |||
| this.scSightSpinner = (XSpinner) findViewById(R.id.scSightSpinner); | |||
| this.scSightSpinner = (SightSpinner) findViewById(R.id.scSightSpinner); | |||
| this.scHeVSSpinner = (XSpinner) findViewById(R.id.scHeVSSpinner); | |||
| this.scHeVSTxtFld = (TextView) findViewById(R.id.scHeVSTxtFld); | |||
| this.scaVTxtFld = (TextView) findViewById(R.id.scaVTxtFld); | |||
| this.scaHTxtFld = (TextView) findViewById(R.id.scaHTxtFld); | |||
| this.scVertScaleRngTxtFld = (TextView) findViewById(R.id.scVertScaleRngTxtFld); | |||
| this.scVertSkalaMiddleTxtFld = (TextView) findViewById(R.id.scVertSkalaMiddleTxtFld); | |||
| this.scEvSValue = (TextView) findViewById(R.id.scEvSValue); | |||
| } | |||
| private void addRiserAndSightSpinnerListeners() { | |||
| this.scRiserSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { | |||
| @Override | |||
| public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) { | |||
| IRiser riser = RBSMainActivity.this.scRiserSpinner.getSelectedRiser(); | |||
| if (riser.getId() != -999) { | |||
| RBSMainActivity.this.scVvisHTxtFld.setText(DF.format(riser.getVVisH())); | |||
| RBSMainActivity.this.scVvisVTxtFld.setText(DF.format(riser.getVVisV())); | |||
| } else { | |||
| RBSMainActivity.this.scVvisHTxtFld.setText(""); | |||
| RBSMainActivity.this.scVvisVTxtFld.setText(""); | |||
| } | |||
| RBSMainActivity.this.scVvisHTxtFld.setEnabled(riser.getId() == -999); | |||
| RBSMainActivity.this.scVvisVTxtFld.setEnabled(riser.getId() == -999); | |||
| } | |||
| @Override | |||
| public void onNothingSelected(final AdapterView<?> parent) { } | |||
| }); | |||
| this.scSightSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { | |||
| @Override | |||
| public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) { | |||
| ISight sight = RBSMainActivity.this.scSightSpinner.getSelectedSight(); | |||
| if (sight.getId() != -999) { | |||
| List<String> listHeVis = new ArrayList<String>(); | |||
| String heVis = sight.getHeVis(); | |||
| StringTokenizer t = new StringTokenizer(heVis, ","); | |||
| while (t.hasMoreTokens()) { | |||
| listHeVis.add(t.nextToken()); | |||
| } | |||
| RBSMainActivity.this.scHeVSTxtFld.setVisibility(View.INVISIBLE); | |||
| RBSMainActivity.this.scHeVSTxtFld.setLayoutParams(new LinearLayout.LayoutParams(RBSMainActivity.this.scHeVSTxtFld | |||
| .getLayoutParams().width, | |||
| RBSMainActivity.this.scHeVSTxtFld | |||
| .getLayoutParams().height, 0f)); | |||
| RBSMainActivity.this.scHeVSSpinner.setVisibility(View.VISIBLE); | |||
| LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(RBSMainActivity.this.scHeVSSpinner.getLayoutParams().width, | |||
| RBSMainActivity.this.scHeVSSpinner.getLayoutParams().height, | |||
| 1f); | |||
| params.gravity = Gravity.FILL_VERTICAL; | |||
| RBSMainActivity.this.scHeVSSpinner.setLayoutParams(params); | |||
| RBSMainActivity.this.scHeVSSpinner.setAdapter(new FontArrayAdapter<String>(RBSMainActivity.this, R.layout.rbs_spinner, | |||
| listHeVis, RBSMainActivity.this.scHeVSSpinner)); | |||
| RBSMainActivity.this.scHeVSSpinner.setSelection(0); | |||
| if (RBSMainActivity.this.selectedArcherySetup != null | |||
| && RBSMainActivity.this.selectedArcherySetup.getSight().getId() == sight.getId()) { | |||
| RBSMainActivity.this.scHeVSSpinner.setSelectionByVal(DF.format(RBSMainActivity.this.selectedArcherySetup | |||
| .getSightHorSetting())); | |||
| } | |||
| RBSMainActivity.this.scaVTxtFld.setText(DF.format(sight.getAV())); | |||
| RBSMainActivity.this.scaHTxtFld.setText(DF.format(sight.getAH())); | |||
| RBSMainActivity.this.scVertScaleRngTxtFld.setText(DF.format(sight.getVertSkalaRangeMin()) + "-" | |||
| + DF.format(sight.getVertSkalaRangeMax())); | |||
| } else { | |||
| RBSMainActivity.this.scHeVSSpinner.setVisibility(View.INVISIBLE); | |||
| RBSMainActivity.this.scHeVSSpinner.setLayoutParams(new LinearLayout.LayoutParams(RBSMainActivity.this.scHeVSSpinner | |||
| .getLayoutParams().width, | |||
| RBSMainActivity.this.scHeVSSpinner | |||
| .getLayoutParams().height, 0f)); | |||
| RBSMainActivity.this.scHeVSTxtFld.setVisibility(View.VISIBLE); | |||
| RBSMainActivity.this.scHeVSTxtFld.setLayoutParams(new LinearLayout.LayoutParams(RBSMainActivity.this.scHeVSTxtFld | |||
| .getLayoutParams().width, | |||
| RBSMainActivity.this.scHeVSTxtFld | |||
| .getLayoutParams().height, 1f)); | |||
| RBSMainActivity.this.scHeVSSpinner.setAdapter(new FontArrayAdapter<String>(RBSMainActivity.this, R.layout.rbs_spinner, | |||
| new ArrayList<String>(), | |||
| RBSMainActivity.this.scHeVSSpinner)); | |||
| RBSMainActivity.this.scaVTxtFld.setText(""); | |||
| RBSMainActivity.this.scaHTxtFld.setText(""); | |||
| RBSMainActivity.this.scVertScaleRngTxtFld.setText(""); | |||
| } | |||
| RBSMainActivity.this.scaVTxtFld.setEnabled(sight.getId() == -999); | |||
| RBSMainActivity.this.scaHTxtFld.setEnabled(sight.getId() == -999); | |||
| RBSMainActivity.this.scVertScaleRngTxtFld.setEnabled(sight.getId() == -999); | |||
| } | |||
| @Override | |||
| public void onNothingSelected(final AdapterView<?> parent) { } | |||
| }); | |||
| } | |||
| private void addTouchListeners() { | |||
| // Scrollview muss den Swipe selbst handeln | |||
| @@ -443,6 +567,7 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi | |||
| @Override | |||
| public void onArcherySetupDlgDismissed(final IArcherySetup archerySetup) { | |||
| this.selectedArcherySetup = archerySetup; | |||
| if (archerySetup != null) { | |||
| if (archerySetup.getId() != -999) { | |||
| this.arrowDiameterTxtFld.setText(archerySetup.getArrowDiameter().toString()); | |||
| @@ -454,14 +579,23 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi | |||
| this.targetCenterHeightTxtFld.setText(archerySetup.getArrowCenterHeight().toString()); | |||
| this.calcTimeIntervalCboBox.setSelectionByVal(archerySetup.getDeltaTime().toString()); | |||
| this.calcAccuracyCboBox.setSelectionByVal(archerySetup.getCalcPrecision().toString()); | |||
| // this.scRiserSpinner.setSelection(archerySetup.getRiser()); | |||
| // this.scSightSpinner.setSelection(archerySetup.getSight()); | |||
| // this.scHeVSSpinner.setSelection(archerySetup.getSightHorSetting()); | |||
| this.scRiserSpinner.setSelectedRiser(archerySetup.getRiser()); | |||
| this.scSightSpinner.setSelectedSight(archerySetup.getSight()); | |||
| this.scVertSkalaMiddleTxtFld.setText(archerySetup.getSightVertSkalaMiddle().toString()); | |||
| } else { | |||
| this.arrowDiameterTxtFld.setText(""); | |||
| this.arrowDiameterTxtFld.setText(""); | |||
| this.arrowCwTxtFld.setText(""); | |||
| this.arrowWeightTxtFld.setText(""); | |||
| this.bowPulloutTxtFld.setText(""); | |||
| this.arrowV0TxtFld.setText(""); | |||
| this.arrowNockHeightTxtFld.setText(""); | |||
| this.targetCenterHeightTxtFld.setText(""); | |||
| this.calcTimeIntervalCboBox.setSelectionByVal(""); | |||
| this.calcAccuracyCboBox.setSelectionByVal(""); | |||
| this.scRiserSpinner.setSelection(0); | |||
| this.scSightSpinner.setSelection(0); | |||
| this.scVertSkalaMiddleTxtFld.setText(""); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,76 @@ | |||
| /** | |||
| * Copyright (C) 2005-2012 XELOG AG | |||
| */ | |||
| package ch.spherIC.recurvebowsight; | |||
| import android.app.Application; | |||
| import android.util.DisplayMetrics; | |||
| /** | |||
| * @author FC Smilari | |||
| */ | |||
| public class UnitConverter { | |||
| public static Application app; | |||
| public static void setApplication(final Application application) { | |||
| app = application; | |||
| } | |||
| /** | |||
| * Convert dp to pixels in horizontal direction. | |||
| * | |||
| * @param dp | |||
| * | |||
| * @return Pixels | |||
| */ | |||
| public static int dpToPxH(final int dp) { | |||
| DisplayMetrics displayMetrics = app.getApplicationContext().getResources().getDisplayMetrics(); | |||
| int px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); | |||
| return px; | |||
| } | |||
| /** | |||
| * Convert pixel to dp in horizontal direction. | |||
| * | |||
| * @param px Pixels | |||
| * | |||
| * @return Dp | |||
| */ | |||
| public static int pxToDpH(final int px) { | |||
| DisplayMetrics displayMetrics = app.getApplicationContext().getResources().getDisplayMetrics(); | |||
| int dp = Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); | |||
| return dp; | |||
| } | |||
| /** | |||
| * Convert dp to pixels in vertical direction. | |||
| * | |||
| * @param dp | |||
| * | |||
| * @return Pixels | |||
| */ | |||
| public static int dpToPxV(final int dp) { | |||
| DisplayMetrics displayMetrics = app.getApplicationContext().getResources().getDisplayMetrics(); | |||
| int px = Math.round(dp * (displayMetrics.ydpi / DisplayMetrics.DENSITY_DEFAULT)); | |||
| return px; | |||
| } | |||
| /** | |||
| * Convert pixel to dp in vertical direction. | |||
| * | |||
| * @param px Pixels | |||
| * | |||
| * @return Dp | |||
| */ | |||
| public static int pxToDpV(final int px) { | |||
| DisplayMetrics displayMetrics = app.getApplicationContext().getResources().getDisplayMetrics(); | |||
| int dp = Math.round(px / (displayMetrics.ydpi / DisplayMetrics.DENSITY_DEFAULT)); | |||
| return dp; | |||
| } | |||
| } | |||
| @@ -16,6 +16,8 @@ import android.widget.TextView; | |||
| import ch.spherIC.recurvebowsight.R; | |||
| import java.util.List; | |||
| /** | |||
| * @author FC Smilari | |||
| @@ -35,6 +37,17 @@ public class FontArrayAdapter<O extends Object> extends ArrayAdapter<O> { | |||
| this.parentSpinner = parent; | |||
| } | |||
| /** | |||
| * @param context | |||
| * @param textViewResourceId | |||
| * @param objects | |||
| */ | |||
| public FontArrayAdapter(final Context context, final int textViewResourceId, final List<O> objects, | |||
| final Spinner parent) { | |||
| super(context, textViewResourceId, objects); | |||
| this.parentSpinner = parent; | |||
| } | |||
| @Override | |||
| public View getView(final int position, final View convertView, final ViewGroup parent) { | |||
| @@ -15,6 +15,7 @@ import android.util.Log; | |||
| import android.widget.EditText; | |||
| import ch.spherIC.recurvebowsight.R; | |||
| import ch.spherIC.recurvebowsight.UnitConverter; | |||
| /** | |||
| @@ -28,6 +29,7 @@ public class FontEditText extends EditText { | |||
| public FontEditText(final Context context) { | |||
| super(context); | |||
| setTextColor(getResources().getColor(R.color.black)); | |||
| } | |||
| public FontEditText(final Context context, final AttributeSet attrs) { | |||
| @@ -49,6 +51,7 @@ public class FontEditText extends EditText { | |||
| } | |||
| a.recycle(); | |||
| } | |||
| setTextColor(getResources().getColor(R.color.black)); | |||
| } | |||
| public boolean setFont(final Context ctx, final String font) { | |||
| @@ -64,5 +67,18 @@ public class FontEditText extends EditText { | |||
| return true; | |||
| } | |||
| @Override | |||
| public void setEnabled(final boolean enabled) { | |||
| super.setEnabled(enabled); | |||
| if (enabled) { | |||
| setBackgroundDrawable(getResources().getDrawable(android.R.drawable.edit_text)); | |||
| setTextColor(getResources().getColor(R.color.black)); | |||
| } else { | |||
| setBackgroundDrawable(getResources().getDrawable(android.R.drawable.editbox_dropdown_light_frame)); | |||
| getBackground().setAlpha(255); | |||
| setTextColor(getResources().getColor(R.color.gray_lite)); | |||
| setPadding(UnitConverter.dpToPxH(8), getPaddingTop(), getPaddingRight(), getPaddingBottom()); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,65 @@ | |||
| /** | |||
| * Copyright (C) 2005-2012 XELOG AG | |||
| */ | |||
| package ch.spherIC.recurvebowsight.components; | |||
| import android.content.Context; | |||
| import android.util.AttributeSet; | |||
| import ch.spherIC.recurvebowsight.model.IRiser; | |||
| /** | |||
| * @author FC Smilari | |||
| */ | |||
| public class RiserSpinner extends XSpinner { | |||
| /** | |||
| * @param context | |||
| */ | |||
| public RiserSpinner(final Context context) { | |||
| super(context); | |||
| } | |||
| /** | |||
| * @param context | |||
| * @param attrs | |||
| */ | |||
| public RiserSpinner(final Context context, final AttributeSet attrs) { | |||
| super(context, attrs); | |||
| } | |||
| /** | |||
| * @param context | |||
| * @param attrs | |||
| * @param defStyle | |||
| */ | |||
| public RiserSpinner(final Context context, final AttributeSet attrs, final int defStyle) { | |||
| super(context, attrs, defStyle); | |||
| } | |||
| /** | |||
| * Retrieves selected riser item. | |||
| * | |||
| * @return Retrieves selected {@link IRiser} item | |||
| */ | |||
| public IRiser getSelectedRiser() { | |||
| return (IRiser) getSelectedItem(); | |||
| } | |||
| /** | |||
| * Set the passed in {@link IRiser} as the selected riser item. | |||
| */ | |||
| public void setSelectedRiser(final IRiser riser) { | |||
| for (int i = 0; i < getCount(); i++) { | |||
| if (((IRiser) getItemAtPosition(i)).getId() == riser.getId()) { | |||
| setSelection(i); | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,65 @@ | |||
| /** | |||
| * Copyright (C) 2005-2012 XELOG AG | |||
| */ | |||
| package ch.spherIC.recurvebowsight.components; | |||
| import android.content.Context; | |||
| import android.util.AttributeSet; | |||
| import ch.spherIC.recurvebowsight.model.ISight; | |||
| /** | |||
| * @author FC Smilari | |||
| */ | |||
| public class SightSpinner extends XSpinner { | |||
| /** | |||
| * @param context | |||
| */ | |||
| public SightSpinner(final Context context) { | |||
| super(context); | |||
| } | |||
| /** | |||
| * @param context | |||
| * @param attrs | |||
| */ | |||
| public SightSpinner(final Context context, final AttributeSet attrs) { | |||
| super(context, attrs); | |||
| } | |||
| /** | |||
| * @param context | |||
| * @param attrs | |||
| * @param defStyle | |||
| */ | |||
| public SightSpinner(final Context context, final AttributeSet attrs, final int defStyle) { | |||
| super(context, attrs, defStyle); | |||
| } | |||
| /** | |||
| * Retrieves selected sight item. | |||
| * | |||
| * @return Retrieves selected {@link ISight} item | |||
| */ | |||
| public ISight getSelectedSight() { | |||
| return (ISight) getSelectedItem(); | |||
| } | |||
| /** | |||
| * Set the passed in {@link ISight} as the selected sight item. | |||
| */ | |||
| public void setSelectedSight(final ISight sight) { | |||
| for (int i = 0; i < getCount(); i++) { | |||
| if (((ISight) getItemAtPosition(i)).getId() == sight.getId()) { | |||
| setSelection(i); | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -138,8 +138,7 @@ public final class RBSDatabaseHelper extends SQLiteOpenHelper { | |||
| List<ISight> sights = new ArrayList<ISight>(); | |||
| sights.add(new Sight(0, "Avalon", "Tec One", 17.5, 12d, | |||
| "260,250,240,230,220,210,200,190,180,170,160", 0d, 110d)); | |||
| sights.add(new Sight(0, "Avalon", "Tec One", 17.5, -12d, "260,250,240,230,220,210,200,190,180,170,160", 0d, 110d)); | |||
| return sights; | |||
| } | |||
| @@ -3,11 +3,16 @@ | |||
| */ | |||
| package ch.spherIC.recurvebowsight.model; | |||
| import java.text.DecimalFormat; | |||
| /** | |||
| * @author FC Smilari | |||
| */ | |||
| public class Riser implements IRiser { | |||
| private static final DecimalFormat DF = new DecimalFormat("0.###"); | |||
| private long id; | |||
| private String manufacturer; | |||
| private String model; | |||
| @@ -131,4 +136,14 @@ public class Riser implements IRiser { | |||
| public void setVVisV(final Double vVisV) { | |||
| this.vVisV = vVisV; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| if (this.id == -999) { | |||
| return getManufacturer(); | |||
| } | |||
| return getManufacturer() + " ● " + getModel() + " ● " + DF.format(getSize()) + "\""; | |||
| } | |||
| } | |||
| @@ -13,7 +13,6 @@ import java.util.StringTokenizer; | |||
| */ | |||
| public class Sight implements ISight { | |||
| private long id; | |||
| private String manufacturer; | |||
| private String model; | |||
| @@ -167,4 +166,14 @@ public class Sight implements ISight { | |||
| return list; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| if (this.id == -999) { | |||
| return getManufacturer(); | |||
| } | |||
| return getManufacturer() + " ● " + getModel(); | |||
| } | |||
| } | |||