62

Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

  • Upload
    xamarin

  • View
    140

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 2: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 3: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 4: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 5: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 6: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 7: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 8: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 9: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 10: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 11: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

dependencies {

...

compile “com.android.support:support-emoji:27.0.0”

}

Page 12: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 13: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 14: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

developer.android.com

Page 15: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

developer.android.com

Page 16: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

developer.android.com

Page 17: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

developer.android.com

Page 18: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

<?xml version="1.0" encoding="utf-8"?>

<adaptive-icon

xmlns:android="http://schemas.android.com/apk/res/android">

<background android:drawable="@color/ic_launcher_background"/>

<foreground android:drawable="@mipmap/ic_launcher_foreground"/>

</adaptive-icon>

Page 19: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 20: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 21: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

developer.android.com

Page 22: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

developer.android.com

Page 23: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

public const string PRIMARY_CHANNEL_ID = "default";

var chan1 = new NotificationChannel(

PRIMARY_CHANNEL_ID,channelName,

NotificationImportance.Default);

var channelName = GetString(Resource.String.noti_channel_default);

chan1.LightColor = Color.Green;chan1.LockscreenVisibility = NotificationVisibility.Private;

manager.CreateNotificationChannel(chan1);

var manager = (NotificationManager)GetSystemService(NotificationService);

Page 24: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

var notificationBuilder= new Notification.Builder(ApplicationContext, PRIMARY_CHANNEL_ID).SetContentTitle(title).SetContentText(body).SetSmallIcon(smallIcon).SetAutoCancel(true);

var manager = (NotificationManager)GetSystemService(NotificationService);

manager.Notify(notificationId, notificationBuilder.Build();

public const string PRIMARY_CHANNEL_ID = "default";

Page 25: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 26: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 27: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 28: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 29: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 30: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 31: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

developer.android.com/guide/components/broadcast-exceptions.html

Page 32: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 33: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

developer.android.com

Page 34: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

[Activity(Label = "PictureInPicture",

MainLauncher = true,

ConfigurationChanges = ConfigChanges.ScreenSize |

ConfigChanges.SmallestScreenSize |

ConfigChanges.ScreenLayout |

ConfigChanges.Orientation,

SupportsPictureInPicture = true)]public class MainActivity : AppCompatActivity{

}

Page 35: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

bool EnterPictureInPictureMode(PictureInPictureParams @params);

public class Builder{

public Builder();

public PictureInPictureParams Build();

public PictureInPictureParams.Builder SetActions(IList<RemoteAction> actions);

public PictureInPictureParams.Builder SetAspectRatio(Rational aspectRatio);

public PictureInPictureParams.Builder SetSourceRectHint (Rect launchBounds);}

Page 36: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

public override void OnPictureInPictureModeChanged(bool isInPictureInPictureMode,

Configuration newConfig)

{base.OnPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);

if (isInPictureInPictureMode){

// Hide the controls in picture-in-picture mode.

}else{

// Restore fullscreen UI.

}}

Page 37: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

protected override void OnUserLeaveHint(){

if (iWantToBeInPipMode) {

EnterPictureInPictureMode(BuildParametersForPiP());}

}

Page 38: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 39: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

TextView regular

TextVie

w auto-

sizing

Page 40: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

<?xml version="1.0" encoding="utf-8"?>

<TextView

android:layout_width="match_parent"

android:layout_height="200dp"

android:autoSizeTextType="uniform"

android:autoSizeMinTextSize="12sp"

android:autoSizeMaxTextSize="100sp"

android:autoSizeStepGranularity="2sp" />

Page 41: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"

android:layout_height="match_parent“

android:orientation="vertical" >

<TextView

android:id="@+id/text_view“

android:layout_width="match_parent"

android:layout_height="200dp"

android:text="Auto Size Text."

app:autoSizeTextType="uniform" />

</LinearLayout>

Page 42: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

developer.android.com

Page 43: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

<EditTextandroid:id="@+id/passwordField"android:layout_width="@dimen/text_field_width"android:layout_height="wrap_content"android:autofillHints="password"android:inputType="textPassword“ />

Page 44: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 45: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 46: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

<TextView

android:text="The quick brown fox jumped over the lazy dog.“

android:textAppearance="?android:attr/textAppearanceLarge"

android:layout_width="match_parent"

android:layout_height="wrap_content" />

Page 47: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

<?xml version="1.0" encoding="utf-8"?>

<font-family xmlns:android="http://schemas.android.com/apk/res/android">

<font android:fontStyle="normal"

android:fontWeight="400"

android:font="@font/lobster_regular"/>

<font android:fontStyle="italic“

android:fontWeight="400“

android:font="@font/lobster_italic" />

</font-family>

Page 48: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

Fonts Contract

Font Provider

Font Cache

Page 49: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

<?xml version="1.0" encoding="utf-8"?>

<font-family

xmlns:android=“http://schemas.android.com/apk/res/android”

android:fontProviderAuthority=“com.example.fontprovider.authority”

android:fontProviderPackage="com.example.fontprovider"

android:fontProviderQuery="example font"

android:fontProviderCerts="@array/certs">

</font-family>

Page 50: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

<?xml version="1.0" encoding="utf-8"?>

<resources>

<array name="preloaded_fonts">

<item>@font/font1</item>

<item>@font/font2</item>

</array>

</resources>

Page 51: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

<meta-data android:name="preloaded_fonts“android:resource="@array/preloaded_fonts"/>

[Application][MetaData("preloaded_fonts", Resource="@array/preloaded_fonts")]public class EmojiCompatApplication : Application{

// Code omitted for clarity}

Page 52: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

FontRequest request = new FontRequest(

"com.google.android.gms.fonts",

"com.google.android.gms",

query,

Resource.Array.com_google_android_gms_fonts_certs);

Page 53: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

class FontRequestCallbackImpl : FontsContractCompat.FontRequestCallback{

public override void OnTypefaceRetrieved(Android.Graphics.Typeface typeface){

// Font downloaded - do something with the typeface}

public override void OnTypefaceRequestFailed(int reason){

// Download failed - react to the failure}

}

Page 54: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

HandlerThread handlerThread = new HandlerThread("fonts");handlerThread.Start();

FontsContractCompat.RequestFont(this, request, callback, handlerThread);

Page 55: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

developer.android.com

Page 56: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Page 57: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

// Use downloadable fonts for EmojiCompatvar fontRequest = new FontRequest("com.google.android.gms.fonts",

"com.google.android.gms","Noto Color Emoji Compat",

Resource.Array.com_google_android_gms_fonts_certs);

EmojiCompat.Config config = new FontRequestEmojiCompatConfig(this, fontRequest).SetReplaceAll(true).RegisterInitCallback(new InitCallbackImpl());

EmojiCompat.Init(config);

// OR, if using the bundled EmojiCompat package:

EmojiCompat.Config config = new BundledEmojiCompatConfig(this);EmojiCompat.Init(config);

Page 58: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

<android.support.text.emoji.widget.EmojiTextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

<android.support.text.emoji.widget.EmojiAppCompatTextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

Page 59: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

<android.support.text.emoji.widget.EmojiEditText

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

<android.support.text.emoji.widget.EmojiAppCompatEditText

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

Page 60: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

<android.support.text.emoji.widget.EmojiButton

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

<android.support.text.emoji.widget.EmojiAppCompatButton

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

Page 61: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

github.com/xamarin/monodroid-samples/tree/master/android-o

www.youtube.com/user/androiddevelopers

developer.android.com/about/versions/oreo/index.html

xamarin.com/download

Page 62: Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

Tom Opgenorth

Senior Content Developer, Microsoft