Skip to content

Commit

Permalink
fix radio bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Notsfsssf committed Apr 18, 2021
1 parent 017e02e commit 73fb23b
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 47 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ android {
applicationId packageName
minSdkVersion 21
targetSdkVersion 30
versionCode 10004051
versionCode 10004052
versionName "0.4.6 X"
}
compileOptions {
Expand Down
33 changes: 6 additions & 27 deletions android/app/src/main/kotlin/com/perol/pixez/Weiss.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ object Weiss {
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, WEISS_CHANNEL).setMethodCallHandler { call, result ->
when (call.method) {
"start" -> {
start()
val p = call.argument<String>("port")
val map = call.argument<String>("map") ?: ""
port = p ?: "9876"
start(map)
}
"proxy" -> {
proxy()
Expand All @@ -39,32 +42,9 @@ object Weiss {
}
}

fun ser() {
val serverSocket = ServerSocket(port.toInt())
while (true) {
val client = serverSocket.accept()
println("Client connected: ${client.inetAddress.hostAddress}")

// Run client in it's own thread.
thread {
val inputStream = client.getInputStream()
val readBytes = inputStream.readBytes()
inputStream.close()
val message = readBytes.toString()
Log.d(TAG, "message:\n $message")
val serverSocket = SSLSocketFactory.getDefault().createSocket()
val outputStream = serverSocket.getOutputStream()
outputStream.write(readBytes)
outputStream.flush()
outputStream.close()

}
}
}

fun start() {
fun start(json: String) {
try {
weiss.Weiss.start(port)
weiss.Weiss.start(port, json)
} catch (e: Throwable) {
}
}
Expand All @@ -73,7 +53,6 @@ object Weiss {
try {
weiss.Weiss.close()
} catch (e: Throwable) {

}
}

Expand Down
Binary file modified android/weiss/weiss.aar
Binary file not shown.
16 changes: 8 additions & 8 deletions lib/component/illust_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,8 @@ class _IllustCardState extends State<IllustCard> {
return Text('');
}

Widget _buildPic(String tag) {
return (store.illusts!.height.toDouble() /
store.illusts!.width.toDouble()) >
3
Widget _buildPic(String tag, bool tooLong) {
return tooLong
? NullHero(
tag: tag,
child: PixivImage(store.illusts!.imageUrls.squareMedium,
Expand All @@ -136,9 +134,11 @@ class _IllustCardState extends State<IllustCard> {
}

Widget buildInkWell(BuildContext context) {
var radio =
store.illusts!.width.toDouble() / store.illusts!.height.toDouble();
if (radio > 3) radio = 1.0;
var tooLong =
store.illusts!.height.toDouble() / store.illusts!.width.toDouble() > 3;
var radio = (tooLong)
? 1.0
: store.illusts!.width.toDouble() / store.illusts!.height.toDouble();
return Card(
margin: EdgeInsets.all(8.0),
elevation: 4.0,
Expand All @@ -158,7 +158,7 @@ class _IllustCardState extends State<IllustCard> {
aspectRatio: radio,
child: Stack(
children: [
Positioned.fill(child: _buildPic(tag)),
Positioned.fill(child: _buildPic(tag, tooLong)),
Positioned(top: 5.0, right: 5.0, child: _buildVisibility()),
],
)),
Expand Down
4 changes: 2 additions & 2 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/

class Constants {
static String tagName = "0.4.5";
static String tagName = "0.4.6";

// static bool isGooglePlay =
// bool.fromEnvironment("IS_GOOGLEPLAY", defaultValue: false);//为何没用啊咕鸽?
static bool isGooglePlay = false;
static bool isGooglePlay = true;
static int type = 0;
static String? code_verifier = null;
}
7 changes: 5 additions & 2 deletions lib/er/hoster.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:convert';
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pixez/component/pixiv_image.dart';
Expand All @@ -17,7 +16,7 @@ class Hoster {
"oauth.secure.pixiv.net": "210.140.131.199",
"i.pximg.net": "210.140.92.143",
"s.pximg.net": "210.140.92.140",
"doh": "1.0.0.1"
"doh": "1.0.0.1",
};

static init() async {
Expand Down Expand Up @@ -47,6 +46,10 @@ class Hoster {
static final String _hostJsonUrl =
"https://cdn.jsdelivr.net/gh/Notsfsssf/pixez-flutter@master/assets/json/host.json";

static Map<String, dynamic> hardMap() {
return _map;
}

static syncRemote() async {
try {
LPrinter.d("sync remote =========");
Expand Down
14 changes: 8 additions & 6 deletions lib/page/splash/splash_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,24 @@ class _SplashPageState extends State<SplashPage>

late ReactionDisposer reactionDisposer, userDisposer;

bool isPush = false;

initMethod() {
userDisposer = reaction((_) => userSetting.disableBypassSni, (_) {
if (userSetting.disableBypassSni) {
apiClient.httpClient.options.baseUrl =
'https://${ApiClient.BASE_API_URL_HOST}';
oAuthClient.httpClient.options.baseUrl =
'https://${OAuthClient.BASE_OAUTH_URL_HOST}';
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
Platform.isIOS ? HelloPage() : AndroidHelloPage()));
Leader.pushUntilHome(context);
isPush = true;
}
});
reactionDisposer = reaction((_) => splashStore.helloWord, (_) {
Leader.pushUntilHome(context);
if (mounted && !isPush) {
Leader.pushUntilHome(context);
isPush = true;
}
});
splashStore.hello();
}
Expand Down
12 changes: 11 additions & 1 deletion lib/weiss_plugin.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import 'dart:convert';

import 'package:flutter/services.dart';
import 'package:pixez/er/hoster.dart';

class WeissPlugin {
static const platform = const MethodChannel('com.perol.dev/weiss');

static Future<void> start() async {
return await platform.invokeMethod("start");
final map = Hoster.hardMap();
String data = "";
try {
if (map.isNotEmpty) {
data = json.encode(map);
}
} catch (e) {}
return await platform.invokeMethod("start", {"port": "9876", "map": data});
}

static Future<void> stop() async {
Expand Down

0 comments on commit 73fb23b

Please sign in to comment.