Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: report bug shortcut #17906

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,11 @@ open class DeckPicker :
syncOnResume = true
}

if (intent.hasExtra(INTENT_REPORT_BUG)) {
Timber.i("DeckPicker:: Reporting bug, launched from shortcut")
ankiActivity.openUrl(Uri.parse(AnkiDroidApp.feedbackUrl))
}

setContentView(R.layout.homescreen)
enableToolbar()
handleStartup()
Expand Down Expand Up @@ -2566,6 +2571,9 @@ open class DeckPicker :
)

companion object {
/** Opens the url to report bug from the ShortcutManager */
const val INTENT_REPORT_BUG = "reportBug"

/**
* Result codes from other activities
*/
Expand Down
27 changes: 27 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/NavigationDrawerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.content.res.Configuration
import android.graphics.Bitmap
import android.graphics.Canvas
import android.os.Bundle
import android.view.KeyEvent
import android.view.LayoutInflater
Expand All @@ -33,6 +35,7 @@ import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.widget.Toolbar
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.content.pm.ShortcutInfoCompat
import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.graphics.drawable.IconCompat
Expand Down Expand Up @@ -478,6 +481,29 @@ abstract class NavigationDrawerActivity :
.setIntent(intentAddNote)
.build()

// Report bug shortcut
val intentReportBug = Intent(context, DeckPicker::class.java)
intentReportBug.action = Intent.ACTION_VIEW
intentReportBug.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
intentReportBug.putExtra(DeckPicker.INTENT_REPORT_BUG, true)

val iconDrawable = ContextCompat.getDrawable(context, R.drawable.ic_bug_report_black_24dp)?.mutate()
iconDrawable?.setTint(ContextCompat.getColor(context, R.color.wb_fg_color_inv))

val bitmap = Bitmap.createBitmap(iconDrawable!!.intrinsicWidth, iconDrawable.intrinsicHeight, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
iconDrawable.setBounds(0, 0, canvas.width, canvas.height)
iconDrawable.draw(canvas)

val reportBugShortcut =
ShortcutInfoCompat
.Builder(context, "reportBugShortcut")
.setShortLabel(context.getString(R.string.help_item_report_bug))
.setLongLabel(context.getString(R.string.help_item_report_bug))
.setIcon(IconCompat.createWithBitmap(bitmap))
.setIntent(intentReportBug)
.build()

// CardBrowser Shortcut
val intentCardBrowser = Intent(context, CardBrowser::class.java)
intentCardBrowser.action = Intent.ACTION_VIEW
Expand All @@ -496,6 +522,7 @@ abstract class NavigationDrawerActivity :
reviewCardsShortcut,
noteEditorShortcut,
cardBrowserShortcut,
reportBugShortcut,
),
)
}
Expand Down