Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check update by query GiHub the latest release. #549

Merged
merged 2 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/account/account_key_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,36 @@ class AccountKeyValue extends HiveKeyValue {
static const _refreshStickerLastTime = 'refreshStickerLastTime';
static const _primarySessionId = 'primarySessionId';
static const _hasNewAlbum = 'hasNewAlbum';
static const _checkUpdateLastTime = 'checkUpdateLastTime';
static const _ignoredVersion = '_ignoredVersion';

bool get hasSyncCircle =>
box.get(_hasSyncCircle, defaultValue: false) as bool;

set hasSyncCircle(bool value) => box.put(_hasSyncCircle, value);

int get refreshStickerLastTime =>
box.get(_refreshStickerLastTime, defaultValue: 0) as int;

set refreshStickerLastTime(int value) =>
box.put(_refreshStickerLastTime, value);

String? get primarySessionId =>
box.get(_primarySessionId, defaultValue: null) as String?;

set primarySessionId(String? value) => box.put(_primarySessionId, value);

bool get hasNewAlbum => box.get(_hasNewAlbum, defaultValue: false) as bool;

set hasNewAlbum(bool value) => box.put(_hasNewAlbum, value);

int get checkUpdateLastTime =>
box.get(_checkUpdateLastTime, defaultValue: 0) as int;

set checkUpdateLastTime(int value) => box.put(_checkUpdateLastTime, value);

String? get ignoredVersion =>
box.get(_ignoredVersion, defaultValue: '0.0.0') as String?;

set ignoredVersion(String? value) => box.put(_ignoredVersion, value);
}
16 changes: 16 additions & 0 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import 'ui/home/conversation/conversation_page.dart';
import 'ui/home/home.dart';
import 'ui/home/route/responsive_navigator_cubit.dart';
import 'ui/landing/landing.dart';
import 'utils/app_lifecycle.dart';
import 'utils/auto_update_checker.dart';
import 'utils/extension/extension.dart';
import 'utils/hook.dart';
import 'utils/logger.dart';
Expand Down Expand Up @@ -258,6 +260,20 @@ class _Home extends HookWidget {
}
}, [signed]);

useEffect(() {
void onAppStateChanged() {
if (isAppActive) {
checkUpdate(context: context);
}
}

onAppStateChanged();
appActiveListener.addListener(onAppStateChanged);
return () {
appActiveListener.removeListener(onAppStateChanged);
};
}, []);

if (signed) {
BlocProvider.of<ConversationListBloc>(context)
..limit = MediaQuery.of(context).size.height ~/
Expand Down
43 changes: 27 additions & 16 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,24 @@ class MessageLookup extends MessageLookupByLibrary {

static String m16(name) => "Remove ${name}";

static String m17(name) => "Do you want to delete ${name} circle?";
static String m17(newVersion, current) =>
"Mixin Messenger ${newVersion} is now available, you have ${current}. Would you like to download it now?";

static String m18(date) => "${date} join";
static String m18(name) => "Do you want to delete ${name} circle?";

static String m19(count) => "${count} Participants";
static String m19(date) => "${date} join";

static String m20(count) => "${count} Pinned Messages";
static String m20(count) => "${count} Participants";

static String m21(user, preview) => "${user} pinned ${preview}";
static String m21(count) => "${count} Pinned Messages";

static String m22(count) => "${count} related messages";
static String m22(user, preview) => "${user} pinned ${preview}";

static String m23(value) => "value now ${value}";
static String m23(count) => "${count} related messages";

static String m24(value) => "value then ${value}";
static String m24(value) => "value now ${value}";

static String m25(value) => "value then ${value}";

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
Expand Down Expand Up @@ -138,6 +141,8 @@ class MessageLookup extends MessageLookupByLibrary {
"chatWaiting": m5,
"chatWaitingDesktop": MessageLookupByLibrary.simpleMessage("desktop"),
"chats": MessageLookupByLibrary.simpleMessage("Chats"),
"checkUpdate":
MessageLookupByLibrary.simpleMessage("Check for updates"),
"circleTitle": m6,
"circles": MessageLookupByLibrary.simpleMessage("Circles"),
"clear": MessageLookupByLibrary.simpleMessage("Clear"),
Expand Down Expand Up @@ -181,6 +186,7 @@ class MessageLookup extends MessageLookupByLibrary {
"deleteGroup": MessageLookupByLibrary.simpleMessage("Delete Group"),
"developer": MessageLookupByLibrary.simpleMessage("Developer"),
"done": MessageLookupByLibrary.simpleMessage("Done"),
"download": MessageLookupByLibrary.simpleMessage("Download"),
"downloadLink": MessageLookupByLibrary.simpleMessage("Download Link: "),
"editAnnouncement":
MessageLookupByLibrary.simpleMessage("Edit group description"),
Expand Down Expand Up @@ -232,6 +238,8 @@ class MessageLookup extends MessageLookupByLibrary {
"groupsInCommon":
MessageLookupByLibrary.simpleMessage("Groups in common"),
"helpCenter": MessageLookupByLibrary.simpleMessage("Help center"),
"ignoreThisUpdate":
MessageLookupByLibrary.simpleMessage("Ignore this update"),
"image": MessageLookupByLibrary.simpleMessage("Image"),
"includeFiles": MessageLookupByLibrary.simpleMessage("Include Files"),
"includeVideos": MessageLookupByLibrary.simpleMessage("Include Videos"),
Expand Down Expand Up @@ -269,6 +277,9 @@ class MessageLookup extends MessageLookupByLibrary {
"name": MessageLookupByLibrary.simpleMessage("Name"),
"networkConnectionFailed":
MessageLookupByLibrary.simpleMessage("Network connection failed"),
"newVersionAvailable":
MessageLookupByLibrary.simpleMessage("New version available"),
"newVersionDescription": m17,
"next": MessageLookupByLibrary.simpleMessage("Next"),
"noAudio": MessageLookupByLibrary.simpleMessage("NO AUDIO"),
"noData": MessageLookupByLibrary.simpleMessage("NO DATA"),
Expand All @@ -288,8 +299,8 @@ class MessageLookup extends MessageLookupByLibrary {
"openLogDirectory":
MessageLookupByLibrary.simpleMessage("open log directory"),
"originalImage": MessageLookupByLibrary.simpleMessage("Original"),
"pageDeleteCircle": m17,
"pageEditProfileJoin": m18,
"pageDeleteCircle": m18,
"pageEditProfileJoin": m19,
"pageLandingClickToReload":
MessageLookupByLibrary.simpleMessage("CLICK TO RELOAD QR CODE"),
"pageLandingLoginMessage": MessageLookupByLibrary.simpleMessage(
Expand All @@ -298,12 +309,12 @@ class MessageLookup extends MessageLookupByLibrary {
"Login to Mixin Messenger by QR Code"),
"pageRightEmptyMessage": MessageLookupByLibrary.simpleMessage(
"Select a conversation to start messaging"),
"participantsCount": m19,
"participantsCount": m20,
"phoneNumber": MessageLookupByLibrary.simpleMessage("Phone number"),
"photos": MessageLookupByLibrary.simpleMessage("Photos"),
"pin": MessageLookupByLibrary.simpleMessage("Pin"),
"pinMessageCount": m20,
"pinned": m21,
"pinMessageCount": m21,
"pinned": m22,
"pleaseWait":
MessageLookupByLibrary.simpleMessage("Please wait a moment"),
"post": MessageLookupByLibrary.simpleMessage("Post"),
Expand Down Expand Up @@ -334,7 +345,7 @@ class MessageLookup extends MessageLookupByLibrary {
"searchEmpty": MessageLookupByLibrary.simpleMessage(
"No chats, \ncontacts or messages found."),
"searchMessageHistory": MessageLookupByLibrary.simpleMessage("Search"),
"searchRelatedMessage": m22,
"searchRelatedMessage": m23,
"searchUser": MessageLookupByLibrary.simpleMessage("Search contact"),
"searchUserHint":
MessageLookupByLibrary.simpleMessage("Mixin ID or Phone number"),
Expand Down Expand Up @@ -396,10 +407,10 @@ class MessageLookup extends MessageLookupByLibrary {
"videos": MessageLookupByLibrary.simpleMessage("Videos"),
"waitingForThisMessage":
MessageLookupByLibrary.simpleMessage("Waiting for this message."),
"walletTransactionCurrentValue": m23,
"walletTransactionCurrentValue": m24,
"walletTransactionThatTimeNoValue":
MessageLookupByLibrary.simpleMessage("value then N/A"),
"walletTransactionThatTimeValue": m24,
"walletTransactionThatTimeValue": m25,
"webView2RuntimeInstallDescription": MessageLookupByLibrary.simpleMessage(
"The device has not installed the WebView2 Runtime component. Please download and install WebView2 Runtime first."),
"webViewRuntimeNotAvailable": MessageLookupByLibrary.simpleMessage(
Expand Down
40 changes: 24 additions & 16 deletions lib/generated/intl/messages_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,24 @@ class MessageLookup extends MessageLookupByLibrary {

static String m16(name) => "移除 ${name}";

static String m17(name) => "确定删除${name}圈子吗?";
static String m17(newVersion, current) =>
"发现新版本 Mixin Messenger ${newVersion},当前版本为 ${current}。是否要下载最新的版本?";

static String m18(date) => "${date}加入";
static String m18(name) => "确定删除${name}圈子吗?";

static String m19(count) => "共 ${count} 人";
static String m19(date) => "${date}加入";

static String m20(count) => "${count}条置顶消息";
static String m20(count) => "${count}";

static String m21(user, preview) => "${user}置顶了${preview}";
static String m21(count) => "${count}条置顶消息";

static String m22(count) => "${count} 条相关的消息";
static String m22(user, preview) => "${user}置顶了${preview}";

static String m23(value) => "价值 ${value}";
static String m23(count) => "${count} 条相关的消息";

static String m24(value) => "当时价值 ${value}";
static String m24(value) => "价值 ${value}";

static String m25(value) => "当时价值 ${value}";

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
Expand Down Expand Up @@ -118,6 +121,7 @@ class MessageLookup extends MessageLookupByLibrary {
"chatWaiting": m5,
"chatWaitingDesktop": MessageLookupByLibrary.simpleMessage("桌面端"),
"chats": MessageLookupByLibrary.simpleMessage("全部聊天"),
"checkUpdate": MessageLookupByLibrary.simpleMessage("检查更新"),
"circleTitle": m6,
"circles": MessageLookupByLibrary.simpleMessage("圈子"),
"clear": MessageLookupByLibrary.simpleMessage("清除"),
Expand Down Expand Up @@ -156,6 +160,7 @@ class MessageLookup extends MessageLookupByLibrary {
"deleteGroup": MessageLookupByLibrary.simpleMessage("删除群组"),
"developer": MessageLookupByLibrary.simpleMessage("开发者"),
"done": MessageLookupByLibrary.simpleMessage("完成"),
"download": MessageLookupByLibrary.simpleMessage("下载"),
"downloadLink": MessageLookupByLibrary.simpleMessage("下载链接:"),
"editAnnouncement": MessageLookupByLibrary.simpleMessage("编辑群公告"),
"editCircle": MessageLookupByLibrary.simpleMessage("管理圈子"),
Expand Down Expand Up @@ -201,6 +206,7 @@ class MessageLookup extends MessageLookupByLibrary {
"groups": MessageLookupByLibrary.simpleMessage("群组"),
"groupsInCommon": MessageLookupByLibrary.simpleMessage("共同群组"),
"helpCenter": MessageLookupByLibrary.simpleMessage("帮助中心"),
"ignoreThisUpdate": MessageLookupByLibrary.simpleMessage("忽略这次更新"),
"image": MessageLookupByLibrary.simpleMessage("照片"),
"includeFiles": MessageLookupByLibrary.simpleMessage("包含文件"),
"includeVideos": MessageLookupByLibrary.simpleMessage("包括视频"),
Expand Down Expand Up @@ -233,6 +239,8 @@ class MessageLookup extends MessageLookupByLibrary {
"name": MessageLookupByLibrary.simpleMessage("名字"),
"networkConnectionFailed":
MessageLookupByLibrary.simpleMessage("网络连接失败"),
"newVersionAvailable": MessageLookupByLibrary.simpleMessage("发现新版本"),
"newVersionDescription": m17,
"next": MessageLookupByLibrary.simpleMessage("下一步"),
"noAudio": MessageLookupByLibrary.simpleMessage("没有音频"),
"noData": MessageLookupByLibrary.simpleMessage("没有数据"),
Expand All @@ -250,8 +258,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("打开通知"),
"openLogDirectory": MessageLookupByLibrary.simpleMessage("打开日志文件夹"),
"originalImage": MessageLookupByLibrary.simpleMessage("原图"),
"pageDeleteCircle": m17,
"pageEditProfileJoin": m18,
"pageDeleteCircle": m18,
"pageEditProfileJoin": m19,
"pageLandingClickToReload":
MessageLookupByLibrary.simpleMessage("点击重新加载二维码"),
"pageLandingLoginMessage": MessageLookupByLibrary.simpleMessage(
Expand All @@ -260,12 +268,12 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("通过二维码登录 Mixin Messenger"),
"pageRightEmptyMessage":
MessageLookupByLibrary.simpleMessage("选择一个对话,开始发送信息"),
"participantsCount": m19,
"participantsCount": m20,
"phoneNumber": MessageLookupByLibrary.simpleMessage("手机号"),
"photos": MessageLookupByLibrary.simpleMessage("照片"),
"pin": MessageLookupByLibrary.simpleMessage("置顶"),
"pinMessageCount": m20,
"pinned": m21,
"pinMessageCount": m21,
"pinned": m22,
"pleaseWait": MessageLookupByLibrary.simpleMessage("请稍等一下"),
"post": MessageLookupByLibrary.simpleMessage("文章"),
"preview": MessageLookupByLibrary.simpleMessage("预览"),
Expand All @@ -290,7 +298,7 @@ class MessageLookup extends MessageLookupByLibrary {
"search": MessageLookupByLibrary.simpleMessage("搜索"),
"searchEmpty": MessageLookupByLibrary.simpleMessage("找不到联系人或消息。"),
"searchMessageHistory": MessageLookupByLibrary.simpleMessage("搜索聊天记录"),
"searchRelatedMessage": m22,
"searchRelatedMessage": m23,
"searchUser": MessageLookupByLibrary.simpleMessage("搜索用户"),
"searchUserHint": MessageLookupByLibrary.simpleMessage("Mixin ID 或手机号"),
"send": MessageLookupByLibrary.simpleMessage("发送"),
Expand Down Expand Up @@ -343,10 +351,10 @@ class MessageLookup extends MessageLookupByLibrary {
"videos": MessageLookupByLibrary.simpleMessage("视频"),
"waitingForThisMessage":
MessageLookupByLibrary.simpleMessage("正在等待这个消息。"),
"walletTransactionCurrentValue": m23,
"walletTransactionCurrentValue": m24,
"walletTransactionThatTimeNoValue":
MessageLookupByLibrary.simpleMessage("当时价值 暂无"),
"walletTransactionThatTimeValue": m24,
"walletTransactionThatTimeValue": m25,
"webView2RuntimeInstallDescription":
MessageLookupByLibrary.simpleMessage(
"该设备暂未安装 WebView2 组件,请先下载并安装 WebView2 Runtime。"),
Expand Down
50 changes: 50 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,10 @@
"groupsInCommon": "Groups in common",
"failedToOpenFile": "Failed to open file {name}",
"openLogDirectory": "open log directory",
"messageTooLong": "Message content is too long"
"messageTooLong": "Message content is too long",
"checkUpdate": "Check for updates",
"newVersionAvailable": "New version available",
"ignoreThisUpdate": "Ignore this update",
"newVersionDescription": "Mixin Messenger {newVersion} is now available, you have {current}. Would you like to download it now?",
"download": "Download"
}
7 changes: 6 additions & 1 deletion lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -247,5 +247,10 @@
"groupsInCommon": "共同群组",
"failedToOpenFile": "无法打开文件:{name}",
"openLogDirectory": "打开日志文件夹",
"messageTooLong": "消息内容过长"
"messageTooLong": "消息内容过长",
"checkUpdate": "检查更新",
"newVersionAvailable": "发现新版本",
"ignoreThisUpdate": "忽略这次更新",
"newVersionDescription": "发现新版本 Mixin Messenger {newVersion},当前版本为 {current}。是否要下载最新的版本?",
"download": "下载"
}
5 changes: 5 additions & 0 deletions lib/ui/setting/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

import '../../constants/resources.dart';
import '../../utils/auto_update_checker.dart';
import '../../utils/extension/extension.dart';
import '../../utils/hook.dart';
import '../../utils/system/package_info.dart';
Expand Down Expand Up @@ -82,6 +83,10 @@ class AboutPage extends HookWidget {
onTap: () =>
openUri(context, 'https://mixin.one/pages/privacy'),
),
CellItem(
title: Text(context.l10n.checkUpdate),
onTap: () => checkUpdate(context: context, force: true),
),
],
),
),
Expand Down
Loading