Commit 4c8cf445 by tanghuan

隐蔽打开开发者模式

1 parent e9b7f361
import 'dart:io';
import 'package:android_intent_plus/android_intent.dart';
import 'package:appframe/config/locator.dart';
import 'package:appframe/config/routes.dart';
import 'package:appframe/data/repositories/phone_auth_repository.dart';
......@@ -81,6 +82,10 @@ class AccountCubit extends Cubit<AccountState> {
late final PhoneAuthRepository _phoneAuthRepository;
late final UserAuthRepository _userAuthRepository;
// 连续点击触发开发者模式
int _devTapCount = 0;
DateTime? _lastDevTapTime;
AccountCubit(super.initialState) {
_phoneAuthRepository = getIt.get<PhoneAuthRepository>();
_userAuthRepository = getIt.get<UserAuthRepository>();
......@@ -268,4 +273,29 @@ class AccountCubit extends Cubit<AccountState> {
});
router.go('/loginMain');
}
/// 透明热区连续点击,触发 Android 开发者模式
void onDevAreaTap() {
final now = DateTime.now();
if (_lastDevTapTime == null ||
now.difference(_lastDevTapTime!) > const Duration(seconds: 2)) {
_devTapCount = 1;
} else {
_devTapCount++;
}
_lastDevTapTime = now;
debugPrint('onDevAreaTap: ${_devTapCount}');
if (_devTapCount >= 7) {
_devTapCount = 0;
_lastDevTapTime = null;
if (Platform.isAndroid) {
const AndroidIntent(
action: 'android.settings.APPLICATION_DEVELOPMENT_SETTINGS',
).launch();
}
}
}
}
......@@ -82,6 +82,16 @@ class AccountPageV2 extends StatelessWidget {
],
),
),
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 15),
child: GestureDetector(
onTap: () => cubit.onDevAreaTap(),
child: const SizedBox(width: 80, height: 80, child: DecoratedBox(decoration: BoxDecoration(color: Colors.white))),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 15, right: 15, bottom: 40),
child: SizedBox(
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!