/* * $URL$ * $Revision$ * $LastChangedBy$ * $LastChangedDate$ * * Copyright (c) 2005 syseca AG, Switzerland * All rights reserved. * * This software is the confidential and proprietary information * of syseca AG. ("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 syseca AG. */ package ch.spherIC.recurvebowsight; import android.app.Activity; import android.app.Dialog; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import ch.spherIC.recurvebowsight.dialog.ChooseArcherySetupDlg; /** * Dialog factory class. */ public final class DialogFactory { /** * Static main method to initialize classes * * @param dlgCode Code of dialog to instantiate. See {@link EasyBracketMain} * @param parent Parent {@link Activity} * * @return Instantiated dialog. */ public static Dialog createDialog(final int dlgCode, final Activity parent) { Dialog dlg; switch (dlgCode) { case RBSMainActivity.DLG_CHOOSE_ARCHERYSETUP: dlg = createChooseArcherySetupDialog(parent); break; case RBSMainActivity.DLG_ABOUT: dlg = createAboutDialog(parent); break; case RBSMainActivity.DLG_USERGUIDE_PARAMS_SIGHT: dlg = createUserguideParamsDialog(parent); break; default: dlg = null; break; } return dlg; } /** * @param parent * * @return */ private static Dialog createUserguideParamsDialog(final Activity parent) { final Dialog dialog = new Dialog(parent); dialog.setContentView(R.layout.rbs_userguide_dialog); dialog.setTitle(parent.getResources().getText(R.string.menuUserGuide).toString()); ImageView image = (ImageView) dialog.findViewById(R.id.ug_image); image.setImageResource(R.drawable.userguide_params); TextView text = (TextView) dialog.findViewById(R.id.ug_txt_HowTo); text.setText(parent.getResources().getString(R.string.caption_UserguideParams, parent.getResources().getString(R.string.arrowNockHeightLbl), parent.getResources().getString(R.string.targetCenterHeightLbl), parent.getResources().getString(R.string.shootingDistanzLbl), parent.getResources().getString(R.string.ashNA), parent.getResources().getString(R.string.bowPulloutLbl), parent.getResources().getString(R.string.asNockRaising), parent.getResources().getString(R.string.asBraceHeight))); ((Button) dialog.findViewById(R.id.btn_ugClose)).setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { dialog.dismiss(); } }); return dialog; } private static Dialog createChooseArcherySetupDialog(final Activity parent) { final ChooseArcherySetupDlg dialog = new ChooseArcherySetupDlg(parent); return dialog; } /** * Creates the About Dialog */ private static Dialog createAboutDialog(final Activity parent) { String versionName = ""; final Dialog dialog = new Dialog(parent); dialog.setContentView(R.layout.rbs_about_dialog); dialog.setTitle(parent.getResources().getText(R.string.menuAbout).toString()); try { versionName = parent.getPackageManager().getPackageInfo("ch.spherIC", PackageManager.GET_CONFIGURATIONS).versionName; } catch (NameNotFoundException e) { versionName = "-"; } ImageView image = (ImageView) dialog.findViewById(R.id.about_imageAppIcon); image.setImageResource(R.drawable.ic_launcher); TextView text = (TextView) dialog.findViewById(R.id.about_TextDescription); text.setText(parent.getResources().getText(R.string.about_Description)); text = (TextView) dialog.findViewById(R.id.about_TextVersion); text.setText(parent.getResources().getText(R.string.AppVersionLabel).toString() + " " + versionName); text = (TextView) dialog.findViewById(R.id.about_TextAutor); text.setText(parent.getResources().getText(R.string.about_DevelopedBy).toString()); ((Button) dialog.findViewById(R.id.btn_AboutClose)).setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { dialog.dismiss(); } }); return dialog; } }