Skip to content

Commit

Permalink
add tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
tienddMbt91 committed Jun 25, 2020
1 parent 21236de commit 7f2d300
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 9 deletions.
14 changes: 14 additions & 0 deletions folioreader/res/drawable/ic_tooltip1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="234dp"
android:height="92.599dp"
android:viewportWidth="234"
android:viewportHeight="92.599">
<path
android:pathData="M130.055,30.02a15.721,15.721 75,1 0,-27.23 -15.721C98.484,21.818 100.591,31.08 108.114,35.423"
android:strokeWidth="1"
android:fillColor="#00000000"
android:strokeColor="#fff"/>
<path
android:pathData="M131.726,33.208a5.051,5.051 0,0 0,-4.537 -4.573,4.206 4.206,0 0,0 -3.459,-1.752 5.1,5.1 0,0 0,-0.934 0.1A4.155,4.155 0,0 0,119.551 25.523h-0.1L119.451,20.837a3.593,3.593 0,1 0,-7.187 0L112.264,29.873l-0.089,-0.128a3.49,3.49 0,0 0,-3 -1.738,3.794 3.794,0 0,0 -3.256,1.905 3.467,3.467 0,0 0,0.084 3.542l7.858,15.049a1.813,1.813 0,0 0,1.605 0.98L126.532,49.483A1.821,1.821 0,0 0,128.341 47.773l0.257,-4.192C131.343,39.356 132.251,36.331 131.726,33.208ZM127.108,43.161 L126.831,47.678a0.305,0.305 0,0 1,-0.3 0.288L115.467,47.966a0.306,0.306 0,0 1,-0.265 -0.168L107.324,32.716a2.1,2.1 0,0 1,1.848 -3.2,1.976 1.976,0 0,1 1.721,1.032l1.008,1.548a1,1 0,0 0,0.846 0.464A1.016,1.016 0,0 0,113.781 31.543L113.781,20.837a2.08,2.08 0,1 1,4.161 0v6.087a0.3,0.3 0,0 0,0.389 0.285,4 4,0 0,1 1.2,-0.2 2.763,2.763 0,0 1,2.5 1.489,0.318 0.318,0 0,0 0.273,0.159 0.306,0.306 0,0 0,0.106 -0.019,3.912 3.912,0 0,1 1.317,-0.244 2.705,2.705 0,0 1,2.363 1.311,0.934 0.934,0 0,0 0.731,0.414 3.559,3.559 0,0 1,3.409 3.337c0.456,2.718 -0.33,5.4 -3.077,9.556A0.3,0.3 0,0 0,127.107 43.161Z"
android:fillColor="#fff"/>
</vector>
8 changes: 8 additions & 0 deletions folioreader/res/drawable/ic_tooltip11.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<vector android:alpha="0" android:height="92.599dp"
android:viewportHeight="92.599" android:viewportWidth="234"
android:width="234dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#00000000"
android:pathData="M130.055,30.02a15.721,15.721 75,1 0,-27.23 -15.721C98.484,21.818 100.591,31.08 108.114,35.423"
android:strokeColor="#fff" android:strokeWidth="1"/>
<path android:fillColor="#fff" android:pathData="M131.726,33.208a5.051,5.051 0,0 0,-4.537 -4.573,4.206 4.206,0 0,0 -3.459,-1.752 5.1,5.1 0,0 0,-0.934 0.1A4.155,4.155 0,0 0,119.551 25.523h-0.1L119.451,20.837a3.593,3.593 0,1 0,-7.187 0L112.264,29.873l-0.089,-0.128a3.49,3.49 0,0 0,-3 -1.738,3.794 3.794,0 0,0 -3.256,1.905 3.467,3.467 0,0 0,0.084 3.542l7.858,15.049a1.813,1.813 0,0 0,1.605 0.98L126.532,49.483A1.821,1.821 0,0 0,128.341 47.773l0.257,-4.192C131.343,39.356 132.251,36.331 131.726,33.208ZM127.108,43.161 L126.831,47.678a0.305,0.305 0,0 1,-0.3 0.288L115.467,47.966a0.306,0.306 0,0 1,-0.265 -0.168L107.324,32.716a2.1,2.1 0,0 1,1.848 -3.2,1.976 1.976,0 0,1 1.721,1.032l1.008,1.548a1,1 0,0 0,0.846 0.464A1.016,1.016 0,0 0,113.781 31.543L113.781,20.837a2.08,2.08 0,1 1,4.161 0v6.087a0.3,0.3 0,0 0,0.389 0.285,4 4,0 0,1 1.2,-0.2 2.763,2.763 0,0 1,2.5 1.489,0.318 0.318,0 0,0 0.273,0.159 0.306,0.306 0,0 0,0.106 -0.019,3.912 3.912,0 0,1 1.317,-0.244 2.705,2.705 0,0 1,2.363 1.311,0.934 0.934,0 0,0 0.731,0.414 3.559,3.559 0,0 1,3.409 3.337c0.456,2.718 -0.33,5.4 -3.077,9.556A0.3,0.3 0,0 0,127.107 43.161Z"/>
</vector>
29 changes: 29 additions & 0 deletions folioreader/res/drawable/ic_tooltip22.xml

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions folioreader/res/drawable/ic_tooltip3.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion folioreader/res/layout/folio_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:layout_height="match_parent"
tools:context="com.folioreader.ui.activity.FolioActivity"
tools:menu="@menu/menu_main">
<com.folioreader.ui.view.DirectionalViewpager
<com.folioreader.ui.view.DirectionalViewpager
android:id="@+id/folioPageViewPager"
android:layout_width="0dp"
android:layout_height="0dp"
Expand Down
27 changes: 27 additions & 0 deletions folioreader/res/layout/login.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
xmlns:app="http://schemas.android.com/apk/res-auto"

>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<ImageView
android:id="@+id/btn_tooltip1"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
app:srcCompat="@drawable/ic_tooltip3"
android:layout_width="180dp"
android:layout_height="90dp"
/>
</LinearLayout>

</LinearLayout>
21 changes: 21 additions & 0 deletions folioreader/res/layout/tooltip_second.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:windowFullscreen="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:gravity="right"

>
<ImageView
android:id="@+id/btn_tooltip2"
app:srcCompat="@drawable/ic_tooltip22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>

</LinearLayout>
7 changes: 7 additions & 0 deletions folioreader/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,11 @@
<item name="android:statusBarColor" tools:targetApi="lollipop">@color/black</item>
</style>

<style name="AlertDialogCustom" parent="@android:style/Theme.Material.Dialog">
<item name="android:textColor">@android:color/black</item>
<item name="android:textStyle">bold</item>
<item name="android:headerDividersEnabled">true</item>
<item name="android:background">@android:color/transparent</item>
</style>

</resources>
8 changes: 8 additions & 0 deletions folioreader/src/main/java/com/folioreader/FolioReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class FolioReader {
public static final String EXTRA_BOOK_ID = "com.folioreader.extra.BOOK_ID";
public static final String EXTRA_BOOK_ID2 = "com.folioreader.extra.BOOK_ID2";
public static final String EXTRA_LINK = "com.folioreader.extra.LINK";
public static final String EXTRA_STATUS_TOOLTIP = "com.folioreader.extra.STATUS_TOOLTIP";
public static final String EXTRA_READ_LOCATOR = "com.folioreader.extra.READ_LOCATOR";
public static final String EXTRA_PORT_NUMBER = "com.folioreader.extra.PORT_NUMBER";
public static final String EXTRA_PORT_NUMBER2 = "com.folioreader.extra.PORT_NUMBER2";
Expand All @@ -55,6 +56,7 @@ public class FolioReader {
private OnClosedListener onClosedListener;
private ReadLocator readLocator;
private String link;
private String statusTooltip;

@Nullable
public Retrofit retrofit;
Expand Down Expand Up @@ -171,6 +173,7 @@ private Intent getIntentFromUrl(String assetOrSdcardPath, int rawId) {
intent.putExtra(EXTRA_PORT_NUMBER, portNumber);
intent.putExtra(FolioActivity.EXTRA_READ_LOCATOR, (Parcelable) readLocator);
intent.putExtra(EXTRA_LINK, this.link);
intent.putExtra(EXTRA_STATUS_TOOLTIP, this.statusTooltip);

if (rawId != 0) {
intent.putExtra(FolioActivity.INTENT_EPUB_SOURCE_PATH, rawId);
Expand Down Expand Up @@ -255,6 +258,11 @@ public FolioReader setLinkPurchase(String linkPurchase) {
return singleton;
}

public FolioReader setStatusTooltip(String statusTooltip) {
this.statusTooltip = statusTooltip;
return singleton;
}

public void saveReceivedHighLights(List<HighLight> highlights,
OnSaveHighlight onSaveHighlight) {
new SaveReceivedHighlightTask(onSaveHighlight, highlights).execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
private var handler: Handler? = null

private var currentChapterIndex: Int = 0
private var tooltipStep: Int = 5
private var mFolioPageFragmentAdapter: FolioPageFragmentAdapter? = null
private var entryReadLocator: ReadLocator? = null
private var lastReadLocator: ReadLocator? = null
Expand All @@ -102,6 +103,8 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle

private var mBookId: String? = null
private var mLink: String? = null
private var mStatusTooltip: String? = null
private var statusTooltip: String? = ""
private var mEpubFilePath: String? = null
private var mEpubSourceType: EpubSourceType? = null
private var mEpubRawId = 0
Expand Down Expand Up @@ -276,6 +279,7 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle

mBookId = intent.getStringExtra(FolioReader.EXTRA_BOOK_ID)
mLink = intent.getStringExtra(FolioReader.EXTRA_LINK)
mStatusTooltip = intent.getStringExtra(FolioReader.EXTRA_STATUS_TOOLTIP)

mEpubSourceType = intent.extras!!.getSerializable(FolioActivity.INTENT_EPUB_SOURCE_TYPE) as EpubSourceType
if (mEpubSourceType == EpubSourceType.RAW) {
Expand Down Expand Up @@ -575,6 +579,15 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
return streamerUri.toString()
}

override fun getTooltipStatus(): String {
return statusTooltip.toString()
}

override fun setTooltipStatus() {
statusTooltip = "done"
}


override fun onDirectionChange(newDirection: Config.Direction) {
Log.v(LOG_TAG, "-> onDirectionChange")

Expand All @@ -587,7 +600,7 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
mFolioPageViewPager!!.setDirection(newDirection)
mFolioPageFragmentAdapter = FolioPageFragmentAdapter(
supportFragmentManager,
spine, bookFileName, mBookId, mLink
spine, bookFileName, mBookId, mLink, mStatusTooltip
)
mFolioPageViewPager!!.adapter = mFolioPageFragmentAdapter
mFolioPageViewPager!!.currentItem = currentChapterIndex
Expand Down Expand Up @@ -762,7 +775,7 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
}
}

private fun hideSystemUI() {
override fun hideSystemUI() {
Log.v(LOG_TAG, "-> hideSystemUI")

if (Build.VERSION.SDK_INT >= 16) {
Expand Down Expand Up @@ -883,6 +896,14 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
return currentChapterIndex
}

override fun getTooltipStep(): String {
return tooltipStep.toString()
}

override fun setTooltipStep() {
tooltipStep = 10
}

private fun configFolio() {

mFolioPageViewPager = findViewById(R.id.folioPageViewPager)
Expand Down Expand Up @@ -931,7 +952,7 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
mFolioPageViewPager!!.setDirection(direction)
mFolioPageFragmentAdapter = FolioPageFragmentAdapter(
supportFragmentManager,
spine, bookFileName, mBookId, mLink
spine, bookFileName, mBookId, mLink, mStatusTooltip
)
mFolioPageViewPager!!.adapter = mFolioPageFragmentAdapter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ public interface FolioActivityCallback {

int getCurrentChapterIndex();

String getTooltipStep();

void setTooltipStep();

ReadLocator getEntryReadLocator();

boolean goToChapter(String href);
Expand All @@ -23,6 +27,8 @@ public interface FolioActivityCallback {

void toggleSystemUI();

void hideSystemUI();

void setDayMode();

void setNightMode();
Expand All @@ -36,4 +42,7 @@ public interface FolioActivityCallback {
WeakReference<FolioActivity> getActivity();

String getStreamerUrl();
String getTooltipStatus();

void setTooltipStatus();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ public class FolioPageFragmentAdapter extends FragmentStatePagerAdapter {
private String mEpubFileName;
private String mBookId;
private String mLink;
private String mStatusTooltip;
private ArrayList<Fragment> fragments;
private ArrayList<Fragment.SavedState> savedStateList;

public FolioPageFragmentAdapter(FragmentManager fragmentManager, List<Link> spineReferences,
String epubFileName, String bookId, String link) {
String epubFileName, String bookId, String link, String statusTooltip) {
super(fragmentManager);
Log.d("----->", statusTooltip);
Log.d("----- epubFileName >", epubFileName);

this.mSpineReferences = spineReferences;
this.mEpubFileName = epubFileName;
this.mBookId = bookId;
this.mLink = link;
this.mStatusTooltip = statusTooltip;
fragments = new ArrayList<>(Arrays.asList(new Fragment[mSpineReferences.size()]));
}

Expand All @@ -60,7 +65,7 @@ public Fragment getItem(int position) {
Fragment fragment = fragments.get(position);
if (fragment == null) {
fragment = FolioPageFragment.newInstance(position,
mEpubFileName, mSpineReferences.get(position), mBookId, mLink);
mEpubFileName, mSpineReferences.get(position), mBookId, mLink, mStatusTooltip);
fragments.set(position, fragment);
}
return fragment;
Expand Down
Loading

0 comments on commit 7f2d300

Please sign in to comment.