Beispiel #1
0
 public void ParseNotExistingBookTest()
 {
     Book book = new BookFullModel("/sdcard/translyte/notexists.fb2");
     Book.Load(ref book);
     Assert.AreNotEqual(null, book.Title);
     Assert.Pass(book.Title);
 }
Beispiel #2
0
 public void CheckBookAuthorTest()
 {
     Book book = new BookFullModel("/sdcard/translyte/Starik.fb2");
     Book.Load(ref book);
     Assert.AreNotEqual(null, book.Author);
     Assert.Pass(book.Author);
 }
Beispiel #3
0
 public void CheckBookAnnotationTest()
 {
     Book book = new BookFullModel("/sdcard/translyte/Starik.fb2");
     Book.Load(ref book);
     Assert.AreNotEqual(null, ((BookFullModel)book).Annotation);
     Assert.Pass(((BookFullModel)book).Annotation);
 }
Beispiel #4
0
 public GalleryBookItem(BookFullModel book)
 {
     _book = book;
 }
Beispiel #5
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            ParentView = inflater.Inflate(Resource.Layout.BookView, container, false);
            LibraryView parentActivity = Activity as LibraryView;
            ParentActivity = parentActivity;

            HasOptionsMenu = true;
            var resideMenu = parentActivity.ResideMenu;

            var title = ParentView.FindViewById<TextView>(Resource.Id.tv_title);
            TextView content = ParentView.FindViewById<TextView>(Resource.Id.tv_book);
            content.SetTextIsSelectable(true);

            ParentView.FindViewById(Resource.Id.tv_book).Click += (s, e) => resideMenu.OpenMenu(global::AndroidResideMenu.ResideMenu.Direction.Left);

            ISharedPreferences prefs = Application.Context.GetSharedPreferences("Settings", FileCreationMode.Private);
            var isDark = prefs.GetBoolean("themeDark", false);
            if (isDark)
            {
                var layout = ParentView.FindViewById<RelativeLayout>(Resource.Id.bookLayout);
                layout.SetBackgroundColor(Color.DarkGray);
                content.SetTextColor(Color.WhiteSmoke);
                title.SetTextColor(Color.WhiteSmoke);
            }
            var size = prefs.GetInt("textSize", 20);
            content.SetTextSize(ComplexUnitType.Dip, size);
            title.SetTextSize(ComplexUnitType.Dip, size + 5);

            var textFont = prefs.GetString("textFont", "Arial");
            var res="";
            switch(textFont)
            {
            case "Arial":
                res = "arial";
                break;
            case "Verdana":
                res = "airstrike";
                break;
            case "Calibri":
                res = "BodoniFLF-Roman";
                break;
            default :
                res = "Raleway-Medium";
                break;
            }
            Typeface tf = Typeface.CreateFromAsset (Application.Context.Assets, "fonts/" + res + ".ttf");
            content.Typeface = tf;
            title.SetTextSize(ComplexUnitType.Dip, 25);

            string extraData = null;
            if (Arguments != null)
                extraData = Arguments.GetString("book");
            if (extraData != null)
            {
                var tempBook = JsonConvert.DeserializeObject<BookReviewModel>(extraData);
                title.Text = tempBook.Title;
                parentActivity.RunOnUiThread(() =>
                {
                    Thread.CurrentThread.IsBackground = true;
                    Book curBook = new BookFullModel(tempBook.BookPath){Position = tempBook.Position};
                    Book.Load(ref curBook);
                    content.Text = ((BookFullModel)curBook).Content;
                    content.CustomSelectionActionModeCallback = new WordSelector(content, ParentActivity, ((BookFullModel)curBook).Language);
                    SetPosition(curBook.Position);
                    _currentBook = (BookFullModel)curBook;
                    var sqliteFilename = "TaskDB.db3";
                    string libraryPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                    var path = Path.Combine(libraryPath, sqliteFilename);
                    var conn = new Connection(path);
                    _translyteDbGateway = new TranslyteDbGateway(conn);
                });
            }
            return ParentView;
        }