Commit 33979812 authored by jake.ejraee's avatar jake.ejraee

Completed homeScreen. Might need merging with MainActivity

parent cd69355c
......@@ -7,43 +7,50 @@ import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
public class homeScreen extends AppCompatActivity {
int swipeStartX = -50; //arbitrary default value
int swipeStartX;
int swipeEndX;
View sideView;
Button settingsButton;
Button helpButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sideView = this.findViewById(R.id.sideView);
ViewCompat.setTranslationZ(sideView, 100f); //bring sideView in front of buttons
settingsButton = this.findViewById(R.id.buttonSettings);
helpButton = this.findViewById(R.id.buttonHelp);
ViewCompat.setTranslationZ(sideView, 20f); //bring sideView in front of buttons
}
@Override
public boolean onTouchEvent(MotionEvent event){
if(event.getAction() == MotionEvent.ACTION_DOWN){ //finger touches screen
if(event.getX() <= 80){ //finger on right side of phone
swipeStartX = (int)event.getX();
}
}else if(event.getAction() == MotionEvent.ACTION_UP){ //finger leaves screen
if(swipeStartX != -50){ //swipe from side has occurred
swipeEndX = (int)event.getX();
int difference = swipeStartX - swipeEndX;
swipeStartX = -50; //reset for future swipes
if(difference < -10){ //swipe was left
//successful swipe
animateSwipe();
}
if((swipeStartX <= 80) && (difference < -10)){ //swipe from left to right
animateSwipeOut();
}else if(difference > 20){ //swipe from right to left
animateSwipeIn();
}
}
return super.onTouchEvent(event);
}
public void animateSwipe(){
ObjectAnimator anim = ObjectAnimator.ofFloat(sideView, "translationX", 500f);
public void animateSwipeOut(){ //bring sideview out
ObjectAnimator anim = ObjectAnimator.ofFloat(sideView, "translationX", 570f);
anim.setDuration(500);
anim.start();
}
public void animateSwipeIn(){ //hide away sideview
ObjectAnimator anim = ObjectAnimator.ofFloat(sideView, "translationX", 0f);
anim.setDuration(500);
anim.start();
}
......@@ -57,4 +64,9 @@ public class homeScreen extends AppCompatActivity {
Intent intent = new Intent(this, searchScreen.class);
startActivity(intent);
}
public void settingsViewOnClick(View view) {
Intent intent = new Intent(this, settings.class);
startActivity(intent);
}
}
......@@ -4,21 +4,40 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
tools:context=".homeScreen">
<View
<android.support.constraint.ConstraintLayout
android:id="@+id/sideView"
android:layout_width="205dp"
android:layout_height="wrap_content"
android:layout_marginEnd="400dp"
android:layout_marginRight="400dp"
android:alpha="255"
android:background="#FFFFFFFF"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="239dp"
android:layout_height="750dp"
android:layout_marginEnd="396dp"
android:layout_marginRight="396dp"
android:background="#FFFFFF"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="@+id/buttonHelp"
android:layout_width="181dp"
android:layout_height="52dp"
android:layout_marginTop="176dp"
android:layout_marginEnd="28dp"
android:layout_marginRight="28dp"
android:text="Help and Support"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/buttonSettings"
android:layout_width="138dp"
android:layout_height="52dp"
android:layout_marginTop="84dp"
android:layout_marginEnd="48dp"
android:layout_marginRight="48dp"
android:text="Settings"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<Button
android:id="@+id/suggestButton"
......
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