Search in sources :

Example 6 with EntryManager

use of com.newsrob.EntryManager in project newsrob by marianokamp.

the class ArticleViewHelper method createArticleMenu.

static void createArticleMenu(final Menu menu, final Activity owningActivity, final Entry selectedEntry) {
    final EntryManager entryManager = EntryManager.getInstance(owningActivity);
    final boolean isArticleContextMenu = menu instanceof ContextMenu;
    if (isArticleContextMenu)
        ((ContextMenu) menu).setHeaderTitle("Article");
    final boolean alternateHRefAvailable = (selectedEntry != null && selectedEntry.getAlternateHRef() != null);
    if (selectedEntry == null) {
        Log.e(TAG, "Oops. SelectedEntry was null.");
        return;
    }
    final boolean isProVersion = entryManager.isProVersion();
    if (isProVersion && entryManager.isGoogleTv() && (selectedEntry.getReadState() == ReadState.READ || selectedEntry.getReadState() == ReadState.UNREAD))
        menu.add(0, MENU_ITEM_PIN_ARTICLE_ID, 1, "Pin").setIcon(android.R.drawable.btn_star);
    if (selectedEntry.getReadState() == ReadState.READ)
        menu.add(0, MENU_ITEM_MARK_ENTRY_UNREAD_ID, 2, R.string.menu_mark_as_unread).setIcon(android.R.drawable.checkbox_on_background);
    else
        menu.add(0, MENU_ITEM_MARK_ENTRY_READ_ID, 2, R.string.menu_mark_as_read).setIcon(android.R.drawable.checkbox_on_background);
    if (isArticleContextMenu) {
        if (selectedEntry.isStarred())
            menu.add(0, MENU_ITEM_UNSTAR_ID, 3, R.string.menu_item_unstar).setIcon(android.R.drawable.btn_star_big_off);
        else
            menu.add(0, MENU_ITEM_STAR_ID, 3, R.string.menu_item_star).setIcon(android.R.drawable.btn_star_big_off);
    }
    Uri uri = null;
    if (alternateHRefAvailable)
        uri = Uri.parse(selectedEntry.getAlternateHRef());
    menu.add(0, MENU_ITEM_SHOW_IN_BROWSER_ID, 5, R.string.menu_show_in_browser).setTitleCondensed(U.t(owningActivity, R.string.menu_show_in_browser_condensed)).setIntent(new Intent(Intent.ACTION_VIEW, uri)).setIcon(android.R.drawable.ic_menu_view).setEnabled(alternateHRefAvailable);
    menu.add(0, MENU_ITEM_SHARE_LINK_ID, 6, R.string.menu_item_share_link).setIntent(Intent.createChooser(createShareLinkSendIntent(selectedEntry), "Share Link")).setIcon(android.R.drawable.ic_menu_share).setEnabled(alternateHRefAvailable);
    if (selectedEntry.getContent() != null)
        System.out.println("selectedEntry.getContent().length() > 100=" + (selectedEntry.getContent().length() > 100));
    if (false)
        menu.add(0, MENU_ITEM_SHARE_ARTICLE_ID, 7, "Share Article").setIntent(Intent.createChooser(createShareArticleSendIntent(selectedEntry), "Share Article")).setIcon(android.R.drawable.ic_menu_share).setEnabled(false && alternateHRefAvailable && selectedEntry.getContent() != null && selectedEntry.getContent().length() > 100);
    menu.add(0, MENU_ITEM_REFRESH_CONTENT_ID, 13, "Refresh Content").setIcon(android.R.drawable.ic_menu_close_clear_cancel).setEnabled(selectedEntry.getDownloaded() != Entry.STATE_NOT_DOWNLOADED && entryManager.getStorageAdapter().canWrite());
    menu.add(0, MENU_ITEM_MANAGE_FEED_ID, 14, R.string.menu_item_manage_feed).setIcon(android.R.drawable.ic_menu_manage).setEnabled(selectedEntry.getFeedId() != 0l);
    menu.add(0, MENU_ITEM_SHOW_ARTICLE_INFO_ID, 15, R.string.menu_item_show_article_info);
    if ("1".equals(NewsRob.getDebugProperties(owningActivity).getProperty("enableBoom", "0")))
        menu.add(0, MENU_ITEM_BOOM_ID, 21, "Boom!");
    if (entryManager.canNewsRobProBeBought()) {
        final Intent viewIntent = new Intent(Intent.ACTION_VIEW);
        viewIntent.setData(Uri.parse("market://details?id=" + EntryManager.PRO_PACKAGE_NAME));
        menu.add(0, MENU_ITEM_BUY_NEWSROB_PRO, 31, "Buy NewsRob Pro!").setIntent(viewIntent);
    }
}
Also used : ContextMenu(android.view.ContextMenu) Intent(android.content.Intent) EntryManager(com.newsrob.EntryManager) Uri(android.net.Uri)

Example 7 with EntryManager

use of com.newsrob.EntryManager in project newsrob by marianokamp.

the class SettingsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final EntryManager em = EntryManager.getInstance(this);
    addPreferencesFromResource(R.xml.settings);
    getPreferenceScreen().setOnPreferenceChangeListener(em);
    if (SDKVersionUtil.getVersion() < 8)
        disableSetting(em, EntryManager.SETTINGS_PLUGINS, "Froyo+");
    if (SDKVersionUtil.getVersion() < 11) {
        disableSetting(em, EntryManager.SETTINGS_HW_ACCEL_LISTS_ENABLED, "HC+ only");
        disableSetting(em, EntryManager.SETTINGS_HW_ACCEL_ADV_ENABLED, "HC+ only");
    }
    if (!em.isProVersion()) {
        disableSetting(em, EntryManager.SETTINGS_KEEP_STARRED);
        disableSetting(em, EntryManager.SETTINGS_KEEP_SHARED);
        disableSetting(em, EntryManager.SETTINGS_KEEP_NOTES);
        disableSetting(em, EntryManager.SETTINGS_UI_THEME);
        disableSetting(em, EntryManager.SETTINGS_SYNC_NEWSROB_ONLY_ENABLED);
    }
    if (em.shouldHWZoomControlsBeDisabled()) {
        Preference pref = getPreferenceScreen().findPreference(EntryManager.SETTINGS_HOVERING_ZOOM_CONTROLS_ENABLED);
        if (pref != null) {
            pref.setEnabled(false);
            if (pref.getSummary() != null)
                pref.setSummary("Disabled until HTC fixes a bug that hurts this function. Sorry.");
        }
    }
    if (em.shouldSyncInProgressNotificationBeDisabled()) {
        Preference pref = getPreferenceScreen().findPreference(EntryManager.SETTINGS_SYNC_IN_PROGRESS_NOTIFICATION);
        if (pref != null) {
            pref.setEnabled(false);
            if (pref.getSummary() != null)
                pref.setSummary("Disabled until HTC/Dell fixes a bug that hurts this function. Sorry.");
        }
    }
    if (em.shouldActionBarLocationOnlyAllowGone()) {
        ListPreference pref = (ListPreference) getPreferenceScreen().findPreference(EntryManager.SETTINGS_UI_ACTION_BAR_LOCATION);
        if (pref != null) {
            pref.setEnabled(false);
            CharSequence[] seq = pref.getEntries();
            CharSequence[] newSeq = new CharSequence[] { seq[2] };
            pref.setEntries(newSeq);
            getPreferenceScreen().removePreference(pref);
        }
    }
    final Preference p = getPreferenceScreen().findPreference(EntryManager.SETTINGS_USAGE_DATA_PERMISSION_GRANTED);
    p.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            Dialog dialog = DashboardListActivity.createUsageDataCollectionPermissionDialog(em, SettingsActivity.this);
            dialog.show();
            return true;
        }
    });
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) Preference(android.preference.Preference) ListPreference(com.newsrob.preference.ListPreference) Dialog(android.app.Dialog) ListPreference(com.newsrob.preference.ListPreference) EntryManager(com.newsrob.EntryManager)

Example 8 with EntryManager

use of com.newsrob.EntryManager in project newsrob by marianokamp.

the class AccountListActivity method doAuth.

protected void doAuth(final String accountName) {
    final IAuthenticationCallback callback = new IAuthenticationCallback() {

        @Override
        public void onError(Exception e) {
            AccountListActivity.this.onError(e);
        }

        @Override
        public void onAuthTokenReceived(String googleAccount, String authToken) {
            EntryManager entryManager = EntryManager.getInstance(AccountListActivity.this);
            entryManager.doLogin(googleAccount, authToken);
            LoginActivity.onSuccess(entryManager, googleAccount);
            SDK9Helper.apply(entryManager.getSharedPreferences().edit().remove(EntryManager.SETTINGS_PASS));
            AccountListActivity.this.finish();
        }
    };
    accountManagementUtils.getAuthToken(AccountListActivity.this, handler, callback, accountName);
}
Also used : IAuthenticationCallback(com.newsrob.auth.IAuthenticationCallback) EntryManager(com.newsrob.EntryManager) IOException(java.io.IOException) BadTokenException(android.view.WindowManager.BadTokenException)

Example 9 with EntryManager

use of com.newsrob.EntryManager in project newsrob by marianokamp.

the class UnreadWidgetPrefActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.configure_unread_widget);
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {
        appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    }
    setResult(RESULT_CANCELED);
    EntryManager entryManager = EntryManager.getInstance(this);
    if (!entryManager.isProVersion()) {
        Toast.makeText(this, "Simple Launcher Widget created.\nWidget configurable in the Pro version.", Toast.LENGTH_LONG).show();
        // finish();
        WidgetPreferences widgetPrefs = new WidgetPreferences();
        widgetPrefs.setLabel("NewsRob");
        widgetPrefs.setStartingActivityName(DashboardListActivity.class.getName());
        doCreateWidget(widgetPrefs, entryManager, null, null);
    }
    wizard = new UnreadWidgetPrefWizard(this) {

        @Override
        void wizardFinished() {
            createWidget();
        }
    };
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) DashboardListActivity(com.newsrob.DashboardListActivity) EntryManager(com.newsrob.EntryManager)

Aggregations

EntryManager (com.newsrob.EntryManager)9 Intent (android.content.Intent)3 DashboardListActivity (com.newsrob.DashboardListActivity)2 ArticleListActivity (com.newsrob.activities.ArticleListActivity)2 Dialog (android.app.Dialog)1 PendingIntent (android.app.PendingIntent)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 Preference (android.preference.Preference)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 ContextMenu (android.view.ContextMenu)1 BadTokenException (android.view.WindowManager.BadTokenException)1 RemoteViews (android.widget.RemoteViews)1 IAuthenticationCallback (com.newsrob.auth.IAuthenticationCallback)1 ListPreference (com.newsrob.preference.ListPreference)1 Timing (com.newsrob.util.Timing)1 IOException (java.io.IOException)1