| <?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:layout_width="fill_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:gravity="center" | |||||
| android:orientation="horizontal" | |||||
| android:padding="8dp" > | |||||
| <ch.spherIC.recurvebowsight.components.XImageView | |||||
| android:id="@+id/xImageView1" | |||||
| android:layout_width="50dp" | |||||
| android:layout_height="50dp" | |||||
| android:layout_marginRight="10dp" | |||||
| android:background="@drawable/glassbg_black" | |||||
| android:src="@drawable/ic_menu_choose_equipment" | |||||
| app:drawBorder="true" | |||||
| app:drawBorderColor="@color/android_blue_dark" | |||||
| app:drawBorderWidth="3dp"/> | |||||
| <LinearLayout | |||||
| android:id="@+id/chooseArcherySetupTxt" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:orientation="vertical" > | |||||
| <ch.spherIC.recurvebowsight.components.FontTextView | |||||
| android:id="@+id/chooseArcherySetupTxtMain" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:gravity="bottom|left" | |||||
| android:lines="1" | |||||
| android:paddingLeft="2dp" | |||||
| android:text="Hoyt / Avalon" | |||||
| android:textAppearance="?android:attr/textAppearanceMediumInverse" | |||||
| android:textColor="@color/android_blue_dark" | |||||
| android:textSize="18sp" | |||||
| app:font="@string/TitilliumWeb_Bold" /> | |||||
| <ch.spherIC.recurvebowsight.components.FontTextView | |||||
| android:id="@+id/chooseArcherySetupTxtSub" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:gravity="bottom|left" | |||||
| android:lines="1" | |||||
| android:paddingLeft="2dp" | |||||
| android:text="Hoyt / Avalon" | |||||
| android:textAppearance="?android:attr/textAppearanceSmallInverse" | |||||
| android:textColor="@color/black" | |||||
| app:font="@string/TitilliumWeb_Regular" /> | |||||
| </LinearLayout> | |||||
| </LinearLayout> |
| <RelativeLayout xmlns:tools="http://schemas.android.com/tools" | |||||
| xmlns:android="http://schemas.android.com/apk/res/android" | |||||
| android:id="@+id/chooseConfiguration" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:gravity="center" > | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
| android:id="@+id/chooseArcherySetupLayout" | |||||
| android:layout_width="fill_parent" | |||||
| android:layout_height="fill_parent" | |||||
| android:background="@drawable/bg_about" | |||||
| android:orientation="vertical" | |||||
| android:padding="10dp" > | |||||
| <ListView | <ListView | ||||
| android:id="@+id/chooseArcerySetupListView" | |||||
| android:id="@+id/chooseArcerySetupItemsList" | |||||
| android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
| android:layout_height="wrap_content" | |||||
| android:background="@drawable/bg" > | |||||
| android:layout_height="250dp" | |||||
| android:divider="@drawable/gradient_view" | |||||
| android:dividerHeight="2dp" > | |||||
| </ListView> | </ListView> | ||||
| </RelativeLayout> | |||||
| </LinearLayout> |
| <!-- --> | <!-- --> | ||||
| <string name="caption_Ok">OK</string> | <string name="caption_Ok">OK</string> | ||||
| <string name="caption_Cancel">Abbrechen</string> | <string name="caption_Cancel">Abbrechen</string> | ||||
| <string name="caption_NoSelection">Keine Auswahl…</string> | |||||
| </resources> | </resources> |
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||
| <resources> | <resources> | ||||
| <declare-styleable | |||||
| name="XTextView"> | |||||
| <declare-styleable name="XTextView"> | |||||
| <attr name="drawBorder" format="boolean" /> | |||||
| <attr name="drawBorderWidth" format="dimension" /> | |||||
| <attr name="drawBorderColor" format="color" /> | |||||
| </declare-styleable> | |||||
| <attr | |||||
| name="drawBorder" | |||||
| format="boolean" /> | |||||
| <attr | |||||
| name="drawBorderWidth" | |||||
| format="dimension" /> | |||||
| <attr | |||||
| name="drawBorderColor" | |||||
| format="color" /> | |||||
| </declare-styleable> | |||||
| <declare-styleable | |||||
| name="FontTextView"> | |||||
| <attr | |||||
| name="font" | |||||
| format="string" /> | |||||
| </declare-styleable> | |||||
| <declare-styleable name="XImageView"> | |||||
| <attr name="drawImgBorder" format="boolean" /> | |||||
| <attr name="drawImgBorderWidth" format="dimension" /> | |||||
| <attr name="drawImgBorderColor" format="color" /> | |||||
| </declare-styleable> | |||||
| <declare-styleable name="FontTextView"> | |||||
| <attr name="font" format="string" /> | |||||
| </declare-styleable> | |||||
| <declare-styleable name="FontEditText"> | |||||
| <attr name="txtFont" format="string" /> | |||||
| </declare-styleable> | |||||
| <declare-styleable name="FontButton"> | |||||
| <attr name="btnFont" format="string" /> | |||||
| </declare-styleable> | |||||
| <declare-styleable | |||||
| name="FontEditText"> | |||||
| <attr | |||||
| name="txtFont" | |||||
| format="string" /> | |||||
| </declare-styleable> | |||||
| <declare-styleable | |||||
| name="FontButton"> | |||||
| <attr | |||||
| name="btnFont" | |||||
| format="string" /> | |||||
| </declare-styleable> | |||||
| <declare-styleable | |||||
| name="FontSpinner"> | |||||
| <attr | |||||
| name="spinnerFont" | |||||
| format="string" /> | |||||
| </declare-styleable> | |||||
| <declare-styleable name="FontSpinner"> | |||||
| <attr name="spinnerFont" format="string" /> | |||||
| </declare-styleable> | |||||
| </resources> | </resources> |
| <!-- --> | <!-- --> | ||||
| <string name="caption_Ok">OK</string> | <string name="caption_Ok">OK</string> | ||||
| <string name="caption_Cancel">Cancel</string> | <string name="caption_Cancel">Cancel</string> | ||||
| <string name="caption_NoSelection">No selection…</string> | |||||
| </resources> | </resources> |
| package ch.spherIC.recurvebowsight; | package ch.spherIC.recurvebowsight; | ||||
| import android.app.Activity; | import android.app.Activity; | ||||
| import android.app.AlertDialog; | |||||
| import android.app.Dialog; | import android.app.Dialog; | ||||
| import android.content.DialogInterface; | |||||
| import android.content.DialogInterface.OnClickListener; | |||||
| import ch.spherIC.recurvebowsight.components.FontArrayAdapter; | |||||
| import ch.spherIC.recurvebowsight.dialog.ChooseArcherySetupDlg; | |||||
| /** | /** | ||||
| * | * | ||||
| * @return Instantiated dialog. | * @return Instantiated dialog. | ||||
| */ | */ | ||||
| public static Dialog createDialog(int dlgCode, Activity parent) { | |||||
| public static Dialog createDialog(final int dlgCode, final Activity parent) { | |||||
| Dialog dlg; | Dialog dlg; | ||||
| return dlg; | return dlg; | ||||
| } | } | ||||
| private static Dialog createChooseArcherySetupDialog(Activity parent) { | |||||
| AlertDialog.Builder builder = new AlertDialog.Builder(parent); | |||||
| builder.setTitle(R.string.menuChooseEquipment); | |||||
| builder.setView(parent.getLayoutInflater().inflate(R.layout.rbs_choose_archerysetup_dlg, null)); | |||||
| builder.setAdapter(new FontArrayAdapter<String>(parent, R.layout.rbs_spinner, | |||||
| parent.getResources().getStringArray(R.array.CalculationTimeIntervals), | |||||
| null), new OnClickListener() { | |||||
| @Override | |||||
| public void onClick(DialogInterface dialog, int which) { } | |||||
| }); | |||||
| builder.setPositiveButton(R.string.caption_Ok, new DialogInterface.OnClickListener() { | |||||
| @Override | |||||
| public void onClick(DialogInterface dialog, int id) { | |||||
| dialog.dismiss(); | |||||
| } | |||||
| }); | |||||
| builder.setNegativeButton(R.string.caption_Cancel, new DialogInterface.OnClickListener() { | |||||
| @Override | |||||
| public void onClick(DialogInterface dialog, int id) { | |||||
| dialog.dismiss(); | |||||
| } | |||||
| }); | |||||
| // Create the AlertDialog object and return it | |||||
| return builder.create(); | |||||
| private static Dialog createChooseArcherySetupDialog(final Activity parent) { | |||||
| final ChooseArcherySetupDlg dialog = new ChooseArcherySetupDlg(parent); | |||||
| return dialog; | |||||
| } | } | ||||
| } | } |
| import android.widget.ListView; | import android.widget.ListView; | ||||
| import android.widget.ScrollView; | import android.widget.ScrollView; | ||||
| import android.widget.Spinner; | import android.widget.Spinner; | ||||
| 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.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.dialog.ChooseArcherySetupDlg.ChooseArcherySetupDlgDismissListener; | |||||
| import ch.spherIC.recurvebowsight.model.IArcherySetup; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Arrays; | import java.util.Arrays; | ||||
| public class RBSMainActivity extends Activity { | |||||
| public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDismissListener { | |||||
| 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; | ||||
| private Spinner calcTimeIntervalCboBox; | private Spinner calcTimeIntervalCboBox; | ||||
| private XSpinner calcAccuracyCboBox; | private XSpinner calcAccuracyCboBox; | ||||
| private TextView arrowDiameterTxtFld; | |||||
| private Activity riserSightConfigActivity; | private Activity riserSightConfigActivity; | ||||
| private boolean showInfoMenu; | private boolean showInfoMenu; | ||||
| this.txtViewSight = (XTextView) findViewById(R.id.viewSight); | this.txtViewSight = (XTextView) findViewById(R.id.viewSight); | ||||
| this.calcTimeIntervalCboBox = (Spinner) findViewById(R.id.deltaTimeCboBox); | this.calcTimeIntervalCboBox = (Spinner) findViewById(R.id.deltaTimeCboBox); | ||||
| this.calcAccuracyCboBox = (XSpinner) findViewById(R.id.calcPrecisionCboBox); | this.calcAccuracyCboBox = (XSpinner) findViewById(R.id.calcPrecisionCboBox); | ||||
| this.arrowDiameterTxtFld = (TextView) findViewById(R.id.arrowDiameterTxtFld); | |||||
| addTouchListeners(); | addTouchListeners(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected Dialog onCreateDialog(int id) { | |||||
| protected Dialog onCreateDialog(final int id) { | |||||
| return DialogFactory.createDialog(id, this); | return DialogFactory.createDialog(id, this); | ||||
| } | } | ||||
| @Override | |||||
| public void onArcherySetupDlgDismissed(final IArcherySetup archerySetup) { | |||||
| if (archerySetup != null) { | |||||
| if (archerySetup.getId() != -999) { | |||||
| this.arrowDiameterTxtFld.setText(archerySetup.getArrowDiameter().toString()); | |||||
| } else { | |||||
| this.arrowDiameterTxtFld.setText(""); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } |
| /** | |||||
| * Copyright (C) 2005-2012 XELOG AG | |||||
| */ | |||||
| package ch.spherIC.recurvebowsight.components; | |||||
| import android.content.Context; | |||||
| import android.view.LayoutInflater; | |||||
| import android.view.View; | |||||
| import android.view.ViewGroup; | |||||
| import android.widget.ArrayAdapter; | |||||
| import android.widget.TextView; | |||||
| import ch.spherIC.recurvebowsight.R; | |||||
| import ch.spherIC.recurvebowsight.model.IArcherySetup; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author FC Smilari | |||||
| */ | |||||
| public class ArcerySetupArrayAdapter extends ArrayAdapter<IArcherySetup> { | |||||
| /** | |||||
| * Konstruktor. | |||||
| * | |||||
| * @param context | |||||
| * @param textViewResourceId | |||||
| * @param objects | |||||
| */ | |||||
| public ArcerySetupArrayAdapter(final Context context, final int textViewResourceId, final IArcherySetup[] objects) { | |||||
| super(context, textViewResourceId, objects); | |||||
| } | |||||
| /** | |||||
| * Konstruktor. | |||||
| * | |||||
| * @param context | |||||
| * @param textViewResourceId | |||||
| * @param objects | |||||
| */ | |||||
| public ArcerySetupArrayAdapter(final Context context, final int textViewResourceId, final List<IArcherySetup> objects) { | |||||
| super(context, textViewResourceId, objects); | |||||
| } | |||||
| @Override | |||||
| public View getView(final int position, final View convertView, final ViewGroup parent) { | |||||
| LayoutInflater inflater = getLayoutInflater(); | |||||
| View item = inflater.inflate(R.layout.rbs_archerysetup_item, parent, false); | |||||
| TextView textViewMain = (TextView) item.findViewById(R.id.chooseArcherySetupTxtMain); | |||||
| TextView textViewSub = (TextView) item.findViewById(R.id.chooseArcherySetupTxtSub); | |||||
| if (getItem(position).getId() != -999) { | |||||
| textViewMain.setText(getItem(position).getRiser().getManufacturer() + " / " + getItem(position).getSight().getManufacturer()); | |||||
| textViewSub.setText(getItem(position).getRiser().getManufacturer() + " / " + getItem(position).getSight().getManufacturer()); | |||||
| } else { | |||||
| textViewMain.setText("[ ]"); | |||||
| textViewSub.setText(getContext().getString(R.string.caption_NoSelection)); | |||||
| } | |||||
| return item; | |||||
| } | |||||
| protected LayoutInflater getLayoutInflater() { | |||||
| return (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); | |||||
| } | |||||
| } |
| /* | |||||
| * $URL$ | |||||
| * $Revision$ | |||||
| * $LastChangedBy$ | |||||
| * $LastChangedDate$ | |||||
| * | |||||
| * Copyright (c) 2011 spherIC, Switzerland | |||||
| * All rights reserved. | |||||
| * | |||||
| * This software is the confidential and proprietary information | |||||
| * of spherIC. ("Confidential Information"). You shall not | |||||
| * disclose such Confidential Information and shall use it only | |||||
| * in accordance with the terms of the license agreement you | |||||
| * entered into with spherIC. | |||||
| */ | |||||
| package ch.spherIC.recurvebowsight.components; | |||||
| import android.content.Context; | |||||
| import android.content.res.TypedArray; | |||||
| import android.graphics.Canvas; | |||||
| import android.graphics.Paint; | |||||
| import android.graphics.Rect; | |||||
| import android.util.AttributeSet; | |||||
| import android.widget.ImageView; | |||||
| import ch.spherIC.recurvebowsight.R; | |||||
| /** | |||||
| * DOCUMENT ME! | |||||
| * | |||||
| * @author $author$ | |||||
| * @version $Revision$, $Date$ | |||||
| */ | |||||
| public class XImageView extends ImageView { | |||||
| private boolean drawborder; | |||||
| private int drawborderColor; | |||||
| private int drawborderWidth; | |||||
| /** | |||||
| * Creates a new XTextView object. | |||||
| * | |||||
| * @param context DOCUMENT ME! | |||||
| */ | |||||
| public XImageView(final Context context) { | |||||
| super(context); | |||||
| } | |||||
| /** | |||||
| * Creates a new $class.name$ object. | |||||
| * | |||||
| * @param context DOCUMENT ME! | |||||
| * @param attrs DOCUMENT ME! | |||||
| * @param defStyle DOCUMENT ME! | |||||
| */ | |||||
| public XImageView(final Context context, final AttributeSet attrs, final int defStyle) { | |||||
| super(context, attrs, defStyle); | |||||
| init(attrs); | |||||
| } | |||||
| /** | |||||
| * Creates a new $class.name$ object. | |||||
| * | |||||
| * @param context DOCUMENT ME! | |||||
| * @param attrs DOCUMENT ME! | |||||
| */ | |||||
| public XImageView(final Context context, final AttributeSet attrs) { | |||||
| super(context, attrs); | |||||
| init(attrs); | |||||
| } | |||||
| /** | |||||
| * DOCUMENT ME! | |||||
| * | |||||
| * @param attrs DOCUMENT ME! | |||||
| */ | |||||
| private void init(final AttributeSet attrs) { | |||||
| TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.XTextView); | |||||
| this.drawborder = a.getBoolean(R.styleable.XTextView_drawBorder, false); | |||||
| this.drawborderColor = a.getColor(R.styleable.XTextView_drawBorderColor, 0xffff0000); | |||||
| this.drawborderWidth = a.getDimensionPixelSize(R.styleable.XTextView_drawBorderWidth, 1); | |||||
| if (this.drawborder) { | |||||
| setPadding(getPaddingLeft() + this.drawborderWidth, getPaddingTop() + this.drawborderWidth, getPaddingRight() + this.drawborderWidth, | |||||
| getPaddingBottom() + this.drawborderWidth); | |||||
| } | |||||
| a.recycle(); | |||||
| } | |||||
| /** | |||||
| * @see android.widget.TextView#onDraw(android.graphics.Canvas) | |||||
| */ | |||||
| @Override | |||||
| protected void onDraw(final Canvas canvas) { | |||||
| super.onDraw(canvas); | |||||
| if (this.drawborder) { | |||||
| Rect rect = new Rect(); | |||||
| Paint paint = new Paint(); | |||||
| paint.setStyle(Paint.Style.STROKE); | |||||
| paint.setColor(this.drawborderColor); | |||||
| paint.setStrokeWidth(this.drawborderWidth); | |||||
| getLocalVisibleRect(rect); | |||||
| rect.bottom -= 1; | |||||
| rect.right -= 1; | |||||
| canvas.drawRect(rect, paint); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * @param drawborderColor the drawborderColor to set | |||||
| */ | |||||
| public void setDrawborderColor(final int drawborderColor) { | |||||
| this.drawborderColor = drawborderColor; | |||||
| invalidate(); | |||||
| } | |||||
| } |
| /** | |||||
| * Copyright (C) 2005-2012 XELOG AG | |||||
| */ | |||||
| package ch.spherIC.recurvebowsight.dialog; | |||||
| import android.app.Dialog; | |||||
| import android.content.Context; | |||||
| import android.content.DialogInterface; | |||||
| import android.os.Bundle; | |||||
| import android.view.ContextThemeWrapper; | |||||
| import android.view.View; | |||||
| import android.widget.AdapterView; | |||||
| import android.widget.AdapterView.OnItemClickListener; | |||||
| import android.widget.ListView; | |||||
| import android.widget.TextView; | |||||
| import ch.spherIC.recurvebowsight.R; | |||||
| import ch.spherIC.recurvebowsight.RBSMainActivity; | |||||
| import ch.spherIC.recurvebowsight.components.ArcerySetupArrayAdapter; | |||||
| import ch.spherIC.recurvebowsight.database.dao.ArcherySetupDao; | |||||
| import ch.spherIC.recurvebowsight.model.ArcherySetup; | |||||
| import ch.spherIC.recurvebowsight.model.IArcherySetup; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author FC Smilari | |||||
| */ | |||||
| public class ChooseArcherySetupDlg extends Dialog { | |||||
| private IArcherySetup archerySetup; | |||||
| /** | |||||
| * @param context | |||||
| */ | |||||
| public ChooseArcherySetupDlg(final Context context) { | |||||
| super(context); | |||||
| this.archerySetup = null; | |||||
| } | |||||
| @Override | |||||
| protected void onCreate(final Bundle savedInstanceState) { | |||||
| super.onCreate(savedInstanceState); | |||||
| setContentView(R.layout.rbs_choose_archerysetup_dlg); | |||||
| setTitle(getContext().getResources().getText(R.string.menuChooseEquipment)); | |||||
| final ListView listView = (ListView) findViewById(R.id.chooseArcerySetupItemsList); | |||||
| List<IArcherySetup> setups = new ArrayList<IArcherySetup>(); | |||||
| setups.add(new ArcherySetup(-999, null, null, null, null, null, null, null, null, null, null, null, null, null, null)); | |||||
| setups.addAll(ArcherySetupDao.getInstance().loadAll()); | |||||
| listView.setAdapter(new ArcerySetupArrayAdapter(getContext(), R.layout.rbs_archerysetup_item, setups)); | |||||
| listView.setOnItemClickListener(new OnItemClickListener() { | |||||
| @Override | |||||
| public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { | |||||
| ChooseArcherySetupDlg.this.archerySetup = (IArcherySetup) listView.getItemAtPosition(position); | |||||
| dismiss(); | |||||
| } | |||||
| }); | |||||
| ((TextView) findViewById(android.R.id.title)).setTextColor(getContext().getResources().getColor(R.color.android_blue)); | |||||
| setOnDismissListener(new OnDismissListener() { | |||||
| @Override | |||||
| public void onDismiss(final DialogInterface dialog) { | |||||
| ((RBSMainActivity) ((ContextThemeWrapper) getContext()).getBaseContext()).onArcherySetupDlgDismissed(ChooseArcherySetupDlg.this.archerySetup); | |||||
| } | |||||
| }); | |||||
| } | |||||
| @Override | |||||
| public void show() { | |||||
| super.show(); | |||||
| this.archerySetup = null; | |||||
| } | |||||
| /** | |||||
| * Interface zum Listen von Dismiss-Events des ChooseArcherySetupDlg. | |||||
| * | |||||
| * @author FC Smilari | |||||
| */ | |||||
| public interface ChooseArcherySetupDlgDismissListener { | |||||
| void onArcherySetupDlgDismissed(IArcherySetup archerySetup); | |||||
| } | |||||
| } |