Exemplo n.º 1
0
        private void ShowSubscribedDialog()
        {
            if (DownloadManager.IsLogged())
            {
                var dialog = new AlertDialog.Builder(Activity);
                dialog.SetTitle(String.Format(GetString(Resource.String.iap_subscribeTo), Activity.ApplicationInfo.LoadLabel(Activity.PackageManager)));

                string[] items = (from a in _Abbonamenti where a.Prezzo != "" select a.Nome + " " + a.Prezzo).ToArray();

                dialog.SetItems(items, SubscribedDialogClicked);
                dialog.SetNegativeButton(GetString(Resource.String.gen_cancel), delegate { return; });

                dialog.Create();
                dialog.Show().SetDivider();
            }
            else
            {
                Action action = delegate {
                    ShowSubscribedDialog();
                };

                ActivitiesBringe.SetObject("loginSuccess", action);

                var logActivity = new Intent(Activity, typeof(LoginActivity));

                StartActivity(logActivity);
            }
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            this.Window.SetSoftInputMode(SoftInput.AdjustResize);

            ActionBar.SetDisplayUseLogoEnabled(false);
            ActionBar.SetIcon(new ColorDrawable(Color.Transparent));
            ActionBar.SetHomeButtonEnabled(false);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetDisplayShowHomeEnabled(true);
            ActionBar.SetDisplayShowTitleEnabled(true);

            ActionBar.SetBackgroundDrawable(new ColorDrawable(Color.Transparent.FromHex(DataManager.Get <ISettingsManager>().Settings.NavigationBarColor)));

            //back
            var iconId = Resources.GetIdentifier("up", "id", "android");
            var abBack = FindViewById <ImageView>(iconId);

            abBack.Colorize(DataManager.Get <ISettingsManager> ().Settings.TintColor);

            //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));

            this.Title = ActionBar.Title = "Login";

            _contentView = new FrameLayout(this);

            //_contentView.SetBackgroundColor(Color.Red);

            _contentView.Id = 12345;

            this.AddContentView(_contentView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.MatchParent));

            Action onSuccess = (Action)ActivitiesBringe.GetObject("loginSuccess");

            LoginFragment fragment = new LoginFragment();

            fragment.LoginSuccess = onSuccess;

            FragmentManager.BeginTransaction()
            .Add(_contentView.Id, fragment).Commit();
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            this.SetContentView(Resource.Layout.ContentsTable);

            if (ActionBar != null)
            {
                ActionBar.SetDisplayUseLogoEnabled(false);
                ActionBar.SetIcon(new ColorDrawable(Color.Transparent));
                ActionBar.SetHomeButtonEnabled(false);
                ActionBar.SetDisplayHomeAsUpEnabled(true);
                ActionBar.SetDisplayShowHomeEnabled(true);
                ActionBar.SetDisplayShowTitleEnabled(true);
            }

            this.Title = "Contenuti";

            _currentPage   = Intent.GetIntExtra("currentPage", 0);
            _pubblicazione = (Pubblicazione)ActivitiesBringe.GetObject("pub");
            _documento     = (Documento)ActivitiesBringe.GetObject("doc");
            _pdfCore       = (MuPDFCore)ActivitiesBringe.GetObject("pdfCore");

            ViewPager viewPager = (ViewPager)this.FindViewById <ViewPager>(Resource.Id.pagesViewPager);
            ArrayList fragments = getFragments();

            TitleFragmentAdapter ama = new TitleFragmentAdapter(this.SupportFragmentManager, fragments);

            viewPager.Adapter = ama;

            TabPageIndicator indicator = this.FindViewById <TabPageIndicator> (Resource.Id.pagesIndicator);

            indicator.SetViewPager(viewPager);



            /*StateListDrawable bgColorList = new StateListDrawable();
             *
             * bgColorList.AddState(new int[] { Android.Resource.Attribute.StateActivated }, new ColorDrawable(Color.Transparent.FromHex("ff0000")));
             * bgColorList.AddState(new int[] { }, new ColorDrawable(Color.Transparent));
             *
             * indicator.Background = bgColorList;*/

            viewPager.CurrentItem = Intent.GetIntExtra("currentItem", 0);
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            _currentPage   = Intent.GetIntExtra("currentPage", 0);
            _pubblicazione = (Pubblicazione)ActivitiesBringe.GetObject("pub");
            _documento     = (Documento)ActivitiesBringe.GetObject("doc");
            _pdfCore       = (MuPDFCore)ActivitiesBringe.GetObject("pdfCore");

            SetContentView(Resource.Layout.SearchDialog);

            Window.SetSoftInputMode(SoftInput.AdjustNothing);

            if (ActionBar != null)
            {
                this.Title = ActionBar.Title = GetString(Resource.String.search);

                ActionBar.SetDisplayUseLogoEnabled(false);
                ActionBar.SetIcon(new ColorDrawable(Color.Transparent));
                ActionBar.SetHomeButtonEnabled(false);
                ActionBar.SetDisplayHomeAsUpEnabled(true);
                ActionBar.SetDisplayShowHomeEnabled(true);
                ActionBar.SetDisplayShowTitleEnabled(true);
            }

            _pageList = (ListView)FindViewById <ListView>(Resource.Id.pageList);

            _searchView = (SearchView)FindViewById <SearchView>(Resource.Id.searchView);

            int  searchPlateId = _searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);
            View searchPlate   = _searchView.FindViewById(searchPlateId);

            searchPlate.Background.Colorize(DataManager.Get <ISettingsManager>().Settings.ButtonColor);

            _searchView.Focusable = true;
            _searchView.Iconified = false;
            _searchView.RequestFocusFromTouch();

            _searchView.QueryTextChange += (sender, e) =>
            {
                SearchPages(e.NewText);
            };

            _searchView.QueryTextSubmit += (sender, e) =>
            {
                _searchView.ClearFocus();
            };

            _pageList.ItemClick += (sender, e) =>
            {
                var art = _articoli[e.Position];

                Intent myIntent = new Intent(this, typeof(ViewerScreen));
                myIntent.PutExtra("doc", art.IdDocumento);
                myIntent.PutExtra("page", (art.Index - 1).ToString());
                myIntent.PutExtra("action", "page");

                SetResult(Result.Ok, myIntent);
                Finish();
            };

            //paramentro ricerca
            var str = ActivitiesBringe.GetObject("search");

            if (str != null)
            {
                string search = (string)str;

                _searchView.SetQuery(search, true);

                _searchView.RequestFocus();
            }
        }
Exemplo n.º 5
0
        public void OnItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            if (actionMode != null)
            {
                return;
            }

            var item = _Items[e.Position];

            if (item.GetType() == typeof(Download))
            {
                DownloadDetails dialog = new DownloadDetails(this.Activity, item as Download);

                dialog.OpenAction += () =>
                {
                    Intent i = new Intent();
                    i.SetClass(Activity, typeof(ViewerScreen));

                    i.SetAction(Intent.ActionView);

                    i.PutExtra("pubPath", (item as Download).GetLocalPath());
                    Activity.StartActivityForResult(i, 0);

                    dialog.Dismiss();
                };

                dialog.DownloadAction += () =>
                {
                    //var cell = ;
                    //var cell = _GridView.Adapter.get(e.Position);

                    //FileDownloader.DefaultRequestDownload((item as Download).Uri, new DownloadGridItem(Activity, (item as Download)));

                    Download down = (item as Download);
                    //MBDownloadManager.Download(down.Uri.AbsoluteUri, System.IO.Path.GetFileName(down.Uri.LocalPath), down.Titolo);
                    MBDownloadManager.RequestDownload(down.Uri, new VoidNotify());

                    this.PopulateTable();
                    dialog.Dismiss();
                };

                dialog.BuyAction += () =>
                {
                    Task.Run(
                        async() =>
                    {
                        if (!DownloadManager.IsLogged())
                        {
                            Action action = delegate {
                                PopulateTable();
                            };

                            ActivitiesBringe.SetObject("loginSuccess", action);

                            var logActivity = new Intent(Activity, typeof(LoginActivity));
                            StartActivity(logActivity);
                        }
                        else
                        {
                            Download down    = (item as Download);
                            List <string> id = new List <string>()
                            {
                                down.IapID
                            };
                            IReadOnlyList <Product> billProducts = await _billingHandler.QueryInventory(id, ItemType.Product);

                            if (billProducts != null)
                            {
                                var prod = billProducts.FirstOrDefault();
                                if (prod != null && prod.ProductId != null)
                                {
                                    Task billTask = BillProcess(prod);
                                }
                            }
                        }
                    }
                        );

                    dialog.Dismiss();
                };

                dialog.Show();
            }
            else if (item.GetType() == typeof(DownDir))
            {
                Console.WriteLine("click dir" + e.Position);

                DownDir dir = item as DownDir;

                _CurrentDir = dir.Path;
                PopulateTable();
            }
        }
Exemplo n.º 6
0
        private async Task LoadDocuments()
        {
            Utils.WriteLog("download PopulateTable");

            if (!CheckBeforeConnect())
            {
                return;
            }

            List <Download> docs = DownloadManager.GetDocuments(_CurrentDir, DataManager.Get <IPreferencesManager>().Preferences.EdicolaOrder);

            List <DownDir> _Directories = DownloadManager.GetDirectory(_CurrentDir);

            //aggiungo celle vuote in modo da tenere separati cartelle e documenti
            int lastLineCol = _Directories.Count - ((int)(_Directories.Count / ColumnNum) * ColumnNum);

            if (ColumnNum > 1 && lastLineCol > 0)
            {
                int n = ColumnNum - lastLineCol;

                for (int i = 0; i < n; i++)
                {
                    DownDir info = new DownDir();
                    _Directories.Add(info);
                }
            }

            //in-app billing
            // prendo i prodotti che non sono stati acquistati e che non hanno permessi dalla lista che mi arriva dal server
            Action <string> buyAction = null;

            _Abbonamenti = new List <Subscription>();

            if (DataManager.Get <ISettingsManager>().Settings.InAppPurchase&& _billingHandler != null)
            {
                var products = docs.Where(p => p.IapID != "" && !p.IapAutorizzato && !p.IapAcquistato && p.Stato == DownloadStato.Download);

                if (products.Count() > 0)
                {
                    //lista degli id dei prodotti per richiedere le info a google
                    List <string> productsIds = new List <string>();

                    foreach (var prod in products)
                    {
                        productsIds.Add(prod.IapID);
                    }

                    //richiesta delle informazioni a google
                    IReadOnlyList <Product> billProducts = await _billingHandler.QueryInventory(productsIds, ItemType.Product);

                    if (billProducts != null)
                    {
                        //per ogni prodotto setto i valori corretti nel download
                        foreach (var billProd in billProducts)
                        {
                            var down = docs.Where(d => d.IapID == billProd.ProductId).FirstOrDefault();
                            if (down != null && down.ID != "")
                            {
                                if (!down.IapAcquistato && !down.IapAutorizzato && down.Stato == DownloadStato.Download)
                                {
                                    down.IapPrezzo = billProd.Price;
                                    down.Stato     = DownloadStato.Buy;
                                }
                            }

                            //tolgo i prodotti corretti dalla lista degli id
                            productsIds.RemoveAll(x => x == billProd.ProductId);
                        }

                        //gli id rimasti li tolgo dai download perché vuol dire che google non li ha riconosciuti
                        foreach (var id in productsIds)
                        {
                            docs.RemoveAll(x => x.IapID == id);
                        }

                        buyAction += (string p) =>
                        {
                            if (!DownloadManager.IsLogged())
                            {
                                Action action = delegate {
                                    PopulateTable();
                                };

                                ActivitiesBringe.SetObject("loginSuccess", action);

                                var logActivity = new Intent(Activity, typeof(LoginActivity));
                                StartActivity(logActivity);
                            }
                            else
                            {
                                var prod = billProducts.Where(x => x.ProductId == p).FirstOrDefault();

                                if (prod == null)
                                {
                                    return;
                                }

                                Task billTask = BillProcess(prod);
                            }
                        };
                    }
                }

                //abbonamenti
                List <string> subIds = new List <string>();
                _Abbonamenti = DownloadManager.GetSubscriptions();

                foreach (var s in _Abbonamenti)
                {
                    subIds.Add(s.IapID);
                }

                if (subIds.Count > 0)
                {
                    IReadOnlyList <Product> billSubscription = await _billingHandler.QueryInventory(subIds, ItemType.Subscription);

                    if (billSubscription != null)
                    {
                        foreach (var billSub in billSubscription)
                        {
                            var sub = _Abbonamenti.Where(d => d.IapID == billSub.ProductId).FirstOrDefault();

                            if (sub != null && sub.IapID != "")
                            {
                                sub.Nome   = billSub.Title.Replace("(" + Activity.ApplicationInfo.LoadLabel(Activity.PackageManager) + ")", "").Trim();
                                sub.Prezzo = billSub.Price;
                            }

                            //tolgo i prodotti corretti dalla lista degli id
                            subIds.RemoveAll(x => x == billSub.ProductId);
                        }

                        //gli id rimasti li tolgo dai download perché vuol dire che google non li ha riconosciuti
                        foreach (var id in subIds)
                        {
                            _Abbonamenti.RemoveAll(x => x.IapID == id);
                        }
                    }
                }
            }

            _Items = new List <Object>();
            _Items.AddRange(_Directories);
            _Items.AddRange(docs);

            var adapter = new DownloadGridAdapter(Activity, _Items);

            adapter.OpenAction += (string p) =>
            {
                Intent i = new Intent();
                i.SetClass(Activity, typeof(ViewerScreen));

                i.SetAction(Intent.ActionView);

                i.PutExtra("pubPath", p);
                Activity.StartActivityForResult(i, 0);
            };

            if (Activity != null)
            {
                Activity.RunOnUiThread(() =>
                {
                    this.SetTitle();
                    StopUpdating();
                    _GridView.Adapter = adapter;
                });
            }

            if (buyAction != null)
            {
                adapter.BuyAction += buyAction;
            }
        }