Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

GH-25: Add PhoneDialer API #37

Merged

Conversation

f1nzer
Copy link
Contributor

@f1nzer f1nzer commented Feb 27, 2018

#25

Will be updated according to related discussions.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense
  • Has Samples

@mattleibow mattleibow added enhancement DO-NOT-MERGE Don't merge it.... don't do it! labels Feb 27, 2018
@mattleibow mattleibow added this to the Preview-1 milestone Feb 27, 2018
Copy link
Contributor

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR, it is good so far, but I think we need to change the API a bit (I updated the spec issue).

I think we are not going to support the name parameter for v1, as this is not really supported across the board. Also, I think we should throw if the dialer is not supported rather than just quietly doing nothing.

For whitespace, until we merge all the rules, just make sure that you are using tabs everywhere.

if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
{
#pragma warning disable CS0618
phoneNumber = PhoneNumberUtils.FormatNumber(number);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this in an if block? Shouldn't we be formatting this every time, not just for old devices. This method is deprecated, not removed.

Open(number, null);
}

public static void Open(string number, string name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because on UWP supports a name, we should probably remove this for v1.

Open(number, null);
}

public static void Open(string number, string name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking for v1 of the API, let's leave name out.

throw new ArgumentNullException(nameof(number));
}

if (IsSupported)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is not supported, then throw, rather than doing nothing. Pending discussion here #19

throw new ArgumentNullException(nameof(number));
}

if (IsSupported)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is not supported, then throw, rather than doing nothing. Pending discussion here #19

Open(number, null);
}

public static void Open(string number, string name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave name out for v1. On second thoughts, leave this here for UWP - let's see what happens to the discussion after this comment: #25 (comment)

throw new ArgumentNullException(nameof(number));
}

if (IsSupported)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throw if not supported. Pending discussion here #19

@f1nzer
Copy link
Contributor Author

f1nzer commented Feb 27, 2018

I've added temporary exception classes.

mattleibow
mattleibow previously approved these changes Feb 27, 2018
Copy link
Contributor

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@jamesmontemagno
Copy link
Collaborator

The other question I have is what should the user pass in here as it looks like ANdroid does special formatting....

Do they need +1 for instance? does 555.555.5555 work?

{
get
{
var packageManager = Application.Context.PackageManager;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thoughts here are to also check telephony is actually on the device.

{
get
{
var nsUrl = CreateNsUrl("0000000000");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this append with: tel:

using (var netInfo = new CTTelephonyNetworkInfo())
{
var mnc = netInfo.SubscriberCellularProvider?.MobileNetworkCode;
return !string.IsNullOrEmpty(mnc) && mnc != "65535"; // 65535 stands for NoNetwordProvider
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need to check against null here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public static void Open(string number)
{
if (string.IsNullOrWhiteSpace(number))
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattleibow are we standardizing on need or not needing { around a single line if?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesmontemagno I prefer always using braces for the simple reason that it avoids confusion due to the grouping. Also it makes changes easier - if we ever have to add another line, then we don't have to also add braces. But, this is a very opinionated thing.

If we are following the .net foundation guides, then they say that we don't need it. So I guess we don't need them.
https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/coding-style.md

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then again, we don't really follow most of them.

UIApplication.SharedApplication.OpenUrl(nsUrl);
}

private NSUrl CreateNsUrl(string number)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use expression bodied method here.

public static bool IsSupported =>
Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.ApplicationModel.Calls.PhoneCallManager");

public static void Open(string number)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expression bodied Method here


if (canCall)
{
using (var netInfo = new CTTelephonyNetworkInfo())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What all is this check doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are checking for SIM-card & network availability

@mattleibow
Copy link
Contributor

@f1nzer to save you time merging and resolving conflicts, I did it here: f1nzer#1

NOTE: I left your files as tabs so that it (hopefully) won't break any local changes you are working on.

@Redth Redth added this to PR Available in Triage Mar 7, 2018
@Redth Redth added this to Ready in v0.5.0-preview Mar 7, 2018
@Redth Redth moved this from Ready to In Progress in v0.5.0-preview Mar 7, 2018
@jamesmontemagno
Copy link
Collaborator

We now have checks in place for StyleCop + Unit Tests + Samples ready to go.

Are you able to ensure everything pulls up from master and validates against StyleCop. Additionally can you add Unit Tests, Tests for Device Runners, and Samples.

@Redth Redth removed this from PR Available in Triage Mar 10, 2018
@jamesmontemagno jamesmontemagno changed the title [WIP] PhoneDialer API GH-25: Add PhoneDialer API Mar 12, 2018
@Redth Redth removed this from In Progress in v0.5.0-preview Mar 12, 2018
@Redth Redth removed the enhancement label Mar 12, 2018
@jamesmontemagno
Copy link
Collaborator

I think the only thing we are trying to figure out is if we want "IsSupported" or some enum there.


namespace Caboodle.Samples.View
{
[XamlCompilation(XamlCompilationOptions.Compile)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this as it is on the assembly level

@jamesmontemagno jamesmontemagno changed the base branch from master to feature/phone-dialer March 23, 2018 17:15
@jamesmontemagno
Copy link
Collaborator

Pulling into a branch so I can work on it

@jamesmontemagno jamesmontemagno merged commit 6061828 into xamarin:feature/phone-dialer Mar 23, 2018
@mattleibow mattleibow mentioned this pull request Mar 23, 2018
5 tasks
jamesmontemagno pushed a commit that referenced this pull request Mar 26, 2018
* GH-25: Add PhoneDialer API (#37)

* added phone dialer api

* fixes according to comments

* Merge branch 'master' into feature/phone-dialer

* Added the UWP SDK references and fix the Android intent logic as StartNewActivity does not exist.

* fixed style errors

* added phone dialer sample

* added phone dialer tests

* Cleanup exceptions from merge

* Cleanup dial API and is supported

* Cleanup dialers is supported

* Cleanup tests and samples.

* Add phone dialer docs.

* Cleanup UWP

* Add remarks

* Changes based on feedback to cleanup samples.

* Add platform helpers.
@mattleibow mattleibow added this to Done in v0.5.0-preview Mar 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
DO-NOT-MERGE Don't merge it.... don't do it!
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants