diff options
author | Andrew Dolgov <[email protected]> | 2013-11-28 21:16:16 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2013-11-28 21:16:16 +0400 |
commit | bd1801e40f31a94da4b83bd2afcdd45049c10dac (patch) | |
tree | 6f4d31ea582da15b4fe86801af67d633ab733756 /src | |
parent | 1459b681fce654c72a180a746646be4a9b4ab9e5 (diff) |
add donate actionbar button
Diffstat (limited to 'src')
-rw-r--r-- | src/org/fox/ttcomics/CommonActivity.java | 22 | ||||
-rw-r--r-- | src/org/fox/ttcomics/MainActivity.java | 8 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/org/fox/ttcomics/CommonActivity.java b/src/org/fox/ttcomics/CommonActivity.java index 4df6de7..6267ee2 100644 --- a/src/org/fox/ttcomics/CommonActivity.java +++ b/src/org/fox/ttcomics/CommonActivity.java @@ -8,12 +8,15 @@ import java.util.Date; import android.accounts.Account;
import android.accounts.AccountManager;
+import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
import android.graphics.BitmapFactory;
+import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
@@ -321,6 +324,25 @@ public class CommonActivity extends SherlockFragmentActivity { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
+ case R.id.menu_donate:
+ if (true) {
+ try {
+ Intent intent = new Intent(Intent.ACTION_VIEW,
+ Uri.parse("market://details?id=org.fox.ttcomics.donation"));
+ startActivity(intent);
+ } catch (ActivityNotFoundException ae) {
+ try {
+ Intent intent = new Intent(Intent.ACTION_VIEW,
+ Uri.parse("https://play.google.com/store/apps/details?id=org.fox.ttcomics.donation"));
+ startActivity(intent);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+ return true;
case R.id.menu_rescan:
ComicListFragment frag = (ComicListFragment) getSupportFragmentManager().findFragmentByTag(FRAG_COMICS_LIST);
diff --git a/src/org/fox/ttcomics/MainActivity.java b/src/org/fox/ttcomics/MainActivity.java index 13af786..7de2f14 100644 --- a/src/org/fox/ttcomics/MainActivity.java +++ b/src/org/fox/ttcomics/MainActivity.java @@ -17,6 +17,7 @@ import android.annotation.SuppressLint; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; +import android.content.pm.PackageManager; import android.os.Bundle; import android.support.v4.app.FragmentTransaction; import android.util.Log; @@ -166,6 +167,13 @@ public class MainActivity extends CommonActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { getSupportMenuInflater().inflate(R.menu.activity_main, menu); + + boolean isDonationFound = getPackageManager().checkSignatures( + getPackageName(), "org.fox.ttcomics.donation") == PackageManager.SIGNATURE_MATCH; + + if (isDonationFound) + menu.findItem(R.id.menu_donate).setVisible(false); + return true; } |