Permalink
Browse files

show version number at bottom of settings

  • Loading branch information...
1 parent f37b043 commit 0e483fad2b830c9d0b2b07a3de7472e63a36cf3b @Xlythe committed Sep 19, 2012
View
@@ -1,35 +1,23 @@
-<?xml version="1.0" encoding="utf-8"?>
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
- <PreferenceCategory>
- <CheckBoxPreference
- android:title="@string/graph"
- android:key="GRAPH"
- android:defaultValue="@bool/GRAPH" />
-<!-- <CheckBoxPreference
- android:title="@string/function"
- android:key="FUNCTION"
- android:defaultValue="@bool/FUNCTION" /> -->
- <CheckBoxPreference
- android:title="@string/hexPanel"
- android:key="HEX"
- android:defaultValue="@bool/HEX" />
- <CheckBoxPreference
- android:title="@string/basic"
- android:key="BASIC"
- android:defaultValue="@bool/BASIC" />
- <CheckBoxPreference
- android:title="@string/advanced"
- android:key="ADVANCED"
- android:defaultValue="@bool/ADVANCED" />
- <CheckBoxPreference
- android:title="@string/matrix"
- android:key="MATRIX"
- android:defaultValue="@bool/MATRIX" />
- </PreferenceCategory>
- <PreferenceCategory>
- <CheckBoxPreference
- android:title="@string/returnToBasic"
- android:key="RETURN_TO_BASIC"
- android:defaultValue="@bool/RETURN_TO_BASIC" />
- </PreferenceCategory>
-</PreferenceScreen>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <!-- Include Version Number footer -->
+ <TextView
+ android:id="@+id/version"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@color/pressed_color"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentRight="true"
+ android:padding="8dp" />
+
+ <!-- Include preferences -->
+ <fragment
+ android:id="@+id/preferences"
+ android:name="com.android2.calculator3.PreferencesFragment"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_above="@id/version" />
+
+</RelativeLayout>
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <PreferenceCategory>
+ <CheckBoxPreference
+ android:title="@string/graph"
+ android:key="GRAPH"
+ android:defaultValue="@bool/GRAPH" />
+<!-- <CheckBoxPreference
+ android:title="@string/function"
+ android:key="FUNCTION"
+ android:defaultValue="@bool/FUNCTION" /> -->
+ <CheckBoxPreference
+ android:title="@string/hexPanel"
+ android:key="HEX"
+ android:defaultValue="@bool/HEX" />
+ <CheckBoxPreference
+ android:title="@string/basic"
+ android:key="BASIC"
+ android:defaultValue="@bool/BASIC" />
+ <CheckBoxPreference
+ android:title="@string/advanced"
+ android:key="ADVANCED"
+ android:defaultValue="@bool/ADVANCED" />
+ <CheckBoxPreference
+ android:title="@string/matrix"
+ android:key="MATRIX"
+ android:defaultValue="@bool/MATRIX" />
+ </PreferenceCategory>
+ <PreferenceCategory>
+ <CheckBoxPreference
+ android:title="@string/returnToBasic"
+ android:key="RETURN_TO_BASIC"
+ android:defaultValue="@bool/RETURN_TO_BASIC" />
+ </PreferenceCategory>
+</PreferenceScreen>
@@ -242,12 +242,6 @@ public boolean onLongClick(View view) {
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
int action = keyEvent.getAction();
- if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT ||
- keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
- boolean eat = mHandler.eatHorizontalMove(keyCode == KeyEvent.KEYCODE_DPAD_LEFT);
- return eat;
- }
-
//Work-around for spurious key event from IME, bug #1639445
if (action == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
return true; // eat it
@@ -2,9 +2,10 @@
import android.app.Activity;
import android.content.Intent;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
-import android.preference.PreferenceFragment;
import android.view.KeyEvent;
+import android.widget.TextView;
/**
* @author Will Harmon
@@ -13,16 +14,14 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- getFragmentManager().beginTransaction().replace(android.R.id.content,
- new PrefsFragment()).commit();
- }
-
- public static class PrefsFragment extends PreferenceFragment {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.layout.preferences);
- }
+ setContentView(R.layout.preferences);
+ try {
+ String versionName = "v" + getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
+ TextView version = (TextView) findViewById(R.id.version);
+ version.setText(versionName);
+ } catch (NameNotFoundException e) {
+ e.printStackTrace();
+ }
}
@Override
@@ -0,0 +1,12 @@
+package com.android2.calculator3;
+
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+
+public class PreferencesFragment extends PreferenceFragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.layout.preferences_body);
+ }
+}

0 comments on commit 0e483fa

Please sign in to comment.