mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
#1624 Add home screen shortcuts.
This commit is contained in:
parent
277c6bcd3a
commit
5543efac85
6 changed files with 75 additions and 4 deletions
|
@ -25,6 +25,10 @@
|
|||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data android:name="android.app.shortcuts"
|
||||
android:resource="@xml/shortcuts" />
|
||||
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
|
|
@ -695,4 +695,7 @@
|
|||
<string name="go_to_feed">Go to feed</string>
|
||||
|
||||
<string name="js_get_selection">(function(){return window.getSelection().toString()})()</string>
|
||||
|
||||
<string name="search">Search</string>
|
||||
<string name="add_feed">Add feed</string>
|
||||
</resources>
|
||||
|
|
40
clients/android/NewsBlur/res/xml-v25/shortcuts.xml
Normal file
40
clients/android/NewsBlur/res/xml-v25/shortcuts.xml
Normal file
|
@ -0,0 +1,40 @@
|
|||
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Keep in sync with ShortcutUtils-->
|
||||
<shortcut
|
||||
android:icon="@drawable/ic_search"
|
||||
android:shortcutId="all_stories_search"
|
||||
android:shortcutShortLabel="@string/search">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:targetClass="com.newsblur.activity.Main"
|
||||
android:targetPackage="com.newsblur">
|
||||
<extra
|
||||
android:name="shortcut_extra"
|
||||
android:value="shortcut_all_stories_search" />
|
||||
</intent>
|
||||
</shortcut>
|
||||
|
||||
<shortcut
|
||||
android:icon="@drawable/ak_icon_allstories"
|
||||
android:shortcutId="all_stories"
|
||||
android:shortcutShortLabel="@string/all_stories">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:targetClass="com.newsblur.activity.Main"
|
||||
android:targetPackage="com.newsblur">
|
||||
<extra
|
||||
android:name="shortcut_extra"
|
||||
android:value="shortcut_all_stories" />
|
||||
</intent>
|
||||
</shortcut>
|
||||
|
||||
<shortcut
|
||||
android:icon="@drawable/ic_menu_add_gray55"
|
||||
android:shortcutId="add_feed"
|
||||
android:shortcutShortLabel="@string/add_feed">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:targetClass="com.newsblur.activity.FeedSearchActivity"
|
||||
android:targetPackage="com.newsblur" />
|
||||
</shortcut>
|
||||
</shortcuts>
|
|
@ -64,9 +64,9 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
public static final String EXTRA_FEED_SET = "feed_set";
|
||||
public static final String EXTRA_STORY_HASH = "story_hash";
|
||||
public static final String EXTRA_WIDGET_STORY = "widget_story";
|
||||
private static final String STORY_ORDER = "storyOrder";
|
||||
private static final String READ_FILTER = "readFilter";
|
||||
private static final String DEFAULT_FEED_VIEW = "defaultFeedView";
|
||||
public static final String EXTRA_VISIBLE_SEARCH = "visibleSearch";
|
||||
private static final String STORY_ORDER = "storyOrder";
|
||||
private static final String READ_FILTER = "readFilter";
|
||||
private static final String BUNDLE_ACTIVE_SEARCH_QUERY = "activeSearchQuery";
|
||||
private ActivityItemslistBinding binding;
|
||||
|
||||
|
@ -88,7 +88,6 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
// the correct session, but that can be delayed by sync backup, so we try here to
|
||||
// reduce UI lag, or in case somehow we got redisplayed in a zero-story state
|
||||
feedUtils.prepareReadingSession(fs, false);
|
||||
|
||||
if (getIntent().getBooleanExtra(EXTRA_WIDGET_STORY, false)) {
|
||||
String hash = (String) getIntent().getSerializableExtra(EXTRA_STORY_HASH);
|
||||
UIUtils.startReadingActivity(fs, hash, this);
|
||||
|
@ -122,6 +121,9 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
binding.itemlistSearchQuery.setText(activeSearchQuery);
|
||||
binding.itemlistSearchQuery.setVisibility(View.VISIBLE);
|
||||
checkSearchQuery();
|
||||
} else if (getIntent().getBooleanExtra(EXTRA_VISIBLE_SEARCH, false)){
|
||||
binding.itemlistSearchQuery.setVisibility(View.VISIBLE);
|
||||
binding.itemlistSearchQuery.requestFocus();
|
||||
}
|
||||
|
||||
binding.itemlistSearchQuery.setOnKeyListener(new OnKeyListener() {
|
||||
|
|
|
@ -38,9 +38,11 @@ import com.newsblur.fragment.TextSizeDialogFragment;
|
|||
import com.newsblur.service.BootReceiver;
|
||||
import com.newsblur.service.NBSyncService;
|
||||
import com.newsblur.util.AppConstants;
|
||||
import com.newsblur.util.FeedSet;
|
||||
import com.newsblur.util.FeedUtils;
|
||||
import com.newsblur.util.PrefConstants.ThemeValue;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
import com.newsblur.util.ShortcutUtils;
|
||||
import com.newsblur.util.SpacingStyle;
|
||||
import com.newsblur.util.StateFilter;
|
||||
import com.newsblur.util.UIUtils;
|
||||
|
@ -130,6 +132,17 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
binding.mainProfileButton.setOnClickListener(v -> onClickProfileButton());
|
||||
binding.mainUserImage.setOnClickListener(v -> onClickUserButton());
|
||||
binding.mainSearchFeedsButton.setOnClickListener(v -> onClickSearchFeedsButton());
|
||||
|
||||
// Check whether it's a shortcut intent
|
||||
String shortcutExtra = getIntent().getStringExtra(ShortcutUtils.SHORTCUT_EXTRA);
|
||||
if (shortcutExtra != null && shortcutExtra.startsWith(ShortcutUtils.SHORTCUT_ALL_STORIES)) {
|
||||
Intent intent = new Intent(this, AllStoriesItemsList.class);
|
||||
intent.putExtra(ItemsList.EXTRA_FEED_SET, FeedSet.allFeeds());
|
||||
if (shortcutExtra.equals(ShortcutUtils.SHORTCUT_ALL_STORIES_SEARCH)) {
|
||||
intent.putExtra(ItemsList.EXTRA_VISIBLE_SEARCH, true);
|
||||
}
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package com.newsblur.util
|
||||
|
||||
object ShortcutUtils {
|
||||
|
||||
// Keep in sync with shortcuts.xml
|
||||
const val SHORTCUT_EXTRA = "shortcut_extra"
|
||||
const val SHORTCUT_ALL_STORIES = "shortcut_all_stories"
|
||||
const val SHORTCUT_ALL_STORIES_SEARCH = SHORTCUT_ALL_STORIES + "_search"
|
||||
}
|
Loading…
Add table
Reference in a new issue