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

Show toast when importing without the app being started at least once #15692

Merged
merged 1 commit into from
Feb 28, 2024
Merged
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
4 changes: 0 additions & 4 deletions AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,6 @@ open class DeckPicker :
}
}

private fun hasShownAppIntro(): Boolean {
return this.sharedPrefs().getBoolean(IntroductionActivity.INTRODUCTION_SLIDES_SHOWN, false)
}

/**
* Check if the current WebView version is older than the last supported version and if it is,
* inform the developer with a snackbar.
Expand Down
5 changes: 5 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/IntentHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ class IntentHandler : Activity() {

private fun handleFileImport(intent: Intent, reloadIntent: Intent, action: String?) {
Timber.i("Handling file import")
if (!hasShownAppIntro()) {
Timber.i("Trying to import a file when the app was not started at all")
showThemedToast(this, R.string.app_not_initialized, false)
return
}
val importResult = handleFileImport(this, intent)
// attempt to delete the downloaded deck if it is a shared deck download import
if (intent.hasExtra(SharedDecksDownloadFragment.EXTRA_IS_SHARED_DOWNLOAD)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.ichi2.anki

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.result.ActivityResult
Expand Down Expand Up @@ -90,3 +91,7 @@ class IntroductionActivity : AnkiActivity() {
const val INTRODUCTION_SLIDES_SHOWN = "IntroductionSlidesShown"
}
}

internal fun Context.hasShownAppIntro(): Boolean {
return sharedPrefs().getBoolean(IntroductionActivity.INTRODUCTION_SLIDES_SHOWN, false)
}
3 changes: 3 additions & 0 deletions AnkiDroid/src/main/res/values/02-strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@
<string name="intro_get_started" comment="Action to start AnkiDroid for the first time without syncing from AnkiWeb">Get Started</string>
<string name="intro_sync_from_ankiweb">Sync from AnkiWeb</string>

<!-- IntentHandler -->
<string name="app_not_initialized">AnkiDroid is not initialized yet. Please open AnkiDroid once, then try again</string>

<string name="already_logged_in">Already logged in</string>

<!-- Deck Creation -->
Expand Down
Loading