add donation menu item

This commit is contained in:
Andrew Dolgov 2012-09-19 22:40:27 +04:00
parent d70e6463ad
commit 0148a20369
3 changed files with 58 additions and 37 deletions

View File

@ -1,7 +1,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <menu xmlns:android="http://schemas.android.com/apk/res/android" >
<group android:id="@+id/menu_group_logged_in" > <group android:id="@+id/menu_group_logged_in" >
<group android:id="@+id/menu_group_feeds" > <group android:id="@+id/menu_group_feeds" >
<!-- <!--
@ -17,137 +16,125 @@
android:icon="@android:drawable/ic_menu_agenda" android:icon="@android:drawable/ic_menu_agenda"
android:showAsAction="" android:showAsAction=""
android:title="@string/menu_all_feeds"/> android:title="@string/menu_all_feeds"/>
<item <item
android:id="@+id/update_feeds" android:id="@+id/update_feeds"
android:icon="@android:drawable/ic_menu_rotate" android:icon="@android:drawable/ic_menu_rotate"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/update_feeds"/> android:title="@string/update_feeds"/>
<item <item
android:id="@+id/go_offline" android:id="@+id/go_offline"
android:icon="@drawable/ic_menu_cloud" android:icon="@drawable/ic_menu_cloud"
android:showAsAction="" android:showAsAction=""
android:title="@string/go_offline"/> android:title="@string/go_offline"/>
<item <item
android:id="@+id/logout" android:id="@+id/logout"
android:icon="@drawable/ic_menu_exit" android:icon="@drawable/ic_menu_exit"
android:showAsAction="" android:showAsAction=""
android:title="@string/logout"/> android:title="@string/logout"/>
</group> </group>
<group android:id="@+id/menu_group_headlines" > <group android:id="@+id/menu_group_headlines" >
<item <item
android:id="@+id/update_headlines" android:id="@+id/update_headlines"
android:icon="@android:drawable/ic_menu_rotate" android:icon="@android:drawable/ic_menu_rotate"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/update_headlines"/> android:title="@string/update_headlines"/>
<item <item
android:id="@+id/search" android:id="@+id/search"
android:actionViewClass="android.widget.SearchView" android:actionViewClass="android.widget.SearchView"
android:icon="@android:drawable/ic_menu_search" android:icon="@android:drawable/ic_menu_search"
android:showAsAction="ifRoom|collapseActionView" android:showAsAction="ifRoom|collapseActionView"
android:title="@string/search"/> android:title="@string/search"/>
<item <item
android:id="@+id/headlines_mark_as_read" android:id="@+id/headlines_mark_as_read"
android:icon="@drawable/ic_menu_tick" android:icon="@drawable/ic_menu_tick"
android:showAsAction="" android:showAsAction=""
android:title="@string/headlines_mark_as_read"/> android:title="@string/headlines_mark_as_read"/>
<item <item
android:id="@+id/headlines_select" android:id="@+id/headlines_select"
android:icon="@drawable/ic_menu_database" android:icon="@drawable/ic_menu_database"
android:showAsAction="" android:showAsAction=""
android:title="@string/headlines_select"/> android:title="@string/headlines_select"/>
<!-- <item <!--
<item
android:id="@+id/close_feed" android:id="@+id/close_feed"
android:icon="@android:drawable/ic_menu_close_clear_cancel" android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:showAsAction="" android:showAsAction=""
android:title="@string/close_feed"/> --> android:title="@string/close_feed"/>
-->
</group> </group>
<group android:id="@+id/menu_group_headlines_selection" > <group android:id="@+id/menu_group_headlines_selection" >
<item <item
android:id="@+id/selection_toggle_unread" android:id="@+id/selection_toggle_unread"
android:icon="@drawable/ic_menu_tick" android:icon="@drawable/ic_menu_tick"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/selection_toggle_unread"/> android:title="@string/selection_toggle_unread"/>
<item <item
android:id="@+id/selection_toggle_marked" android:id="@+id/selection_toggle_marked"
android:icon="@drawable/ic_menu_marked" android:icon="@drawable/ic_menu_marked"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/selection_toggle_marked"/> android:title="@string/selection_toggle_marked"/>
<item <item
android:id="@+id/selection_toggle_published" android:id="@+id/selection_toggle_published"
android:icon="@drawable/ic_menu_rss" android:icon="@drawable/ic_menu_rss"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/selection_toggle_published"/> android:title="@string/selection_toggle_published"/>
<item <item
android:id="@+id/selection_select_none" android:id="@+id/selection_select_none"
android:icon="@android:drawable/ic_menu_close_clear_cancel" android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:showAsAction="" android:showAsAction=""
android:title="@string/selection_select_none"/> android:title="@string/selection_select_none"/>
</group> </group>
<group android:id="@+id/menu_group_article" > <group android:id="@+id/menu_group_article" >
<item <item
android:id="@+id/toggle_marked" android:id="@+id/toggle_marked"
android:icon="@drawable/ic_menu_marked" android:icon="@drawable/ic_menu_marked"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/article_toggle_marked"/> android:title="@string/article_toggle_marked"/>
<item <item
android:id="@+id/toggle_published" android:id="@+id/toggle_published"
android:icon="@drawable/ic_menu_rss" android:icon="@drawable/ic_menu_rss"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/article_toggle_published"/> android:title="@string/article_toggle_published"/>
<item <item
android:id="@+id/share_article" android:id="@+id/share_article"
android:actionProviderClass="android.widget.ShareActionProvider"
android:icon="@android:drawable/ic_menu_share" android:icon="@android:drawable/ic_menu_share"
android:showAsAction="" android:showAsAction=""
android:actionProviderClass="android.widget.ShareActionProvider"
android:title="@string/share_article"/> android:title="@string/share_article"/>
<item <item
android:id="@+id/set_unread" android:id="@+id/set_unread"
android:icon="@android:drawable/ic_menu_recent_history" android:icon="@android:drawable/ic_menu_recent_history"
android:showAsAction="" android:showAsAction=""
android:title="@string/article_set_unread"/> android:title="@string/article_set_unread"/>
<item <item
android:id="@+id/catchup_above" android:id="@+id/catchup_above"
android:icon="@drawable/ic_menu_tick" android:icon="@drawable/ic_menu_tick"
android:title="@string/article_mark_read_above"/> android:title="@string/article_mark_read_above"/>
<item <item
android:id="@+id/set_labels" android:id="@+id/set_labels"
android:icon="@drawable/ic_menu_marked" android:icon="@drawable/ic_menu_marked"
android:title="@string/article_set_labels"/> android:title="@string/article_set_labels"/>
<item <item
android:id="@+id/article_set_note" android:id="@+id/article_set_note"
android:showAsAction="" android:showAsAction=""
android:title="@string/article_set_note"/> android:title="@string/article_set_note"/>
<!-- <item <!--
<item
android:id="@+id/close_article" android:id="@+id/close_article"
android:icon="@android:drawable/ic_menu_close_clear_cancel" android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:showAsAction="" android:showAsAction=""
android:title="@string/close_article"/> --> android:title="@string/close_article"/>
-->
</group> </group>
<item
android:id="@+id/donate"
android:showAsAction=""
android:title="@string/donate"/>
</group> </group>
<item <item
@ -155,9 +142,8 @@
android:icon="@android:drawable/ic_menu_preferences" android:icon="@android:drawable/ic_menu_preferences"
android:showAsAction="" android:showAsAction=""
android:title="@string/preferences"/> android:title="@string/preferences"/>
<group android:id="@+id/menu_group_logged_out" >
<group android:id="@+id/menu_group_logged_out" >
<item <item
android:id="@+id/login" android:id="@+id/login"
android:icon="@android:drawable/ic_menu_rotate" android:icon="@android:drawable/ic_menu_rotate"

View File

@ -134,4 +134,5 @@
<string name="category_browse_headlines">Browse headlines</string> <string name="category_browse_headlines">Browse headlines</string>
<string name="pref_default_view_mode">Default feed view</string> <string name="pref_default_view_mode">Default feed view</string>
<string name="pref_default_view_mode_long">Which feed view to open by default on smartphones</string> <string name="pref_default_view_mode_long">Which feed view to open by default on smartphones</string>
<string name="donate_thanks">Donation found, thank you for support!</string>
</resources> </resources>

View File

@ -15,6 +15,7 @@ import org.fox.ttrss.types.Label;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -23,7 +24,9 @@ import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
@ -442,6 +445,24 @@ public class OnlineActivity extends CommonActivity {
case android.R.id.home: case android.R.id.home:
finish(); finish();
return true; return true;
case R.id.donate:
if (true) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=org.fox.ttrss.key"));
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.ttrss.key"));
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
toast(R.string.error_other_error);
}
}
}
return true;
case R.id.logout: case R.id.logout:
logout(); logout();
return true; return true;
@ -851,6 +872,19 @@ public class OnlineActivity extends CommonActivity {
initMenu(); initMenu();
List<PackageInfo> pkgs = getPackageManager()
.getInstalledPackages(0);
for (PackageInfo p : pkgs) {
if ("org.fox.ttrss.key".equals(p.packageName)) {
Log.d(TAG, "license apk found");
menu.findItem(R.id.donate).setVisible(false);
toast(R.string.donate_thanks);
break;
}
}
return true; return true;
} }