Compare commits

..
92 changed files with 919 additions and 3134 deletions

View file

@ -15,8 +15,6 @@
"underride", "underride",
"unifiedpush", "unifiedpush",
"unredact", "unredact",
"webpush", "webpush"
"subprofile",
"subprofiles"
] ]
} }

View file

@ -47,12 +47,6 @@
<data android:scheme="matrix" /> <data android:scheme="matrix" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<meta-data <meta-data
android:name="io.flutter.embedding.android.NormalTheme" android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" android:resource="@style/NormalTheme"

View file

@ -28,7 +28,7 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
libFileName = "libgomuks.dylib"; libFileName = "libgomuks.dylib";
final iosConfig = codeConfig.iOS; final iosConfig = codeConfig.iOS;
iosSdk = iosConfig.targetSdk; iosSdk = iosConfig.targetSdk;
final minVersion = iosConfig.deploymentVersion.major; final minVersion = iosConfig.targetVersion;
iosSdkPath = await getXCodeTool(sdkType: iosSdk.type); iosSdkPath = await getXCodeTool(sdkType: iosSdk.type);
final archTriple = switch (targetArch) { final archTriple = switch (targetArch) {
@ -53,8 +53,7 @@ Future<void> main(List<String> args) => build(args, (input, output) async {
libFileName = "libgomuks.dylib"; libFileName = "libgomuks.dylib";
extraEnv = { extraEnv = {
"SDKROOT": await getXCodeTool(), "SDKROOT": await getXCodeTool(),
"MACOSX_DEPLOYMENT_TARGET": codeConfig.macOS.deploymentVersion.major "MACOSX_DEPLOYMENT_TARGET": codeConfig.macOS.targetVersion.toString(),
.toString(),
}; };
break; break;
case OS.windows: case OS.windows:

View file

@ -16,10 +16,6 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
5A4E00000000000000000008 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A4E00000000000000000001 /* ShareViewController.swift */; };
5A4E00000000000000000009 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5A4E00000000000000000007 /* MainInterface.storyboard */; };
5A4E0000000000000000000A /* ShareExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 5A4E00000000000000000005 /* ShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
5A4E0000000000000000000B /* better-share-handler-models in Frameworks */ = {isa = PBXBuildFile; productRef = 5A4E00000000000000000015 /* better-share-handler-models */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
@ -30,13 +26,6 @@
remoteGlobalIDString = 97C146ED1CF9000F007C117D; remoteGlobalIDString = 97C146ED1CF9000F007C117D;
remoteInfo = Runner; remoteInfo = Runner;
}; };
5A4E00000000000000000012 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 97C146E61CF9000F007C117D /* Project object */;
proxyType = 1;
remoteGlobalIDString = 5A4E0000000000000000000D;
remoteInfo = ShareExtension;
};
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
@ -50,17 +39,6 @@
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
5A4E00000000000000000011 /* Embed App Extensions */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 13;
files = (
5A4E0000000000000000000A /* ShareExtension.appex in Embed App Extensions */,
);
name = "Embed App Extensions";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@ -81,12 +59,6 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5A4E00000000000000000001 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
5A4E00000000000000000002 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
5A4E00000000000000000003 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5A4E00000000000000000004 /* ShareExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ShareExtension.entitlements; sourceTree = "<group>"; };
5A4E00000000000000000005 /* ShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
5A4E00000000000000000006 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -105,14 +77,6 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
5A4E0000000000000000000F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
5A4E0000000000000000000B /* better-share-handler-models in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */ /* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
@ -143,7 +107,6 @@
97C146F01CF9000F007C117D /* Runner */, 97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */, 97C146EF1CF9000F007C117D /* Products */,
331C8082294A63A400263BE5 /* RunnerTests */, 331C8082294A63A400263BE5 /* RunnerTests */,
5A4E0000000000000000000C /* ShareExtension */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
}; };
@ -152,7 +115,6 @@
children = ( children = (
97C146EE1CF9000F007C117D /* Runner.app */, 97C146EE1CF9000F007C117D /* Runner.app */,
331C8081294A63A400263BE5 /* RunnerTests.xctest */, 331C8081294A63A400263BE5 /* RunnerTests.xctest */,
5A4E00000000000000000005 /* ShareExtension.appex */,
); );
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
@ -169,22 +131,10 @@
74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */, 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */,
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
5A4E00000000000000000006 /* Runner.entitlements */,
); );
path = Runner; path = Runner;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
5A4E0000000000000000000C /* ShareExtension */ = {
isa = PBXGroup;
children = (
5A4E00000000000000000001 /* ShareViewController.swift */,
5A4E00000000000000000007 /* MainInterface.storyboard */,
5A4E00000000000000000003 /* Info.plist */,
5A4E00000000000000000004 /* ShareExtension.entitlements */,
);
path = ShareExtension;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
@ -215,13 +165,11 @@
97C146EB1CF9000F007C117D /* Frameworks */, 97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */, 97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */, 9705A1C41CF9048500538489 /* Embed Frameworks */,
5A4E00000000000000000011 /* Embed App Extensions */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
); );
buildRules = ( buildRules = (
); );
dependencies = ( dependencies = (
5A4E00000000000000000013 /* PBXTargetDependency */,
); );
name = Runner; name = Runner;
packageProductDependencies = ( packageProductDependencies = (
@ -231,26 +179,6 @@
productReference = 97C146EE1CF9000F007C117D /* Runner.app */; productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
productType = "com.apple.product-type.application"; productType = "com.apple.product-type.application";
}; };
5A4E0000000000000000000D /* ShareExtension */ = {
isa = PBXNativeTarget;
buildConfigurationList = 5A4E00000000000000000016 /* Build configuration list for PBXNativeTarget "ShareExtension" */;
buildPhases = (
5A4E0000000000000000000E /* Sources */,
5A4E0000000000000000000F /* Frameworks */,
5A4E00000000000000000010 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = ShareExtension;
packageProductDependencies = (
5A4E00000000000000000015 /* better-share-handler-models */,
);
productName = ShareExtension;
productReference = 5A4E00000000000000000005 /* ShareExtension.appex */;
productType = "com.apple.product-type.app-extension";
};
/* End PBXNativeTarget section */ /* End PBXNativeTarget section */
/* Begin PBXProject section */ /* Begin PBXProject section */
@ -269,9 +197,6 @@
CreatedOnToolsVersion = 7.3.1; CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 1100; LastSwiftMigration = 1100;
}; };
5A4E0000000000000000000D = {
CreatedOnToolsVersion = 15.0;
};
}; };
}; };
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
@ -285,7 +210,6 @@
mainGroup = 97C146E51CF9000F007C117D; mainGroup = 97C146E51CF9000F007C117D;
packageReferences = ( packageReferences = (
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */, 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */,
5A4E00000000000000000014 /* XCLocalSwiftPackageReference "better_share_handler" */,
); );
productRefGroup = 97C146EF1CF9000F007C117D /* Products */; productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
projectDirPath = ""; projectDirPath = "";
@ -293,7 +217,6 @@
targets = ( targets = (
97C146ED1CF9000F007C117D /* Runner */, 97C146ED1CF9000F007C117D /* Runner */,
331C8080294A63A400263BE5 /* RunnerTests */, 331C8080294A63A400263BE5 /* RunnerTests */,
5A4E0000000000000000000D /* ShareExtension */,
); );
}; };
/* End PBXProject section */ /* End PBXProject section */
@ -317,14 +240,6 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
5A4E00000000000000000010 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5A4E00000000000000000009 /* MainInterface.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */
@ -380,14 +295,6 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
5A4E0000000000000000000E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5A4E00000000000000000008 /* ShareViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */ /* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */ /* Begin PBXTargetDependency section */
@ -396,11 +303,6 @@
target = 97C146ED1CF9000F007C117D /* Runner */; target = 97C146ED1CF9000F007C117D /* Runner */;
targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */;
}; };
5A4E00000000000000000013 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 5A4E0000000000000000000D /* ShareExtension */;
targetProxy = 5A4E00000000000000000012 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */ /* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */ /* Begin PBXVariantGroup section */
@ -420,14 +322,6 @@
name = LaunchScreen.storyboard; name = LaunchScreen.storyboard;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
5A4E00000000000000000007 /* MainInterface.storyboard */ = {
isa = PBXVariantGroup;
children = (
5A4E00000000000000000002 /* Base */,
);
name = MainInterface.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */ /* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */ /* Begin XCBuildConfiguration section */
@ -474,7 +368,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0; IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos; SUPPORTED_PLATFORMS = iphoneos;
@ -492,7 +386,6 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = PK66NJM372; DEVELOPMENT_TEAM = PK66NJM372;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -602,7 +495,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0; IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
@ -653,7 +546,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0; IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos; SUPPORTED_PLATFORMS = iphoneos;
@ -673,7 +566,6 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = PK66NJM372; DEVELOPMENT_TEAM = PK66NJM372;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -697,7 +589,6 @@
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = PK66NJM372; DEVELOPMENT_TEAM = PK66NJM372;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -711,87 +602,6 @@
}; };
name = Release; name = Release;
}; };
5A4E00000000000000000017 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = PK66NJM372;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ShareExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)";
PRODUCT_BUNDLE_IDENTIFIER = nexus.federated.nexus.ShareExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
5A4E00000000000000000018 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = PK66NJM372;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ShareExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)";
PRODUCT_BUNDLE_IDENTIFIER = nexus.federated.nexus.ShareExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
5A4E00000000000000000019 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = PK66NJM372;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ShareExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)";
PRODUCT_BUNDLE_IDENTIFIER = nexus.federated.nexus.ShareExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Profile;
};
/* End XCBuildConfiguration section */ /* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */ /* Begin XCConfigurationList section */
@ -825,16 +635,6 @@
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release; defaultConfigurationName = Release;
}; };
5A4E00000000000000000016 /* Build configuration list for PBXNativeTarget "ShareExtension" */ = {
isa = XCConfigurationList;
buildConfigurations = (
5A4E00000000000000000017 /* Debug */,
5A4E00000000000000000018 /* Release */,
5A4E00000000000000000019 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */ /* End XCConfigurationList section */
/* Begin XCLocalSwiftPackageReference section */ /* Begin XCLocalSwiftPackageReference section */
@ -842,10 +642,6 @@
isa = XCLocalSwiftPackageReference; isa = XCLocalSwiftPackageReference;
relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage;
}; };
5A4E00000000000000000014 /* XCLocalSwiftPackageReference "better_share_handler" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = "Flutter/ephemeral/Packages/.packages/better_share_handler-1.1.1";
};
/* End XCLocalSwiftPackageReference section */ /* End XCLocalSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */ /* Begin XCSwiftPackageProductDependency section */
@ -853,11 +649,6 @@
isa = XCSwiftPackageProductDependency; isa = XCSwiftPackageProductDependency;
productName = FlutterGeneratedPluginSwiftPackage; productName = FlutterGeneratedPluginSwiftPackage;
}; };
5A4E00000000000000000015 /* better-share-handler-models */ = {
isa = XCSwiftPackageProductDependency;
package = 5A4E00000000000000000014 /* XCLocalSwiftPackageReference "better_share_handler" */;
productName = "better-share-handler-models";
};
/* End XCSwiftPackageProductDependency section */ /* End XCSwiftPackageProductDependency section */
}; };
rootObject = 97C146E61CF9000F007C117D /* Project object */; rootObject = 97C146E61CF9000F007C117D /* Project object */;

View file

@ -31,15 +31,6 @@
<string>matrix</string> <string>matrix</string>
</array> </array>
</dict> </dict>
<!-- Opened by the share extension, see ShareRequestController -->
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ShareMedia-$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</array>
</dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string> <string>$(FLUTTER_BUILD_NUMBER)</string>

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.nexus.federated.nexus</string>
</array>
</dict>
</plist>

View file

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="j1y-V4-xli">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Share View Controller-->
<scene sceneID="ceB-am-kn3">
<objects>
<viewController id="j1y-V4-xli" customClass="ShareViewController" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" opaque="NO" contentMode="scaleToFill" id="wbc-yd-nQP">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="1Xd-am-t49"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="CEy-Cv-SGf" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>

View file

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>Nexus</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>PHSupportedMediaTypes</key>
<array>
<string>Video</string>
<string>Image</string>
</array>
<!-- One of each at most, as the composer takes one attachment -->
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsText</key>
<true/>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsMovieWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsFileWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
</dict>
</plist>

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.nexus.federated.nexus</string>
</array>
</dict>
</plist>

View file

@ -1,5 +0,0 @@
import better_share_handler_models
// Saves what was shared to the App Group, then opens Nexus, which asks which
// room to send it to. See ShareRequestController.
class ShareViewController: ShareHandlerIosViewController {}

View file

@ -5,9 +5,6 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:flutter/foundation.dart"; import "package:flutter/foundation.dart";
import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:nexus/controllers/client.dart"; import "package:nexus/controllers/client.dart";
import "package:nexus/controllers/pending_subprofiles.dart";
import "package:nexus/controllers/rooms.dart";
import "package:nexus/models/per_message_profiles.dart";
import "package:nexus/models/account_data.dart"; import "package:nexus/models/account_data.dart";
import "package:nexus/models/push_rules.dart"; import "package:nexus/models/push_rules.dart";
import "package:nexus/models/requests/update_push_rule.dart"; import "package:nexus/models/requests/update_push_rule.dart";
@ -76,45 +73,6 @@ class AccountDataController extends Notifier<AccountData> {
(data) => data.ignoredUserList.contains(userId) == ignored, (data) => data.ignoredUserList.contains(userId) == ignored,
); );
Future<void> setPerMessageProfiles(PerMessageProfiles profiles) =>
_sendAndWait(
() => ref
.read(ClientController.provider.notifier)
.setAccountData(
.new(type: AccountData.perMessageProfilesKey, content: profiles),
),
(data) => data.perMessageProfiles == profiles,
);
Future<void> setRoomProfile(String roomId, String profileId) {
const type = AccountData.perMessageProfilesKey;
const key = "default_profile_id";
final current = ref
.read(RoomsController.provider)[roomId]
?.accountData[type];
return ref.read(PendingSubprofilesController.provider.notifier).track(
roomId,
profileId,
() async {
await ref
.read(ClientController.provider.notifier)
.setAccountData(
.new(
type: type,
roomId: roomId,
content: {...?current, key: profileId},
),
);
await ref
.read(RoomsController.provider.notifier)
.awaitRooms(
(rooms) => rooms[roomId]?.accountData[type]?[key] == profileId,
);
},
);
}
/// Saves [rule] of [kind], creating it if it's new, or otherwise changing only /// Saves [rule] of [kind], creating it if it's new, or otherwise changing only
/// its actions and whether it's enabled. /// its actions and whether it's enabled.
Future<void> savePushRule(PushRuleKind kind, PushRule rule) { Future<void> savePushRule(PushRuleKind kind, PushRule rule) {

View file

@ -1,24 +0,0 @@
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:nexus/controllers/client.dart";
import "package:nexus/controllers/client_state.dart";
import "package:nexus/models/account_management.dart";
/// Where the homeserver lets the user manage their account, if it says.
class AccountManagementController extends AsyncNotifier<AccountManagement?> {
@override
Future<AccountManagement?> build() async {
final homeserver = ref.watch(
ClientStateController.provider.select((state) => state?.homeserverUrl),
);
if (homeserver == null) return null;
return ref
.read(ClientController.provider.notifier)
.getAccountManagement(.parse(homeserver));
}
static final provider =
AsyncNotifierProvider<AccountManagementController, AccountManagement?>(
AccountManagementController.new,
);
}

View file

@ -66,7 +66,7 @@ class BotArgumentSuggestionsController(final ComposerParams composer)
), ),
) => ) =>
BotArgumentSuggestion( BotArgumentSuggestion(
title: displayName ?? userId.localpart!, title: displayName ?? userId.localpart,
subtitle: userId, subtitle: userId,
avatar: avatarUrl, avatar: avatarUrl,
text: userId, text: userId,

View file

@ -50,7 +50,7 @@ class BotCommandsController(final String roomId)
) => ) =>
BotCommand( BotCommand(
sender: sender, sender: sender,
botName: displayName ?? sender.localpart!, botName: displayName ?? sender.localpart,
botAvatar: avatarUrl, botAvatar: avatarUrl,
description: description, description: description,
), ),

View file

@ -36,8 +36,6 @@ import "package:nexus/models/requests/get_mentions.dart";
import "package:nexus/models/requests/get_related_events.dart"; import "package:nexus/models/requests/get_related_events.dart";
import "package:nexus/models/requests/get_room_state.dart"; import "package:nexus/models/requests/get_room_state.dart";
import "package:nexus/models/requests/get_specific_room_state.dart"; import "package:nexus/models/requests/get_specific_room_state.dart";
import "package:nexus/models/content/content.dart";
import "package:nexus/models/account_management.dart";
import "package:nexus/models/requests/get_space_hierarchy.dart"; import "package:nexus/models/requests/get_space_hierarchy.dart";
import "package:nexus/models/requests/get_room_directory.dart"; import "package:nexus/models/requests/get_room_directory.dart";
import "package:nexus/models/requests/get_threads.dart"; import "package:nexus/models/requests/get_threads.dart";
@ -282,19 +280,24 @@ class ClientController(final String? accountId) extends AsyncNotifier<int> {
Future<void> resetEncryption(RecoveryKey key) => Future<void> resetEncryption(RecoveryKey key) =>
sendCommand("reset_encryption", key.toJson()); sendCommand("reset_encryption", key.toJson());
Future<AccountManagement?> getAccountManagement(Uri homeserver) async => Future<Uri?> getCrossSigningResetUrl(Uri homeserver) async {
switch ((await sendCommand("get_login_flows", { const action = "org.matrix.cross_signing_reset";
final oauth = (await sendCommand("get_login_flows", {
"homeserver_url": homeserver.toString(), "homeserver_url": homeserver.toString(),
}))["oauth"]) { }))["oauth"];
{"account_management_uri": final String uri} && final oauth => .new(
.parse(uri), if (oauth?["account_management_uri"] case final String uri
.new( when (oauth["account_management_actions_supported"] as List?)?.contains(
(oauth["account_management_actions_supported"] as List? ?? []) action,
.whereType<String>(), ) ??
), false) {
), final parsed = Uri.parse(uri);
_ => null, return parsed.replace(
}; queryParameters: {...parsed.queryParameters, "action": action},
);
}
return null;
}
Future<String> joinRoom(JoinRoomRequest request) async => Future<String> joinRoom(JoinRoomRequest request) async =>
(await sendCommand("join_room", request.toJson()))["room_id"]; (await sendCommand("join_room", request.toJson()))["room_id"];
@ -333,50 +336,15 @@ class ClientController(final String? accountId) extends AsyncNotifier<int> {
); );
} }
/// The raw JSON of the events [request] asks for, for when the parsed
/// content would lose fields.
Future<List> getSpecificRoomStateJson(
GetSpecificRoomStateRequest request,
) async =>
(await sendCommand("get_specific_room_state", request.toJson()))
as List? ??
[];
Future<IList<Event>> getSpecificRoomState( Future<IList<Event>> getSpecificRoomState(
GetSpecificRoomStateRequest request, GetSpecificRoomStateRequest request,
) async => .new( ) async => .new(
(await getSpecificRoomStateJson(request)).map((event) => .fromJson(event)), ((await sendCommand("get_specific_room_state", request.toJson()))
as List? ??
[])
.map((event) => .fromJson(event)),
); );
Future<String?> updateMembership(
String roomId,
String userId,
IMap<String, Object?> changes,
) async {
final type = EventType.membership.type;
final current = switch ((await getSpecificRoomStateJson(
.new(
keys: .new([.new(roomId: roomId, type: type, stateKey: userId)]),
),
)).firstOrNull) {
{"content": final Map content} => content.cast<String, Object?>(),
_ => throw Exception("You aren't a member of this room"),
};
return await sendCommand("set_state", {
"room_id": roomId,
"type": type,
"state_key": userId,
"content": current.lock
.addAll(changes)
.removeWhere(
(key, value) =>
value == null || key == "join_authorised_via_users_server",
)
.unlock,
});
}
Future<IList<Event>?> getRelatedEvents( Future<IList<Event>?> getRelatedEvents(
GetRelatedEventsRequest request, GetRelatedEventsRequest request,
) async { ) async {
@ -446,17 +414,17 @@ class ClientController(final String? accountId) extends AsyncNotifier<int> {
Future<void> registerPusher(RegisterPusherRequest request) => Future<void> registerPusher(RegisterPusherRequest request) =>
sendCommand("register_homeserver_push", request.toJson()); sendCommand("register_homeserver_push", request.toJson());
Future<void> deregisterPusher(DeregisterPusherRequest request) => sendCommand( Future<void> deregisterPusher(DeregisterPusherRequest request) =>
"register_homeserver_push", sendCommand("register_homeserver_push", {
{...request.toJson(), "kind": null}, ...request.toJson(),
); "kind": null,
});
Future<MessageContent> uploadMedia(UploadMediaRequest request) async => Future<MessageContent> uploadMedia(UploadMediaRequest request) async =>
.fromJson(await sendCommand("upload_media", request.toJson())); .fromJson(await sendCommand("upload_media", request.toJson()));
Future<File> downloadMedia(DownloadMediaRequest request) async { Future<File> downloadMedia(DownloadMediaRequest request) async {
if (accountId == null && if (accountId == null &&
!isInBackground &&
ref.read(ClientStateController.provider)?.isLoggedIn != true) { ref.read(ClientStateController.provider)?.isLoggedIn != true) {
throw StateError("Can't download media while logged out"); throw StateError("Can't download media while logged out");
} }

View file

@ -1,11 +1,8 @@
import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:fluttertagger/fluttertagger.dart";
import "package:nexus/controllers/attachment.dart"; import "package:nexus/controllers/attachment.dart";
import "package:nexus/controllers/bot_command_draft.dart"; import "package:nexus/controllers/bot_command_draft.dart";
import "package:nexus/controllers/rooms.dart"; import "package:nexus/controllers/rooms.dart";
import "package:nexus/helpers/extensions/get_filename.dart"; import "package:nexus/helpers/extensions/get_filename.dart";
import "package:nexus/helpers/extensions/get_localpart.dart";
import "package:nexus/helpers/extensions/is_media.dart"; import "package:nexus/helpers/extensions/is_media.dart";
import "package:nexus/helpers/extensions/with_latest_edit.dart"; import "package:nexus/helpers/extensions/with_latest_edit.dart";
import "package:nexus/models/composer_draft.dart"; import "package:nexus/models/composer_draft.dart";
@ -52,10 +49,8 @@ class ComposerDraftController(final ComposerParams composer)
}, },
); );
final tagged = _restoreTags(text);
state = ComposerDraft( state = ComposerDraft(
text: tagged.text, text: text,
tags: tagged.tags,
textCommands: commands, textCommands: commands,
relatedEvent: rowId, relatedEvent: rowId,
relationType: .edit, relationType: .edit,
@ -81,52 +76,6 @@ class ComposerDraftController(final ComposerParams composer)
_botCommand.clear(); _botCommand.clear();
} }
static final _tagPattern = RegExp(
r"\[@[^\]]*\]\(matrix:u/([^)\s]+)\)"
r"|\[#[^\]]*\]\(matrix:roomid/([^)?\s]+)[^)\s]*\)"
r"|\[#[^\]]*\]\(matrix:r/([^)?\s]+)[^)\s]*\)"
r'|!\[:([^\]\s]+):\]\(mxc://[^)\s]+(?: "(?:[^"\\]|\\.)*")?\)',
);
/// Turns the mentions and custom emoji in [text], an edit source, back into
/// tags, formatted like the composer's tagTextFormatter.
({String text, IList<Tag> tags}) _restoreTags(String text) {
final rooms = ref.read(RoomsController.provider);
Tag tagOf(Match match) =>
switch ((match[1], match[2], match[3], match[4])) {
(final userId?, _, _, _) => .new(
id: match[0]!,
text: userId.split(":").first,
triggerCharacter: "@",
),
(_, final roomId?, _, _) => .new(
id: match[0]!,
text:
rooms["!$roomId"]?.metadata?.canonicalAlias?.localpart ??
"!$roomId",
triggerCharacter: "#",
),
(_, _, final alias?, _) => .new(
id: match[0]!,
text: "#$alias".localpart!,
triggerCharacter: "#",
),
(_, _, _, final shortcode) => .new(
id: match[0]!,
text: shortcode!,
triggerCharacter: ":",
),
};
return (
text: text.replaceAllMapped(_tagPattern, (match) {
final tag = tagOf(match);
return "${tag.triggerCharacter}${tag.id}#${tag.text}#";
}),
tags: _tagPattern.allMatches(text).map(tagOf).toISet().toIList(),
);
}
void dismiss() { void dismiss() {
if (state.isEditing) return _restoreBeforeEdit(); if (state.isEditing) return _restoreBeforeEdit();
state = state.copyWith(relatedEvent: null); state = state.copyWith(relatedEvent: null);

View file

@ -1,10 +0,0 @@
import "package:flutter_riverpod/flutter_riverpod.dart";
class LaunchScopeController extends Notifier<bool> {
@override
bool build() => true;
static final provider = NotifierProvider<LaunchScopeController, bool>(
LaunchScopeController.new,
);
}

View file

@ -2,15 +2,11 @@ import "dart:async";
import "dart:convert"; import "dart:convert";
import "dart:io"; import "dart:io";
import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:flutter/services.dart"; import "package:flutter/services.dart";
import "package:material_ui/material_ui.dart"; import "package:material_ui/material_ui.dart";
import "package:nexus/controllers/active_account.dart"; import "package:nexus/controllers/active_account.dart";
import "package:nexus/controllers/launch_scope.dart";
import "package:nexus/controllers/portal.dart"; import "package:nexus/controllers/portal.dart";
import "package:nexus/controllers/rooms.dart";
import "package:nexus/controllers/sidebar_page.dart"; import "package:nexus/controllers/sidebar_page.dart";
import "package:nexus/helpers/shown_notifications_helper.dart";
import "package:nexus/main.dart"; import "package:nexus/main.dart";
import "package:flutter_local_notifications/flutter_local_notifications.dart"; import "package:flutter_local_notifications/flutter_local_notifications.dart";
import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:flutter_riverpod/flutter_riverpod.dart";
@ -30,17 +26,7 @@ class NotificationController
Future<FlutterLocalNotificationsPlugin> build() async { Future<FlutterLocalNotificationsPlugin> build() async {
final notifications = FlutterLocalNotificationsPlugin(); final notifications = FlutterLocalNotificationsPlugin();
if (Platform.isLinux) { if (!Platform.isLinux) {
const MethodChannel("nexus/notifications")
.setMethodCallHandler((call) async {
if (call case MethodCall(
method: "notificationClicked",
arguments: final String payload,
)) {
_open(payload);
}
});
} else {
final darwin = DarwinInitializationSettings(); final darwin = DarwinInitializationSettings();
await notifications.initialize( await notifications.initialize(
@ -58,89 +44,26 @@ class NotificationController
if (details.payload case final payload?) _open(payload); if (details.payload case final payload?) _open(payload);
}, },
); );
await notifications
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin
>()
?.deleteNotificationChannel(channelId: "messages");
// Taps that launched the app don't reach the callback above
if (!isInBackground && ref.read(LaunchScopeController.provider)) {
if (await notifications.getNotificationAppLaunchDetails()
case NotificationAppLaunchDetails(
didNotificationLaunchApp: true,
notificationResponse: NotificationResponse(:final payload?),
)) {
_open(payload);
}
}
} }
// Reading a room, here or on another client, dismisses its notifications if (Platform.isLinux) {
if (!isInBackground) { const notificationChannel = MethodChannel("nexus/notifications");
ref.listen(
RoomsController.provider.select(
(rooms) => rooms
.where((_, room) => room.metadata?.unreadNotifications == 0)
.keys
.toISet(),
),
(previous, read) {
final newlyRead = read.difference(previous ?? const ISetConst({}));
if (newlyRead.isEmpty) return;
final accountId = ref.read(ActiveAccountController.provider); notificationChannel.setMethodCallHandler((call) async {
dismiss( if (call.method != "notificationClicked") {
newlyRead.map((roomId) => threadIdFor(accountId, roomId)).toISet(), return;
).onError(showError); }
},
fireImmediately: true, if (call.arguments case final String payload) _open(payload);
); });
} }
return notifications; return notifications;
} }
static String threadIdFor(String accountId, String roomId) =>
"$accountId/$roomId";
static String payloadFor(String accountId, int rowId) => "$accountId:$rowId"; static String payloadFor(String accountId, int rowId) => "$accountId:$rowId";
static const _messagesChannel = "messages_v2";
static const _androidGroup = "nexus.federated.nexus.MESSAGES";
/// Dismisses the notifications shown for [threadIds].
Future<void> dismiss(ISet<String> threadIds) async {
final ids = await ref
.read(ShownNotificationsHelper.provider)
.remove(threadIds);
if (ids.isEmpty) return;
if (Platform.isLinux) {
final portal = await ref.read(PortalController.provider.future);
await Future.wait(
ids.map((id) => portal.notification.removeNotification(id.toString())),
);
return;
}
final controller = await future;
await Future.wait(ids.map((id) => controller.cancel(id: id)));
// The summary would otherwise outlive its group
if (Platform.isAndroid &&
(await controller.getActiveNotifications()).every(
(notification) => notification.id == 0,
)) {
await controller.cancel(id: 0);
}
}
void _open(String payload) { void _open(String payload) {
navigatorKey.currentState?.popUntil((route) => route.isFirst);
ref.read(SidebarPageController.provider.notifier).set(.notifications);
final (accountId, rowId) = switch (payload.split(":")) { final (accountId, rowId) = switch (payload.split(":")) {
[final accountId, final rowId] => (accountId, int.tryParse(rowId)), [final accountId, final rowId] => (accountId, int.tryParse(rowId)),
// From before notifications were per account // From before notifications were per account
@ -149,6 +72,9 @@ class NotificationController
}; };
if (rowId == null) return; if (rowId == null) return;
navigatorKey.currentState?.popUntil((route) => route.isFirst);
ref.read(SidebarPageController.provider.notifier).set(.notifications);
ref ref
.read(ActiveAccountController.provider.notifier) .read(ActiveAccountController.provider.notifier)
.switchTo( .switchTo(
@ -158,21 +84,29 @@ class NotificationController
.onError(showError); .onError(showError);
} }
// Each resolves to null except on its own platform
Future<bool> requestPermissions() async { Future<bool> requestPermissions() async {
if (Platform.isLinux) {
return true;
}
final controller = await future; final controller = await future;
if (Platform.isIOS) {
return await controller return await controller
.resolvePlatformSpecificImplementation< .resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin IOSFlutterLocalNotificationsPlugin
>() >()
?.requestPermissions(alert: true, badge: true, sound: true) ?? ?.requestPermissions(alert: true, badge: true, sound: true) ??
await controller true;
} else if (Platform.isMacOS) {
return await controller
.resolvePlatformSpecificImplementation< .resolvePlatformSpecificImplementation<
MacOSFlutterLocalNotificationsPlugin MacOSFlutterLocalNotificationsPlugin
>() >()
?.requestPermissions(alert: true, badge: true, sound: true) ?? ?.requestPermissions(alert: true, badge: true, sound: true) ??
await controller true;
} else if (Platform.isAndroid) {
return await controller
.resolvePlatformSpecificImplementation< .resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin AndroidFlutterLocalNotificationsPlugin
>() >()
@ -180,23 +114,35 @@ class NotificationController
true; true;
} }
return true;
}
/// Whether notifications can currently be shown, without prompting /// Whether notifications can currently be shown, without prompting
Future<bool> permissionsGranted() async { Future<bool> permissionsGranted() async {
if (Platform.isLinux) {
return true;
}
final controller = await future; final controller = await future;
if (Platform.isIOS) {
return (await controller return (await controller
.resolvePlatformSpecificImplementation< .resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin IOSFlutterLocalNotificationsPlugin
>() >()
?.checkPermissions()) ?.checkPermissions())
?.isEnabled ?? ?.isEnabled ??
(await controller true;
} else if (Platform.isMacOS) {
return (await controller
.resolvePlatformSpecificImplementation< .resolvePlatformSpecificImplementation<
MacOSFlutterLocalNotificationsPlugin MacOSFlutterLocalNotificationsPlugin
>() >()
?.checkPermissions()) ?.checkPermissions())
?.isEnabled ?? ?.isEnabled ??
await controller true;
} else if (Platform.isAndroid) {
return await controller
.resolvePlatformSpecificImplementation< .resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin AndroidFlutterLocalNotificationsPlugin
>() >()
@ -204,6 +150,9 @@ class NotificationController
true; true;
} }
return true;
}
/// Passing [message] shows it as a chat message in the conversation for /// Passing [message] shows it as a chat message in the conversation for
/// [threadId], naming the sender in group chats. [subtitle] is shown on /// [threadId], naming the sender in group chats. [subtitle] is shown on
/// platforms that support it. /// platforms that support it.
@ -224,7 +173,6 @@ class NotificationController
// In DMs the title is already the sender // In DMs the title is already the sender
final sender = message == null || message.isDm ? null : message.sender; final sender = message == null || message.isDm ? null : message.sender;
final prefixedBody = sender == null ? body : "${sender.name}: $body"; final prefixedBody = sender == null ? body : "${sender.name}: $body";
final shown = ref.read(ShownNotificationsHelper.provider);
if (Platform.isLinux) { if (Platform.isLinux) {
final portal = await ref.read(PortalController.provider.future); final portal = await ref.read(PortalController.provider.future);
@ -251,7 +199,6 @@ class NotificationController
// ), // ),
], ],
); );
if (threadId != null) await shown.add(threadId, id);
return; return;
} }
@ -267,7 +214,6 @@ class NotificationController
.onError((_, _) => null) .onError((_, _) => null)
: null; : null;
final largeIcon = icon == null ? null : FilePathAndroidBitmap(icon.path);
final darwin = DarwinNotificationDetails( final darwin = DarwinNotificationDetails(
subtitle: subtitle, subtitle: subtitle,
presentSound: sound, presentSound: sound,
@ -284,24 +230,24 @@ class NotificationController
? .new( ? .new(
"general", "general",
"General", "General",
groupKey: _androidGroup,
subText: subtitle, subText: subtitle,
silent: !sound, silent: !sound,
when: timestamp?.millisecondsSinceEpoch, when: timestamp?.millisecondsSinceEpoch,
largeIcon: largeIcon, largeIcon: icon == null
? null
: FilePathAndroidBitmap(icon.path),
styleInformation: BigTextStyleInformation(body), styleInformation: BigTextStyleInformation(body),
) )
: .new( : .new(
_messagesChannel, "messages",
"Messages", "Messages",
importance: .high,
priority: .high,
groupKey: _androidGroup,
subText: subtitle, subText: subtitle,
silent: !sound, silent: !sound,
when: timestamp?.millisecondsSinceEpoch, when: timestamp?.millisecondsSinceEpoch,
category: .message, category: .message,
largeIcon: largeIcon, largeIcon: icon == null
? null
: FilePathAndroidBitmap(icon.path),
styleInformation: MessagingStyleInformation( styleInformation: MessagingStyleInformation(
.new(key: message.self.id, name: message.self.name), .new(key: message.self.id, name: message.self.name),
conversationTitle: message.isDm ? null : title, conversationTitle: message.isDm ? null : title,
@ -314,12 +260,11 @@ class NotificationController
.new( .new(
key: message.sender.id, key: message.sender.id,
name: message.sender.name, name: message.sender.name,
icon: switch (message.senderAvatar) { icon: message.senderAvatar == null
final avatar? => BitmapFilePathAndroidIcon( ? null
avatar.path, : BitmapFilePathAndroidIcon(
message.senderAvatar!.path,
), ),
null => null,
},
), ),
), ),
], ],
@ -336,28 +281,6 @@ class NotificationController
), ),
), ),
); );
if (threadId != null) await shown.add(threadId, id);
if (Platform.isAndroid) {
await controller.show(
id: 0,
title: "Nexus",
payload: payload,
notificationDetails: const .new(
android: .new(
_messagesChannel,
"Messages",
importance: .high,
groupKey: _androidGroup,
setAsGroupSummary: true,
groupAlertBehavior: .children,
onlyAlertOnce: true,
silent: true,
),
),
);
}
} }
static final provider = static final provider =

View file

@ -1,45 +0,0 @@
import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
typedef PendingSubprofile = ({String id, Future<void> synced});
/// Subprofiles just chosen for rooms, by room ID, until they come down sync.
/// gomuks only learns of them then, so messages sent before would use the
/// previous one.
class PendingSubprofilesController
extends Notifier<IMap<String, PendingSubprofile>> {
@override
IMap<String, PendingSubprofile> build() => const .empty();
Future<void> track(
String roomId,
String id,
Future<void> Function() save,
) async {
final synced = save();
state = state.add(roomId, (id: id, synced: synced));
try {
await synced;
} finally {
// Unless another subprofile was chosen meanwhile
if (state[roomId]?.synced == synced) state = state.remove(roomId);
}
}
Future<void> settled(String roomId) async {
try {
await state[roomId]?.synced;
} catch (_) {
throw Exception(
"The message wasn't sent, as the subprofile chosen for this room couldn't be saved",
);
}
}
static final provider =
NotifierProvider<
PendingSubprofilesController,
IMap<String, PendingSubprofile>
>(PendingSubprofilesController.new);
}

View file

@ -7,8 +7,6 @@ import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:fluttertagger/fluttertagger.dart"; import "package:fluttertagger/fluttertagger.dart";
import "package:nexus/controllers/attachment.dart"; import "package:nexus/controllers/attachment.dart";
import "package:nexus/controllers/client.dart"; import "package:nexus/controllers/client.dart";
import "package:nexus/controllers/pending_subprofiles.dart";
import "package:nexus/controllers/subprofiles.dart";
import "package:nexus/controllers/event.dart"; import "package:nexus/controllers/event.dart";
import "package:nexus/controllers/rooms.dart"; import "package:nexus/controllers/rooms.dart";
import "package:nexus/controllers/thread_replies.dart"; import "package:nexus/controllers/thread_replies.dart";
@ -401,7 +399,6 @@ class RoomChatController(final ChatParams info)
required RelationType relationType, required RelationType relationType,
int? relatedEventRowId, int? relatedEventRowId,
}) async { }) async {
final subprofile = subprofileFor(text);
final events = ref.read(RoomsController.provider)[info.roomId]?.events; final events = ref.read(RoomsController.provider)[info.roomId]?.events;
final relatedEvent = relatedEventRowId == null final relatedEvent = relatedEventRowId == null
? null ? null
@ -440,7 +437,6 @@ class RoomChatController(final ChatParams info)
); );
final client = ref.read(ClientController.provider.notifier); final client = ref.read(ClientController.provider.notifier);
await awaitSubprofile(text, subprofile);
final event = await client.sendMessage( final event = await client.sendMessage(
SendMessageRequest( SendMessageRequest(
roomId: info.roomId, roomId: info.roomId,
@ -462,24 +458,6 @@ class RoomChatController(final ChatParams info)
addSent(event); addSent(event);
} }
String? subprofileFor(String text, {bool synced = false}) {
final subprofiles = ref.read(SubprofilesController.provider(info.roomId));
return (subprofiles.triggeredBy(text) ??
(synced ? subprofiles.synced : subprofiles.current))
?.id;
}
Future<void> awaitSubprofile(String text, String? shown) async {
await ref
.read(PendingSubprofilesController.provider.notifier)
.settled(info.roomId);
if (subprofileFor(text, synced: true) != shown) {
throw Exception(
"The message wasn't sent, as it would have been sent as a different subprofile than shown",
);
}
}
/// Shows [event], which was just sent, until it comes down sync. /// Shows [event], which was just sent, until it comes down sync.
void addSent(Event? event) { void addSent(Event? event) {
if (event case final event?) { if (event case final event?) {
@ -636,7 +614,6 @@ class RoomChatController(final ChatParams info)
.read(RoomsController.provider)[info.roomId] .read(RoomsController.provider)[info.roomId]
?.events[repliedEventRowId]; ?.events[repliedEventRowId];
await awaitSubprofile("", subprofileFor(""));
final event = await ref final event = await ref
.read(ClientController.provider.notifier) .read(ClientController.provider.notifier)
.sendMessage( .sendMessage(

Some files were not shown because too many files have changed in this diff Show more