Compare commits

..
5 Commits
Author SHA1 Message Date
seven332 fad9e3ccc0 1.0.8 2016-05-02 19:38:21 +08:00
seven332 5aa56e0237 Add detail size options
Large for 480dp width
Small for 320dp width
2016-05-02 19:36:41 +08:00
seven332 d4d4ba8c75 Use TuXiang library
Make GLRootView extends com.hippo.tuxiang.GLSurfaceView
2016-05-02 18:56:56 +08:00
seven332 2a324c4d89 Call GLRootView onPause and onResume 2016-05-02 13:20:35 +08:00
seven332 e6638b6f56 Remove ANRWatchDog 2016-05-01 23:20:00 +08:00
18 changed files with 100 additions and 2000 deletions

No files matched your search

+3 -3
View File
@@ -8,8 +8,8 @@ android {
applicationId "com.hippo.ehviewer"
minSdkVersion 14
targetSdkVersion 23
versionCode 60
versionName "1.0.7"
versionCode 61
versionName "1.0.8"
vectorDrawables.useSupportLibrary = true
resConfigs "zh", "zh-rCN", "zh-rHK", "zh-rTW"
@@ -59,7 +59,6 @@ dependencies {
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
compile 'com.github.anrwatchdog:anrwatchdog:1.2.0'
compile 'com.github.seven332:beerbelly:0.1.2'
compile 'com.github.seven332:conaco:0.1.3-eh'
compile 'com.github.seven332:easyrecyclerview:0.1.0'
@@ -69,6 +68,7 @@ dependencies {
compile 'com.github.seven332:refreshlayout:0.1.0'
compile 'com.github.seven332:ripple:0.1.1'
compile 'com.github.seven332:streampipe:0.1.0'
compile 'com.github.seven332:tuxiang:0.1.0'
compile 'com.github.seven332:unifile:0.1.3'
compile 'com.github.seven332:yorozuya-collect:0.1.2'
compile 'com.github.seven332:yorozuya-thread:0.1.0'
@@ -28,8 +28,6 @@ import android.support.annotation.Nullable;
import android.support.v4.util.LruCache;
import android.util.Log;
import com.github.anrwatchdog.ANRError;
import com.github.anrwatchdog.ANRWatchDog;
import com.hippo.beerbelly.SimpleDiskCache;
import com.hippo.conaco.Conaco;
import com.hippo.ehviewer.client.EhClient;
@@ -93,15 +91,6 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(this);
// Start anr watch dog
new ANRWatchDog().setANRListener(new ANRWatchDog.ANRListener() {
@Override
public void onAppNotResponding(ANRError error) {
// Throw RuntimeException, let crash handler do it
throw new RuntimeException(error.getCause());
}
}).start();
super.onCreate();
GetText.initialize(this);
@@ -265,9 +254,9 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
EhApplication application = ((EhApplication) context.getApplicationContext());
if (application.mOkHttpClient == null) {
application.mOkHttpClient = new OkHttpClient.Builder()
.connectTimeout(15, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS)
.writeTimeout(15, TimeUnit.SECONDS)
.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(10, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
.cookieJar(getEhCookieStore(application))
.build();
}
@@ -255,6 +255,24 @@ public class Settings {
return getIntFromStr(KEY_LIST_MODE, DEFAULT_LIST_MODE);
}
public static final String KEY_DETAIL_SIZE = "detail_size";
private static final int DEFAULT_DETAIL_SIZE = 0;
public static int getDetailSize() {
return getIntFromStr(KEY_DETAIL_SIZE, DEFAULT_DETAIL_SIZE);
}
@DimenRes
public static int getDetailSizeResId() {
switch (getDetailSize()) {
default:
case 0:
return R.dimen.gallery_list_column_width_long;
case 1:
return R.dimen.gallery_list_column_width_short;
}
}
public static final String KEY_THUMB_SIZE = "thumb_size";
private static final int DEFAULT_THUMB_SIZE = 1;
@@ -99,6 +99,8 @@ public class GalleryActivity extends EhActivity
private GalleryInfo mGalleryInfo;
private int mPage;
@Nullable
private GLRootView mGLRootView;
@Nullable
private GalleryView mGalleryView;
@@ -259,9 +261,9 @@ public class GalleryActivity extends EhActivity
mGalleryProvider.start();
setContentView(R.layout.activity_gallery);
GLRootView glRootView = (GLRootView) ViewUtils.$$(this, R.id.gl_root_view);
mGalleryProvider.setGLRoot(glRootView);
mUploader = new ImageTexture.Uploader(glRootView);
mGLRootView = (GLRootView) ViewUtils.$$(this, R.id.gl_root_view);
mGalleryProvider.setGLRoot(mGLRootView);
mUploader = new ImageTexture.Uploader(mGLRootView);
int startPage;
if (savedInstanceState == null) {
@@ -273,7 +275,7 @@ public class GalleryActivity extends EhActivity
mGalleryView = new GalleryView(this, new GalleryAdapter(), this,
Settings.getReadingDirection(), Settings.getPageScaling(),
Settings.getStartPosition(), startPage);
glRootView.setContentPane(mGalleryView);
mGLRootView.setContentPane(mGalleryView);
// System UI helper
if (Settings.getReadingFullscreen()) {
@@ -343,6 +345,7 @@ public class GalleryActivity extends EhActivity
@Override
protected void onDestroy() {
super.onDestroy();
mGLRootView = null;
mGalleryView = null;
if (mUploader != null) {
mUploader.clear();
@@ -366,6 +369,24 @@ public class GalleryActivity extends EhActivity
SimpleHandler.getInstance().removeCallbacks(mHideSliderRunnable);
}
@Override
protected void onPause() {
super.onPause();
if (mGLRootView != null) {
mGLRootView.onPause();
}
}
@Override
protected void onResume() {
super.onResume();
if (mGLRootView != null) {
mGLRootView.onResume();
}
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
@@ -34,10 +34,12 @@ public class EhFragment extends PreferenceFragment
Preference gallerySite = findPreference(Settings.KEY_GALLERY_SITE);
Preference listMode = findPreference(Settings.KEY_LIST_MODE);
Preference detailSize = findPreference(Settings.KEY_DETAIL_SIZE);
Preference thumbSize = findPreference(Settings.KEY_THUMB_SIZE);
gallerySite.setOnPreferenceChangeListener(this);
listMode.setOnPreferenceChangeListener(this);
detailSize.setOnPreferenceChangeListener(this);
thumbSize.setOnPreferenceChangeListener(this);
}
@@ -50,6 +52,8 @@ public class EhFragment extends PreferenceFragment
} else if (Settings.KEY_LIST_MODE.equals(key)) {
getActivity().setResult(Activity.RESULT_OK);
return true;
} else if (Settings.KEY_DETAIL_SIZE.equals(key)) {
getActivity().setResult(Activity.RESULT_OK);
} else if (Settings.KEY_THUMB_SIZE.equals(key)) {
getActivity().setResult(Activity.RESULT_OK);
}
@@ -297,7 +297,7 @@ public class DownloadsScene extends ToolbarScene
mAdapter.setHasStableIds(true);
mRecyclerView.setAdapter(mAdapter);
mLayoutManager = new AutoStaggeredGridLayoutManager(0, StaggeredGridLayoutManager.VERTICAL);
mLayoutManager.setColumnSize(resources.getDimensionPixelOffset(R.dimen.gallery_list_column_width));
mLayoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
@@ -95,7 +95,7 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
switch (type) {
default:
case GalleryAdapter.TYPE_LIST: {
int columnWidth = mResources.getDimensionPixelOffset(R.dimen.gallery_list_column_width);
int columnWidth = mResources.getDimensionPixelOffset(Settings.getDetailSizeResId());
mLayoutManager.setColumnSize(columnWidth);
mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
if (null != mGirdDecoration) {
@@ -48,6 +48,7 @@ import com.hippo.easyrecyclerview.HandlerDrawable;
import com.hippo.easyrecyclerview.MarginItemDecoration;
import com.hippo.ehviewer.EhDB;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.ehviewer.client.EhCacheKeyFactory;
import com.hippo.ehviewer.client.EhUtils;
import com.hippo.ehviewer.client.data.GalleryInfo;
@@ -122,7 +123,7 @@ public class HistoryScene extends ToolbarScene
mRecyclerView.setItemAnimator(animator);
AutoStaggeredGridLayoutManager layoutManager = new AutoStaggeredGridLayoutManager(
0, StaggeredGridLayoutManager.VERTICAL);
layoutManager.setColumnSize(resources.getDimensionPixelOffset(R.dimen.gallery_list_column_width));
layoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
layoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
@@ -1,65 +0,0 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hippo.gl.view;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGL11;
final class EGLError {
private EGLError() {}
private static String getHex(int value) {
return "0x" + Integer.toHexString(value);
}
public static String getErrorString(int error) {
switch (error) {
case EGL10.EGL_SUCCESS:
return "EGL_SUCCESS";
case EGL10.EGL_NOT_INITIALIZED:
return "EGL_NOT_INITIALIZED";
case EGL10.EGL_BAD_ACCESS:
return "EGL_BAD_ACCESS";
case EGL10.EGL_BAD_ALLOC:
return "EGL_BAD_ALLOC";
case EGL10.EGL_BAD_ATTRIBUTE:
return "EGL_BAD_ATTRIBUTE";
case EGL10.EGL_BAD_CONFIG:
return "EGL_BAD_CONFIG";
case EGL10.EGL_BAD_CONTEXT:
return "EGL_BAD_CONTEXT";
case EGL10.EGL_BAD_CURRENT_SURFACE:
return "EGL_BAD_CURRENT_SURFACE";
case EGL10.EGL_BAD_DISPLAY:
return "EGL_BAD_DISPLAY";
case EGL10.EGL_BAD_MATCH:
return "EGL_BAD_MATCH";
case EGL10.EGL_BAD_NATIVE_PIXMAP:
return "EGL_BAD_NATIVE_PIXMAP";
case EGL10.EGL_BAD_NATIVE_WINDOW:
return "EGL_BAD_NATIVE_WINDOW";
case EGL10.EGL_BAD_PARAMETER:
return "EGL_BAD_PARAMETER";
case EGL10.EGL_BAD_SURFACE:
return "EGL_BAD_SURFACE";
case EGL11.EGL_CONTEXT_LOST:
return "EGL_CONTEXT_LOST";
default:
return getHex(error);
}
}
}
@@ -39,6 +39,9 @@ import com.hippo.gl.glrenderer.UploadedTexture;
import com.hippo.gl.util.ApiHelper;
import com.hippo.gl.util.GalleryUtils;
import com.hippo.gl.util.MotionEventHelper;
import com.hippo.tuxiang.BestConfigChooser;
import com.hippo.tuxiang.GLSurfaceView;
import com.hippo.tuxiang.Renderer;
import com.hippo.yorozuya.AssertUtils;
import java.util.ArrayDeque;
@@ -46,9 +49,7 @@ import java.util.ArrayList;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL11;
@@ -62,7 +63,7 @@ import javax.microedition.khronos.opengles.GL11;
// (2) The public methods of CameraHeadUpDisplay
// (3) The overridden methods in GLRootView.
public class GLRootView extends GLSurfaceView
implements GLSurfaceView.Renderer, GLRoot {
implements Renderer, GLRoot {
private static final String TAG = "GLRootView";
private static final boolean DEBUG_FPS = false;
@@ -630,111 +631,4 @@ public class GLRootView extends GLSurfaceView
super.finalize();
}
}
private static abstract class BaseConfigChooser implements EGLConfigChooser {
public BaseConfigChooser(int[] configSpec) {
mConfigSpec = filterConfigSpec(configSpec);
}
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
int[] num_config = new int[1];
if (!egl.eglChooseConfig(display, mConfigSpec, null, 0,
num_config)) {
throw new IllegalArgumentException("eglChooseConfig failed");
}
int numConfigs = num_config[0];
if (numConfigs <= 0) {
throw new IllegalArgumentException(
"No configs match configSpec");
}
EGLConfig[] configs = new EGLConfig[numConfigs];
if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs,
num_config)) {
throw new IllegalArgumentException("eglChooseConfig#2 failed");
}
EGLConfig config = chooseConfig(egl, display, configs);
if (config == null) {
throw new IllegalArgumentException("No config chosen");
}
return config;
}
abstract EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
EGLConfig[] configs);
protected int[] mConfigSpec;
private int[] filterConfigSpec(int[] configSpec) {
/* We know none of the subclasses define EGL_RENDERABLE_TYPE.
* And we know the configSpec is well formed.
*/
int len = configSpec.length;
int[] newConfigSpec = new int[len + 2];
System.arraycopy(configSpec, 0, newConfigSpec, 0, len-1);
newConfigSpec[len-1] = EGL10.EGL_RENDERABLE_TYPE;
newConfigSpec[len] = 4; // EGL14.EGL_OPENGL_ES2_BIT; /* EGL_OPENGL_ES2_BIT */
newConfigSpec[len+1] = EGL10.EGL_NONE;
return newConfigSpec;
}
}
private static class BestConfigChooser extends BaseConfigChooser {
private final int[] mValue = new int[1];
public BestConfigChooser() {
super(new int[] {
EGL10.EGL_DEPTH_SIZE, 0,
EGL10.EGL_STENCIL_SIZE, 0,
EGL10.EGL_NONE});
}
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
EGLConfig[] configs) {
// Use score to avoid "No config chosen"
int configIndex = 0;
int maxScore = 0;
for (int i = 0, n = configs.length; i < n; i++) {
EGLConfig config = configs[i];
int redSize = findConfigAttrib(egl, display, config,
EGL10.EGL_RED_SIZE, 0);
int greenSize = findConfigAttrib(egl, display, config,
EGL10.EGL_GREEN_SIZE, 0);
int blueSize = findConfigAttrib(egl, display, config,
EGL10.EGL_BLUE_SIZE, 0);
int alphaSize = findConfigAttrib(egl, display, config,
EGL10.EGL_ALPHA_SIZE, 0);
int sampleBuffers = findConfigAttrib(egl, display, config,
EGL10.EGL_SAMPLE_BUFFERS, 0);
int samples = findConfigAttrib(egl, display, config,
EGL10.EGL_SAMPLES, 0);
int score = redSize + greenSize + blueSize + alphaSize +
sampleBuffers + samples;
if (score > maxScore) {
maxScore = score;
configIndex = i;
}
}
return configs[configIndex];
}
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
EGLConfig config, int attribute, int defaultValue) {
if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
return mValue[0];
}
return defaultValue;
}
}
}
File diff suppressed because it is too large. Load diff
@@ -361,6 +361,9 @@
<string name="settings_eh_list_mode">列表模式</string>
<string name="settings_eh_list_mode_detail">详情</string>
<string name="settings_eh_list_mode_thumb">缩略图</string>
<string name="settings_eh_detail_size">详情大小</string>
<string name="settings_eh_detail_size_long">长</string>
<string name="settings_eh_detail_size_short">短</string>
<string name="settings_eh_thumb_size">缩略图大小</string>
<string name="settings_eh_thumb_size_large">大</string>
<string name="settings_eh_thumb_size_middle">中</string>
@@ -361,6 +361,9 @@
<string name="settings_eh_list_mode">列表模式</string>
<string name="settings_eh_list_mode_detail">詳情</string>
<string name="settings_eh_list_mode_thumb">縮略圖</string>
<string name="settings_eh_detail_size">詳情大小</string>
<string name="settings_eh_detail_size_long">長</string>
<string name="settings_eh_detail_size_short">短</string>
<string name="settings_eh_thumb_size">縮略圖大小</string>
<string name="settings_eh_thumb_size_large">大</string>
<string name="settings_eh_thumb_size_middle">中</string>
@@ -361,6 +361,9 @@
<string name="settings_eh_list_mode">列表模式</string>
<string name="settings_eh_list_mode_detail">詳情</string>
<string name="settings_eh_list_mode_thumb">縮圖</string>
<string name="settings_eh_detail_size">詳情大小</string>
<string name="settings_eh_detail_size_long">長</string>
<string name="settings_eh_detail_size_short">短</string>
<string name="settings_eh_thumb_size">縮圖大小</string>
<string name="settings_eh_thumb_size_large">大</string>
<string name="settings_eh_thumb_size_middle">中</string>
+16 -6
View File
@@ -37,12 +37,28 @@
<item>1</item>
</string-array>
<string-array name="detail_size_entries" translatable="false">
<item>@string/settings_eh_detail_size_long</item>
<item>@string/settings_eh_detail_size_short</item>
</string-array>
<string-array name="detail_size_entry_values" translatable="false">
<item>0</item>
<item>1</item>
</string-array>
<string-array name="thumb_size_entries" translatable="false">
<item>@string/settings_eh_thumb_size_large</item>
<item>@string/settings_eh_thumb_size_middle</item>
<item>@string/settings_eh_thumb_size_small</item>
</string-array>
<string-array name="thumb_size_entry_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string-array name="thumb_resolution_entries" translatable="false">
<item>@string/settings_eh_thumb_resolution_auto</item>
<item>250x</item>
@@ -55,12 +71,6 @@
<item>2</item>
</string-array>
<string-array name="thumb_size_entry_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string-array name="search_min_rating">
<item>@string/star_2</item>
<item>@string/star_3</item>
+3 -1
View File
@@ -59,7 +59,9 @@
<dimen name="gallery_padding_top_search_bar">64dp</dimen>
<dimen name="gallery_padding_bottom_fab">80dp</dimen>
<dimen name="gallery_list_column_width">480dp</dimen>
<dimen name="gallery_list_column_width_long">480dp</dimen>
<dimen name="gallery_list_column_width_short">320dp</dimen>
<dimen name="gallery_grid_column_width_large">160dp</dimen>
<dimen name="gallery_grid_column_width_middle">120dp</dimen>
<dimen name="gallery_grid_column_width_small">80dp</dimen>
+3
View File
@@ -403,6 +403,9 @@
<string name="settings_eh_list_mode">List mode</string>
<string name="settings_eh_list_mode_detail">Detail</string>
<string name="settings_eh_list_mode_thumb">Thumb</string>
<string name="settings_eh_detail_size">Detail size</string>
<string name="settings_eh_detail_size_long">Long</string>
<string name="settings_eh_detail_size_short">Short</string>
<string name="settings_eh_thumb_size">Thumb size</string>
<string name="settings_eh_thumb_size_large">Large</string>
<string name="settings_eh_thumb_size_middle">Middle</string>
+8
View File
@@ -40,6 +40,14 @@
app:entryValues="@array/list_mode_entry_values"
android:defaultValue="0"/>
<com.hippo.preference.ListPreference
android:key="detail_size"
android:title="@string/settings_eh_detail_size"
android:summary="%s"
app:entries="@array/detail_size_entries"
app:entryValues="@array/detail_size_entry_values"
android:defaultValue="0"/>
<com.hippo.preference.ListPreference
android:key="thumb_size"
android:title="@string/settings_eh_thumb_size"