Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add network requests allowed API #1519

Merged
merged 42 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
599ca9f
Add new API to App Center SDK
Apr 19, 2021
197affd
Update android version
Apr 19, 2021
bc8316d
Update test apps
Apr 19, 2021
35bc6eb
Rename methods
Apr 19, 2021
f5ae576
Update test apps
Apr 19, 2021
c41a16b
Add block for network requests API
Apr 20, 2021
a576f53
Update API for iOS
Apr 20, 2021
8fe2233
Update tests
Apr 20, 2021
b72e2bb
Resolve feedback
Apr 21, 2021
865db40
Resolve feedback
Apr 21, 2021
06c404f
Fix test
Apr 21, 2021
05ace1a
Update changelog
Apr 21, 2021
a7630d0
Save block network requests state
Apr 22, 2021
ccaa275
Fix block network requests after adding the channel
Apr 23, 2021
f6fa627
Update test apps
Apr 23, 2021
390c635
Add user default values
Apr 23, 2021
24eaef4
Merge pull request #1517 from microsoft/feature/block-network-request…
Apr 23, 2021
bea7fa4
Merge branch 'feature/block-network-requests' into feature/block-netw…
Apr 23, 2021
f52ece4
Merge pull request #1518 from microsoft/feature/block-network-request…
Apr 23, 2021
552c70c
Fix test
Apr 23, 2021
3ede877
Update block network requests implementation
Apr 27, 2021
4f249ef
Update block network requests implementation
Apr 28, 2021
829f595
Resolve feedback
Apr 28, 2021
99933b5
Update block network requests implementation
Apr 28, 2021
2924683
Remove tests
Apr 29, 2021
7c37992
Update test apps
Apr 29, 2021
3f51fe6
Update the implementation for the blocking network requests
Apr 30, 2021
1338990
Resolve feedback
Apr 30, 2021
2d2d822
Update tests
Apr 30, 2021
abf8cea
Fix some tests
Apr 30, 2021
3a2abd3
Update versions
May 4, 2021
f8f93b8
Update tests
May 4, 2021
ef5529b
Update metadata file
May 5, 2021
6f321d0
Update android version
May 5, 2021
6b54a99
Update test apps
May 5, 2021
e0b4b70
Update test apps
May 5, 2021
ca8f69b
Update changelog
May 5, 2021
2fbb05f
Resolve feedback
May 7, 2021
d394c54
Fix build
May 7, 2021
3f24438
Revert some changes
May 7, 2021
782e3cf
Update tests
May 11, 2021
f5814e7
Update Android and iOS version
May 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Apps/Contoso.Android.Puppet/ModulePages/AppCenterFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class AppCenterFragment : PageFragment
private LogLevel mLogWriteLevel = LogLevel.Verbose;

private Switch AppCenterEnabledSwitch;
private Switch AppCenterNetworkRequestsAllowedSwitch;
private TextView LogLevelLabel;
private EditText LogWriteMessageText;
private EditText LogWriteTagText;
Expand All @@ -54,6 +55,7 @@ public override void OnViewCreated(View view, Bundle savedInstanceState)

// Find views.
AppCenterEnabledSwitch = view.FindViewById(Resource.Id.enabled_app_center) as Switch;
AppCenterNetworkRequestsAllowedSwitch = view.FindViewById(Resource.Id.appcenter_network_requests_allowed) as Switch;
LogLevelLabel = view.FindViewById(Resource.Id.log_level) as TextView;
LogWriteMessageText = view.FindViewById(Resource.Id.write_log_message) as EditText;
LogWriteTagText = view.FindViewById(Resource.Id.write_log_tag) as EditText;
Expand All @@ -65,6 +67,7 @@ public override void OnViewCreated(View view, Bundle savedInstanceState)

// Subscribe to events.
AppCenterEnabledSwitch.CheckedChange += UpdateEnabled;
AppCenterNetworkRequestsAllowedSwitch.CheckedChange += NetworkRequestAllowedChange;
((View)LogLevelLabel.Parent).Click += LogLevelClicked;
((View)LogWriteLevelLabel.Parent).Click += LogWriteLevelClicked;
LogWriteButton.Click += WriteLog;
Expand All @@ -86,6 +89,9 @@ protected override async void UpdateState()
AppCenterEnabledSwitch.CheckedChange -= UpdateEnabled;
AppCenterEnabledSwitch.Checked = await AppCenter.IsEnabledAsync();
AppCenterEnabledSwitch.CheckedChange += UpdateEnabled;
AppCenterNetworkRequestsAllowedSwitch.CheckedChange -= NetworkRequestAllowedChange;
AppCenterNetworkRequestsAllowedSwitch.Checked = AppCenter.IsNetworkRequestsAllowed;
AppCenterNetworkRequestsAllowedSwitch.CheckedChange += NetworkRequestAllowedChange;
LogLevelLabel.Text = LogLevelNames[AppCenter.LogLevel];
LogWriteLevelLabel.Text = LogLevelNames[mLogWriteLevel];
}
Expand Down Expand Up @@ -117,6 +123,11 @@ private async void UpdateEnabled(object sender, CompoundButton.CheckedChangeEven
AppCenterEnabledSwitch.Checked = await AppCenter.IsEnabledAsync();
}

private void NetworkRequestAllowedChange(object sender, CompoundButton.CheckedChangeEventArgs e)
{
AppCenter.IsNetworkRequestsAllowed = e.IsChecked;
}

private void LogLevelClicked(object sender, EventArgs e)
{
var intent = new Intent(Activity.ApplicationContext, typeof(LogLevelActivity));
Expand Down
14 changes: 14 additions & 0 deletions Apps/Contoso.Android.Puppet/Resources/layout/AppCenter.axml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="@string/AppCenterNetworkRequestsAllowed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp" />
<Switch
android:id="@+id/appcenter_network_requests_allowed"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
Expand Down
1 change: 1 addition & 0 deletions Apps/Contoso.Android.Puppet/Resources/values/Strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<string name="AppCenterWriteUserId">Write User Id</string>
<string name="AppCenterUserId">User Id</string>
<string name="AnalyticsEnabled">Analytics Enabled</string>
<string name="AppCenterNetworkRequestsAllowed">Allow network requests</string>
<string name="AnalyticsEventName">Event Name</string>
<string name="AnalyticsProperties">Properties</string>
<string name="AnalyticsAddProperty">Add Property</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TableView Intent="Form">
<TableSection Title="AppCenter Settings">
<SwitchCell Text="AppCenter Enabled" On="true" x:Name="AppCenterEnabledSwitchCell" OnChanged="UpdateEnabled" />
<SwitchCell Text="Allow network requests" On="true" x:Name="AllowedNetworkRequestSwitchCell" OnChanged="AllowedNetworkRequestEnabled" />
</TableSection>
<TableSection Title="Startup type">
<ViewCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ protected override async void OnAppearing()
{
base.OnAppearing();
AppCenterEnabledSwitchCell.On = await AppCenter.IsEnabledAsync();
AllowedNetworkRequestSwitchCell.On = AppCenter.IsNetworkRequestsAllowed;
if (Application.Current.Properties.ContainsKey(Constants.UserId) && Application.Current.Properties[Constants.UserId] is string id)
{
UserIdEntry.Text = id;
Expand Down Expand Up @@ -87,5 +88,10 @@ private void SaveStorageSize_Clicked(object sender, System.EventArgs e)
AppCenterLog.Error(LogTag, "Wrong number value for the max storage size.");
}
}

void AllowedNetworkRequestEnabled(System.Object sender, Xamarin.Forms.ToggledEventArgs e)
{
AppCenter.IsNetworkRequestsAllowed = e.Value;
}
}
}
1 change: 1 addition & 0 deletions Apps/Contoso.WPF.Puppet.DotNetCore/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<TabItem Header="App Center">
<StackPanel>
<CheckBox Name="AppCenterEnabled" Content="App Center Enabled" Margin="0,10,0,10" Checked="AppCenterEnabled_Checked" Unchecked="AppCenterEnabled_Checked"/>
<CheckBox Name="AppCenterAllowNetworkRequests" Content="Allow network requests" Margin="0,10,0,10" Checked="AppCenterAllowNetworkRequests_Checked" Unchecked="AppCenterAllowNetworkRequests_Checked"/>
<StackPanel Orientation ="Horizontal" HorizontalAlignment="Right" />
<GroupBox Header="Misc">
<Grid>
Expand Down
9 changes: 9 additions & 0 deletions Apps/Contoso.WPF.Puppet.DotNetCore/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public MainWindow()
private void UpdateState()
{
AppCenterEnabled.IsChecked = AppCenter.IsEnabledAsync().Result;
AppCenterAllowNetworkRequests.IsChecked = AppCenter.IsNetworkRequestsAllowed;
CrashesEnabled.IsChecked = Crashes.IsEnabledAsync().Result;
AnalyticsEnabled.IsChecked = Analytics.IsEnabledAsync().Result;
AnalyticsEnabled.IsEnabled = AppCenterEnabled.IsChecked.Value;
Expand All @@ -71,6 +72,14 @@ private void AppCenterEnabled_Checked(object sender, RoutedEventArgs e)
AppCenter.SetEnabledAsync(AppCenterEnabled.IsChecked.Value).Wait();
}
}

private void AppCenterAllowNetworkRequests_Checked(object sender, RoutedEventArgs e)
{
if (AppCenterAllowNetworkRequests.IsChecked.HasValue)
{
AppCenter.IsNetworkRequestsAllowed = AppCenterAllowNetworkRequests.IsChecked.Value;
}
}

private void AnalyticsEnabled_Checked(object sender, RoutedEventArgs e)
{
Expand Down
8 changes: 4 additions & 4 deletions Apps/Contoso.WPF.Puppet/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
<userSettings>
<Contoso.WPF.Puppet.Properties.Settings>
<setting name="FileErrorAttachments" serializeAs="String">
<value/>
<value />
</setting>
<setting name="TextErrorAttachments" serializeAs="String">
<value/>
<value />
</setting>
<setting name="CountryCode" serializeAs="String">
<value/>
<value />
</setting>
<setting name="UserId" serializeAs="String">
<value/>
<value />
</setting>
<setting name="StorageMaxSize" serializeAs="String">
<value>0</value>
Expand Down
1 change: 1 addition & 0 deletions Apps/Contoso.WPF.Puppet/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<TabItem Header="App Center">
<StackPanel>
<CheckBox Name="AppCenterEnabled" Content="App Center Enabled" Margin="0,10,0,10" Checked="AppCenterEnabled_Checked" Unchecked="AppCenterEnabled_Checked"/>
<CheckBox Name="AppCenterAllowNetworkRequests" Content="Allow network requests" Margin="0,10,0,10" Checked="AppCenterAllowNetworkRequests_Checked" Unchecked="AppCenterAllowNetworkRequests_Checked"/>
<StackPanel Orientation ="Horizontal" HorizontalAlignment="Right" />
<GroupBox Header="Misc" Height="116">
<Grid>
Expand Down
9 changes: 9 additions & 0 deletions Apps/Contoso.WPF.Puppet/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public MainWindow()
private void UpdateState()
{
AppCenterEnabled.IsChecked = AppCenter.IsEnabledAsync().Result;
AppCenterAllowNetworkRequests.IsChecked = AppCenter.IsNetworkRequestsAllowed;
CrashesEnabled.IsChecked = Crashes.IsEnabledAsync().Result;
AnalyticsEnabled.IsChecked = Analytics.IsEnabledAsync().Result;
AnalyticsEnabled.IsEnabled = AppCenterEnabled.IsChecked.Value;
Expand All @@ -74,6 +75,14 @@ private void AppCenterEnabled_Checked(object sender, RoutedEventArgs e)
}
}

private void AppCenterAllowNetworkRequests_Checked(object sender, RoutedEventArgs e)
{
if (AppCenterAllowNetworkRequests.IsChecked.HasValue)
{
AppCenter.IsNetworkRequestsAllowed = AppCenterAllowNetworkRequests.IsChecked.Value;
}
}

private void AnalyticsEnabled_Checked(object sender, RoutedEventArgs e)
{
AnalyticsEnabled.IsEnabled = AppCenterEnabled.IsChecked.Value;
Expand Down
18 changes: 17 additions & 1 deletion Apps/Contoso.WinForms.Puppet.DotNetCore/MainForm.Designer.cs

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

7 changes: 7 additions & 0 deletions Apps/Contoso.WinForms.Puppet.DotNetCore/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ public MainForm()
{
StorageMaxSizeTextBox.Text = Settings.Default.StorageMaxSize.ToString();
}
AppCenterAllowNetworkRequests.Checked = AppCenter.IsNetworkRequestsAllowed;
}

private void UpdateState()
{
AppCenterEnabled.Checked = AppCenter.IsEnabledAsync().Result;
AppCenterAllowNetworkRequests.Checked = AppCenter.IsNetworkRequestsAllowed;
AnalyticsEnabled.Checked = Analytics.IsEnabledAsync().Result;
CrashesEnabled.Checked = Crashes.IsEnabledAsync().Result;
AnalyticsEnabled.Enabled = AppCenterEnabled.Checked;
Expand All @@ -46,6 +48,11 @@ private void AppCenterEnabled_CheckedChanged(object sender, EventArgs e)
AppCenter.SetEnabledAsync(AppCenterEnabled.Checked).Wait();
}

private void AppCenterAllowNetworkRequest_CheckedChanged(object sender, EventArgs e)
{
AppCenter.IsNetworkRequestsAllowed = AppCenterAllowNetworkRequests.Checked;
}

private void AnalyticsEnabled_CheckedChanged(object sender, EventArgs e)
{
AnalyticsEnabled.Enabled = AppCenterEnabled.Checked;
Expand Down
18 changes: 17 additions & 1 deletion Apps/Contoso.WinForms.Puppet/MainForm.Designer.cs

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

7 changes: 7 additions & 0 deletions Apps/Contoso.WinForms.Puppet/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ public MainForm()
{
StorageMaxSizeTextBox.Text = Settings.Default.StorageMaxSize.ToString();
}
AppCenterAllowNetworkRequest.Checked = AppCenter.IsNetworkRequestsAllowed;
}

private void UpdateState()
{
AppCenterEnabled.Checked = AppCenter.IsEnabledAsync().Result;
AppCenterAllowNetworkRequest.Checked = AppCenter.IsNetworkRequestsAllowed;
AnalyticsEnabled.Checked = Analytics.IsEnabledAsync().Result;
CrashesEnabled.Checked = Crashes.IsEnabledAsync().Result;
AnalyticsEnabled.Enabled = AppCenterEnabled.Checked;
Expand All @@ -48,6 +50,11 @@ private void AppCenterEnabled_CheckedChanged(object sender, EventArgs e)
AppCenter.SetEnabledAsync(AppCenterEnabled.Checked).Wait();
}

private void AppCenterAllowNetworkRequest_CheckedChanged(object sender, EventArgs e)
{
AppCenter.IsNetworkRequestsAllowed = AppCenterAllowNetworkRequest.Checked;
}

private void AnalyticsEnabled_CheckedChanged(object sender, EventArgs e)
{
AnalyticsEnabled.Enabled = AppCenterEnabled.Checked;
Expand Down
2 changes: 2 additions & 0 deletions Apps/Contoso.iOS.Puppet/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public override UIWindow Window

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{

// Configure App Center.
AppCenter.LogLevel = LogLevel.Verbose;
AppCenter.SetLogUrl("https://in-integration.dev.avalanch.es");
Distribute.SetInstallUrl("https://install.portal-server-core-integration.dev.avalanch.es");
Expand Down
Loading