Skip to content

Commit 76479ab

Browse files
Amit-kumar80844david-allison
authored andcommitted
refactor: fix Android Studio warnings
Co-authored-by: David Allison <62114487+david-allison@users.noreply.github.com>
1 parent 243fdec commit 76479ab

File tree

6 files changed

+10
-30
lines changed

6 files changed

+10
-30
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ package com.ichi2.anki
2323

2424
import android.annotation.SuppressLint
2525
import android.content.ActivityNotFoundException
26-
import android.content.ClipboardManager
2726
import android.content.Context
2827
import android.content.Intent
2928
import android.content.SharedPreferences
@@ -149,7 +148,6 @@ import com.ichi2.libanki.undoableOp
149148
import com.ichi2.themes.Themes
150149
import com.ichi2.themes.Themes.getResFromAttr
151150
import com.ichi2.ui.FixedEditText
152-
import com.ichi2.utils.ClipboardUtil.getText
153151
import com.ichi2.utils.HandlerUtils.newHandler
154152
import com.ichi2.utils.HashUtil.hashSetInit
155153
import com.ichi2.utils.Stopwatch
@@ -243,7 +241,6 @@ abstract class AbstractFlashcardViewer :
243241
internal var easeButton3: EaseButton? = null
244242
internal var easeButton4: EaseButton? = null
245243
protected var topBarLayout: RelativeLayout? = null
246-
private val clipboard: ClipboardManager? = null
247244
private var previousAnswerIndicator: PreviousAnswerIndicator? = null
248245

249246
private var currentEase: Ease? = null
@@ -282,9 +279,6 @@ abstract class AbstractFlashcardViewer :
282279
var cardContent: String? = null
283280
private set
284281

285-
private var viewerUrl: String? = null
286-
private val fadeDuration = 300
287-
288282
@VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
289283
internal lateinit var cardMediaPlayer: CardMediaPlayer
290284

@@ -403,7 +397,7 @@ abstract class AbstractFlashcardViewer :
403397
val diffX = abs(event.rawX - touchX)
404398
val diffY = abs(event.rawY - touchY)
405399
// If a click is not coming then we reset the touch
406-
if (diffX > Companion.CLICK_ACTION_THRESHOLD || diffY > Companion.CLICK_ACTION_THRESHOLD) {
400+
if (diffX > CLICK_ACTION_THRESHOLD || diffY > CLICK_ACTION_THRESHOLD) {
407401
hasBeenTouched = false
408402
}
409403
}
@@ -734,19 +728,6 @@ abstract class AbstractFlashcardViewer :
734728

735729
protected open fun answerFieldIsFocused(): Boolean = answerField != null && answerField!!.isFocused
736730

737-
protected fun clipboardHasText(): Boolean = !getText(clipboard).isNullOrEmpty()
738-
739-
/**
740-
* Returns the text stored in the clipboard or the empty string if the clipboard is empty or contains something that
741-
* cannot be converted to text.
742-
*
743-
* @return the text in clipboard or the empty string.
744-
*/
745-
private fun clipboardGetText(): CharSequence {
746-
val text = getText(clipboard)
747-
return text ?: ""
748-
}
749-
750731
val deckOptionsLauncher =
751732
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { _ ->
752733
Timber.i("Returned from deck options -> Restarting activity")
@@ -2073,7 +2054,7 @@ abstract class AbstractFlashcardViewer :
20732054
private fun isTouchingEdge(e1: MotionEvent): Boolean {
20742055
val height = touchLayer!!.height
20752056
val width = touchLayer!!.width
2076-
val margin = Companion.NO_GESTURE_BORDER_DIP * resources.displayMetrics.density + 0.5f
2057+
val margin = NO_GESTURE_BORDER_DIP * resources.displayMetrics.density + 0.5f
20772058
return e1.x < margin || e1.y < margin || height - e1.y < margin || width - e1.x < margin
20782059
}
20792060

@@ -2143,7 +2124,7 @@ abstract class AbstractFlashcardViewer :
21432124
private fun initShakeDetector() {
21442125
Timber.d("Initializing shake detector")
21452126
if (gestureProcessor.isBound(Gesture.SHAKE)) {
2146-
val sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager
2127+
val sensorManager = getSystemService(SENSOR_SERVICE) as SensorManager
21472128
shakeDetector =
21482129
ShakeDetector(this).apply {
21492130
start(sensorManager, SensorManager.SENSOR_DELAY_UI)
@@ -2456,7 +2437,7 @@ abstract class AbstractFlashcardViewer :
24562437
return true
24572438
}
24582439

2459-
when (val signalOrdinal = url.toSignal()) {
2440+
when (url.toSignal()) {
24602441
Signal.SIGNAL_UNHANDLED -> {}
24612442
Signal.SIGNAL_NOOP -> return true
24622443
Signal.TYPE_FOCUS -> return true

AnkiDroid/src/main/java/com/ichi2/anki/analytics/AcraAnalyticsInteraction.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import java.io.File
3030
* See <a href="https://github.com/ACRA/acra/wiki/Custom-Extensions">Custom Extensions</a>
3131
*/
3232
@AutoService(ReportInteraction::class)
33+
@Suppress("unused") // Not unused. ACRA dynamically loads this class
3334
class AcraAnalyticsInteraction : ReportInteraction {
3435
override fun performInteraction(
3536
context: Context,

AnkiDroid/src/main/java/com/ichi2/anki/analytics/UsageAnalytics.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ object UsageAnalytics {
377377
object Actions {
378378
// Analytics actions used in Help Dialog
379379
@AnalyticsConstant
380-
val OPENED_HELPDIALOG = "Opened HelpDialogBox"
380+
val OPENED_HELP_DIALOG = "Opened HelpDialogBox"
381381

382382
@AnalyticsConstant
383383
val OPENED_USING_ANKIDROID = "Opened Using AnkiDroid"

AnkiDroid/src/main/java/com/ichi2/anki/browser/BrowserColumnCollection.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import com.ichi2.anki.model.CardsOrNotes
2424
import com.ichi2.anki.model.CardsOrNotes.CARDS
2525
import com.ichi2.anki.model.CardsOrNotes.NOTES
2626
import com.ichi2.libanki.BrowserConfig
27+
import com.ichi2.libanki.BrowserConfig.ACTIVE_CARD_COLUMNS_KEY
28+
import com.ichi2.libanki.BrowserConfig.ACTIVE_NOTE_COLUMNS_KEY
2729
import com.ichi2.libanki.BrowserDefaults
30+
import net.ankiweb.rsdroid.Backend
2831
import timber.log.Timber
2932

3033
/**

AnkiDroid/src/main/java/com/ichi2/anki/dialogs/help/HelpDialog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class HelpDialog : DialogFragment() {
122122
private const val PAGE_TAG = "HelpMenuPage"
123123

124124
fun newHelpInstance(): HelpDialog {
125-
UsageAnalytics.sendAnalyticsEvent(Category.LINK_CLICKED, Actions.OPENED_HELPDIALOG)
125+
UsageAnalytics.sendAnalyticsEvent(Category.LINK_CLICKED, Actions.OPENED_HELP_DIALOG)
126126
return HelpDialog().apply {
127127
arguments =
128128
bundleOf(

AnkiDroid/src/main/java/com/ichi2/utils/ClipboardUtil.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ object ClipboardUtil {
5757

5858
fun getUri(clipboard: ClipboardManager?): Uri? = clipboard?.getFirstItem()?.uri
5959

60-
fun hasSVG(description: ClipDescription): Boolean = description.hasMimeType("image/svg+xml")
61-
6260
fun hasMedia(clipboard: ClipboardManager?): Boolean =
6361
clipboard
6462
?.primaryClip
@@ -79,9 +77,6 @@ object ClipboardUtil {
7977

8078
fun getDescription(clipboard: ClipboardManager?): ClipDescription? = clipboard?.primaryClip?.description
8179

82-
@CheckResult
83-
fun getText(clipboard: ClipboardManager?): CharSequence? = clipboard?.getFirstItem()?.text
84-
8580
@CheckResult
8681
fun getPlainText(
8782
clipboard: ClipboardManager?,

0 commit comments

Comments
 (0)