1,优化安卓平台呼叫提醒本地通知

2,新增微信公众号推送部分国际化
3,新增设置微信公众号推送开关接口对接
4,新增获取微信公众号二维码接口对接
5,新增微信公众号二维码部分显示逻辑
This commit is contained in:
Daisy 2024-04-16 15:05:35 +08:00
parent 529d75f2fe
commit 502f3880b4
15 changed files with 227 additions and 61 deletions

View File

@ -688,5 +688,6 @@
"手掌":"palm",
"商城":"mall",
"我的":"my"
"我的":"my",
"微信公众号推送":"Wechat public account"
}

View File

@ -687,5 +687,6 @@
"手掌":"手掌",
"商城":"mall",
"我的":"my"
"我的":"my",
"微信公众号推送":"微信公众号推送"
}

View File

@ -688,5 +688,6 @@
"虹膜":"虹膜",
"手掌":"手掌",
"商城":"商城",
"我的":"我的"
"我的":"我的",
"微信公众号推送":"微信公众号推送"
}

View File

@ -107,16 +107,6 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
// XSJPushProvider().initJPushService();
loginInitLocalNotification();
}
Future<void> loginInitLocalNotification() async {
bool isLoggedIn = await getLoginStatus();
if (isLoggedIn) {
XSJPushProvider().initLocalNotification(false);
}
}
@override

View File

@ -18,16 +18,17 @@ class StarLockLoginLogic extends BaseGetXController {
void login() async {
var entity = await ApiRepository.to.login(
loginType:"1",
password:state.pwd.value,
countryCode:state.countryCode.value,
username:state.emailOrPhone.value);
loginType: "1",
password: state.pwd.value,
countryCode: state.countryCode.value,
username: state.emailOrPhone.value);
if (entity.errorCode!.codeIsSuccessful) {
Storage.saveLoginData(entity.data);
eventBus.fire(MineInfoChangeRefreshUI());
// Get.back();
// Get.toNamed(Routers.starLockMain);
XSJPushProvider().initJPushService();
XSJPushProvider().initLocalNotification(false);
Get.offNamedUntil(Routers.starLockMain, (route) => false);
}
}

View File

@ -1,11 +1,15 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElectronicKey/expireLockList_entity.dart';
import 'package:star_lock/mine/mineSet/mineSet/mineSet_state.dart';
import 'package:star_lock/mine/mineSet/mineSet/weChatQRCodeEntity.dart';
import 'package:star_lock/tools/appFirstEnterHandle.dart';
import 'package:star_lock/tools/storage.dart';
import 'package:star_lock/tools/xs_jPhush.dart';
import 'package:star_lock/versionUndate/versionUndate_entity.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart';
import '../../../blue/blue_manage.dart';
@ -36,6 +40,12 @@ class MineSetLogic extends BaseGetXController {
} else {
state.isTouchUnlock.value = false;
}
//
if (entity.data!.mpWechatPushSwitch! == 1) {
state.isWechatPublicAccountPush.value = true;
} else {
state.isWechatPublicAccountPush.value = false;
}
}
}
@ -49,6 +59,33 @@ class MineSetLogic extends BaseGetXController {
}
}
//
Future<void> setMpWechatPushSwitchRequest(BuildContext widgetContext) async {
VersionUndateEntity entity = await ApiRepository.to.setMpWechatPushSwitch(
mpWechatPushSwitch:
state.isWechatPublicAccountPush.value == true ? 1 : 2);
if (entity.errorCode!.codeIsSuccessful) {
showToast("设置成功".tr);
userSettingsInfoRequest();
} else if (entity.errorCode! == 421) {
//
getMpWechatQrCodeRequest(widgetContext);
}
}
//
Future<void> getMpWechatQrCodeRequest(BuildContext widgetContext) async {
GetWechatQrCodeEntity entity = await ApiRepository.to.getMpWechatQrCode();
if (entity.errorCode!.codeIsSuccessful) {
state.qrCodeUrl.value = entity.data!.qrCodeUrl!;
showQRImageAlert(state.qrCodeUrl.value, widgetContext);
}
}
void showQRImageAlert(String qrCodeUrl, BuildContext widgetContext) {
AppFirstEnterHandle().showQRImageAlert(widgetContext, qrCodeUrl);
}
//退
Future<void> userLogoutRequest() async {
var getPushDeviceID = '';

View File

@ -89,10 +89,21 @@ class _MineSetPageState extends State<MineSetPage> with WidgetsBindingObserver {
leftTitel: TranslationLoader.lanKeys!.pushNotification!.tr,
rightTitle: "",
isHaveRightWidget: true,
isHaveLine: F.appFlavor == Flavor.sky ? true : false,
rightWidget: SizedBox(
width: 60.w,
height: 50.h,
child: Obx(() => _isPushNotificationSwitch()))),
F.appFlavor == Flavor.sky
? CommonItem(
leftTitel: "微信公众号推送".tr,
rightTitle: "",
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w,
height: 50.h,
child: Obx(() => _isWechatPublicAccountPushSwitch())))
: Container(),
SizedBox(height: 10.h),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.lockUserManagement!.tr,
@ -273,7 +284,7 @@ class _MineSetPageState extends State<MineSetPage> with WidgetsBindingObserver {
isDelete: true,
onClick: () {
//退
ShowTipView().showIosTipWithContentDialog("确定要退出吗?".tr, (){
ShowTipView().showIosTipWithContentDialog("确定要退出吗?".tr, () {
logic.userLogoutRequest();
});
// showLoginOutAlertTipDialog();
@ -291,7 +302,8 @@ class _MineSetPageState extends State<MineSetPage> with WidgetsBindingObserver {
color: AppColors.darkGrayTextColor, fontSize: 18.sp),
),
onPressed: () {
ShowTipView().showIosTipWithContentDialog(TranslationLoader.lanKeys!.deleteAccountTips!.tr, (){
ShowTipView().showIosTipWithContentDialog(
TranslationLoader.lanKeys!.deleteAccountTips!.tr, () {
//
Get.toNamed(Routers.safeVerifyPage);
});
@ -389,6 +401,21 @@ class _MineSetPageState extends State<MineSetPage> with WidgetsBindingObserver {
);
}
//
CupertinoSwitch _isWechatPublicAccountPushSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isWechatPublicAccountPush.value,
onChanged: (value) {
state.isWechatPublicAccountPush.value =
!state.isWechatPublicAccountPush.value;
logic.setMpWechatPushSwitchRequest(context);
},
);
}
CupertinoSwitch _isPushNotificationSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,

View File

@ -9,6 +9,8 @@ class MineSetState {
var isPrompTone = false.obs; //
var isTouchUnlock = false.obs; //
var isPushNotification = false.obs; //
var isWechatPublicAccountPush = false.obs; //
var qrCodeUrl = ''.obs; //
var lockScreen = 2.obs; //
var hideExpiredAccessFlag = 2.obs; //

View File

@ -41,6 +41,7 @@ class UserSettingInfoData {
int? hasCameraLock;
int? hasGoogleHome;
int? alertMode;
int? mpWechatPushSwitch;
UserSettingInfoData(
{this.userSettings,
@ -54,7 +55,8 @@ class UserSettingInfoData {
this.hasPaidFeature,
this.hasCameraLock,
this.hasGoogleHome,
this.alertMode});
this.alertMode,
this.mpWechatPushSwitch});
UserSettingInfoData.fromJson(Map<String, dynamic> json) {
userSettings = json['userSettings'] != null
@ -71,6 +73,7 @@ class UserSettingInfoData {
hasCameraLock = json['hasCameraLock'];
hasGoogleHome = json['hasGoogleHome'];
alertMode = json['alertMode'];
mpWechatPushSwitch = json['mpWechatPushSwitch'];
}
Map<String, dynamic> toJson() {
@ -89,6 +92,7 @@ class UserSettingInfoData {
data['hasCameraLock'] = hasCameraLock;
data['hasGoogleHome'] = hasGoogleHome;
data['alertMode'] = alertMode;
data['mpWechatPushSwitch'] = mpWechatPushSwitch;
return data;
}
}

View File

@ -0,0 +1,43 @@
class GetWechatQrCodeEntity {
int? errorCode;
String? description;
String? errorMsg;
Data? data;
GetWechatQrCodeEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
GetWechatQrCodeEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data = json['data'] != null ? Data.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
return data;
}
}
class Data {
String? qrCodeUrl;
Data({this.qrCodeUrl});
Data.fromJson(Map<String, dynamic> json) {
qrCodeUrl = json['qrCodeUrl'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['qrCodeUrl'] = qrCodeUrl;
return data;
}
}

View File

@ -45,7 +45,8 @@ abstract class Api {
final String passwordKeyGetURL = '/keyboardPwd/get'; //
final String passwordKeyAddURL = '/keyboardPwd/add'; //
final String passwordKeyCheckKeyboardpwdNameURL = '/keyboardPwd/checkKeyboardpwdName'; //
final String passwordKeyCheckKeyboardpwdNameURL =
'/keyboardPwd/checkKeyboardpwdName'; //
final String updatePasswordKeyURL = '/keyboardPwd/update'; //
final String clearOperationRecordURL = '/lockRecords/clear'; //
final String addlockGroupURL = '/keyGroup/add'; //
@ -175,7 +176,8 @@ abstract class Api {
'/safeAnswer/getOwnQuestionList'; //
final String updateSafeAnswerURL = '/safeAnswer/update'; //
final String setSafeAnswerURL = '/safeAnswer/set'; //
final String getUpTokenURL = '/file/getUploadParams'; // upToken updateUserInfo
final String getUpTokenURL =
'/file/getUploadParams'; // upToken updateUserInfo
final String unbindPhoneTokenURL = '/user/unbindPhoneToken'; //Token
final String unbindEmailTokenURL = '/user/unbindEmailToken'; //Token
final String pushBindAppIdURL = '/user/bindAppId'; //APP设备
@ -193,4 +195,7 @@ abstract class Api {
final String getLockNoticeSettingURL =
'/lockSetting/getLockNoticeSetting'; //
final String setWechatPushSwitchURL =
'/user/setMpWechatPushSwitch'; //
final String getMpWechatQrCodeURL = '/user/getMpWechatQrCode'; //
}

View File

@ -453,10 +453,7 @@ class ApiProvider extends BaseProvider {
//
Future<Response> checkKeyboardpwdName(
String lockId,
String keyboardPwdName,
String keyboardPwd
) =>
String lockId, String keyboardPwdName, String keyboardPwd) =>
post(
passwordKeyCheckKeyboardpwdNameURL.toUrl,
jsonEncode({
@ -1556,14 +1553,16 @@ class ApiProvider extends BaseProvider {
}));
//-
Future<Response> updateUserNameInfo(String nickname) =>
post(updateUserInfoURL.toUrl, jsonEncode({
Future<Response> updateUserNameInfo(String nickname) => post(
updateUserInfoURL.toUrl,
jsonEncode({
'nickname': nickname,
}));
//-
Future<Response> updateUserHeadUrlInfo(String headUrl) =>
post(updateUserInfoURL.toUrl, jsonEncode({
Future<Response> updateUserHeadUrlInfo(String headUrl) => post(
updateUserInfoURL.toUrl,
jsonEncode({
'headUrl': headUrl,
}));
@ -1626,10 +1625,10 @@ class ApiProvider extends BaseProvider {
// upToken updateUserInfo
Future<Response> getUpHeadToken(
String userId,
String filename,
int size,
) =>
String userId,
String filename,
int size,
) =>
post(
getUpTokenURL.toUrl,
jsonEncode({
@ -1641,7 +1640,9 @@ class ApiProvider extends BaseProvider {
//
Future<Response> uploadFile(String url, dynamic boay) => post(url, boay,
isUnUploadFile: false, contentType: 'multipart/form-data', isUserBaseUrl: false);
isUnUploadFile: false,
contentType: 'multipart/form-data',
isUserBaseUrl: false);
//Token
Future<Response> unbindPhoneToken(String verificationCode) => post(
@ -1779,6 +1780,17 @@ class ApiProvider extends BaseProvider {
jsonEncode({
'lockId': lockId,
}));
//
Future<Response> setMpWechatPushSwitch(int mpWechatPushSwitch) => post(
setWechatPushSwitchURL.toUrl,
jsonEncode({
'mpWechatPushSwitch': mpWechatPushSwitch,
}));
//
Future<Response> getMpWechatQrCode() =>
post(getMpWechatQrCodeURL.toUrl, jsonEncode({}));
}
extension ExtensionString on String {

View File

@ -21,6 +21,7 @@ import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireElect
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireFingerprint/expireFingerprint_entity.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/lockUserManageList/keyListByUserEntity.dart';
import 'package:star_lock/mine/mineSet/mineSet/userSettingInfoEntity.dart';
import 'package:star_lock/mine/mineSet/mineSet/weChatQRCodeEntity.dart';
import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart';
import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
import '../login/login/entity/LoginEntity.dart';
@ -101,12 +102,10 @@ class ApiRepository {
//
Future<LoginEntity> login(
{
required String loginType,
required String password,
required String countryCode,
required String username
}) async {
{required String loginType,
required String password,
required String countryCode,
required String username}) async {
final res =
await apiProvider.login(loginType, password, countryCode, username);
return LoginEntity.fromJson(res.body);
@ -274,7 +273,8 @@ class ApiRepository {
}
// NO
Future<LockNetTokenEntity> updateLockUserNo({required String keyId, required String lockUserNo}) async {
Future<LockNetTokenEntity> updateLockUserNo(
{required String keyId, required String lockUserNo}) async {
final res = await apiProvider.updateLockUserNo(keyId, lockUserNo);
return LockNetTokenEntity.fromJson(res.body);
}
@ -401,8 +401,7 @@ class ApiRepository {
}
//
Future<LockListInfoEntity> deletOwnerLockData(
{required int lockId}) async {
Future<LockListInfoEntity> deletOwnerLockData({required int lockId}) async {
final res = await apiProvider.deletLockInfo(lockId);
return LockListInfoEntity.fromJson(res.body);
}
@ -456,13 +455,11 @@ class ApiRepository {
//
Future<PasswordKeyEntity> checkKeyboardpwdName(
{
required String lockId,
required String keyboardPwdName,
required String keyboardPwd
}) async {
final res = await apiProvider.checkKeyboardpwdName(lockId, keyboardPwdName,
keyboardPwd);
{required String lockId,
required String keyboardPwdName,
required String keyboardPwd}) async {
final res = await apiProvider.checkKeyboardpwdName(
lockId, keyboardPwdName, keyboardPwd);
return PasswordKeyEntity.fromJson(res.body);
}
@ -1601,8 +1598,7 @@ class ApiRepository {
}
//-
Future<PasswordKeyListEntity> updateUserNameInfo(
{
Future<PasswordKeyListEntity> updateUserNameInfo({
required String nickname,
}) async {
final res = await apiProvider.updateUserNameInfo(nickname);
@ -1611,9 +1607,7 @@ class ApiRepository {
//-
Future<PasswordKeyListEntity> updateUserHeadUrlInfo(
{
required String headUrl
}) async {
{required String headUrl}) async {
final res = await apiProvider.updateUserHeadUrlInfo(headUrl);
return PasswordKeyListEntity.fromJson(res.body);
}
@ -1673,8 +1667,7 @@ class ApiRepository {
required String filename,
required int size,
}) async {
final res =
await apiProvider.getUpHeadToken(userId, filename, size);
final res = await apiProvider.getUpHeadToken(userId, filename, size);
return MinePersonGetUploadFileInfoEntity.fromJson(res.body);
}
@ -1813,4 +1806,17 @@ class ApiRepository {
final res = await apiProvider.getLockNoticeSetting(lockId);
return VersionUndateEntity.fromJson(res.body);
}
//
Future<VersionUndateEntity> setMpWechatPushSwitch(
{required int mpWechatPushSwitch}) async {
final res = await apiProvider.setMpWechatPushSwitch(mpWechatPushSwitch);
return VersionUndateEntity.fromJson(res.body);
}
//
Future<GetWechatQrCodeEntity> getMpWechatQrCode() async {
final res = await apiProvider.getMpWechatQrCode();
return GetWechatQrCodeEntity.fromJson(res.body);
}
}

View File

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
@ -179,6 +180,39 @@ class AppFirstEnterHandle {
);
}
//
void showQRImageAlert(BuildContext widgetContext, String qrCodeUrl) {
showCupertinoDialog(
context: widgetContext,
builder: (context) {
return PopScope(
canPop: false,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.network(
qrCodeUrl,
width: 1.sw - 40.w,
height: 1.sw - 40.w,
),
SizedBox(
height: 20.h,
),
//
GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
child: Image.asset('images/icon_massSend_delete.png'),
),
],
)));
},
);
}
// _launchURL(String url) async {
// if (await canLaunchUrl(Uri.parse(url))) {
// await launchUrl(Uri.parse(url));

View File

@ -65,9 +65,11 @@ class XSJPushProvider {
FlutterLocalNotificationsPlugin();
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('app_icon');
const InitializationSettings initializationSettings =
InitializationSettings(android: initializationSettingsAndroid);
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
if (Platform.isAndroid) {
const InitializationSettings initializationSettings =
InitializationSettings(android: initializationSettingsAndroid);
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
}
if (isCancelLocalPush) {
await flutterLocalNotificationsPlugin.cancelAll();