Skip to content

Commit

Permalink
Create "About" dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
inguin committed Sep 17, 2012
1 parent fffaeb0 commit aa5c87d
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 9 deletions.
24 changes: 24 additions & 0 deletions res/layout/about_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="vertical" >

<TextView
android:id="@+id/about_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:drawableLeft="@drawable/coins" />

<TextView
android:id="@+id/about_license"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textColor="#444444"
android:textSize="10dip"
android:textStyle="italic" />

</LinearLayout>
3 changes: 3 additions & 0 deletions res/menu/calculation_list_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
<item android:id="@+id/new_calculation"
android:title="@string/new_calculation"
android:showAsAction="always" android:icon="@android:drawable/ic_menu_add"/>
<item android:id="@+id/about"
android:title="@string/menu_about"
android:icon="@android:drawable/ic_menu_info_details"/>
</menu>
1 change: 1 addition & 0 deletions res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<string name="app_name">Abrechnung</string>
<string name="menu_save">Speichern</string>
<string name="menu_delete">Löschen</string>
<string name="menu_about">Über MoneyBalance</string>
<string name="minus">Entfernen</string>

<string name="confirm_delete_calculation">Bist Du sicher, dass diese Abrechnung gelöscht werden soll?</string>
Expand Down
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<string name="app_name">MoneyBalance</string>
<string name="menu_save">Save</string>
<string name="menu_delete">Delete</string>
<string name="menu_about">About MoneyBalance</string>
<string name="minus">minus</string>

<string name="confirm_delete_calculation">Are you sure you want to delete this calculation?</string>
Expand Down
43 changes: 43 additions & 0 deletions src/ivl/android/moneybalance/AboutDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package ivl.android.moneybalance;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;

public class AboutDialog extends Dialog {

private static String INFO_HTML =
"Copyright (C) 2012 Ingo van Lil<br>" +
"<a href=\"https://github.com/inguin/moneybalance\">https://github.com/inguin/moneybalance</a><br><br>" +
"Icons created by <a href=\"http://www.visualpharm.com\">VisualPharm</a>, " +
"used under a <a href=\"http://creativecommons.org/licenses/by-nd/3.0/\">CC BY-ND 3.0</a> license.";

private static String LICENSE_HTML =
"Licensed under the Apache License, Version 2.0 (the \"License\"). " +
"You may not use this program except in compliance with the License.<br>" +
"You may obtain a copy of the License at " +
"<a href=\"http://www.apache.org/licenses/LICENSE-2.0\">http://www.apache.org/licenses/LICENSE-2.0</a>.";

public AboutDialog(Context context) {
super(context);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about_dialog);
setTitle(R.string.app_name);

TextView info = (TextView) findViewById(R.id.about_info);
info.setText(Html.fromHtml(INFO_HTML));
info.setMovementMethod(LinkMovementMethod.getInstance());

TextView license = (TextView) findViewById(R.id.about_license);
license.setText(Html.fromHtml(LICENSE_HTML));
license.setMovementMethod(LinkMovementMethod.getInstance());
}

}
26 changes: 17 additions & 9 deletions src/ivl/android/moneybalance/CalculationListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,18 @@ public boolean onCreateOptionsMenu(Menu menu) {
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.new_calculation:
startActivity(new Intent(this, CalculationEditorActivity.class));
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.new_calculation:
startActivity(new Intent(this, CalculationEditorActivity.class));
return true;
case R.id.about:
showAboutDialog();
return true;
default:
return super.onOptionsItemSelected(item);
}
}

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
Expand Down Expand Up @@ -197,6 +200,11 @@ public void onClick(DialogInterface dialog, int which) {
dialog.show();
}

private void showAboutDialog() {
AboutDialog about = new AboutDialog(this);
about.show();
}

@Override
protected void onPause() {
super.onPause();
Expand Down

0 comments on commit aa5c87d

Please sign in to comment.