mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Stories keyboard shortcuts ui
This commit is contained in:
parent
3e8ff61104
commit
e9bc6086b6
8 changed files with 205 additions and 44 deletions
|
@ -11,6 +11,7 @@ import com.newsblur.R
|
|||
import com.newsblur.activity.*
|
||||
import com.newsblur.database.BlurDatabaseHelper
|
||||
import com.newsblur.fragment.*
|
||||
import com.newsblur.keyboard.KeyboardManager
|
||||
import com.newsblur.service.NBSyncService
|
||||
import com.newsblur.util.ListTextSize
|
||||
import com.newsblur.util.ListTextSize.Companion.fromSize
|
||||
|
@ -41,10 +42,9 @@ class MainContextMenuDelegateImpl(
|
|||
menu.findItem(R.id.menu_loginas).isVisible = true
|
||||
}
|
||||
|
||||
// TODO uncomment
|
||||
// if (hasHardwareKeyboard(activity)) {
|
||||
// menu.findItem(R.id.menu_shortcuts).isVisible = true
|
||||
// }
|
||||
if (KeyboardManager.hasHardwareKeyboard(activity)) {
|
||||
menu.findItem(R.id.menu_shortcuts).isVisible = true
|
||||
}
|
||||
|
||||
when (PrefsUtils.getSelectedTheme(activity)) {
|
||||
ThemeValue.LIGHT -> menu.findItem(R.id.menu_theme_light).isChecked = true
|
||||
|
@ -191,8 +191,8 @@ class MainContextMenuDelegateImpl(
|
|||
true
|
||||
}
|
||||
R.id.menu_shortcuts -> {
|
||||
val newFragment = StoryShortcutsFragment()
|
||||
newFragment.show(activity.supportFragmentManager, StoryShortcutsFragment::class.java.name)
|
||||
val newFragment = FeedsShortcutFragment()
|
||||
newFragment.show(activity.supportFragmentManager, FeedsShortcutFragment::class.java.name)
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.newsblur.fragment
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import com.newsblur.databinding.FeedsShortcutsDialogBinding
|
||||
|
||||
class FeedsShortcutFragment : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val binding = FeedsShortcutsDialogBinding.inflate(layoutInflater)
|
||||
|
||||
return AlertDialog.Builder(requireContext()).apply {
|
||||
setView(binding.root)
|
||||
setPositiveButton(android.R.string.ok, null)
|
||||
}.create()
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ import com.newsblur.di.StoryImageCache
|
|||
import com.newsblur.domain.Classifier
|
||||
import com.newsblur.domain.Story
|
||||
import com.newsblur.domain.UserDetails
|
||||
import com.newsblur.keyboard.KeyboardManager
|
||||
import com.newsblur.network.APIManager
|
||||
import com.newsblur.service.NBSyncReceiver.Companion.UPDATE_INTEL
|
||||
import com.newsblur.service.NBSyncReceiver.Companion.UPDATE_SOCIAL
|
||||
|
@ -263,6 +264,10 @@ class ReadingItemFragment : NbFragment(), PopupMenu.OnMenuItemClickListener {
|
|||
menu.findItem(R.id.menu_reading_save).setTitle(if (story!!.starred) R.string.menu_unsave_story else R.string.menu_save_story)
|
||||
if (fs!!.isFilterSaved || fs!!.isAllSaved || fs!!.singleSavedTag != null) menu.findItem(R.id.menu_reading_markunread).isVisible = false
|
||||
|
||||
if (KeyboardManager.hasHardwareKeyboard(requireContext())) {
|
||||
menu.findItem(R.id.menu_shortcuts).isVisible = true
|
||||
}
|
||||
|
||||
when (PrefsUtils.getSelectedTheme(requireContext())) {
|
||||
ThemeValue.LIGHT -> menu.findItem(R.id.menu_theme_light).isChecked = true
|
||||
ThemeValue.DARK -> menu.findItem(R.id.menu_theme_dark).isChecked = true
|
||||
|
@ -317,6 +322,11 @@ class ReadingItemFragment : NbFragment(), PopupMenu.OnMenuItemClickListener {
|
|||
feedUtils.sendStoryFull(story, requireContext())
|
||||
true
|
||||
}
|
||||
R.id.menu_shortcuts -> {
|
||||
val newFragment = StoryShortcutsFragment()
|
||||
newFragment.show(requireActivity().supportFragmentManager, StoryShortcutsFragment::class.java.name)
|
||||
true
|
||||
}
|
||||
R.id.menu_text_size_xs -> {
|
||||
setTextSizeStyle(ReadingTextSize.XS)
|
||||
true
|
||||
|
|
|
@ -36,7 +36,7 @@ class StoryShortcutsFragment : DialogFragment() {
|
|||
}
|
||||
|
||||
private fun SpannableString.shiftKeySpannable() {
|
||||
setSpan(AbsoluteSizeSpan(17, true),
|
||||
setSpan(AbsoluteSizeSpan(18, true),
|
||||
0, 1, Spannable.SPAN_INCLUSIVE_INCLUSIVE)
|
||||
setSpan(StyleSpan(Typeface.BOLD),
|
||||
0, 1, Spannable.SPAN_INCLUSIVE_INCLUSIVE)
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="25dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/feeds_shortcuts"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:text="@string/short_open_all_stories"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_open_all_stories_key"
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:text="@string/short_switch_views"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_switch_views_key_left"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:text="@string/short_switch_views"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_switch_views_key_right"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:text="@string/short_add_site"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_add_site_key"
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</ScrollView>
|
|
@ -17,7 +17,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/stories_shortcuts"
|
||||
android:textSize="18sp"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<FrameLayout
|
||||
|
@ -39,7 +39,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_next_story_key_j"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
|||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:text="@string/short_next_story"
|
||||
android:textSize="15sp" />
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_next_story_key_down"
|
||||
android:textSize="17sp"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</FrameLayout>
|
||||
|
@ -78,7 +78,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:text="@string/short_previous_story"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
|
@ -86,7 +86,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_previous_story_key_k"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
@ -99,9 +99,9 @@
|
|||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:text="@string/short_previous_story"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
|
@ -109,7 +109,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_previous_story_key_up"
|
||||
android:textSize="17sp"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</FrameLayout>
|
||||
|
@ -117,15 +117,15 @@
|
|||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
android:layout_marginTop="7dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:text="@string/short_text_view"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
|
@ -133,7 +133,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_text_view_key"
|
||||
android:textSize="17sp"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</FrameLayout>
|
||||
|
@ -149,7 +149,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:text="@string/short_page_down"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
|
@ -157,22 +157,22 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_page_down_key"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:text="@string/short_page_up"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/txt_page_up_key"
|
||||
|
@ -181,7 +181,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_page_up_key"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
@ -204,14 +204,14 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_next_unread_story_key"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
|
@ -227,14 +227,14 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_toggle_read_unread_key_u"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
|
@ -250,14 +250,14 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_toggle_read_unread_key_m"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
|
@ -273,14 +273,14 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_save_unsave_story_key"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
|
@ -296,14 +296,14 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_open_in_browser_key_o"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
|
@ -319,20 +319,20 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_open_in_browser_key_v"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:text="@string/short_share_this_story"
|
||||
android:textSize="15sp" />
|
||||
|
||||
|
@ -343,7 +343,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_share_this_story_key"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
@ -366,14 +366,14 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_scroll_to_comments_key"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="?defaultText"
|
||||
|
@ -389,7 +389,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/short_open_story_trainer_key"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="15sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
|
|
@ -22,6 +22,12 @@
|
|||
app:showAsAction="never"
|
||||
android:title="@string/menu_send_story_full"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_shortcuts"
|
||||
android:title="@string/menu_shortcuts"
|
||||
android:visible="false"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item android:id="@+id/menu_text_size"
|
||||
android:title="@string/menu_text_size" >
|
||||
<menu>
|
||||
|
|
|
@ -793,6 +793,14 @@
|
|||
<string name="short_open_story_trainer">Open Story Trainer</string>
|
||||
<string name="short_open_story_trainer_key">T</string>
|
||||
|
||||
<!-- ⌥ (option): U+2325-->
|
||||
<string name="short_open_all_stories">Open All Stories</string>
|
||||
<string name="short_open_all_stories_key">\u2325 E</string>
|
||||
|
||||
<string name="short_switch_views">Switch Views</string>
|
||||
<string name="short_switch_views_key_left">\u2190</string>
|
||||
<string name="short_switch_views_key_right">\u2192</string>
|
||||
|
||||
<string name="short_add_site">Add Site</string>
|
||||
<string name="short_add_site_key">\u2325 A</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Reference in a new issue