| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="0123456789" | |||||
| android:textSize="18sp" | android:textSize="18sp" | ||||
| android:typeface="sans" | android:typeface="sans" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textSize="18sp" | android:textSize="18sp" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textSize="18sp" | android:textSize="18sp" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textSize="18sp" | android:textSize="18sp" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textSize="18sp" | android:textSize="18sp" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textSize="18sp" | android:textSize="18sp" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textSize="18sp" | android:textSize="18sp" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textSize="18sp" | android:textSize="18sp" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textSize="18sp" | android:textSize="18sp" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textSize="18sp" | android:textSize="18sp" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:textColor="@color/black" | android:textColor="@color/black" | ||||
| app:font="@string/TitilliumWeb_Regular" /> | 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" | style="@style/GlassSpinner" | ||||
| android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
| android:layout_height="40dp" | android:layout_height="40dp" | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textAppearance="?android:attr/textAppearanceMediumInverse" | android:textAppearance="?android:attr/textAppearanceMediumInverse" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" > | |||||
| <requestFocus /> | |||||
| </ch.spherIC.recurvebowsight.components.FontEditText> | |||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | |||||
| </TableRow> | </TableRow> | ||||
| <TableRow | <TableRow | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textAppearance="?android:attr/textAppearanceMediumInverse" | android:textAppearance="?android:attr/textAppearanceMediumInverse" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:textColor="@color/black" | android:textColor="@color/black" | ||||
| app:font="@string/TitilliumWeb_Regular" /> | app:font="@string/TitilliumWeb_Regular" /> | ||||
| <ch.spherIC.recurvebowsight.components.XSpinner | |||||
| <ch.spherIC.recurvebowsight.components.SightSpinner | |||||
| android:id="@+id/scSightSpinner" | android:id="@+id/scSightSpinner" | ||||
| style="@style/GlassSpinner" | style="@style/GlassSpinner" | ||||
| android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
| android:textColor="@color/black" | android:textColor="@color/black" | ||||
| app:font="@string/TitilliumWeb_Regular" /> | 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_height="40dp" | ||||
| android:layout_marginLeft="4dp" | 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> | ||||
| <TableRow | <TableRow | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="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" | android:textSize="18sp" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textSize="18sp" | android:textSize="18sp" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:inputType="numberDecimal" | android:inputType="numberDecimal" | ||||
| android:paddingBottom="9dp" | android:paddingBottom="9dp" | ||||
| android:paddingTop="9dp" | android:paddingTop="9dp" | ||||
| android:text="22" | |||||
| android:textSize="18sp" | android:textSize="18sp" | ||||
| app:txtFont="@string/TitilliumWeb_Regular" /> | app:txtFont="@string/TitilliumWeb_Regular" /> | ||||
| </TableRow> | </TableRow> | ||||
| android:background="@drawable/evs_ok_background" | android:background="@drawable/evs_ok_background" | ||||
| android:gravity="left|center_vertical" | android:gravity="left|center_vertical" | ||||
| android:paddingLeft="9dp" | android:paddingLeft="9dp" | ||||
| android:text="22" | |||||
| android:textAppearance="?android:attr/textAppearanceMediumInverse" | android:textAppearance="?android:attr/textAppearanceMediumInverse" | ||||
| app:txtFont="@string/TitilliumWeb_Bold" /> | app:txtFont="@string/TitilliumWeb_Bold" /> | ||||
| </TableRow> | </TableRow> |
| android:id="@+id/spinner_view" | android:id="@+id/spinner_view" | ||||
| android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:ellipsize="end" | |||||
| android:gravity="bottom|left" | android:gravity="bottom|left" | ||||
| android:lines="1" | android:lines="1" | ||||
| android:paddingLeft="2dp" | android:paddingLeft="2dp" |
| <?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> |
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||
| <resources> | <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> | </resources> |
| import android.os.Bundle; | import android.os.Bundle; | ||||
| import android.os.Handler; | import android.os.Handler; | ||||
| import android.view.Gravity; | |||||
| import android.view.Menu; | import android.view.Menu; | ||||
| import android.view.MenuItem; | import android.view.MenuItem; | ||||
| import android.view.MotionEvent; | import android.view.MotionEvent; | ||||
| import android.view.View.OnTouchListener; | import android.view.View.OnTouchListener; | ||||
| import android.widget.AdapterView; | import android.widget.AdapterView; | ||||
| import android.widget.AdapterView.OnItemSelectedListener; | |||||
| import android.widget.ArrayAdapter; | import android.widget.ArrayAdapter; | ||||
| import android.widget.LinearLayout; | |||||
| import android.widget.ListView; | import android.widget.ListView; | ||||
| import android.widget.ScrollView; | import android.widget.ScrollView; | ||||
| import android.widget.TextView; | import android.widget.TextView; | ||||
| import android.widget.ViewFlipper; | import android.widget.ViewFlipper; | ||||
| import ch.spherIC.recurvebowsight.components.FontArrayAdapter; | 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.XSpinner; | ||||
| import ch.spherIC.recurvebowsight.components.XTextView; | import ch.spherIC.recurvebowsight.components.XTextView; | ||||
| import ch.spherIC.recurvebowsight.database.RBSDatabaseHelper; | 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.dialog.ChooseArcherySetupDlg.ChooseArcherySetupDlgDismissListener; | ||||
| import ch.spherIC.recurvebowsight.model.IArcherySetup; | 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.ArrayList; | ||||
| import java.util.Arrays; | import java.util.Arrays; | ||||
| import java.util.List; | |||||
| import java.util.StringTokenizer; | |||||
| public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDismissListener { | 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_CHOOSE_ARCHERYSETUP = 0; | ||||
| public static final int DLG_USERGUIDE_PARAMS = 1; | public static final int DLG_USERGUIDE_PARAMS = 1; | ||||
| public static final int DLG_USERGUIDE_SIGHT = 2; | public static final int DLG_USERGUIDE_SIGHT = 2; | ||||
| private XSpinner calcTimeIntervalCboBox; | private XSpinner calcTimeIntervalCboBox; | ||||
| private XSpinner calcAccuracyCboBox; | private XSpinner calcAccuracyCboBox; | ||||
| private XSpinner scRiserSpinner; | |||||
| private RiserSpinner scRiserSpinner; | |||||
| private TextView scVvisHTxtFld; | private TextView scVvisHTxtFld; | ||||
| private TextView scVvisVTxtFld; | private TextView scVvisVTxtFld; | ||||
| private XSpinner scSightSpinner; | |||||
| private SightSpinner scSightSpinner; | |||||
| private XSpinner scHeVSSpinner; | private XSpinner scHeVSSpinner; | ||||
| private TextView scHeVSTxtFld; | |||||
| private TextView scaVTxtFld; | private TextView scaVTxtFld; | ||||
| private TextView scaHTxtFld; | |||||
| private TextView scVertScaleRngTxtFld; | private TextView scVertScaleRngTxtFld; | ||||
| private TextView scVertSkalaMiddleTxtFld; | private TextView scVertSkalaMiddleTxtFld; | ||||
| private TextView scEvSValue; | private TextView scEvSValue; | ||||
| private IArcherySetup selectedArcherySetup; | |||||
| private Activity riserSightConfigActivity; | private Activity riserSightConfigActivity; | ||||
| super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
| setContentView(R.layout.rbs_main); | setContentView(R.layout.rbs_main); | ||||
| UnitConverter.setApplication(getApplication()); | |||||
| RBSDatabaseHelper.setContext(this); | RBSDatabaseHelper.setContext(this); | ||||
| RBSDatabaseHelper.getInstance().initializeDB(); | RBSDatabaseHelper.getInstance().initializeDB(); | ||||
| getResources().getStringArray(R.array.CalculationAccuracies), | getResources().getStringArray(R.array.CalculationAccuracies), | ||||
| this.calcAccuracyCboBox)); | 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*************************************************** | // ** TEST WEISE AB HIER*************************************************** | ||||
| this.calcTimeIntervalCboBox = (XSpinner) findViewById(R.id.deltaTimeCboBox); | this.calcTimeIntervalCboBox = (XSpinner) findViewById(R.id.deltaTimeCboBox); | ||||
| this.calcAccuracyCboBox = (XSpinner) findViewById(R.id.calcPrecisionCboBox); | 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.scVvisHTxtFld = (TextView) findViewById(R.id.scVvisHTxtFld); | ||||
| this.scVvisVTxtFld = (TextView) findViewById(R.id.scVvisVTxtFld); | 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.scHeVSSpinner = (XSpinner) findViewById(R.id.scHeVSSpinner); | ||||
| this.scHeVSTxtFld = (TextView) findViewById(R.id.scHeVSTxtFld); | |||||
| this.scaVTxtFld = (TextView) findViewById(R.id.scaVTxtFld); | this.scaVTxtFld = (TextView) findViewById(R.id.scaVTxtFld); | ||||
| this.scaHTxtFld = (TextView) findViewById(R.id.scaHTxtFld); | |||||
| this.scVertScaleRngTxtFld = (TextView) findViewById(R.id.scVertScaleRngTxtFld); | this.scVertScaleRngTxtFld = (TextView) findViewById(R.id.scVertScaleRngTxtFld); | ||||
| this.scVertSkalaMiddleTxtFld = (TextView) findViewById(R.id.scVertSkalaMiddleTxtFld); | this.scVertSkalaMiddleTxtFld = (TextView) findViewById(R.id.scVertSkalaMiddleTxtFld); | ||||
| this.scEvSValue = (TextView) findViewById(R.id.scEvSValue); | 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() { | private void addTouchListeners() { | ||||
| // Scrollview muss den Swipe selbst handeln | // Scrollview muss den Swipe selbst handeln | ||||
| @Override | @Override | ||||
| public void onArcherySetupDlgDismissed(final IArcherySetup archerySetup) { | public void onArcherySetupDlgDismissed(final IArcherySetup archerySetup) { | ||||
| this.selectedArcherySetup = archerySetup; | |||||
| if (archerySetup != null) { | if (archerySetup != null) { | ||||
| if (archerySetup.getId() != -999) { | if (archerySetup.getId() != -999) { | ||||
| this.arrowDiameterTxtFld.setText(archerySetup.getArrowDiameter().toString()); | this.arrowDiameterTxtFld.setText(archerySetup.getArrowDiameter().toString()); | ||||
| this.targetCenterHeightTxtFld.setText(archerySetup.getArrowCenterHeight().toString()); | this.targetCenterHeightTxtFld.setText(archerySetup.getArrowCenterHeight().toString()); | ||||
| this.calcTimeIntervalCboBox.setSelectionByVal(archerySetup.getDeltaTime().toString()); | this.calcTimeIntervalCboBox.setSelectionByVal(archerySetup.getDeltaTime().toString()); | ||||
| this.calcAccuracyCboBox.setSelectionByVal(archerySetup.getCalcPrecision().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()); | this.scVertSkalaMiddleTxtFld.setText(archerySetup.getSightVertSkalaMiddle().toString()); | ||||
| } else { | } else { | ||||
| this.arrowDiameterTxtFld.setText(""); | 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(""); | |||||
| } | } | ||||
| } | } | ||||
| } | } |
| /** | |||||
| * 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; | |||||
| } | |||||
| } |
| import ch.spherIC.recurvebowsight.R; | import ch.spherIC.recurvebowsight.R; | ||||
| import java.util.List; | |||||
| /** | /** | ||||
| * @author FC Smilari | * @author FC Smilari | ||||
| this.parentSpinner = parent; | 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 | @Override | ||||
| public View getView(final int position, final View convertView, final ViewGroup parent) { | public View getView(final int position, final View convertView, final ViewGroup parent) { | ||||
| import android.widget.EditText; | import android.widget.EditText; | ||||
| import ch.spherIC.recurvebowsight.R; | import ch.spherIC.recurvebowsight.R; | ||||
| import ch.spherIC.recurvebowsight.UnitConverter; | |||||
| /** | /** | ||||
| public FontEditText(final Context context) { | public FontEditText(final Context context) { | ||||
| super(context); | super(context); | ||||
| setTextColor(getResources().getColor(R.color.black)); | |||||
| } | } | ||||
| public FontEditText(final Context context, final AttributeSet attrs) { | public FontEditText(final Context context, final AttributeSet attrs) { | ||||
| } | } | ||||
| a.recycle(); | a.recycle(); | ||||
| } | } | ||||
| setTextColor(getResources().getColor(R.color.black)); | |||||
| } | } | ||||
| public boolean setFont(final Context ctx, final String font) { | public boolean setFont(final Context ctx, final String font) { | ||||
| return true; | 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()); | |||||
| } | |||||
| } | |||||
| } | } |
| /** | |||||
| * 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; | |||||
| } | |||||
| } | |||||
| } | |||||
| } |
| /** | |||||
| * 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; | |||||
| } | |||||
| } | |||||
| } | |||||
| } |
| List<ISight> sights = new ArrayList<ISight>(); | 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; | return sights; | ||||
| } | } |
| */ | */ | ||||
| package ch.spherIC.recurvebowsight.model; | package ch.spherIC.recurvebowsight.model; | ||||
| import java.text.DecimalFormat; | |||||
| /** | /** | ||||
| * @author FC Smilari | * @author FC Smilari | ||||
| */ | */ | ||||
| public class Riser implements IRiser { | public class Riser implements IRiser { | ||||
| private static final DecimalFormat DF = new DecimalFormat("0.###"); | |||||
| private long id; | private long id; | ||||
| private String manufacturer; | private String manufacturer; | ||||
| private String model; | private String model; | ||||
| public void setVVisV(final Double vVisV) { | public void setVVisV(final Double vVisV) { | ||||
| this.vVisV = vVisV; | this.vVisV = vVisV; | ||||
| } | } | ||||
| @Override | |||||
| public String toString() { | |||||
| if (this.id == -999) { | |||||
| return getManufacturer(); | |||||
| } | |||||
| return getManufacturer() + " ● " + getModel() + " ● " + DF.format(getSize()) + "\""; | |||||
| } | |||||
| } | } |
| */ | */ | ||||
| public class Sight implements ISight { | public class Sight implements ISight { | ||||
| private long id; | private long id; | ||||
| private String manufacturer; | private String manufacturer; | ||||
| private String model; | private String model; | ||||
| return list; | return list; | ||||
| } | } | ||||
| @Override | |||||
| public String toString() { | |||||
| if (this.id == -999) { | |||||
| return getManufacturer(); | |||||
| } | |||||
| return getManufacturer() + " ● " + getModel(); | |||||
| } | |||||
| } | } |