diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index 5635a1e9e..56b8d0fe4 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -12,6 +12,7 @@ import android.widget.PopupWindow import androidx.activity.viewModels import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.tabs.TabLayout +import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.AppConst @@ -112,7 +113,8 @@ class BookSourceEditActivity : R.id.menu_share_str -> share(GSON.toJson(getSource())) R.id.menu_share_qr -> shareWithQr( GSON.toJson(getSource()), - getString(R.string.share_book_source) + getString(R.string.share_book_source), + ErrorCorrectionLevel.L ) R.id.menu_help -> showRuleHelp() R.id.menu_login -> getSource().let { diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt index 6b3f2f0de..a738a4633 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt @@ -10,6 +10,7 @@ import android.view.ViewTreeObserver import android.widget.EditText import android.widget.PopupWindow import androidx.activity.viewModels +import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.AppConst @@ -117,7 +118,8 @@ class RssSourceEditActivity : R.id.menu_share_str -> share(GSON.toJson(getRssSource())) R.id.menu_share_qr -> shareWithQr( GSON.toJson(getRssSource()), - getString(R.string.share_rss_source) + getString(R.string.share_rss_source), + ErrorCorrectionLevel.L ) R.id.menu_help -> showRuleHelp() } diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index c1d5e50e3..f11a7f890 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -21,6 +21,7 @@ import androidx.core.content.ContextCompat import androidx.core.content.FileProvider import androidx.core.content.edit import androidx.preference.PreferenceManager +import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel import io.legado.app.R import io.legado.app.constant.AppConst import java.io.File @@ -146,8 +147,12 @@ fun Context.share(text: String, title: String = getString(R.string.share)) { } @SuppressLint("SetWorldReadable") -fun Context.shareWithQr(text: String, title: String = getString(R.string.share)) { - val bitmap = QRCodeUtils.createQRCode(text) +fun Context.shareWithQr( + text: String, + title: String = getString(R.string.share), + errorCorrectionLevel: ErrorCorrectionLevel = ErrorCorrectionLevel.H +) { + val bitmap = QRCodeUtils.createQRCode(text, errorCorrectionLevel = errorCorrectionLevel) if (bitmap == null) { toastOnUi(R.string.text_too_long_qr_error) } else { diff --git a/app/src/main/java/io/legado/app/utils/QRCodeUtils.kt b/app/src/main/java/io/legado/app/utils/QRCodeUtils.kt index 366abfbe3..2a42839d6 100644 --- a/app/src/main/java/io/legado/app/utils/QRCodeUtils.kt +++ b/app/src/main/java/io/legado/app/utils/QRCodeUtils.kt @@ -28,7 +28,7 @@ object QRCodeUtils { * @param heightPix 二维码的高 * @param logo 二维码中间的logo * @param ratio logo所占比例 因为二维码的最大容错率为30%,所以建议ratio的范围小于0.3 - * @return + * @param errorCorrectionLevel */ fun createQRCode( content: String,