mirror of
https://github.com/bitwarden/android.git
synced 2024-12-18 23:31:52 +03:00
Added rate app function and message passing for android
This commit is contained in:
parent
1e17c2212a
commit
e3b44ac7d1
3 changed files with 51 additions and 6 deletions
|
@ -13,6 +13,7 @@ using Plugin.Settings.Abstractions;
|
|||
using Plugin.Connectivity.Abstractions;
|
||||
using Acr.UserDialogs;
|
||||
using PushNotification.Plugin.Abstractions;
|
||||
using Android.Content;
|
||||
|
||||
namespace Bit.Android
|
||||
{
|
||||
|
@ -44,6 +45,12 @@ namespace Bit.Android
|
|||
Resolver.Resolve<IPushNotification>(),
|
||||
Resolver.Resolve<ILockService>(),
|
||||
Resolver.Resolve<IGoogleAnalyticsService>()));
|
||||
|
||||
Xamarin.Forms.MessagingCenter.Subscribe<Xamarin.Forms.Application>(
|
||||
Xamarin.Forms.Application.Current, "RateApp", (sender) =>
|
||||
{
|
||||
RateApp();
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnPause()
|
||||
|
@ -81,5 +88,37 @@ namespace Bit.Android
|
|||
Console.WriteLine("A OnResume");
|
||||
base.OnResume();
|
||||
}
|
||||
|
||||
public void RateApp()
|
||||
{
|
||||
try
|
||||
{
|
||||
var rateIntent = RateIntentForUrl("market://details");
|
||||
StartActivity(rateIntent);
|
||||
}
|
||||
catch(ActivityNotFoundException)
|
||||
{
|
||||
var rateIntent = RateIntentForUrl("https://play.google.com/store/apps/details");
|
||||
StartActivity(rateIntent);
|
||||
}
|
||||
}
|
||||
|
||||
private Intent RateIntentForUrl(string url)
|
||||
{
|
||||
var intent = new Intent(Intent.ActionView, global::Android.Net.Uri.Parse($"{url}?id={PackageName}"));
|
||||
var flags = ActivityFlags.NoHistory | ActivityFlags.MultipleTask;
|
||||
if((int)Build.VERSION.SdkInt >= 21)
|
||||
{
|
||||
flags |= ActivityFlags.NewDocument;
|
||||
}
|
||||
else
|
||||
{
|
||||
// noinspection deprecation
|
||||
flags |= ActivityFlags.ClearWhenTaskReset;
|
||||
}
|
||||
|
||||
intent.AddFlags(flags);
|
||||
return intent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
|
||||
<uses-permission android:name="com.8bit.bitwarden.permission.C2D_MESSAGE" />
|
||||
<uses-permission android:name="com.x8bit.bitwarden.permission.C2D_MESSAGE" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<application android:label="bitwarden" android:theme="@style/BitwardenTheme"></application>
|
||||
</manifest>
|
|
@ -130,7 +130,8 @@ namespace Bit.App.Pages
|
|||
|
||||
if(Device.OS == TargetPlatform.iOS)
|
||||
{
|
||||
rateCell.Detail.Text = "App Store ratings are reset with every new version of bitwarden. Please consider helping us out with a good review!";
|
||||
rateCell.Detail.Text = "App Store ratings are reset with every new version of bitwarden."
|
||||
+ " Please consider helping us out with a good review!";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -240,11 +241,15 @@ namespace Bit.App.Pages
|
|||
|
||||
private void RateCell_Tapped(object sender, EventArgs e)
|
||||
{
|
||||
_googleAnalyticsService.TrackAppEvent("OpenedSetting", "RateApp");
|
||||
if(Device.OS == TargetPlatform.iOS)
|
||||
{
|
||||
_googleAnalyticsService.TrackAppEvent("OpenedSetting", "RateApp");
|
||||
var appStoreId = "1137397744";
|
||||
Device.OpenUri(new Uri($"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id={appStoreId}&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software"));
|
||||
Device.OpenUri(new Uri($"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews" +
|
||||
"?id=1137397744&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software"));
|
||||
}
|
||||
else if(Device.OS == TargetPlatform.Android)
|
||||
{
|
||||
MessagingCenter.Send(Application.Current, "RateApp");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,7 +267,8 @@ namespace Bit.App.Pages
|
|||
|
||||
private async void LogOutCell_Tapped(object sender, EventArgs e)
|
||||
{
|
||||
if(!await _userDialogs.ConfirmAsync("Are you sure you want to log out?", null, AppResources.Yes, AppResources.Cancel))
|
||||
if(!await _userDialogs.ConfirmAsync(
|
||||
"Are you sure you want to log out?", null, AppResources.Yes, AppResources.Cancel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue