protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); if (DataManager.Get <ISettingsManager>().Settings.InAppPurchase) { BillingHandler = new SaneInAppBillingHandler(this, DataManager.Get <ISettingsManager>().Settings.PublicKey); try { Task.Run( async() => { await BillingHandler.Connect(); if (DownloadManager.IsLogged()) { //abbonamenti var purch = await BillingHandler.GetPurchases(ItemType.Subscription); var subList = new List <Dictionary <string, string> >(); foreach (var p in purch) { //BillingHandler.ConsumePurchase(p); Dictionary <string, string> data = new Dictionary <string, string>(); string orderID = p.OrderId; if (orderID == null || orderID == "") { orderID = p.PurchaseToken; } data.Add("packageName", this.PackageName); data.Add("orderId", orderID); data.Add("productId", p.ProductId); data.Add("developerPayload", p.DeveloperPayload); data.Add("purchaseTime", p.PurchaseTime.ToString()); data.Add("purchaseToken", p.PurchaseToken); data.Add("purchaseState", p.PurchaseState.ToString()); subList.Add(data); } var encodeData = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(subList))); Notification.CheckSubscriptions(encodeData); } } ); //await _billingHandler.Connect(); } catch (InAppBillingException ex) { // Thrown if the commection fails for whatever reason (device doesn't support In-App billing, etc.) // All methods (except for Disconnect()) may throw this exception, // handling it is omitted for brevity in the rest of the samples Log.Error("HomeScreen", ex.Message); } } //permessi cartella condivisa if (!this.CanAccessExternal()) { var permissions = new string[] { Manifest.Permission.ReadExternalStorage, Manifest.Permission.WriteExternalStorage }; this.RequestPermissions(permissions, 1); } //this.SetTheme(Resource.Style.MB); SetContentView(Resource.Layout.HomeScreen); MenuLabels = new Dictionary <string, string>() { { "edicola", GetString(Resource.String.menu_Edicola) }, { "download", GetString(Resource.String.menu_Download) }, { "impostazioni", GetString(Resource.String.menu_Settings) }, { "crediti", GetString(Resource.String.menu_Credits) }, { "ciccio", "ddddddd" } }; _Title = _DrawerTitle = Title = this.AppName(); _Drawer = this.FindViewById <DrawerLayout>(Resource.Id.drawer_layout); _DrawerList = this.FindViewById <ListView>(Resource.Id.left_drawer); _DrawerContent = this.FindViewById <LinearLayout>(Resource.Id.drawer_content); _Drawer.SetBackgroundColor(Color.Transparent.FromHex("eeeeee")); //voci menu List <string> Sections = new List <string>(); if (DataManager.Get <ISettingsManager>().Settings.EdicolaEnabled) { MenuItems.Add("edicola"); Sections.Add(MenuLabels["edicola"]); } if (DataManager.Get <ISettingsManager>().Settings.DownloadEnabled) { MenuItems.Add("download"); Sections.Add(MenuLabels["download"]); } if (DataManager.Get <ISettingsManager>().Settings.SettingsEnabled) { MenuItems.Add("impostazioni"); Sections.Add(MenuLabels["impostazioni"]); } MenuItems.Add("crediti"); Sections.Add(MenuLabels["crediti"]); //_DrawerList.Adapter = new ArrayAdapter<string>(this, Resource.Layout.DrawerListItem, Sections); _DrawerList.Adapter = new DrawerAdapter <string>(this, Resource.Layout.DrawerListItem, Sections); _DrawerList.ItemClick += (sender, args) => ListItemClicked(args.Position); _Drawer.SetDrawerShadow(Resource.Drawable.drawer_shadow_light, (int)Android.Views.GravityFlags.Start); _DrawerContent.SetBackgroundColor(Color.Transparent.FromHex(DataManager.Get <ISettingsManager>().Settings.MenuFondoColor)); _DrawerList.SetBackgroundColor(Color.Transparent.FromHex(DataManager.Get <ISettingsManager>().Settings.MenuFondoColor)); _DrawerList.Divider = new ColorDrawable(Color.Transparent); _DrawerList.DividerHeight = 8; _DrawerToggle = new MyActionBarDrawerToggle(this, _Drawer, Resource.Drawable.ic_drawer, Resource.String.DrawerOpen, Resource.String.DrawerClose); //Display the current fragments title and update the options menu _DrawerToggle.DrawerClosed += (o, args) => { this.ActionBar.Title = _Title; ActionBar.SetDisplayShowCustomEnabled(true); this.InvalidateOptionsMenu(); }; //Display the drawer title and update the options menu _DrawerToggle.DrawerOpened += (o, args) => { this.ActionBar.Title = _DrawerTitle; ActionBar.SetDisplayShowCustomEnabled(false); this.InvalidateOptionsMenu(); }; //Set the drawer lister to be the toggle. _Drawer.SetDrawerListener(this._DrawerToggle); //if first time you will want to go ahead and click first item. if (bundle == null) { ListItemClicked(0); } /*string color = "#" + DataManager.Get<ISettingsManager>().Settings.NavigationBarColor; * ActionBar.SetBackgroundDrawable(new ColorDrawable(Color.ParseColor(color))); * * int amId = this.Resources.GetIdentifier("action_context_bar", "id", "android"); * View view= FindViewById(amId); * view.SetBackgroundColor(Color.ParseColor(color)); */ ActionBar.SetCustomView(Resource.Layout.CustomActionBar); ActionBar.SetDisplayShowCustomEnabled(true); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetHomeButtonEnabled(true); //ActionBar.SetDisplayShowHomeEnabled (false); ActionBar.SetIcon(Android.Resource.Color.Transparent); ActionBar.SetBackgroundDrawable(new ColorDrawable(Color.Transparent.FromHex(DataManager.Get <ISettingsManager>().Settings.NavigationBarColor))); //ActionBar.CustomView.Background.Colorize(DataManager.Get<ISettingsManager>().Settings.NavigationBarColor); var btnBack = ActionBar.CustomView.FindViewById <Button>(Resource.Id.btnBack); btnBack.SetTextColor(Color.Transparent.FromHex(DataManager.Get <ISettingsManager>().Settings.TintColor)); btnBack.Click += (sender, e) => { if (_CurrentItem == "crediti" || _CurrentItem == "impostazioni") { _Drawer.OpenDrawer(_DrawerContent); } }; //colore titolo var titleId = Resources.GetIdentifier("action_bar_title", "id", "android"); var abTitle = FindViewById <TextView>(titleId); abTitle.SetTextColor(Color.Transparent.FromHex(DataManager.Get <ISettingsManager>().Settings.TintColor)); //se è un'applicazione edicola e non ci sono documenti lo mando direttamente ai downloads if (DataManager.Get <ISettingsManager>().Settings.EdicolaEnabled&& DataManager.Get <ISettingsManager>().Settings.DownloadEnabled) { if (FileSystemManager.ElemetsInBaseDir == 0) { //if(/*this.CanAccessExternal() &&*/ FileSystemManager.DocumentsToImport == 0) GoTo(1); } } //coloro l'icona di navigazione ColorizeDrawer(); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.DownloadScreen, container, false); Activity.Title = Activity.ActionBar.Title = GetString(Resource.String.menu_Download); if (Activity.GetType() == typeof(HomeScreen)) { var home = Activity as HomeScreen; _billingHandler = home.BillingHandler; } this.SetHasOptionsMenu(true); //this.RetainInstance = true; //this.HasOptionsMenu = true; /*ActionBar.Title = "Pubblicazioni"; * ActionBar.SetHomeButtonEnabled(true);*/ string color = DataManager.Get <ISettingsManager>().Settings.ToolbarBarColor; //ActionBar.SetBackgroundDrawable(new ColorDrawable(Color.ParseColor(color))); _GridView = view.FindViewById <GridView>(Resource.Id.downloadGrid); _GridView.ChoiceMode = (ChoiceMode)AbsListViewChoiceMode.None; this.SetGridColumnNumber(); //selettore /*StateListDrawable states = new StateListDrawable(); * states.AddState(new int[] {Android.Resource.Attribute.StatePressed}, new ColorDrawable(Color.ParseColor(color).SetAlpha(0.2f))); * states.AddState(new int[] {}, new ColorDrawable(Color.Transparent)); * * _EdicolaGridView.Selector = states; //new ColorDrawable(Color.ParseColor(color).SetAlpha(0.5f)); * _EdicolaGridView.SetDrawSelectorOnTop(true);*/ _GridView.ItemClick += OnItemClick; //pulsante indietro _BtnBack = Activity.ActionBar.CustomView.FindViewById <Button>(Resource.Id.btnBack); _BtnBack.Text = Activity.Title = Activity.ActionBar.Title = GetString(Resource.String.down_title); _BtnBack.SetCompoundDrawables(null, null, null, null); _BtnBack.Click += (sender, e) => { if (_CurrentDir == "") { if (Activity != null && Activity.GetType() == typeof(HomeScreen)) { var home = Activity as HomeScreen; home.OpenDrawer(); } } this.GoBack(); }; _CurrentDir = ""; if (this.Arguments != null) { String path = this.Arguments.GetString("path"); if (path != null && path != "") { _CurrentDir = path.Trim('/'); } } /*IntentFilter filter = new IntentFilter(Android.App.DownloadManager.ActionDownloadComplete); * Activity.RegisterReceiver(new DownloadReceiver(), filter);*/ //MBDownloadManager.Context = Activity.BaseContext; return(view); }