Professional Documents
Culture Documents
Kod Za Android Aplikaciju
Kod Za Android Aplikaciju
using Acr.UserDialogs;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Android.Util;
using Android.Views;
using CarouselView.FormsPlugin.Android;
using Microsoft.AppCenter.Push;
using Microsoft.Identity.Client;
using Plugin.HtmlLabel.Android;
using Plugin.Permissions;
using TheBeat.Clients.Base.Helpers;
using TheBeat.Clients.Base.Services.Authentication;
using TheBeat.Clients.Base.ViewModels.Base;
using TheBeat.Clients.Droid.Services.Authentication;
using TheBeat.Clients.Droid.Services.CardEmulation;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
namespace TheBeat.Clients.Droid
{
[Activity(
Label = "theBeat.hr",
Icon = "@drawable/icon",
Theme = "@style/MainTheme",
MainLauncher = false,
ScreenOrientation = ScreenOrientation.Portrait)]
public class MainActivity : FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
HtmlLabelRenderer.Initialize();
Forms.Init(this, bundle);
CarouselViewRenderer.Init();
UserDialogs.Init(this);
Renderers.Calendar.Init();
Xamarin.FormsMaps.Init(this, bundle);
Push.SetSenderId("802023456231");
InitMessageCenterSubscriptions();
RegisterPlatformDependencies();
LoadApplication(new App());
App.AuthenticationClient.PlatformParameters =
new PlatformParameters(Forms.Context as Activity);
MakeStatusBarTranslucent(false);
InitNFCService();
}
using System;
using Android.App;
using Android.OS;
using Android.Runtime;
using Plugin.CurrentActivity;
namespace TheBeat.Clients.Droid
{
//You can specify additional application information in this attribute
[Application]
public class MainApplication : Application, Application.IActivityLifecycleCallbacks
{
public MainApplication(IntPtr handle, JniHandleOwnership transer)
:base(handle, transer)
{
}
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Android.Support.V7.App;
using Android.Views;
namespace TheBeat.Clients.Droid
{
[Activity(
Label = "theBeat.hr",
Icon = "@drawable/icon",
Theme = "@style/SplashTheme",
MainLauncher = true,
NoHistory = true,
ScreenOrientation = ScreenOrientation.Portrait)]
public class SplashActivity : AppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
InvokeMainActivity();
}
using Android.OS;
using Android.Webkit;
using TheBeat.Clients.Base.Services.Authentication;
using System.Threading.Tasks;
namespace TheBeat.Clients.Droid.Services.Authentication
{
public class BrowserCookiesService : IBrowserCookiesService
{
public Task ClearCookiesAsync()
{
var context = Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity;
return Task.FromResult(true);
}
}
}
using System;
using System.Linq;
using System.Text;
using Android.OS;
using Android.Nfc.CardEmulators;
using TheBeat.Clients.Base;
using Xamarin.Forms;
using Android.App;
namespace TheBeat.Clients.Droid.Services.CardEmulation
{
[Service(
Exported = true,
Enabled = true,
Name = ServiceName,
Permission = "android.permission.BIND_NFC_SERVICE"),
IntentFilter(new[] { "android.nfc.cardemulation.action.HOST_APDU_SERVICE" },
Categories = new[] { "android.intent.category.DEFAULT" }),
MetaData("android.nfc.cardemulation.host_apdu_service",
Resource = "@xml/apduservice")]
public class CardService : HostApduService
{
public const string ServiceName = "theBeat.clients.droid.services.cardEmulation.cardService";
public CardService()
{
MessagingCenter.Subscribe<string>(this, MessengerKeys.SendNFCToken, StartNFCService);
}
using Android.Views.InputMethods;
using Plugin.CurrentActivity;
using TheBeat.Clients.Base.Services.DismissKeyboard;
using TheBeat.Clients.Droid.Services.DismissKeyboard;
[assembly: Xamarin.Forms.Dependency(typeof(DismissKeyboardService))]
namespace TheBeat.Clients.Droid.Services.DismissKeyboard
{
public class DismissKeyboardService : IDismissKeyboardService
{
public void DismissKeyboard()
{
InputMethodManager inputMethodManager =
InputMethodManager.FromContext(CrossCurrentActivity.Current.Activity.ApplicationContext);
inputMethodManager.HideSoftInputFromWindow(
CrossCurrentActivity.Current.Activity.Window.DecorView.WindowToken, HideSoftInputFlags.NotAlways);
}
}
}
using Android.App;
using Android.Nfc;
using TheBeat.Clients.Base.Services.NFC;
using TheBeat.Clients.Droid.Services.NFC;
[assembly: Xamarin.Forms.Dependency(typeof(NfcService))]
namespace TheBeat.Clients.Droid.Services.NFC
{
public class NfcService : INfcService
{
private NfcAdapter _nfcDevice;
public NfcService()
{
var activity = Xamarin.Forms.Forms.Context as Activity;
_nfcDevice = NfcAdapter.GetDefaultAdapter(activity);
}
using System.Collections.Generic;
using Android.Runtime;
using Xamarin.Forms.Platform.Android;
using TheBeat.Clients.Base.Controls;
using Android.Graphics.Drawables;
using System.Threading.Tasks;
using Xamarin.Forms;
using TheBeat.Clients.Droid.Renderers;
using Android.Graphics;
if (e.PropertyName == nameof(element.BackgroundPattern))
{
ChangeBackgroundPattern();
}
if (e.PropertyName == nameof(element.BackgroundImage))
{
if (element.BackgroundImage == null)
{
var drawable = new GradientDrawable();
drawable.SetShape(ShapeType.Rectangle);
drawable.SetStroke((int)Element.BorderWidth, Element.BorderColor.ToAndroid());
drawable.SetColor(Element.BackgroundColor.ToAndroid());
Control.SetBackground(drawable);
}
else
{
await ChangeBackgroundImageAsync();
}
}
}
using Android.Gms.Maps;
using Android.Gms.Maps.Model;
using TheBeat.Clients.Base.Controls;
using TheBeat.Clients.Base.Helpers;
using TheBeat.Clients.Base.Models;
using TheBeat.Clients.Droid.Renderers;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Xamarin.Forms;
using Xamarin.Forms.Maps;
using Xamarin.Forms.Maps.Android;
public CustomMapRenderer()
{
_tempMarkers = new List<CustomMarkerOptions>();
_pinIcon = BitmapDescriptorFactory.FromResource(EventResource);
}
NativeMap.MyLocationEnabled = formsMap.IsShowingUser;
AddPushPins(androidMapView, formsMap.CustomPins);
PositionMap();
_isDrawnDone = true;
}
}
if (changed)
{
_isDrawnDone = false;
}
}
switch (formsPin.Type)
{
case SuggestionType.Event:
_pinIcon = BitmapDescriptorFactory.FromResource(EventResource);
markerWithIcon.SetIcon(_pinIcon);
break;
case SuggestionType.Restaurant:
_pinIcon = BitmapDescriptorFactory.FromResource(RestaurantResource);
markerWithIcon.SetIcon(_pinIcon);
break;
default:
markerWithIcon.SetIcon(BitmapDescriptorFactory.DefaultMarker());
break;
}
NativeMap.AddMarker(markerWithIcon);
_tempMarkers.Add(new CustomMarkerOptions
{
Id = formsPin.Id,
MarkerOptions = markerWithIcon
});
}
}
myMap.MoveToRegion(MapSpan.FromCenterAndRadius(centerPosition, Distance.FromMiles(distance)));
}
}
using Android.Support.V7.Widget;
using TheBeat.Clients.Base.Views;
using TheBeat.Clients.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms.Platform.Android.AppCompat;
using AView = Android.Views.View;
int containerHeight = b - t;
if (child is Toolbar)
{
continue;
}
child.Layout(0, 0, r, b);
}
}
}
}
using TheBeat.Clients.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
Control?.SetPadding(0, 0, 0, 0);
}
}
}
using System.ComponentModel;
using TheBeat.Clients.Base.Controls;
using TheBeat.Clients.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
if (e.NewElement != null)
{
Control.InputType |= Android.Text.InputTypes.TextFlagNoSuggestions;
UpdateLineColor();
}
}
if (e.PropertyName.Equals(nameof(ExtendedEntry.LineColorToApply)))
{
UpdateLineColor();
}
}
/*
// Helpers/Settings.cs This file was automatically added when you installed the Settings Plugin. If you are not using a
PCL then comment this file back in to use it.
using Plugin.Settings;
using Plugin.Settings.Abstractions;
namespace TheBeat.Clients.Droid.Helpers
{
/// <summary>
/// This is the Settings static class that can be used in your Core solution or in any
/// of your client applications. All settings are laid out the same exact way with getters
/// and setters.
/// </summary>
public static class Settings
{
private static ISettings AppSettings
{
get
{
return CrossSettings.Current;
}
}
#endregion
}
}*/
using Android.Widget;
using TheBeat.Clients.Droid.Effects;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
if (label != null)
{
label.PaintFlags |= Android.Graphics.PaintFlags.UnderlineText;
}
}