Skip to content

Commit c0a9001

Browse files
committed
changes to animations
1 parent fa7d9f2 commit c0a9001

26 files changed

+633
-41
lines changed

Diff for: build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.1.2'
8+
classpath 'com.android.tools.build:gradle:2.1.3'
99
// NOTE: Do not place your application dependencies here; they belong
1010
// in the individual module build.gradle files
1111
}

Diff for: gestureframework/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 22
4+
compileSdkVersion 23
55
buildToolsVersion '23.0.2'
66

77
defaultConfig {

Diff for: gestureframework/src/main/java/hs_mannheim/gestureframework/animation/DragAndDropper.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ public void dragDrop(TouchPoint touchPoint){
6666

6767
//TODO: still needs work
6868
if (mShouldDragX){
69-
mLayoutParams.leftMargin = (int) (touchPoint.getX() - mDeltaPoint.getX());
69+
mView.setX(touchPoint.getX());
70+
//mLayoutParams.leftMargin = (int) (touchPoint.getX() - mDeltaPoint.getX());
7071
}
7172

7273
if (mShouldDragY){
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Copyright (C) 2016 Insitute for User Experience and Interaction Design,
3+
* Hochschule Mannheim University of Applied Sciences
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License
16+
*
17+
*/
18+
19+
package hs_mannheim.gestureframework.animation;
20+
21+
import android.content.Context;
22+
import android.content.res.TypedArray;
23+
import android.graphics.Canvas;
24+
import android.graphics.drawable.Drawable;
25+
import android.util.AttributeSet;
26+
import android.widget.ImageView;
27+
28+
import hs_mannheim.gestureframework.R;
29+
30+
31+
public class ForegroundImageView extends ImageView {
32+
private Drawable foreground;
33+
34+
public ForegroundImageView(Context context) {
35+
this(context, null);
36+
}
37+
38+
public ForegroundImageView(Context context, AttributeSet attrs) {
39+
super(context, attrs);
40+
41+
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundImageView);
42+
Drawable foreground = a.getDrawable(R.styleable.ForegroundImageView_android_foreground);
43+
if (foreground != null) {
44+
setForeground(foreground);
45+
}
46+
a.recycle();
47+
}
48+
49+
/**
50+
* Supply a drawable resource that is to be rendered on top of all of the child
51+
* views in the frame layout.
52+
*
53+
* @param drawableResId The drawable resource to be drawn on top of the children.
54+
*/
55+
public void setForegroundResource(int drawableResId) {
56+
setForeground(getContext().getResources().getDrawable(drawableResId));
57+
}
58+
59+
/**
60+
* Supply a Drawable that is to be rendered on top of all of the child
61+
* views in the frame layout.
62+
*
63+
* @param drawable The Drawable to be drawn on top of the children.
64+
*/
65+
public void setForeground(Drawable drawable) {
66+
if (foreground == drawable) {
67+
return;
68+
}
69+
if (foreground != null) {
70+
foreground.setCallback(null);
71+
unscheduleDrawable(foreground);
72+
}
73+
74+
foreground = drawable;
75+
76+
if (drawable != null) {
77+
drawable.setCallback(this);
78+
if (drawable.isStateful()) {
79+
drawable.setState(getDrawableState());
80+
}
81+
}
82+
requestLayout();
83+
invalidate();
84+
}
85+
86+
@Override protected boolean verifyDrawable(Drawable who) {
87+
return super.verifyDrawable(who) || who == foreground;
88+
}
89+
90+
@Override public void jumpDrawablesToCurrentState() {
91+
super.jumpDrawablesToCurrentState();
92+
if (foreground != null) foreground.jumpToCurrentState();
93+
}
94+
95+
@Override protected void drawableStateChanged() {
96+
super.drawableStateChanged();
97+
if (foreground != null && foreground.isStateful()) {
98+
foreground.setState(getDrawableState());
99+
}
100+
}
101+
102+
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
103+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
104+
if (foreground != null) {
105+
foreground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
106+
invalidate();
107+
}
108+
}
109+
110+
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) {
111+
super.onSizeChanged(w, h, oldw, oldh);
112+
if (foreground != null) {
113+
foreground.setBounds(0, 0, w, h);
114+
invalidate();
115+
}
116+
}
117+
118+
@Override public void draw(Canvas canvas) {
119+
super.draw(canvas);
120+
121+
if (foreground != null) {
122+
foreground.draw(canvas);
123+
}
124+
}
125+
}

Diff for: gestureframework/src/main/java/hs_mannheim/gestureframework/gesture/shake/ShakeDetector.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void onSensorChanged(SensorEvent event) {
6666
float gZ = z / SensorManager.GRAVITY_EARTH;
6767

6868
// gForce will be close to 1 when there is no movement.
69-
float gForce = FloatMath.sqrt(gX * gX + gY * gY + gZ * gZ);
69+
float gForce = (float) Math.sqrt(gX * gX + gY * gY + gZ * gZ);
7070

7171
if (gForce > SHAKE_THRESHOLD_GRAVITY) {
7272
final long now = System.currentTimeMillis();

Diff for: gestureframework/src/main/java/hs_mannheim/gestureframework/model/GestureManager.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ public void onGestureDetected(GestureDetector gestureDetector) {
176176

177177
@Override
178178
public void onSwipeDetected(SwipeDetector swipeDetector, SwipeEvent event) {
179-
179+
for (SwipeDetector.SwipeEventListener swipeEventListener : mSwipeEventListeners) {
180+
swipeEventListener.onSwipeDetected(swipeDetector, event);
181+
}
180182
}
181183

182184
@Override

Diff for: gestureframework/src/main/res/values/attrs.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2016 Insitute for User Experience and Interaction Design,
4+
~ Hochschule Mannheim University of Applied Sciences
5+
~
6+
~ Licensed under the Apache License, Version 2.0 (the "License");
7+
~ you may not use this file except in compliance with the License.
8+
~ You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License
17+
~
18+
-->
19+
20+
<resources>
21+
<declare-styleable name="ForegroundImageView">
22+
<attr name="android:foreground"/>
23+
</declare-styleable>
24+
</resources>

Diff for: gradle/wrapper/gradle-wrapper.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu Jan 21 11:59:22 CET 2016
1+
#Tue Aug 30 11:40:50 CEST 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

Diff for: plug_swipe_left.png

10.2 KB
Loading

Diff for: sysplace/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ android {
2222
dependencies {
2323
compile fileTree(dir: 'libs', include: ['*.jar'])
2424
testCompile 'junit:junit:4.12'
25+
compile 'com.github.traex.rippleeffect:library:1.3'
2526
compile 'com.android.support:appcompat-v7:23.3.0'
2627
compile project(':gestureframework')
2728
}

Diff for: sysplace/src/main/java/hs_mannheim/sysplace/ConnectedActivity.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
package hs_mannheim.sysplace;
22

33
import android.content.Intent;
4+
import android.content.res.ColorStateList;
45
import android.graphics.Bitmap;
56
import android.graphics.BitmapFactory;
7+
import android.graphics.Color;
68
import android.graphics.Point;
9+
import android.graphics.drawable.Drawable;
10+
import android.graphics.drawable.RippleDrawable;
711
import android.os.Bundle;
12+
import android.support.v4.content.res.ResourcesCompat;
813
import android.support.v7.app.AppCompatActivity;
914
import android.view.View;
15+
import android.widget.ImageView;
1016
import android.widget.Toast;
1117

1218
import java.io.InputStream;
@@ -40,6 +46,7 @@ public class ConnectedActivity extends AppCompatActivity implements IViewContext
4046
private SysplaceContext mSysplaceContext;
4147
private final String TAG = "[ConnectedActivity]";
4248
private ViewWrapper mViewWrapper;
49+
private ImageView mImageView;
4350
private GestureAnimator mReceiveAnimator, mSelectAnimator;
4451
private TransitionAnimator mSendAnimator;
4552
private boolean mShouldDragDrop = false;
@@ -58,13 +65,19 @@ protected void onCreate(Bundle savedInstanceState) {
5865
mSysplaceContext.updateViewContext(LifecycleEvent.SELECT, this);
5966
mSysplaceContext.updateViewContext(LifecycleEvent.TRANSFER, this);
6067

61-
6268
mSendAnimator = new ElevateAndLeaveAnimator(this, mViewWrapper.getView());
6369
mSelectAnimator = new FlipSelectAnimator(this, mViewWrapper.getView());
6470
mReceiveAnimator = new FlyInAndLowerAnimator(this, mViewWrapper.getView());
6571

6672
mSysplaceContext.registerForSwipeEvents(this);
6773
AnimationsContainer.getInstance().registerListener(this);
74+
75+
//TODO: UGLY
76+
mImageView = (ImageView) mViewWrapper.getView();
77+
Drawable polaroid = ResourcesCompat.getDrawable(getResources(), R.drawable.polaroid, null);
78+
RippleDrawable ripplePolaroid = new RippleDrawable(ColorStateList.valueOf(Color.argb(255, 62, 62, 62)), polaroid, null);
79+
//mImageView.setImageDrawable(ripplePolaroid);
80+
6881
}
6982

7083
@Override

Diff for: sysplace/src/main/java/hs_mannheim/sysplace/MainActivity.java

+74-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.graphics.Color;
66
import android.graphics.Point;
77
import android.os.Bundle;
8+
import android.os.Handler;
89
import android.os.StrictMode;
910
import android.os.Vibrator;
1011
import android.support.v7.app.AppCompatActivity;
@@ -17,16 +18,20 @@
1718
import android.widget.Toast;
1819

1920
import hs_mannheim.gestureframework.ConfigurationBuilder;
20-
import hs_mannheim.gestureframework.gesture.approach.ApproachDetector;
21+
import hs_mannheim.gestureframework.gesture.swipe.SwipeDetector;
22+
import hs_mannheim.gestureframework.gesture.swipe.SwipeEvent;
23+
import hs_mannheim.gestureframework.gesture.swipe.TouchPoint;
2124
import hs_mannheim.gestureframework.messaging.IPacketReceiver;
2225
import hs_mannheim.gestureframework.messaging.Packet;
2326
import hs_mannheim.gestureframework.model.IViewContext;
2427
import hs_mannheim.gestureframework.model.InteractionApplication;
2528
import hs_mannheim.gestureframework.model.Selection;
2629
import hs_mannheim.gestureframework.model.SysplaceContext;
2730
import hs_mannheim.gestureframework.model.ViewWrapper;
31+
import hs_mannheim.sysplace.animations.PlugAnimator;
32+
import hs_mannheim.sysplace.animations.SocketAnimator;
2833

29-
public class MainActivity extends AppCompatActivity implements IViewContext, IPacketReceiver {
34+
public class MainActivity extends AppCompatActivity implements IViewContext, IPacketReceiver, SwipeDetector.SwipeEventListener {
3035
private static final String TAG = "[Main Activity]";
3136

3237
private TextView mTextView;
@@ -35,6 +40,9 @@ public class MainActivity extends AppCompatActivity implements IViewContext, IPa
3540
private Button mPhotoButton;
3641
private Button mDisconnectButton;
3742
private SysplaceContext mSysplaceContext;
43+
private PlugAnimator mPlugAnimator;
44+
private SocketAnimator mSocketAnimator;
45+
private boolean mIsConnectionEstablished;
3846

3947
@Override
4048
protected void onCreate(Bundle savedInstanceState) {
@@ -68,10 +76,17 @@ protected void onCreate(Bundle savedInstanceState) {
6876
mSysplaceContext = ((InteractionApplication) getApplicationContext()).getSysplaceContext();
6977
mEditText.addTextChangedListener(new SysplaceTextWatcher(mSysplaceContext));
7078

79+
//////////////////////////////////////
80+
81+
View plugView = findViewById(R.id.plug), socketView = findViewById(R.id.socket);
82+
mPlugAnimator = new PlugAnimator(this, plugView, getDisplaySize());
83+
mSocketAnimator = new SocketAnimator(this, socketView, getDisplaySize());
84+
85+
86+
//////////////////////////////////////
7187
mSysplaceContext.activate(this);
7288

73-
//TODO: take this out again. saves time on animation testing
74-
mPhotoButton.setEnabled(true);
89+
mSysplaceContext.registerForSwipeEvents(this);
7590
}
7691

7792

@@ -135,6 +150,14 @@ public void receive(Packet packet) {
135150
//TODO: turn this on again. was getting on my nerves >:(
136151
//((Vibrator) this.getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE)).vibrate(700);
137152

153+
mIsConnectionEstablished = true;
154+
155+
if (mSwipeOrientation == SwipeEvent.Orientation.WEST) {
156+
mSocketAnimator.plugIn();
157+
} else if (mSwipeOrientation == SwipeEvent.Orientation.EAST) {
158+
mPlugAnimator.plugIn();
159+
}
160+
138161
break;
139162
case ConnectionLost:
140163
mTextView.setText(R.string.not_connected_info);
@@ -151,5 +174,52 @@ public void receive(Packet packet) {
151174
break;
152175
}
153176
}
177+
178+
private SwipeEvent.Orientation mSwipeOrientation;
179+
private boolean isPeakedIn;
180+
181+
@Override
182+
public void onSwipeDetected(SwipeDetector swipeDetector, SwipeEvent event) {
183+
mSwipeOrientation = event.getOrientation();
184+
185+
if (!isPeakedIn) {
186+
if (mSwipeOrientation == SwipeEvent.Orientation.WEST) {
187+
mSocketAnimator.play();
188+
} else if (mSwipeOrientation == SwipeEvent.Orientation.EAST) {
189+
mPlugAnimator.play();
190+
}
191+
isPeakedIn = true;
192+
193+
new Handler().postDelayed(new Runnable() {
194+
@Override
195+
public void run() {
196+
if (!mIsConnectionEstablished) {
197+
if (mSwipeOrientation == SwipeEvent.Orientation.WEST) {
198+
mSocketAnimator.retreat();
199+
} else if (mSwipeOrientation == SwipeEvent.Orientation.EAST) {
200+
mPlugAnimator.retreat();
201+
}
202+
203+
isPeakedIn = false;
204+
}
205+
}
206+
}, 5000);
207+
}
208+
}
209+
210+
@Override
211+
public void onSwiping(SwipeDetector swipeDetector, TouchPoint touchPoint) {
212+
213+
}
214+
215+
@Override
216+
public void onSwipeStart(SwipeDetector swipeDetector, TouchPoint touchPoint, View view) {
217+
218+
}
219+
220+
@Override
221+
public void onSwipeEnd(SwipeDetector swipeDetector, TouchPoint touchPoint) {
222+
223+
}
154224
}
155225

0 commit comments

Comments
 (0)