Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
soulfood
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
charley.punshon
soulfood
Commits
33979812
Commit
33979812
authored
May 16, 2019
by
jake.ejraee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Completed homeScreen. Might need merging with MainActivity
parent
cd69355c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
27 deletions
+58
-27
homeScreen.java
...ain/java/com/example/soulfood_assignment2/homeScreen.java
+27
-15
activity_main.xml
app/src/main/res/layout/activity_main.xml
+31
-12
No files found.
app/src/main/java/com/example/soulfood_assignment2/homeScreen.java
View file @
33979812
...
@@ -7,43 +7,50 @@ import android.support.v7.app.AppCompatActivity;
...
@@ -7,43 +7,50 @@ import android.support.v7.app.AppCompatActivity;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.view.MotionEvent
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.Button
;
public
class
homeScreen
extends
AppCompatActivity
{
public
class
homeScreen
extends
AppCompatActivity
{
int
swipeStartX
=
-
50
;
//arbitrary default value
int
swipeStartX
;
int
swipeEndX
;
int
swipeEndX
;
View
sideView
;
View
sideView
;
Button
settingsButton
;
Button
helpButton
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
setContentView
(
R
.
layout
.
activity_main
);
sideView
=
this
.
findViewById
(
R
.
id
.
sideView
);
sideView
=
this
.
findViewById
(
R
.
id
.
sideView
);
ViewCompat
.
setTranslationZ
(
sideView
,
100
f
);
//bring sideView in front of buttons
settingsButton
=
this
.
findViewById
(
R
.
id
.
buttonSettings
);
helpButton
=
this
.
findViewById
(
R
.
id
.
buttonHelp
);
ViewCompat
.
setTranslationZ
(
sideView
,
20
f
);
//bring sideView in front of buttons
}
}
@Override
@Override
public
boolean
onTouchEvent
(
MotionEvent
event
){
public
boolean
onTouchEvent
(
MotionEvent
event
){
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
){
//finger touches screen
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
){
//finger touches screen
if
(
event
.
getX
()
<=
80
){
//finger on right side of phone
swipeStartX
=
(
int
)
event
.
getX
();
swipeStartX
=
(
int
)
event
.
getX
();
}
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
){
//finger leaves screen
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
){
//finger leaves screen
if
(
swipeStartX
!=
-
50
){
//swipe from side has occurred
swipeEndX
=
(
int
)
event
.
getX
();
swipeEndX
=
(
int
)
event
.
getX
();
int
difference
=
swipeStartX
-
swipeEndX
;
int
difference
=
swipeStartX
-
swipeEndX
;
swipeStartX
=
-
50
;
//reset for future swipes
if
((
swipeStartX
<=
80
)
&&
(
difference
<
-
10
)){
//swipe from left to right
if
(
difference
<
-
10
){
//swipe was left
animateSwipeOut
();
//successful swipe
}
else
if
(
difference
>
20
){
//swipe from right to left
animateSwipe
();
animateSwipeIn
();
}
}
}
}
}
return
super
.
onTouchEvent
(
event
);
return
super
.
onTouchEvent
(
event
);
}
}
public
void
animateSwipe
(){
public
void
animateSwipeOut
(){
//bring sideview out
ObjectAnimator
anim
=
ObjectAnimator
.
ofFloat
(
sideView
,
"translationX"
,
500
f
);
ObjectAnimator
anim
=
ObjectAnimator
.
ofFloat
(
sideView
,
"translationX"
,
570
f
);
anim
.
setDuration
(
500
);
anim
.
start
();
}
public
void
animateSwipeIn
(){
//hide away sideview
ObjectAnimator
anim
=
ObjectAnimator
.
ofFloat
(
sideView
,
"translationX"
,
0
f
);
anim
.
setDuration
(
500
);
anim
.
setDuration
(
500
);
anim
.
start
();
anim
.
start
();
}
}
...
@@ -57,4 +64,9 @@ public class homeScreen extends AppCompatActivity {
...
@@ -57,4 +64,9 @@ public class homeScreen extends AppCompatActivity {
Intent
intent
=
new
Intent
(
this
,
searchScreen
.
class
);
Intent
intent
=
new
Intent
(
this
,
searchScreen
.
class
);
startActivity
(
intent
);
startActivity
(
intent
);
}
}
public
void
settingsViewOnClick
(
View
view
)
{
Intent
intent
=
new
Intent
(
this
,
settings
.
class
);
startActivity
(
intent
);
}
}
}
app/src/main/res/layout/activity_main.xml
View file @
33979812
...
@@ -4,21 +4,40 @@
...
@@ -4,21 +4,40 @@
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".
MainActivity
"
>
tools:context=
".
homeScreen
"
>
<
View
<
android.support.constraint.ConstraintLayout
android:id=
"@+id/sideView"
android:id=
"@+id/sideView"
android:layout_width=
"205dp"
android:layout_width=
"239dp"
android:layout_height=
"wrap_content"
android:layout_height=
"750dp"
android:layout_marginEnd=
"400dp"
android:layout_marginEnd=
"396dp"
android:layout_marginRight=
"400dp"
android:layout_marginRight=
"396dp"
android:alpha=
"255"
android:background=
"#FFFFFF"
android:background=
"#FFFFFFFF"
android:visibility=
"visible"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
app:layout_constraintVertical_bias=
"1.0"
/>
<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
<Button
android:id=
"@+id/suggestButton"
android:id=
"@+id/suggestButton"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment