#1644 Stories shortcut dialog

This commit is contained in:
sictiru 2023-03-12 20:12:57 -07:00
parent 86b5861b51
commit 3e8ff61104
6 changed files with 505 additions and 7 deletions

View file

@ -10,10 +10,7 @@ import androidx.fragment.app.DialogFragment
import com.newsblur.R
import com.newsblur.activity.*
import com.newsblur.database.BlurDatabaseHelper
import com.newsblur.fragment.FolderListFragment
import com.newsblur.fragment.LoginAsDialogFragment
import com.newsblur.fragment.LogoutDialogFragment
import com.newsblur.fragment.NewslettersFragment
import com.newsblur.fragment.*
import com.newsblur.service.NBSyncService
import com.newsblur.util.ListTextSize
import com.newsblur.util.ListTextSize.Companion.fromSize
@ -44,6 +41,11 @@ class MainContextMenuDelegateImpl(
menu.findItem(R.id.menu_loginas).isVisible = true
}
// TODO uncomment
// if (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
ThemeValue.DARK -> menu.findItem(R.id.menu_theme_dark).isChecked = true
@ -184,10 +186,15 @@ class MainContextMenuDelegateImpl(
true
}
R.id.menu_newsletters -> {
val newFragment: DialogFragment = NewslettersFragment()
val newFragment = NewslettersFragment()
newFragment.show(activity.supportFragmentManager, NewslettersFragment::class.java.name)
true
}
R.id.menu_shortcuts -> {
val newFragment = StoryShortcutsFragment()
newFragment.show(activity.supportFragmentManager, StoryShortcutsFragment::class.java.name)
true
}
else -> false
}
}

View file

@ -15,8 +15,7 @@ import com.newsblur.util.setViewVisible
class NewslettersFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val view = layoutInflater.inflate(R.layout.newsletter_dialog, null)
val binding: NewsletterDialogBinding = NewsletterDialogBinding.bind(view)
val binding = NewsletterDialogBinding.inflate(layoutInflater)
val emailAddress = generateEmail()
binding.txtEmail.text = emailAddress

View file

@ -0,0 +1,44 @@
package com.newsblur.fragment
import android.app.Dialog
import android.graphics.Typeface
import android.os.Bundle
import android.text.Spannable
import android.text.SpannableString
import android.text.style.AbsoluteSizeSpan
import android.text.style.StyleSpan
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import com.newsblur.R
import com.newsblur.databinding.StoryShortcutsDialogBinding
class StoryShortcutsFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val binding = StoryShortcutsDialogBinding.inflate(layoutInflater)
SpannableString(getString(R.string.short_share_this_story_key)).apply {
shiftKeySpannable()
}.also {
binding.txtShareStoryKey.text = it
}
SpannableString(getString(R.string.short_page_up_key)).apply {
shiftKeySpannable()
}.also {
binding.txtPageUpKey.text = it
}
return AlertDialog.Builder(requireContext()).apply {
setView(binding.root)
setPositiveButton(android.R.string.ok, null)
}.create()
}
private fun SpannableString.shiftKeySpannable() {
setSpan(AbsoluteSizeSpan(17, true),
0, 1, Spannable.SPAN_INCLUSIVE_INCLUSIVE)
setSpan(StyleSpan(Typeface.BOLD),
0, 1, Spannable.SPAN_INCLUSIVE_INCLUSIVE)
}
}

View file

@ -0,0 +1,397 @@
<?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/stories_shortcuts"
android:textSize="18sp"
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"
android:text="@string/short_next_story"
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_next_story_key_j"
android:textSize="14sp" />
</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"
android:text="@string/short_next_story"
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_next_story_key_down"
android:textSize="17sp"
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"
android:text="@string/short_previous_story"
android:textSize="14sp" />
<androidx.appcompat.widget.AppCompatTextView
style="?defaultText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="@string/short_previous_story_key_k"
android:textSize="14sp" />
</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"
android:text="@string/short_previous_story"
android:textSize="14sp" />
<androidx.appcompat.widget.AppCompatTextView
style="?defaultText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="@string/short_previous_story_key_up"
android:textSize="17sp"
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"
android:text="@string/short_text_view"
android:textSize="14sp" />
<androidx.appcompat.widget.AppCompatTextView
style="?defaultText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="@string/short_text_view_key"
android:textSize="17sp"
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"
android:text="@string/short_page_down"
android:textSize="14sp" />
<androidx.appcompat.widget.AppCompatTextView
style="?defaultText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="@string/short_page_down_key"
android:textSize="14sp" />
</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"
android:text="@string/short_page_up"
android:textSize="14sp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/txt_page_up_key"
style="?defaultText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="@string/short_page_up_key"
android:textSize="14sp" />
</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"
android:text="@string/short_next_unread_story"
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_next_unread_story_key"
android:textSize="14sp" />
</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"
android:text="@string/short_toggle_read_unread"
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_toggle_read_unread_key_u"
android:textSize="14sp" />
</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"
android:text="@string/short_toggle_read_unread"
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_toggle_read_unread_key_m"
android:textSize="14sp" />
</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"
android:text="@string/short_save_unsave_story"
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_save_unsave_story_key"
android:textSize="14sp" />
</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"
android:text="@string/short_open_in_browser"
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_in_browser_key_o"
android:textSize="14sp" />
</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"
android:text="@string/short_open_in_browser"
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_in_browser_key_v"
android:textSize="14sp" />
</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"
android:text="@string/short_share_this_story"
android:textSize="15sp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/txt_share_story_key"
style="?defaultText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="@string/short_share_this_story_key"
android:textSize="14sp" />
</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"
android:text="@string/short_scroll_to_comments"
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_scroll_to_comments_key"
android:textSize="14sp" />
</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"
android:text="@string/short_open_story_trainer"
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_story_trainer_key"
android:textSize="14sp" />
</FrameLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</ScrollView>

View file

@ -31,6 +31,11 @@
android:title="@string/menu_newsletters"
app:showAsAction="never" />
<item android:id="@+id/menu_shortcuts"
android:title="@string/menu_shortcuts"
app:showAsAction="never"
android:visible="false" />
<item android:id="@+id/menu_text_size"
android:title="@string/menu_text_size" >
<menu>

View file

@ -274,6 +274,9 @@
<string name="setup_instructions_details">To read your email newsletters in NewsBlur, forward your newsletters to your custom email address shown above.\n\nIn Gmail, go to Settings > Forwarding and click on Add a forwarding address. Add your custom NewsBlur email address.\n\nGmail will walk you through confirming the email address. You\'ll want to come back to NewsBlur and look for the confirmation email under the "Newsletters" folder.\n\nNext, create a filter with all of your newsletters so that they forward to the custom address on NewsBlur.</string>
<string name="copy_email">Copy email</string>
<string name="stories_shortcuts">Stories shortcuts</string>
<string name="feeds_shortcuts">Feeds shortcuts</string>
<string name="import_export">Import/Export…</string>
<string name="settings">Preferences…</string>
<string name="menu_mute_sites">Mute Sites…</string>
@ -285,6 +288,7 @@
<string name="title_no_subscriptions">No active subscriptions detected</string>
<string name="title_widget_loading">Loading…</string>
<string name="menu_newsletters">Newsletters…</string>
<string name="menu_shortcuts">Shortcuts…</string>
<string name="import_export_title">Import/Export OPML</string>
<string name="notifications_title">Notifications</string>
@ -748,5 +752,47 @@
<string name="unread_stories">Unread stories</string>
<string name="focused_stories">Focused stories</string>
<string name="saved_stories">Saved stories</string>
<string name="short_next_story">Next Story</string>
<string name="short_next_story_key_down">\u2193</string>
<string name="short_next_story_key_j">J</string>
<string name="short_previous_story">Previous Story</string>
<string name="short_previous_story_key_up">\u2191</string>
<string name="short_previous_story_key_k">K</string>
<string name="short_text_view">Text View</string>
<string name="short_text_view_key">\u21E7 \u23CE</string>
<string name="short_page_down">Page Down</string>
<string name="short_page_down_key">space</string>
<string name="short_page_up">Page Up</string>
<string name="short_page_up_key">\u21E7 space</string>
<string name="short_next_unread_story">Next Unread Story</string>
<string name="short_next_unread_story_key">N</string>
<string name="short_toggle_read_unread">Toggle Read/Unread</string>
<string name="short_toggle_read_unread_key_u">U</string>
<string name="short_toggle_read_unread_key_m">M</string>
<string name="short_save_unsave_story">Save/Unsave Story</string>
<string name="short_save_unsave_story_key">S</string>
<string name="short_open_in_browser">Open in Browser</string>
<string name="short_open_in_browser_key_o">O</string>
<string name="short_open_in_browser_key_v">V</string>
<string name="short_share_this_story">Share this Story</string>
<string name="short_share_this_story_key">\u21E7 S</string>
<string name="short_scroll_to_comments">Scroll to Comments</string>
<string name="short_scroll_to_comments_key">C</string>
<string name="short_open_story_trainer">Open Story Trainer</string>
<string name="short_open_story_trainer_key">T</string>
<!-- ⌥ (option): U+2325-->
</resources>