eschao / android-PageFlip

3D Style Page Flip on Android
Apache License 2.0
1.74k stars 262 forks source link

Is it really to highlight the text on pages? #35

Closed acuna-public closed 6 years ago

acuna-public commented 6 years ago

I need to implement the text highlight on pages to copy it (for example). I'm clicking on text (eg "First page" which is default) and hold it, but have no action. Is it really to use a TextView rather than Bitmap or I missing something?

eschao commented 6 years ago

@acuna-pro No, you can't use TextView on it since pageflip only accepts a bitmap as a screen content to show. I'm not sure why you need that. Suppose you want to implement a pageflip animation when swap two views. I think android animation library should be responsible for it, but unfortunately, pageflip doesn't support android animation layer.

acuna-public commented 6 years ago

Because I'm looking for the way to implement the text hightlight in books (e. g. like in learning manuals and synopsis). Any known bookreaders like MoonReader, eReader, etc have similar page flips, but with normal text which can be highlighted. Seems that they've found the way to implement it, and not so known readers are too, so seems that it's really, but don't know how...

eschao commented 6 years ago

@acuna-pro Firstly, you need to understand the principle of the PageFlip lib. It is just aimed to implement a 3D style flipping effect with OpenGL. This is only what it is responsible for. Except that, all the functions what you need should be implemented by yourself or other 3rd library. Given that your requirement, I think you can follow the below steps to reach:

  1. Draw normal text of one page on a bitmap, pass the bitmap to PageFlip to show.
  2. Intercept gesture before PageFlip handle them to turn page. For example: long click a word. you need to recognize the long click action and find out which word is chosen by (x, y) coordinate.
  3. Redraw the selected word with highlight style on a bitmap, normally, you need to redraw the whole page with the different style for choosing word. and then pass it to PageFlip to show it on screen.

As you see in the above steps, you have to be responsible for drawing text with different style. The PageFlip only help you to show a prepared bitmap on screen and play a flip animation when trigger a page turning. Hope my answer can help address your problem.

mahdimzf2015 commented 6 years ago

I want to write text in every page. please guide how I put to each page the text

acuna-public commented 6 years ago

@eschao Wow, thanks a lot for your adviсes. Seems that I need to implement it by myself... But I still can't believe that all not most known readers have this implemented yet but there's no any open-source libraries for this...

mahdimzf2015 commented 6 years ago

please help me.I want to write text in every page. please guide how I put to each page the text

acuna-public commented 6 years ago

@mahdimzf2015 What is your problem? You can find the "First page" text in the code and edit it for your purposes, but it will be an image only, but with text.

eschao commented 6 years ago

@acuna-pro I created a reader application on Android before(not open source project), that's why I know this responsibility is not in PageFlip's scope and that is also why I created PageFlip library. :)

acuna-public commented 6 years ago

Ah, wait, I don't understand you) You've created a reader which is supported the plain text, but created a PageFlip in open-source which do not? Can't imagine where it can be useful to use images instead of plain text) But after that, I have some thoughts about its implementation (but now I making another project), but how do you think, can I put it to open-source afterwards? There's some... some... ethic moment in this all :/ Thanks.