Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

preferences match trebuchet

  • Loading branch information...
commit 56c340433b97927abc91b67548494e5bf10afc9d 1 parent cd4aa32
@Xlythe authored
View
28 res/layout/preferences.xml
@@ -1,25 +1,5 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<fragment xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/preferences"
+ android:name="com.android2.calculator3.view.PreferencesFragment"
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:paddingRight="20dp"
- android:paddingTop="8dp"
- android:paddingBottom="8dp" />
-
- <!-- Include preferences -->
- <fragment
- android:id="@+id/preferences"
- android:name="com.android2.calculator3.view.PreferencesFragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_above="@id/version" />
-
-</RelativeLayout>
+ android:layout_height="match_parent" />
View
7 res/layout/preferences_body.xml
@@ -43,4 +43,11 @@
android:switchTextOff="@string/degrees"
android:defaultValue="@bool/USE_RADIANS" />
</PreferenceCategory>
+ <PreferenceCategory
+ android:title="@string/pref_application" >
+ <Preference
+ android:title="@string/app_name"
+ android:summary="@string/application_copyright"
+ android:key="ABOUT" />
+ </PreferenceCategory>
</PreferenceScreen>
View
3  res/values/strings.xml
@@ -186,6 +186,7 @@
<string name="pref_panels">Panels</string>
<string name="pref_actions">Actions</string>
<string name="pref_units">Units</string>
+ <string name="pref_application">Application</string>
<string name="returnToBasic">Return to the basic panel</string>
<string name="trigUnits">Trig units</string>
<string name="radians">RAD</string>
@@ -205,5 +206,5 @@
<string name="easter_egg">Magikarp used Splash but nothing happened.</string>
<string name="activity_about">About</string>
- <string name="about">Maintainer: Will Harmon (Xlythe)\nUniversity: University of Waterloo\nContact Details: xlythe@gmail.com\nVersion Number: %s\nCountry: Canada\nLast Updated: Feb 11, 2013\nSource Code: https://github.com/Xlythe/android_packages_apps_Calculator\nOther Apps: https://play.google.com/store/apps/developer?id=Xlythe</string>
+ <string name="about">Maintainer: Will Harmon (Xlythe)\nUniversity: University of Waterloo\nContact Details: xlythe@gmail.com\nVersion Number: %s\nCountry: Canada\nLast Updated: Feb 14, 2013\nSource Code: https://github.com/Xlythe/android_packages_apps_Calculator\nOther Apps: https://play.google.com/store/apps/developer?id=Xlythe</string>
</resources>
View
18 src/com/android2/calculator3/Preferences.java
@@ -2,12 +2,8 @@
import android.app.Activity;
import android.content.Intent;
-import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.view.KeyEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.TextView;
/**
* @author Will Harmon
@@ -17,20 +13,6 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.preferences);
- try {
- String versionName = "v" + getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
- TextView version = (TextView) findViewById(R.id.version);
- version.setText(versionName);
- version.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- startActivity(new Intent(Preferences.this, About.class));
- }
- });
- }
- catch(NameNotFoundException e) {
- e.printStackTrace();
- }
}
@Override
View
23 src/com/android2/calculator3/view/PreferencesFragment.java
@@ -1,8 +1,13 @@
package com.android2.calculator3.view;
+import android.content.Intent;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceFragment;
+import com.android2.calculator3.About;
import com.android2.calculator3.R;
public class PreferencesFragment extends PreferenceFragment {
@@ -10,5 +15,23 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.preferences_body);
+ Preference about = findPreference("ABOUT");
+ if(about != null) {
+ String versionName = "";
+ try {
+ versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
+ }
+ catch(NameNotFoundException e) {
+ e.printStackTrace();
+ }
+ about.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ startActivity(new Intent(getActivity(), About.class));
+ return false;
+ }
+ });
+ about.setTitle(about.getTitle() + " " + versionName);
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.