PageRenderTime 113ms CodeModel.GetById 70ms app.highlight 7ms RepoModel.GetById 34ms app.codeStats 0ms

/AndDaaven/src/com/saraandshmuel/anddaaven/AndDaavenAboutDialogController.java

https://code.google.com/p/anddaaven/
Java | 73 lines | 57 code | 10 blank | 6 comment | 4 complexity | a8c8a703222608286e11df7cfb64ce5d MD5 | raw file
 1package com.saraandshmuel.anddaaven;
 2
 3import android.app.Activity;
 4import android.app.Dialog;
 5import android.content.Intent;
 6import android.content.pm.PackageInfo;
 7import android.content.pm.PackageManager.NameNotFoundException;
 8import android.util.Log;
 9import android.view.View;
10import android.view.View.OnLongClickListener;
11import android.widget.TextView;
12
13
14/**
15 * Creates and controls the about dialog
16 * @author shmuelp
17 *
18 */
19public class AndDaavenAboutDialogController implements OnLongClickListener
20{
21
22	private Activity context;
23	private TextView versionText;
24	
25	public boolean onLongClick(View p1)
26	{
27		Intent intent = new Intent(context, com.saraandshmuel.anddaaven.AndDaavenTestSettings.class);
28		context.startActivity(intent);
29		Log.v(TAG, "onOptionsItemSelected() returning early 2");
30		return true;
31	}
32	
33	
34	private static final String TAG = "AndDaavenAboutDialogController";
35
36    public AndDaavenAboutDialogController(Activity context){
37		this.context=context;
38	}
39	
40	public Dialog create()
41	{
42		Dialog aboutDialog = new Dialog(context);
43		aboutDialog.setContentView(R.layout.acknowlegements);
44		String version=new String();
45		// Add the version number to the title bar
46		try
47		{
48			PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
49			version = pi.versionName;
50		}
51		catch (NameNotFoundException e)
52		{
53			e.printStackTrace();
54			Log.e(TAG, "Error looking up version information", e);
55		}
56		View v=aboutDialog.findViewById(R.id.VersionAcknowledgement);
57		if (v != null && v instanceof TextView)
58		{
59			versionText=((TextView)v);
60			versionText.setText(version);
61			versionText.setOnLongClickListener(this);
62			
63		} else {
64			Log.e(TAG, "Can't set version, v=" + v);
65		}
66		aboutDialog
67			.setTitle(context.getString(R.string.TextViewAcknowledgementTitle));
68		aboutDialog.setCancelable(true);
69		aboutDialog.setOwnerActivity(context);
70		Log.v(TAG, "onOptionsItemSelected() returning early 1");
71		return aboutDialog;
72	}
73}