This repository has been archived by the owner on Aug 16, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
6,867 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
############################################################################### | ||
# Set default behavior to automatically normalize line endings. | ||
############################################################################### | ||
* text=auto | ||
|
||
############################################################################### | ||
# Set default behavior for command prompt diff. | ||
# | ||
# This is need for earlier builds of msysgit that does not have it on by | ||
# default for csharp files. | ||
# Note: This is only used by command line | ||
############################################################################### | ||
#*.cs diff=csharp | ||
|
||
############################################################################### | ||
# Set the merge driver for project and solution files | ||
# | ||
# Merging from the command prompt will add diff markers to the files if there | ||
# are conflicts (Merging from VS is not affected by the settings below, in VS | ||
# the diff markers are never inserted). Diff markers may cause the following | ||
# file extensions to fail to load in VS. An alternative would be to treat | ||
# these files as binary and thus will always conflict and require user | ||
# intervention with every merge. To do so, just uncomment the entries below | ||
############################################################################### | ||
#*.sln merge=binary | ||
#*.csproj merge=binary | ||
#*.vbproj merge=binary | ||
#*.vcxproj merge=binary | ||
#*.vcproj merge=binary | ||
#*.dbproj merge=binary | ||
#*.fsproj merge=binary | ||
#*.lsproj merge=binary | ||
#*.wixproj merge=binary | ||
#*.modelproj merge=binary | ||
#*.sqlproj merge=binary | ||
#*.wwaproj merge=binary | ||
|
||
############################################################################### | ||
# behavior for image files | ||
# | ||
# image files are treated as binary by default. | ||
############################################################################### | ||
#*.jpg binary | ||
#*.png binary | ||
#*.gif binary | ||
|
||
############################################################################### | ||
# diff behavior for common document formats | ||
# | ||
# Convert binary document formats to text before diffing them. This feature | ||
# is only available from the command line. Turn it on by uncommenting the | ||
# entries below. | ||
############################################################################### | ||
#*.doc diff=astextplain | ||
#*.DOC diff=astextplain | ||
#*.docx diff=astextplain | ||
#*.DOCX diff=astextplain | ||
#*.dot diff=astextplain | ||
#*.DOT diff=astextplain | ||
#*.pdf diff=astextplain | ||
#*.PDF diff=astextplain | ||
#*.rtf diff=astextplain | ||
#*.RTF diff=astextplain |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Any raw assets you want to be deployed with your application can be placed in | ||
this directory (and child directories) and given a Build Action of "AndroidAsset". | ||
|
||
These files will be deployed with you package and will be accessible using Android's | ||
AssetManager, like this: | ||
|
||
public class ReadAsset : Activity | ||
{ | ||
protected override void OnCreate (Bundle bundle) | ||
{ | ||
base.OnCreate (bundle); | ||
|
||
InputStream input = Assets.Open ("my_asset.txt"); | ||
} | ||
} | ||
|
||
Additionally, some Android functions will automatically load asset files: | ||
|
||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
| ||
using Android.App; | ||
using Android.Content.PM; | ||
using Android.Graphics; | ||
using Android.OS; | ||
using Android.Views; | ||
using Android.Widget; | ||
using System; | ||
|
||
namespace SoftInput.Droid | ||
{ | ||
[Activity(Label = "SoftInput", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] | ||
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity | ||
{ | ||
protected override void OnCreate(Bundle bundle) | ||
{ | ||
TabLayoutResource = Resource.Layout.Tabbar; | ||
ToolbarResource = Resource.Layout.Toolbar; | ||
|
||
base.OnCreate(bundle); | ||
|
||
Window.SetSoftInputMode(Android.Views.SoftInput.AdjustResize); | ||
AndroidBug5497WorkaroundForXamarinAndroid.assistActivity(this); | ||
|
||
global::Xamarin.Forms.Forms.Init(this, bundle); | ||
|
||
LoadApplication(new App()); | ||
} | ||
} | ||
|
||
public class AndroidBug5497WorkaroundForXamarinAndroid | ||
{ | ||
|
||
// For more information, see https://code.google.com/p/android/issues/detail?id=5497 | ||
// To use this class, simply invoke assistActivity() on an Activity that already has its content view set. | ||
|
||
// CREDIT TO Joseph Johnson (http://stackoverflow.com/users/341631/joseph-johnson) for publishing the original Android solution on stackoverflow.com | ||
|
||
public static void assistActivity(Activity activity) | ||
{ | ||
new AndroidBug5497WorkaroundForXamarinAndroid(activity); | ||
} | ||
|
||
private Android.Views.View mChildOfContent; | ||
private int usableHeightPrevious; | ||
private FrameLayout.LayoutParams frameLayoutParams; | ||
|
||
private AndroidBug5497WorkaroundForXamarinAndroid(Activity activity) | ||
{ | ||
FrameLayout content = (FrameLayout)activity.FindViewById(Android.Resource.Id.Content); | ||
mChildOfContent = content.GetChildAt(0); | ||
ViewTreeObserver vto = mChildOfContent.ViewTreeObserver; | ||
vto.GlobalLayout += (object sender, EventArgs e) => { | ||
possiblyResizeChildOfContent(); | ||
}; | ||
frameLayoutParams = (FrameLayout.LayoutParams)mChildOfContent.LayoutParameters; | ||
} | ||
|
||
private void possiblyResizeChildOfContent() | ||
{ | ||
int usableHeightNow = computeUsableHeight(); | ||
if (usableHeightNow != usableHeightPrevious) | ||
{ | ||
int usableHeightSansKeyboard = mChildOfContent.RootView.Height; | ||
int heightDifference = usableHeightSansKeyboard - usableHeightNow; | ||
|
||
frameLayoutParams.Height = usableHeightSansKeyboard - heightDifference; | ||
|
||
mChildOfContent.RequestLayout(); | ||
usableHeightPrevious = usableHeightNow; | ||
} | ||
} | ||
|
||
private int computeUsableHeight() | ||
{ | ||
Rect r = new Rect(); | ||
mChildOfContent.GetWindowVisibleDisplayFrame(r); | ||
if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop) | ||
{ | ||
return (r.Bottom - r.Top); | ||
} | ||
return r.Bottom; | ||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<uses-sdk android:minSdkVersion="15" /> | ||
<application android:label="SoftInput.Droid"></application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using Android.App; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("SoftInput.Droid")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("SoftInput.Droid")] | ||
[assembly: AssemblyCopyright("Copyright © 2014")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: ComVisible(false)] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] | ||
|
||
// Add some common permissions, these can be removed if not needed | ||
[assembly: UsesPermission(Android.Manifest.Permission.Internet)] | ||
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Xamarin.Forms; | ||
using SoftInput.Droid.Render; | ||
|
||
[assembly: ExportRenderer(typeof(Entry), typeof(EntryRender))] | ||
namespace SoftInput.Droid.Render | ||
{ | ||
using Android.Views.InputMethods; | ||
using Xamarin.Forms.Platform.Android; | ||
|
||
public class EntryRender : EntryRenderer | ||
{ | ||
|
||
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e) | ||
{ | ||
base.OnElementChanged(e); | ||
|
||
//if (Control != null) | ||
// Control.ImeOptions = (ImeAction)ImeFlags.NoExtractUi; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Images, layout descriptions, binary blobs and string dictionaries can be included | ||
in your application as resource files. Various Android APIs are designed to | ||
operate on the resource IDs instead of dealing with images, strings or binary blobs | ||
directly. | ||
|
||
For example, a sample Android app that contains a user interface layout (main.xml), | ||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) | ||
would keep its resources in the "Resources" directory of the application: | ||
|
||
Resources/ | ||
drawable-hdpi/ | ||
icon.png | ||
|
||
drawable-ldpi/ | ||
icon.png | ||
|
||
drawable-mdpi/ | ||
icon.png | ||
|
||
layout/ | ||
main.xml | ||
|
||
values/ | ||
strings.xml | ||
|
||
In order to get the build system to recognize Android resources, set the build action to | ||
"AndroidResource". The native Android APIs do not operate directly with filenames, but | ||
instead operate on resource IDs. When you compile an Android application that uses resources, | ||
the build system will package the resources for distribution and generate a class called | ||
"Resource" that contains the tokens for each one of the resources included. For example, | ||
for the above Resources layout, this is what the Resource class would expose: | ||
|
||
public class Resource { | ||
public class drawable { | ||
public const int icon = 0x123; | ||
} | ||
|
||
public class layout { | ||
public const int main = 0x456; | ||
} | ||
|
||
public class strings { | ||
public const int first_string = 0xabc; | ||
public const int second_string = 0xbcd; | ||
} | ||
} | ||
|
||
You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main | ||
to reference the layout/main.xml file, or Resource.strings.first_string to reference the first | ||
string in the dictionary file values/strings.xml. |
Oops, something went wrong.