示例#1
0
 public override void UpdateTitle()
 {
     if (NohanaImagePickerController != null)
     {
         Title = NSString.LocalizedFormat("Moment");
     }
 }
        public static void SetToolbarTitle(this UIViewController vc, NohanaImagePickerController nohanaImagePickerController)
        {
            var count = vc.ToolbarItems.Length;

            if (count >= 2)
            {
                if (vc.ToolbarItems[1] != null)
                {
                    UIBarButtonItem infoButton = vc.ToolbarItems[1];
                    infoButton.TintColor = UIColor.Black;
                    if (nohanaImagePickerController.MaximumNumberOfSelection == 0)
                    {
                        var title = NSString.LocalizedFormat(
                            (nohanaImagePickerController.Conf.Strings.ToolbarTitleNoLimit ?? NSString.LocalizedFormat($"Selected Items: "))
                            + $"{nohanaImagePickerController.PickedAssetList?.Count ?? 0}");

                        infoButton.Title = title;
                    }
                    else
                    {
                        var title = NSString.LocalizedFormat(
                            (nohanaImagePickerController.Conf.Strings.ToolbarTitleHasLimit ?? NSString.LocalizedFormat($"Selected Items: "))
                            + $"{nohanaImagePickerController.PickedAssetList?.Count ?? 0} / {nohanaImagePickerController.MaximumNumberOfSelection}");

                        infoButton.Title = title;
                    }
                }
            }
        }
示例#3
0
        public async Task <bool> Fetch()
        {
            var dataStore = ServiceLocator.Instance.Get <IVplanDataStore>();
            await dataStore.Load();

            var diff = await dataStore.Refresh();

            if (diff == null)
            {
                throw new Exception();
            }

            var notificationCenter = UNUserNotificationCenter.Current;
            var settings           = await notificationCenter.GetNotificationSettingsAsync();

            var oldNotifications = await notificationCenter.GetPendingNotificationRequestsAsync();

            if (settings.AuthorizationStatus == UNAuthorizationStatus.Authorized &&
                oldNotifications.Length == 0 &&
                (diff.NewBookmarkedChanges.Any() || diff.NewNewSchoolClassBookmarks.Any()))
            {
                var content = new UNMutableNotificationContent
                {
                    Title = NSBundle.MainBundle.LocalizedString("new_plan_title", "")
                };
                if (diff.NewBookmarkedChanges.Any())
                {
                    if (diff.NewBookmarkedChanges.Count() == 1)
                    {
                        content.Body = NSBundle.MainBundle.LocalizedString("new_changes_singular", "");
                    }
                    else
                    {
                        var text = NSBundle.MainBundle.LocalizedString("new_changes_plural", "");
                        content.Body = NSString.LocalizedFormat(text, diff.NewBookmarkedChanges.Count());
                    }
                    content.Badge = diff.NewBookmarkedChanges.Count();
                }
                else
                {
                    if (diff.NewNewSchoolClassBookmarks.Count() == 1)
                    {
                        content.Body = NSBundle.MainBundle.LocalizedString("new_school_classes_singular", "");
                    }
                    else
                    {
                        var text = NSBundle.MainBundle.LocalizedString("new_school_classes_plural", "");
                        content.Body = NSString.LocalizedFormat(text, diff.NewNewSchoolClassBookmarks.Count());
                    }
                    content.Badge = diff.NewNewSchoolClassBookmarks.Count();
                }

                var request = UNNotificationRequest.FromIdentifier(dataStore.SchoolVplan.Value.LastUpdate.ToString(), content, null);
                await notificationCenter.AddNotificationRequestAsync(request);
            }

            return(diff.Updated);
        }
示例#4
0
 void ReloadData()
 {
     InvokeOnMainThread(() =>
     {
         DataSource.Context = this;
         DataSource.Items   = ViewModel?.Items;
         TableView.ReloadData();
         var lastUpdateText   = NSBundle.MainBundle.LocalizedString("vplan_last_update", "");
         LastUpdateLabel.Text = NSString.LocalizedFormat(lastUpdateText, ViewModel?.LastUpdate);
     });
 }
示例#5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var nohanaImagePickerController = NohanaImagePickerController;

            if (nohanaImagePickerController != null)
            {
                View.BackgroundColor = nohanaImagePickerController.Conf.Color.Background ?? UIColor.White;
                Title = nohanaImagePickerController.Conf.Strings.AlbumListTitle ?? NSString.LocalizedFormat("Photos", "NohanaImagePicker", nohanaImagePickerController, string.Empty);
                this.SetUpToolbarItems();
                NavigationController.SetToolbarHidden(nohanaImagePickerController.ToolbarHidden, false);
            }
            SetUpEmptyIndicator();
            SetUpActivityIndicator();
            this.TableView.SeparatorColor = UIColor.LightGray;
        }
示例#6
0
        public void LocalizedFormatTest()
        {
            // Strings and NSstring
            Assert.AreEqual("hello", NSString.LocalizedFormat("hello").ToString());
            Assert.AreEqual("hello", NSString.LocalizedFormat(new NSString("hello")).ToString());

            // Test the overloads with numbers
            Assert.AreEqual("hello", NSString.LocalizedFormat("hello").ToString());
            Assert.AreEqual("hello0", NSString.LocalizedFormat("hello%@", 0).ToString());
            Assert.AreEqual("hello01", NSString.LocalizedFormat("hello%@%@", 0, 1).ToString());
            Assert.AreEqual("hello012", NSString.LocalizedFormat("hello%@%@%@", 0, 1, 2).ToString());
            Assert.AreEqual("hello0123", NSString.LocalizedFormat("hello%@%@%@%@", 0, 1, 2, 3).ToString());
            Assert.AreEqual("hello01234", NSString.LocalizedFormat("hello%@%@%@%@%@", 0, 1, 2, 3, 4).ToString());
            Assert.AreEqual("hello012345", NSString.LocalizedFormat("hello%@%@%@%@%@%@", 0, 1, 2, 3, 4, 5).ToString());
            Assert.AreEqual("hello0123456", NSString.LocalizedFormat("hello%@%@%@%@%@%@%@", 0, 1, 2, 3, 4, 5, 6).ToString());
            Assert.AreEqual("hello01234567", NSString.LocalizedFormat("hello%@%@%@%@%@%@%@%@", 0, 1, 2, 3, 4, 5, 6, 7).ToString());
            Assert.AreEqual("hello012345678", NSString.LocalizedFormat("hello%@%@%@%@%@%@%@%@%@", 0, 1, 2, 3, 4, 5, 6, 7, 8).ToString());
        }
示例#7
0
        private static NSString OK_QueryStringWithSignature(this NSDictionary self, NSString secretKey, NSString sigName)
        {
            var sigSource   = new NSMutableString();
            var queryString = new NSMutableString();

            var sortedKeys = self.Keys.OrderBy((NSObject arg) => arg);

            foreach (var key in sortedKeys)
            {
                var @value = self[key] as NSString;
                sigSource.Append(NSString.LocalizedFormat(@"%@=%@\", key, value));
                queryString.Append(NSString.LocalizedFormat(@"%@=%@&", key, value.OK_Encode()));
            }

            sigSource.Append(secretKey);
            queryString.Append(NSString.LocalizedFormat(@"%@=%@&", sigName, sigSource.OK_MD5()));

            return(queryString);
        }
示例#8
0
        void SetUpEmptyIndicator()
        {
            var frame = new CGRect(CGPoint.Empty, Size.ScreenRectWithoutAppBar(this).Size);
            var nohanaImagePickerController = NohanaImagePickerController;

            if (nohanaImagePickerController != null)
            {
                EmptyIndicator = new AlbumListEmptyIndicator(
                    message: nohanaImagePickerController.Conf.Strings.AlbumListEmptyMessage ?? NSString.LocalizedFormat("No Photos"),
                    description: nohanaImagePickerController.Conf.Strings.AlbumListEmptyDescription ?? NSString.LocalizedFormat("Use the camera to take new photos."),
                    frame: frame,
                    config: nohanaImagePickerController.Conf
                    );
            }
        }
示例#9
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            if ((indexPath.Section + 1) > albumListViewControllerSectionTypeCount)
            {
                throw new Exception("bad section type selected");
            }

            var sectionType = (AlbumListViewControllerSectionType)Enum.ToObject(typeof(AlbumListViewControllerSectionType), indexPath.Section);

            switch (sectionType)
            {
            case AlbumListViewControllerSectionType.Moment:
                var cell = TableView.DequeueReusableCell("MomentAlbumCell") as MomentCell;
                if (cell == null)
                {
                    throw new Exception("failed to dequeueReusableCellWithIdentifier(\"MomentAlbumCell\")");
                }
                if (NohanaImagePickerController != null)
                {
                    cell.Config          = NohanaImagePickerController.Conf;
                    cell.titleLabel.Text = NohanaImagePickerController.Conf.Strings.AlbumListMomentTitle ?? NSString.LocalizedFormat("Moment", "NohanaImagePicker", NohanaImagePickerController.AssetBundle, string.Empty);
                }
                return(cell);

            case AlbumListViewControllerSectionType.Albums:
                var albumCell = TableView.DequeueReusableCell("AlbumCell") as AlbumCell;
                if (albumCell == null)
                {
                    throw new Exception("failed to dequeueReusableCellWithIdentifier(\"AlbumCell\")");
                }
                var albumList = PhotoKitAlbumList[indexPath.Row];
                albumCell.titleLabel.Text = albumList.Title;
                albumCell.Tag             = indexPath.Row;
                var imageSize = new CGSize(
                    width: albumCell.thumbnailImageView.Frame.Size.Width * UIScreen.MainScreen.Scale,
                    height: albumCell.thumbnailImageView.Frame.Size.Width * UIScreen.MainScreen.Scale
                    );
                var albumCount = albumList.Count;
                if (albumCount > 0)
                {
                    var lastAsset = albumList[albumCount - 1];

                    lastAsset.Image(imageSize, (imageData) =>
                    {
                        InvokeOnMainThread(() =>
                        {
                            if (albumCell.Tag == indexPath.Row)
                            {
                                albumCell.thumbnailImageView.Image = imageData.Image;
                            }
                        });
                    });
                }
                else
                {
                    albumCell.thumbnailImageView.Image = null;
                }
                return(albumCell);
            }


            return(base.GetCell(tableView, indexPath));
        }