Skip to content

Commit

Permalink
Add about dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Pietu1998 committed Dec 24, 2015
1 parent bfd337e commit fc9ef11
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 0 deletions.
Binary file added res/drawable-hdpi/ic_menu_info_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-ldpi/ic_menu_info_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_menu_info_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_menu_info_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxhdpi/ic_menu_info_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions res/menu/mainmenu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
3 changes: 3 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
25 changes: 25 additions & 0 deletions src/net/pietu1998/wordbasehacker/GameListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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;
Expand All @@ -17,12 +18,16 @@
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;
Expand All @@ -31,6 +36,7 @@
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 {
Expand Down Expand Up @@ -79,11 +85,30 @@ public boolean onPrepareOptionsMenu(Menu menu) {
}

@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();
Expand Down

0 comments on commit fc9ef11

Please sign in to comment.