-
Notifications
You must be signed in to change notification settings - Fork 506
GH-25: Add PhoneDialer API #37
GH-25: Add PhoneDialer API #37
Conversation
There was a problem hiding this 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); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
fcd57de
to
51addd5
Compare
I've added temporary exception classes. |
There was a problem hiding this 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.
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; |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)) | ||
{ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
a3482df
to
c06e2bf
Compare
…tNewActivity does not exist.
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. |
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)] |
There was a problem hiding this comment.
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
Pulling into a branch so I can work on it |
* 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.
#25
Will be updated according to related discussions.
PR Checklist