Skip to content

Commit

Permalink
Merge pull request #20 from psx95/ps/release/v0.1-alpha
Browse files Browse the repository at this point in the history
Ps/release/v0.1 alpha
  • Loading branch information
psx95 authored Apr 21, 2018
2 parents 78239eb + 24e1141 commit 877588b
Show file tree
Hide file tree
Showing 23 changed files with 38 additions and 49 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultPublishConfig "debug"
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:support-dynamic-animation:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation project(":hiddenlinearlayoutview")
implementation project(':hidden-layout-view')
}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'


classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
apply plugin: 'com.android.library'

ext {
bintrayRepo = 'HiddenLayoutView'
bintrayName = 'hidden-layout-view'

publishedGroupId = 'com.psx95'
libraryName = 'HiddenLayoutView'
artifact = 'hidden-layout-view'

libraryDescription = 'A library to show hidden layouts with built-in animations'

siteUrl = 'https://github.com/psx95/HiddenLayout'
gitUrl = 'https://github.com/psx95/HiddenLayout.git'

libraryVersion = '0.1.0'

developerId = 'psx95'
developerName = 'Pranav Sharma'
developerEmail = '[email protected]'

licenseName = 'MIT License'
licenseUrl = 'https://opensource.org/licenses/MIT'
allLicenses = ["MIT"]
}

android {
compileSdkVersion 27

Expand Down Expand Up @@ -36,3 +60,5 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:support-dynamic-animation:27.1.1'
}
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void initView(AttributeSet attributeSet) {
inflatedUnderLayout = under.inflate();
inflatedOverLayout = over.inflate();
} else {
Log.d(TAG, "Layout inflater null");
Log.e(TAG, "Layout inflater null");
}
initListeners();
setupListeners();
Expand All @@ -88,21 +88,19 @@ private void initListeners() {
overLayoutEventListener = (view) -> {
};
animationUpdateListeners = () -> {
Log.d(TAG, "Max Pulled");
};
}

private void setupAnimations(String animationType) {
int animType = Integer.parseInt(animationType);
switch (animType) {
case 1:
Log.d(TAG, "Spring Animation");
SpringAnimationUtil springAnimationUtil = new SpringAnimationUtil(context, inflatedOverLayout,
revealViewPercentageRight, inflatedUnderLayout.findViewById(R.id.revealed_view_right),
revealViewPercentageRight, inflatedUnderLayout,
scaleHiddenView, maxMovementFactor, this);
SpringAnimation springAnimation = springAnimationUtil.getxAnimation();
if (springAnimation == null)
Log.wtf(TAG, "SPringanimation is null");
Log.wtf(TAG, "SpringAnimation is null");
springReverseAnim = springAnimationUtil.getReverseXAnim();
animation = springAnimation;
reverseAnimation = springReverseAnim;
Expand All @@ -121,7 +119,6 @@ private void setupAnimations(String animationType) {

private void loadPreferencesFromAttributes(AttributeSet attributeSet) {
if (attributeSet != null) {
Log.d(TAG, "Attribute set not null");
TypedArray typedArray = getContext().obtainStyledAttributes(attributeSet, R.styleable.HiddenLayoutView);
try {
layout_over = typedArray.getResourceId(R.styleable.HiddenLayoutView_layout_over, R.layout.over_layout_default);
Expand All @@ -132,14 +129,11 @@ private void loadPreferencesFromAttributes(AttributeSet attributeSet) {
maxMovementFactor = typedArray.getFloat(R.styleable.HiddenLayoutView_maxMovementFactorForSpring, 2);
flingFriction = typedArray.getFloat(R.styleable.HiddenLayoutView_flingFriction, 0.8f);
flingFrictionReverse = typedArray.getFloat(R.styleable.HiddenLayoutView_flingFrictionReverse, 0.001f);
Log.d(TAG, "Animation typed Array " + animationType);
if (animationType == null || animationType.equals(""))
animationType = "2";
} finally {
typedArray.recycle();
}
} else {
Log.d(TAG, "Attribute set is null ");
}
}

Expand Down Expand Up @@ -227,7 +221,6 @@ public float getFlingFrictionReverse() {

@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
private void closeOpenHiddenView() {
Log.i(TAG, "Closing View");
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ private void setSpeedForReverseAnimation() {
float pixelsRevealed = displayMetrics.widthPixels * minValue;
float dpsRevealed = UtilityFunctions.convertPixelsToDp(pixelsRevealed, activityContext);
reverseAnimationStartVelocity = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpsRevealed, this.activityContext.getResources().getDisplayMetrics());
Log.d(TAG, "pixels per second " + reverseAnimationStartVelocity + " \n pixels revealed " + pixelsRevealed);
}

private void createFlingAnimationForHome(View inflatedOverLayout) {
Expand All @@ -76,7 +75,6 @@ private void initTouchListener() {
boolean clickOccoured = false;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
Log.d(TAG, "Motion Action Down");
clickStart = Calendar.getInstance().getTimeInMillis();
pressedX = event.getX();
pressedY = event.getY();
Expand All @@ -91,17 +89,14 @@ else if (reverseFlingAnimation!=null)
if (velocityTracker == null)
break;
velocityTracker.addMovement(event);
Log.d(TAG, "Motion Action Up");
long clickDuration = Calendar.getInstance().getTimeInMillis() - clickStart;
if (clickDuration < CLICK_DURATION_IN_MILLIS && UtilityFunctions.distance(pressedX, pressedY, event.getX(), event.getY(), activityContext) < MOVE_THRESHOLD_IN_DP) {
Log.d(TAG, " Click duration " + clickDuration + " Distance " + UtilityFunctions.distance(pressedX, pressedY, event.getX(), event.getY(), activityContext));
clickOccoured = true;
}
velocityTracker.recycle();
velocityTracker = null;
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG,"ACTION MOVE");
if (velocityTracker == null)
break;
velocityTracker.addMovement(event);
Expand All @@ -114,14 +109,12 @@ else if (reverseFlingAnimation!=null)
cancelEvent.recycle();
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG,"ACTION CANCEL");
if (velocityTracker == null)
break;
velocityTracker.recycle();
velocityTracker = null;
long clickDuration1 = Calendar.getInstance().getTimeInMillis() - clickStart;
if (clickDuration1 < CLICK_DURATION_IN_MILLIS && UtilityFunctions.distance(pressedX, pressedY, event.getX(), event.getY(), activityContext) < MOVE_THRESHOLD_IN_DP) {
Log.d(TAG, " Click duration " + clickDuration1 + " Distance " + UtilityFunctions.distance(pressedX, pressedY, event.getX(), event.getY(), activityContext));
clickOccoured = true;
}
break;
Expand All @@ -138,14 +131,11 @@ else if (reverseFlingAnimation!=null)

private void setTouchListenerOnView(View inflatedOverLayout) {
if (inflatedOverLayout instanceof ViewGroup) {
Log.d(TAG, "FOUND multiple children inside view");
for (int i = 0; i < ((ViewGroup) inflatedOverLayout).getChildCount(); i++) {
View childView = ((ViewGroup) inflatedOverLayout).getChildAt(i);
childView.setOnTouchListener(onTouchListener);
Log.d(TAG, " ID " + childView.getId() + " found at pos " + i);
}
} else {
Log.d(TAG, "No Child views");
inflatedOverLayout.setOnTouchListener(onTouchListener);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public SpringAnimationUtil(Context context, View animatedView, float revealViewP
((Activity)animatedView.getContext()).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
finalPosDiff = displayMetrics.widthPixels * revealViewPercentageRight;
maxMovement = maxMovementFactor*finalPosDiff;
Log.i(TAG,"FInal pos Diff "+finalPosDiff);
Log.d(TAG,"MaX Movement allowed "+maxMovement);
this.hiddenLayoutView = hiddenLayoutView;
this.animatedView = animatedView;
this.underLayout = underLayout;
Expand Down Expand Up @@ -70,7 +68,6 @@ public boolean onTouch(View v, MotionEvent event) {
reverseXAnim.cancel();
xAnimation.cancel();
maxReached = false;
Log.d(TAG,"MOTION ACTION DOWN");
velocityTracker = VelocityTracker.obtain();
velocityTracker.addMovement(event);
return false;
Expand All @@ -79,7 +76,6 @@ public boolean onTouch(View v, MotionEvent event) {
break;
velocityTracker.addMovement(event);
float movement = event.getRawX() + dX;
Log.d(TAG,"Movement Action move"+movement);
float scaleFactor = movement > 0 ? -0.04f : 0.04f;
if (!scalehiddenView)
scaleFactor = 0;
Expand All @@ -100,10 +96,7 @@ public boolean onTouch(View v, MotionEvent event) {
if (velocityTracker == null)
break;
velocityTracker.addMovement(event);
Log.d(TAG,"Motion UP ");
if ((event.getRawX() + dX) < -finalPosDiff/2) {
// Toast.makeText(context,"X Animation", Toast.LENGTH_SHORT).show();
Log.d(TAG,"Anim "+(event.getRawX() + dX));
xAnimation.start();
hiddenViewRevealed = true;
} else if ((event.getRawX() + dX) < 0 && (event.getRawX() + dX) > -finalPosDiff/2){
Expand All @@ -112,48 +105,35 @@ public boolean onTouch(View v, MotionEvent event) {
hiddenViewRevealed = false;
}
else if ((event.getRawX() + dX) > 0){
Toast.makeText(context,"Reverse Animation",Toast.LENGTH_SHORT).show();
Log.d(TAG,"reverse Anim "+(event.getRawX() + dX));
reverseXAnim.start();
hiddenViewRevealed = false;
}
underLayout.animate().scaleX(1f).setDuration(0).start();
if (Math.abs(event.getRawX() + dX) >= maxMovement) {
hiddenLayoutView.animationUpdateListeners.onMaxSpringPull();
} else {
Log.i(TAG,"Not a max pull event max Movement "+maxMovement +" actual move "+(event.getRawX()+dX));
}
Log.d(TAG,"Motion UP ");
velocityTracker.recycle();
velocityTracker = null;
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG,"ACTION CANCEL");
if (velocityTracker == null)
break;
velocityTracker.recycle();
velocityTracker = null;
if ((event.getRawX() + dX) < -finalPosDiff/2) {
// Toast.makeText(context,"X Animation", Toast.LENGTH_SHORT).show();
Log.d(TAG,"Anim "+(event.getRawX() + dX));
xAnimation.start();
hiddenViewRevealed = true;
} else if ((event.getRawX() + dX) < 0 && (event.getRawX() + dX) > -finalPosDiff/2){
// Log.d(TAG,"Reverse Anim "+(event.getRawX() + dX));
reverseXAnim.start();
hiddenViewRevealed = false;
}
else if ((event.getRawX() + dX) > 0){
Toast.makeText(context,"Reverse Animation",Toast.LENGTH_SHORT).show();
Log.d(TAG,"reverse Anim "+(event.getRawX() + dX));
reverseXAnim.start();
hiddenViewRevealed = false;
}
underLayout.animate().scaleX(1f).setDuration(0).start();
if (Math.abs(event.getRawX() + dX) >= maxMovement) {
hiddenLayoutView.animationUpdateListeners.onMaxSpringPull();
} else {
Log.i(TAG,"Not a max pull event max Movement "+maxMovement +" actual move "+(event.getRawX()+dX));
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ private static float pxToDp(float px, Context context) {
public static float convertPixelsToDp(float px, Context context){
Resources resources = context.getResources();
DisplayMetrics metrics = resources.getDisplayMetrics();
float dp = px / ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
return dp;
return px / ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
android:layout_height="wrap_content"
android:layout_below="@+id/current_area_home"
android:gravity="center"
android:text="ACRES"
android:text="SPEED"
android:textSize="12dp"
android:textStyle="bold" />
</RelativeLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Last Seen"
android:text="Last Synced"
android:textSize="11dp"
android:gravity="center"
android:paddingTop="4dp"
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':app', ':hiddenlinearlayoutview'
include ':app', ':hidden-layout-view'

0 comments on commit 877588b

Please sign in to comment.