Commit fc9ef111 authored by PurkkaKoodari's avatar PurkkaKoodari

Add about dialog

parent bfd337e5
......@@ -31,5 +31,11 @@
android:showAsAction="always"
android:title="@string/refresh">
</item>
<item
android:id="@+id/miInfo"
android:icon="@drawable/ic_menu_info_details"
android:showAsAction="always"
android:title="@string/about">
</item>
</menu>
\ No newline at end of file
......@@ -33,6 +33,9 @@
<string name="no_moves">No moves found.</string>
<string name="best_move">Best word: %1$s (%2$d)</string>
<string name="refresh">Refresh</string>
<string name="about">About</string>
<string name="about_title">About Wordbase Hacker</string>
<string name="about_text">Wordbase Hacker\nversion %1$s\n\nCopyright &#169; Pietu1998 2015\nLicensed under the MIT license.\nYou can find the source code at https://bitbucket.org/Pietu1998/wordbase-hacker&#8204;.</string>
<string name="dev">Developer</string>
<string name="dev_on">Developer options enabled</string>
<string name="dev_off">Developer options disabled</string>
......
......@@ -9,6 +9,7 @@ import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;
import net.pietu1998.wordbasehacker.solver.Game;
import android.annotation.SuppressLint;
......@@ -17,12 +18,16 @@ import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
import android.database.sqlite.SQLiteCantOpenDatabaseException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
......@@ -31,6 +36,7 @@ import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class GameListActivity extends ListActivity {
......@@ -79,11 +85,30 @@ public class GameListActivity extends ListActivity {
}
@Override
@SuppressLint("InflateParams")
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.miRefresh:
loadData();
return true;
case R.id.miInfo:
try {
String version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
String aboutText = getResources().getString(R.string.about_text, version);
SpannableString spannable = new SpannableString(aboutText);
Linkify.addLinks(spannable, Pattern.compile("https?://[\u0021-\u007e]+"), "http://");
TextView view = new TextView(this);
view.setTextAppearance(this, android.R.style.TextAppearance_Holo_Small);
view.setPadding(5, 5, 5, 5);
view.setText(spannable);
view.setMovementMethod(LinkMovementMethod.getInstance());
new AlertDialog.Builder(this).setView(view).setNeutralButton(R.string.ok, null)
.setTitle(R.string.about_title).show();
} catch (NameNotFoundException e) {
Log.e("WordbaseHacker", "Couldn't get version.", e);
Toast.makeText(this, R.string.internal_error, Toast.LENGTH_SHORT).show();
}
return true;
case R.id.miOffdev:
getSharedPreferences("WordbaseHacker", 0).edit().putBoolean("dev", false).commit();
invalidateOptionsMenu();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment