Commit 9d9b6fcc authored by Sajal Narang's avatar Sajal Narang

Reformat code

parent 1b9d3f22
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data <data
android:scheme="https"
android:host="insti.app" android:host="insti.app"
android:pathPattern="/org/.*" /> android:pathPattern="/org/.*"
android:scheme="https" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
...@@ -51,9 +51,9 @@ ...@@ -51,9 +51,9 @@
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data <data
android:scheme="https"
android:host="insti.app" android:host="insti.app"
android:pathPattern="/user/.*" /> android:pathPattern="/user/.*"
android:scheme="https" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
...@@ -62,9 +62,9 @@ ...@@ -62,9 +62,9 @@
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data <data
android:scheme="https"
android:host="insti.app" android:host="insti.app"
android:pathPattern="/event/.*" /> android:pathPattern="/event/.*"
android:scheme="https" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
...@@ -73,9 +73,9 @@ ...@@ -73,9 +73,9 @@
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data <data
android:scheme="http"
android:host="insti.app" android:host="insti.app"
android:pathPattern="/org/.*" /> android:pathPattern="/org/.*"
android:scheme="http" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
...@@ -84,9 +84,9 @@ ...@@ -84,9 +84,9 @@
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data <data
android:scheme="http"
android:host="insti.app" android:host="insti.app"
android:pathPattern="/user/.*" /> android:pathPattern="/user/.*"
android:scheme="http" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
...@@ -95,9 +95,9 @@ ...@@ -95,9 +95,9 @@
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data <data
android:scheme="http"
android:host="insti.app" android:host="insti.app"
android:pathPattern="/event/.*" /> android:pathPattern="/event/.*"
android:scheme="http" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
} }
</style> </style>
</head> </head>
......
package app.insti; package app.insti;
import android.util.Log;
import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage; import com.google.firebase.messaging.RemoteMessage;
......
...@@ -22,7 +22,6 @@ import android.view.MotionEvent; ...@@ -22,7 +22,6 @@ import android.view.MotionEvent;
import android.view.ScaleGestureDetector; import android.view.ScaleGestureDetector;
import android.view.View; import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.ImageView;
import android.widget.OverScroller; import android.widget.OverScroller;
import android.widget.Scroller; import android.widget.Scroller;
...@@ -50,42 +49,33 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -50,42 +49,33 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
// saved prior to the screen rotating. // saved prior to the screen rotating.
// //
private Matrix matrix, prevMatrix; private Matrix matrix, prevMatrix;
private static enum State { NONE, DRAG, ZOOM, FLING, ANIMATE_ZOOM };
private State state; private State state;
;
private float minScale; private float minScale;
private float maxScale; private float maxScale;
private float superMinScale; private float superMinScale;
private float superMaxScale; private float superMaxScale;
private float[] m; private float[] m;
private Context context; private Context context;
private Fling fling; private Fling fling;
private ScaleType mScaleType; private ScaleType mScaleType;
private boolean imageRenderedAtLeastOnce; private boolean imageRenderedAtLeastOnce;
private boolean onDrawReady; private boolean onDrawReady;
private ZoomVariables delayedZoomVariables; private ZoomVariables delayedZoomVariables;
// //
// Size of view and previous view size (ie before rotation) // Size of view and previous view size (ie before rotation)
// //
private int viewWidth, viewHeight, prevViewWidth, prevViewHeight; private int viewWidth, viewHeight, prevViewWidth, prevViewHeight;
// //
// Size of image when it is stretched to fit view. Before and After rotation. // Size of image when it is stretched to fit view. Before and After rotation.
// //
private float matchViewWidth, matchViewHeight, prevMatchViewWidth, prevMatchViewHeight; private float matchViewWidth, matchViewHeight, prevMatchViewWidth, prevMatchViewHeight;
private ScaleGestureDetector mScaleDetector; private ScaleGestureDetector mScaleDetector;
private GestureDetector mGestureDetector; private GestureDetector mGestureDetector;
private GestureDetector.OnDoubleTapListener doubleTapListener = null; private GestureDetector.OnDoubleTapListener doubleTapListener = null;
private OnTouchListener userTouchListener = null; private OnTouchListener userTouchListener = null;
private OnTouchImageViewListener touchImageViewListener = null; private OnTouchImageViewListener touchImageViewListener = null;
public TouchImageView(Context context) { public TouchImageView(Context context) {
super(context); super(context);
sharedConstructing(context); sharedConstructing(context);
...@@ -165,6 +155,11 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -165,6 +155,11 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
fitImageToView(); fitImageToView();
} }
@Override
public ScaleType getScaleType() {
return mScaleType;
}
@Override @Override
public void setScaleType(ScaleType type) { public void setScaleType(ScaleType type) {
if (type == ScaleType.FIT_START || type == ScaleType.FIT_END) { if (type == ScaleType.FIT_START || type == ScaleType.FIT_END) {
...@@ -185,13 +180,9 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -185,13 +180,9 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
} }
} }
@Override
public ScaleType getScaleType() {
return mScaleType;
}
/** /**
* Returns false if image is in initial, unzoomed state. False, otherwise. * Returns false if image is in initial, unzoomed state. False, otherwise.
*
* @return true if image is zoomed * @return true if image is zoomed
*/ */
public boolean isZoomed() { public boolean isZoomed() {
...@@ -200,6 +191,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -200,6 +191,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
/** /**
* Return a Rect representing the zoomed image. * Return a Rect representing the zoomed image.
*
* @return rect representing zoomed image * @return rect representing zoomed image
*/ */
public RectF getZoomedRect() { public RectF getZoomedRect() {
...@@ -282,6 +274,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -282,6 +274,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
/** /**
* Get the max zoom multiplier. * Get the max zoom multiplier.
*
* @return max zoom multiplier. * @return max zoom multiplier.
*/ */
public float getMaxZoom() { public float getMaxZoom() {
...@@ -290,6 +283,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -290,6 +283,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
/** /**
* Set the max zoom multiplier. Default value: 3. * Set the max zoom multiplier. Default value: 3.
*
* @param max max zoom multiplier. * @param max max zoom multiplier.
*/ */
public void setMaxZoom(float max) { public void setMaxZoom(float max) {
...@@ -299,23 +293,16 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -299,23 +293,16 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
/** /**
* Get the min zoom multiplier. * Get the min zoom multiplier.
*
* @return min zoom multiplier. * @return min zoom multiplier.
*/ */
public float getMinZoom() { public float getMinZoom() {
return minScale; return minScale;
} }
/**
* Get the current zoom. This is the zoom relative to the initial
* scale, not the original resource.
* @return current zoom multiplier.
*/
public float getCurrentZoom() {
return normalizedScale;
}
/** /**
* Set the min zoom multiplier. Default value: 1. * Set the min zoom multiplier. Default value: 1.
*
* @param min min zoom multiplier. * @param min min zoom multiplier.
*/ */
public void setMinZoom(float min) { public void setMinZoom(float min) {
...@@ -323,6 +310,16 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -323,6 +310,16 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
superMinScale = SUPER_MIN_MULTIPLIER * minScale; superMinScale = SUPER_MIN_MULTIPLIER * minScale;
} }
/**
* Get the current zoom. This is the zoom relative to the initial
* scale, not the original resource.
*
* @return current zoom multiplier.
*/
public float getCurrentZoom() {
return normalizedScale;
}
/** /**
* Reset zoom and translation to initial state. * Reset zoom and translation to initial state.
*/ */
...@@ -333,6 +330,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -333,6 +330,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
/** /**
* Set zoom to the specified scale. Image will be centered by default. * Set zoom to the specified scale. Image will be centered by default.
*
* @param scale * @param scale
*/ */
public void setZoom(float scale) { public void setZoom(float scale) {
...@@ -344,6 +342,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -344,6 +342,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
* (focusX, focusY). These floats range from 0 to 1 and denote the focus point * (focusX, focusY). These floats range from 0 to 1 and denote the focus point
* as a fraction from the left and top of the view. For example, the top left * as a fraction from the left and top of the view. For example, the top left
* corner of the image would be (0, 0). And the bottom right corner would be (1, 1). * corner of the image would be (0, 0). And the bottom right corner would be (1, 1).
*
* @param scale * @param scale
* @param focusX * @param focusX
* @param focusY * @param focusY
...@@ -357,6 +356,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -357,6 +356,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
* (focusX, focusY). These floats range from 0 to 1 and denote the focus point * (focusX, focusY). These floats range from 0 to 1 and denote the focus point
* as a fraction from the left and top of the view. For example, the top left * as a fraction from the left and top of the view. For example, the top left
* corner of the image would be (0, 0). And the bottom right corner would be (1, 1). * corner of the image would be (0, 0). And the bottom right corner would be (1, 1).
*
* @param scale * @param scale
* @param focusX * @param focusX
* @param focusY * @param focusY
...@@ -389,6 +389,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -389,6 +389,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
/** /**
* Set zoom parameters equal to another TouchImageView. Including scale, position, * Set zoom parameters equal to another TouchImageView. Including scale, position,
* and ScaleType. * and ScaleType.
*
* @param TouchImageView * @param TouchImageView
*/ */
public void setZoom(TouchImageView img) { public void setZoom(TouchImageView img) {
...@@ -401,6 +402,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -401,6 +402,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
* in value between 0 and 1 and the focus point is denoted as a fraction from the left * in value between 0 and 1 and the focus point is denoted as a fraction from the left
* and top of the view. For example, the top left corner of the image would be (0, 0). * and top of the view. For example, the top left corner of the image would be (0, 0).
* And the bottom right corner would be (1, 1). * And the bottom right corner would be (1, 1).
*
* @return PointF representing the scroll position of the zoomed image. * @return PointF representing the scroll position of the zoomed image.
*/ */
public PointF getScrollPosition() { public PointF getScrollPosition() {
...@@ -420,6 +422,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -420,6 +422,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
/** /**
* Set the focus point of the zoomed image. The focus points are denoted as a fraction from the * Set the focus point of the zoomed image. The focus points are denoted as a fraction from the
* left and top of the view. The focus points can range in value between 0 and 1. * left and top of the view. The focus points can range in value between 0 and 1.
*
* @param focusX * @param focusX
* @param focusY * @param focusY
*/ */
...@@ -730,32 +733,123 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -730,32 +733,123 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
return true; return true;
} }
private void scaleImage(double deltaScale, float focusX, float focusY, boolean stretchImageToSuper) {
float lowerScale, upperScale;
if (stretchImageToSuper) {
lowerScale = superMinScale;
upperScale = superMaxScale;
} else {
lowerScale = minScale;
upperScale = maxScale;
}
float origScale = normalizedScale;
normalizedScale *= deltaScale;
if (normalizedScale > upperScale) {
normalizedScale = upperScale;
deltaScale = upperScale / origScale;
} else if (normalizedScale < lowerScale) {
normalizedScale = lowerScale;
deltaScale = lowerScale / origScale;
}
matrix.postScale((float) deltaScale, (float) deltaScale, focusX, focusY);
fixScaleTrans();
}
/**
* This function will transform the coordinates in the touch event to the coordinate
* system of the drawable that the imageview contain
*
* @param x x-coordinate of touch event
* @param y y-coordinate of touch event
* @param clipToBitmap Touch event may occur within view, but outside image content. True, to clip return value
* to the bounds of the bitmap size.
* @return Coordinates of the point touched, in the coordinate system of the original drawable.
*/
private PointF transformCoordTouchToBitmap(float x, float y, boolean clipToBitmap) {
matrix.getValues(m);
float origW = getDrawable().getIntrinsicWidth();
float origH = getDrawable().getIntrinsicHeight();
float transX = m[Matrix.MTRANS_X];
float transY = m[Matrix.MTRANS_Y];
float finalX = ((x - transX) * origW) / getImageWidth();
float finalY = ((y - transY) * origH) / getImageHeight();
if (clipToBitmap) {
finalX = Math.min(Math.max(finalX, 0), origW);
finalY = Math.min(Math.max(finalY, 0), origH);
}
return new PointF(finalX, finalY);
}
/**
* Inverse of transformCoordTouchToBitmap. This function will transform the coordinates in the
* drawable's coordinate system to the view's coordinate system.
*
* @param bx x-coordinate in original bitmap coordinate system
* @param by y-coordinate in original bitmap coordinate system
* @return Coordinates of the point in the view's coordinate system.
*/
private PointF transformCoordBitmapToTouch(float bx, float by) {
matrix.getValues(m);
float origW = getDrawable().getIntrinsicWidth();
float origH = getDrawable().getIntrinsicHeight();
float px = bx / origW;
float py = by / origH;
float finalX = m[Matrix.MTRANS_X] + getImageWidth() * px;
float finalY = m[Matrix.MTRANS_Y] + getImageHeight() * py;
return new PointF(finalX, finalY);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void compatPostOnAnimation(Runnable runnable) {
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
postOnAnimation(runnable);
} else {
postDelayed(runnable, 1000 / 60);
}
}
private void printMatrixInfo() {
float[] n = new float[9];
matrix.getValues(n);
Log.d(DEBUG, "Scale: " + n[Matrix.MSCALE_X] + " TransX: " + n[Matrix.MTRANS_X] + " TransY: " + n[Matrix.MTRANS_Y]);
}
private static enum State {NONE, DRAG, ZOOM, FLING, ANIMATE_ZOOM}
public interface OnTouchImageViewListener {
public void onMove();
}
/** /**
* Gesture Listener detects a single click or long click and passes that on * Gesture Listener detects a single click or long click and passes that on
* to the view's listener. * to the view's listener.
* @author Ortiz
* *
* @author Ortiz
*/ */
private class GestureListener extends GestureDetector.SimpleOnGestureListener { private class GestureListener extends GestureDetector.SimpleOnGestureListener {
@Override @Override
public boolean onSingleTapConfirmed(MotionEvent e) public boolean onSingleTapConfirmed(MotionEvent e) {
{ if (doubleTapListener != null) {
if(doubleTapListener != null) {
return doubleTapListener.onSingleTapConfirmed(e); return doubleTapListener.onSingleTapConfirmed(e);
} }
return performClick(); return performClick();
} }
@Override @Override
public void onLongPress(MotionEvent e) public void onLongPress(MotionEvent e) {
{
performLongClick(); performLongClick();
} }
@Override @Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
{
if (fling != null) { if (fling != null) {
// //
// If a previous fling is still active, it should be cancelled so that two flings // If a previous fling is still active, it should be cancelled so that two flings
...@@ -771,7 +865,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -771,7 +865,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
@Override @Override
public boolean onDoubleTap(MotionEvent e) { public boolean onDoubleTap(MotionEvent e) {
boolean consumed = false; boolean consumed = false;
if(doubleTapListener != null) { if (doubleTapListener != null) {
consumed = doubleTapListener.onDoubleTap(e); consumed = doubleTapListener.onDoubleTap(e);
} }
if (state == State.NONE) { if (state == State.NONE) {
...@@ -785,22 +879,18 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -785,22 +879,18 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
@Override @Override
public boolean onDoubleTapEvent(MotionEvent e) { public boolean onDoubleTapEvent(MotionEvent e) {
if(doubleTapListener != null) { if (doubleTapListener != null) {
return doubleTapListener.onDoubleTapEvent(e); return doubleTapListener.onDoubleTapEvent(e);
} }
return false; return false;
} }
} }
public interface OnTouchImageViewListener {
public void onMove();
}
/** /**
* Responsible for all touch events. Handles the heavy lifting of drag and also sends * Responsible for all touch events. Handles the heavy lifting of drag and also sends
* touch events to Scale Detector and Gesture Detector. * touch events to Scale Detector and Gesture Detector.
* @author Ortiz
* *
* @author Ortiz
*/ */
private class PrivateOnTouchListener implements OnTouchListener { private class PrivateOnTouchListener implements OnTouchListener {
...@@ -848,7 +938,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -848,7 +938,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
// //
// User-defined OnTouchListener // User-defined OnTouchListener
// //
if(userTouchListener != null) { if (userTouchListener != null) {
userTouchListener.onTouch(v, event); userTouchListener.onTouch(v, event);
} }
...@@ -868,8 +958,8 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -868,8 +958,8 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
/** /**
* ScaleListener detects user two finger scaling and scales image. * ScaleListener detects user two finger scaling and scales image.
* @author Ortiz
* *
* @author Ortiz
*/ */
private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener { private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
@Override @Override
...@@ -913,42 +1003,16 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -913,42 +1003,16 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
} }
} }
private void scaleImage(double deltaScale, float focusX, float focusY, boolean stretchImageToSuper) {
float lowerScale, upperScale;
if (stretchImageToSuper) {
lowerScale = superMinScale;
upperScale = superMaxScale;
} else {
lowerScale = minScale;
upperScale = maxScale;
}
float origScale = normalizedScale;
normalizedScale *= deltaScale;
if (normalizedScale > upperScale) {
normalizedScale = upperScale;
deltaScale = upperScale / origScale;
} else if (normalizedScale < lowerScale) {
normalizedScale = lowerScale;
deltaScale = lowerScale / origScale;
}
matrix.postScale((float) deltaScale, (float) deltaScale, focusX, focusY);
fixScaleTrans();
}
/** /**
* DoubleTapZoom calls a series of runnables which apply * DoubleTapZoom calls a series of runnables which apply
* an animated zoom in/out graphic to the image. * an animated zoom in/out graphic to the image.
* @author Ortiz
* *
* @author Ortiz
*/ */
private class DoubleTapZoom implements Runnable { private class DoubleTapZoom implements Runnable {
private long startTime;
private static final float ZOOM_TIME = 500; private static final float ZOOM_TIME = 500;
private long startTime;
private float startZoom, targetZoom; private float startZoom, targetZoom;
private float bitmapX, bitmapY; private float bitmapX, bitmapY;
private boolean stretchImageToSuper; private boolean stretchImageToSuper;
...@@ -1008,6 +1072,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -1008,6 +1072,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
* Interpolate between where the image should start and end in order to translate * Interpolate between where the image should start and end in order to translate
* the image so that the point that is touched is what ends up centered at the end * the image so that the point that is touched is what ends up centered at the end
* of the zoom. * of the zoom.
*
* @param t * @param t
*/ */
private void translateImageToCenterTouchPosition(float t) { private void translateImageToCenterTouchPosition(float t) {
...@@ -1019,6 +1084,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -1019,6 +1084,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
/** /**
* Use interpolator to get t * Use interpolator to get t
*
* @return * @return
*/ */
private float interpolate() { private float interpolate() {
...@@ -1031,6 +1097,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -1031,6 +1097,7 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
/** /**
* Interpolate the current targeted zoom and get the delta * Interpolate the current targeted zoom and get the delta
* from the current zoom. * from the current zoom.
*
* @param t * @param t
* @return * @return
*/ */
...@@ -1040,56 +1107,12 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -1040,56 +1107,12 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
} }
} }
/**
* This function will transform the coordinates in the touch event to the coordinate
* system of the drawable that the imageview contain
* @param x x-coordinate of touch event
* @param y y-coordinate of touch event
* @param clipToBitmap Touch event may occur within view, but outside image content. True, to clip return value
* to the bounds of the bitmap size.
* @return Coordinates of the point touched, in the coordinate system of the original drawable.
*/
private PointF transformCoordTouchToBitmap(float x, float y, boolean clipToBitmap) {
matrix.getValues(m);
float origW = getDrawable().getIntrinsicWidth();
float origH = getDrawable().getIntrinsicHeight();
float transX = m[Matrix.MTRANS_X];
float transY = m[Matrix.MTRANS_Y];
float finalX = ((x - transX) * origW) / getImageWidth();
float finalY = ((y - transY) * origH) / getImageHeight();
if (clipToBitmap) {
finalX = Math.min(Math.max(finalX, 0), origW);
finalY = Math.min(Math.max(finalY, 0), origH);
}
return new PointF(finalX , finalY);
}
/**
* Inverse of transformCoordTouchToBitmap. This function will transform the coordinates in the
* drawable's coordinate system to the view's coordinate system.
* @param bx x-coordinate in original bitmap coordinate system
* @param by y-coordinate in original bitmap coordinate system
* @return Coordinates of the point in the view's coordinate system.
*/
private PointF transformCoordBitmapToTouch(float bx, float by) {
matrix.getValues(m);
float origW = getDrawable().getIntrinsicWidth();
float origH = getDrawable().getIntrinsicHeight();
float px = bx / origW;
float py = by / origH;
float finalX = m[Matrix.MTRANS_X] + getImageWidth() * px;
float finalY = m[Matrix.MTRANS_Y] + getImageHeight() * py;
return new PointF(finalX , finalY);
}
/** /**
* Fling launches sequential runnables which apply * Fling launches sequential runnables which apply
* the fling graphic to the image. The values for the translation * the fling graphic to the image. The values for the translation
* are interpolated by the Scroller. * are interpolated by the Scroller.
* @author Ortiz
* *
* @author Ortiz
*/ */
private class Fling implements Runnable { private class Fling implements Runnable {
...@@ -1232,16 +1255,6 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -1232,16 +1255,6 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
} }
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void compatPostOnAnimation(Runnable runnable) {
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
postOnAnimation(runnable);
} else {
postDelayed(runnable, 1000/60);
}
}
private class ZoomVariables { private class ZoomVariables {
public float scale; public float scale;
public float focusX; public float focusX;
...@@ -1255,11 +1268,5 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView ...@@ -1255,11 +1268,5 @@ public class TouchImageView extends android.support.v7.widget.AppCompatImageView
this.scaleType = scaleType; this.scaleType = scaleType;
} }
} }
private void printMatrixInfo() {
float[] n = new float[9];
matrix.getValues(n);
Log.d(DEBUG, "Scale: " + n[Matrix.MSCALE_X] + " TransX: " + n[Matrix.MTRANS_X] + " TransY: " + n[Matrix.MTRANS_Y]);
}
} }
...@@ -33,11 +33,11 @@ public class LoginActivity extends AppCompatActivity { ...@@ -33,11 +33,11 @@ public class LoginActivity extends AppCompatActivity {
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000; private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
private final String redirectUri = "https://redirecturi"; private final String redirectUri = "https://redirecturi";
private final String guestUri = "https://guesturi"; private final String guestUri = "https://guesturi";
private boolean loggingIn = false;
public String authCode = null; public String authCode = null;
public String fcmId = null; public String fcmId = null;
SessionManager session; SessionManager session;
Context mContext = this; Context mContext = this;
private boolean loggingIn = false;
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
@Override @Override
...@@ -70,7 +70,7 @@ public class LoginActivity extends AppCompatActivity { ...@@ -70,7 +70,7 @@ public class LoginActivity extends AppCompatActivity {
webview.loadUrl("file:///android_asset/login.html"); webview.loadUrl("file:///android_asset/login.html");
// Get FCM Id // Get FCM Id
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener( new OnSuccessListener<InstanceIdResult>() { FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {
@Override @Override
public void onSuccess(InstanceIdResult instanceIdResult) { public void onSuccess(InstanceIdResult instanceIdResult) {
fcmId = instanceIdResult.getToken(); fcmId = instanceIdResult.getToken();
......
...@@ -80,6 +80,17 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -80,6 +80,17 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private boolean showNotifications = false; private boolean showNotifications = false;
private BackHandledFragment selectedFragment; private BackHandledFragment selectedFragment;
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
//Find the currently focused view, so we can grab the correct window token from it.
View view = activity.getCurrentFocus();
//If no view currently has focus, create a new one, just so we can grab a window token from it
if (view == null) {
view = new View(activity);
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -140,7 +151,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -140,7 +151,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
int importance = NotificationManager.IMPORTANCE_HIGH; int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel mChannel = null; NotificationChannel mChannel = null;
mChannel = new NotificationChannel(id, name,importance); mChannel = new NotificationChannel(id, name, importance);
// Configure the notification channel. // Configure the notification channel.
mChannel.setDescription(description); mChannel.setDescription(description);
...@@ -227,7 +238,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -227,7 +238,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
} }
/** Update FCM Id and update profile */ /**
* Update FCM Id and update profile
*/
private void updateFCMId() { private void updateFCMId() {
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() { FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {
@Override @Override
...@@ -248,7 +261,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -248,7 +261,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
@Override @Override
public void onFailure(Call<User> call, Throwable t) { } public void onFailure(Call<User> call, Throwable t) {
}
}); });
} }
}); });
...@@ -290,7 +304,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -290,7 +304,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if(selectedFragment == null || !selectedFragment.onBackPressed()) { if (selectedFragment == null || !selectedFragment.onBackPressed()) {
// Selected fragment did not consume the back press event. // Selected fragment did not consume the back press event.
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) { if (drawer.isDrawerOpen(GravityCompat.START)) {
...@@ -310,7 +324,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -310,7 +324,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
return true; return true;
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId(); int id = item.getItemId();
...@@ -509,17 +522,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -509,17 +522,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
return false; return false;
} }
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
//Find the currently focused view, so we can grab the correct window token from it.
View view = activity.getCurrentFocus();
//If no view currently has focus, create a new one, just so we can grab a window token from it
if (view == null) {
view = new View(activity);
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
@Override @Override
public void setSelectedFragment(BackHandledFragment backHandledFragment) { public void setSelectedFragment(BackHandledFragment backHandledFragment) {
this.selectedFragment = backHandledFragment; this.selectedFragment = backHandledFragment;
......
...@@ -51,7 +51,7 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> { ...@@ -51,7 +51,7 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> {
Body body = bodyList.get(position); Body body = bodyList.get(position);
holder.name.setText(body.getBodyName()); holder.name.setText(body.getBodyName());
holder.description.setText(body.getBodyShortDescription()); holder.description.setText(body.getBodyShortDescription());
Picasso.get().load(body.getBodyImageURL()).resize(0,200).into(holder.image); Picasso.get().load(body.getBodyImageURL()).resize(0, 200).into(holder.image);
} }
...@@ -60,6 +60,10 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> { ...@@ -60,6 +60,10 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> {
return bodyList.size(); return bodyList.size();
} }
public void setBodyList(List<Body> bodyList) {
this.bodyList = bodyList;
}
public class ViewHolder extends RecyclerView.ViewHolder { public class ViewHolder extends RecyclerView.ViewHolder {
public TextView name; public TextView name;
public TextView description; public TextView description;
...@@ -72,8 +76,4 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> { ...@@ -72,8 +76,4 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> {
image = (ImageView) itemView.findViewById(R.id.object_picture); image = (ImageView) itemView.findViewById(R.id.object_picture);
} }
} }
public void setBodyList(List<Body> bodyList) {
this.bodyList = bodyList;
}
} }
package app.insti.adapter; package app.insti.adapter;
import android.content.Context; import android.content.Context;
import android.media.Image;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -97,6 +96,10 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -97,6 +96,10 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
return events.size(); return events.size();
} }
public void setEvents(List<Event> events) {
this.events = events;
}
public class ViewHolder extends RecyclerView.ViewHolder { public class ViewHolder extends RecyclerView.ViewHolder {
private ImageView eventPicture; private ImageView eventPicture;
private TextView eventTitle; private TextView eventTitle;
...@@ -112,8 +115,4 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -112,8 +115,4 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
eventBigPicture = (ImageView) itemView.findViewById(R.id.big_object_picture); eventBigPicture = (ImageView) itemView.findViewById(R.id.big_object_picture);
} }
} }
public void setEvents(List<Event> events) {
this.events = events;
}
} }
...@@ -3,7 +3,6 @@ package app.insti.adapter; ...@@ -3,7 +3,6 @@ package app.insti.adapter;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -110,6 +109,15 @@ public class NewsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { ...@@ -110,6 +109,15 @@ public class NewsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
return NewsFragment.showLoader ? (newsArticles.size() + 1) : newsArticles.size(); return NewsFragment.showLoader ? (newsArticles.size() + 1) : newsArticles.size();
} }
public static class ProgressViewHolder extends RecyclerView.ViewHolder {
public ProgressBar progressBar;
public ProgressViewHolder(View v) {
super(v);
progressBar = (ProgressBar) v.findViewById(R.id.blog_load_item);
}
}
public class ViewHolder extends RecyclerView.ViewHolder { public class ViewHolder extends RecyclerView.ViewHolder {
private TextView articleTitle; private TextView articleTitle;
private TextView articleBody; private TextView articleBody;
...@@ -125,12 +133,4 @@ public class NewsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { ...@@ -125,12 +133,4 @@ public class NewsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
articleContent = (TextView) itemView.findViewById(R.id.article_content); articleContent = (TextView) itemView.findViewById(R.id.article_content);
} }
} }
public static class ProgressViewHolder extends RecyclerView.ViewHolder {
public ProgressBar progressBar;
public ProgressViewHolder(View v) {
super(v);
progressBar = (ProgressBar)v.findViewById(R.id.blog_load_item);
}
}
} }
...@@ -2,7 +2,6 @@ package app.insti.adapter; ...@@ -2,7 +2,6 @@ package app.insti.adapter;
import android.content.Context; import android.content.Context;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -25,6 +24,13 @@ import ru.noties.markwon.Markwon; ...@@ -25,6 +24,13 @@ import ru.noties.markwon.Markwon;
public class PlacementBlogAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class PlacementBlogAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final int VIEW_ITEM = 1; private final int VIEW_ITEM = 1;
private final int VIEW_PROG = 0; private final int VIEW_PROG = 0;
private List<PlacementBlogPost> posts;
private Context context;
private ItemClickListener itemClickListener;
public PlacementBlogAdapter(List<PlacementBlogPost> posts, ItemClickListener itemClickListener) {
this.posts = posts;
this.itemClickListener = itemClickListener;
}
public List<PlacementBlogPost> getPosts() { public List<PlacementBlogPost> getPosts() {
return posts; return posts;
...@@ -34,15 +40,6 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<RecyclerView.View ...@@ -34,15 +40,6 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<RecyclerView.View
this.posts = posts; this.posts = posts;
} }
private List<PlacementBlogPost> posts;
private Context context;
private ItemClickListener itemClickListener;
public PlacementBlogAdapter(List<PlacementBlogPost> posts, ItemClickListener itemClickListener) {
this.posts = posts;
this.itemClickListener = itemClickListener;
}
@Override @Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
context = parent.getContext(); context = parent.getContext();
...@@ -101,6 +98,14 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<RecyclerView.View ...@@ -101,6 +98,14 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<RecyclerView.View
} }
} }
public static class ProgressViewHolder extends RecyclerView.ViewHolder {
public ProgressBar progressBar;
public ProgressViewHolder(View v) {
super(v);
progressBar = (ProgressBar) v.findViewById(R.id.blog_load_item);
}
}
public class ViewHolder extends RecyclerView.ViewHolder { public class ViewHolder extends RecyclerView.ViewHolder {
private TextView postTitle; private TextView postTitle;
...@@ -116,13 +121,4 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<RecyclerView.View ...@@ -116,13 +121,4 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<RecyclerView.View
} }
} }
public static class ProgressViewHolder extends RecyclerView.ViewHolder {
public ProgressBar progressBar;
public ProgressViewHolder(View v) {
super(v);
progressBar = (ProgressBar) v.findViewById(R.id.blog_load_item);
}
}
} }
...@@ -2,7 +2,6 @@ package app.insti.adapter; ...@@ -2,7 +2,6 @@ package app.insti.adapter;
import android.content.Context; import android.content.Context;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -100,6 +99,15 @@ public class TrainingBlogAdapter extends RecyclerView.Adapter<RecyclerView.ViewH ...@@ -100,6 +99,15 @@ public class TrainingBlogAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
return TrainingBlogFragment.showLoader ? (posts.size() + 1) : posts.size(); return TrainingBlogFragment.showLoader ? (posts.size() + 1) : posts.size();
} }
public static class ProgressViewHolder extends RecyclerView.ViewHolder {
public ProgressBar progressBar;
public ProgressViewHolder(View v) {
super(v);
progressBar = (ProgressBar) v.findViewById(R.id.blog_load_item);
}
}
public class ViewHolder extends RecyclerView.ViewHolder { public class ViewHolder extends RecyclerView.ViewHolder {
private TextView postTitle; private TextView postTitle;
private TextView postPublished; private TextView postPublished;
...@@ -113,12 +121,4 @@ public class TrainingBlogAdapter extends RecyclerView.Adapter<RecyclerView.ViewH ...@@ -113,12 +121,4 @@ public class TrainingBlogAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
postContent = (TextView) itemView.findViewById(R.id.post_content); postContent = (TextView) itemView.findViewById(R.id.post_content);
} }
} }
public static class ProgressViewHolder extends RecyclerView.ViewHolder {
public ProgressBar progressBar;
public ProgressViewHolder(View v) {
super(v);
progressBar = (ProgressBar)v.findViewById(R.id.blog_load_item);
}
}
} }
...@@ -66,6 +66,10 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> { ...@@ -66,6 +66,10 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> {
return userList.size(); return userList.size();
} }
public void setUserList(List<User> userList) {
this.userList = userList;
}
public class ViewHolder extends RecyclerView.ViewHolder { public class ViewHolder extends RecyclerView.ViewHolder {
public TextView userName; public TextView userName;
public TextView role; public TextView role;
...@@ -78,8 +82,4 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> { ...@@ -78,8 +82,4 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> {
image = (ImageView) itemView.findViewById(R.id.object_picture); image = (ImageView) itemView.findViewById(R.id.object_picture);
} }
} }
public void setUserList(List<User> userList) {
this.userList = userList;
}
} }
package app.insti.api; package app.insti.api;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
......
...@@ -9,16 +9,14 @@ import android.support.v7.widget.Toolbar; ...@@ -9,16 +9,14 @@ import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import de.hdodenhof.circleimageview.CircleImageView;
import app.insti.R; import app.insti.R;
import de.hdodenhof.circleimageview.CircleImageView;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
...@@ -55,7 +53,7 @@ public class AboutFragment extends BaseFragment { ...@@ -55,7 +53,7 @@ public class AboutFragment extends BaseFragment {
put(R.id.cheekuimg, "cheeku.jpg"); put(R.id.cheekuimg, "cheeku.jpg");
put(R.id.sarthakimg, "sarthak.jpg"); put(R.id.sarthakimg, "sarthak.jpg");
put(R.id.sohamimg, "soham.jpg"); put(R.id.sohamimg, "soham.jpg");
put(R.id.maitreyaimg,"maitreya.jpg"); put(R.id.maitreyaimg, "maitreya.jpg");
put(R.id.mrunmayiimg, "mrunmayi.jpg"); put(R.id.mrunmayiimg, "mrunmayi.jpg");
put(R.id.owaisimg, "owais.jpg"); put(R.id.owaisimg, "owais.jpg");
put(R.id.hrushikeshimg, "hrushikesh.jpg"); put(R.id.hrushikeshimg, "hrushikesh.jpg");
...@@ -73,11 +71,12 @@ public class AboutFragment extends BaseFragment { ...@@ -73,11 +71,12 @@ public class AboutFragment extends BaseFragment {
/* Show team pics */ /* Show team pics */
for (final Map.Entry<Integer, String> entry : team.entrySet()) { for (final Map.Entry<Integer, String> entry : team.entrySet()) {
CircleImageView circleImageView = getActivity().findViewById(entry.getKey()); CircleImageView circleImageView = getActivity().findViewById(entry.getKey());
Picasso.get().load("https://insti.app/team-pics/" + entry.getValue()).resize(0,300).into(circleImageView); Picasso.get().load("https://insti.app/team-pics/" + entry.getValue()).resize(0, 300).into(circleImageView);
} }
/* Map TextView ids to links */ /* Map TextView ids to links */
final Map<Integer, String> joinUs = new HashMap<Integer, String>() {{; final Map<Integer, String> joinUs = new HashMap<Integer, String>() {{
;
put(R.id.django, "https://github.com/wncc/IITBapp"); put(R.id.django, "https://github.com/wncc/IITBapp");
put(R.id.android, "https://github.com/wncc/InstiApp"); put(R.id.android, "https://github.com/wncc/InstiApp");
put(R.id.angular, "https://github.com/pulsejet/iitb-app-angular"); put(R.id.angular, "https://github.com/pulsejet/iitb-app-angular");
......
...@@ -25,8 +25,8 @@ import android.widget.Toast; ...@@ -25,8 +25,8 @@ import android.widget.Toast;
import com.google.gson.Gson; import com.google.gson.Gson;
import app.insti.Constants; import app.insti.Constants;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
import app.insti.data.Body; import app.insti.data.Body;
...@@ -37,9 +37,8 @@ import retrofit2.Response; ...@@ -37,9 +37,8 @@ import retrofit2.Response;
public class AddEventFragment extends BaseFragment { public class AddEventFragment extends BaseFragment {
private ProgressDialog progressDialog;
public ValueCallback<Uri[]> uploadMessage; public ValueCallback<Uri[]> uploadMessage;
private ProgressDialog progressDialog;
public AddEventFragment() { public AddEventFragment() {
// Required empty public constructor // Required empty public constructor
...@@ -98,6 +97,7 @@ public class AddEventFragment extends BaseFragment { ...@@ -98,6 +97,7 @@ public class AddEventFragment extends BaseFragment {
webView.setOnTouchListener(new View.OnTouchListener() { webView.setOnTouchListener(new View.OnTouchListener() {
float m_downX; float m_downX;
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
if (event.getPointerCount() > 1) { if (event.getPointerCount() > 1) {
...@@ -128,7 +128,39 @@ public class AddEventFragment extends BaseFragment { ...@@ -128,7 +128,39 @@ public class AddEventFragment extends BaseFragment {
return view; return view;
} }
public class MyWebViewClient extends WebViewClient{ void openEvent(Event event) {
String eventJson = new Gson().toJson(event);
Bundle bundle = getArguments();
if (bundle == null)
bundle = new Bundle();
bundle.putString(Constants.EVENT_JSON, eventJson);
EventFragment eventFragment = new EventFragment();
eventFragment.setArguments(bundle);
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
transaction.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag());
transaction.addToBackStack(eventFragment.getTag()).commit();
}
void openBody(Body body) {
BodyFragment bodyFragment = BodyFragment.newInstance(body);
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
transaction.replace(R.id.framelayout_for_fragment, bodyFragment, bodyFragment.getTag());
transaction.addToBackStack(bodyFragment.getTag()).commit();
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 101) {
if (uploadMessage == null) return;
uploadMessage.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, data));
uploadMessage = null;
}
}
public class MyWebViewClient extends WebViewClient {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
/* Check URL */ /* Check URL */
...@@ -145,7 +177,8 @@ public class AddEventFragment extends BaseFragment { ...@@ -145,7 +177,8 @@ public class AddEventFragment extends BaseFragment {
} }
@Override @Override
public void onFailure(Call<Event> call, Throwable t) { } public void onFailure(Call<Event> call, Throwable t) {
}
}); });
return true; return true;
...@@ -162,7 +195,8 @@ public class AddEventFragment extends BaseFragment { ...@@ -162,7 +195,8 @@ public class AddEventFragment extends BaseFragment {
} }
@Override @Override
public void onFailure(Call<Body> call, Throwable t) { } public void onFailure(Call<Body> call, Throwable t) {
}
}); });
return true; return true;
...@@ -206,36 +240,4 @@ public class AddEventFragment extends BaseFragment { ...@@ -206,36 +240,4 @@ public class AddEventFragment extends BaseFragment {
return true; return true;
} }
} }
void openEvent(Event event) {
String eventJson = new Gson().toJson(event);
Bundle bundle = getArguments();
if (bundle == null)
bundle = new Bundle();
bundle.putString(Constants.EVENT_JSON, eventJson);
EventFragment eventFragment = new EventFragment();
eventFragment.setArguments(bundle);
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
transaction.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag());
transaction.addToBackStack(eventFragment.getTag()).commit();
}
void openBody(Body body) {
BodyFragment bodyFragment = BodyFragment.newInstance(body);
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
transaction.replace(R.id.framelayout_for_fragment, bodyFragment, bodyFragment.getTag());
transaction.addToBackStack(bodyFragment.getTag()).commit();
}
public void onActivityResult(int requestCode, int resultCode, Intent data){
if (requestCode == 101) {
if (uploadMessage == null) return;
uploadMessage.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, data));
uploadMessage = null;
}
}
} }
...@@ -4,12 +4,13 @@ import android.os.Bundle; ...@@ -4,12 +4,13 @@ import android.os.Bundle;
public abstract class BackHandledFragment extends BaseFragment { public abstract class BackHandledFragment extends BaseFragment {
protected BackHandlerInterface backHandlerInterface; protected BackHandlerInterface backHandlerInterface;
public abstract boolean onBackPressed(); public abstract boolean onBackPressed();
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if(!(getActivity() instanceof BackHandlerInterface)) { if (!(getActivity() instanceof BackHandlerInterface)) {
throw new ClassCastException("Hosting activity must implement BackHandlerInterface"); throw new ClassCastException("Hosting activity must implement BackHandlerInterface");
} else { } else {
backHandlerInterface = (BackHandlerInterface) getActivity(); backHandlerInterface = (BackHandlerInterface) getActivity();
......
...@@ -38,9 +38,9 @@ import java.util.List; ...@@ -38,9 +38,9 @@ import java.util.List;
import app.insti.Constants; import app.insti.Constants;
import app.insti.ItemClickListener; import app.insti.ItemClickListener;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.ShareURLMaker; import app.insti.ShareURLMaker;
import app.insti.activity.MainActivity;
import app.insti.adapter.BodyAdapter; import app.insti.adapter.BodyAdapter;
import app.insti.adapter.FeedAdapter; import app.insti.adapter.FeedAdapter;
import app.insti.adapter.UserAdapter; import app.insti.adapter.UserAdapter;
...@@ -93,16 +93,6 @@ public class BodyFragment extends BackHandledFragment { ...@@ -93,16 +93,6 @@ public class BodyFragment extends BackHandledFragment {
// Required empty public constructor // Required empty public constructor
} }
@Override
public boolean onBackPressed() {
if (zoomMode) {
zoomOut(expandedImageView, startBounds, startScaleFinal, bodyPicture);
zoomMode = false;
return true;
}
return false;
}
/** /**
* Use this factory method to create a new instance of * Use this factory method to create a new instance of
* this fragment using the provided parameters. * this fragment using the provided parameters.
...@@ -119,6 +109,16 @@ public class BodyFragment extends BackHandledFragment { ...@@ -119,6 +109,16 @@ public class BodyFragment extends BackHandledFragment {
return fragment; return fragment;
} }
@Override
public boolean onBackPressed() {
if (zoomMode) {
zoomOut(expandedImageView, startBounds, startScaleFinal, bodyPicture);
zoomMode = false;
return true;
}
return false;
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -185,7 +185,7 @@ public class BodyFragment extends BackHandledFragment { ...@@ -185,7 +185,7 @@ public class BodyFragment extends BackHandledFragment {
private void setVisibleIfHasElements(int[] viewIds, List list) { private void setVisibleIfHasElements(int[] viewIds, List list) {
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
for (int viewId: viewIds){ for (int viewId : viewIds) {
getActivity().findViewById(viewId).setVisibility(View.VISIBLE); getActivity().findViewById(viewId).setVisibility(View.VISIBLE);
} }
} }
...@@ -194,7 +194,7 @@ public class BodyFragment extends BackHandledFragment { ...@@ -194,7 +194,7 @@ public class BodyFragment extends BackHandledFragment {
private void displayBody() { private void displayBody() {
/* Skip if we're already destroyed */ /* Skip if we're already destroyed */
if (getActivity() == null || getView() == null) return; if (getActivity() == null || getView() == null) return;
if(!body.equals(min_body)) bodyDisplayed = true; if (!body.equals(min_body)) bodyDisplayed = true;
TextView bodyName = (TextView) getView().findViewById(R.id.body_name); TextView bodyName = (TextView) getView().findViewById(R.id.body_name);
TextView bodyDescription = (TextView) getView().findViewById(R.id.body_description); TextView bodyDescription = (TextView) getView().findViewById(R.id.body_description);
...@@ -408,33 +408,6 @@ public class BodyFragment extends BackHandledFragment { ...@@ -408,33 +408,6 @@ public class BodyFragment extends BackHandledFragment {
return inflater.inflate(R.layout.fragment_body, container, false); return inflater.inflate(R.layout.fragment_body, container, false);
} }
private class updateDbBody extends AsyncTask<Body, Void, Integer> {
@Override
protected Integer doInBackground(Body... body) {
if (appDatabase.dbDao().getBody(body[0].getBodyID()).length > 0) {
appDatabase.dbDao().updateBody(body[0]);
} else {
appDatabase.dbDao().insertBody(body[0]);
}
return 1;
}
}
private class getDbBody extends AsyncTask<String, Void, Body[]> {
@Override
protected Body[] doInBackground(String... id) {
return appDatabase.dbDao().getBody(min_body.getBodyID());
}
@Override
protected void onPostExecute(Body[] result) {
if (result.length > 0 && !bodyDisplayed) {
body = result[0];
displayBody();
}
}
}
private void zoomOut(final ImageView expandedImageView, Rect startBounds, float startScaleFinal, final View thumbView) { private void zoomOut(final ImageView expandedImageView, Rect startBounds, float startScaleFinal, final View thumbView) {
expandedImageView.setBackgroundColor(0x00000000); expandedImageView.setBackgroundColor(0x00000000);
if (mCurrentAnimator != null) { if (mCurrentAnimator != null) {
...@@ -448,7 +421,7 @@ public class BodyFragment extends BackHandledFragment { ...@@ -448,7 +421,7 @@ public class BodyFragment extends BackHandledFragment {
.ofFloat(expandedImageView, View.X, startBounds.left)) .ofFloat(expandedImageView, View.X, startBounds.left))
.with(ObjectAnimator .with(ObjectAnimator
.ofFloat(expandedImageView, .ofFloat(expandedImageView,
View.Y,startBounds.top)) View.Y, startBounds.top))
.with(ObjectAnimator .with(ObjectAnimator
.ofFloat(expandedImageView, .ofFloat(expandedImageView,
View.SCALE_X, startScaleFinal)) View.SCALE_X, startScaleFinal))
...@@ -571,4 +544,31 @@ public class BodyFragment extends BackHandledFragment { ...@@ -571,4 +544,31 @@ public class BodyFragment extends BackHandledFragment {
startScaleFinal = startScale; startScaleFinal = startScale;
zoomMode = true; zoomMode = true;
} }
private class updateDbBody extends AsyncTask<Body, Void, Integer> {
@Override
protected Integer doInBackground(Body... body) {
if (appDatabase.dbDao().getBody(body[0].getBodyID()).length > 0) {
appDatabase.dbDao().updateBody(body[0]);
} else {
appDatabase.dbDao().insertBody(body[0]);
}
return 1;
}
}
private class getDbBody extends AsyncTask<String, Void, Body[]> {
@Override
protected Body[] doInBackground(String... id) {
return appDatabase.dbDao().getBody(min_body.getBodyID());
}
@Override
protected void onPostExecute(Body[] result) {
if (result.length > 0 && !bodyDisplayed) {
body = result[0];
displayBody();
}
}
}
} }
...@@ -29,8 +29,8 @@ import java.util.TimeZone; ...@@ -29,8 +29,8 @@ import java.util.TimeZone;
import app.insti.Constants; import app.insti.Constants;
import app.insti.ItemClickListener; import app.insti.ItemClickListener;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.adapter.FeedAdapter; import app.insti.adapter.FeedAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
...@@ -92,7 +92,7 @@ public class CalendarFragment extends BaseFragment { ...@@ -92,7 +92,7 @@ public class CalendarFragment extends BaseFragment {
((MainActivity) getActivity()).updateFragment(addEventFragment); ((MainActivity) getActivity()).updateFragment(addEventFragment);
} }
}); });
if (((MainActivity)getActivity()).createEventAccess()) { if (((MainActivity) getActivity()).createEventAccess()) {
fab.setVisibility(View.VISIBLE); fab.setVisibility(View.VISIBLE);
} }
......
...@@ -44,9 +44,9 @@ import java.util.List; ...@@ -44,9 +44,9 @@ import java.util.List;
import app.insti.Constants; import app.insti.Constants;
import app.insti.ItemClickListener; import app.insti.ItemClickListener;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.ShareURLMaker; import app.insti.ShareURLMaker;
import app.insti.activity.MainActivity;
import app.insti.adapter.BodyAdapter; import app.insti.adapter.BodyAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
...@@ -92,6 +92,27 @@ public class EventFragment extends BackHandledFragment { ...@@ -92,6 +92,27 @@ public class EventFragment extends BackHandledFragment {
// Required empty public constructor // Required empty public constructor
} }
/**
* Get a spannable with a small count badge to set for an element text
*
* @param text Text to show in the spannable
* @param count integer count to show in the badge
* @return spannable to be used as view.setText(spannable)
*/
static Spannable getCountBadgeSpannable(String text, Integer count) {
// Check for nulls
if (count == null) return new SpannableString(text);
// Make a spannable
String countString = Integer.toString(count);
Spannable spannable = new SpannableString(text + " " + countString);
// Set font face and color of badge
spannable.setSpan(new RelativeSizeSpan(0.75f), text.length(), text.length() + 1 + countString.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
spannable.setSpan(new ForegroundColorSpan(Color.DKGRAY), text.length(), text.length() + 1 + countString.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
return spannable;
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
...@@ -270,28 +291,6 @@ public class EventFragment extends BackHandledFragment { ...@@ -270,28 +291,6 @@ public class EventFragment extends BackHandledFragment {
goingButton.setText(getCountBadgeSpannable("GOING", event.getEventGoingCount())); goingButton.setText(getCountBadgeSpannable("GOING", event.getEventGoingCount()));
} }
/**
* Get a spannable with a small count badge to set for an element text
*
* @param text Text to show in the spannable
* @param count integer count to show in the badge
* @return spannable to be used as view.setText(spannable)
*/
static Spannable getCountBadgeSpannable(String text, Integer count) {
// Check for nulls
if (count == null) return new SpannableString(text);
// Make a spannable
String countString = Integer.toString(count);
Spannable spannable = new SpannableString(text + " " + countString);
// Set font face and color of badge
spannable.setSpan(new RelativeSizeSpan(0.75f), text.length(), text.length() + 1 + countString.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
spannable.setSpan(new ForegroundColorSpan(Color.DKGRAY), text.length(), text.length() + 1 + countString.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
return spannable;
}
View.OnClickListener getUESOnClickListener(final int status) { View.OnClickListener getUESOnClickListener(final int status) {
return new View.OnClickListener() { return new View.OnClickListener() {
@Override @Override
...@@ -304,14 +303,26 @@ public class EventFragment extends BackHandledFragment { ...@@ -304,14 +303,26 @@ public class EventFragment extends BackHandledFragment {
if (response.isSuccessful()) { if (response.isSuccessful()) {
/* TODO: Find a better way to change counts */ /* TODO: Find a better way to change counts */
if (endStatus == 0) { if (endStatus == 0) {
if (event.getEventUserUes() == 1) { event.setEventInterestedCount(event.getEventInterestedCount() - 1); } if (event.getEventUserUes() == 1) {
if (event.getEventUserUes() == 2) { event.setEventGoingCount(event.getEventGoingCount() - 1); } event.setEventInterestedCount(event.getEventInterestedCount() - 1);
}
if (event.getEventUserUes() == 2) {
event.setEventGoingCount(event.getEventGoingCount() - 1);
}
} else if (endStatus == 1) { } else if (endStatus == 1) {
if (event.getEventUserUes() != 1) { event.setEventInterestedCount(event.getEventInterestedCount() + 1); } if (event.getEventUserUes() != 1) {
if (event.getEventUserUes() == 2) { event.setEventGoingCount(event.getEventGoingCount() - 1); } event.setEventInterestedCount(event.getEventInterestedCount() + 1);
}
if (event.getEventUserUes() == 2) {
event.setEventGoingCount(event.getEventGoingCount() - 1);
}
} else if (endStatus == 2) { } else if (endStatus == 2) {
if (event.getEventUserUes() != 2) { event.setEventGoingCount(event.getEventGoingCount() + 1); } if (event.getEventUserUes() != 2) {
if (event.getEventUserUes() == 1) { event.setEventInterestedCount(event.getEventInterestedCount() - 1); } event.setEventGoingCount(event.getEventGoingCount() + 1);
}
if (event.getEventUserUes() == 1) {
event.setEventInterestedCount(event.getEventInterestedCount() - 1);
}
} }
event.setEventUserUes(endStatus); event.setEventUserUes(endStatus);
...@@ -329,14 +340,6 @@ public class EventFragment extends BackHandledFragment { ...@@ -329,14 +340,6 @@ public class EventFragment extends BackHandledFragment {
}; };
} }
private class updateDbEvent extends AsyncTask<Event, Void, Integer> {
@Override
protected Integer doInBackground(Event... event) {
appDatabase.dbDao().updateEvent(event[0]);
return 1;
}
}
private void zoomImageFromThumb(final ImageView thumbView) { private void zoomImageFromThumb(final ImageView thumbView) {
// If there's an animation in progress, cancel it // If there's an animation in progress, cancel it
// immediately and proceed with this one. // immediately and proceed with this one.
...@@ -446,7 +449,7 @@ public class EventFragment extends BackHandledFragment { ...@@ -446,7 +449,7 @@ public class EventFragment extends BackHandledFragment {
.ofFloat(expandedImageView, View.X, startBounds.left)) .ofFloat(expandedImageView, View.X, startBounds.left))
.with(ObjectAnimator .with(ObjectAnimator
.ofFloat(expandedImageView, .ofFloat(expandedImageView,
View.Y,startBounds.top)) View.Y, startBounds.top))
.with(ObjectAnimator .with(ObjectAnimator
.ofFloat(expandedImageView, .ofFloat(expandedImageView,
View.SCALE_X, startScaleFinal)) View.SCALE_X, startScaleFinal))
...@@ -473,4 +476,12 @@ public class EventFragment extends BackHandledFragment { ...@@ -473,4 +476,12 @@ public class EventFragment extends BackHandledFragment {
set.start(); set.start();
mCurrentAnimator = set; mCurrentAnimator = set;
} }
private class updateDbEvent extends AsyncTask<Event, Void, Integer> {
@Override
protected Integer doInBackground(Event... event) {
appDatabase.dbDao().updateEvent(event[0]);
return 1;
}
}
} }
...@@ -21,8 +21,8 @@ import java.util.List; ...@@ -21,8 +21,8 @@ import java.util.List;
import app.insti.Constants; import app.insti.Constants;
import app.insti.ItemClickListener; import app.insti.ItemClickListener;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.adapter.BodyAdapter; import app.insti.adapter.BodyAdapter;
import app.insti.adapter.FeedAdapter; import app.insti.adapter.FeedAdapter;
import app.insti.adapter.UserAdapter; import app.insti.adapter.UserAdapter;
...@@ -60,6 +60,7 @@ public class ExploreFragment extends Fragment { ...@@ -60,6 +60,7 @@ public class ExploreFragment extends Fragment {
/** /**
* Use this factory method to create a new instance of * Use this factory method to create a new instance of
* this fragment. * this fragment.
*
* @return A new instance of fragment ExploreFragment. * @return A new instance of fragment ExploreFragment.
*/ */
// TODO: Rename and change types and number of parameters // TODO: Rename and change types and number of parameters
...@@ -96,7 +97,8 @@ public class ExploreFragment extends Fragment { ...@@ -96,7 +97,8 @@ public class ExploreFragment extends Fragment {
} }
@Override @Override
public void onFailure(Call<List<Body>> call, Throwable t) {} public void onFailure(Call<List<Body>> call, Throwable t) {
}
}); });
} else { } else {
getView().findViewById(R.id.loadingPanel).setVisibility(View.GONE); getView().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
...@@ -106,9 +108,12 @@ public class ExploreFragment extends Fragment { ...@@ -106,9 +108,12 @@ public class ExploreFragment extends Fragment {
final EditText searchEditText = getView().findViewById(R.id.explore_search); final EditText searchEditText = getView().findViewById(R.id.explore_search);
searchEditText.addTextChangedListener(new TextWatcher() { searchEditText.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {} public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) {} public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
......
...@@ -23,8 +23,8 @@ import java.util.List; ...@@ -23,8 +23,8 @@ import java.util.List;
import app.insti.ActivityBuffer; import app.insti.ActivityBuffer;
import app.insti.Constants; import app.insti.Constants;
import app.insti.ItemClickListener; import app.insti.ItemClickListener;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.adapter.FeedAdapter; import app.insti.adapter.FeedAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
...@@ -124,9 +124,9 @@ public class FeedFragment extends BaseFragment { ...@@ -124,9 +124,9 @@ public class FeedFragment extends BaseFragment {
((MainActivity) getActivity()).updateFragment(addEventFragment); ((MainActivity) getActivity()).updateFragment(addEventFragment);
} }
}); });
feedRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener(){ feedRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override @Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy){ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (dy > 0) fab.hide(); if (dy > 0) fab.hide();
else if (dy < 0) fab.show(); else if (dy < 0) fab.show();
} }
......
...@@ -87,8 +87,8 @@ import java.util.Locale; ...@@ -87,8 +87,8 @@ import java.util.Locale;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import app.insti.Constants; import app.insti.Constants;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
import app.insti.data.AppDatabase; import app.insti.data.AppDatabase;
...@@ -102,7 +102,33 @@ import static app.insti.Constants.MY_PERMISSIONS_REQUEST_LOCATION; ...@@ -102,7 +102,33 @@ import static app.insti.Constants.MY_PERMISSIONS_REQUEST_LOCATION;
public class MapFragment extends Fragment implements TextWatcher, public class MapFragment extends Fragment implements TextWatcher,
TextView.OnEditorActionListener, AdapterView.OnItemClickListener, View.OnFocusChangeListener, TextView.OnEditorActionListener, AdapterView.OnItemClickListener, View.OnFocusChangeListener,
View.OnTouchListener, ExpandableListView.OnChildClickListener { View.OnTouchListener, ExpandableListView.OnChildClickListener {
public static final PointF MAP_CENTER = new PointF(2971f, 1744f);
public static final long DURATION_INIT_MAP_ANIM = 500;
public static final String FONT_SEMIBOLD = "rigascreen_bold.ttf";
public static final String FONT_REGULAR = "rigascreen_regular.ttf";
public static final int SOUND_ID_RESULT = 0;
public static final int SOUND_ID_ADD = 1;
public static final int SOUND_ID_REMOVE = 2;
private static final String INSTANCE_CARD_STATE = "instanceCardState";
private static final String INSTANCE_VISIBILITY_INDEX = "instanceVisibilityIndex";
private static MapFragment mainactivity; private static MapFragment mainactivity;
private final String firstStackTag = "FIRST_TAG";
private final int MSG_ANIMATE = 1;
private final int MSG_PLAY_SOUND = 2;
private final int MSG_DISPLAY_MAP = 3;
private final long DELAY_ANIMATE = 150;
private final long DELAY_INIT_LAYOUT = 250;
public LinearLayout newSmallCard;
public ImageView placeColor;
public TextView placeNameTextView;
public TextView placeSubHeadTextView;
public EditText editText;
public HashMap<String, com.mrane.data.Marker> data;
public FragmentTransaction transaction;
public CampusMapView campusMapView;
public ImageButton addMarkerIcon;
public SoundPool soundPool;
public int[] soundPoolIds;
private AppDatabase appDatabase; private AppDatabase appDatabase;
private SettingsManager settingsManager; private SettingsManager settingsManager;
private FuzzySearchAdapter adapter; private FuzzySearchAdapter adapter;
...@@ -110,47 +136,21 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -110,47 +136,21 @@ public class MapFragment extends Fragment implements TextWatcher,
private FragmentManager fragmentManager; private FragmentManager fragmentManager;
private ListFragment listFragment; private ListFragment listFragment;
private Fragment fragment; private Fragment fragment;
public LinearLayout newSmallCard;
public ImageView placeColor;
private RelativeLayout fragmentContainer; private RelativeLayout fragmentContainer;
private View actionBarView; private View actionBarView;
public TextView placeNameTextView;
public TextView placeSubHeadTextView;
public EditText editText;
public HashMap<String, com.mrane.data.Marker> data;
private List<com.mrane.data.Marker> markerlist; private List<com.mrane.data.Marker> markerlist;
public FragmentTransaction transaction;
public CampusMapView campusMapView;
public ImageButton addMarkerIcon;
private DrawerLayout mDrawerLayout; private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mDrawerToggle; private ActionBarDrawerToggle mDrawerToggle;
private SlidingUpPanelLayout slidingLayout; private SlidingUpPanelLayout slidingLayout;
private CardSlideListener cardSlideListener; private CardSlideListener cardSlideListener;
private boolean noFragments = true; private boolean noFragments = true;
private boolean editTextFocused = false; private boolean editTextFocused = false;
private final String firstStackTag = "FIRST_TAG";
private final int MSG_ANIMATE = 1;
private final int MSG_PLAY_SOUND = 2;
private final int MSG_DISPLAY_MAP = 3;
private final long DELAY_ANIMATE = 150;
private final long DELAY_INIT_LAYOUT = 250;
private Toast toast; private Toast toast;
private String message = "Sorry, no such place in our data."; private String message = "Sorry, no such place in our data.";
public static final PointF MAP_CENTER = new PointF(2971f, 1744f);
public static final long DURATION_INIT_MAP_ANIM = 500;
public static final String FONT_SEMIBOLD = "rigascreen_bold.ttf";
public static final String FONT_REGULAR = "rigascreen_regular.ttf";
public static final int SOUND_ID_RESULT = 0;
public static final int SOUND_ID_ADD = 1;
public static final int SOUND_ID_REMOVE = 2;
public SoundPool soundPool;
public int[] soundPoolIds;
private boolean locationsShown = false; private boolean locationsShown = false;
private boolean GPSIsSetup = false; private boolean GPSIsSetup = false;
private boolean followingUser = false; private boolean followingUser = false;
private Marker user = new Marker("You", "", 0, 0, -10, ""); private Marker user = new Marker("You", "", 0, 0, -10, "");
private Handler mHandler = new Handler() { private Handler mHandler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
...@@ -172,6 +172,35 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -172,6 +172,35 @@ public class MapFragment extends Fragment implements TextWatcher,
// Required empty public constructor // Required empty public constructor
} }
public static MapFragment getMainActivity() {
return mainactivity;
}
public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null)
return;
int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(),
View.MeasureSpec.UNSPECIFIED);
int totalHeight = 0;
View view = null;
for (int i = 0; i < listAdapter.getCount(); i++) {
view = listAdapter.getView(i, view, listView);
if (i == 0)
view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth,
RelativeLayout.LayoutParams.WRAP_CONTENT));
view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
totalHeight += view.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight
+ (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
listView.requestLayout();
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
mainactivity = this; mainactivity = this;
...@@ -195,7 +224,7 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -195,7 +224,7 @@ public class MapFragment extends Fragment implements TextWatcher,
/* Initialize */ /* Initialize */
appDatabase = AppDatabase.getAppDatabase(getContext()); appDatabase = AppDatabase.getAppDatabase(getContext());
editText = (EditText)getView().findViewById(R.id.search); editText = (EditText) getView().findViewById(R.id.search);
setFonts(); setFonts();
getAPILocations(); getAPILocations();
...@@ -223,29 +252,6 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -223,29 +252,6 @@ public class MapFragment extends Fragment implements TextWatcher,
}); });
} }
private class updateDatabase extends AsyncTask<List<Venue>, Void, Integer> {
@Override
protected Integer doInBackground(List<Venue>... venues) {
appDatabase.dbDao().deleteVenues();
appDatabase.dbDao().insertVenues(venues[0]);
return 1;
}
}
private class showLocationsFromDB extends AsyncTask<String, Void, List<Venue>> {
@Override
protected List<Venue> doInBackground(String... events) {
return appDatabase.dbDao().getAllVenues();
}
protected void onPostExecute(List<Venue> result) {
if (!locationsShown && result.size() > 0) {
setupWithData(result);
locationsShown = true;
}
}
}
void setupWithData(List<Venue> venues) { void setupWithData(List<Venue> venues) {
if (getView() == null || getActivity() == null) return; if (getView() == null || getActivity() == null) return;
Locations mLocations = new Locations(venues); Locations mLocations = new Locations(venues);
...@@ -302,7 +308,7 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -302,7 +308,7 @@ public class MapFragment extends Fragment implements TextWatcher,
fragmentContainer = (RelativeLayout) getActivity().findViewById(R.id.fragment_container); fragmentContainer = (RelativeLayout) getActivity().findViewById(R.id.fragment_container);
adapter = new FuzzySearchAdapter(getContext(), markerlist); adapter = new FuzzySearchAdapter(getContext(), markerlist);
editText = (EditText)getView().findViewById(R.id.search); editText = (EditText) getView().findViewById(R.id.search);
editText.addTextChangedListener(this); editText.addTextChangedListener(this);
editText.setOnEditorActionListener(this); editText.setOnEditorActionListener(this);
editText.setOnFocusChangeListener(this); editText.setOnFocusChangeListener(this);
...@@ -351,9 +357,9 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -351,9 +357,9 @@ public class MapFragment extends Fragment implements TextWatcher,
} }
private void initShowDefault() { private void initShowDefault() {
String[] keys = { "Convocation Hall", "Hostel 13 House of Titans", String[] keys = {"Convocation Hall", "Hostel 13 House of Titans",
"Hostel 15", "Main Gate no. 2", "Hostel 15", "Main Gate no. 2",
"Market Gate, Y point Gate no. 3", "Lake Side Gate no. 1", }; "Market Gate, Y point Gate no. 3", "Lake Side Gate no. 1",};
for (String key : keys) { for (String key : keys) {
if (data.containsKey(key)) { if (data.containsKey(key)) {
data.get(key).setShowDefault(true); data.get(key).setShowDefault(true);
...@@ -364,13 +370,13 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -364,13 +370,13 @@ public class MapFragment extends Fragment implements TextWatcher,
} }
private void initImageUri() { private void initImageUri() {
String[] keys = { "Convocation Hall", "Guest House/ Jalvihar", String[] keys = {"Convocation Hall", "Guest House/ Jalvihar",
"Guest House/ Vanvihar", "Gulmohar Restaurant", "Hostel 14", "Guest House/ Vanvihar", "Gulmohar Restaurant", "Hostel 14",
"Industrial Design Centre", "Main Building", "Industrial Design Centre", "Main Building",
"Nestle Cafe (Coffee Shack)", "School of Management", "Nestle Cafe (Coffee Shack)", "School of Management",
"Victor Menezes Convention Centre" }; "Victor Menezes Convention Centre"};
String[] uri = { "convo_hall", "jalvihar", "vanvihar", "gulmohar", String[] uri = {"convo_hall", "jalvihar", "vanvihar", "gulmohar",
"h14", "idc", "mainbuilding", "nescafestall", "som", "vmcc" }; "h14", "idc", "mainbuilding", "nescafestall", "som", "vmcc"};
for (int i = 0; i < keys.length; i++) { for (int i = 0; i < keys.length; i++) {
if (data.containsKey(keys[i])) { if (data.containsKey(keys[i])) {
data.get(keys[i]).setImageUri(uri[i]); data.get(keys[i]).setImageUri(uri[i]);
...@@ -462,10 +468,6 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -462,10 +468,6 @@ public class MapFragment extends Fragment implements TextWatcher,
return true; return true;
} }
public static MapFragment getMainActivity() {
return mainactivity;
}
private void putFragment(Fragment tempFragment) { private void putFragment(Fragment tempFragment) {
this.dismissCard(); this.dismissCard();
transaction = fragmentManager.beginTransaction(); transaction = fragmentManager.beginTransaction();
...@@ -595,31 +597,6 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -595,31 +597,6 @@ public class MapFragment extends Fragment implements TextWatcher,
} }
} }
public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null)
return;
int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(),
View.MeasureSpec.UNSPECIFIED);
int totalHeight = 0;
View view = null;
for (int i = 0; i < listAdapter.getCount(); i++) {
view = listAdapter.getView(i, view, listView);
if (i == 0)
view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth,
RelativeLayout.LayoutParams.WRAP_CONTENT));
view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
totalHeight += view.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight
+ (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
listView.requestLayout();
}
private void setChildrenView(LinearLayout parent, Building building) { private void setChildrenView(LinearLayout parent, Building building) {
View childrenView = getLayoutInflater().inflate(R.layout.map_children_view, View childrenView = getLayoutInflater().inflate(R.layout.map_children_view,
parent); parent);
...@@ -678,47 +655,10 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -678,47 +655,10 @@ public class MapFragment extends Fragment implements TextWatcher,
} }
private class CustomListAdapter extends ArrayAdapter<String> {
private Context mContext;
private int id;
private List<String> items;
public CustomListAdapter(Context context, int textViewResourceId,
List<String> list) {
super(context, textViewResourceId, list);
mContext = context;
id = textViewResourceId;
items = list;
}
@Override
public View getView(int position, View v, ViewGroup parent) {
View mView = v;
if (mView == null) {
LayoutInflater vi = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mView = vi.inflate(id, null);
}
TextView text = (TextView) mView.findViewById(R.id.child_name);
Log.d("testing", "position = " + position);
if (items.get(position) != null) {
Typeface regular = Typeface.createFromAsset(getContext().getAssets(),
FONT_REGULAR);
text.setText(items.get(position));
text.setTypeface(regular);
}
return mView;
}
}
private SpannableStringBuilder getDescriptionText(com.mrane.data.Marker marker) { private SpannableStringBuilder getDescriptionText(com.mrane.data.Marker marker) {
String text = marker.getDescription(); String text = marker.getDescription();
SpannableStringBuilder desc = new SpannableStringBuilder(text); SpannableStringBuilder desc = new SpannableStringBuilder(text);
String[] toBoldParts = { "Email", "Phone No.", "Fax No." }; String[] toBoldParts = {"Email", "Phone No.", "Fax No."};
for (String part : toBoldParts) { for (String part : toBoldParts) {
setBold(desc, part); setBold(desc, part);
} }
...@@ -1011,9 +951,6 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -1011,9 +951,6 @@ public class MapFragment extends Fragment implements TextWatcher,
this.expAdapter = expAdapter; this.expAdapter = expAdapter;
} }
private static final String INSTANCE_CARD_STATE = "instanceCardState";
private static final String INSTANCE_VISIBILITY_INDEX = "instanceVisibilityIndex";
public SlidingUpPanelLayout getSlidingLayout() { public SlidingUpPanelLayout getSlidingLayout() {
return slidingLayout; return slidingLayout;
} }
...@@ -1042,50 +979,6 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -1042,50 +979,6 @@ public class MapFragment extends Fragment implements TextWatcher,
} }
} }
/*---------- Listener class to get coordinates ------------- */
private class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location loc) {
if (getView() == null || getActivity() == null) return;
// Set the origin
double Xn = Constants.MAP_Xn, Yn = Constants.MAP_Yn, Zn = Constants.MAP_Zn, Zyn = Constants.MAP_Zyn;
double x = (loc.getLatitude() - Xn) * 1000;
double y = (loc.getLongitude() - Yn) * 1000;
// Pre-trained weights
double[] A = Constants.MAP_WEIGHTS_X;
int px = (int)(Zn + A[0] + A[1]*x + A[2]*y + A[3]*x*x + A[4]*x*x*y + A[5]*x*x*y*y + A[6]*y*y + A[7]*x*y*y + A[8]*x*y);
A = Constants.MAP_WEIGHTS_Y;
int py = (int)(Zyn + A[0] + A[1]*x + A[2]*y + A[3]*x*x + A[4]*x*x*y + A[5]*x*x*y*y + A[6]*y*y + A[7]*x*y*y + A[8]*x*y);
if (px > 0 && py > 0 && px < 5430 && py < 5375){
if (!campusMapView.isAddedMarker(user)) {
campusMapView.addMarker(user);
}
user.setPoint(new PointF(px, py));
user.setName("You - " + (int)loc.getAccuracy() + "m");
if (followingUser) {
SubsamplingScaleImageView.AnimationBuilder anim = campusMapView.animateCenter(user.getPoint());
if (anim != null) anim.start();
}
campusMapView.invalidate();
}
}
@Override
public void onProviderDisabled(String provider) {}
@Override
public void onProviderEnabled(String provider) {}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {}
}
public void setFollowingUser(boolean followingUser) { public void setFollowingUser(boolean followingUser) {
this.followingUser = followingUser; this.followingUser = followingUser;
} }
...@@ -1109,8 +1002,7 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -1109,8 +1002,7 @@ public class MapFragment extends Fragment implements TextWatcher,
if (result.getLocationSettingsStates().isGpsPresent() && if (result.getLocationSettingsStates().isGpsPresent() &&
result.getLocationSettingsStates().isGpsUsable() && result.getLocationSettingsStates().isGpsUsable() &&
result.getLocationSettingsStates().isLocationPresent() && result.getLocationSettingsStates().isLocationPresent() &&
result.getLocationSettingsStates().isLocationUsable()) result.getLocationSettingsStates().isLocationUsable()) {
{
setupGPS(); setupGPS();
} }
} catch (ApiException ex) { } catch (ApiException ex) {
...@@ -1122,7 +1014,8 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -1122,7 +1014,8 @@ public class MapFragment extends Fragment implements TextWatcher,
resolvableApiException resolvableApiException
.startResolutionForResult(getActivity(), 87); .startResolutionForResult(getActivity(), 87);
setupGPS(); setupGPS();
} catch (IntentSender.SendIntentException e) { } } catch (IntentSender.SendIntentException e) {
}
break; break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
Toast.makeText(getContext(), "GPS is not enabled!", Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), "GPS is not enabled!", Toast.LENGTH_LONG).show();
...@@ -1132,5 +1025,112 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -1132,5 +1025,112 @@ public class MapFragment extends Fragment implements TextWatcher,
} }
}); });
} }
private class updateDatabase extends AsyncTask<List<Venue>, Void, Integer> {
@Override
protected Integer doInBackground(List<Venue>... venues) {
appDatabase.dbDao().deleteVenues();
appDatabase.dbDao().insertVenues(venues[0]);
return 1;
}
}
private class showLocationsFromDB extends AsyncTask<String, Void, List<Venue>> {
@Override
protected List<Venue> doInBackground(String... events) {
return appDatabase.dbDao().getAllVenues();
}
protected void onPostExecute(List<Venue> result) {
if (!locationsShown && result.size() > 0) {
setupWithData(result);
locationsShown = true;
}
}
}
private class CustomListAdapter extends ArrayAdapter<String> {
private Context mContext;
private int id;
private List<String> items;
public CustomListAdapter(Context context, int textViewResourceId,
List<String> list) {
super(context, textViewResourceId, list);
mContext = context;
id = textViewResourceId;
items = list;
}
@Override
public View getView(int position, View v, ViewGroup parent) {
View mView = v;
if (mView == null) {
LayoutInflater vi = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mView = vi.inflate(id, null);
}
TextView text = (TextView) mView.findViewById(R.id.child_name);
Log.d("testing", "position = " + position);
if (items.get(position) != null) {
Typeface regular = Typeface.createFromAsset(getContext().getAssets(),
FONT_REGULAR);
text.setText(items.get(position));
text.setTypeface(regular);
}
return mView;
}
}
/*---------- Listener class to get coordinates ------------- */
private class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location loc) {
if (getView() == null || getActivity() == null) return;
// Set the origin
double Xn = Constants.MAP_Xn, Yn = Constants.MAP_Yn, Zn = Constants.MAP_Zn, Zyn = Constants.MAP_Zyn;
double x = (loc.getLatitude() - Xn) * 1000;
double y = (loc.getLongitude() - Yn) * 1000;
// Pre-trained weights
double[] A = Constants.MAP_WEIGHTS_X;
int px = (int) (Zn + A[0] + A[1] * x + A[2] * y + A[3] * x * x + A[4] * x * x * y + A[5] * x * x * y * y + A[6] * y * y + A[7] * x * y * y + A[8] * x * y);
A = Constants.MAP_WEIGHTS_Y;
int py = (int) (Zyn + A[0] + A[1] * x + A[2] * y + A[3] * x * x + A[4] * x * x * y + A[5] * x * x * y * y + A[6] * y * y + A[7] * x * y * y + A[8] * x * y);
if (px > 0 && py > 0 && px < 5430 && py < 5375) {
if (!campusMapView.isAddedMarker(user)) {
campusMapView.addMarker(user);
}
user.setPoint(new PointF(px, py));
user.setName("You - " + (int) loc.getAccuracy() + "m");
if (followingUser) {
SubsamplingScaleImageView.AnimationBuilder anim = campusMapView.animateCenter(user.getPoint());
if (anim != null) anim.start();
}
campusMapView.invalidate();
}
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
}
} }
...@@ -156,12 +156,14 @@ public class MessMenuFragment extends BaseFragment { ...@@ -156,12 +156,14 @@ public class MessMenuFragment extends BaseFragment {
final List<MessMenu> sortedMenus = new ArrayList<>(); final List<MessMenu> sortedMenus = new ArrayList<>();
final Calendar calendar = Calendar.getInstance(Locale.UK); final Calendar calendar = Calendar.getInstance(Locale.UK);
int today = calendar.get(Calendar.DAY_OF_WEEK) - 2; int today = calendar.get(Calendar.DAY_OF_WEEK) - 2;
if (today == -1) { today = 6; } if (today == -1) {
today = 6;
}
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
final int day = (today + i) % 7 + 1; final int day = (today + i) % 7 + 1;
for(MessMenu menu : messMenus) { for (MessMenu menu : messMenus) {
if(menu.getDay() == day) { if (menu.getDay() == day) {
sortedMenus.add(menu); sortedMenus.add(menu);
} }
} }
......
...@@ -23,8 +23,8 @@ import java.util.List; ...@@ -23,8 +23,8 @@ import java.util.List;
import app.insti.ActivityBuffer; import app.insti.ActivityBuffer;
import app.insti.Constants; import app.insti.Constants;
import app.insti.ItemClickListener; import app.insti.ItemClickListener;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.adapter.FeedAdapter; import app.insti.adapter.FeedAdapter;
import app.insti.data.AppDatabase; import app.insti.data.AppDatabase;
import app.insti.data.Event; import app.insti.data.Event;
...@@ -67,7 +67,7 @@ public class MyEventsFragment extends BaseFragment { ...@@ -67,7 +67,7 @@ public class MyEventsFragment extends BaseFragment {
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
if (((MainActivity)getActivity()).createEventAccess()) { if (((MainActivity) getActivity()).createEventAccess()) {
fab.setVisibility(View.VISIBLE); fab.setVisibility(View.VISIBLE);
} }
......
...@@ -26,8 +26,8 @@ import java.util.List; ...@@ -26,8 +26,8 @@ import java.util.List;
import app.insti.ActivityBuffer; import app.insti.ActivityBuffer;
import app.insti.Constants; import app.insti.Constants;
import app.insti.ItemClickListener; import app.insti.ItemClickListener;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.adapter.NewsAdapter; import app.insti.adapter.NewsAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
...@@ -42,11 +42,11 @@ import retrofit2.Response; ...@@ -42,11 +42,11 @@ import retrofit2.Response;
*/ */
public class NewsFragment extends BaseFragment { public class NewsFragment extends BaseFragment {
public static boolean showLoader = true;
private RecyclerView newsRecyclerView; private RecyclerView newsRecyclerView;
private SwipeRefreshLayout newsSwipeRefreshLayout; private SwipeRefreshLayout newsSwipeRefreshLayout;
private AppDatabase appDatabase; private AppDatabase appDatabase;
private boolean freshNewsDisplayed = false; private boolean freshNewsDisplayed = false;
public static boolean showLoader = true;
private String searchQuery; private String searchQuery;
public NewsFragment() { public NewsFragment() {
...@@ -177,28 +177,6 @@ public class NewsFragment extends BaseFragment { ...@@ -177,28 +177,6 @@ public class NewsFragment extends BaseFragment {
startActivity(browse); startActivity(browse);
} }
private class updateDatabase extends AsyncTask<List<NewsArticle>, Void, Integer> {
@Override
protected Integer doInBackground(List<NewsArticle>... posts) {
appDatabase.dbDao().deleteNewsArticles();
appDatabase.dbDao().insertNewsArticles(posts[0]);
return 1;
}
}
private class showNewsFromDB extends AsyncTask<String, Void, List<NewsArticle>> {
@Override
protected List<NewsArticle> doInBackground(String... posts) {
return appDatabase.dbDao().getAllNewsArticles();
}
protected void onPostExecute(List<NewsArticle> result) {
if (!freshNewsDisplayed) {
displayNews(result);
}
}
}
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.search_view_menu, menu); inflater.inflate(R.menu.search_view_menu, menu);
...@@ -215,7 +193,7 @@ public class NewsFragment extends BaseFragment { ...@@ -215,7 +193,7 @@ public class NewsFragment extends BaseFragment {
@Override @Override
public boolean onQueryTextChange(String newText) { public boolean onQueryTextChange(String newText) {
if (TextUtils.isEmpty(newText)){ if (TextUtils.isEmpty(newText)) {
//Text is cleared, do your thing //Text is cleared, do your thing
searchQuery = null; searchQuery = null;
updateNews(); updateNews();
...@@ -235,4 +213,26 @@ public class NewsFragment extends BaseFragment { ...@@ -235,4 +213,26 @@ public class NewsFragment extends BaseFragment {
updateNews(); updateNews();
showLoader = false; showLoader = false;
} }
private class updateDatabase extends AsyncTask<List<NewsArticle>, Void, Integer> {
@Override
protected Integer doInBackground(List<NewsArticle>... posts) {
appDatabase.dbDao().deleteNewsArticles();
appDatabase.dbDao().insertNewsArticles(posts[0]);
return 1;
}
}
private class showNewsFromDB extends AsyncTask<String, Void, List<NewsArticle>> {
@Override
protected List<NewsArticle> doInBackground(String... posts) {
return appDatabase.dbDao().getAllNewsArticles();
}
protected void onPostExecute(List<NewsArticle> result) {
if (!freshNewsDisplayed) {
displayNews(result);
}
}
}
} }
...@@ -18,8 +18,8 @@ import java.util.List; ...@@ -18,8 +18,8 @@ import java.util.List;
import app.insti.Constants; import app.insti.Constants;
import app.insti.ItemClickListener; import app.insti.ItemClickListener;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.adapter.NotificationsAdapter; import app.insti.adapter.NotificationsAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
...@@ -58,7 +58,7 @@ public class NotificationsFragment extends BaseFragment { ...@@ -58,7 +58,7 @@ public class NotificationsFragment extends BaseFragment {
toolbar.setTitle("Notifications"); toolbar.setTitle("Notifications");
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class); RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getNotifications(((MainActivity)getActivity()).getSessionIDHeader()).enqueue(new Callback<List<Notification>>() { retrofitInterface.getNotifications(((MainActivity) getActivity()).getSessionIDHeader()).enqueue(new Callback<List<Notification>>() {
@Override @Override
public void onResponse(Call<List<Notification>> call, Response<List<Notification>> response) { public void onResponse(Call<List<Notification>> call, Response<List<Notification>> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -68,7 +68,8 @@ public class NotificationsFragment extends BaseFragment { ...@@ -68,7 +68,8 @@ public class NotificationsFragment extends BaseFragment {
} }
@Override @Override
public void onFailure(Call<List<Notification>> call, Throwable t) { } public void onFailure(Call<List<Notification>> call, Throwable t) {
}
}); });
} }
...@@ -87,12 +88,15 @@ public class NotificationsFragment extends BaseFragment { ...@@ -87,12 +88,15 @@ public class NotificationsFragment extends BaseFragment {
/* Mark notification read */ /* Mark notification read */
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class); RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
String sessId = ((MainActivity)getActivity()).getSessionIDHeader(); String sessId = ((MainActivity) getActivity()).getSessionIDHeader();
retrofitInterface.markNotificationRead(sessId, notification.getNotificationId()).enqueue(new Callback<Void>() { retrofitInterface.markNotificationRead(sessId, notification.getNotificationId()).enqueue(new Callback<Void>() {
@Override @Override
public void onResponse(Call<Void> call, Response<Void> response) { } public void onResponse(Call<Void> call, Response<Void> response) {
}
@Override @Override
public void onFailure(Call<Void> call, Throwable t) { } public void onFailure(Call<Void> call, Throwable t) {
}
}); });
FragmentManager manager = getActivity().getSupportFragmentManager(); FragmentManager manager = getActivity().getSupportFragmentManager();
...@@ -100,7 +104,9 @@ public class NotificationsFragment extends BaseFragment { ...@@ -100,7 +104,9 @@ public class NotificationsFragment extends BaseFragment {
String tag = ""; String tag = "";
Bundle bundle = getArguments(); Bundle bundle = getArguments();
if (bundle == null) { bundle = new Bundle(); } if (bundle == null) {
bundle = new Bundle();
}
bundle.putString(Constants.SESSION_ID, ((MainActivity) getActivity()).getSessionIDHeader()); bundle.putString(Constants.SESSION_ID, ((MainActivity) getActivity()).getSessionIDHeader());
/* Open event */ /* Open event */
......
...@@ -26,8 +26,8 @@ import java.util.List; ...@@ -26,8 +26,8 @@ import java.util.List;
import app.insti.ActivityBuffer; import app.insti.ActivityBuffer;
import app.insti.Constants; import app.insti.Constants;
import app.insti.ItemClickListener; import app.insti.ItemClickListener;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.adapter.PlacementBlogAdapter; import app.insti.adapter.PlacementBlogAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
...@@ -42,12 +42,12 @@ import retrofit2.Response; ...@@ -42,12 +42,12 @@ import retrofit2.Response;
*/ */
public class PlacementBlogFragment extends BaseFragment { public class PlacementBlogFragment extends BaseFragment {
public static boolean showLoader = true;
private RecyclerView placementFeedRecyclerView; private RecyclerView placementFeedRecyclerView;
private PlacementBlogAdapter placementBlogAdapter; private PlacementBlogAdapter placementBlogAdapter;
private SwipeRefreshLayout feedSwipeRefreshLayout; private SwipeRefreshLayout feedSwipeRefreshLayout;
private AppDatabase appDatabase; private AppDatabase appDatabase;
private boolean freshBlogDisplayed = false; private boolean freshBlogDisplayed = false;
public static boolean showLoader = true;
private String searchQuery; private String searchQuery;
...@@ -177,28 +177,6 @@ public class PlacementBlogFragment extends BaseFragment { ...@@ -177,28 +177,6 @@ public class PlacementBlogFragment extends BaseFragment {
startActivity(browse); startActivity(browse);
} }
private class updateDatabase extends AsyncTask<List<PlacementBlogPost>, Void, Integer> {
@Override
protected Integer doInBackground(List<PlacementBlogPost>... posts) {
appDatabase.dbDao().deletePlacementBlogPosts();
appDatabase.dbDao().insertPlacementBlogPosts(posts[0]);
return 1;
}
}
private class showPlacementBlogFromDB extends AsyncTask<String, Void, List<PlacementBlogPost>> {
@Override
protected List<PlacementBlogPost> doInBackground(String... posts) {
return appDatabase.dbDao().getAllPlacementBlogPosts();
}
protected void onPostExecute(List<PlacementBlogPost> result) {
if (!freshBlogDisplayed) {
displayPlacementFeed(result);
}
}
}
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.search_view_menu, menu); inflater.inflate(R.menu.search_view_menu, menu);
...@@ -215,7 +193,7 @@ public class PlacementBlogFragment extends BaseFragment { ...@@ -215,7 +193,7 @@ public class PlacementBlogFragment extends BaseFragment {
@Override @Override
public boolean onQueryTextChange(String newText) { public boolean onQueryTextChange(String newText) {
if (TextUtils.isEmpty(newText)){ if (TextUtils.isEmpty(newText)) {
//Text is cleared, do your thing //Text is cleared, do your thing
searchQuery = null; searchQuery = null;
updatePlacementFeed(); updatePlacementFeed();
...@@ -235,4 +213,26 @@ public class PlacementBlogFragment extends BaseFragment { ...@@ -235,4 +213,26 @@ public class PlacementBlogFragment extends BaseFragment {
updatePlacementFeed(); updatePlacementFeed();
showLoader = false; showLoader = false;
} }
private class updateDatabase extends AsyncTask<List<PlacementBlogPost>, Void, Integer> {
@Override
protected Integer doInBackground(List<PlacementBlogPost>... posts) {
appDatabase.dbDao().deletePlacementBlogPosts();
appDatabase.dbDao().insertPlacementBlogPosts(posts[0]);
return 1;
}
}
private class showPlacementBlogFromDB extends AsyncTask<String, Void, List<PlacementBlogPost>> {
@Override
protected List<PlacementBlogPost> doInBackground(String... posts) {
return appDatabase.dbDao().getAllPlacementBlogPosts();
}
protected void onPostExecute(List<PlacementBlogPost> result) {
if (!freshBlogDisplayed) {
displayPlacementFeed(result);
}
}
}
} }
...@@ -66,6 +66,13 @@ public class ProfileFragment extends BackHandledFragment { ...@@ -66,6 +66,13 @@ public class ProfileFragment extends BackHandledFragment {
// Required empty public constructor // Required empty public constructor
} }
public static ProfileFragment newInstance(String userID) {
ProfileFragment fragment = new ProfileFragment();
Bundle args = new Bundle();
args.putString(Constants.USER_ID, userID);
fragment.setArguments(args);
return fragment;
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
...@@ -221,14 +228,6 @@ public class ProfileFragment extends BackHandledFragment { ...@@ -221,14 +228,6 @@ public class ProfileFragment extends BackHandledFragment {
mCurrentAnimator = set; mCurrentAnimator = set;
} }
public static ProfileFragment newInstance(String userID) {
ProfileFragment fragment = new ProfileFragment();
Bundle args = new Bundle();
args.putString(Constants.USER_ID, userID);
fragment.setArguments(args);
return fragment;
}
private void zoomImageFromThumb(final ImageView thumbView) { private void zoomImageFromThumb(final ImageView thumbView) {
// If there's an animation in progress, cancel it // If there's an animation in progress, cancel it
// immediately and proceed with this one. // immediately and proceed with this one.
......
...@@ -17,7 +17,7 @@ public class QuickLinksFragment extends BaseFragment { ...@@ -17,7 +17,7 @@ public class QuickLinksFragment extends BaseFragment {
// Required empty public constructor // Required empty public constructor
} }
public void onStart(){ public void onStart() {
super.onStart(); super.onStart();
Toolbar toolbar = getActivity().findViewById(R.id.toolbar); Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
...@@ -47,36 +47,125 @@ public class QuickLinksFragment extends BaseFragment { ...@@ -47,36 +47,125 @@ public class QuickLinksFragment extends BaseFragment {
TextView Hospital = getActivity().findViewById(R.id.button_Hospital); TextView Hospital = getActivity().findViewById(R.id.button_Hospital);
TextView VPN = getActivity().findViewById(R.id.button_VPN); TextView VPN = getActivity().findViewById(R.id.button_VPN);
CMS.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://gymkhana.iitb.ac.in/cms_new/"); } }); CMS.setOnClickListener(new View.OnClickListener() {
CMSMaint.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://support.iitb.ac.in"); } }); public void onClick(View v) {
CMSNet.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://help-cc.iitb.ac.in/"); } }); goToUrl("https://gymkhana.iitb.ac.in/cms_new/");
ASC.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://asc.iitb.ac.in"); } }); }
ASCExt.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://portal.iitb.ac.in/asc"); } }); });
Moodle.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://moodle.iitb.ac.in"); } }); CMSMaint.setOnClickListener(new View.OnClickListener() {
Intern.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("http://placements.iitb.ac.in/internship/login.jsp"); } }); public void onClick(View v) {
Placement.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("http://placements.iitb.ac.in/placements/login.jsp"); } }); goToUrl("https://support.iitb.ac.in");
Library.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("http://www.library.iitb.ac.in/"); } }); }
AcadCal.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("http://www.iitb.ac.in/newacadhome/toacadcalender.jsp"); } }); });
AcadTime.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("http://www.iitb.ac.in/newacadhome/timetable.jsp"); } }); CMSNet.setOnClickListener(new View.OnClickListener() {
Holidays.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("http://www.iitb.ac.in/en/about-iit-bombay/iit-bombay-holidays-list"); } }); public void onClick(View v) {
Circulars.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("http://www.iitb.ac.in/newacadhome/circular.jsp"); } }); goToUrl("https://help-cc.iitb.ac.in/");
Courses.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://portal.iitb.ac.in/asc/Courses"); } }); }
WebMail.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://webmail.iitb.ac.in"); } }); });
GPO.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://gpo.iitb.ac.in"); } }); ASC.setOnClickListener(new View.OnClickListener() {
CAMP.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://camp.iitb.ac.in/"); } }); public void onClick(View v) {
MSStore.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("http://msstore.iitb.ac.in/"); } }); goToUrl("https://asc.iitb.ac.in");
BigHome.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://home.iitb.ac.in/"); } }); }
});
ASCExt.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("https://portal.iitb.ac.in/asc");
}
});
Moodle.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("https://moodle.iitb.ac.in");
}
});
Intern.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("http://placements.iitb.ac.in/internship/login.jsp");
}
});
Placement.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("http://placements.iitb.ac.in/placements/login.jsp");
}
});
Library.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("http://www.library.iitb.ac.in/");
}
});
AcadCal.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("http://www.iitb.ac.in/newacadhome/toacadcalender.jsp");
}
});
AcadTime.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("http://www.iitb.ac.in/newacadhome/timetable.jsp");
}
});
Holidays.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("http://www.iitb.ac.in/en/about-iit-bombay/iit-bombay-holidays-list");
}
});
Circulars.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("http://www.iitb.ac.in/newacadhome/circular.jsp");
}
});
Courses.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("https://portal.iitb.ac.in/asc/Courses");
}
});
WebMail.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("https://webmail.iitb.ac.in");
}
});
GPO.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("https://gpo.iitb.ac.in");
}
});
CAMP.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("https://camp.iitb.ac.in/");
}
});
MSStore.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("http://msstore.iitb.ac.in/");
}
});
BigHome.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("https://home.iitb.ac.in/");
}
});
// FTP.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("ftp://ftp.iitb.ac.in/"); } }); // FTP.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("ftp://ftp.iitb.ac.in/"); } });
Intercom.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://portal.iitb.ac.in/TelephoneDirectory/"); } }); Intercom.setOnClickListener(new View.OnClickListener() {
Hospital.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("http://www.iitb.ac.in/hospital/"); } }); public void onClick(View v) {
VPN.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://www.cc.iitb.ac.in/engservices/engaccessingiitffromoutside/19-vpn"); } }); goToUrl("https://portal.iitb.ac.in/TelephoneDirectory/");
}
});
Hospital.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("http://www.iitb.ac.in/hospital/");
}
});
VPN.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goToUrl("https://www.cc.iitb.ac.in/engservices/engaccessingiitffromoutside/19-vpn");
} }
});
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_quick_links, container, false); return inflater.inflate(R.layout.fragment_quick_links, container, false);
} }
public void goToUrl (String url) { public void goToUrl(String url) {
Uri uriUrl = Uri.parse(url); Uri uriUrl = Uri.parse(url);
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl); Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
startActivity(launchBrowser); startActivity(launchBrowser);
......
...@@ -18,9 +18,9 @@ import android.widget.TextView; ...@@ -18,9 +18,9 @@ import android.widget.TextView;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import app.insti.Constants; import app.insti.Constants;
import app.insti.activity.LoginActivity;
import app.insti.R; import app.insti.R;
import app.insti.SessionManager; import app.insti.SessionManager;
import app.insti.activity.LoginActivity;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
import app.insti.data.User; import app.insti.data.User;
......
...@@ -26,8 +26,8 @@ import java.util.List; ...@@ -26,8 +26,8 @@ import java.util.List;
import app.insti.ActivityBuffer; import app.insti.ActivityBuffer;
import app.insti.Constants; import app.insti.Constants;
import app.insti.ItemClickListener; import app.insti.ItemClickListener;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.adapter.TrainingBlogAdapter; import app.insti.adapter.TrainingBlogAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
...@@ -42,11 +42,11 @@ import retrofit2.Response; ...@@ -42,11 +42,11 @@ import retrofit2.Response;
*/ */
public class TrainingBlogFragment extends BaseFragment { public class TrainingBlogFragment extends BaseFragment {
public static boolean showLoader = true;
private RecyclerView trainingFeedRecyclerView; private RecyclerView trainingFeedRecyclerView;
private SwipeRefreshLayout feedSwipeRefreshLayout; private SwipeRefreshLayout feedSwipeRefreshLayout;
private AppDatabase appDatabase; private AppDatabase appDatabase;
private boolean freshBlogDisplayed = false; private boolean freshBlogDisplayed = false;
public static boolean showLoader = true;
private String searchQuery; private String searchQuery;
...@@ -176,28 +176,6 @@ public class TrainingBlogFragment extends BaseFragment { ...@@ -176,28 +176,6 @@ public class TrainingBlogFragment extends BaseFragment {
startActivity(browse); startActivity(browse);
} }
private class updateDatabase extends AsyncTask<List<TrainingBlogPost>, Void, Integer> {
@Override
protected Integer doInBackground(List<TrainingBlogPost>... posts) {
appDatabase.dbDao().deleteTrainingBlogPosts();
appDatabase.dbDao().insertTrainingBlogPosts(posts[0]);
return 1;
}
}
private class showTrainingBlogFromDB extends AsyncTask<String, Void, List<TrainingBlogPost>> {
@Override
protected List<TrainingBlogPost> doInBackground(String... posts) {
return appDatabase.dbDao().getAllTrainingBlogPosts();
}
protected void onPostExecute(List<TrainingBlogPost> result) {
if (!freshBlogDisplayed) {
displayTrainingFeed(result);
}
}
}
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.search_view_menu, menu); inflater.inflate(R.menu.search_view_menu, menu);
...@@ -214,7 +192,7 @@ public class TrainingBlogFragment extends BaseFragment { ...@@ -214,7 +192,7 @@ public class TrainingBlogFragment extends BaseFragment {
@Override @Override
public boolean onQueryTextChange(String newText) { public boolean onQueryTextChange(String newText) {
if (TextUtils.isEmpty(newText)){ if (TextUtils.isEmpty(newText)) {
//Text is cleared, do your thing //Text is cleared, do your thing
searchQuery = null; searchQuery = null;
updateTrainingFeed(); updateTrainingFeed();
...@@ -234,4 +212,26 @@ public class TrainingBlogFragment extends BaseFragment { ...@@ -234,4 +212,26 @@ public class TrainingBlogFragment extends BaseFragment {
updateTrainingFeed(); updateTrainingFeed();
showLoader = false; showLoader = false;
} }
private class updateDatabase extends AsyncTask<List<TrainingBlogPost>, Void, Integer> {
@Override
protected Integer doInBackground(List<TrainingBlogPost>... posts) {
appDatabase.dbDao().deleteTrainingBlogPosts();
appDatabase.dbDao().insertTrainingBlogPosts(posts[0]);
return 1;
}
}
private class showTrainingBlogFromDB extends AsyncTask<String, Void, List<TrainingBlogPost>> {
@Override
protected List<TrainingBlogPost> doInBackground(String... posts) {
return appDatabase.dbDao().getAllTrainingBlogPosts();
}
protected void onPostExecute(List<TrainingBlogPost> result) {
if (!freshBlogDisplayed) {
displayTrainingFeed(result);
}
}
}
} }
...@@ -16,9 +16,9 @@ import java.util.List; ...@@ -16,9 +16,9 @@ import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import app.insti.Constants; import app.insti.Constants;
import app.insti.activity.MainActivity;
import app.insti.R; import app.insti.R;
import app.insti.SessionManager; import app.insti.SessionManager;
import app.insti.activity.MainActivity;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
import app.insti.data.Event; import app.insti.data.Event;
...@@ -29,11 +29,11 @@ import retrofit2.Response; ...@@ -29,11 +29,11 @@ import retrofit2.Response;
public class NotificationIntentService extends JobIntentService { public class NotificationIntentService extends JobIntentService {
public static final String ACTION_OPEN_EVENT = "ACTION_OPEN_EVENT";
private static final String ACTION_START = "ACTION_START"; private static final String ACTION_START = "ACTION_START";
private static final String ACTION_DELETE = "ACTION_DELETE"; private static final String ACTION_DELETE = "ACTION_DELETE";
private static final String ACTION_NAVIGATE = "ACTION_NAVIGATE"; private static final String ACTION_NAVIGATE = "ACTION_NAVIGATE";
private static final String ACTION_NOT_GOING = "ACTION_NOT_GOING"; private static final String ACTION_NOT_GOING = "ACTION_NOT_GOING";
public static final String ACTION_OPEN_EVENT = "ACTION_OPEN_EVENT";
private static int NOTIFICATION_ID = 1; private static int NOTIFICATION_ID = 1;
private NotificationManager manager; private NotificationManager manager;
...@@ -97,7 +97,8 @@ public class NotificationIntentService extends JobIntentService { ...@@ -97,7 +97,8 @@ public class NotificationIntentService extends JobIntentService {
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
startActivity(mapIntent); startActivity(mapIntent);
} }
} finally { } } finally {
}
} }
private void processDeleteNotification(Intent intent) { private void processDeleteNotification(Intent intent) {
......
...@@ -45,21 +45,6 @@ public class FuzzySearchAdapter extends BaseAdapter { ...@@ -45,21 +45,6 @@ public class FuzzySearchAdapter extends BaseAdapter {
map = new ArrayList<ScoredMarker>(); map = new ArrayList<ScoredMarker>();
} }
public class ViewHolder {
TextView label;
LinearLayout rowContainer;
}
public class ScoredMarker {
Marker m;
int score;
public ScoredMarker(int score, Marker m) {
this.m = m;
this.score = score;
}
}
public int getResultSize() { public int getResultSize() {
return resultlist.size(); return resultlist.size();
} }
...@@ -319,6 +304,21 @@ public class FuzzySearchAdapter extends BaseAdapter { ...@@ -319,6 +304,21 @@ public class FuzzySearchAdapter extends BaseAdapter {
this.settingsManager = settingsManager; this.settingsManager = settingsManager;
} }
public class ViewHolder {
TextView label;
LinearLayout rowContainer;
}
public class ScoredMarker {
Marker m;
int score;
public ScoredMarker(int score, Marker m) {
this.m = m;
this.score = score;
}
}
public class MarkerScoreComparator implements Comparator<ScoredMarker> { public class MarkerScoreComparator implements Comparator<ScoredMarker> {
public int compare(ScoredMarker m1, ScoredMarker m2) { public int compare(ScoredMarker m1, ScoredMarker m2) {
return m1.score - m2.score; return m1.score - m2.score;
......
...@@ -6,15 +6,13 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener; ...@@ -6,15 +6,13 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.Resources; import android.content.res.Resources;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import app.insti.R; public class SettingsManager implements OnSharedPreferenceChangeListener {
public class SettingsManager implements OnSharedPreferenceChangeListener{
private SharedPreferences sharedPrefs; private SharedPreferences sharedPrefs;
private String muteKey; private String muteKey;
private String residencesKey; private String residencesKey;
private String lastUpdatedKey; private String lastUpdatedKey;
public SettingsManager(Context context){ public SettingsManager(Context context) {
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
sharedPrefs.registerOnSharedPreferenceChangeListener(this); sharedPrefs.registerOnSharedPreferenceChangeListener(this);
Resources res = context.getResources(); Resources res = context.getResources();
...@@ -23,11 +21,11 @@ public class SettingsManager implements OnSharedPreferenceChangeListener{ ...@@ -23,11 +21,11 @@ public class SettingsManager implements OnSharedPreferenceChangeListener{
lastUpdatedKey = "lastupdated"; lastUpdatedKey = "lastupdated";
} }
public boolean isMuted(){ public boolean isMuted() {
return sharedPrefs.getBoolean(muteKey, false); return sharedPrefs.getBoolean(muteKey, false);
} }
public boolean showResidences(){ public boolean showResidences() {
return sharedPrefs.getBoolean(residencesKey, true); return sharedPrefs.getBoolean(residencesKey, true);
} }
......
...@@ -7,26 +7,10 @@ import java.util.ArrayList; ...@@ -7,26 +7,10 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
public class Marker { public class Marker {
private int id;
private String name;
private String shortName;
private PointF point;
private int groupIndex;
private boolean showDefault;
private String description;
private String tag;
private String imageUri;
private int parentId;
private String parentRel;
private int[] childIds;
private long lat;
private long lng;
public static final int COLOR_BLUE = Color.rgb(75, 186, 238); public static final int COLOR_BLUE = Color.rgb(75, 186, 238);
public static final int COLOR_YELLOW = Color.rgb(255, 186, 0); public static final int COLOR_YELLOW = Color.rgb(255, 186, 0);
public static final int COLOR_GREEN = Color.rgb(162, 208, 104); public static final int COLOR_GREEN = Color.rgb(162, 208, 104);
public static final int COLOR_GRAY = Color.rgb(156, 156, 156); public static final int COLOR_GRAY = Color.rgb(156, 156, 156);
public static final int DEPARTMENTS = 1; public static final int DEPARTMENTS = 1;
public static final int HOSTELS = 2; public static final int HOSTELS = 2;
public static final int RESIDENCES = 3; public static final int RESIDENCES = 3;
...@@ -39,7 +23,6 @@ public class Marker { ...@@ -39,7 +23,6 @@ public class Marker {
public static final int GATES = 10; public static final int GATES = 10;
public static final int PRINT = 11; public static final int PRINT = 11;
public static final int LABS = 12; public static final int LABS = 12;
private static final String DEPARTMENTS_NAME = "Departments"; private static final String DEPARTMENTS_NAME = "Departments";
private static final String HOSTELS_NAME = "Hostels"; private static final String HOSTELS_NAME = "Hostels";
private static final String RESIDENCES_NAME = "Residences"; private static final String RESIDENCES_NAME = "Residences";
...@@ -52,6 +35,20 @@ public class Marker { ...@@ -52,6 +35,20 @@ public class Marker {
private static final String GATES_NAME = "Gates"; private static final String GATES_NAME = "Gates";
private static final String PRINT_NAME = "Printer facility"; private static final String PRINT_NAME = "Printer facility";
private static final String LABS_NAME = "Labs"; private static final String LABS_NAME = "Labs";
private int id;
private String name;
private String shortName;
private PointF point;
private int groupIndex;
private boolean showDefault;
private String description;
private String tag;
private String imageUri;
private int parentId;
private String parentRel;
private int[] childIds;
private long lat;
private long lng;
public Marker(String name, String shortName, float x, float y, public Marker(String name, String shortName, float x, float y,
int groupIndex, String description) { int groupIndex, String description) {
...@@ -85,12 +82,12 @@ public class Marker { ...@@ -85,12 +82,12 @@ public class Marker {
return -10; return -10;
} }
Integer[] yellowGroup = new Integer[] { HOSTELS }; Integer[] yellowGroup = new Integer[]{HOSTELS};
Integer[] blueGroup = new Integer[] { DEPARTMENTS, LABS, Integer[] blueGroup = new Integer[]{DEPARTMENTS, LABS,
HALLS_N_AUDITORIUMS }; HALLS_N_AUDITORIUMS};
Integer[] greenGroup = new Integer[] { RESIDENCES }; Integer[] greenGroup = new Integer[]{RESIDENCES};
Integer[] purpleGroup = new Integer[] { FOOD_STALLS, BANKS_N_ATMS, Integer[] purpleGroup = new Integer[]{FOOD_STALLS, BANKS_N_ATMS,
SCHOOLS, SPORTS, OTHERS, GATES, PRINT }; SCHOOLS, SPORTS, OTHERS, GATES, PRINT};
ArrayList<Integer> yellowList = new ArrayList<Integer>( ArrayList<Integer> yellowList = new ArrayList<Integer>(
Arrays.asList(yellowGroup)); Arrays.asList(yellowGroup));
...@@ -114,46 +111,11 @@ public class Marker { ...@@ -114,46 +111,11 @@ public class Marker {
return 0; return 0;
} }
public int getColor() {
int group = this.groupIndex;
return getColor(group);
}
public String getGroupName() {
switch (groupIndex) {
case DEPARTMENTS:
return DEPARTMENTS_NAME;
case HOSTELS:
return HOSTELS_NAME;
case RESIDENCES:
return RESIDENCES_NAME;
case HALLS_N_AUDITORIUMS:
return HALLS_N_AUDITORIUMS_NAME;
case FOOD_STALLS:
return FOOD_STALLS_NAME;
case BANKS_N_ATMS:
return BANKS_N_ATMS_NAME;
case SCHOOLS:
return SCHOOLS_NAME;
case SPORTS:
return SPORTS_NAME;
case OTHERS:
return OTHERS_NAME;
case GATES:
return GATES_NAME;
case PRINT:
return PRINT_NAME;
case LABS:
return LABS_NAME;
}
return "";
}
public static String[] getGroupNames() { public static String[] getGroupNames() {
String[] groupNames = { DEPARTMENTS_NAME, LABS_NAME, String[] groupNames = {DEPARTMENTS_NAME, LABS_NAME,
HALLS_N_AUDITORIUMS_NAME, HOSTELS_NAME, RESIDENCES_NAME, HALLS_N_AUDITORIUMS_NAME, HOSTELS_NAME, RESIDENCES_NAME,
FOOD_STALLS_NAME, BANKS_N_ATMS_NAME, SCHOOLS_NAME, SPORTS_NAME, FOOD_STALLS_NAME, BANKS_N_ATMS_NAME, SCHOOLS_NAME, SPORTS_NAME,
PRINT_NAME, GATES_NAME, OTHERS_NAME }; PRINT_NAME, GATES_NAME, OTHERS_NAME};
return groupNames; return groupNames;
} }
...@@ -187,6 +149,41 @@ public class Marker { ...@@ -187,6 +149,41 @@ public class Marker {
return result; return result;
} }
public int getColor() {
int group = this.groupIndex;
return getColor(group);
}
public String getGroupName() {
switch (groupIndex) {
case DEPARTMENTS:
return DEPARTMENTS_NAME;
case HOSTELS:
return HOSTELS_NAME;
case RESIDENCES:
return RESIDENCES_NAME;
case HALLS_N_AUDITORIUMS:
return HALLS_N_AUDITORIUMS_NAME;
case FOOD_STALLS:
return FOOD_STALLS_NAME;
case BANKS_N_ATMS:
return BANKS_N_ATMS_NAME;
case SCHOOLS:
return SCHOOLS_NAME;
case SPORTS:
return SPORTS_NAME;
case OTHERS:
return OTHERS_NAME;
case GATES:
return GATES_NAME;
case PRINT:
return PRINT_NAME;
case LABS:
return LABS_NAME;
}
return "";
}
public int getId() { public int getId() {
return id; return id;
} }
......
...@@ -7,20 +7,19 @@ import android.view.View; ...@@ -7,20 +7,19 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.Interpolator; import android.view.animation.Interpolator;
import com.mrane.navigation.SlidingUpPanelLayout.PanelSlideListener;
import app.insti.R; import app.insti.R;
import app.insti.fragment.MapFragment; import app.insti.fragment.MapFragment;
import com.mrane.navigation.SlidingUpPanelLayout.PanelSlideListener;
public class CardSlideListener implements PanelSlideListener, public class CardSlideListener implements PanelSlideListener,
ValueAnimator.AnimatorUpdateListener { ValueAnimator.AnimatorUpdateListener {
private static final long TIME_ANIMATION_SHOW = 250;
private MapFragment mainActivity; private MapFragment mainActivity;
private SlidingUpPanelLayout slidingLayout; private SlidingUpPanelLayout slidingLayout;
private EndDetectScrollView scrollView; private EndDetectScrollView scrollView;
private ValueAnimator animator; private ValueAnimator animator;
private static final long TIME_ANIMATION_SHOW = 250;
public CardSlideListener(MapFragment mainActivity) { public CardSlideListener(MapFragment mainActivity) {
this.mainActivity = mainActivity; this.mainActivity = mainActivity;
slidingLayout = mainActivity.getSlidingLayout(); slidingLayout = mainActivity.getSlidingLayout();
......
...@@ -8,22 +8,8 @@ import android.widget.ScrollView; ...@@ -8,22 +8,8 @@ import android.widget.ScrollView;
public class EndDetectScrollView extends ScrollView { public class EndDetectScrollView extends ScrollView {
private enum ScrollState {
TOP, BETWEEN, BOTTOM
}
private ScrollState mCurrState = ScrollState.TOP; private ScrollState mCurrState = ScrollState.TOP;
private boolean scrollable = true; private boolean scrollable = true;
public interface ScrollEndListener {
public void onScrollHitBottom();
public void onScrollHitTop();
public void onScrollInBetween();
}
private ScrollEndListener listener; private ScrollEndListener listener;
public EndDetectScrollView(Context context) { public EndDetectScrollView(Context context) {
...@@ -109,4 +95,16 @@ public class EndDetectScrollView extends ScrollView { ...@@ -109,4 +95,16 @@ public class EndDetectScrollView extends ScrollView {
else else
return super.onInterceptTouchEvent(ev); return super.onInterceptTouchEvent(ev);
} }
private enum ScrollState {
TOP, BETWEEN, BOTTOM
}
public interface ScrollEndListener {
public void onScrollHitBottom();
public void onScrollHitTop();
public void onScrollInBetween();
}
} }
...@@ -32,22 +32,14 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -32,22 +32,14 @@ public class SlidingUpPanelLayout extends ViewGroup {
* Default anchor point height * Default anchor point height
*/ */
private static final float DEFAULT_ANCHOR_POINT = 1.0f; // In relative % private static final float DEFAULT_ANCHOR_POINT = 1.0f; // In relative %
/**
* Default initial state for the component
*/
private static SlideState DEFAULT_SLIDE_STATE = SlideState.COLLAPSED;
/** /**
* Default height of the shadow above the peeking out panel * Default height of the shadow above the peeking out panel
*/ */
private static final int DEFAULT_SHADOW_HEIGHT = 4; // dp; private static final int DEFAULT_SHADOW_HEIGHT = 4; // dp;
/** /**
* If no fade color is given by default it will fade to 80% gray. * If no fade color is given by default it will fade to 80% gray.
*/ */
private static final int DEFAULT_FADE_COLOR = 0x99000000; private static final int DEFAULT_FADE_COLOR = 0x99000000;
/** /**
* Default Minimum velocity that will be detected as a fling * Default Minimum velocity that will be detected as a fling
*/ */
...@@ -59,132 +51,103 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -59,132 +51,103 @@ public class SlidingUpPanelLayout extends ViewGroup {
/** /**
* Default attributes for layout * Default attributes for layout
*/ */
private static final int[] DEFAULT_ATTRS = new int[] { private static final int[] DEFAULT_ATTRS = new int[]{
android.R.attr.gravity android.R.attr.gravity
}; };
/**
* Minimum velocity that will be detected as a fling
*/
private int mMinFlingVelocity = DEFAULT_MIN_FLING_VELOCITY;
/**
* The fade color used for the panel covered by the slider. 0 = no fading.
*/
private int mCoveredFadeColor = DEFAULT_FADE_COLOR;
/** /**
* Default paralax length of the main view * Default paralax length of the main view
*/ */
private static final int DEFAULT_PARALAX_OFFSET = 0; private static final int DEFAULT_PARALAX_OFFSET = 0;
/**
* Default initial state for the component
*/
private static SlideState DEFAULT_SLIDE_STATE = SlideState.COLLAPSED;
/** /**
* The paint used to dim the main layout when sliding * The paint used to dim the main layout when sliding
*/ */
private final Paint mCoveredFadePaint = new Paint(); private final Paint mCoveredFadePaint = new Paint();
/** /**
* Drawable used to draw the shadow between panes. * Drawable used to draw the shadow between panes.
*/ */
private final Drawable mShadowDrawable; private final Drawable mShadowDrawable;
private final ViewDragHelper mDragHelper;
private final Rect mTmpRect = new Rect();
/**
* Minimum velocity that will be detected as a fling
*/
private int mMinFlingVelocity = DEFAULT_MIN_FLING_VELOCITY;
/**
* The fade color used for the panel covered by the slider. 0 = no fading.
*/
private int mCoveredFadeColor = DEFAULT_FADE_COLOR;
/** /**
* The size of the overhang in pixels. * The size of the overhang in pixels.
*/ */
private int mPanelHeight = -1; private int mPanelHeight = -1;
/** /**
* The size of the shadow in pixels. * The size of the shadow in pixels.
*/ */
private int mShadowHeight = -1; private int mShadowHeight = -1;
/** /**
* Paralax offset * Paralax offset
*/ */
private int mParallaxOffset = -1; private int mParallaxOffset = -1;
/** /**
* True if the collapsed panel should be dragged up. * True if the collapsed panel should be dragged up.
*/ */
private boolean mIsSlidingUp; private boolean mIsSlidingUp;
/** /**
* Panel overlays the windows instead of putting it underneath it. * Panel overlays the windows instead of putting it underneath it.
*/ */
private boolean mOverlayContent = DEFAULT_OVERLAY_FLAG; private boolean mOverlayContent = DEFAULT_OVERLAY_FLAG;
/** /**
* If provided, the panel can be dragged by only this view. Otherwise, the entire panel can be * If provided, the panel can be dragged by only this view. Otherwise, the entire panel can be
* used for dragging. * used for dragging.
*/ */
private View mDragView; private View mDragView;
/** /**
* If provided, the panel can be dragged by only this view. Otherwise, the entire panel can be * If provided, the panel can be dragged by only this view. Otherwise, the entire panel can be
* used for dragging. * used for dragging.
*/ */
private int mDragViewResId = -1; private int mDragViewResId = -1;
/** /**
* The child view that can slide, if any. * The child view that can slide, if any.
*/ */
private View mSlideableView; private View mSlideableView;
/** /**
* The main view * The main view
*/ */
private View mMainView; private View mMainView;
/**
* Current state of the slideable view.
*/
private enum SlideState {
EXPANDED,
COLLAPSED,
ANCHORED,
HIDDEN,
DRAGGING
}
private SlideState mSlideState = SlideState.COLLAPSED; private SlideState mSlideState = SlideState.COLLAPSED;
/** /**
* How far the panel is offset from its expanded position. * How far the panel is offset from its expanded position.
* range [0, 1] where 0 = collapsed, 1 = expanded. * range [0, 1] where 0 = collapsed, 1 = expanded.
*/ */
private float mSlideOffset; private float mSlideOffset;
/** /**
* How far in pixels the slideable panel may move. * How far in pixels the slideable panel may move.
*/ */
private int mSlideRange; private int mSlideRange;
/** /**
* A panel view is locked into internal scrolling or another condition that * A panel view is locked into internal scrolling or another condition that
* is preventing a drag. * is preventing a drag.
*/ */
private boolean mIsUnableToDrag; private boolean mIsUnableToDrag;
/** /**
* Flag indicating that sliding feature is enabled\disabled * Flag indicating that sliding feature is enabled\disabled
*/ */
private boolean mIsSlidingEnabled; private boolean mIsSlidingEnabled;
/** /**
* Flag indicating if a drag view can have its own touch events. If set * Flag indicating if a drag view can have its own touch events. If set
* to true, a drag view can scroll horizontally and have its own click listener. * to true, a drag view can scroll horizontally and have its own click listener.
* * <p>
* Default is set to false. * Default is set to false.
*/ */
private boolean mIsUsingDragViewTouchEvents; private boolean mIsUsingDragViewTouchEvents;
private float mInitialMotionX; private float mInitialMotionX;
private float mInitialMotionY; private float mInitialMotionY;
private float mAnchorPoint = 1.f; private float mAnchorPoint = 1.f;
private PanelSlideListener mPanelSlideListener; private PanelSlideListener mPanelSlideListener;
private final ViewDragHelper mDragHelper;
/** /**
* Stores whether or not the pane was expanded the last time it was slideable. * Stores whether or not the pane was expanded the last time it was slideable.
* If expand/collapse operations are invoked this state is modified. Used by * If expand/collapse operations are invoked this state is modified. Used by
...@@ -192,43 +155,6 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -192,43 +155,6 @@ public class SlidingUpPanelLayout extends ViewGroup {
*/ */
private boolean mFirstLayout = true; private boolean mFirstLayout = true;
private final Rect mTmpRect = new Rect();
/**
* Listener for monitoring events about sliding panes.
*/
public interface PanelSlideListener {
/**
* Called when a sliding pane's position changes.
* @param panel The child view that was moved
* @param slideOffset The new offset of this sliding pane within its range, from 0-1
*/
public void onPanelSlide(View panel, float slideOffset);
/**
* Called when a sliding panel becomes slid completely collapsed.
* @param panel The child view that was slid to an collapsed position
*/
public void onPanelCollapsed(View panel);
/**
* Called when a sliding panel becomes slid completely expanded.
* @param panel The child view that was slid to a expanded position
*/
public void onPanelExpanded(View panel);
/**
* Called when a sliding panel becomes anchored.
* @param panel The child view that was slid to a anchored position
*/
public void onPanelAnchored(View panel);
/**
* Called when a sliding panel becomes completely hidden.
* @param panel The child view that was slid to a hidden position
*/
public void onPanelHidden(View panel);
}
public SlidingUpPanelLayout(Context context) { public SlidingUpPanelLayout(Context context) {
this(context, null); this(context, null);
} }
...@@ -240,7 +166,7 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -240,7 +166,7 @@ public class SlidingUpPanelLayout extends ViewGroup {
public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) { public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle); super(context, attrs, defStyle);
if(isInEditMode()) { if (isInEditMode()) {
mShadowDrawable = null; mShadowDrawable = null;
mDragHelper = null; mDragHelper = null;
return; return;
...@@ -271,7 +197,7 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -271,7 +197,7 @@ public class SlidingUpPanelLayout extends ViewGroup {
mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_dragView, -1); mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_dragView, -1);
mOverlayContent = ta.getBoolean(R.styleable.SlidingUpPanelLayout_overlay,DEFAULT_OVERLAY_FLAG); mOverlayContent = ta.getBoolean(R.styleable.SlidingUpPanelLayout_overlay, DEFAULT_OVERLAY_FLAG);
mAnchorPoint = ta.getFloat(R.styleable.SlidingUpPanelLayout_anchorPoint, DEFAULT_ANCHOR_POINT); mAnchorPoint = ta.getFloat(R.styleable.SlidingUpPanelLayout_anchorPoint, DEFAULT_ANCHOR_POINT);
...@@ -311,6 +237,11 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -311,6 +237,11 @@ public class SlidingUpPanelLayout extends ViewGroup {
mIsSlidingEnabled = true; mIsSlidingEnabled = true;
} }
private static boolean hasOpaqueBackground(View v) {
final Drawable bg = v.getBackground();
return bg != null && bg.getOpacity() == PixelFormat.OPAQUE;
}
/** /**
* Set the Drag View after the view is inflated * Set the Drag View after the view is inflated
*/ */
...@@ -326,6 +257,13 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -326,6 +257,13 @@ public class SlidingUpPanelLayout extends ViewGroup {
return mIsSlidingEnabled && mSlideableView != null; return mIsSlidingEnabled && mSlideableView != null;
} }
/**
* @return The current collapsed panel height
*/
public int getPanelHeight() {
return mPanelHeight;
}
/** /**
* Set the collapsed panel height in pixels * Set the collapsed panel height in pixels
* *
...@@ -338,24 +276,18 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -338,24 +276,18 @@ public class SlidingUpPanelLayout extends ViewGroup {
onPanelDragged(newTop); onPanelDragged(newTop);
} }
/**
* @return The current collapsed panel height
*/
public int getPanelHeight() {
return mPanelHeight;
}
/** /**
* @return The current paralax offset * @return The current paralax offset
*/ */
public int getCurrentParalaxOffset() { public int getCurrentParalaxOffset() {
// Clamp slide offset at zero for parallax computation; // Clamp slide offset at zero for parallax computation;
int offset = (int)(mParallaxOffset * Math.max(mSlideOffset, 0)); int offset = (int) (mParallaxOffset * Math.max(mSlideOffset, 0));
return mIsSlidingUp ? -offset : offset; return mIsSlidingUp ? -offset : offset;
} }
/** /**
* Sets the panel slide listener * Sets the panel slide listener
*
* @param listener * @param listener
*/ */
public void setPanelSlideListener(PanelSlideListener listener) { public void setPanelSlideListener(PanelSlideListener listener) {
...@@ -386,7 +318,8 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -386,7 +318,8 @@ public class SlidingUpPanelLayout extends ViewGroup {
collapsePanel(); collapsePanel();
} }
} }
});; });
;
} }
} }
...@@ -480,11 +413,6 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -480,11 +413,6 @@ public class SlidingUpPanelLayout extends ViewGroup {
} }
} }
private static boolean hasOpaqueBackground(View v) {
final Drawable bg = v.getBackground();
return bg != null && bg.getOpacity() == PixelFormat.OPAQUE;
}
@Override @Override
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
super.onAttachedToWindow(); super.onAttachedToWindow();
...@@ -684,7 +612,7 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -684,7 +612,7 @@ public class SlidingUpPanelLayout extends ViewGroup {
return super.onInterceptTouchEvent(ev); return super.onInterceptTouchEvent(ev);
} }
if ((ady > dragSlop && adx > ady) || !isDragViewUnder((int)mInitialMotionX, (int)mInitialMotionY)) { if ((ady > dragSlop && adx > ady) || !isDragViewUnder((int) mInitialMotionX, (int) mInitialMotionY)) {
mDragHelper.cancel(); mDragHelper.cancel();
mIsUnableToDrag = true; mIsUnableToDrag = true;
return false; return false;
...@@ -814,7 +742,7 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -814,7 +742,7 @@ public class SlidingUpPanelLayout extends ViewGroup {
// height of the main content // height of the main content
if (mSlideOffset <= 0 && !mOverlayContent) { if (mSlideOffset <= 0 && !mOverlayContent) {
// expand the main view // expand the main view
LayoutParams lp = (LayoutParams)mMainView.getLayoutParams(); LayoutParams lp = (LayoutParams) mMainView.getLayoutParams();
lp.height = mIsSlidingUp ? (newTop - getPaddingBottom()) : (getHeight() - getPaddingBottom() - mSlideableView.getMeasuredHeight() - newTop); lp.height = mIsSlidingUp ? (newTop - getPaddingBottom()) : (getHeight() - getPaddingBottom() - mSlideableView.getMeasuredHeight() - newTop);
mMainView.requestLayout(); mMainView.requestLayout();
} }
...@@ -913,7 +841,6 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -913,7 +841,6 @@ public class SlidingUpPanelLayout extends ViewGroup {
} }
} }
@Override @Override
protected ViewGroup.LayoutParams generateDefaultLayoutParams() { protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
return new LayoutParams(); return new LayoutParams();
...@@ -953,6 +880,119 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -953,6 +880,119 @@ public class SlidingUpPanelLayout extends ViewGroup {
mSlideState = ss.mSlideState; mSlideState = ss.mSlideState;
} }
/**
* Current state of the slideable view.
*/
private enum SlideState {
EXPANDED,
COLLAPSED,
ANCHORED,
HIDDEN,
DRAGGING
}
/**
* Listener for monitoring events about sliding panes.
*/
public interface PanelSlideListener {
/**
* Called when a sliding pane's position changes.
*
* @param panel The child view that was moved
* @param slideOffset The new offset of this sliding pane within its range, from 0-1
*/
public void onPanelSlide(View panel, float slideOffset);
/**
* Called when a sliding panel becomes slid completely collapsed.
*
* @param panel The child view that was slid to an collapsed position
*/
public void onPanelCollapsed(View panel);
/**
* Called when a sliding panel becomes slid completely expanded.
*
* @param panel The child view that was slid to a expanded position
*/
public void onPanelExpanded(View panel);
/**
* Called when a sliding panel becomes anchored.
*
* @param panel The child view that was slid to a anchored position
*/
public void onPanelAnchored(View panel);
/**
* Called when a sliding panel becomes completely hidden.
*
* @param panel The child view that was slid to a hidden position
*/
public void onPanelHidden(View panel);
}
public static class LayoutParams extends ViewGroup.MarginLayoutParams {
private static final int[] ATTRS = new int[]{
android.R.attr.layout_weight
};
public LayoutParams() {
super(MATCH_PARENT, MATCH_PARENT);
}
public LayoutParams(android.view.ViewGroup.LayoutParams source) {
super(source);
}
public LayoutParams(MarginLayoutParams source) {
super(source);
}
public LayoutParams(Context c, AttributeSet attrs) {
super(c, attrs);
final TypedArray a = c.obtainStyledAttributes(attrs, ATTRS);
a.recycle();
}
}
static class SavedState extends BaseSavedState {
public static final Parcelable.Creator<SavedState> CREATOR =
new Parcelable.Creator<SavedState>() {
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
@Override
public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
SlideState mSlideState;
SavedState(Parcelable superState) {
super(superState);
}
private SavedState(Parcel in) {
super(in);
try {
mSlideState = Enum.valueOf(SlideState.class, in.readString());
} catch (IllegalArgumentException e) {
mSlideState = SlideState.COLLAPSED;
}
}
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeString(mSlideState.toString());
}
}
private class DragHelperCallback extends ViewDragHelper.Callback { private class DragHelperCallback extends ViewDragHelper.Callback {
@Override @Override
...@@ -1051,66 +1091,4 @@ public class SlidingUpPanelLayout extends ViewGroup { ...@@ -1051,66 +1091,4 @@ public class SlidingUpPanelLayout extends ViewGroup {
} }
} }
} }
public static class LayoutParams extends ViewGroup.MarginLayoutParams {
private static final int[] ATTRS = new int[] {
android.R.attr.layout_weight
};
public LayoutParams() {
super(MATCH_PARENT, MATCH_PARENT);
}
public LayoutParams(android.view.ViewGroup.LayoutParams source) {
super(source);
}
public LayoutParams(MarginLayoutParams source) {
super(source);
}
public LayoutParams(Context c, AttributeSet attrs) {
super(c, attrs);
final TypedArray a = c.obtainStyledAttributes(attrs, ATTRS);
a.recycle();
}
}
static class SavedState extends BaseSavedState {
SlideState mSlideState;
SavedState(Parcelable superState) {
super(superState);
}
private SavedState(Parcel in) {
super(in);
try {
mSlideState = Enum.valueOf(SlideState.class, in.readString());
} catch (IllegalArgumentException e) {
mSlideState = SlideState.COLLAPSED;
}
}
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeString(mSlideState.toString());
}
public static final Parcelable.Creator<SavedState> CREATOR =
new Parcelable.Creator<SavedState>() {
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
@Override
public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
}
} }
...@@ -93,13 +93,21 @@ public class ViewDragHelper { ...@@ -93,13 +93,21 @@ public class ViewDragHelper {
private static final int BASE_SETTLE_DURATION = 256; // ms private static final int BASE_SETTLE_DURATION = 256; // ms
private static final int MAX_SETTLE_DURATION = 600; // ms private static final int MAX_SETTLE_DURATION = 600; // ms
/**
* Interpolator defining the animation curve for mScroller
*/
private static final Interpolator sInterpolator = new Interpolator() {
public float getInterpolation(float t) {
t -= 1.0f;
return t * t * t * t * t + 1.0f;
}
};
private final Callback mCallback;
private final ViewGroup mParentView;
// Current drag state; idle, dragging or settling // Current drag state; idle, dragging or settling
private int mDragState; private int mDragState;
// Distance to travel before a drag may begin // Distance to travel before a drag may begin
private int mTouchSlop; private int mTouchSlop;
// Last known position/pointer tracking // Last known position/pointer tracking
private int mActivePointerId = INVALID_POINTER; private int mActivePointerId = INVALID_POINTER;
private float[] mInitialMotionX; private float[] mInitialMotionX;
...@@ -110,220 +118,48 @@ public class ViewDragHelper { ...@@ -110,220 +118,48 @@ public class ViewDragHelper {
private int[] mEdgeDragsInProgress; private int[] mEdgeDragsInProgress;
private int[] mEdgeDragsLocked; private int[] mEdgeDragsLocked;
private int mPointersDown; private int mPointersDown;
private VelocityTracker mVelocityTracker; private VelocityTracker mVelocityTracker;
private float mMaxVelocity; private float mMaxVelocity;
private float mMinVelocity; private float mMinVelocity;
private int mEdgeSize; private int mEdgeSize;
private int mTrackingEdges; private int mTrackingEdges;
private ScrollerCompat mScroller; private ScrollerCompat mScroller;
private final Callback mCallback;
private View mCapturedView; private View mCapturedView;
private boolean mReleaseInProgress; private final Runnable mSetIdleRunnable = new Runnable() {
public void run() {
private final ViewGroup mParentView; setDragState(STATE_IDLE);
/**
* A Callback is used as a communication channel with the ViewDragHelper back to the
* parent view using it. <code>on*</code>methods are invoked on siginficant events and several
* accessor methods are expected to provide the ViewDragHelper with more information
* about the state of the parent view upon request. The callback also makes decisions
* governing the range and draggability of child views.
*/
public static abstract class Callback {
/**
* Called when the drag state changes. See the <code>STATE_*</code> constants
* for more information.
*
* @param state The new drag state
*
* @see #STATE_IDLE
* @see #STATE_DRAGGING
* @see #STATE_SETTLING
*/
public void onViewDragStateChanged(int state) {}
/**
* Called when the captured view's position changes as the result of a drag or settle.
*
* @param changedView View whose position changed
* @param left New X coordinate of the left edge of the view
* @param top New Y coordinate of the top edge of the view
* @param dx Change in X position from the last call
* @param dy Change in Y position from the last call
*/
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {}
/**
* Called when a child view is captured for dragging or settling. The ID of the pointer
* currently dragging the captured view is supplied. If activePointerId is
* identified as {@link #INVALID_POINTER} the capture is programmatic instead of
* pointer-initiated.
*
* @param capturedChild Child view that was captured
* @param activePointerId Pointer id tracking the child capture
*/
public void onViewCaptured(View capturedChild, int activePointerId) {}
/**
* Called when the child view is no longer being actively dragged.
* The fling velocity is also supplied, if relevant. The velocity values may
* be clamped to system minimums or maximums.
*
* <p>Calling code may decide to fling or otherwise release the view to let it
* settle into place. It should do so using {@link #settleCapturedViewAt(int, int)}
* or {@link #flingCapturedView(int, int, int, int)}. If the Callback invokes
* one of these methods, the ViewDragHelper will enter {@link #STATE_SETTLING}
* and the view capture will not fully end until it comes to a complete stop.
* If neither of these methods is invoked before <code>onViewReleased</code> returns,
* the view will stop in place and the ViewDragHelper will return to
* {@link #STATE_IDLE}.</p>
*
* @param releasedChild The captured child view now being released
* @param xvel X velocity of the pointer as it left the screen in pixels per second.
* @param yvel Y velocity of the pointer as it left the screen in pixels per second.
*/
public void onViewReleased(View releasedChild, float xvel, float yvel) {}
/**
* Called when one of the subscribed edges in the parent view has been touched
* by the user while no child view is currently captured.
*
* @param edgeFlags A combination of edge flags describing the edge(s) currently touched
* @param pointerId ID of the pointer touching the described edge(s)
* @see #EDGE_LEFT
* @see #EDGE_TOP
* @see #EDGE_RIGHT
* @see #EDGE_BOTTOM
*/
public void onEdgeTouched(int edgeFlags, int pointerId) {}
/**
* Called when the given edge may become locked. This can happen if an edge drag
* was preliminarily rejected before beginning, but after {@link #onEdgeTouched(int, int)}
* was called. This method should return true to lock this edge or false to leave it
* unlocked. The default behavior is to leave edges unlocked.
*
* @param edgeFlags A combination of edge flags describing the edge(s) locked
* @return true to lock the edge, false to leave it unlocked
*/
public boolean onEdgeLock(int edgeFlags) {
return false;
}
/**
* Called when the user has started a deliberate drag away from one
* of the subscribed edges in the parent view while no child view is currently captured.
*
* @param edgeFlags A combination of edge flags describing the edge(s) dragged
* @param pointerId ID of the pointer touching the described edge(s)
* @see #EDGE_LEFT
* @see #EDGE_TOP
* @see #EDGE_RIGHT
* @see #EDGE_BOTTOM
*/
public void onEdgeDragStarted(int edgeFlags, int pointerId) {}
/**
* Called to determine the Z-order of child views.
*
* @param index the ordered position to query for
* @return index of the view that should be ordered at position <code>index</code>
*/
public int getOrderedChildIndex(int index) {
return index;
}
/**
* Return the magnitude of a draggable child view's horizontal range of motion in pixels.
* This method should return 0 for views that cannot move horizontally.
*
* @param child Child view to check
* @return range of horizontal motion in pixels
*/
public int getViewHorizontalDragRange(View child) {
return 0;
} }
};
private boolean mReleaseInProgress;
/** /**
* Return the magnitude of a draggable child view's vertical range of motion in pixels. * Apps should use ViewDragHelper.create() to get a new instance.
* This method should return 0 for views that cannot move vertically. * This will allow VDH to use internal compatibility implementations for different
* platform versions.
* *
* @param child Child view to check * @param context Context to initialize config-dependent params from
* @return range of vertical motion in pixels * @param forParent Parent view to monitor
*/ */
public int getViewVerticalDragRange(View child) { private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
return 0; if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
} }
if (cb == null) {
/** throw new IllegalArgumentException("Callback may not be null");
* Called when the user's input indicates that they want to capture the given child view
* with the pointer indicated by pointerId. The callback should return true if the user
* is permitted to drag the given view with the indicated pointer.
*
* <p>ViewDragHelper may call this method multiple times for the same view even if
* the view is already captured; this indicates that a new pointer is trying to take
* control of the view.</p>
*
* <p>If this method returns true, a call to {@link #onViewCaptured(android.view.View, int)}
* will follow if the capture is successful.</p>
*
* @param child Child the user is attempting to capture
* @param pointerId ID of the pointer attempting the capture
* @return true if capture should be allowed, false otherwise
*/
public abstract boolean tryCaptureView(View child, int pointerId);
/**
* Restrict the motion of the dragged child view along the horizontal axis.
* The default implementation does not allow horizontal motion; the extending
* class must override this method and provide the desired clamping.
*
*
* @param child Child view being dragged
* @param left Attempted motion along the X axis
* @param dx Proposed change in position for left
* @return The new clamped position for left
*/
public int clampViewPositionHorizontal(View child, int left, int dx) {
return 0;
} }
/** mParentView = forParent;
* Restrict the motion of the dragged child view along the vertical axis. mCallback = cb;
* The default implementation does not allow vertical motion; the extending
* class must override this method and provide the desired clamping.
*
*
* @param child Child view being dragged
* @param top Attempted motion along the Y axis
* @param dy Proposed change in position for top
* @return The new clamped position for top
*/
public int clampViewPositionVertical(View child, int top, int dy) {
return 0;
}
}
/** final ViewConfiguration vc = ViewConfiguration.get(context);
* Interpolator defining the animation curve for mScroller final float density = context.getResources().getDisplayMetrics().density;
*/ mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
private static final Interpolator sInterpolator = new Interpolator() {
public float getInterpolation(float t) {
t -= 1.0f;
return t * t * t * t * t + 1.0f;
}
};
private final Runnable mSetIdleRunnable = new Runnable() { mTouchSlop = vc.getScaledTouchSlop();
public void run() { mMaxVelocity = vc.getScaledMaximumFlingVelocity();
setDragState(STATE_IDLE); mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
} }
};
/** /**
* Factory method to create a new ViewDragHelper. * Factory method to create a new ViewDragHelper.
...@@ -351,35 +187,6 @@ public class ViewDragHelper { ...@@ -351,35 +187,6 @@ public class ViewDragHelper {
return helper; return helper;
} }
/**
* Apps should use ViewDragHelper.create() to get a new instance.
* This will allow VDH to use internal compatibility implementations for different
* platform versions.
*
* @param context Context to initialize config-dependent params from
* @param forParent Parent view to monitor
*/
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
}
if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
}
mParentView = forParent;
mCallback = cb;
final ViewConfiguration vc = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
mTouchSlop = vc.getScaledTouchSlop();
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
}
/** /**
* Set the minimum velocity that will be detected as having a magnitude greater than zero * Set the minimum velocity that will be detected as having a magnitude greater than zero
* in pixels per second. Callback methods accepting a velocity will be clamped appropriately. * in pixels per second. Callback methods accepting a velocity will be clamped appropriately.
...@@ -393,6 +200,7 @@ public class ViewDragHelper { ...@@ -393,6 +200,7 @@ public class ViewDragHelper {
/** /**
* Retrieve the current drag state of this helper. This will return one of * Retrieve the current drag state of this helper. This will return one of
* {@link #STATE_IDLE}, {@link #STATE_DRAGGING} or {@link #STATE_SETTLING}. * {@link #STATE_IDLE}, {@link #STATE_DRAGGING} or {@link #STATE_SETTLING}.
*
* @return The current drag state * @return The current drag state
*/ */
public int getViewDragState() { public int getViewDragState() {
...@@ -462,7 +270,7 @@ public class ViewDragHelper { ...@@ -462,7 +270,7 @@ public class ViewDragHelper {
* If this method returns true, the caller should invoke {@link #continueSettling(boolean)} * If this method returns true, the caller should invoke {@link #continueSettling(boolean)}
* on each subsequent frame to continue the motion until it returns false. If this method * on each subsequent frame to continue the motion until it returns false. If this method
* returns false there is no further work to do to complete the movement. * returns false there is no further work to do to complete the movement.
* * <p>
* <p>This operation does not count as a capture event, though {@link #getCapturedView()} * <p>This operation does not count as a capture event, though {@link #getCapturedView()}
* will still report the sliding view while the slide is in progress.</p> * will still report the sliding view while the slide is in progress.</p>
* *
...@@ -758,7 +566,7 @@ public class ViewDragHelper { ...@@ -758,7 +566,7 @@ public class ViewDragHelper {
/** /**
* Check if the given pointer ID represents a pointer that is currently down (to the best * Check if the given pointer ID represents a pointer that is currently down (to the best
* of the ViewDragHelper's knowledge). * of the ViewDragHelper's knowledge).
* * <p>
* <p>The state used to report this information is populated by the methods * <p>The state used to report this information is populated by the methods
* {@link #shouldInterceptTouchEvent(android.view.MotionEvent)} or * {@link #shouldInterceptTouchEvent(android.view.MotionEvent)} or
* {@link #processTouchEvent(android.view.MotionEvent)}. If one of these methods has not * {@link #processTouchEvent(android.view.MotionEvent)}. If one of these methods has not
...@@ -886,7 +694,7 @@ public class ViewDragHelper { ...@@ -886,7 +694,7 @@ public class ViewDragHelper {
break; break;
} }
final View toCapture = findTopChildUnder((int)mInitialMotionX[pointerId], (int)mInitialMotionY[pointerId]); final View toCapture = findTopChildUnder((int) mInitialMotionX[pointerId], (int) mInitialMotionY[pointerId]);
if (toCapture != null && checkTouchSlop(toCapture, dx, dy) && if (toCapture != null && checkTouchSlop(toCapture, dx, dy) &&
tryCaptureViewForDrag(toCapture, pointerId)) { tryCaptureViewForDrag(toCapture, pointerId)) {
break; break;
...@@ -1229,4 +1037,189 @@ public class ViewDragHelper { ...@@ -1229,4 +1037,189 @@ public class ViewDragHelper {
return result; return result;
} }
/**
* A Callback is used as a communication channel with the ViewDragHelper back to the
* parent view using it. <code>on*</code>methods are invoked on siginficant events and several
* accessor methods are expected to provide the ViewDragHelper with more information
* about the state of the parent view upon request. The callback also makes decisions
* governing the range and draggability of child views.
*/
public static abstract class Callback {
/**
* Called when the drag state changes. See the <code>STATE_*</code> constants
* for more information.
*
* @param state The new drag state
* @see #STATE_IDLE
* @see #STATE_DRAGGING
* @see #STATE_SETTLING
*/
public void onViewDragStateChanged(int state) {
}
/**
* Called when the captured view's position changes as the result of a drag or settle.
*
* @param changedView View whose position changed
* @param left New X coordinate of the left edge of the view
* @param top New Y coordinate of the top edge of the view
* @param dx Change in X position from the last call
* @param dy Change in Y position from the last call
*/
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
}
/**
* Called when a child view is captured for dragging or settling. The ID of the pointer
* currently dragging the captured view is supplied. If activePointerId is
* identified as {@link #INVALID_POINTER} the capture is programmatic instead of
* pointer-initiated.
*
* @param capturedChild Child view that was captured
* @param activePointerId Pointer id tracking the child capture
*/
public void onViewCaptured(View capturedChild, int activePointerId) {
}
/**
* Called when the child view is no longer being actively dragged.
* The fling velocity is also supplied, if relevant. The velocity values may
* be clamped to system minimums or maximums.
* <p>
* <p>Calling code may decide to fling or otherwise release the view to let it
* settle into place. It should do so using {@link #settleCapturedViewAt(int, int)}
* or {@link #flingCapturedView(int, int, int, int)}. If the Callback invokes
* one of these methods, the ViewDragHelper will enter {@link #STATE_SETTLING}
* and the view capture will not fully end until it comes to a complete stop.
* If neither of these methods is invoked before <code>onViewReleased</code> returns,
* the view will stop in place and the ViewDragHelper will return to
* {@link #STATE_IDLE}.</p>
*
* @param releasedChild The captured child view now being released
* @param xvel X velocity of the pointer as it left the screen in pixels per second.
* @param yvel Y velocity of the pointer as it left the screen in pixels per second.
*/
public void onViewReleased(View releasedChild, float xvel, float yvel) {
}
/**
* Called when one of the subscribed edges in the parent view has been touched
* by the user while no child view is currently captured.
*
* @param edgeFlags A combination of edge flags describing the edge(s) currently touched
* @param pointerId ID of the pointer touching the described edge(s)
* @see #EDGE_LEFT
* @see #EDGE_TOP
* @see #EDGE_RIGHT
* @see #EDGE_BOTTOM
*/
public void onEdgeTouched(int edgeFlags, int pointerId) {
}
/**
* Called when the given edge may become locked. This can happen if an edge drag
* was preliminarily rejected before beginning, but after {@link #onEdgeTouched(int, int)}
* was called. This method should return true to lock this edge or false to leave it
* unlocked. The default behavior is to leave edges unlocked.
*
* @param edgeFlags A combination of edge flags describing the edge(s) locked
* @return true to lock the edge, false to leave it unlocked
*/
public boolean onEdgeLock(int edgeFlags) {
return false;
}
/**
* Called when the user has started a deliberate drag away from one
* of the subscribed edges in the parent view while no child view is currently captured.
*
* @param edgeFlags A combination of edge flags describing the edge(s) dragged
* @param pointerId ID of the pointer touching the described edge(s)
* @see #EDGE_LEFT
* @see #EDGE_TOP
* @see #EDGE_RIGHT
* @see #EDGE_BOTTOM
*/
public void onEdgeDragStarted(int edgeFlags, int pointerId) {
}
/**
* Called to determine the Z-order of child views.
*
* @param index the ordered position to query for
* @return index of the view that should be ordered at position <code>index</code>
*/
public int getOrderedChildIndex(int index) {
return index;
}
/**
* Return the magnitude of a draggable child view's horizontal range of motion in pixels.
* This method should return 0 for views that cannot move horizontally.
*
* @param child Child view to check
* @return range of horizontal motion in pixels
*/
public int getViewHorizontalDragRange(View child) {
return 0;
}
/**
* Return the magnitude of a draggable child view's vertical range of motion in pixels.
* This method should return 0 for views that cannot move vertically.
*
* @param child Child view to check
* @return range of vertical motion in pixels
*/
public int getViewVerticalDragRange(View child) {
return 0;
}
/**
* Called when the user's input indicates that they want to capture the given child view
* with the pointer indicated by pointerId. The callback should return true if the user
* is permitted to drag the given view with the indicated pointer.
* <p>
* <p>ViewDragHelper may call this method multiple times for the same view even if
* the view is already captured; this indicates that a new pointer is trying to take
* control of the view.</p>
* <p>
* <p>If this method returns true, a call to {@link #onViewCaptured(android.view.View, int)}
* will follow if the capture is successful.</p>
*
* @param child Child the user is attempting to capture
* @param pointerId ID of the pointer attempting the capture
* @return true if capture should be allowed, false otherwise
*/
public abstract boolean tryCaptureView(View child, int pointerId);
/**
* Restrict the motion of the dragged child view along the horizontal axis.
* The default implementation does not allow horizontal motion; the extending
* class must override this method and provide the desired clamping.
*
* @param child Child view being dragged
* @param left Attempted motion along the X axis
* @param dx Proposed change in position for left
* @return The new clamped position for left
*/
public int clampViewPositionHorizontal(View child, int left, int dx) {
return 0;
}
/**
* Restrict the motion of the dragged child view along the vertical axis.
* The default implementation does not allow vertical motion; the extending
* class must override this method and provide the desired clamping.
*
* @param child Child view being dragged
* @param top Attempted motion along the Y axis
* @param dy Proposed change in position for top
* @return The new clamped position for top
*/
public int clampViewPositionVertical(View child, int top, int dy) {
return 0;
}
}
} }
\ No newline at end of file
...@@ -23,9 +23,6 @@ import android.view.MotionEvent; ...@@ -23,9 +23,6 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.animation.BounceInterpolator; import android.view.animation.BounceInterpolator;
import app.insti.R.drawable;
import app.insti.fragment.MapFragment;
import com.mrane.campusmap.SettingsManager; import com.mrane.campusmap.SettingsManager;
import com.mrane.data.Building; import com.mrane.data.Building;
import com.mrane.data.Marker; import com.mrane.data.Marker;
...@@ -37,7 +34,15 @@ import java.util.Collection; ...@@ -37,7 +34,15 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import app.insti.R.drawable;
import app.insti.fragment.MapFragment;
public class CampusMapView extends SubsamplingScaleImageView { public class CampusMapView extends SubsamplingScaleImageView {
private static int RATIO_SHOW_PIN = 10;
private static int RATIO_SHOW_PIN_TEXT = 20;
private static long DURATION_MARKER_ANIMATION = 500;
private static long DELAY_MARKER_ANIMATION = 675;
private static float MAX_SCALE = 1F;
private MapFragment mainActivity; private MapFragment mainActivity;
private HashMap<String, Marker> data; private HashMap<String, Marker> data;
private Collection<Marker> markerList; private Collection<Marker> markerList;
...@@ -65,11 +70,6 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -65,11 +70,6 @@ public class CampusMapView extends SubsamplingScaleImageView {
private Paint textPaint; private Paint textPaint;
private Paint strokePaint; private Paint strokePaint;
private Rect bounds = new Rect(); private Rect bounds = new Rect();
private static int RATIO_SHOW_PIN = 10;
private static int RATIO_SHOW_PIN_TEXT = 20;
private static long DURATION_MARKER_ANIMATION = 500;
private static long DELAY_MARKER_ANIMATION = 675;
private static float MAX_SCALE = 1F;
private DisplayMetrics displayMetrics; private DisplayMetrics displayMetrics;
private float density; private float density;
private boolean isFirstLoad = true; private boolean isFirstLoad = true;
...@@ -84,6 +84,22 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -84,6 +84,22 @@ public class CampusMapView extends SubsamplingScaleImageView {
initialise(); initialise();
} }
public static int getShowPinRatio() {
return RATIO_SHOW_PIN;
}
public static void setShowPinRatio(int ratio) {
RATIO_SHOW_PIN = ratio;
}
public static int getShowPinTextRatio() {
return RATIO_SHOW_PIN_TEXT;
}
public static void setShowPinTextRatio(int ratio) {
RATIO_SHOW_PIN_TEXT = ratio;
}
private void initialise() { private void initialise() {
displayMetrics = getResources().getDisplayMetrics(); displayMetrics = getResources().getDisplayMetrics();
density = displayMetrics.density; density = displayMetrics.density;
...@@ -115,7 +131,7 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -115,7 +131,7 @@ public class CampusMapView extends SubsamplingScaleImageView {
} }
} }
public void setSettingsManager(SettingsManager sm){ public void setSettingsManager(SettingsManager sm) {
settingsManager = sm; settingsManager = sm;
} }
...@@ -158,7 +174,7 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -158,7 +174,7 @@ public class CampusMapView extends SubsamplingScaleImageView {
drawable.marker_gray_s, options); drawable.marker_gray_s, options);
grayLockedMarker = BitmapFactory.decodeResource(getResources(), grayLockedMarker = BitmapFactory.decodeResource(getResources(),
drawable.marker_gray_h, options); drawable.marker_gray_h, options);
w = pointerWidth*density; w = pointerWidth * density;
h = bluePointer.getScaledHeight(displayMetrics) * (w / bluePointer.getScaledWidth(displayMetrics)); h = bluePointer.getScaledHeight(displayMetrics) * (w / bluePointer.getScaledWidth(displayMetrics));
bluePointer = Bitmap.createScaledBitmap(bluePointer, (int) w, (int) h, bluePointer = Bitmap.createScaledBitmap(bluePointer, (int) w, (int) h,
...@@ -245,35 +261,19 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -245,35 +261,19 @@ public class CampusMapView extends SubsamplingScaleImageView {
} }
} }
public static int getShowPinRatio() {
return RATIO_SHOW_PIN;
}
public static void setShowPinRatio(int ratio) {
RATIO_SHOW_PIN = ratio;
}
public static int getShowPinTextRatio() {
return RATIO_SHOW_PIN_TEXT;
}
public static void setShowPinTextRatio(int ratio) {
RATIO_SHOW_PIN_TEXT = ratio;
}
public Marker getResultMarker() { public Marker getResultMarker() {
return resultMarker; return resultMarker;
} }
public void setResultMarker(Marker marker) {
resultMarker = marker;
}
@Deprecated @Deprecated
public Marker getHighlightedMarker() { public Marker getHighlightedMarker() {
return getResultMarker(); return getResultMarker();
} }
public void setResultMarker(Marker marker) {
resultMarker = marker;
}
public boolean isResultMarker(Marker marker) { public boolean isResultMarker(Marker marker) {
if (resultMarker == null) if (resultMarker == null)
return false; return false;
...@@ -411,7 +411,7 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -411,7 +411,7 @@ public class CampusMapView extends SubsamplingScaleImageView {
private boolean shouldShowUp(Marker marker) { private boolean shouldShowUp(Marker marker) {
boolean result = true; boolean result = true;
if(marker.getGroupIndex() == Marker.RESIDENCES){ if (marker.getGroupIndex() == Marker.RESIDENCES) {
result = settingsManager.showResidences(); result = settingsManager.showResidences();
} }
if (marker instanceof Building) { if (marker instanceof Building) {
...@@ -464,7 +464,7 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -464,7 +464,7 @@ public class CampusMapView extends SubsamplingScaleImageView {
else else
name = marker.getShortName(); name = marker.getShortName();
Paint temp = new Paint(textPaint); Paint temp = new Paint(textPaint);
if(marker.getGroupIndex() == Marker.RESIDENCES) temp.setTextSize(12*density); if (marker.getGroupIndex() == Marker.RESIDENCES) temp.setTextSize(12 * density);
textPaint.getTextBounds(name, 0, name.length() - 1, bounds); textPaint.getTextBounds(name, 0, name.length() - 1, bounds);
float tX = vPin.x + pin.getWidth(); float tX = vPin.x + pin.getWidth();
float tY = vPin.y + bounds.height() / 2; float tY = vPin.y + bounds.height() / 2;
...@@ -531,9 +531,9 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -531,9 +531,9 @@ public class CampusMapView extends SubsamplingScaleImageView {
if (color == Marker.COLOR_BLUE) { if (color == Marker.COLOR_BLUE) {
markerBitmap = blueMarker; markerBitmap = blueMarker;
if (isAddedMarker(marker)){ if (isAddedMarker(marker)) {
markerBitmap = blueLockedMarker; markerBitmap = blueLockedMarker;
if(convoMarkerList.contains(marker)) markerBitmap = blueConvoMarker; if (convoMarkerList.contains(marker)) markerBitmap = blueConvoMarker;
} }
} else if (color == Marker.COLOR_YELLOW) { } else if (color == Marker.COLOR_YELLOW) {
markerBitmap = yellowMarker; markerBitmap = yellowMarker;
...@@ -607,7 +607,7 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -607,7 +607,7 @@ public class CampusMapView extends SubsamplingScaleImageView {
valAnim.start(); valAnim.start();
} }
public Runnable getScaleAnim(final float scale){ public Runnable getScaleAnim(final float scale) {
Runnable anim = new Runnable() { Runnable anim = new Runnable() {
public void run() { public void run() {
AnimationBuilder animation = animateScale(scale); AnimationBuilder animation = animateScale(scale);
...@@ -623,7 +623,7 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -623,7 +623,7 @@ public class CampusMapView extends SubsamplingScaleImageView {
@Override @Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) { protected void onSizeChanged(int w, int h, int oldw, int oldh) {
if(getTargetMinScale() > getScale()){ if (getTargetMinScale() > getScale()) {
setScaleAndCenter(getTargetMinScale(), getCenter()); setScaleAndCenter(getTargetMinScale(), getCenter());
} }
super.onSizeChanged(w, h, oldw, oldh); super.onSizeChanged(w, h, oldw, oldh);
...@@ -656,16 +656,14 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -656,16 +656,14 @@ public class CampusMapView extends SubsamplingScaleImageView {
public boolean onTouch(View view, MotionEvent motionEvent) { public boolean onTouch(View view, MotionEvent motionEvent) {
final float targetMinScale = getTargetMinScale(); final float targetMinScale = getTargetMinScale();
int action = motionEvent.getAction(); int action = motionEvent.getAction();
if(action== MotionEvent.ACTION_DOWN){ if (action == MotionEvent.ACTION_DOWN) {
if(motionEvent.getX()<20*density){ if (motionEvent.getX() < 20 * density) {
getParent().requestDisallowInterceptTouchEvent(false); getParent().requestDisallowInterceptTouchEvent(false);
return true; return true;
} } else {
else{
// CampusMapView.this.setPanEnabled(true); // CampusMapView.this.setPanEnabled(true);
} }
} } else if (action == MotionEvent.ACTION_UP) {
else if(action == MotionEvent.ACTION_UP){
CampusMapView.this.setPanEnabled(true); CampusMapView.this.setPanEnabled(true);
} }
if (targetMinScale > getScale()) { if (targetMinScale > getScale()) {
...@@ -674,7 +672,7 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -674,7 +672,7 @@ public class CampusMapView extends SubsamplingScaleImageView {
if (action == MotionEvent.ACTION_UP) { if (action == MotionEvent.ACTION_UP) {
Runnable anim = getScaleAnim(targetMinScale); Runnable anim = getScaleAnim(targetMinScale);
if(isImageReady()) anim.run(); if (isImageReady()) anim.run();
} }
return true; return true;
} }
......
...@@ -44,8 +44,6 @@ import android.view.GestureDetector; ...@@ -44,8 +44,6 @@ import android.view.GestureDetector;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import app.insti.R.styleable;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
...@@ -53,141 +51,139 @@ import java.util.LinkedHashMap; ...@@ -53,141 +51,139 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import app.insti.R.styleable;
/** /**
* Displays an image subsampled as necessary to avoid loading too much image data into memory. After a pinch to zoom in, * Displays an image subsampled as necessary to avoid loading too much image data into memory. After a pinch to zoom in,
* a set of image tiles subsampled at higher resolution are loaded and displayed over the base layer. During pinch and * a set of image tiles subsampled at higher resolution are loaded and displayed over the base layer. During pinch and
* zoom, tiles off screen or higher/lower resolution than required are discarded from memory. * zoom, tiles off screen or higher/lower resolution than required are discarded from memory.
* * <p>
* Tiles over 2048px are not used due to hardware rendering limitations. * Tiles over 2048px are not used due to hardware rendering limitations.
* * <p>
* This view will not work very well with images that are far larger in one dimension than the other because the tile grid * This view will not work very well with images that are far larger in one dimension than the other because the tile grid
* for each subsampling level has the same number of rows as columns, so each tile has the same width:height ratio as * for each subsampling level has the same number of rows as columns, so each tile has the same width:height ratio as
* the source image. This could result in image data totalling several times the screen area being loaded. * the source image. This could result in image data totalling several times the screen area being loaded.
* * <p>
* v prefixes - coordinates, translations and distances measured in screen (view) pixels * v prefixes - coordinates, translations and distances measured in screen (view) pixels
* s prefixes - coordinates, translations and distances measured in source image pixels (scaled) * s prefixes - coordinates, translations and distances measured in source image pixels (scaled)
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class SubsamplingScaleImageView extends View { public class SubsamplingScaleImageView extends View {
private static final String TAG = SubsamplingScaleImageView.class.getSimpleName(); /**
* Attempt to use EXIF information on the image to rotate it. Works for external files only.
/** Attempt to use EXIF information on the image to rotate it. Works for external files only. */ */
public static final int ORIENTATION_USE_EXIF = -1; public static final int ORIENTATION_USE_EXIF = -1;
/** Display the image file in its native orientation. */ /**
* Display the image file in its native orientation.
*/
public static final int ORIENTATION_0 = 0; public static final int ORIENTATION_0 = 0;
/** Rotate the image 90 degrees clockwise. */ /**
* Rotate the image 90 degrees clockwise.
*/
public static final int ORIENTATION_90 = 90; public static final int ORIENTATION_90 = 90;
/** Rotate the image 180 degrees. */ /**
* Rotate the image 180 degrees.
*/
public static final int ORIENTATION_180 = 180; public static final int ORIENTATION_180 = 180;
/** Rotate the image 270 degrees clockwise. */ /**
* Rotate the image 270 degrees clockwise.
*/
public static final int ORIENTATION_270 = 270; public static final int ORIENTATION_270 = 270;
/**
private static final List<Integer> VALID_ORIENTATIONS = Arrays.asList(ORIENTATION_0, ORIENTATION_90, ORIENTATION_180, ORIENTATION_270, ORIENTATION_USE_EXIF); * During zoom animation, keep the point of the image that was tapped in the same place, and scale the image around it.
*/
/** During zoom animation, keep the point of the image that was tapped in the same place, and scale the image around it. */
public static final int ZOOM_FOCUS_FIXED = 1; public static final int ZOOM_FOCUS_FIXED = 1;
/** During zoom animation, move the point of the image that was tapped to the center of the screen. */ /**
* During zoom animation, move the point of the image that was tapped to the center of the screen.
*/
public static final int ZOOM_FOCUS_CENTER = 2; public static final int ZOOM_FOCUS_CENTER = 2;
/** Zoom in to and center the tapped point immediately without animating. */ /**
* Zoom in to and center the tapped point immediately without animating.
*/
public static final int ZOOM_FOCUS_CENTER_IMMEDIATE = 3; public static final int ZOOM_FOCUS_CENTER_IMMEDIATE = 3;
/**
private static final List<Integer> VALID_ZOOM_STYLES = Arrays.asList(ZOOM_FOCUS_FIXED, ZOOM_FOCUS_CENTER, ZOOM_FOCUS_CENTER_IMMEDIATE); * Quadratic ease out. Not recommended for scale animation, but good for panning.
*/
/** Quadratic ease out. Not recommended for scale animation, but good for panning. */
public static final int EASE_OUT_QUAD = 1; public static final int EASE_OUT_QUAD = 1;
/** Quadratic ease in and out. */ /**
* Quadratic ease in and out.
*/
public static final int EASE_IN_OUT_QUAD = 2; public static final int EASE_IN_OUT_QUAD = 2;
/**
private static final List<Integer> VALID_EASING_STYLES = Arrays.asList(EASE_IN_OUT_QUAD, EASE_OUT_QUAD); * Don't allow the image to be panned off screen. As much of the image as possible is always displayed, centered in the view when it is smaller. This is the best option for galleries.
*/
/** Don't allow the image to be panned off screen. As much of the image as possible is always displayed, centered in the view when it is smaller. This is the best option for galleries. */
public static final int PAN_LIMIT_INSIDE = 1; public static final int PAN_LIMIT_INSIDE = 1;
/** Allows the image to be panned until it is just off screen, but no further. The edge of the image will stop when it is flush with the screen edge. */ /**
* Allows the image to be panned until it is just off screen, but no further. The edge of the image will stop when it is flush with the screen edge.
*/
public static final int PAN_LIMIT_OUTSIDE = 2; public static final int PAN_LIMIT_OUTSIDE = 2;
/** Allows the image to be panned until a corner reaches the center of the screen but no further. Useful when you want to pan any spot on the image to the exact center of the screen. */ /**
* Allows the image to be panned until a corner reaches the center of the screen but no further. Useful when you want to pan any spot on the image to the exact center of the screen.
*/
public static final int PAN_LIMIT_CUSTOM = 3; public static final int PAN_LIMIT_CUSTOM = 3;
private static final String TAG = SubsamplingScaleImageView.class.getSimpleName();
private static final List<Integer> VALID_ORIENTATIONS = Arrays.asList(ORIENTATION_0, ORIENTATION_90, ORIENTATION_180, ORIENTATION_270, ORIENTATION_USE_EXIF);
private static final List<Integer> VALID_ZOOM_STYLES = Arrays.asList(ZOOM_FOCUS_FIXED, ZOOM_FOCUS_CENTER, ZOOM_FOCUS_CENTER_IMMEDIATE);
private static final List<Integer> VALID_EASING_STYLES = Arrays.asList(EASE_IN_OUT_QUAD, EASE_OUT_QUAD);
private static final List<Integer> VALID_PAN_LIMITS = Arrays.asList(PAN_LIMIT_INSIDE, PAN_LIMIT_OUTSIDE, PAN_LIMIT_CUSTOM); private static final List<Integer> VALID_PAN_LIMITS = Arrays.asList(PAN_LIMIT_INSIDE, PAN_LIMIT_OUTSIDE, PAN_LIMIT_CUSTOM);
private static final int MESSAGE_LONG_CLICK = 1;
private final Object decoderLock = new Object();
// Overlay tile boundaries and other info // Overlay tile boundaries and other info
private boolean debug = false; private boolean debug = false;
// Image orientation setting // Image orientation setting
private int orientation = ORIENTATION_0; private int orientation = ORIENTATION_0;
// Max scale allowed (prevent infinite zoom) // Max scale allowed (prevent infinite zoom)
private float maxScale = 2F; private float maxScale = 2F;
// Density to reach before loading higher resolution tiles // Density to reach before loading higher resolution tiles
private int minimumTileDpi = -1; private int minimumTileDpi = -1;
// Pan limiting style // Pan limiting style
private int panLimit = PAN_LIMIT_INSIDE; private int panLimit = PAN_LIMIT_INSIDE;
// Gesture detection settings // Gesture detection settings
private boolean panEnabled = true; private boolean panEnabled = true;
private boolean zoomEnabled = true; private boolean zoomEnabled = true;
// Double tap zoom behaviour // Double tap zoom behaviour
private float doubleTapZoomScale = 1F; private float doubleTapZoomScale = 1F;
private int doubleTapZoomStyle = ZOOM_FOCUS_FIXED; private int doubleTapZoomStyle = ZOOM_FOCUS_FIXED;
// Current scale and scale at start of zoom // Current scale and scale at start of zoom
private float scale; private float scale;
private float scaleStart; private float scaleStart;
// Screen coordinate of top-left corner of source image // Screen coordinate of top-left corner of source image
private PointF vTranslate; private PointF vTranslate;
private PointF vTranslateStart; private PointF vTranslateStart;
// Source coordinate to center on, used when new position is set externally before view is ready // Source coordinate to center on, used when new position is set externally before view is ready
private Float pendingScale; private Float pendingScale;
private PointF sPendingCenter; private PointF sPendingCenter;
private PointF sRequestedCenter; private PointF sRequestedCenter;
// Source image dimensions and orientation - dimensions relate to the unrotated image // Source image dimensions and orientation - dimensions relate to the unrotated image
private int sWidth; private int sWidth;
private int sHeight; private int sHeight;
private int sOrientation; private int sOrientation;
// Is two-finger zooming in progress // Is two-finger zooming in progress
private boolean isZooming; private boolean isZooming;
// Is one-finger panning in progress // Is one-finger panning in progress
private boolean isPanning; private boolean isPanning;
// Max touches used in current gesture // Max touches used in current gesture
private int maxTouchCount; private int maxTouchCount;
// Fling detector // Fling detector
private GestureDetector detector; private GestureDetector detector;
// Tile decoder // Tile decoder
private BitmapRegionDecoder decoder; private BitmapRegionDecoder decoder;
private final Object decoderLock = new Object();
// Sample size used to display the whole image when fully zoomed out // Sample size used to display the whole image when fully zoomed out
private int fullImageSampleSize; private int fullImageSampleSize;
// Map of zoom level to tile grid // Map of zoom level to tile grid
private Map<Integer, List<Tile>> tileMap; private Map<Integer, List<Tile>> tileMap;
// Debug values // Debug values
private PointF vCenterStart; private PointF vCenterStart;
private float vDistStart; private float vDistStart;
// Scale and center animation tracking // Scale and center animation tracking
private Anim anim; private Anim anim;
// Whether a ready notification has been sent to subclasses // Whether a ready notification has been sent to subclasses
private boolean readySent = false; private boolean readySent = false;
// Long click listener // Long click listener
private OnLongClickListener onLongClickListener; private OnLongClickListener onLongClickListener;
// Long click handler // Long click handler
private Handler handler; private Handler handler;
private static final int MESSAGE_LONG_CLICK = 1;
// Paint objects created once and reused for efficiency // Paint objects created once and reused for efficiency
private Paint bitmapPaint; private Paint bitmapPaint;
private Paint debugPaint; private Paint debugPaint;
...@@ -212,8 +208,8 @@ public class SubsamplingScaleImageView extends View { ...@@ -212,8 +208,8 @@ public class SubsamplingScaleImageView extends View {
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (panEnabled && readySent && vTranslate != null && (Math.abs(e1.getX() - e2.getX()) > 50 || Math.abs(e1.getY() - e2.getY()) > 50) && (Math.abs(velocityX) > 500 || Math.abs(velocityY) > 500) && !isZooming) { if (panEnabled && readySent && vTranslate != null && (Math.abs(e1.getX() - e2.getX()) > 50 || Math.abs(e1.getY() - e2.getY()) > 50) && (Math.abs(velocityX) > 500 || Math.abs(velocityY) > 500) && !isZooming) {
PointF vTranslateEnd = new PointF(vTranslate.x + (velocityX * 0.25f), vTranslate.y + (velocityY * 0.25f)); PointF vTranslateEnd = new PointF(vTranslate.x + (velocityX * 0.25f), vTranslate.y + (velocityY * 0.25f));
float sCenterXEnd = ((getWidth()/2) - vTranslateEnd.x)/scale; float sCenterXEnd = ((getWidth() / 2) - vTranslateEnd.x) / scale;
float sCenterYEnd = ((getHeight()/2) - vTranslateEnd.y)/scale; float sCenterYEnd = ((getHeight() / 2) - vTranslateEnd.y) / scale;
new AnimationBuilder(new PointF(sCenterXEnd, sCenterYEnd)).withEasing(EASE_OUT_QUAD).withPanLimited(false).start(); new AnimationBuilder(new PointF(sCenterXEnd, sCenterYEnd)).withEasing(EASE_OUT_QUAD).withPanLimited(false).start();
return true; return true;
} }
...@@ -270,22 +266,9 @@ public class SubsamplingScaleImageView extends View { ...@@ -270,22 +266,9 @@ public class SubsamplingScaleImageView extends View {
this(context, null); this(context, null);
} }
/**
* Sets the image orientation. It's best to call this before setting the image file or asset, because it may waste
* loading of tiles. However, this can be freely called at any time.
*/
public final void setOrientation(int orientation) {
if (!VALID_ORIENTATIONS.contains(orientation)) {
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
this.orientation = orientation;
reset(false);
invalidate();
requestLayout();
}
/** /**
* Display an image from a file in internal or external storage. * Display an image from a file in internal or external storage.
*
* @param extFile URI of the file to display. * @param extFile URI of the file to display.
*/ */
public final void setImageFile(String extFile) { public final void setImageFile(String extFile) {
...@@ -299,6 +282,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -299,6 +282,7 @@ public class SubsamplingScaleImageView extends View {
* Display an image from a file in internal or external storage, starting with a given orientation setting, scale * Display an image from a file in internal or external storage, starting with a given orientation setting, scale
* and center. This is the best method to use when you want scale and center to be restored after screen orientation * and center. This is the best method to use when you want scale and center to be restored after screen orientation
* change; it avoids any redundant loading of tiles in the wrong orientation. * change; it avoids any redundant loading of tiles in the wrong orientation.
*
* @param extFile URI of the file to display. * @param extFile URI of the file to display.
* @param state State to be restored. Nullable. * @param state State to be restored. Nullable.
*/ */
...@@ -312,6 +296,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -312,6 +296,7 @@ public class SubsamplingScaleImageView extends View {
/** /**
* Display an image from a file in assets. * Display an image from a file in assets.
*
* @param assetName asset name. * @param assetName asset name.
*/ */
public final void setImageAsset(String assetName) { public final void setImageAsset(String assetName) {
...@@ -322,6 +307,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -322,6 +307,7 @@ public class SubsamplingScaleImageView extends View {
* Display an image from a file in assets, starting with a given orientation setting, scale and center. This is the * Display an image from a file in assets, starting with a given orientation setting, scale and center. This is the
* best method to use when you want scale and center to be restored after screen orientation change; it avoids any * best method to use when you want scale and center to be restored after screen orientation change; it avoids any
* redundant loading of tiles in the wrong orientation. * redundant loading of tiles in the wrong orientation.
*
* @param assetName asset name. * @param assetName asset name.
* @param state State to be restored. Nullable. * @param state State to be restored. Nullable.
*/ */
...@@ -406,9 +392,9 @@ public class SubsamplingScaleImageView extends View { ...@@ -406,9 +392,9 @@ public class SubsamplingScaleImageView extends View {
width = sWidth(); width = sWidth();
height = sHeight(); height = sHeight();
} else if (resizeHeight) { } else if (resizeHeight) {
height = (int)((((double)sHeight()/(double)sWidth()) * width)); height = (int) ((((double) sHeight() / (double) sWidth()) * width));
} else if (resizeWidth) { } else if (resizeWidth) {
width = (int)((((double)sWidth()/(double)sHeight()) * height)); width = (int) ((((double) sWidth() / (double) sHeight()) * height));
} }
} }
width = Math.max(width, getSuggestedMinimumWidth()); width = Math.max(width, getSuggestedMinimumWidth());
...@@ -455,7 +441,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -455,7 +441,7 @@ public class SubsamplingScaleImageView extends View {
scaleStart = scale; scaleStart = scale;
vDistStart = distance; vDistStart = distance;
vTranslateStart = new PointF(vTranslate.x, vTranslate.y); vTranslateStart = new PointF(vTranslate.x, vTranslate.y);
vCenterStart = new PointF((event.getX(0) + event.getX(1))/2, (event.getY(0) + event.getY(1))/2); vCenterStart = new PointF((event.getX(0) + event.getX(1)) / 2, (event.getY(0) + event.getY(1)) / 2);
} else { } else {
// Abort all gestures on second touch // Abort all gestures on second touch
maxTouchCount = 0; maxTouchCount = 0;
...@@ -477,7 +463,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -477,7 +463,7 @@ public class SubsamplingScaleImageView extends View {
if (touchCount >= 2) { if (touchCount >= 2) {
// Calculate new distance between touch points, to scale and pan relative to start values. // Calculate new distance between touch points, to scale and pan relative to start values.
vDistEnd = distance(event.getX(0), event.getX(1), event.getY(0), event.getY(1)); vDistEnd = distance(event.getX(0), event.getX(1), event.getY(0), event.getY(1));
vCenterEnd = new PointF((event.getX(0) + event.getX(1))/2, (event.getY(0) + event.getY(1))/2); vCenterEnd = new PointF((event.getX(0) + event.getX(1)) / 2, (event.getY(0) + event.getY(1)) / 2);
if (zoomEnabled && (distance(vCenterStart.x, vCenterEnd.x, vCenterStart.y, vCenterEnd.y) > 5 || Math.abs(vDistEnd - vDistStart) > 5 || isPanning)) { if (zoomEnabled && (distance(vCenterStart.x, vCenterEnd.x, vCenterStart.y, vCenterEnd.y) > 5 || Math.abs(vDistEnd - vDistStart) > 5 || isPanning)) {
isZooming = true; isZooming = true;
...@@ -497,18 +483,18 @@ public class SubsamplingScaleImageView extends View { ...@@ -497,18 +483,18 @@ public class SubsamplingScaleImageView extends View {
// at the center of the pinch now, to give simultaneous pan + zoom. // at the center of the pinch now, to give simultaneous pan + zoom.
float vLeftStart = vCenterStart.x - vTranslateStart.x; float vLeftStart = vCenterStart.x - vTranslateStart.x;
float vTopStart = vCenterStart.y - vTranslateStart.y; float vTopStart = vCenterStart.y - vTranslateStart.y;
float vLeftNow = vLeftStart * (scale/scaleStart); float vLeftNow = vLeftStart * (scale / scaleStart);
float vTopNow = vTopStart * (scale/scaleStart); float vTopNow = vTopStart * (scale / scaleStart);
vTranslate.x = vCenterEnd.x - vLeftNow; vTranslate.x = vCenterEnd.x - vLeftNow;
vTranslate.y = vCenterEnd.y - vTopNow; vTranslate.y = vCenterEnd.y - vTopNow;
} else if (sRequestedCenter != null) { } else if (sRequestedCenter != null) {
// With a center specified from code, zoom around that point. // With a center specified from code, zoom around that point.
vTranslate.x = (getWidth()/2) - (scale * sRequestedCenter.x); vTranslate.x = (getWidth() / 2) - (scale * sRequestedCenter.x);
vTranslate.y = (getHeight()/2) - (scale * sRequestedCenter.y); vTranslate.y = (getHeight() / 2) - (scale * sRequestedCenter.y);
} else { } else {
// With no requested center, scale around the image center. // With no requested center, scale around the image center.
vTranslate.x = (getWidth()/2) - (scale * (sWidth()/2)); vTranslate.x = (getWidth() / 2) - (scale * (sWidth() / 2));
vTranslate.y = (getHeight()/2) - (scale * (sHeight()/2)); vTranslate.y = (getHeight() / 2) - (scale * (sHeight() / 2));
} }
fitToBounds(true); fitToBounds(true);
...@@ -618,8 +604,8 @@ public class SubsamplingScaleImageView extends View { ...@@ -618,8 +604,8 @@ public class SubsamplingScaleImageView extends View {
// If waiting to translate to new center position, set translate now // If waiting to translate to new center position, set translate now
if (sPendingCenter != null && pendingScale != null) { if (sPendingCenter != null && pendingScale != null) {
scale = pendingScale; scale = pendingScale;
vTranslate.x = (getWidth()/2) - (scale * sPendingCenter.x); vTranslate.x = (getWidth() / 2) - (scale * sPendingCenter.x);
vTranslate.y = (getHeight()/2) - (scale * sPendingCenter.y); vTranslate.y = (getHeight() / 2) - (scale * sPendingCenter.y);
sPendingCenter = null; sPendingCenter = null;
pendingScale = null; pendingScale = null;
fitToBounds(true); fitToBounds(true);
...@@ -711,7 +697,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -711,7 +697,7 @@ public class SubsamplingScaleImageView extends View {
canvas.drawCircle(vCenterStart.x, vCenterStart.y, 10, debugPaint); canvas.drawCircle(vCenterStart.x, vCenterStart.y, 10, debugPaint);
canvas.drawCircle(vCenterEndRequested.x, vCenterEndRequested.y, 20, debugPaint); canvas.drawCircle(vCenterEndRequested.x, vCenterEndRequested.y, 20, debugPaint);
canvas.drawCircle(vCenterEnd.x, vCenterEnd.y, 25, debugPaint); canvas.drawCircle(vCenterEnd.x, vCenterEnd.y, 25, debugPaint);
canvas.drawCircle(getWidth()/2, getHeight()/2, 30, debugPaint); canvas.drawCircle(getWidth() / 2, getHeight() / 2, 30, debugPaint);
} }
} }
} }
...@@ -765,6 +751,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -765,6 +751,7 @@ public class SubsamplingScaleImageView extends View {
/** /**
* Loads the optimum tiles for display at the current scale and translate, so the screen can be filled with tiles * Loads the optimum tiles for display at the current scale and translate, so the screen can be filled with tiles
* that are at least as high resolution as the screen. Frees up bitmaps that are now off the screen. * that are at least as high resolution as the screen. Frees up bitmaps that are now off the screen.
*
* @param load Whether to load the new tiles needed. Use false while scrolling/panning for performance. * @param load Whether to load the new tiles needed. Use false while scrolling/panning for performance.
*/ */
private void refreshRequiredTiles(boolean load) { private void refreshRequiredTiles(boolean load) {
...@@ -812,12 +799,12 @@ public class SubsamplingScaleImageView extends View { ...@@ -812,12 +799,12 @@ public class SubsamplingScaleImageView extends View {
float adjustedScale = scale; float adjustedScale = scale;
if (minimumTileDpi > 0) { if (minimumTileDpi > 0) {
DisplayMetrics metrics = getResources().getDisplayMetrics(); DisplayMetrics metrics = getResources().getDisplayMetrics();
float averageDpi = (metrics.xdpi + metrics.ydpi)/2; float averageDpi = (metrics.xdpi + metrics.ydpi) / 2;
adjustedScale = (minimumTileDpi/averageDpi) * scale; adjustedScale = (minimumTileDpi / averageDpi) * scale;
} }
int reqWidth = (int)(sWidth() * adjustedScale); int reqWidth = (int) (sWidth() * adjustedScale);
int reqHeight = (int)(sHeight() * adjustedScale); int reqHeight = (int) (sHeight() * adjustedScale);
// Raw height and width of image // Raw height and width of image
int inSampleSize = 1; int inSampleSize = 1;
...@@ -850,6 +837,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -850,6 +837,7 @@ public class SubsamplingScaleImageView extends View {
* Adjusts hypothetical future scale and translate values to keep scale within the allowed range and the image on screen. Minimum scale * Adjusts hypothetical future scale and translate values to keep scale within the allowed range and the image on screen. Minimum scale
* is set so one dimension fills the view and the image is centered on the other dimension. Used to calculate what the target of an * is set so one dimension fills the view and the image is centered on the other dimension. Used to calculate what the target of an
* animation should be. * animation should be.
*
* @param center Whether the image should be centered in the dimension it's too small to fill. While animating this can be false to avoid changes in direction as bounds are reached. * @param center Whether the image should be centered in the dimension it's too small to fill. While animating this can be false to avoid changes in direction as bounds are reached.
* @param scaleAndTranslate The scale we want and the translation we're aiming for. The values are adjusted to be valid. * @param scaleAndTranslate The scale we want and the translation we're aiming for. The values are adjusted to be valid.
*/ */
...@@ -865,7 +853,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -865,7 +853,7 @@ public class SubsamplingScaleImageView extends View {
if (panLimit == PAN_LIMIT_CUSTOM && isImageReady()) { if (panLimit == PAN_LIMIT_CUSTOM && isImageReady()) {
vTranslate.x = Math.max(vTranslate.x, getWidth() - scaleWidth); vTranslate.x = Math.max(vTranslate.x, getWidth() - scaleWidth);
vTranslate.y = Math.max(vTranslate.y, 9*getHeight()/10 - scaleHeight); vTranslate.y = Math.max(vTranslate.y, 9 * getHeight() / 10 - scaleHeight);
} else if (center) { } else if (center) {
vTranslate.x = Math.max(vTranslate.x, getWidth() - scaleWidth); vTranslate.x = Math.max(vTranslate.x, getWidth() - scaleWidth);
vTranslate.y = Math.max(vTranslate.y, getHeight() - scaleHeight); vTranslate.y = Math.max(vTranslate.y, getHeight() - scaleHeight);
...@@ -878,7 +866,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -878,7 +866,7 @@ public class SubsamplingScaleImageView extends View {
float maxTy; float maxTy;
if (panLimit == PAN_LIMIT_CUSTOM && isImageReady()) { if (panLimit == PAN_LIMIT_CUSTOM && isImageReady()) {
maxTx = Math.max(0, 0); maxTx = Math.max(0, 0);
maxTy = Math.max(0, getHeight()/10); maxTy = Math.max(0, getHeight() / 10);
} else if (center) { } else if (center) {
maxTx = Math.max(0, (getWidth() - scaleWidth) / 2); maxTx = Math.max(0, (getWidth() - scaleWidth) / 2);
maxTy = Math.max(0, (getHeight() - scaleHeight) / 2); maxTy = Math.max(0, (getHeight() - scaleHeight) / 2);
...@@ -896,6 +884,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -896,6 +884,7 @@ public class SubsamplingScaleImageView extends View {
/** /**
* Adjusts current scale and translate values to keep scale within the allowed range and the image on screen. Minimum scale * Adjusts current scale and translate values to keep scale within the allowed range and the image on screen. Minimum scale
* is set so one dimension fills the view and the image is centered on the other dimension. * is set so one dimension fills the view and the image is centered on the other dimension.
*
* @param center Whether the image should be centered in the dimension it's too small to fill. While animating this can be false to avoid changes in direction as bounds are reached. * @param center Whether the image should be centered in the dimension it's too small to fill. While animating this can be false to avoid changes in direction as bounds are reached.
*/ */
private void fitToBounds(boolean center) { private void fitToBounds(boolean center) {
...@@ -916,19 +905,19 @@ public class SubsamplingScaleImageView extends View { ...@@ -916,19 +905,19 @@ public class SubsamplingScaleImageView extends View {
int xTiles = 1; int xTiles = 1;
int yTiles = 1; int yTiles = 1;
while (true) { while (true) {
int sTileWidth = sWidth()/xTiles; int sTileWidth = sWidth() / xTiles;
int sTileHeight = sHeight()/yTiles; int sTileHeight = sHeight() / yTiles;
int subTileWidth = sTileWidth/sampleSize; int subTileWidth = sTileWidth / sampleSize;
int subTileHeight = sTileHeight/sampleSize; int subTileHeight = sTileHeight / sampleSize;
while (subTileWidth > maxTileDimensions.x || (subTileWidth > getWidth() * 1.25 && sampleSize < fullImageSampleSize)) { while (subTileWidth > maxTileDimensions.x || (subTileWidth > getWidth() * 1.25 && sampleSize < fullImageSampleSize)) {
xTiles += 1; xTiles += 1;
sTileWidth = sWidth()/xTiles; sTileWidth = sWidth() / xTiles;
subTileWidth = sTileWidth/sampleSize; subTileWidth = sTileWidth / sampleSize;
} }
while (subTileHeight > maxTileDimensions.y || (subTileHeight > getHeight() * 1.25 && sampleSize < fullImageSampleSize)) { while (subTileHeight > maxTileDimensions.y || (subTileHeight > getHeight() * 1.25 && sampleSize < fullImageSampleSize)) {
yTiles += 1; yTiles += 1;
sTileHeight = sHeight()/yTiles; sTileHeight = sHeight() / yTiles;
subTileHeight = sTileHeight/sampleSize; subTileHeight = sTileHeight / sampleSize;
} }
List<Tile> tileGrid = new ArrayList<Tile>(xTiles * yTiles); List<Tile> tileGrid = new ArrayList<Tile>(xTiles * yTiles);
for (int x = 0; x < xTiles; x++) { for (int x = 0; x < xTiles; x++) {
...@@ -973,172 +962,6 @@ public class SubsamplingScaleImageView extends View { ...@@ -973,172 +962,6 @@ public class SubsamplingScaleImageView extends View {
invalidate(); invalidate();
} }
/**
* Async task used to get image details without blocking the UI thread.
*/
private static class BitmapInitTask extends AsyncTask<Void, Void, int[]> {
private final WeakReference<SubsamplingScaleImageView> viewRef;
private final WeakReference<Context> contextRef;
private final String source;
private final boolean sourceIsAsset;
private BitmapRegionDecoder decoder;
public BitmapInitTask(SubsamplingScaleImageView view, Context context, String source, boolean sourceIsAsset) {
this.viewRef = new WeakReference<SubsamplingScaleImageView>(view);
this.contextRef = new WeakReference<Context>(context);
this.source = source;
this.sourceIsAsset = sourceIsAsset;
}
@Override
protected int[] doInBackground(Void... params) {
try {
if (viewRef != null && contextRef != null) {
Context context = contextRef.get();
if (context != null) {
int exifOrientation = ORIENTATION_0;
if (sourceIsAsset) {
decoder = BitmapRegionDecoder.newInstance(context.getAssets().open(source, AssetManager.ACCESS_RANDOM), true);
} else {
decoder = BitmapRegionDecoder.newInstance(source, true);
try {
ExifInterface exifInterface = new ExifInterface(source);
int orientationAttr = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
if (orientationAttr == ExifInterface.ORIENTATION_NORMAL) {
exifOrientation = ORIENTATION_0;
} else if (orientationAttr == ExifInterface.ORIENTATION_ROTATE_90) {
exifOrientation = ORIENTATION_90;
} else if (orientationAttr == ExifInterface.ORIENTATION_ROTATE_180) {
exifOrientation = ORIENTATION_180;
} else if (orientationAttr == ExifInterface.ORIENTATION_ROTATE_270) {
exifOrientation = ORIENTATION_270;
} else {
Log.w(TAG, "Unsupported EXIF orientation: " + orientationAttr);
}
} catch (Exception e) {
Log.w(TAG, "Could not get EXIF orientation of image");
}
}
return new int[] { decoder.getWidth(), decoder.getHeight(), exifOrientation };
}
}
} catch (Exception e) {
Log.e(TAG, "Failed to initialise bitmap decoder", e);
}
return null;
}
@Override
protected void onPostExecute(int[] xyo) {
if (viewRef != null && decoder != null) {
final SubsamplingScaleImageView subsamplingScaleImageView = viewRef.get();
if (subsamplingScaleImageView != null && decoder != null && xyo != null && xyo.length == 3) {
subsamplingScaleImageView.onImageInited(decoder, xyo[0], xyo[1], xyo[2]);
}
}
}
}
/**
* Async task used to load images without blocking the UI thread.
*/
private static class BitmapTileTask extends AsyncTask<Void, Void, Bitmap> {
private final WeakReference<SubsamplingScaleImageView> viewRef;
private final WeakReference<BitmapRegionDecoder> decoderRef;
private final WeakReference<Object> decoderLockRef;
private final WeakReference<Tile> tileRef;
public BitmapTileTask(SubsamplingScaleImageView view, BitmapRegionDecoder decoder, Object decoderLock, Tile tile) {
this.viewRef = new WeakReference<SubsamplingScaleImageView>(view);
this.decoderRef = new WeakReference<BitmapRegionDecoder>(decoder);
this.decoderLockRef = new WeakReference<Object>(decoderLock);
this.tileRef = new WeakReference<Tile>(tile);
tile.loading = true;
}
@Override
protected Bitmap doInBackground(Void... params) {
try {
if (decoderRef != null && tileRef != null && viewRef != null) {
final BitmapRegionDecoder decoder = decoderRef.get();
final Object decoderLock = decoderLockRef.get();
final Tile tile = tileRef.get();
final SubsamplingScaleImageView view = viewRef.get();
if (decoder != null && decoderLock != null && tile != null && view != null && !decoder.isRecycled()) {
synchronized (decoderLock) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = tile.sampleSize;
options.inPreferredConfig = Config.RGB_565;
options.inDither = true;
Bitmap bitmap = decoder.decodeRegion(view.fileSRect(tile.sRect), options);
int rotation = view.getRequiredRotation();
if (rotation != 0) {
Matrix matrix = new Matrix();
matrix.postRotate(rotation);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}
return bitmap;
}
} else if (tile != null) {
tile.loading = false;
}
}
} catch (Exception e) {
Log.e(TAG, "Failed to decode tile", e);
}
return null;
}
@Override
protected void onPostExecute(Bitmap bitmap) {
if (viewRef != null && tileRef != null && bitmap != null) {
final SubsamplingScaleImageView subsamplingScaleImageView = viewRef.get();
final Tile tile = tileRef.get();
if (subsamplingScaleImageView != null && tile != null) {
tile.bitmap = bitmap;
tile.loading = false;
subsamplingScaleImageView.onTileLoaded();
}
}
}
}
private static class Tile {
private Rect sRect;
private int sampleSize;
private Bitmap bitmap;
private boolean loading;
private boolean visible;
}
private static class Anim {
private float scaleStart; // Scale at start of anim
private float scaleEnd; // Scale at end of anim (target)
private PointF sCenterStart; // Source center point at start
private PointF sCenterEnd; // Source center point at end, adjusted for pan limits
private PointF sCenterEndRequested; // Source center point that was requested, without adjustment
private PointF vFocusStart; // View point that was double tapped
private PointF vFocusEnd; // Where the view focal point should be moved to during the anim
private long duration = 500; // How long the anim takes
private boolean interruptible = true; // Whether the anim can be interrupted by a touch
private int easing = EASE_IN_OUT_QUAD; // Easing style
private long time = System.currentTimeMillis(); // Start time
}
private static class ScaleAndTranslate {
private ScaleAndTranslate(float scale, PointF translate) {
this.scale = scale;
this.translate = translate;
}
private float scale;
private PointF translate;
}
/** /**
* Set scale, center and orientation from saved state. * Set scale, center and orientation from saved state.
*/ */
...@@ -1157,8 +980,8 @@ public class SubsamplingScaleImageView extends View { ...@@ -1157,8 +980,8 @@ public class SubsamplingScaleImageView extends View {
private Point getMaxBitmapDimensions(Canvas canvas) { private Point getMaxBitmapDimensions(Canvas canvas) {
if (VERSION.SDK_INT >= 14) { if (VERSION.SDK_INT >= 14) {
try { try {
int maxWidth = (Integer)Canvas.class.getMethod("getMaximumBitmapWidth").invoke(canvas); int maxWidth = (Integer) Canvas.class.getMethod("getMaximumBitmapWidth").invoke(canvas);
int maxHeight = (Integer)Canvas.class.getMethod("getMaximumBitmapHeight").invoke(canvas); int maxHeight = (Integer) Canvas.class.getMethod("getMaximumBitmapHeight").invoke(canvas);
return new Point(maxWidth, maxHeight); return new Point(maxWidth, maxHeight);
} catch (Exception e) { } catch (Exception e) {
// Return default // Return default
...@@ -1224,7 +1047,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1224,7 +1047,7 @@ public class SubsamplingScaleImageView extends View {
private float distance(float x0, float x1, float y0, float y1) { private float distance(float x0, float x1, float y0, float y1) {
float x = x0 - x1; float x = x0 - x1;
float y = y0 - y1; float y = y0 - y1;
return (float)Math.sqrt(x * x + y * y); return (float) Math.sqrt(x * x + y * y);
} }
/** /**
...@@ -1241,8 +1064,8 @@ public class SubsamplingScaleImageView extends View { ...@@ -1241,8 +1064,8 @@ public class SubsamplingScaleImageView extends View {
if (vTranslate == null) { if (vTranslate == null) {
return null; return null;
} }
float sx = (vx - vTranslate.x)/scale; float sx = (vx - vTranslate.x) / scale;
float sy = (vy - vTranslate.y)/scale; float sy = (vy - vTranslate.y) / scale;
return new PointF(sx, sy); return new PointF(sx, sy);
} }
...@@ -1301,7 +1124,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1301,7 +1124,7 @@ public class SubsamplingScaleImageView extends View {
* Float to int rect conversion. * Float to int rect conversion.
*/ */
private Rect convertRect(RectF rect) { private Rect convertRect(RectF rect) {
return new Rect((int)rect.left, (int)rect.top, (int)rect.right, (int)rect.bottom); return new Rect((int) rect.left, (int) rect.top, (int) rect.right, (int) rect.bottom);
} }
/** /**
...@@ -1310,7 +1133,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1310,7 +1133,7 @@ public class SubsamplingScaleImageView extends View {
* the image point as near to the screen center as permitted. * the image point as near to the screen center as permitted.
*/ */
private PointF vTranslateForSCenter(PointF sCenter, float scale) { private PointF vTranslateForSCenter(PointF sCenter, float scale) {
PointF vTranslate = new PointF((getWidth()/2) - (sCenter.x * scale), (getHeight()/2) - (sCenter.y * scale)); PointF vTranslate = new PointF((getWidth() / 2) - (sCenter.x * scale), (getHeight() / 2) - (sCenter.y * scale));
ScaleAndTranslate sat = new ScaleAndTranslate(scale, vTranslate); ScaleAndTranslate sat = new ScaleAndTranslate(scale, vTranslate);
fitToBounds(true, sat); fitToBounds(true, sat);
return vTranslate; return vTranslate;
...@@ -1322,9 +1145,9 @@ public class SubsamplingScaleImageView extends View { ...@@ -1322,9 +1145,9 @@ public class SubsamplingScaleImageView extends View {
*/ */
private PointF limitedSCenter(PointF sCenter, float scale) { private PointF limitedSCenter(PointF sCenter, float scale) {
PointF vTranslate = vTranslateForSCenter(sCenter, scale); PointF vTranslate = vTranslateForSCenter(sCenter, scale);
int mY = getHeight()/2; int mY = getHeight() / 2;
float sx = ((getWidth()/2) - vTranslate.x)/scale; float sx = ((getWidth() / 2) - vTranslate.x) / scale;
float sy = ((getHeight()/2) - vTranslate.y)/scale; float sy = ((getHeight() / 2) - vTranslate.y) / scale;
return new PointF(sx, sy); return new PointF(sx, sy);
} }
...@@ -1332,7 +1155,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1332,7 +1155,7 @@ public class SubsamplingScaleImageView extends View {
* Returns the minimum allowed scale. * Returns the minimum allowed scale.
*/ */
private float minScale() { private float minScale() {
return Math.min(getWidth() / (float) sWidth(), (getHeight())/ (float) sHeight()); return Math.min(getWidth() / (float) sWidth(), (getHeight()) / (float) sHeight());
} }
/** /**
...@@ -1346,6 +1169,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1346,6 +1169,7 @@ public class SubsamplingScaleImageView extends View {
/** /**
* Apply a selected type of easing. * Apply a selected type of easing.
*
* @param type Easing type, from static fields * @param type Easing type, from static fields
* @param time Elapsed time * @param time Elapsed time
* @param from Start value * @param from Start value
...@@ -1366,6 +1190,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1366,6 +1190,7 @@ public class SubsamplingScaleImageView extends View {
/** /**
* Quadratic easing for fling. With thanks to Robert Penner - http://gizma.com/easing/ * Quadratic easing for fling. With thanks to Robert Penner - http://gizma.com/easing/
*
* @param time Elapsed time * @param time Elapsed time
* @param from Start value * @param from Start value
* @param change Target value * @param change Target value
...@@ -1373,12 +1198,13 @@ public class SubsamplingScaleImageView extends View { ...@@ -1373,12 +1198,13 @@ public class SubsamplingScaleImageView extends View {
* @return Current value * @return Current value
*/ */
private float easeOutQuad(long time, float from, float change, long duration) { private float easeOutQuad(long time, float from, float change, long duration) {
float progress = (float)time/(float)duration; float progress = (float) time / (float) duration;
return -change * progress*(progress-2) + from; return -change * progress * (progress - 2) + from;
} }
/** /**
* Quadratic easing for scale and center animations. With thanks to Robert Penner - http://gizma.com/easing/ * Quadratic easing for scale and center animations. With thanks to Robert Penner - http://gizma.com/easing/
*
* @param time Elapsed time * @param time Elapsed time
* @param from Start value * @param from Start value
* @param change Target value * @param change Target value
...@@ -1386,12 +1212,12 @@ public class SubsamplingScaleImageView extends View { ...@@ -1386,12 +1212,12 @@ public class SubsamplingScaleImageView extends View {
* @return Current value * @return Current value
*/ */
private float easeInOutQuad(long time, float from, float change, long duration) { private float easeInOutQuad(long time, float from, float change, long duration) {
float timeF = time/(duration/2f); float timeF = time / (duration / 2f);
if (timeF < 1) { if (timeF < 1) {
return (change/2f * timeF * timeF) + from; return (change / 2f * timeF * timeF) + from;
} else { } else {
timeF--; timeF--;
return (-change/2f) * (timeF * (timeF - 2) - 1) + from; return (-change / 2f) * (timeF * (timeF - 2) - 1) + from;
} }
} }
...@@ -1409,6 +1235,13 @@ public class SubsamplingScaleImageView extends View { ...@@ -1409,6 +1235,13 @@ public class SubsamplingScaleImageView extends View {
} }
} }
/**
* Returns the maximum allowed scale.
*/
public float getMaxScale() {
return maxScale;
}
/** /**
* Set the maximum scale allowed. A value of 1 means 1:1 pixels at maximum scale. You may wish to set this according * Set the maximum scale allowed. A value of 1 means 1:1 pixels at maximum scale. You may wish to set this according
* to screen density - on a retina screen, 1:1 may still be too small. Consider using {@link #setMinimumDpi(int)}, * to screen density - on a retina screen, 1:1 may still be too small. Consider using {@link #setMinimumDpi(int)},
...@@ -1418,23 +1251,17 @@ public class SubsamplingScaleImageView extends View { ...@@ -1418,23 +1251,17 @@ public class SubsamplingScaleImageView extends View {
this.maxScale = maxScale; this.maxScale = maxScale;
} }
/**
* Returns the maximum allowed scale.
*/
public float getMaxScale() {
return maxScale;
}
/** /**
* This is a screen density aware alternative to {@link #setMaxScale(float)}; it allows you to express the maximum * This is a screen density aware alternative to {@link #setMaxScale(float)}; it allows you to express the maximum
* allowed scale in terms of the minimum pixel density. This avoids the problem of 1:1 scale still being * allowed scale in terms of the minimum pixel density. This avoids the problem of 1:1 scale still being
* too small on a high density screen. A sensible starting point is 160 - the default used by this view. * too small on a high density screen. A sensible starting point is 160 - the default used by this view.
*
* @param dpi Source image pixel density at maximum zoom. * @param dpi Source image pixel density at maximum zoom.
*/ */
public final void setMinimumDpi(int dpi) { public final void setMinimumDpi(int dpi) {
DisplayMetrics metrics = getResources().getDisplayMetrics(); DisplayMetrics metrics = getResources().getDisplayMetrics();
float averageDpi = (metrics.xdpi + metrics.ydpi)/2; float averageDpi = (metrics.xdpi + metrics.ydpi) / 2;
setMaxScale(averageDpi/dpi); setMaxScale(averageDpi / dpi);
} }
/** /**
...@@ -1449,12 +1276,13 @@ public class SubsamplingScaleImageView extends View { ...@@ -1449,12 +1276,13 @@ public class SubsamplingScaleImageView extends View {
* necessary, and may increase the likelihood of an OutOfMemoryError. This method sets a DPI at which higher * necessary, and may increase the likelihood of an OutOfMemoryError. This method sets a DPI at which higher
* resolution tiles should be loaded. Using a lower number will on average use less memory but result in a lower * resolution tiles should be loaded. Using a lower number will on average use less memory but result in a lower
* quality image. 160-240dpi will usually be enough. * quality image. 160-240dpi will usually be enough.
*
* @param minimumTileDpi Tile loading threshold. * @param minimumTileDpi Tile loading threshold.
*/ */
public void setMinimumTileDpi(int minimumTileDpi) { public void setMinimumTileDpi(int minimumTileDpi) {
DisplayMetrics metrics = getResources().getDisplayMetrics(); DisplayMetrics metrics = getResources().getDisplayMetrics();
float averageDpi = (metrics.xdpi + metrics.ydpi)/2; float averageDpi = (metrics.xdpi + metrics.ydpi) / 2;
this.minimumTileDpi = (int)Math.min(averageDpi, minimumTileDpi); this.minimumTileDpi = (int) Math.min(averageDpi, minimumTileDpi);
if (isImageReady()) { if (isImageReady()) {
reset(false); reset(false);
invalidate(); invalidate();
...@@ -1465,8 +1293,8 @@ public class SubsamplingScaleImageView extends View { ...@@ -1465,8 +1293,8 @@ public class SubsamplingScaleImageView extends View {
* Returns the source point at the center of the view. * Returns the source point at the center of the view.
*/ */
public final PointF getCenter() { public final PointF getCenter() {
int mX = getWidth()/2; int mX = getWidth() / 2;
int mY = getHeight()/2; int mY = getHeight() / 2;
return viewToSourceCoord(mX, mY); return viewToSourceCoord(mX, mY);
} }
...@@ -1480,6 +1308,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1480,6 +1308,7 @@ public class SubsamplingScaleImageView extends View {
/** /**
* Externally change the scale and translation of the source image. This may be used with getCenter() and getScale() * Externally change the scale and translation of the source image. This may be used with getCenter() and getScale()
* to restore the scale and zoom after a screen rotate. * to restore the scale and zoom after a screen rotate.
*
* @param scale New scale to set. * @param scale New scale to set.
* @param sCenter New source image coordinate to center on the screen, subject to boundaries. * @param sCenter New source image coordinate to center on the screen, subject to boundaries.
*/ */
...@@ -1491,7 +1320,6 @@ public class SubsamplingScaleImageView extends View { ...@@ -1491,7 +1320,6 @@ public class SubsamplingScaleImageView extends View {
invalidate(); invalidate();
} }
/** /**
* Fully zoom out and return the image to the middle of the screen. This might be useful if you have a view pager * Fully zoom out and return the image to the middle of the screen. This might be useful if you have a view pager
* and want images to be reset when the user has moved to another page. * and want images to be reset when the user has moved to another page.
...@@ -1500,7 +1328,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1500,7 +1328,7 @@ public class SubsamplingScaleImageView extends View {
this.anim = null; this.anim = null;
this.pendingScale = limitedScale(0); this.pendingScale = limitedScale(0);
if (isImageReady()) { if (isImageReady()) {
this.sPendingCenter = new PointF(sWidth()/2, sHeight()/2); this.sPendingCenter = new PointF(sWidth() / 2, sHeight() / 2);
} else { } else {
this.sPendingCenter = new PointF(0, 0); this.sPendingCenter = new PointF(0, 0);
} }
...@@ -1546,6 +1374,20 @@ public class SubsamplingScaleImageView extends View { ...@@ -1546,6 +1374,20 @@ public class SubsamplingScaleImageView extends View {
return orientation; return orientation;
} }
/**
* Sets the image orientation. It's best to call this before setting the image file or asset, because it may waste
* loading of tiles. However, this can be freely called at any time.
*/
public final void setOrientation(int orientation) {
if (!VALID_ORIENTATIONS.contains(orientation)) {
throw new IllegalArgumentException("Invalid orientation: " + orientation);
}
this.orientation = orientation;
reset(false);
invalidate();
requestLayout();
}
/** /**
* Returns the actual orientation of the image relative to the source file. This will be based on the source file's * Returns the actual orientation of the image relative to the source file. This will be based on the source file's
* EXIF orientation if you're using ORIENTATION_USE_EXIF. Values are 0, 90, 180, 270. * EXIF orientation if you're using ORIENTATION_USE_EXIF. Values are 0, 90, 180, 270.
...@@ -1592,8 +1434,8 @@ public class SubsamplingScaleImageView extends View { ...@@ -1592,8 +1434,8 @@ public class SubsamplingScaleImageView extends View {
public final void setPanEnabled(boolean panEnabled) { public final void setPanEnabled(boolean panEnabled) {
this.panEnabled = panEnabled; this.panEnabled = panEnabled;
if (!panEnabled && vTranslate != null) { if (!panEnabled && vTranslate != null) {
vTranslate.x = (getWidth()/2) - (scale * (sWidth()/2)); vTranslate.x = (getWidth() / 2) - (scale * (sWidth() / 2));
vTranslate.y = (getHeight()/2) - (scale * (sHeight()/2)); vTranslate.y = (getHeight() / 2) - (scale * (sHeight() / 2));
if (isImageReady()) { if (isImageReady()) {
refreshRequiredTiles(true); refreshRequiredTiles(true);
invalidate(); invalidate();
...@@ -1605,6 +1447,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1605,6 +1447,7 @@ public class SubsamplingScaleImageView extends View {
* Set the scale the image will zoom in to when double tapped. This also the scale point where a double tap is interpreted * Set the scale the image will zoom in to when double tapped. This also the scale point where a double tap is interpreted
* as a zoom out gesture - if the scale is greater than 90% of this value, a double tap zooms out. Avoid using values * as a zoom out gesture - if the scale is greater than 90% of this value, a double tap zooms out. Avoid using values
* greater than the max zoom. * greater than the max zoom.
*
* @param doubleTapZoomScale New value for double tap gesture zoom scale. * @param doubleTapZoomScale New value for double tap gesture zoom scale.
*/ */
public final void setDoubleTapZoomScale(float doubleTapZoomScale) { public final void setDoubleTapZoomScale(float doubleTapZoomScale) {
...@@ -1615,16 +1458,18 @@ public class SubsamplingScaleImageView extends View { ...@@ -1615,16 +1458,18 @@ public class SubsamplingScaleImageView extends View {
* A density aware alternative to {@link #setDoubleTapZoomScale(float)}; this allows you to express the scale the * A density aware alternative to {@link #setDoubleTapZoomScale(float)}; this allows you to express the scale the
* image will zoom in to when double tapped in terms of the image pixel density. Values lower than the max scale will * image will zoom in to when double tapped in terms of the image pixel density. Values lower than the max scale will
* be ignored. A sensible starting point is 160 - the default used by this view. * be ignored. A sensible starting point is 160 - the default used by this view.
*
* @param dpi New value for double tap gesture zoom scale. * @param dpi New value for double tap gesture zoom scale.
*/ */
public final void setDoubleTapZoomDpi(int dpi) { public final void setDoubleTapZoomDpi(int dpi) {
DisplayMetrics metrics = getResources().getDisplayMetrics(); DisplayMetrics metrics = getResources().getDisplayMetrics();
float averageDpi = (metrics.xdpi + metrics.ydpi)/2; float averageDpi = (metrics.xdpi + metrics.ydpi) / 2;
setDoubleTapZoomScale(averageDpi/dpi); setDoubleTapZoomScale(averageDpi / dpi);
} }
/** /**
* Set the type of zoom animation to be used for double taps. See static fields. * Set the type of zoom animation to be used for double taps. See static fields.
*
* @param doubleTapZoomStyle New value for zoom style. * @param doubleTapZoomStyle New value for zoom style.
*/ */
public final void setDoubleTapZoomStyle(int doubleTapZoomStyle) { public final void setDoubleTapZoomStyle(int doubleTapZoomStyle) {
...@@ -1646,6 +1491,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1646,6 +1491,7 @@ public class SubsamplingScaleImageView extends View {
* the image in the center of the screen. If doing this would move the image beyond the edges of the screen, the * the image in the center of the screen. If doing this would move the image beyond the edges of the screen, the
* image is instead animated to move the center point as near to the center of the screen as is allowed - it's * image is instead animated to move the center point as near to the center of the screen as is allowed - it's
* guaranteed to be on screen. * guaranteed to be on screen.
*
* @param sCenter Target center point * @param sCenter Target center point
* @return {@link AnimationBuilder} instance. Call {@link com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.AnimationBuilder#start()} to start the anim. * @return {@link AnimationBuilder} instance. Call {@link com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.AnimationBuilder#start()} to start the anim.
*/ */
...@@ -1659,6 +1505,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1659,6 +1505,7 @@ public class SubsamplingScaleImageView extends View {
/** /**
* Creates a scale animation builder, that when started will animate a zoom in or out. If this would move the image * Creates a scale animation builder, that when started will animate a zoom in or out. If this would move the image
* beyond the panning limits, the image is automatically panned during the animation. * beyond the panning limits, the image is automatically panned during the animation.
*
* @param scale Target scale. * @param scale Target scale.
* @return {@link AnimationBuilder} instance. Call {@link com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.AnimationBuilder#start()} to start the anim. * @return {@link AnimationBuilder} instance. Call {@link com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.AnimationBuilder#start()} to start the anim.
*/ */
...@@ -1672,6 +1519,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1672,6 +1519,7 @@ public class SubsamplingScaleImageView extends View {
/** /**
* Creates a scale animation builder, that when started will animate a zoom in or out. If this would move the image * Creates a scale animation builder, that when started will animate a zoom in or out. If this would move the image
* beyond the panning limits, the image is automatically panned during the animation. * beyond the panning limits, the image is automatically panned during the animation.
*
* @param scale Target scale. * @param scale Target scale.
* @return {@link AnimationBuilder} instance. Call {@link com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.AnimationBuilder#start()} to start the anim. * @return {@link AnimationBuilder} instance. Call {@link com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.AnimationBuilder#start()} to start the anim.
*/ */
...@@ -1682,6 +1530,172 @@ public class SubsamplingScaleImageView extends View { ...@@ -1682,6 +1530,172 @@ public class SubsamplingScaleImageView extends View {
return new AnimationBuilder(scale, sCenter); return new AnimationBuilder(scale, sCenter);
} }
/**
* Async task used to get image details without blocking the UI thread.
*/
private static class BitmapInitTask extends AsyncTask<Void, Void, int[]> {
private final WeakReference<SubsamplingScaleImageView> viewRef;
private final WeakReference<Context> contextRef;
private final String source;
private final boolean sourceIsAsset;
private BitmapRegionDecoder decoder;
public BitmapInitTask(SubsamplingScaleImageView view, Context context, String source, boolean sourceIsAsset) {
this.viewRef = new WeakReference<SubsamplingScaleImageView>(view);
this.contextRef = new WeakReference<Context>(context);
this.source = source;
this.sourceIsAsset = sourceIsAsset;
}
@Override
protected int[] doInBackground(Void... params) {
try {
if (viewRef != null && contextRef != null) {
Context context = contextRef.get();
if (context != null) {
int exifOrientation = ORIENTATION_0;
if (sourceIsAsset) {
decoder = BitmapRegionDecoder.newInstance(context.getAssets().open(source, AssetManager.ACCESS_RANDOM), true);
} else {
decoder = BitmapRegionDecoder.newInstance(source, true);
try {
ExifInterface exifInterface = new ExifInterface(source);
int orientationAttr = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
if (orientationAttr == ExifInterface.ORIENTATION_NORMAL) {
exifOrientation = ORIENTATION_0;
} else if (orientationAttr == ExifInterface.ORIENTATION_ROTATE_90) {
exifOrientation = ORIENTATION_90;
} else if (orientationAttr == ExifInterface.ORIENTATION_ROTATE_180) {
exifOrientation = ORIENTATION_180;
} else if (orientationAttr == ExifInterface.ORIENTATION_ROTATE_270) {
exifOrientation = ORIENTATION_270;
} else {
Log.w(TAG, "Unsupported EXIF orientation: " + orientationAttr);
}
} catch (Exception e) {
Log.w(TAG, "Could not get EXIF orientation of image");
}
}
return new int[]{decoder.getWidth(), decoder.getHeight(), exifOrientation};
}
}
} catch (Exception e) {
Log.e(TAG, "Failed to initialise bitmap decoder", e);
}
return null;
}
@Override
protected void onPostExecute(int[] xyo) {
if (viewRef != null && decoder != null) {
final SubsamplingScaleImageView subsamplingScaleImageView = viewRef.get();
if (subsamplingScaleImageView != null && decoder != null && xyo != null && xyo.length == 3) {
subsamplingScaleImageView.onImageInited(decoder, xyo[0], xyo[1], xyo[2]);
}
}
}
}
/**
* Async task used to load images without blocking the UI thread.
*/
private static class BitmapTileTask extends AsyncTask<Void, Void, Bitmap> {
private final WeakReference<SubsamplingScaleImageView> viewRef;
private final WeakReference<BitmapRegionDecoder> decoderRef;
private final WeakReference<Object> decoderLockRef;
private final WeakReference<Tile> tileRef;
public BitmapTileTask(SubsamplingScaleImageView view, BitmapRegionDecoder decoder, Object decoderLock, Tile tile) {
this.viewRef = new WeakReference<SubsamplingScaleImageView>(view);
this.decoderRef = new WeakReference<BitmapRegionDecoder>(decoder);
this.decoderLockRef = new WeakReference<Object>(decoderLock);
this.tileRef = new WeakReference<Tile>(tile);
tile.loading = true;
}
@Override
protected Bitmap doInBackground(Void... params) {
try {
if (decoderRef != null && tileRef != null && viewRef != null) {
final BitmapRegionDecoder decoder = decoderRef.get();
final Object decoderLock = decoderLockRef.get();
final Tile tile = tileRef.get();
final SubsamplingScaleImageView view = viewRef.get();
if (decoder != null && decoderLock != null && tile != null && view != null && !decoder.isRecycled()) {
synchronized (decoderLock) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = tile.sampleSize;
options.inPreferredConfig = Config.RGB_565;
options.inDither = true;
Bitmap bitmap = decoder.decodeRegion(view.fileSRect(tile.sRect), options);
int rotation = view.getRequiredRotation();
if (rotation != 0) {
Matrix matrix = new Matrix();
matrix.postRotate(rotation);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}
return bitmap;
}
} else if (tile != null) {
tile.loading = false;
}
}
} catch (Exception e) {
Log.e(TAG, "Failed to decode tile", e);
}
return null;
}
@Override
protected void onPostExecute(Bitmap bitmap) {
if (viewRef != null && tileRef != null && bitmap != null) {
final SubsamplingScaleImageView subsamplingScaleImageView = viewRef.get();
final Tile tile = tileRef.get();
if (subsamplingScaleImageView != null && tile != null) {
tile.bitmap = bitmap;
tile.loading = false;
subsamplingScaleImageView.onTileLoaded();
}
}
}
}
private static class Tile {
private Rect sRect;
private int sampleSize;
private Bitmap bitmap;
private boolean loading;
private boolean visible;
}
private static class Anim {
private float scaleStart; // Scale at start of anim
private float scaleEnd; // Scale at end of anim (target)
private PointF sCenterStart; // Source center point at start
private PointF sCenterEnd; // Source center point at end, adjusted for pan limits
private PointF sCenterEndRequested; // Source center point that was requested, without adjustment
private PointF vFocusStart; // View point that was double tapped
private PointF vFocusEnd; // Where the view focal point should be moved to during the anim
private long duration = 500; // How long the anim takes
private boolean interruptible = true; // Whether the anim can be interrupted by a touch
private int easing = EASE_IN_OUT_QUAD; // Easing style
private long time = System.currentTimeMillis(); // Start time
}
private static class ScaleAndTranslate {
private float scale;
private PointF translate;
private ScaleAndTranslate(float scale, PointF translate) {
this.scale = scale;
this.translate = translate;
}
}
/** /**
* Builder class used to set additional options for a scale animation. Create an instance using {@link #animateScale(float)}, * Builder class used to set additional options for a scale animation. Create an instance using {@link #animateScale(float)},
* then set your options and call {@link #start()}. * then set your options and call {@link #start()}.
...@@ -1722,6 +1736,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1722,6 +1736,7 @@ public class SubsamplingScaleImageView extends View {
/** /**
* Desired duration of the anim in milliseconds. Default is 500. * Desired duration of the anim in milliseconds. Default is 500.
*
* @param duration duration in milliseconds. * @param duration duration in milliseconds.
* @return this builder for method chaining. * @return this builder for method chaining.
*/ */
...@@ -1732,6 +1747,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1732,6 +1747,7 @@ public class SubsamplingScaleImageView extends View {
/** /**
* Whether the animation can be interrupted with a touch. Default is true. * Whether the animation can be interrupted with a touch. Default is true.
*
* @param interruptible interruptible flag. * @param interruptible interruptible flag.
* @return this builder for method chaining. * @return this builder for method chaining.
*/ */
...@@ -1742,6 +1758,7 @@ public class SubsamplingScaleImageView extends View { ...@@ -1742,6 +1758,7 @@ public class SubsamplingScaleImageView extends View {
/** /**
* Set the easing style. See static fields. {@link #EASE_IN_OUT_QUAD} is recommended, and the default. * Set the easing style. See static fields. {@link #EASE_IN_OUT_QUAD} is recommended, and the default.
*
* @param easing easing style. * @param easing easing style.
* @return this builder for method chaining. * @return this builder for method chaining.
*/ */
...@@ -1779,8 +1796,8 @@ public class SubsamplingScaleImageView extends View { ...@@ -1779,8 +1796,8 @@ public class SubsamplingScaleImageView extends View {
anim.sCenterEnd = targetSCenter; anim.sCenterEnd = targetSCenter;
anim.vFocusStart = sourceToViewCoord(targetSCenter); anim.vFocusStart = sourceToViewCoord(targetSCenter);
anim.vFocusEnd = new PointF( anim.vFocusEnd = new PointF(
getWidth()/2, getWidth() / 2,
getHeight()/2 getHeight() / 2
); );
anim.duration = duration; anim.duration = duration;
anim.interruptible = interruptible; anim.interruptible = interruptible;
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient <gradient
android:startColor="#20000000" android:angle="90"
android:endColor="@android:color/transparent" android:endColor="@android:color/transparent"
android:angle="90" > android:startColor="#20000000"></gradient>
</gradient>
</shape> </shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient <gradient
android:startColor="#20000000" android:angle="270"
android:endColor="@android:color/transparent" android:endColor="@android:color/transparent"
android:angle="270" > android:startColor="#20000000"></gradient>
</gradient>
</shape> </shape>
\ No newline at end of file
...@@ -2,18 +2,18 @@ ...@@ -2,18 +2,18 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="#30555555"/> <solid android:color="#30555555" />
<corners android:radius="2dp" /> <corners android:radius="2dp" />
</shape> </shape>
</item> </item>
<item <item
android:bottom="2dp"
android:left="0dp" android:left="0dp"
android:right="0dp" android:right="0dp"
android:top="0dp" android:top="0dp">
android:bottom="2dp">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="#FFFFFF"/> <solid android:color="#FFFFFF" />
<corners android:radius="2dp" /> <corners android:radius="2dp" />
</shape> </shape>
</item> </item>
......
...@@ -4,31 +4,51 @@ ...@@ -4,31 +4,51 @@
<!-- Drop Shadow Stack --> <!-- Drop Shadow Stack -->
<item> <item>
<shape> <shape>
<padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" /> <padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" /> <solid android:color="#00999999" />
</shape> </shape>
</item> </item>
<item> <item>
<shape> <shape>
<padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" /> <padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#10999999" /> <solid android:color="#10999999" />
</shape> </shape>
</item> </item>
<item> <item>
<shape> <shape>
<padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" /> <padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#20999999" /> <solid android:color="#20999999" />
</shape> </shape>
</item> </item>
<item> <item>
<shape> <shape>
<padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" /> <padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#10999999" /> <solid android:color="#10999999" />
</shape> </shape>
</item> </item>
<item> <item>
<shape> <shape>
<padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" /> <padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" /> <solid android:color="#00999999" />
</shape> </shape>
</item> </item>
......
...@@ -4,35 +4,55 @@ ...@@ -4,35 +4,55 @@
<!-- Drop Shadow Stack --> <!-- Drop Shadow Stack -->
<item> <item>
<shape> <shape>
<padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" /> <padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" /> <solid android:color="#00999999" />
<corners android:radius="5dp" /> <corners android:radius="5dp" />
</shape> </shape>
</item> </item>
<item> <item>
<shape> <shape>
<padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" /> <padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" /> <solid android:color="#00999999" />
<corners android:radius="5dp" /> <corners android:radius="5dp" />
</shape> </shape>
</item> </item>
<item> <item>
<shape> <shape>
<padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" /> <padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" /> <solid android:color="#00999999" />
<corners android:radius="5dp" /> <corners android:radius="5dp" />
</shape> </shape>
</item> </item>
<item> <item>
<shape> <shape>
<padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" /> <padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" /> <solid android:color="#00999999" />
<corners android:radius="5dp" /> <corners android:radius="5dp" />
</shape> </shape>
</item> </item>
<item> <item>
<shape> <shape>
<padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" /> <padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" /> <solid android:color="#00999999" />
<corners android:radius="5dp" /> <corners android:radius="5dp" />
</shape> </shape>
...@@ -42,12 +62,12 @@ ...@@ -42,12 +62,12 @@
<item> <item>
<shape> <shape>
<gradient <gradient
android:type="linear" android:angle="90"
android:centerX="6%"
android:startColor="#FFe4e4e4"
android:centerColor="#FFf6f6f6" android:centerColor="#FFf6f6f6"
android:centerX="6%"
android:endColor="#FFffffff" android:endColor="#FFffffff"
android:angle="90"/> android:startColor="#FFe4e4e4"
android:type="linear" />
<corners android:radius="5dp" /> <corners android:radius="5dp" />
</shape> </shape>
</item> </item>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient <gradient
android:type="linear" android:angle="270"
android:centerX="20%"
android:startColor="#66000000"
android:centerColor="#22000000" android:centerColor="#22000000"
android:centerX="20%"
android:endColor="#00f6f6f6" android:endColor="#00f6f6f6"
android:angle="270"/> android:startColor="#66000000"
android:type="linear" />
</shape> </shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient <gradient
android:type="linear" android:angle="90"
android:centerX="2%"
android:startColor="#FFe4e4e4"
android:centerColor="#FFf6f6f6" android:centerColor="#FFf6f6f6"
android:centerX="2%"
android:endColor="#FFffffff" android:endColor="#FFffffff"
android:angle="90"/> android:startColor="#FFe4e4e4"
android:type="linear" />
</shape> </shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient <gradient
android:type="linear" android:angle="270"
android:centerX="60%"
android:startColor="#00000000"
android:centerColor="#19000000" android:centerColor="#19000000"
android:centerX="60%"
android:endColor="#FF000000" android:endColor="#FF000000"
android:angle="270"/> android:startColor="#00000000"
android:type="linear" />
</shape> </shape>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0" android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal"> android:viewportWidth="24.0">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,5c1.66,0 3,1.34 3,3s-1.34,3 -3,3 -3,-1.34 -3,-3 1.34,-3 3,-3zM12,19.2c-2.5,0 -4.71,-1.28 -6,-3.22 0.03,-1.99 4,-3.08 6,-3.08 1.99,0 5.97,1.09 6,3.08 -1.29,1.94 -3.5,3.22 -6,3.22z"/> android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,5c1.66,0 3,1.34 3,3s-1.34,3 -3,3 -3,-1.34 -3,-3 1.34,-3 3,-3zM12,19.2c-2.5,0 -4.71,-1.28 -6,-3.22 0.03,-1.99 4,-3.08 6,-3.08 1.99,0 5.97,1.09 6,3.08 -1.29,1.94 -3.5,3.22 -6,3.22z" />
</vector> </vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0" android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal"> android:viewportWidth="24.0">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" />
</vector> </vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0" android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal"> android:viewportWidth="24.0">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M10.09,15.59L11.5,17l5,-5 -5,-5 -1.41,1.41L12.67,11H3v2h9.67l-2.58,2.59zM19,3H5c-1.11,0 -2,0.9 -2,2v4h2V5h14v14H5v-4H3v4c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2z"/> android:pathData="M10.09,15.59L11.5,17l5,-5 -5,-5 -1.41,1.41L12.67,11H3v2h9.67l-2.58,2.59zM19,3H5c-1.11,0 -2,0.9 -2,2v4h2V5h14v14H5v-4H3v4c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2z" />
</vector> </vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0" android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal"> android:viewportWidth="24.0">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM13,14h-2v-2h2v2zM13,10h-2L11,6h2v4z"/> android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM13,14h-2v-2h2v2zM13,10h-2L11,6h2v4z" />
</vector> </vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0" android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal"> android:viewportWidth="24.0">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/> android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z" />
</vector> </vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0" android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal"> android:viewportWidth="24.0">
<path <path
android:fillColor="@android:color/white" android:fillColor="@android:color/white"
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/> android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z" />
</vector> </vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:viewportHeight="24.0"
android:viewportHeight="24.0"> android:viewportWidth="24.0">
<path <path
android:fillColor="#FF000000" android:fillColor="#FF000000"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/> android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</vector> </vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:viewportHeight="24.0"
android:viewportHeight="24.0"> android:viewportWidth="24.0">
<path <path
android:fillColor="#FF000000" android:fillColor="#FF000000"
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/> android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z" />
</vector> </vector>
<vector android:height="24dp" android:viewportHeight="792" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="792" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> android:width="24dp"
<path android:fillAlpha="0.4" android:fillColor="#ffffff" android:height="24dp"
android:pathData="m396.004,170.224l0,0a303.09,303.09 90,0 1,-0.007 428.627l0,0 0,0A303.09,303.09 90,0 1,396.004 170.224Z" android:strokeAlpha="0.4"/> android:viewportHeight="792"
<path android:fillAlpha="0.4" android:fillColor="#ffffff" android:viewportWidth="792">
android:pathData="M726.43,533.13A302.83,302.83 0,0 1,396 598.85,303.38 303.38,0 0,1 726.43,533.13Z" android:strokeAlpha="0.4"/> <path
<path android:fillAlpha="0.4" android:fillColor="#ffffff" android:fillAlpha="0.4"
android:pathData="M297.36,532.94A302,302 0,0 1,396 598.85,303.48 303.48,0 0,1 65.57,533.13 304,304 0,0 1,297.36 532.94Z" android:strokeAlpha="0.4"/> android:fillColor="#ffffff"
<path android:fillAlpha="0.4" android:fillColor="#ffffff" android:pathData="m396.004,170.224l0,0a303.09,303.09 90,0 1,-0.007 428.627l0,0 0,0A303.09,303.09 90,0 1,396.004 170.224Z"
android:pathData="m699.09,295.76l-0,0a303.09,303.09 0,0 1,-303.09 303.09l-0,0 -0,0A303.09,303.09 0,0 1,699.09 295.76Z" android:strokeAlpha="0.4"/> android:strokeAlpha="0.4" />
<path android:fillAlpha="0.4" android:fillColor="#ffffff" <path
android:pathData="M512.38,622A302.31,302.31 0,0 1,396 598.85,302.22 302.22,0 0,1 512.38,622Z" android:strokeAlpha="0.4"/> android:fillAlpha="0.4"
<path android:fillAlpha="0.4" android:fillColor="#ffffff" android:fillColor="#ffffff"
android:pathData="M279.62,622A302.22,302.22 0,0 1,396 598.85,302.31 302.31,0 0,1 279.62,622Z" android:strokeAlpha="0.4"/> android:pathData="M726.43,533.13A302.83,302.83 0,0 1,396 598.85,303.38 303.38,0 0,1 726.43,533.13Z"
<path android:fillAlpha="0.4" android:fillColor="#ffffff" android:strokeAlpha="0.4" />
android:pathData="m92.91,295.76v0A303.09,303.09 0,0 1,396 598.85v0,0A303.09,303.09 0,0 1,92.91 295.76Z" android:strokeAlpha="0.4"/> <path
<path android:fillAlpha="0.4" android:fillColor="#ffffff" android:fillAlpha="0.4"
android:pathData="m231.969,202.853l0,0a303.09,303.09 67.5,0 1,164.035 395.997l0,0 0,0A303.09,303.09 67.5,0 1,231.969 202.853Z" android:strokeAlpha="0.4"/> android:fillColor="#ffffff"
<path android:fillAlpha="0.4" android:fillColor="#ffffff" android:pathData="M297.36,532.94A302,302 0,0 1,396 598.85,303.48 303.48,0 0,1 65.57,533.13 304,304 0,0 1,297.36 532.94Z"
android:pathData="m792,434.82a302.83,302.83 0,0 1,-396 164,302.83 302.83,0 0,1 396,-164z" android:strokeAlpha="0.4"/> android:strokeAlpha="0.4" />
<path android:fillAlpha="0.4" android:fillColor="#ffffff" <path
android:pathData="m279.62,575.7a301.94,301.94 0,0 1,116.38 23.15,302.06 302.06,0 0,1 -232,0 303.77,303.77 0,0 1,115.62 -23.15z" android:strokeAlpha="0.4"/> android:fillAlpha="0.4"
<path android:fillAlpha="0.4" android:fillColor="#ffffff" android:fillColor="#ffffff"
android:pathData="m560.025,202.845l0,0a303.09,303.09 112.5,0 1,-164.022 396.002l0,0 0,0A303.09,303.09 112.5,0 1,560.025 202.845Z" android:strokeAlpha="0.4"/> android:pathData="m699.09,295.76l-0,0a303.09,303.09 0,0 1,-303.09 303.09l-0,0 -0,0A303.09,303.09 0,0 1,699.09 295.76Z"
<path android:fillAlpha="0.4" android:fillColor="#ffffff" android:strokeAlpha="0.4" />
android:pathData="m628,598.84a302.06,302.06 0,0 1,-232 0,302.18 302.18,0 0,1 232,0z" android:strokeAlpha="0.4"/> <path
<path android:fillAlpha="0.4" android:fillColor="#ffffff" android:fillAlpha="0.4"
android:pathData="M396,598.85A302.83,302.83 0,0 1,0 434.82a302.83,302.83 0,0 1,396 164z" android:strokeAlpha="0.4"/> android:fillColor="#ffffff"
android:pathData="M512.38,622A302.31,302.31 0,0 1,396 598.85,302.22 302.22,0 0,1 512.38,622Z"
android:strokeAlpha="0.4" />
<path
android:fillAlpha="0.4"
android:fillColor="#ffffff"
android:pathData="M279.62,622A302.22,302.22 0,0 1,396 598.85,302.31 302.31,0 0,1 279.62,622Z"
android:strokeAlpha="0.4" />
<path
android:fillAlpha="0.4"
android:fillColor="#ffffff"
android:pathData="m92.91,295.76v0A303.09,303.09 0,0 1,396 598.85v0,0A303.09,303.09 0,0 1,92.91 295.76Z"
android:strokeAlpha="0.4" />
<path
android:fillAlpha="0.4"
android:fillColor="#ffffff"
android:pathData="m231.969,202.853l0,0a303.09,303.09 67.5,0 1,164.035 395.997l0,0 0,0A303.09,303.09 67.5,0 1,231.969 202.853Z"
android:strokeAlpha="0.4" />
<path
android:fillAlpha="0.4"
android:fillColor="#ffffff"
android:pathData="m792,434.82a302.83,302.83 0,0 1,-396 164,302.83 302.83,0 0,1 396,-164z"
android:strokeAlpha="0.4" />
<path
android:fillAlpha="0.4"
android:fillColor="#ffffff"
android:pathData="m279.62,575.7a301.94,301.94 0,0 1,116.38 23.15,302.06 302.06,0 0,1 -232,0 303.77,303.77 0,0 1,115.62 -23.15z"
android:strokeAlpha="0.4" />
<path
android:fillAlpha="0.4"
android:fillColor="#ffffff"
android:pathData="m560.025,202.845l0,0a303.09,303.09 112.5,0 1,-164.022 396.002l0,0 0,0A303.09,303.09 112.5,0 1,560.025 202.845Z"
android:strokeAlpha="0.4" />
<path
android:fillAlpha="0.4"
android:fillColor="#ffffff"
android:pathData="m628,598.84a302.06,302.06 0,0 1,-232 0,302.18 302.18,0 0,1 232,0z"
android:strokeAlpha="0.4" />
<path
android:fillAlpha="0.4"
android:fillColor="#ffffff"
android:pathData="M396,598.85A302.83,302.83 0,0 1,0 434.82a302.83,302.83 0,0 1,396 164z"
android:strokeAlpha="0.4" />
</vector> </vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:viewportHeight="24.0"
android:viewportHeight="24.0"> android:viewportWidth="24.0">
<path <path
android:fillColor="#FFFFFFFF" android:fillColor="#FFFFFFFF"
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z"/> android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z" />
</vector> </vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="24.0" android:viewportHeight="24.0"
android:viewportHeight="24.0"> android:viewportWidth="24.0">
<path <path
android:fillColor="#FF000000" android:fillColor="#FF000000"
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/> android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z" />
</vector> </vector>
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignParentTop="false" android:layout_alignParentTop="false"
android:layout_alignWithParentIfMissing="false"> android:layout_alignWithParentIfMissing="false"></WebView>
</WebView>
</LinearLayout> </LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="vertical">
<ProgressBar <ProgressBar
android:id="@+id/blog_load_item"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true"
android:id="@+id/blog_load_item"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_margin="@dimen/activity_vertical_margin"/> android:layout_margin="@dimen/activity_vertical_margin"
android:indeterminate="true" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:background="?android:attr/selectableItemBackground"
android:background="?android:attr/selectableItemBackground"> android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/big_object_picture" android:id="@+id/big_object_picture"
...@@ -60,11 +60,11 @@ ...@@ -60,11 +60,11 @@
android:id="@+id/object_subtitle" android:id="@+id/object_subtitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Subtitle"
android:textSize="16sp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1"
android:scrollHorizontally="true" android:scrollHorizontally="true"
android:maxLines="1" /> android:text="Subtitle"
android:textSize="16sp" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
......
...@@ -278,20 +278,20 @@ ...@@ -278,20 +278,20 @@
android:id="@+id/mrunmayi" android:id="@+id/mrunmayi"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:gravity="center" android:gravity="center"
android:text="Mrunmayi Mungekar" android:text="Mrunmayi Mungekar"
android:textSize="13sp" android:textSize="13sp"
android:layout_marginEnd="15dp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/owais" android:id="@+id/owais"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="25dp"
android:gravity="center" android:gravity="center"
android:text="Owais Chunawala" android:text="Owais Chunawala"
android:textSize="13sp" android:textSize="13sp"
android:layout_marginEnd="25dp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
...@@ -306,7 +306,6 @@ ...@@ -306,7 +306,6 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
...@@ -349,18 +348,18 @@ ...@@ -349,18 +348,18 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:gravity="center" android:gravity="center"
android:textSize="13sp"
android:text="Yash Khemchandani" android:text="Yash Khemchandani"
android:textSize="13sp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/bavish" android:id="@+id/bavish"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center"
android:textSize="13sp"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:gravity="center"
android:text="Bavish Kulur" android:text="Bavish Kulur"
android:textSize="13sp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
...@@ -369,14 +368,13 @@ ...@@ -369,14 +368,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="40dp" android:layout_marginStart="40dp"
android:gravity="center" android:gravity="center"
android:textSize="13sp"
android:text="Mayuresh Bhattu" android:text="Mayuresh Bhattu"
android:textSize="13sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView <de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/maitreyaimg" android:id="@+id/maitreyaimg"
android:layout_width="75dp" android:layout_width="75dp"
...@@ -455,10 +453,10 @@ ...@@ -455,10 +453,10 @@
android:id="@+id/bijoy" android:id="@+id/bijoy"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:gravity="center" android:gravity="center"
android:textSize="13sp"
android:text="Bijoy Singh Kochar" android:text="Bijoy Singh Kochar"
android:layout_marginStart="30dp" android:textSize="13sp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
...@@ -467,8 +465,8 @@ ...@@ -467,8 +465,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="25dp" android:layout_marginStart="25dp"
android:gravity="center" android:gravity="center"
android:textSize="13sp"
android:text="Dheerendra Rathor" android:text="Dheerendra Rathor"
android:textSize="13sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
...@@ -550,9 +548,9 @@ ...@@ -550,9 +548,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:textStyle="bold"
android:gravity="center" android:gravity="center"
android:text="tty0" /> android:text="tty0"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/join_us" android:id="@+id/join_us"
...@@ -570,42 +568,42 @@ ...@@ -570,42 +568,42 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:layout_marginTop="10dp"
android:autoLink="web" android:autoLink="web"
android:linksClickable="true"
android:gravity="center" android:gravity="center"
android:linksClickable="true"
android:text="@string/django_api" android:text="@string/django_api"
android:textStyle="bold" android:textColorLink="@color/colorPrimaryDark"
android:textColorLink="@color/colorPrimaryDark"/> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/android" android:id="@+id/android"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginTop="5dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:layout_marginTop="5dp"
android:autoLink="web" android:autoLink="web"
android:linksClickable="true"
android:gravity="center" android:gravity="center"
android:linksClickable="true"
android:text="@string/android_app" android:text="@string/android_app"
android:textStyle="bold" android:textColorLink="@color/colorPrimaryDark"
android:textColorLink="@color/colorPrimaryDark"/> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/angular" android:id="@+id/angular"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginTop="5dp"
android:layout_marginBottom="36dp" android:layout_marginBottom="36dp"
android:layout_marginTop="5dp"
android:autoLink="web" android:autoLink="web"
android:linksClickable="true"
android:gravity="center" android:gravity="center"
android:linksClickable="true"
android:text="@string/angular_pwa" android:text="@string/angular_pwa"
android:textStyle="bold" android:textColorLink="@color/colorPrimaryDark"
android:textColorLink="@color/colorPrimaryDark"/> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
......
...@@ -104,15 +104,15 @@ ...@@ -104,15 +104,15 @@
<Button <Button
android:id="@+id/follow_button" android:id="@+id/follow_button"
style="?android:attr/buttonBarButtonStyle" style="?android:attr/buttonBarButtonStyle"
android:textAllCaps="false"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="0dp" android:layout_margin="0dp"
android:layout_weight="1" android:layout_weight="1"
android:text="FOLLOW" android:clickable="true"
android:textColor="@color/secondaryTextColor"
android:foreground="?attr/selectableItemBackground" android:foreground="?attr/selectableItemBackground"
android:clickable="true" /> android:text="FOLLOW"
android:textAllCaps="false"
android:textColor="@color/secondaryTextColor" />
</LinearLayout> </LinearLayout>
<View <View
...@@ -219,7 +219,7 @@ ...@@ -219,7 +219,7 @@
android:layout_margin="16dp" android:layout_margin="16dp"
android:src="@drawable/ic_edit_black_24dp" android:src="@drawable/ic_edit_black_24dp"
android:tint="@android:color/black" android:tint="@android:color/black"
android:visibility="gone"/> android:visibility="gone" />
</RelativeLayout> </RelativeLayout>
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
android:theme="@style/BlueAccent"/> android:theme="@style/BlueAccent" />
</RelativeLayout> </RelativeLayout>
<app.insti.TouchImageView <app.insti.TouchImageView
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
android:theme="@style/BlueAccent"/> android:theme="@style/BlueAccent" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -157,15 +157,15 @@ ...@@ -157,15 +157,15 @@
<Button <Button
android:id="@+id/going_button" android:id="@+id/going_button"
style="?android:attr/buttonBarButtonStyle" style="?android:attr/buttonBarButtonStyle"
android:textAllCaps="false"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="0dp" android:layout_margin="0dp"
android:layout_weight="1" android:layout_weight="1"
android:text="GOING" android:clickable="true"
android:textColor="@color/secondaryTextColor"
android:foreground="?attr/selectableItemBackground" android:foreground="?attr/selectableItemBackground"
android:clickable="true" /> android:text="GOING"
android:textAllCaps="false"
android:textColor="@color/secondaryTextColor" />
<View <View
android:layout_width="1dp" android:layout_width="1dp"
...@@ -177,15 +177,15 @@ ...@@ -177,15 +177,15 @@
<Button <Button
android:id="@+id/interested_button" android:id="@+id/interested_button"
style="?android:attr/buttonBarButtonStyle" style="?android:attr/buttonBarButtonStyle"
android:textAllCaps="false"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="0dp" android:layout_margin="0dp"
android:layout_weight="1" android:layout_weight="1"
android:text="INTERESTED" android:clickable="true"
android:textColor="@color/secondaryTextColor"
android:foreground="?attr/selectableItemBackground" android:foreground="?attr/selectableItemBackground"
android:clickable="true" /> android:text="INTERESTED"
android:textAllCaps="false"
android:textColor="@color/secondaryTextColor" />
</LinearLayout> </LinearLayout>
......
...@@ -14,16 +14,16 @@ ...@@ -14,16 +14,16 @@
<EditText <EditText
android:id="@+id/explore_search" android:id="@+id/explore_search"
android:background="@color/colorPrimary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:hint="Search"
android:paddingBottom="15dp"
android:paddingLeft="18dp" android:paddingLeft="18dp"
android:paddingRight="6dp" android:paddingRight="6dp"
android:paddingTop="3dp" android:paddingTop="3dp"
android:paddingBottom="15dp"
android:hint="Search"
android:textColor="@color/primaryTextColor" android:textColor="@color/primaryTextColor"
android:textColorHint="@color/primaryTextColor"/> android:textColorHint="@color/primaryTextColor" />
<android.support.v4.widget.NestedScrollView <android.support.v4.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
android:theme="@style/BlueAccent"/> android:theme="@style/BlueAccent" />
</RelativeLayout> </RelativeLayout>
</FrameLayout> </FrameLayout>
\ No newline at end of file
...@@ -38,6 +38,6 @@ ...@@ -38,6 +38,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
android:theme="@style/BlueAccent"/> android:theme="@style/BlueAccent" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -6,22 +6,22 @@ ...@@ -6,22 +6,22 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true"> android:focusableInTouchMode="true"
android:orientation="vertical">
<EditText <EditText
android:id="@+id/search" android:id="@+id/search"
android:background="@color/colorPrimary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:hint="Search"
android:paddingBottom="15dp"
android:paddingLeft="18dp" android:paddingLeft="18dp"
android:paddingRight="6dp" android:paddingRight="6dp"
android:paddingTop="3dp" android:paddingTop="3dp"
android:paddingBottom="15dp"
android:hint="Search"
android:textColor="@color/primaryTextColor" android:textColor="@color/primaryTextColor"
android:textColorHint="@color/primaryTextColor"/> android:textColorHint="@color/primaryTextColor" />
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
...@@ -34,10 +34,10 @@ ...@@ -34,10 +34,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/darker_gray" android:background="@android:color/darker_gray"
tools:context="com.mrane.campusmap.MainActivity"
tools:ignore="MergeRootFrame"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true"> android:focusableInTouchMode="true"
tools:context="com.mrane.campusmap.MainActivity"
tools:ignore="MergeRootFrame">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true"></LinearLayout> android:focusableInTouchMode="true"></LinearLayout>
<com.mrane.navigation.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto" <com.mrane.navigation.SlidingUpPanelLayout
android:id="@+id/sliding_layout" android:id="@+id/sliding_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
...@@ -76,16 +76,16 @@ ...@@ -76,16 +76,16 @@
</LinearLayout> </LinearLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/loadingPanel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center">
android:id="@+id/loadingPanel">
<ProgressBar <ProgressBar
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
android:theme="@style/BlueAccent"/> android:theme="@style/BlueAccent" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="12dp" android:layout_marginBottom="12dp"
android:paddingLeft="16dp"
android:backgroundTint="@color/colorWhite" android:backgroundTint="@color/colorWhite"
android:paddingLeft="16dp"
android:theme="@style/AppTheme" /> android:theme="@style/AppTheme" />
</FrameLayout> </FrameLayout>
...@@ -47,6 +47,6 @@ ...@@ -47,6 +47,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
android:theme="@style/BlueAccent"/> android:theme="@style/BlueAccent" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -39,6 +39,6 @@ ...@@ -39,6 +39,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
android:theme="@style/BlueAccent"/> android:theme="@style/BlueAccent" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
android:theme="@style/BlueAccent"/> android:theme="@style/BlueAccent" />
</RelativeLayout> </RelativeLayout>
</FrameLayout> </FrameLayout>
...@@ -27,6 +27,6 @@ ...@@ -27,6 +27,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
android:theme="@style/BlueAccent"/> android:theme="@style/BlueAccent" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
...@@ -33,9 +33,9 @@ ...@@ -33,9 +33,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="2dp" android:layout_marginBottom="2dp"
android:textSize="20sp"
android:fontFamily="sans-serif-light" android:fontFamily="sans-serif-light"
android:textColor="@color/secondaryTextColor"/> android:textColor="@color/secondaryTextColor"
android:textSize="20sp" />
<TextView <TextView
android:id="@+id/user_rollno_profile" android:id="@+id/user_rollno_profile"
...@@ -105,13 +105,13 @@ ...@@ -105,13 +105,13 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
android:theme="@style/BlueAccent"/> android:theme="@style/BlueAccent" />
</RelativeLayout> </RelativeLayout>
<app.insti.TouchImageView <app.insti.TouchImageView
android:id="@+id/expanded_image_profile" android:id="@+id/expanded_image_profile"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:visibility="gone" android:contentDescription="Zoomed Image"
android:contentDescription="Zoomed Image" /> android:visibility="gone" />
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -48,10 +48,10 @@ ...@@ -48,10 +48,10 @@
style="@style/Widget.AppCompat.Button.Borderless" style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp"
android:drawablePadding="16dp" android:drawablePadding="16dp"
android:drawableStart="@drawable/baseline_account_circle_black_36" android:drawableStart="@drawable/baseline_account_circle_black_36"
android:gravity="center_vertical" android:gravity="center_vertical"
android:padding="16dp"
android:text="Update Profile" android:text="Update Profile"
android:textAllCaps="false" android:textAllCaps="false"
android:textSize="20sp" /> android:textSize="20sp" />
...@@ -61,10 +61,10 @@ ...@@ -61,10 +61,10 @@
style="@style/Widget.AppCompat.Button.Borderless" style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp"
android:drawablePadding="16dp" android:drawablePadding="16dp"
android:drawableStart="@drawable/baseline_feedback_black_36" android:drawableStart="@drawable/baseline_feedback_black_36"
android:gravity="center_vertical" android:gravity="center_vertical"
android:padding="16dp"
android:text="Feedback" android:text="Feedback"
android:textAllCaps="false" android:textAllCaps="false"
android:textSize="20sp" /> android:textSize="20sp" />
...@@ -74,10 +74,10 @@ ...@@ -74,10 +74,10 @@
style="@style/Widget.AppCompat.Button.Borderless" style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp"
android:drawablePadding="16dp" android:drawablePadding="16dp"
android:drawableStart="@drawable/baseline_info_black_36" android:drawableStart="@drawable/baseline_info_black_36"
android:gravity="center_vertical" android:gravity="center_vertical"
android:padding="16dp"
android:text="About" android:text="About"
android:textAllCaps="false" android:textAllCaps="false"
android:textSize="20sp" /> android:textSize="20sp" />
...@@ -87,10 +87,10 @@ ...@@ -87,10 +87,10 @@
style="@style/Widget.AppCompat.Button.Borderless" style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp"
android:drawablePadding="16dp" android:drawablePadding="16dp"
android:drawableStart="@drawable/baseline_exit_to_app_black_36" android:drawableStart="@drawable/baseline_exit_to_app_black_36"
android:gravity="center_vertical" android:gravity="center_vertical"
android:padding="16dp"
android:text="Logout" android:text="Logout"
android:textAllCaps="false" android:textAllCaps="false"
android:textSize="20sp" /> android:textSize="20sp" />
......
...@@ -27,6 +27,6 @@ ...@@ -27,6 +27,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
android:theme="@style/BlueAccent"/> android:theme="@style/BlueAccent" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/small_card_bg" android:background="@drawable/small_card_bg"
android:orientation="horizontal" > android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/place_color" android:id="@+id/place_color"
...@@ -24,16 +24,16 @@ ...@@ -24,16 +24,16 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="@dimen/hidden_card_height" android:minHeight="@dimen/hidden_card_height"
android:paddingBottom="8dp" > android:paddingBottom="8dp">
<ImageButton <ImageButton
android:id="@+id/add_marker_icon" android:id="@+id/add_marker_icon"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_marginRight="0dp" android:layout_marginRight="0dp"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:layout_alignParentRight="true"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:contentDescription="Search" android:contentDescription="Search"
android:cropToPadding="true" android:cropToPadding="true"
...@@ -54,8 +54,7 @@ ...@@ -54,8 +54,7 @@
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"
android:paddingTop="8dp" android:paddingTop="8dp"
android:textSize="@dimen/place_name_text_size" > android:textSize="@dimen/place_name_text_size"></TextView>
</TextView>
<TextView <TextView
android:id="@+id/place_sub_head" android:id="@+id/place_sub_head"
...@@ -77,25 +76,24 @@ ...@@ -77,25 +76,24 @@
android:id="@+id/new_expand_container" android:id="@+id/new_expand_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="@color/list_item_gray_even" > android:background="@color/list_item_gray_even">
<com.mrane.navigation.EndDetectScrollView <com.mrane.navigation.EndDetectScrollView
android:id="@+id/new_expanded_place_card_scroll" android:id="@+id/new_expanded_place_card_scroll"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentTop="true" > android:layout_alignParentTop="true">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" > android:layout_height="match_parent">
<LinearLayout <LinearLayout
android:id="@+id/expanded_place_card" android:id="@+id/expanded_place_card"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#e5e5e5" android:background="#e5e5e5"
android:orientation="horizontal" > android:orientation="horizontal"></LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/other_details" android:id="@+id/other_details"
...@@ -103,8 +101,7 @@ ...@@ -103,8 +101,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:orientation="vertical" > android:orientation="vertical"></LinearLayout>
</LinearLayout>
</RelativeLayout> </RelativeLayout>
</com.mrane.navigation.EndDetectScrollView> </com.mrane.navigation.EndDetectScrollView>
...@@ -113,7 +110,7 @@ ...@@ -113,7 +110,7 @@
android:layout_width="12dp" android:layout_width="12dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" > android:layout_alignParentTop="true">
<View <View
android:id="@+id/place_group_color" android:id="@+id/place_group_color"
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
android:id="@+id/child_name" android:id="@+id/child_name"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:fontFamily="sans-serif-light"
android:minHeight="56dp" android:minHeight="56dp"
android:textSize="18dp" android:padding="8dp"
android:fontFamily="sans-serif-light" /> android:textSize="18dp" />
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="#e0e0e0" > android:background="#e0e0e0">
<LinearLayout <LinearLayout
android:id="@+id/header_layout" android:id="@+id/header_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -10,16 +11,18 @@ ...@@ -10,16 +11,18 @@
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/arrow_icon" android:id="@+id/arrow_icon"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:paddingTop="16dp" android:cropToPadding="true"
android:paddingBottom="16dp" android:paddingBottom="16dp"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingRight="8dp" android:paddingRight="8dp"
android:cropToPadding="true" android:paddingTop="16dp"
android:scaleType="centerInside" /> android:scaleType="centerInside" />
<TextView <TextView
android:id="@+id/list_header" android:id="@+id/list_header"
android:layout_width="fill_parent" android:layout_width="fill_parent"
...@@ -27,11 +30,12 @@ ...@@ -27,11 +30,12 @@
android:layout_gravity="left|center_vertical" android:layout_gravity="left|center_vertical"
android:paddingLeft="8dp" /> android:paddingLeft="8dp" />
</LinearLayout> </LinearLayout>
<ListView <ListView
android:id="@+id/child_list" android:id="@+id/child_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/header_layout" android:layout_below="@id/header_layout"
android:paddingLeft="48dp" android:background="#e5e5e5"
android:background="#e5e5e5"></ListView> android:paddingLeft="48dp"></ListView>
</RelativeLayout> </RelativeLayout>
...@@ -2,28 +2,31 @@ ...@@ -2,28 +2,31 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:orientation="vertical" android:background="#F5F5F5"
android:background="#F5F5F5" > android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/group_color" android:id="@+id/group_color"
android:layout_width="12dp" android:layout_width="12dp"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:paddingLeft="0dp"
android:layout_marginLeft="0dp" android:layout_marginLeft="0dp"
android:cropToPadding="true"/> android:cropToPadding="true"
android:paddingLeft="0dp" />
<ImageView <ImageView
android:id="@+id/icon_expand" android:id="@+id/icon_expand"
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_toRightOf="@id/group_color" android:layout_toRightOf="@id/group_color"
android:contentDescription="list item"
android:cropToPadding="true" android:cropToPadding="true"
android:paddingTop="16dp"
android:paddingBottom="16dp" android:paddingBottom="16dp"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"
android:contentDescription="list item" android:paddingTop="16dp"
android:visibility="visible" /> android:visibility="visible" />
<TextView <TextView
android:id="@+id/lblListHeader" android:id="@+id/lblListHeader"
android:layout_width="fill_parent" android:layout_width="fill_parent"
...@@ -32,10 +35,12 @@ ...@@ -32,10 +35,12 @@
android:layout_toRightOf="@id/icon_expand" android:layout_toRightOf="@id/icon_expand"
android:padding="8dp" android:padding="8dp"
android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft" /> android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft" />
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:layout_alignParentBottom="true" /> android:layout_alignParentBottom="true" />
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
......
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" > android:orientation="vertical">
<ExpandableListView <ExpandableListView
android:id="@+id/index_list" android:id="@+id/index_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="@android:color/transparent"
android:divider="@null" android:divider="@null"
android:groupIndicator="@null"
android:paddingLeft="0dp" android:paddingLeft="0dp"
android:paddingRight="0dp" android:paddingRight="0dp"
android:groupIndicator="@null"
android:background="@android:color/transparent"
android:transcriptMode="disabled" /> android:transcriptMode="disabled" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -8,9 +8,8 @@ ...@@ -8,9 +8,8 @@
android:id="@+id/suggestion_list" android:id="@+id/suggestion_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/listview_background"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingRight="16dp" android:paddingRight="16dp"></ListView>
android:background="@drawable/listview_background" >
</ListView>
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -2,58 +2,65 @@ ...@@ -2,58 +2,65 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="#F0E5E5E5"
android:minHeight="48dp" android:minHeight="48dp"
android:orientation="horizontal" android:orientation="horizontal">
android:background="#F0E5E5E5">
<RelativeLayout <RelativeLayout
android:layout_width="12dp" android:layout_width="12dp"
android:layout_height="fill_parent"> android:layout_height="fill_parent">
<View <View
android:id="@+id/item_group_color" android:id="@+id/item_group_color"
android:layout_width="12dp" android:layout_width="12dp"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:paddingLeft="0dp" android:layout_alignParentTop="true"
android:layout_marginLeft="0dp"/> android:layout_marginLeft="0dp"
android:paddingLeft="0dp" />
<View <View
android:layout_width="12dp" android:layout_width="12dp"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:paddingLeft="0dp" android:layout_alignParentTop="true"
android:layout_marginLeft="0dp" /> android:layout_marginLeft="0dp"
android:paddingLeft="0dp" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="48dp" android:minHeight="48dp"
android:paddingRight="8dp"> android:paddingRight="8dp">
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:padding="8dp"
android:layout_marginLeft="40dp"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" /> android:layout_alignParentLeft="true"
android:layout_marginLeft="40dp"
android:padding="8dp" />
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:padding="8dp" android:layout_alignParentLeft="true"
android:layout_marginLeft="40dp"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" /> android:layout_marginLeft="40dp"
android:padding="8dp" />
<TextView <TextView
android:id="@+id/lblListItem" android:id="@+id/lblListItem"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:padding="8dp" android:layout_centerVertical="true"
android:layout_marginLeft="48dp"
android:fontFamily="sans-serif-light" android:fontFamily="sans-serif-light"
android:layout_marginLeft="48dp" /> android:padding="8dp" />
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -2,15 +2,17 @@ ...@@ -2,15 +2,17 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="12dp" > android:paddingLeft="12dp">
<TextView <TextView
android:id="@+id/desc_header" android:id="@+id/desc_header"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:padding="8dp"
android:paddingBottom="0dp" android:paddingBottom="0dp"
android:textSize="20sp" android:text="Description"
android:text="Description"/> android:textSize="20sp" />
<TextView <TextView
android:id="@+id/desc_content" android:id="@+id/desc_content"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -18,25 +20,27 @@ ...@@ -18,25 +20,27 @@
android:layout_below="@id/desc_header" android:layout_below="@id/desc_header"
android:lineSpacingExtra="3dp" android:lineSpacingExtra="3dp"
android:padding="8dp" android:padding="8dp"
android:textSize="18sp"
android:paddingTop="0dp" android:paddingTop="0dp"
android:textIsSelectable="true"/> android:textIsSelectable="true"
android:textSize="18sp" />
<View <View
android:layout_below="@id/desc_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="96dp"/> android:layout_height="96dp"
android:layout_below="@id/desc_content" />
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:background="@color/colorSecondary"/> android:background="@color/colorSecondary" />
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:background="@color/colorSecondary"/> android:layout_alignParentTop="true"
android:background="@color/colorSecondary" />
</RelativeLayout> </RelativeLayout>
...@@ -3,14 +3,13 @@ ...@@ -3,14 +3,13 @@
android:id="@+id/row_container" android:id="@+id/row_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" > android:orientation="vertical">
<TextView <TextView
android:id="@+id/label" android:id="@+id/label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:fontFamily="sans-serif-light"
android:fontFamily="sans-serif-light" > android:padding="8dp"></TextView>
</TextView>
</LinearLayout> </LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><!--
<!--
Copyright 2014 David Morrissey Copyright 2014 David Morrissey
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
<string name="gps_network_not_enabled">Location is not enabled. Please turn on your location from the settings.</string> <string name="gps_network_not_enabled">Location is not enabled. Please turn on your location from the settings.</string>
<string name="open_location_settings">Open Location Settings</string> <string name="open_location_settings">Open Location Settings</string>
<string name="django_api"> <a href="https://github.com/wncc/IITBapp"> Django API</a></string> <string name="django_api"> <a href="https://github.com/wncc/IITBapp"> Django API</a></string>
<string name="android_app"> <a href= "https://github.com/wncc/InstiApp"> Android App</a></string> <string name="android_app"> <a href="https://github.com/wncc/InstiApp"> Android App</a></string>
<string name="angular_pwa"> <a href= "https://github.com/pulsejet/iitb-app-angular"> Angular PWA </a></string> <string name="angular_pwa"> <a href="https://github.com/pulsejet/iitb-app-angular"> Angular PWA </a></string>
<string-array name="hostels_array"> <string-array name="hostels_array">
<item>Hostel 1</item> <item>Hostel 1</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment