Skip to content

Commit

Permalink
Merge pull request #150 from codetoart/master
Browse files Browse the repository at this point in the history
Bug Fixes
  • Loading branch information
Mahavir Jain authored Dec 8, 2017
2 parents 68fe717 + f539591 commit c134b2d
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 98 deletions.
2 changes: 1 addition & 1 deletion folioreader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ dependencies {
compile "org.readium:r2-parser:$R2_STREAMER_VERSION"
compile "org.readium:r2-server:$R2_STREAMER_VERSION"

compile 'com.squareup:otto:1.3.8'
compile 'org.greenrobot:eventbus:3.1.1'
}

apply from: '../folioreader/bintray/installv1.gradle'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.folioreader.model.event;

/**
* Created by gautam on 8/12/17.
*/

public class UpdateHighlightEvent {
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ public class ContentHighlightActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_content_highlight);
getSupportActionBar().hide();
if (getSupportActionBar() != null) {
getSupportActionBar().hide();
}
mConfig = AppUtil.getSavedConfig(this);
mIsNightMode = mConfig.isNightMode();
mIsNightMode = mConfig != null && mConfig.isNightMode();
initViews();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import com.folioreader.R;
import com.folioreader.model.HighlightImpl;
import com.folioreader.model.event.AnchorIdEvent;
import com.folioreader.model.event.BusOwner;
import com.folioreader.model.event.MediaOverlayHighlightStyleEvent;
import com.folioreader.model.event.MediaOverlayPlayPauseEvent;
import com.folioreader.model.event.MediaOverlaySpeedEvent;
Expand All @@ -62,9 +61,8 @@
import com.folioreader.view.DirectionalViewpager;
import com.folioreader.view.ObservableWebView;
import com.folioreader.view.StyleableTextView;
import com.squareup.otto.Bus;
import com.squareup.otto.ThreadEnforcer;

import org.greenrobot.eventbus.EventBus;
import org.readium.r2_streamer.model.container.Container;
import org.readium.r2_streamer.model.container.EpubContainer;
import org.readium.r2_streamer.model.publication.EpubPublication;
Expand All @@ -86,7 +84,6 @@ public class FolioActivity
implements FolioPageFragment.FolioPageFragmentCallback,
ObservableWebView.ToolBarListener,
ConfigBottomSheetDialogFragment.ConfigDialogCallback,
BusOwner,
MainMvpView {

private static final String TAG = "FolioActivity";
Expand All @@ -107,12 +104,6 @@ public enum EpubSourceType {
private String bookFileName;
private static final String HIGHLIGHT_ITEM = "highlight_item";

private final Bus BUS = new Bus(ThreadEnforcer.MAIN);
@Override
public Bus getBus() {
return BUS;
}

public boolean mIsActionBarVisible;
private DirectionalViewpager mFolioPageViewPager;
private Toolbar mToolbar;
Expand Down Expand Up @@ -164,9 +155,6 @@ protected void onCreate(Bundle savedInstanceState) {

initColors();

BUS.register(this);


if (ContextCompat.checkSelfPermission(FolioActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(FolioActivity.this, Constants.getWriteExternalStoragePerms(), Constants.WRITE_EXTERNAL_STORAGE_REQUEST);
} else {
Expand Down Expand Up @@ -273,15 +261,15 @@ public void onOrientationChange(int orentation) {
}

private void configFolio() {
mFolioPageViewPager = (DirectionalViewpager) findViewById(R.id.folioPageViewPager);
mFolioPageViewPager = findViewById(R.id.folioPageViewPager);
mFolioPageViewPager.setOnPageChangeListener(new DirectionalViewpager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}

@Override
public void onPageSelected(int position) {
BUS.post(new MediaOverlayPlayPauseEvent(mSpineReferenceList.get(mChapterPosition).href, false, true));
EventBus.getDefault().post(new MediaOverlayPlayPauseEvent(mSpineReferenceList.get(mChapterPosition).href, false, true));
mPlayPauseBtn.setImageDrawable(ContextCompat.getDrawable(FolioActivity.this, R.drawable.play_icon));
mChapterPosition = position;
}
Expand Down Expand Up @@ -402,15 +390,15 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mChapterPosition = mSpineReferenceList.indexOf(spine);
mFolioPageViewPager.setCurrentItem(mChapterPosition);
title.setText(data.getStringExtra(Constants.BOOK_TITLE));
BUS.post(new AnchorIdEvent(selectedChapterHref));
EventBus.getDefault().post(new AnchorIdEvent(selectedChapterHref));
break;
}
}
} else if (type.equals(HIGHLIGHT_SELECTED)) {
HighlightImpl highlightImpl = data.getParcelableExtra(HIGHLIGHT_ITEM);
int position = highlightImpl.getPageNumber();
mFolioPageViewPager.setCurrentItem(position);
BUS.post(new WebViewPosition(mSpineReferenceList.get(mChapterPosition).href, highlightImpl.getRangy()));
EventBus.getDefault().post(new WebViewPosition(mSpineReferenceList.get(mChapterPosition).href, highlightImpl.getRangy()));
}
}
}
Expand All @@ -421,7 +409,6 @@ protected void onDestroy() {
if (mEpubServer != null) {
mEpubServer.stop();
}
BUS.unregister(this);
}

public int getmChapterPosition() {
Expand Down Expand Up @@ -473,18 +460,18 @@ private void setConfig() {
private RelativeLayout shade;

private void initAudioView() {
mHalfSpeed = (StyleableTextView) findViewById(R.id.btn_half_speed);
mOneSpeed = (StyleableTextView) findViewById(R.id.btn_one_x_speed);
mTwoSpeed = (StyleableTextView) findViewById(R.id.btn_twox_speed);
audioContainer = (RelativeLayout) findViewById(R.id.container);
shade = (RelativeLayout) findViewById(R.id.shade);
mOneAndHalfSpeed = (StyleableTextView) findViewById(R.id.btn_one_and_half_speed);
mPlayPauseBtn = (ImageButton) findViewById(R.id.play_button);
mPreviousButton = (ImageButton) findViewById(R.id.prev_button);
mNextButton = (ImageButton) findViewById(R.id.next_button);
mBackgroundColorStyle = (StyleableTextView) findViewById(R.id.btn_backcolor_style);
mUnderlineStyle = (StyleableTextView) findViewById(R.id.btn_text_undeline_style);
mTextColorStyle = (StyleableTextView) findViewById(R.id.btn_text_color_style);
mHalfSpeed = findViewById(R.id.btn_half_speed);
mOneSpeed = findViewById(R.id.btn_one_x_speed);
mTwoSpeed = findViewById(R.id.btn_twox_speed);
audioContainer = findViewById(R.id.container);
shade = findViewById(R.id.shade);
mOneAndHalfSpeed = findViewById(R.id.btn_one_and_half_speed);
mPlayPauseBtn = findViewById(R.id.play_button);
mPreviousButton = findViewById(R.id.prev_button);
mNextButton = findViewById(R.id.next_button);
mBackgroundColorStyle = findViewById(R.id.btn_backcolor_style);
mUnderlineStyle = findViewById(R.id.btn_text_undeline_style);
mTextColorStyle = findViewById(R.id.btn_text_color_style);
mIsSpeaking = false;

final Context mContext = mHalfSpeed.getContext();
Expand Down Expand Up @@ -519,11 +506,11 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
if (mIsSpeaking) {
BUS.post(new MediaOverlayPlayPauseEvent(mSpineReferenceList.get(mChapterPosition).href, false, false));
EventBus.getDefault().post(new MediaOverlayPlayPauseEvent(mSpineReferenceList.get(mChapterPosition).href, false, false));
mPlayPauseBtn.setImageDrawable(ContextCompat.getDrawable(FolioActivity.this, R.drawable.play_icon));
UiUtil.setColorToImage(mContext, mConfig.getThemeColor(), mPlayPauseBtn.getDrawable());
} else {
BUS.post(new MediaOverlayPlayPauseEvent(mSpineReferenceList.get(mChapterPosition).href, true, false));
EventBus.getDefault().post(new MediaOverlayPlayPauseEvent(mSpineReferenceList.get(mChapterPosition).href, true, false));
mPlayPauseBtn.setImageDrawable(ContextCompat.getDrawable(FolioActivity.this, R.drawable.pause_btn));
UiUtil.setColorToImage(mContext, mConfig.getThemeColor(), mPlayPauseBtn.getDrawable());
}
Expand All @@ -539,7 +526,7 @@ public void onClick(View v) {
mOneSpeed.setSelected(false);
mOneAndHalfSpeed.setSelected(false);
mTwoSpeed.setSelected(false);
BUS.post(new MediaOverlaySpeedEvent(MediaOverlaySpeedEvent.Speed.HALF));
EventBus.getDefault().post(new MediaOverlaySpeedEvent(MediaOverlaySpeedEvent.Speed.HALF));
}
});

Expand All @@ -551,7 +538,7 @@ public void onClick(View v) {
mOneSpeed.setSelected(true);
mOneAndHalfSpeed.setSelected(false);
mTwoSpeed.setSelected(false);
BUS.post(new MediaOverlaySpeedEvent(MediaOverlaySpeedEvent.Speed.ONE));
EventBus.getDefault().post(new MediaOverlaySpeedEvent(MediaOverlaySpeedEvent.Speed.ONE));
}
});
mOneAndHalfSpeed.setOnClickListener(new View.OnClickListener() {
Expand All @@ -562,7 +549,7 @@ public void onClick(View v) {
mOneSpeed.setSelected(false);
mOneAndHalfSpeed.setSelected(true);
mTwoSpeed.setSelected(false);
BUS.post(new MediaOverlaySpeedEvent(MediaOverlaySpeedEvent.Speed.ONE_HALF));
EventBus.getDefault().post(new MediaOverlaySpeedEvent(MediaOverlaySpeedEvent.Speed.ONE_HALF));
}
});
mTwoSpeed.setOnClickListener(new View.OnClickListener() {
Expand All @@ -572,7 +559,7 @@ public void onClick(View v) {
mOneSpeed.setSelected(false);
mOneAndHalfSpeed.setSelected(false);
mTwoSpeed.setSelected(true);
BUS.post(new MediaOverlaySpeedEvent(MediaOverlaySpeedEvent.Speed.TWO));
EventBus.getDefault().post(new MediaOverlaySpeedEvent(MediaOverlaySpeedEvent.Speed.TWO));
}
});

Expand All @@ -582,7 +569,7 @@ public void onClick(View v) {
mBackgroundColorStyle.setSelected(true);
mUnderlineStyle.setSelected(false);
mTextColorStyle.setSelected(false);
BUS.post(new MediaOverlayHighlightStyleEvent(MediaOverlayHighlightStyleEvent.Style.DEFAULT));
EventBus.getDefault().post(new MediaOverlayHighlightStyleEvent(MediaOverlayHighlightStyleEvent.Style.DEFAULT));
}
});

Expand All @@ -592,7 +579,7 @@ public void onClick(View v) {
mBackgroundColorStyle.setSelected(false);
mUnderlineStyle.setSelected(true);
mTextColorStyle.setSelected(false);
BUS.post(new MediaOverlayHighlightStyleEvent(MediaOverlayHighlightStyleEvent.Style.UNDERLINE));
EventBus.getDefault().post(new MediaOverlayHighlightStyleEvent(MediaOverlayHighlightStyleEvent.Style.UNDERLINE));

}
});
Expand All @@ -603,7 +590,7 @@ public void onClick(View v) {
mBackgroundColorStyle.setSelected(false);
mUnderlineStyle.setSelected(false);
mTextColorStyle.setSelected(true);
BUS.post(new MediaOverlayHighlightStyleEvent(MediaOverlayHighlightStyleEvent.Style.BACKGROUND));
EventBus.getDefault().post(new MediaOverlayHighlightStyleEvent(MediaOverlayHighlightStyleEvent.Style.BACKGROUND));
}
});

Expand Down
Loading

0 comments on commit c134b2d

Please sign in to comment.