Skip to content

Commit

Permalink
Add options to automatically resize images
Browse files Browse the repository at this point in the history
修復看大圖時可能會模糊的問題
  • Loading branch information
Haleydu committed Aug 3, 2020
1 parent e7c4203 commit be2d965
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class PreferenceManager {
public static final String PREF_READER_HIDE_NAV = "pref_reader_hide_nav";
public static final String PREF_READER_BAN_DOUBLE_CLICK = "pref_reader_ban_double_click";
public static final String PREF_READER_PAGING = "pref_reader_paging";
public static final String PREF_READER_CLOSEAUTORESIZEIMAGE = "pref_reader_closeautoresizeimage ";
public static final String PREF_READER_PAGING_REVERSE = "pref_reader_paging_reverse";
public static final String PREF_READER_WHITE_EDGE = "pref_reader_white_edge";
public static final String PREF_READER_WHITE_BACKGROUND = "pref_reader_white_background";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ private void initReaderAdapter() {
mReaderAdapter.setDoubleTap(!mPreference.getBoolean(PreferenceManager.PREF_READER_BAN_DOUBLE_CLICK, false));
mReaderAdapter.setVertical(turn == PreferenceManager.READER_TURN_ATB);
mReaderAdapter.setPaging(mPreference.getBoolean(PreferenceManager.PREF_READER_PAGING, false));
mReaderAdapter.setCloseAutoResizeImage(mPreference.getBoolean(PreferenceManager.PREF_READER_CLOSEAUTORESIZEIMAGE, false));
mReaderAdapter.setPagingReverse(mPreference.getBoolean(PreferenceManager.PREF_READER_PAGING_REVERSE, false));
mReaderAdapter.setWhiteEdge(mPreference.getBoolean(PreferenceManager.PREF_READER_WHITE_EDGE, false));
mReaderAdapter.setBanTurn(mPreference.getBoolean(PreferenceManager.PREF_READER_PAGE_BAN_TURN, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public class SettingsActivity extends BackActivity implements SettingsView {
CheckBoxPreference mReaderBanDoubleClick;
@BindView(R.id.settings_reader_paging)
CheckBoxPreference mReaderPaging;
@BindView(R.id.settings_reader_closeautoresizeimage)
CheckBoxPreference mReaderCloseAutoResizeImage;
@BindView(R.id.settings_reader_paging_reverse)
CheckBoxPreference mReaderPagingReverse;
@BindView(R.id.settings_reader_white_edge)
Expand Down Expand Up @@ -121,6 +123,7 @@ protected void initView() {
mReaderHideNav.bindPreference(PreferenceManager.PREF_READER_HIDE_NAV, false);
mReaderBanDoubleClick.bindPreference(PreferenceManager.PREF_READER_BAN_DOUBLE_CLICK, false);
mReaderPaging.bindPreference(PreferenceManager.PREF_READER_PAGING, false);
mReaderCloseAutoResizeImage.bindPreference(PreferenceManager.PREF_READER_CLOSEAUTORESIZEIMAGE, false);
mReaderPagingReverse.bindPreference(PreferenceManager.PREF_READER_PAGING_REVERSE, false);
mReaderWhiteEdge.bindPreference(PreferenceManager.PREF_READER_WHITE_EDGE, false);
mReaderWhiteBackground.bindPreference(PreferenceManager.PREF_READER_WHITE_BACKGROUND, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilderSupplier;
import com.facebook.drawee.controller.BaseControllerListener;
import com.facebook.drawee.view.DraweeView;
import com.facebook.imagepipeline.common.ResizeOptions;
import com.facebook.imagepipeline.image.ImageInfo;
import com.facebook.imagepipeline.listener.BaseRequestListener;
import com.facebook.imagepipeline.request.ImageRequest;
Expand Down Expand Up @@ -53,8 +54,10 @@ public class ReaderAdapter extends BaseAdapter<ImageUrl> {
private boolean isWhiteEdge;
private boolean isBanTurn;
private boolean isDoubleTap;
private boolean isCloseAutoResizeImage;
private float mScaleFactor;


public ReaderAdapter(Context context, List<ImageUrl> list) {
super(context, list);
}
Expand Down Expand Up @@ -133,11 +136,11 @@ public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatabl
// TODO 切图后可能需要修改图片高度和宽度
MangaPostprocessor processor = new MangaPostprocessor(imageUrl, isPaging, isPagingReverse, isWhiteEdge);
imageRequestBuilder.setPostprocessor(processor);
/* if (isNeedResize(imageUrl)) {
if (!isCloseAutoResizeImage) {
ResizeOptions options = isVertical ? new ResizeOptions(App.mWidthPixels, App.mHeightPixels) :
new ResizeOptions(App.mHeightPixels, App.mWidthPixels);
imageRequestBuilder.setResizeOptions(options);
}*/
}
imageRequestBuilder.setRequestListener(new BaseRequestListener() {
@Override
public void onRequestSuccess(ImageRequest request, String requestId, boolean isPrefetch) {
Expand Down Expand Up @@ -188,6 +191,10 @@ public void setPagingReverse(boolean pagingReverse) {
isPagingReverse = pagingReverse;
}

public void setCloseAutoResizeImage(boolean closeAutoResizeImage) {
isCloseAutoResizeImage = closeAutoResizeImage;
}

public void setWhiteEdge(boolean whiteEdge) {
isWhiteEdge = whiteEdge;
}
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
app:summary="@string/settings_reader_paging_summary"
app:title="@string/settings_reader_paging" />

<com.hiroshi.cimoc.ui.widget.preference.CheckBoxPreference
android:id="@+id/settings_reader_closeautoresizeimage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:summary="@string/settings_reader_closeautoresizeimage_summary"
app:title="@string/settings_reader_closeautoresizeimage" />

<com.hiroshi.cimoc.ui.widget.preference.CheckBoxPreference
android:id="@+id/settings_reader_paging_reverse"
android:layout_width="match_parent"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@
<string name="settings_reader_hide_nav">隱藏導航欄</string>
<string name="settings_reader_hide_nav_summary">閱讀狀態底部隱藏導航欄</string>
<string name="settings_reader_paging">自動切割大圖</string>
<string name="settings_reader_closeautoresizeimage">關閉自動調整圖像大小</string>
<string name="settings_reader_paging_reverse">反向切割大圖</string>
<string name="settings_reader_paging_summary">閱讀狀態自動切割大圖</string>
<string name="settings_reader_closeautoresizeimage_summary">閱讀狀態關閉自動調整圖像大小\n(提升速度,但是圖片可能模糊)</string>
<string name="settings_reader_paging_reverse_summary">交換大圖切割後位置</string>
<string name="settings_reader_scale_factor">雙擊放大百分比</string>
<string name="settings_download">下載設定</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@
<string name="settings_reader_hide_nav">隐藏导航栏</string>
<string name="settings_reader_hide_nav_summary">阅读状态底部隐藏导航栏</string>
<string name="settings_reader_paging">自动切割大图</string>
<string name="settings_reader_closeautoresizeimage">关闭自动调整图像大小</string>
<string name="settings_reader_paging_reverse">反向切割大图</string>
<string name="settings_reader_paging_summary">阅读状态自动切割大图</string>
<string name="settings_reader_closeautoresizeimage_summary">阅读状态关闭自动调整图像大小\n(提升速度,但是图片可能模糊)</string>
<string name="settings_reader_paging_reverse_summary">交换大图切割后位置</string>
<string name="settings_reader_scale_factor">双击放大百分比</string>
<string name="settings_download">下载设置</string>
Expand Down

0 comments on commit be2d965

Please sign in to comment.