Skip to content

Commit

Permalink
fix: login
Browse files Browse the repository at this point in the history
转为扫码登陆
  • Loading branch information
sgpublic committed Aug 20, 2024
1 parent 25db6d5 commit 3d7cafd
Show file tree
Hide file tree
Showing 41 changed files with 1,258 additions and 169 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ local.properties
version.properties

buildSrc/build/
.kotlin/
47 changes: 25 additions & 22 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ fun VariantDimension.buildConfigField(name: String, value: Int) {
}

android {
compileSdk = 33
buildToolsVersion = "33.0.0"
compileSdk = 34
namespace = "io.github.sgpublic.bilidownload"

val properties = file("./sign/sign.properties")
Expand Down Expand Up @@ -75,8 +74,8 @@ android {

defaultConfig {
applicationId = "io.github.sgpublic.bilidownload"
minSdk = 26
targetSdk = 33
minSdk = 29
targetSdk = 34
versionCode = VersionGen.COMMIT_VERSION
versionName = "3.5.0".also {
buildConfigField("ORIGIN_VERSION_NAME", it)
Expand Down Expand Up @@ -147,7 +146,11 @@ android {
kotlinOptions {
jvmTarget = "11"
}
packagingOptions {
buildFeatures {
buildConfig = true
viewBinding = true
}
packaging {
resources.excludes.addAll(listOf(
"META-INF/DEPENDENCIES",
"META-INF/NOTICE",
Expand Down Expand Up @@ -188,35 +191,35 @@ kapt {
}

dependencies {
implementation("androidx.test.ext:junit-ktx:1.1.4")
implementation("androidx.test.ext:junit-ktx:1.2.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.4")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
androidTestImplementation("androidx.test:runner:1.5.1")
androidTestImplementation("androidx.test:rules:1.5.0")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
androidTestImplementation("androidx.test:runner:1.6.2")
androidTestImplementation("androidx.test:rules:1.6.1")
implementation(kotlin("reflect"))

implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("com.google.android.material:material:1.7.0")
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("androidx.navigation:navigation-fragment-ktx:2.5.3")
implementation("androidx.navigation:navigation-fragment-ktx:2.7.7")

/* https://github.com/zhpanvip/BannerViewPager */
implementation("com.github.zhpanvip:BannerViewPager:3.5.7")
/* https://github.com/yanzhenjie/Sofia */
implementation("com.yanzhenjie:sofia:1.0.5")
/* https://github.com/scwang90/MultiWaveHeader */
implementation("com.scwang.wave:MultiWaveHeader:1.0.0")
implementation("io.github.sgpublic:MultiWaveHeader:1.0.2")
/* https://github.com/li-xiaojun/XPopup */
implementation("com.github.li-xiaojun:XPopup:2.9.1")
/* https://github.com/zxing/zxing qrcode */
implementation("com.google.zxing:core:3.5.0")
// /* https://github.com/KwaiAppTeam/AkDanmaku */
// implementation("com.kuaishou:akdanmaku:1.0.3")
/* https://docs.geetest.com/sensebot/deploy/client/android */
implementation("com.geetest.sensebot:sensebot:4.3.7")
implementation("com.geetest.sensebot:sensebot:4.4.2.1")

/* https://github.com/sgpublic/ExSharedPreference */
implementation("io.github.sgpublic:exsp-runtime:${Dep.EXSP}")
Expand All @@ -236,8 +239,8 @@ dependencies {
implementation("com.google.protobuf:protobuf-java:${Dep.Proto}")
// 阿b用的 cronet,如果用 okhttp 会导致 io.grpc.StatusRuntimeException: INTERNAL: Received unexpected EOS on DATA frame from server.
implementation("io.grpc:grpc-cronet:${Dep.GrpcJava}")
implementation("com.google.android.gms:play-services-cronet:18.0.1")
implementation("org.chromium.net:cronet-fallback:106.5249.126")
implementation("com.google.android.gms:play-services-cronet:18.1.0")
implementation("org.chromium.net:cronet-fallback:119.6045.31")
implementation("io.grpc:grpc-android:${Dep.GrpcJava}")
implementation("io.grpc:grpc-protobuf:${Dep.GrpcJava}")
implementation("io.grpc:grpc-stub:${Dep.GrpcJava}")
Expand All @@ -258,13 +261,13 @@ dependencies {
kapt("me.laoyuyu.aria:compiler:${Dep.Aria}")

/* https://github.com/tony19/logback-android */
implementation("com.github.tony19:logback-android:2.0.0")
implementation("org.slf4j:slf4j-api:1.7.36")
implementation("com.github.tony19:logback-android:3.0.0")
implementation("org.slf4j:slf4j-api:2.0.13")

/* https://github.com/dromara/forest */
implementation("com.dtflys.forest:forest-core:1.5.26")
implementation("com.google.code.gson:gson:2.9.1")
implementation("com.squareup.okhttp3:okhttp:4.10.0")
implementation("com.google.code.gson:gson:2.10.1")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
}

/** 自动修改输出文件名并定位文件 */
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
android:name=".app.activity.LoginPwd"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize"/>
<activity
android:name=".app.activity.LoginSms"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize"/>
<activity
android:name=".app.activity.LoginQrcode"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize"/>
<activity
android:name=".app.activity.LoginValidateAccount"
android:windowSoftInputMode="adjustResize"/>
Expand All @@ -59,4 +67,8 @@
<service android:name=".app.service.DownloadService"
android:exported="false"/>
</application>

<queries>
<package android:name="tv.danmaku.bili" />
</queries>
</manifest>
13 changes: 6 additions & 7 deletions app/src/main/assets/js/ajax_interception.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
let verify = false;
XMLHttpRequest.prototype.reallyOpen = XMLHttpRequest.prototype.open;
let reallyOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
verify = (url.toString() === "https://passport.bilibili.com/x/safecenter/login/tel/verify");
this.reallyOpen(method, url, async, user, password);
Injection.logOnOpen(url.toString());
reallyOpen(method, url, async, user, password);
};
XMLHttpRequest.prototype.reallySend = XMLHttpRequest.prototype.send;
let reallySend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
if (body != null) {
Injection.setVerifyBody(body.toString());
}
this.reallySend(body);
};
reallySend(body);
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import io.github.sgpublic.exsp.ExPreference
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.json.JSONObject

@Deprecated("Use sms sending instead.")
class LoginPwd: BaseViewModelActivity<ActivityLoginPwdBinding, LoginPwdModel>() {
private val Token: TokenPreference by lazy { ExPreference.get() }
private val User: UserPreference by lazy { ExPreference.get() }
Expand All @@ -54,6 +56,7 @@ class LoginPwd: BaseViewModelActivity<ActivityLoginPwdBinding, LoginPwdModel>()
}
private val geetestBean: GT3ConfigBean by lazy {
return@lazy GT3ConfigBean().also {
it.isCanceledOnTouchOutside = false
it.listener = object : GT3Listener() {
override fun onReceiveCaptchaCode(p0: Int) { }
override fun onStatistics(p0: String?) { }
Expand Down Expand Up @@ -95,26 +98,27 @@ class LoginPwd: BaseViewModelActivity<ActivityLoginPwdBinding, LoginPwdModel>()
}
ViewModel.CaptchaData.observe(this) { data ->
ViewModel.Loading.postValue(false)
// geetestBean.api1Json = JSONObject().also {
// it.put("success", 1)
// it.put("challenge", data.geetest.challenge)
// it.put("gt", data.geetest.gt)
// it.put("token", data.token)
// }
// geetest.startCustomFlow()
XPopup.Builder(this)
.asCustom(GeetestDialog(this, data.url, {
ViewModel.Loading.postValue(false)
}, { validate ->
ViewModel.startGeetestAction(
data.token, data.geetest.challenge,
validate, "$validate|jordan",
ViewBinding.loginUsername.editText!!.text.takeOr(""),
ViewBinding.loginPassword.editText!!.text.takeOr(""),
::validatePhone
)
}))
.show()
log.debug("CaptchaData: $data")
geetestBean.api1Json = JSONObject().also {
it.put("success", 1)
it.put("challenge", data.geetest.challenge)
it.put("gt", data.geetest.gt)
it.put("token", data.token)
}
geetest.startCustomFlow()
// XPopup.Builder(this)
// .asCustom(GeetestDialog(this, data.url, {
// ViewModel.Loading.postValue(false)
// }, { validate ->
// ViewModel.startGeetestAction(
// data.token, data.geetest.challenge,
// validate, "$validate|jordan",
// ViewBinding.loginUsername.editText!!.text.takeOr(""),
// ViewBinding.loginPassword.editText!!.text.takeOr(""),
// ::validatePhone
// )
// }))
// .show()
}
ViewModel.LoginData.observe(this) { data ->
Token.accessToken = data.tokenInfo.accessToken
Expand Down Expand Up @@ -165,7 +169,8 @@ class LoginPwd: BaseViewModelActivity<ActivityLoginPwdBinding, LoginPwdModel>()
// }
// else -> url
// }
phoneValidate.launch(url)
ViewModel.getCaptcha()
// phoneValidate.launch(url)
}

override fun onViewSetup() {
Expand Down
Loading

0 comments on commit 3d7cafd

Please sign in to comment.