diff options
author | Andrew Dolgov <[email protected]> | 2012-12-01 15:36:09 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-12-01 15:36:09 +0400 |
commit | 8245607f3d6f055bb3feec288777f4216196b366 (patch) | |
tree | ddf0a9fa4784b1e9be13dcf8fce44297b83da5ec | |
parent | 022b17a79b02d1199b4c6fe3b98d98ad3c2ef1e7 (diff) | |
parent | f00ef55ad2687d0dd783c9b0b7a29d125ce13684 (diff) |
Merge branch 'master' of github.com:gothfox/Tiny-Comics-Reader
Conflicts:
res/values/strings.xml
-rw-r--r-- | AndroidManifest.xml | 4 | ||||
-rw-r--r-- | res/drawable-hdpi/badimage.png | bin | 0 -> 14350 bytes | |||
-rw-r--r-- | res/drawable/s_badimage.svg | 88 | ||||
-rw-r--r-- | res/menu/activity_view_comic.xml | 6 | ||||
-rw-r--r-- | res/values/strings.xml | 7 | ||||
-rw-r--r-- | src/it/sephiroth/android/library/imagezoom/ImageViewTouch.java | 6 | ||||
-rw-r--r-- | src/org/fox/ttcomics/ComicFragment.java | 35 | ||||
-rw-r--r-- | src/org/fox/ttcomics/ComicPager.java | 12 | ||||
-rw-r--r-- | src/org/fox/ttcomics/CommonActivity.java | 6 | ||||
-rw-r--r-- | src/org/fox/ttcomics/ViewComicActivity.java | 29 | ||||
-rw-r--r-- | src/org/fox/ttcomics/ViewPager.java | 39 |
11 files changed, 179 insertions, 53 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 0cdd97b..2be143d 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,7 +1,7 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttcomics"
- android:versionCode="25"
- android:versionName="1.0.13" >
+ android:versionCode="26"
+ android:versionName="1.0.14" >
<uses-sdk
android:minSdkVersion="8"
diff --git a/res/drawable-hdpi/badimage.png b/res/drawable-hdpi/badimage.png Binary files differnew file mode 100644 index 0000000..bc71802 --- /dev/null +++ b/res/drawable-hdpi/badimage.png diff --git a/res/drawable/s_badimage.svg b/res/drawable/s_badimage.svg new file mode 100644 index 0000000..8c61713 --- /dev/null +++ b/res/drawable/s_badimage.svg @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="64px" + height="64px" + id="svg2985" + version="1.1" + inkscape:version="0.48.0 r9654" + inkscape:export-filename="C:\Users\fox\workspace\org.fox.ttcomics\res\drawable\badimage.png" + inkscape:export-xdpi="800" + inkscape:export-ydpi="800" + sodipodi:docname="s_badimage.svg"> + <defs + id="defs2987" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="5.5" + inkscape:cx="3.6363636" + inkscape:cy="32" + inkscape:current-layer="layer1" + showgrid="true" + inkscape:document-units="px" + inkscape:grid-bbox="true" + inkscape:window-width="1600" + inkscape:window-height="1138" + inkscape:window-x="-8" + inkscape:window-y="-8" + inkscape:window-maximized="1" /> + <metadata + id="metadata2990"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + id="layer1" + inkscape:label="Layer 1" + inkscape:groupmode="layer"> + <path + sodipodi:type="star" + style="opacity:0.25000000000000000;fill:#909090;fill-opacity:1;stroke:none" + id="path2999" + sodipodi:sides="3" + sodipodi:cx="33.090908" + sodipodi:cy="8.363636" + sodipodi:r1="33.989788" + sodipodi:r2="16.994896" + sodipodi:arg1="2.6179939" + sodipodi:arg2="3.6651914" + inkscape:flatsided="true" + inkscape:rounded="0" + inkscape:randomized="0" + d="M 3.6548878,25.358529 33.090909,-25.626152 62.526928,25.358531 z" + inkscape:transform-center-y="-8.4974474" + transform="translate(-1.0909077,32.133811)" /> + <text + xml:space="preserve" + style="font-size:23.69292450000000000px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Sans" + x="21.763916" + y="50.357021" + id="text2993" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan2995" + x="21.763916" + y="50.357021" + style="font-size:33.17009354000000300px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#ffffff;fill-opacity:1;font-family:Arial;-inkscape-font-specification:Arial Bold">?</tspan></text> + </g> +</svg> diff --git a/res/menu/activity_view_comic.xml b/res/menu/activity_view_comic.xml index 898dc01..ebef4e1 100644 --- a/res/menu/activity_view_comic.xml +++ b/res/menu/activity_view_comic.xml @@ -7,7 +7,7 @@ <item android:id="@+id/menu_go_location" android:title="@string/menu_go_location" android:showAsAction="never" /> - + <item android:id="@+id/menu_sync_location" android:title="@string/menu_sync_location" android:showAsAction="never" /> @@ -16,5 +16,9 @@ android:title="@string/menu_share" android:icon="@android:drawable/ic_menu_share" android:showAsAction="ifRoom" /> + + <item android:id="@+id/menu_toggle_orientation_lock" + android:title="@string/menu_toggle_orientation_lock" + android:showAsAction="never" /> </menu> diff --git a/res/values/strings.xml b/res/values/strings.xml index c8324e8..dfb6ba0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -2,10 +2,10 @@ <string name="app_name">Pow! Comics Reader</string>
<string name="hello_world">Hello world!</string>
- <string name="menu_settings">Preferences</string>
+ <string name="menu_settings">Settings</string>
<string name="menu_go_location">Go to</string>
<string name="title_activity_main">Pow! Comics Reader</string>
- <string name="title_activity_preferences">Preferences</string>
+ <string name="title_activity_preferences">Settings</string>
<string name="prefs_comics_directory">Comics directory</string>
<string name="prefs_general">General</string>
<string name="prefs_dim_status_bar">Dim status bar</string>
@@ -15,7 +15,7 @@ <string name="tab_unread">Unread</string>
<string name="tab_read">Finished</string>
<string name="dialog_need_prefs_message">Please configure base directory for comics archives.</string>
- <string name="dialog_need_prefs_preferences">Preferences</string>
+ <string name="dialog_need_prefs_preferences">Settings</string>
<string name="cancel">Cancel</string>
<string name="comics_directory_default">/mnt/sdcard/Comics</string>
<string name="prefs_reading">Reading</string>
@@ -56,4 +56,5 @@ <string name="prefs_enable_rar_summary">Using RAR (CBR) files is not recommended because of underlying RAR library issues. Enable at your own risk.</string>
<string name="file_unread">Unread (%1$d pages)</string>
<string name="file_finished">Finished</string>
+ <string name="menu_toggle_orientation_lock">(Un)lock orientation</string>
</resources>
\ No newline at end of file diff --git a/src/it/sephiroth/android/library/imagezoom/ImageViewTouch.java b/src/it/sephiroth/android/library/imagezoom/ImageViewTouch.java index f3399fd..73392b1 100644 --- a/src/it/sephiroth/android/library/imagezoom/ImageViewTouch.java +++ b/src/it/sephiroth/android/library/imagezoom/ImageViewTouch.java @@ -7,7 +7,6 @@ import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.Log; -import android.view.Display; import android.view.GestureDetector; import android.view.GestureDetector.OnGestureListener; import android.view.MotionEvent; @@ -34,7 +33,7 @@ public class ImageViewTouch extends ImageViewTouchBase { private OnImageViewTouchDoubleTapListener doubleTapListener; public interface OnScaleChangedListener { - public void onScaleChanged(float scale, boolean widthFits); + public void onScaleChanged(float scale); } protected OnScaleChangedListener mScaleChangedListener; @@ -121,8 +120,7 @@ public class ImageViewTouch extends ImageViewTouchBase { if ( !mScaleDetector.isInProgress() ) mCurrentScaleFactor = scale; if (mScaleChangedListener != null) { - RectF bitmapRect = getBitmapRect(); - mScaleChangedListener.onScaleChanged(mCurrentScaleFactor, getWidth() >= (bitmapRect.right - bitmapRect.left)); + mScaleChangedListener.onScaleChanged(mCurrentScaleFactor); } } diff --git a/src/org/fox/ttcomics/ComicFragment.java b/src/org/fox/ttcomics/ComicFragment.java index da34ce4..21c50fd 100644 --- a/src/org/fox/ttcomics/ComicFragment.java +++ b/src/org/fox/ttcomics/ComicFragment.java @@ -102,6 +102,7 @@ public class ComicFragment extends Fragment { image.setImageBitmap(result);
} else {
activity.toast(R.string.error_loading_image);
+ image.setImageResource(R.drawable.badimage);
}
}
}
@@ -111,12 +112,12 @@ public class ComicFragment extends Fragment { image.setOnScaleChangedListener(new ImageViewTouch.OnScaleChangedListener() {
@Override
- public void onScaleChanged(float scale, boolean widthFits) {
- ViewPager pager = (ViewPager) getActivity().findViewById(R.id.comics_pager);
+ public void onScaleChanged(float scale) {
+ /* ViewPager pager = (ViewPager) getActivity().findViewById(R.id.comics_pager);
if (pager != null) {
pager.setPagingEnabled(widthFits);
- }
+ } */
}
});
@@ -154,11 +155,33 @@ public class ComicFragment extends Fragment { }
private void onLeftSideTapped() {
- m_activity.selectPreviousComic();
+ ImageViewTouch image = (ImageViewTouch) getView().findViewById(R.id.comic_image);
+
+ if (image != null) {
+ boolean atLeftEdge = !image.canScroll(1);
+
+ if (atLeftEdge) {
+ m_activity.selectPreviousComic();
+ }
+ }
}
-
+
+ public boolean canScroll(int direction) {
+ ImageViewTouch image = (ImageViewTouch) getView().findViewById(R.id.comic_image);
+
+ return image.canScroll(direction);
+ }
+
private void onRightSideTapped() {
- m_activity.selectNextComic();
+ ImageViewTouch image = (ImageViewTouch) getView().findViewById(R.id.comic_image);
+
+ if (image != null) {
+ boolean atRightEdge = !image.canScroll(-1);
+
+ if (atRightEdge) {
+ m_activity.selectNextComic();
+ }
+ }
}
@Override
diff --git a/src/org/fox/ttcomics/ComicPager.java b/src/org/fox/ttcomics/ComicPager.java index ab40936..934aaa7 100644 --- a/src/org/fox/ttcomics/ComicPager.java +++ b/src/org/fox/ttcomics/ComicPager.java @@ -164,17 +164,5 @@ public class ComicPager extends Fragment { out.putString("fileName", m_fileName);
}
-
- public boolean isPagingEnabled() {
-
- ViewPager pager = (ViewPager) getView().findViewById(R.id.comics_pager);
-
- if (pager != null) {
- return pager.isPagingEnabled();
- }
-
- return false;
- }
-
}
diff --git a/src/org/fox/ttcomics/CommonActivity.java b/src/org/fox/ttcomics/CommonActivity.java index 873ccd3..d535fe6 100644 --- a/src/org/fox/ttcomics/CommonActivity.java +++ b/src/org/fox/ttcomics/CommonActivity.java @@ -492,7 +492,7 @@ public class CommonActivity extends FragmentActivity { public void selectPreviousComic() {
ComicPager frag = (ComicPager) getSupportFragmentManager().findFragmentByTag(FRAG_COMICS_PAGER);
- if (frag != null && frag.isAdded() && frag.getPosition() > 0 && frag.isPagingEnabled()) {
+ if (frag != null && frag.isAdded() && frag.getPosition() > 0) {
frag.setCurrentItem(frag.getPosition() - 1);
}
}
@@ -500,11 +500,9 @@ public class CommonActivity extends FragmentActivity { public void selectNextComic() {
ComicPager frag = (ComicPager) getSupportFragmentManager().findFragmentByTag(FRAG_COMICS_PAGER);
- if (frag != null && frag.isAdded() && frag.getPosition() < frag.getCount()-1 && frag.isPagingEnabled()) {
+ if (frag != null && frag.isAdded() && frag.getPosition() < frag.getCount()-1) {
frag.setCurrentItem(frag.getPosition() + 1);
}
-
-
}
public void cleanupSqliteCache(String baseDir) {
diff --git a/src/org/fox/ttcomics/ViewComicActivity.java b/src/org/fox/ttcomics/ViewComicActivity.java index 48bfa9e..95917c5 100644 --- a/src/org/fox/ttcomics/ViewComicActivity.java +++ b/src/org/fox/ttcomics/ViewComicActivity.java @@ -12,6 +12,8 @@ import android.content.BroadcastReceiver; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
@@ -33,6 +35,7 @@ public class ViewComicActivity extends CommonActivity { private String m_fileName;
private String m_tmpFileName;
private boolean m_fullScreen = false;
+ private boolean m_orientationLocked = false;
@SuppressLint("NewApi")
@Override
@@ -54,8 +57,11 @@ public class ViewComicActivity extends CommonActivity { } else {
m_fileName = savedInstanceState.getString("fileName");
m_tmpFileName = savedInstanceState.getString("tmpFileName");
+ m_orientationLocked = savedInstanceState.getBoolean("orientationLocked");
}
+ setOrientationLock(m_orientationLocked);
+
if (!isCompatMode()) {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
@@ -91,6 +97,7 @@ public class ViewComicActivity extends CommonActivity { out.putString("fileName", m_fileName);
out.putString("tmpFileName", m_tmpFileName);
+ out.putBoolean("orientationLocked", m_orientationLocked);
}
@Override
@@ -103,7 +110,7 @@ public class ViewComicActivity extends CommonActivity { // upload progress
if (m_prefs.getBoolean("use_position_sync", false) && m_syncClient.hasOwner()) {
- toast(R.string.sync_uploading);
+ //toast(R.string.sync_uploading);
m_syncClient.setPosition(sha1(new File(m_fileName).getName()), getLastPosition(m_fileName));
}
}
@@ -162,10 +169,30 @@ public class ViewComicActivity extends CommonActivity { super.onActivityResult(requestCode, resultCode, intent);
}
+ private void setOrientationLock(boolean locked) {
+ if (locked) {
+ int currentOrientation = getResources().getConfiguration().orientation;
+
+ if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
+ }
+ else {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
+ }
+ } else {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
+ }
+
+ m_orientationLocked = locked;
+ }
+
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_share:
shareComic();
+ return true;
+ case R.id.menu_toggle_orientation_lock:
+ setOrientationLock(!m_orientationLocked);
return true;
case R.id.menu_sync_location:
m_syncClient.getPosition(sha1(new File(m_fileName).getName()), new SyncClient.PositionReceivedListener() {
diff --git a/src/org/fox/ttcomics/ViewPager.java b/src/org/fox/ttcomics/ViewPager.java index c5d2f13..6d9c68f 100644 --- a/src/org/fox/ttcomics/ViewPager.java +++ b/src/org/fox/ttcomics/ViewPager.java @@ -1,43 +1,42 @@ package org.fox.ttcomics;
+import it.sephiroth.android.library.imagezoom.ImageViewTouch;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
+import android.view.View;
public class ViewPager extends android.support.v4.view.ViewPager {
private final String TAG = this.getClass().getSimpleName();
- private boolean enabled;
public ViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
- this.enabled = true;
}
@Override
+ protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
+ if (v instanceof ImageViewTouch) {
+ ImageViewTouch ivt = (ImageViewTouch) v;
+ try {
+ return ivt.canScroll(dx);
+ } catch (NullPointerException e) {
+ // bad image, etc
+ return false;
+ }
+ } else {
+ return super.canScroll(v, checkV, dx, x, y);
+ }
+ }
+
+ @Override
public boolean onTouchEvent(MotionEvent event) {
- if (this.enabled) {
- return super.onTouchEvent(event);
- }
-
- return false;
+ return super.onTouchEvent(event);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
- if (this.enabled) {
- return super.onInterceptTouchEvent(event);
- }
-
- return false;
- }
-
- public void setPagingEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- public boolean isPagingEnabled() {
- return this.enabled;
+ return super.onInterceptTouchEvent(event);
}
}
\ No newline at end of file |