Skip to content

Commit

Permalink
fix known issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbxyyx committed Nov 8, 2024
1 parent 81fa2d4 commit 356f706
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
<activity
android:name=".VideoViewActivity2"
android:configChanges="orientation|screenSize"
android:exported="false"
android:screenOrientation="landscape" />
android:exported="false" />
<!--
<activity
android:name=".VideoViewActivity"
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/com/github/jsbxyyx/xbook/BookJavascript.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
import android.content.Context;
import android.webkit.JavascriptInterface;

import com.github.jsbxyyx.xbook.common.Common;
import com.github.jsbxyyx.xbook.common.IdUtil;
import com.github.jsbxyyx.xbook.common.LogUtil;
import com.github.jsbxyyx.xbook.common.SessionManager;
import com.github.jsbxyyx.xbook.common.UiUtils;
import com.github.jsbxyyx.xbook.data.BookDbHelper;
import com.github.jsbxyyx.xbook.data.bean.Book;
import com.github.jsbxyyx.xbook.data.bean.BookReader;

import java.util.Map;

/**
* @author jsbxyyx
* @since
Expand Down Expand Up @@ -50,4 +54,21 @@ public void toast(String text) {
UiUtils.showToast(text);
}

@JavascriptInterface
public String suid() {
String s = SessionManager.getSession();
Map<String, String> kvMap = Common.parseKv(s);
return kvMap.getOrDefault(Common.serv_userid, "");
}

@JavascriptInterface
public String vc() {
return UiUtils.getVersionCode() + "";
}

@JavascriptInterface
public String vn() {
return UiUtils.getVersionName();
}

}
10 changes: 10 additions & 0 deletions app/src/main/java/com/github/jsbxyyx/xbook/ProfileFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public void call(Profile profile, Throwable err) {
data.add("云同步本地");
data.add("设置");
data.add("意见反馈");
data.add("捐赠");
data.add("测试");
lv_profile.setAdapter(new ArrayAdapter(mActivity, R.layout.profile_item, R.id.tv_profile_item, data));
lv_profile.setOnItemClickListener((parent, view1, position, id) -> {
Expand All @@ -173,6 +174,8 @@ public void call(Profile profile, Throwable err) {
settings();
} else if (position == 2) {
issues();
} else if (position == 3) {
donate();
}
});

Expand Down Expand Up @@ -469,6 +472,13 @@ private void issues() {
startActivity(intent);
}

private void donate() {
Intent intent = new Intent(getContext(), VideoViewActivity2.class);
intent.putExtra("playUrl", "https://http2.idingdang.org/donate");
intent.putExtra("orientation", "v");
startActivity(intent);
}

private void test() {
LogUtil.d(TAG, "test: ");
LoadingDialog loading = new LoadingDialog(mActivity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void onClick(View view, String type, int position) {
LogUtil.d(TAG, "%s", playUrl);
Intent intent = new Intent(mActivity, VideoViewActivity2.class);
intent.putExtra("playUrl", playUrl);
intent.putExtra("orientation", "h");
startActivity(intent);
}
});
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/com/github/jsbxyyx/xbook/VideoViewActivity2.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.jsbxyyx.xbook;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

Expand All @@ -26,14 +26,22 @@ public class VideoViewActivity2 extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_view);

playUrl = getIntent().getStringExtra("playUrl");

if (Common.isBlank(playUrl)) {
UiUtils.showToast("没有播放地址");
return;
}

String orientation = getIntent().getStringExtra("orientation");
if ("v".equals(orientation) &&
getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else if ("h".equals(orientation) &&
getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}

webView = findViewById(R.id.wv_video_view);
GeckoSession session = new GeckoSession();
if (runtime == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,11 @@ public void onResponse(@NonNull Call call, @NonNull Response response) throws IO
long count = 0;
int n;
while (-1 != (n = input.read(buffer))) {
byte[] bytes = Common.xor(buffer, n, Common.MG_XOR);
output.write(bytes, 0, n);
if (magic > 0) {
output.write(Common.xor(buffer, n, Common.MG_XOR), 0, n);
} else {
output.write(buffer, 0, n);
}
count += n;
output.flush();
if (listener != null) {
Expand Down

0 comments on commit 356f706

Please sign in to comment.