mirror of
https://github.com/bitwarden/mobile
synced 2024-12-23 07:26:44 +01:00
39a34bd8c4
* PM-3349 PM-3350 MAUI Migration Initial * PM-3349 PM-3350 MAUI Migration fix nullable exception bindings and AsyncCommand canExecute null exception * PM-3349 PM-3350 MAUI Migration fix nullable bindings and fallbacks * PM-3349: Android Added CustomTabbedPageHandler for Android to handle the tab "reselection" for PopToRoot. Commented support for Windows in App.csproj Disabled Interpreter on Android to avoid very slow app in Debug (during Login for example) Added some null checks that were causing crashes (on GeneratorPageVM and PickerVM) Minor TabsPage cleanup * TabBarEffect removed and it's behavior is now taken care of by CustomTabbedPageHandler * PM-3349 PM-3350 Add null checks on CipherDetailsPageVM to avoid crash opening Secure Notes. * PM-3349 PM-3350 MAUI Migration Start iOS extensions * Changes to solution to hopefully fix Config Mappings * PM-3349 Removed Deploy from iOS.Autofill to allow running Android Changed MainApplication SpecialFolder.Personal to SpecialFolder.LocalApplicationData * PM-3350 MAUI Migration Fix iOS Autofill extension * PM-3349 Changed UseMauiApp init so that Android Handlers still get added * PM-3349 Implemented HybridWebViewHandler for Android which enables 2nd factor auth flows Ensured CustomTabbedPageHandler had it's DisconnectHandler called Some minor code upgrades of older obsolete Xamarin Forms code. * PM-3349 Implemented HybridWebViewHandler for iOS * hardcoded AccountViewCell Avatar image to 40x40 to avoid current iOS/Android bugs where they fill much larger space. * PM-3349 PM-3350 Added (migrated) CustomNavigationHandler (which should partially fix the AvatarIcon in the NavBar in iOS) Added (migrated) CustomContentPageHandler (which should mostly place the AvatarIcon in the navBar in the correct place for iOS) Added Task.Delay (workaround) to allow the Avatar to load in iOS on the LoginPage Added workaround for iOS bug with the toolbar size (more info in comment in AvatarImageSource.cs) Went through the AccountViewCell MAUI-Migration comments. (and deleted/added more comments as needed) Migrated some Device calls to DeviceInfo and MainThread Added (migrated) CustomTabbedHandler (for managing the iOS TabBar) * PM-3349 Replaced the FabShadowEffect with the new MAUI Shadow to fix the buggy shadows on the Android Fab Button. * PM-3349 ToolbarHandler created for setting text on Android go back buttons. * PM-3350 Migrated the CustomViewCellRenderer for iOS * PM-3350 Removed ButtonHandlerMappings and some other code related with fonts as MAUI is taking care of Accessibility and no custom code should be needed Migrated SelectableLabelRenderer to Handler Cleaned LabelHandlerMappings and added logic to migrate the CustomLabelRenderer * Enabled argon2Id for iOS * PM-3349 Added Argon libraries for Android minor change to gitignore so that the Argon x86 lib is not ignored on the Android platform * PM-3350 Migrated some Device to DeviceInfo and added temporary workaround with some comments to be able to see the Generated Password on iOS * PM-3350 Added some missing images in iOS * PM-3349 PRM-3350 Replaced XZing with Camera.MAUI for QRCodes * Checked some [MAUI-Migration] and deleted when it's working as intended. SearchBarHandlerMapping: IME options working as intended SliderHandlerMappings: The MAUI "replacement" for Color.Default seems to be White so the old use case doesn't seem to be needed anymore. * PM-3350 Checked some [MAUI-Migration] and changed as needed. TimePickerHandlerMappings: Remove old code for forcing the Wheel. After testing without it wheel picker is still used so this code shouldn't be needed anymore. AppDelegate.ContinueUserActivity: Uncommented and changed the iOS ContinueUserActivity. It needs to call Platform.ContinueUserActivity according with Xamarin Essentials migration docs. * PM-3349 Fixed white tint color not appearing on images added as MAU IImage SVG PM-3349 PM-3350 Fix for Avatar text not adjusting to white/black color correctly * PM-3350 Removed MAUI Splash Screen. Fixed iOS Privacy Screen logo (hardcoded image to avoid it getting cropped) * PM-3350 Quick workaround to allow 2nd factor auth to not get stuck in iOS in modals. Updated some older "Device" code to the newer MAUI code. * PM-3350 Removed duplicate reference to LaunchScreen.storyboard * PM-3349 PM-3350 Minor change to HomePage to set fixed Image height otherwise it takes more space than it did in the old Xamarin Forms app. Added HIdeSoftInputOnTapped on several pages (the ones with Entry controls) to allow hiding the keyboard when tapping "outside" of it. (just like we did in Xamarin Forms app) * PM-3350 Added Scrollview on HomePage so that the "Create account" button can be accessed in smaller devices like iPhone SE. * PM-3349 Added Handler that enables the ExtendedDatePicker to get IsFocused events in Android. This is a workaround for fixing the current bug where it's not possible to select the "current day" in the expiration date of a Send. Fix for TimePicker not displaying default Time Value Updated some "Device" code to the new MAUI "DeviceInfo" * PM-3349 PM-3350 Migrated IconLabelButton Frames to Borders to fix issue with TapGestureRecognizer in Android Also fixed some minor "styles" for normal Button and IconLabelButton (both Android and iOS) * PM-3349 Fix for TabGestureRecognizer not working inside the StackLayout area of IconLabelButton * PM-3349 Fix for Android buttons having all letters in Caps * PM-3349 PM-3350 Started using OnNavigatedTo/From instead of On(Dis)Appearing for LoginPage and LoginSSOPage to avoid the "Modal loading" issues in iOS Also had to add IsInitialized logic to these pages because OnNavigatedTo can be called twice in some scenario. Some minor migrations of Device to DeviceInfo was also done * PM-3350 Fixed iOS extensions (iOS.Extension and iOS.ShareExtension) to load and commented argon2id from debug configuration until we have the .a compiled again with the new platform/arch * PM-3350 Added configurations for Release mode (no FDroid yet) * PM-3349 PM-3350 Migrated remaining AutomationProperties to SemanticProperties. All 'IsInAccessibleTree="True"' were deleted. 'IsInAccessibleTree="False"' were kept and stayed in code. * PM-3349 PM-3350 Changed binding set for CipherViewCell so it updates accordingly * PM-3349 PM-3350 Changed AccountViewCell and its binding to be directly against the ViewModel * PM-3349 Fix for HTML Label on Android. Color hex doesn't need to be cropped anymore. * PM-3350 Fix for colored html text on iOS * PM-3349 PM-3350 Added the partial MAUI Community Toolkit implementation for TouchEffect. This is a temporary solution until they finalize this and add it to their nuget package. This allows implementing the LongPressCommand in AccountSwitchingOverlay and also have the "Ripple effect" animation when touching an item in Android * PM-3349 PM-3350 Changed SendViewCell and its binding to be directly against the ViewModel * PM-3350 Fixed iOS Share extension lazy views loading and an issue with the avatar loading. Also discovered issue with TapGestureRecognizer not working on MAUI Embedding * PM-3350 Fixed iOS Extensions navigation to several pages and improved avoiding duplicate calls to OnNavigatedTo * PM-3350 Updated PCL Crypto to latest alpha version to fix "Dll not found NCrypt" issue * PM-3350 Removed workaround for iOS issue with Avatar icon as it's now fixed in latest .Net8 release. * PM-3349 PM-3350 Removed AsyncCommand "wrapper" and added AsyncRelayCommand directly in all ViewModels that were using the other one. * PM-3350 Added watchOS app to main project and fixed some csproj conditions for runtime identifiers on iOS. * PM-3350 Fixed/Updated all MAUI-Migration TODOs * PM-3350 Fixed account toolbar item and TitleView on SendAddOnlyPage, also removed comments on AvatarImageSource given the workaround is not needed anymore to draw the image successfully. * PM-3350 Updated AppCenter package to latest version 5.0.3 and updated some things into MAUI style * PM-3350 Added workaround for iOS Avatar icon again. * PM-3349 Added workaround for Android to avoid issues with setting MainPage when app is in background. They are now kept on a Queue to be executed after the app has resumed. Updated some things on App.xaml.cs to the new MAUI style * PM-3349 PM-3350 Fixed issue where creating an account with weak/exposed password would get stuck after the Captcha (if a captcha is shown) Changed App.xaml.cs NavigateImpl to be private * PM-3349 Started to configure build.yml for MAUI Android * PM-3349 build.yml update paths for MAUI Android * PM-3349 build.yml commented verify format and just set qa as variant on MAUI Android for faster checks on CI * PM-3349 PM-3350 build.cake updated paths * PM-3349 build.yml updated env helpers variables and set specific csproj to build on Android so not to build iOS extensions * PM-3349 build.yml add Android "prod" variant * PM-3350 build.yml updated iOS build and ignore Android build to try the CI faster * PM-3350 build.yml changed nuget restore for dotnet restore on iOS build to fix issue on restoring due to msbuild * PM-3350 build.yml Upgraded iOS build to run on macos-13 image which has XCode 15, and set the XCode 15 version as currently the default one is 14.x * PM-3350 build.yml try to fix ILLINK warnings and changed image to be macos-13-arm64 to see if the build is faster * PM-3350 build.yml changed image back to be macos-13 to see if the build is faster * PM-3350 Added Document.Build.props to disable trimming on publish * PM-3350 build.yml disable trimming on publish so it's faster * PM-3350 added linkskip for iOS csprojs * PM-3350 iOS projs disable linking and set Newstandkit as weak framework * Update build.yml disabling iOS job to avoid long running process of publish until we can fix that * PM-3349 PM-3350 Workaround to fix issues with text getting cropped/truncated when a Label has both Multiline and LinebreakMode set * PM-3349 build.yml enabled android build workflow * PM-3349 build.yml configured FDROID job for MAUI * PM-3350 iOS extensions TapGestureRecognizer try Window workaround * PM-3350 iOS applied workaround on the iOS Autofill and Share extension to maui embed the navigation page with its content page in the Window * PM-3349 PM-3350 Added workaround for More Options to work on Search and Groupings Page Updated some code to MAUI Style also * PM-3349 PM-3350 Added the ability for users to press "Continue" button as a fallback when using the Yubikey if the "SubmitCommand" doesn't trigger automatically. * PM-3349 PM-3350 Fix for text getting cut/truncated in both account switcher and ciphers/search lists Issue is due to MAUI but can be avoided by using slightly different layout * PM-3350 iOS updated CFBundlerShortVersionString to latest one 2023.10.1 * PM-3350 fix build.yml Bitwarden.ipa AppStore exported file * PM-3350 build.yml added step to validate app for submitting into App Store and have better logs of it * PM-3350 build.yml Added several fixes like not using MtouchUseLLVM on the iOS builds to fix they taking forever to build and some changes on the automation CI to do a debug build for the moment * PM-3350 Improved MTouch linking and extra args on iOS related csprojs * PM-3349 PM-3350 Added MAUI label on self-host settings and on about settings to differentiate from XF app * PM-3349 PM-3350 build.yml uncommented jobs so we have a more complete workflow * PM-3349 PM-3350 Minor change: removed unneeded HorizontalTextAlignment from Label. * PM-3349 Replaced CrossCurrentActivity plugin with MAUI internal CurrentActivity * PM-3350 Fix iOS extensions navigation and Window/RootViewController handling for TapGestureRecognizer to work * PM-3350 Cleared left ClipLogger from the iOS extensions debug logging. * PM-3349 PM-3350 Refactored cipher bindings to have a simpler approach reusing a new CipherItemViewModel to avoid unwanted issues in the app * PM-3349 Added base structure for avoiding Android Autofill crash. This workaround works but it's not complete as it can't handle the entire workflow when showing CipherSelectionPAge (like checking if it should show LockPage) * PM-3350 Bumped iOS version * PM-3350 Changed linker to use default mode given that "Full" is presenting some problems as the linker is stripping things it shouldn't and we're trying to solve it. So for now we will use the mode "Link SDK assemblies only" so QA can test. * PM-3349 Fix for app crashing on Android when Dark mode is enabled Removed unused button style for android * Proof of concept for having multiple window in Android for autofill support and navigating with the help of an Extended splash page. * PM-3350 Fix crash on Release by adding Interpreter on iOS and also adding System.Security.Cryptography to be ignored by the linker * PM-3350 Apply Cryptography TrimmerRootAssembly only to iOS * PM-3350 Updated Plugin.Fingerprint so biometrics work * Update .github/workflows/build.yml setup-xcode commit hash Co-authored-by: Vince Grassia <593223+vgrassia@users.noreply.github.com> * PM-3349 PM-3350 Enabled argon2id and fixed one issue with the Uris when getting the icon image * PM-3349 Upgraded Android targetSdkVersion to 34 * minor change (public to private fields) * minor improvemments on autofill-redirect * PM-3349 Commented the Deploy step for Android job given that we're using the hotfix-rc branch for testing iOS on TestFlight * PM-3349 Uncommented the Deploy step for Android job * PM-3349 Ensure "_isResumed=true" is set on App.xaml.cs:Bootstrap * Reusing App.xaml.cs Navigation for the Android RedirectPage Some other cleanup and changes * Improved autofill workaround to better handle switching between windows. * PM-3349 minor fix to add space in HomePage between the region picker labels. * Added some comments and improvemments. * PM-3349 Added Window events unsubscription of events. Also changed code to avoid potentially having multiple autofillwindow * PM-3349 Minor ui fix (space between buttons in delete account page) * initial commit of android credential provider service (wip) * Revert "initial commit of android credential provider service (wip)" This reverts commit6011b63958
. * PM-3350 Fix for Delete Account buttons on iOS * PM-3349 PM-3350 Changed search icon used in app to avoid issue with icon size on iOS * PM-3349 Added custom window so that we can always get the current Active Window. This is used to support the Android Autofil and multi-window scenarios. * PM-3349 Fix for icon and text spacing in some list items * PM-3349 Minor aligment improvemment for region selection in HomePage * PM-3349 Changed the "track color" for the Android switch so that the color is different from the "thumb" * PM-3350 Updated version to 2024.1.0 on iOS * PM-3349 Fix Picker selection style by doing a custom PickerHandler for Android which uses SetSingleChoiceItems(...) to provide with the appropriate UI * PM-3350 Updated MauiVersion to 8.0.4-nightly.* to have the TapGestureRecognizer fix applied. This is done on the Directory.Build.props so we don't have to change it on every csproj. Also removed the workaround of TapGestureHack and fix the Show environment picker to work on the extensions as well. * PM-3350 Added nuget.config so we add the nuget package source for MAUI Nightly builds * Bump main iOS version * PM-3350 Removed "iOS" old folder project that has been moved into the MAUI Single app project. * PM-3350 Improved code safety adding a lot of try...catch and logging throughout the app. Also made the invoking on main thread safer on several places of the app. Additionally, on the GroupingsPageViewModel changed the code removing the old Xamarin hack and just using Replace directly instead of Clearing first to see if that fixes the crash we're having sometimes on the app. * PM-3350 PM-3349 Updated Unit Test projects to NET 8.0 and fixed it to work with Core project reference. Also fixed a test that was breaking due to CIpherKey creation being wrong. Added "UT" as a constant to add when building/running Core.Test project so we have something on the context that tells us that is for a UT. With this I had to remove FFImageLoading on UT context because it doesn't support NET 8.0 * PM-3350 PM-3349 Updated Readme with MAUI and main branch * PM-3350 PM-3349 Enable running Core tests * PM-3350 Fix build.yml format * PM-3349 Fix navigation when coming from autofill with Accessibility Services enabled. The user was getting into Home page instead of where they were, with this workaround the app navigates as if the account has been switched, leaving the user as closely as possible to where they were, basically on the first screen for the current state of the user. * PM-3350 PM-3349 Added property to Directory.Build.props to enable Unit Testing globally so Test runners work * Improve TOTP scan performance on Android * Move Android camera/scan changes to xaml * PM-3350 Testing UseInterpreter false on CI build * PM-3350 Enabled back UseInterpreter on iOS Release given that it crashes on startup without it. * PM-3349 PM-3350 Improved code safety with try...catch, better invoke on main thread and better null handling. * PM-3349 PM-3350 Updated XCode version on build.yml to 15.1 * PM-3350 Removed TapGesture Window MAUI hack from iOS.Extension and iOS.ShareExtension * PM-3350 Fixed CancellationTokenSource proper disposal * PM-3350 Fix Avatar toolbar icon on extensions to load properly and to take advantage of using directly SkiaSharp to do the native conversion to UIImage. Also improved the toolbar item so that size is set appropriately. * PM-3349 PM-3350 Fix external link icon * PM-3350 Added new style to prevent spell check and text prediction * Fix merge from main * PM-3350 Commented event collection upload on the timer and when sending the app to background to see if that prevents the app from crashing on release mode. * PM-3350 Added check for state migration version before trying to migrate LiteDB values into Prefs when there's no need to and that may be inducing crashes on backgrounded iOS apps. * PM-3350 Try to disable Interpreter to have better crash knowledge. This time testing if avoiding loading the argon2id lib we're able to not use the interpreter. * PM-5928 Fix circle animation to be shown on verification codes list on each item * PM-3350 Go back to use Interpreter and added some Directory.Build.props to easily change Codesign properties and also include/exclude iOS extensions / WatchOS from the build. * PM-3350 Enabled iOS extensions and WatchOS app to be included based on the Directory.Build.props * PM-3350 Go back to include argon2id and interpreter * Removing error/loading placeholders of icons on the cells to see if that is causing the background crash on iOS; so we can test this in TestFlight * [PM-5910] Workaround for for sliding elements in Duo 2FA flow (#2967) * workaround for sliding elements in duo 2fa flow * restrict workaround to Android * restrict workaround to Android * Revert "restrict workaround to Android" This reverts commitc2753d5dc4
. * Revert "restrict workaround to Android" This reverts commit69688cfb98
. * PM-5902 fix for account switcher not dismissing when tapping outside (#2974) * PM-3350 Fix iossimulator-x64 argon2id load so we can test on simulators and also made easier to maintain loading the argon2id library on the iOS projects by setting a general Directory.Build.props that is shared. * PM-5903 Changed App.xaml.cs SetOption to only update the needed properties instead of replacing the existing Options object which would cause the AccountSwitcher button bug (#2973) * [PM-5896] Fix MAUI iOS Background crash due to lock files on suspension (#2969) * PM-5896 Fix background crash on iOS due to lock files when app gets suspended. Changed loading and error placeholders of the CachedImage to not be used and use default icon of IconLabel instead changing visibility. * PM-5896 Changed methods to be protected so that they don't get removed by the linker. * PM-5896 Added stub class and references to it so to have stronger references to Icon_Success and Icon_Error so the linker doesn't remove them. * PM-3349 Removed commented code from build.yml regarding FDroid that is not needed anymore. * PM-6077 Separated Android and iOS HybridWebViewHandler so that it can be used on iOS.Core (#2983) * [PM-5907] Fix for incorrect TOTP white text color on label when using light theme on iOS (#2982) * PM-5907 workaround for incorrect textcolor when programmatically changing text on Entry * Update src/Core/Pages/Vault/CipherAddEditPage.xaml.cs Co-authored-by: Federico Maccaroni <fedemkr@gmail.com> --------- Co-authored-by: Federico Maccaroni <fedemkr@gmail.com> * [PM-5906] Fix for incorrect Send MaxAccess white text color on label when using light theme on iOS (#2981) * PM-5906 workaround for incorrect textcolor when programmatically changing text on Entry * Update src/Core/Pages/Send/SendAddEditPage.xaml.cs Co-authored-by: Federico Maccaroni <fedemkr@gmail.com> --------- Co-authored-by: Federico Maccaroni <fedemkr@gmail.com> * PM-3349 PM-3350 Fixed Unit tests because of referencing FFImageLoading when it's not possible --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> Co-authored-by: Vince Grassia <593223+vgrassia@users.noreply.github.com> Co-authored-by: mpbw2 <59324545+mpbw2@users.noreply.github.com>
440 lines
18 KiB
C#
440 lines
18 KiB
C#
#addin nuget:?package=Cake.FileHelpers&version=5.0.0
|
|
#addin nuget:?package=Cake.AndroidAppManifest&version=1.1.2
|
|
#addin nuget:?package=Cake.Plist&version=0.7.0
|
|
#addin nuget:?package=Cake.Incubator&version=7.0.0
|
|
#tool dotnet:?package=GitVersion.Tool&version=5.10.3
|
|
using Path = System.IO.Path;
|
|
using System.Text.RegularExpressions;
|
|
|
|
var debugScript = Argument<bool>("debugScript", false);
|
|
var target = Argument("target", "Default");
|
|
var configuration = Argument("configuration", "Release");
|
|
var variant = Argument("variant", "dev");
|
|
|
|
abstract record VariantConfig(
|
|
string AppName,
|
|
string AndroidPackageName,
|
|
string iOSBundleId,
|
|
string ApsEnvironment
|
|
);
|
|
|
|
const string BASE_BUNDLE_ID_DROID = "com.x8bit.bitwarden";
|
|
const string BASE_BUNDLE_ID_IOS = "com.8bit.bitwarden";
|
|
|
|
record Dev(): VariantConfig("Bitwarden Dev", $"{BASE_BUNDLE_ID_DROID}.dev", $"{BASE_BUNDLE_ID_IOS}.dev", "development");
|
|
record QA(): VariantConfig("Bitwarden QA", $"{BASE_BUNDLE_ID_DROID}.qa", $"{BASE_BUNDLE_ID_IOS}.qa", "development");
|
|
record Beta(): VariantConfig("Bitwarden Beta", $"{BASE_BUNDLE_ID_DROID}.beta", $"{BASE_BUNDLE_ID_IOS}.beta", "production");
|
|
record Prod(): VariantConfig("Bitwarden", $"{BASE_BUNDLE_ID_DROID}", $"{BASE_BUNDLE_ID_IOS}", "production");
|
|
|
|
VariantConfig GetVariant() => variant.ToLower() switch{
|
|
"qa" => new QA(),
|
|
"beta" => new Beta(),
|
|
"prod" => new Prod(),
|
|
_ => new Dev()
|
|
};
|
|
|
|
GitVersion _gitVersion; //will be set by GetGitInfo task
|
|
var _slnPath = Path.Combine(""); //base path used to access files. If build.cake file is moved, just update this
|
|
string _androidPackageName = string.Empty; //will be set by UpdateAndroidManifest task
|
|
string _iOSVersionName = string.Empty; //will be set by UpdateiOSPlist task
|
|
string CreateFeatureBranch(string prevVersionName, GitVersion git) => $"{prevVersionName}-{git.BranchName.Replace("/","-")}";
|
|
string GetVersionName(string prevVersionName, VariantConfig buildVariant, GitVersion git) => buildVariant is Prod? prevVersionName : CreateFeatureBranch(prevVersionName, git);
|
|
int CreateBuildNumber(int previousNumber) => ++previousNumber;
|
|
|
|
Task("GetGitInfo")
|
|
.Does(()=> {
|
|
_gitVersion = GitVersion(new GitVersionSettings());
|
|
|
|
if(debugScript)
|
|
{
|
|
Information($"GitVersion Dump:\n{_gitVersion.Dump()}");
|
|
}
|
|
|
|
Information("Git data Load successfully.");
|
|
});
|
|
|
|
#region Android
|
|
Task("UpdateAndroidAppIcon")
|
|
.Does(()=>{
|
|
//TODO we'll implement variant icons later
|
|
//manifest.ApplicationIcon = "@mipmap/ic_launcher";
|
|
Information($"Updated Androix App Icon with success");
|
|
});
|
|
|
|
|
|
Task("UpdateAndroidManifest")
|
|
.IsDependentOn("GetGitInfo")
|
|
.Does(()=>
|
|
{
|
|
var buildVariant = GetVariant();
|
|
var manifestPath = Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "AndroidManifest.xml");
|
|
|
|
// Cake.AndroidAppManifest doesn't currently enable us to access nested items so, quick (not ideal) fix:
|
|
var manifestText = FileReadText(manifestPath);
|
|
manifestText = manifestText.Replace("com.x8bit.bitwarden.", buildVariant.AndroidPackageName + ".");
|
|
manifestText = manifestText.Replace("android:label=\"Bitwarden\"", $"android:label=\"{buildVariant.AppName}\"");
|
|
FileWriteText(manifestPath, manifestText);
|
|
|
|
var manifest = DeserializeAppManifest(manifestPath);
|
|
|
|
var prevVersionCode = manifest.VersionCode;
|
|
var prevVersionName = manifest.VersionName;
|
|
_androidPackageName = manifest.PackageName;
|
|
|
|
//manifest.VersionCode = CreateBuildNumber(prevVersionCode);
|
|
manifest.VersionName = GetVersionName(prevVersionName, buildVariant, _gitVersion);
|
|
manifest.PackageName = buildVariant.AndroidPackageName;
|
|
manifest.ApplicationLabel = buildVariant.AppName;
|
|
|
|
//Information($"AndroidManigest.xml VersionCode from {prevVersionCode} to {manifest.VersionCode}");
|
|
Information($"AndroidManigest.xml VersionName from {prevVersionName} to {manifest.VersionName}");
|
|
Information($"AndroidManigest.xml PackageName from {_androidPackageName} to {buildVariant.AndroidPackageName}");
|
|
Information($"AndroidManigest.xml ApplicationLabel to {buildVariant.AppName}");
|
|
|
|
SerializeAppManifest(manifestPath, manifest);
|
|
|
|
Information("AndroidManifest updated with success!");
|
|
});
|
|
|
|
void ReplaceInFile(string filePath, string oldtext, string newtext)
|
|
{
|
|
var fileText = FileReadText(filePath);
|
|
|
|
if(string.IsNullOrEmpty(fileText) || !fileText.Contains(oldtext))
|
|
{
|
|
throw new Exception($"Couldn't find {filePath} or it didn't contain: {oldtext}");
|
|
}
|
|
|
|
fileText = fileText.Replace(oldtext, newtext);
|
|
|
|
FileWriteText(filePath, fileText);
|
|
Information($"{filePath} modified successfully.");
|
|
}
|
|
|
|
Task("UpdateAndroidCodeFiles")
|
|
.IsDependentOn("UpdateAndroidManifest")
|
|
.Does(()=> {
|
|
var buildVariant = GetVariant();
|
|
|
|
//We're not using _androidPackageName here because the codefile is currently slightly different string than the one in AndroidManifest.xml
|
|
var keyName = "com.8bit.bitwarden";
|
|
var fixedPackageName = buildVariant.AndroidPackageName.Replace("x8bit", "8bit");
|
|
var filePath = Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Services", "BiometricService.cs");
|
|
ReplaceInFile(filePath, keyName, fixedPackageName);
|
|
|
|
var packageFileList = new string[] {
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "MainActivity.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "MainApplication.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Constants.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Accessibility", "AccessibilityService.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Autofill", "AutofillHelpers.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Autofill", "AutofillService.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Receivers", "ClearClipboardAlarmReceiver.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Receivers", "EventUploadReceiver.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Receivers", "PackageReplacedReceiver.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Receivers", "RestrictionsChangedReceiver.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Services", "DeviceActionService.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Services", "FileService.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Tiles", "AutofillTileService.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Tiles", "GeneratorTileService.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Tiles", "MyVaultTileService.cs"),
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "google-services.json"),
|
|
Path.Combine(_slnPath, "store", "google", "Publisher", "Program.cs"),
|
|
};
|
|
|
|
foreach(string path in packageFileList)
|
|
{
|
|
ReplaceInFile(path, "com.x8bit.bitwarden", buildVariant.AndroidPackageName);
|
|
}
|
|
|
|
var labelFileList = new string[] {
|
|
Path.Combine(_slnPath, "src", "App", "Platforms", "Android", "Autofill", "AutofillService.cs"),
|
|
};
|
|
|
|
foreach(string path in labelFileList)
|
|
{
|
|
ReplaceInFile(path, "Bitwarden\"", $"{buildVariant.AppName}\"");
|
|
}
|
|
});
|
|
#endregion Android
|
|
|
|
#region iOS
|
|
enum iOSProjectType
|
|
{
|
|
Null,
|
|
MainApp,
|
|
Autofill,
|
|
Extension,
|
|
ShareExtension,
|
|
WatchApp
|
|
}
|
|
|
|
string GetiOSBundleId(VariantConfig buildVariant, iOSProjectType projectType) => projectType switch
|
|
{
|
|
iOSProjectType.Autofill => $"{buildVariant.iOSBundleId}.autofill",
|
|
iOSProjectType.Extension => $"{buildVariant.iOSBundleId}.find-login-action-extension",
|
|
iOSProjectType.ShareExtension => $"{buildVariant.iOSBundleId}.share-extension",
|
|
iOSProjectType.WatchApp => $"{buildVariant.iOSBundleId}.watchkitapp",
|
|
_ => buildVariant.iOSBundleId
|
|
};
|
|
|
|
string GetiOSBundleName(VariantConfig buildVariant, iOSProjectType projectType) => projectType switch
|
|
{
|
|
iOSProjectType.Autofill => $"{buildVariant.AppName} Autofill",
|
|
iOSProjectType.Extension => $"{buildVariant.AppName} Extension",
|
|
iOSProjectType.ShareExtension => $"{buildVariant.AppName} Share Extension",
|
|
_ => buildVariant.AppName
|
|
};
|
|
|
|
private void UpdateiOSInfoPlist(string plistPath, VariantConfig buildVariant, GitVersion git, iOSProjectType projectType = iOSProjectType.MainApp)
|
|
{
|
|
var plistFile = File(plistPath);
|
|
dynamic plist = DeserializePlist(plistFile);
|
|
|
|
var prevVersionName = plist["CFBundleShortVersionString"];
|
|
var prevVersionString = plist["CFBundleVersion"];
|
|
var prevVersion = int.Parse(plist["CFBundleVersion"]);
|
|
var prevBundleId = plist["CFBundleIdentifier"];
|
|
var prevBundleName = plist["CFBundleName"];
|
|
//var newVersion = CreateBuildNumber(prevVersion).ToString();
|
|
var newVersionName = GetVersionName(prevVersionName, buildVariant, git);
|
|
var newBundleId = GetiOSBundleId(buildVariant, projectType);
|
|
var newBundleName = GetiOSBundleName(buildVariant, projectType);
|
|
|
|
plist["CFBundleName"] = newBundleName;
|
|
plist["CFBundleDisplayName"] = newBundleName;
|
|
//plist["CFBundleVersion"] = newVersion;
|
|
plist["CFBundleShortVersionString"] = newVersionName;
|
|
plist["CFBundleIdentifier"] = newBundleId;
|
|
|
|
if(projectType == iOSProjectType.MainApp)
|
|
{
|
|
_iOSVersionName = newVersionName;
|
|
plist["CFBundleURLTypes"][0]["CFBundleURLName"] = $"{buildVariant.iOSBundleId}.url";
|
|
}
|
|
|
|
if(projectType == iOSProjectType.Extension)
|
|
{
|
|
var keyText = plist["NSExtension"]["NSExtensionAttributes"]["NSExtensionActivationRule"];
|
|
plist["NSExtension"]["NSExtensionAttributes"]["NSExtensionActivationRule"] = keyText.Replace("com.8bit.bitwarden", buildVariant.iOSBundleId);
|
|
}
|
|
|
|
SerializePlist(plistFile, plist);
|
|
|
|
Information($"Changed app name from {prevBundleName} to {newBundleName}");
|
|
//Information($"Changed Bundle Version from {prevVersion} to {newVersion}");
|
|
Information($"Changed Bundle Short Version name from {prevVersionName} to {newVersionName}");
|
|
Information($"Changed Bundle Identifier from {prevBundleId} to {newBundleId}");
|
|
Information($"{plistPath} updated with success!");
|
|
}
|
|
|
|
private void UpdateiOSEntitlementsPlist(string entitlementsPath, VariantConfig buildVariant)
|
|
{
|
|
var EntitlementlistFile = File(entitlementsPath);
|
|
dynamic Entitlements = DeserializePlist(EntitlementlistFile);
|
|
|
|
Entitlements["aps-environment"] = buildVariant.ApsEnvironment;
|
|
Entitlements["keychain-access-groups"] = new List<string>() { "$(AppIdentifierPrefix)" + buildVariant.iOSBundleId };
|
|
Entitlements["com.apple.security.application-groups"] = new List<string>() { $"group.{buildVariant.iOSBundleId}" };;
|
|
|
|
Information($"Changed ApsEnvironment name to {buildVariant.ApsEnvironment}");
|
|
Information($"Changed keychain-access-groups bundleID to {buildVariant.iOSBundleId}");
|
|
|
|
SerializePlist(EntitlementlistFile, Entitlements);
|
|
|
|
Information($"{entitlementsPath} updated with success!");
|
|
}
|
|
|
|
private void UpdateWatchKitAppInfoPlist(string plistPath, VariantConfig buildVariant)
|
|
{
|
|
var plistFile = File(plistPath);
|
|
dynamic plist = DeserializePlist(plistFile);
|
|
|
|
var prevBundleId = plist["NSExtension"]["NSExtensionAttributes"]["WKAppBundleIdentifier"];
|
|
var newBundleId = GetiOSBundleId(buildVariant, iOSProjectType.WatchApp);
|
|
|
|
plist["NSExtension"]["NSExtensionAttributes"]["WKAppBundleIdentifier"] = newBundleId;
|
|
|
|
SerializePlist(plistFile, plist);
|
|
|
|
Information($"Changed Bundle Identifier from {prevBundleId} to {newBundleId}");
|
|
Information($"{plistPath} updated with success!");
|
|
}
|
|
|
|
private void UpdateWatchPbxproj(string pbxprojPath, string newVersion)
|
|
{
|
|
var fileText = FileReadText(pbxprojPath);
|
|
if (string.IsNullOrEmpty(fileText))
|
|
{
|
|
throw new Exception($"Couldn't find {pbxprojPath}");
|
|
}
|
|
|
|
const string pattern = @"MARKETING_VERSION = [^;]*;";
|
|
|
|
fileText = Regex.Replace(fileText, pattern, $"MARKETING_VERSION = {newVersion};");
|
|
|
|
FileWriteText(pbxprojPath, fileText);
|
|
Information($"{pbxprojPath} modified successfully.");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the target icons on the given appiconset target
|
|
/// taking as source the icon in appIcons/iOS folder for the giving variant
|
|
/// </summary>
|
|
/// <param name="target">It can be <ios|watch|complication|macos></param>
|
|
/// <param name="appiconsetTarget">Folder to copy the generated icons to</param>
|
|
private void UpdateAppleIcons(string target, string appiconsetTarget)
|
|
{
|
|
Information($"Updating {target} App Icons");
|
|
|
|
var iconsTempDirPath = Path.Combine(_slnPath, "appIcons", "temp");
|
|
CreateDirectory(iconsTempDirPath);
|
|
|
|
var arguments = new ProcessArgumentBuilder();
|
|
arguments.Append(target);
|
|
arguments.Append(Path.Combine(_slnPath, "appIcons", "iOS", $"{variant}.png"));
|
|
arguments.Append(iconsTempDirPath);
|
|
|
|
using(var process = StartAndReturnProcess(Path.Combine(_slnPath, "appIcons", "icongen.sh"),
|
|
new ProcessSettings { Arguments = arguments }))
|
|
{
|
|
process.WaitForExit();
|
|
Information("Exit code: {0}", process.GetExitCode());
|
|
}
|
|
|
|
var generatedIconsPath = Path.Combine(iconsTempDirPath, "*.png");
|
|
CopyFiles(generatedIconsPath, appiconsetTarget);
|
|
|
|
DeleteDirectory(iconsTempDirPath, new DeleteDirectorySettings {
|
|
Recursive = true,
|
|
Force = true
|
|
});
|
|
|
|
Information($"{target} App Icons have been updated");
|
|
}
|
|
|
|
Task("UpdateiOSIcons")
|
|
.Does(()=>{
|
|
UpdateAppleIcons("ios", Path.Combine(_slnPath, "src", "App", "Platforms", "iOS", "Resources", "Assets.xcassets", "AppIcons.appiconset"));
|
|
UpdateAppleIcons("watch", Path.Combine(_slnPath, "src", "watchOS", "bitwarden", "bitwarden WatchKit App", "Assets.xcassets", "AppIcon.appiconset"));
|
|
// TODO: Update complication icons when they start working
|
|
});
|
|
|
|
Task("UpdateiOSPlist")
|
|
.IsDependentOn("GetGitInfo")
|
|
.Does(()=> {
|
|
var buildVariant = GetVariant();
|
|
var infoPath = Path.Combine(_slnPath, "src", "App", "Platforms", "iOS", "Info.plist");
|
|
var entitlementsPath = Path.Combine(_slnPath, "src", "App", "Platforms", "iOS", "Entitlements.plist");
|
|
UpdateiOSInfoPlist(infoPath, buildVariant, _gitVersion, iOSProjectType.MainApp);
|
|
UpdateiOSEntitlementsPlist(entitlementsPath, buildVariant);
|
|
});
|
|
|
|
Task("UpdateiOSAutofillPlist")
|
|
.IsDependentOn("GetGitInfo")
|
|
.IsDependentOn("UpdateiOSPlist")
|
|
.Does(()=> {
|
|
var buildVariant = GetVariant();
|
|
var infoPath = Path.Combine(_slnPath, "src", "iOS.Autofill", "Info.plist");
|
|
var entitlementsPath = Path.Combine(_slnPath, "src", "iOS.Autofill", "Entitlements.plist");
|
|
UpdateiOSInfoPlist(infoPath, buildVariant, _gitVersion, iOSProjectType.Autofill);
|
|
UpdateiOSEntitlementsPlist(entitlementsPath, buildVariant);
|
|
});
|
|
|
|
Task("UpdateiOSExtensionPlist")
|
|
.IsDependentOn("GetGitInfo")
|
|
.IsDependentOn("UpdateiOSPlist")
|
|
.Does(()=> {
|
|
var buildVariant = GetVariant();
|
|
var infoPath = Path.Combine(_slnPath, "src", "iOS.Extension", "Info.plist");
|
|
var entitlementsPath = Path.Combine(_slnPath, "src", "iOS.Extension", "Entitlements.plist");
|
|
UpdateiOSInfoPlist(infoPath, buildVariant, _gitVersion, iOSProjectType.Extension);
|
|
UpdateiOSEntitlementsPlist(entitlementsPath, buildVariant);
|
|
});
|
|
|
|
Task("UpdateiOSShareExtensionPlist")
|
|
.IsDependentOn("GetGitInfo")
|
|
.IsDependentOn("UpdateiOSPlist")
|
|
.Does(()=> {
|
|
var buildVariant = GetVariant();
|
|
var infoPath = Path.Combine(_slnPath, "src", "iOS.ShareExtension", "Info.plist");
|
|
var entitlementsPath = Path.Combine(_slnPath, "src", "iOS.ShareExtension", "Entitlements.plist");
|
|
UpdateiOSInfoPlist(infoPath, buildVariant, _gitVersion, iOSProjectType.ShareExtension);
|
|
UpdateiOSEntitlementsPlist(entitlementsPath, buildVariant);
|
|
});
|
|
|
|
Task("UpdateiOSCodeFiles")
|
|
.IsDependentOn("UpdateiOSPlist")
|
|
.Does(()=> {
|
|
var buildVariant = GetVariant();
|
|
var fileList = new string[] {
|
|
Path.Combine(_slnPath, "src", "iOS.Core", "Utilities", "iOSCoreHelpers.cs"),
|
|
Path.Combine(_slnPath, "src", "iOS.Core", "Constants.cs"),
|
|
Path.Combine(_slnPath, "src", "watchOS", "bitwarden", "bitwarden.xcodeproj", "project.pbxproj"),
|
|
Path.Combine(_slnPath, "src", "watchOS", "bitwarden", "bitwarden WatchKit Extension", "Helpers", "KeychainHelper.swift"),
|
|
Path.Combine(".github", "resources", "export-options-ad-hoc.plist"),
|
|
Path.Combine(".github", "resources", "export-options-app-store.plist")
|
|
};
|
|
|
|
foreach(string path in fileList)
|
|
{
|
|
ReplaceInFile(path, "com.8bit.bitwarden", buildVariant.iOSBundleId);
|
|
}
|
|
});
|
|
|
|
Task("UpdateWatchProject")
|
|
.IsDependentOn("UpdateiOSPlist")
|
|
.WithCriteria(() => !string.IsNullOrEmpty(_iOSVersionName))
|
|
.Does(()=> {
|
|
var watchProjectPath = Path.Combine(_slnPath, "src", "watchOS", "bitwarden", "bitwarden.xcodeproj", "project.pbxproj");
|
|
UpdateWatchPbxproj(watchProjectPath, _iOSVersionName);
|
|
});
|
|
|
|
Task("UpdateWatchKitAppInfoPlist")
|
|
.Does(()=> {
|
|
var buildVariant = GetVariant();
|
|
var infoPath = Path.Combine(_slnPath, "src", "watchOS", "bitwarden", "bitwarden WatchKit Extension", "Info.plist");
|
|
UpdateWatchKitAppInfoPlist(infoPath, buildVariant);
|
|
});
|
|
|
|
#endregion iOS
|
|
|
|
#region Main Tasks
|
|
Task("Android")
|
|
//.IsDependentOn("UpdateAndroidAppIcon")
|
|
.IsDependentOn("UpdateAndroidManifest")
|
|
.IsDependentOn("UpdateAndroidCodeFiles")
|
|
.Does(()=>
|
|
{
|
|
Information("Android app updated");
|
|
});
|
|
|
|
Task("iOS")
|
|
.IsDependentOn("UpdateiOSIcons")
|
|
.IsDependentOn("UpdateiOSPlist")
|
|
.IsDependentOn("UpdateiOSAutofillPlist")
|
|
.IsDependentOn("UpdateiOSExtensionPlist")
|
|
.IsDependentOn("UpdateiOSShareExtensionPlist")
|
|
.IsDependentOn("UpdateiOSCodeFiles")
|
|
.IsDependentOn("UpdateWatchProject")
|
|
.IsDependentOn("UpdateWatchKitAppInfoPlist")
|
|
.Does(()=>
|
|
{
|
|
Information("iOS app updated");
|
|
});
|
|
|
|
Task("Default")
|
|
.Does(() => {
|
|
var usage = @"Missing target.
|
|
|
|
Usage:
|
|
dotnet cake build.cake --target (Android | iOS) --variant (dev | qa | beta | prod)
|
|
|
|
Options:
|
|
--debugScript=<bool> Script debug mode.
|
|
";
|
|
Information(usage);
|
|
});
|
|
#endregion Main Tasks
|
|
|
|
RunTarget(target); |