Skip to content

Commit

Permalink
Working on new app style
Browse files Browse the repository at this point in the history
  • Loading branch information
avalax committed Sep 3, 2017
1 parent 2521c24 commit b51d887
Show file tree
Hide file tree
Showing 20 changed files with 294 additions and 53 deletions.
37 changes: 37 additions & 0 deletions art/icons/ic_launcher/web_hi_res.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 17 additions & 11 deletions build.gradle
Expand Up @@ -87,13 +87,19 @@ android {
} }
} }
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
} }


dependencies { dependencies {
implementation 'com.android.support:support-v4:26.0.2'
//implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support:design:26.0.2'
implementation 'com.google.zxing:android-integration:3.3.0'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.google.dagger:dagger:2.11'

annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
androidTestAnnotationProcessor 'com.google.dagger:dagger-compiler:2.11'

testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation 'org.hamcrest:hamcrest-all:1.3' testImplementation 'org.hamcrest:hamcrest-all:1.3'
testImplementation 'org.mockito:mockito-all:1.10.19' testImplementation 'org.mockito:mockito-all:1.10.19'
Expand All @@ -103,17 +109,17 @@ dependencies {
exclude module: 'commons-logging' exclude module: 'commons-logging'
exclude module: 'httpclient' exclude module: 'httpclient'
} }
androidTestImplementation 'com.android.support:support-annotations:26.0.1' androidTestImplementation 'com.android.support:support-annotations:26.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1' androidTestImplementation 'com.android.support.test:rules:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestImplementation('com.android.support.test.espresso:espresso-contrib:3.0.1') {
exclude module: 'support-v4'
exclude module: 'recyclerview-v7'
exclude module: 'appcompat-v7'
exclude module: 'design'
}
androidTestUtil 'com.android.support.test:orchestrator:1.0.1' androidTestUtil 'com.android.support.test:orchestrator:1.0.1'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.android.support:support-v4:26.0.1'
implementation 'com.google.zxing:android-integration:3.3.0'
implementation 'com.google.dagger:dagger:2.11'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
androidTestAnnotationProcessor 'com.google.dagger:dagger-compiler:2.11'
} }


versioneye { versioneye {
Expand Down
Expand Up @@ -4,6 +4,7 @@
import android.support.test.filters.LargeTest; import android.support.test.filters.LargeTest;
import android.support.test.runner.AndroidJUnit4; import android.support.test.runner.AndroidJUnit4;


import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
Expand All @@ -19,11 +20,13 @@
import static android.support.test.espresso.matcher.ViewMatchers.isEnabled; import static android.support.test.espresso.matcher.ViewMatchers.isEnabled;
import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText; import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.not; import static de.avalax.fitbuddy.runner.BottomNavigationMatcher.bottomNavItemIsChecked;
import static de.avalax.fitbuddy.runner.BottomNavigationMatcher.bottomNavItemIsNotChecked;


@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
@LargeTest @LargeTest
public class MainActivityTest { public class FitbuddyAcceptanceTest {

private int actionBarTitleId() { private int actionBarTitleId() {
Resources resources = activityRule.getActivity().getResources(); Resources resources = activityRule.getActivity().getResources();
return resources.getIdentifier("action_bar_title", "id", "android"); return resources.getIdentifier("action_bar_title", "id", "android");
Expand All @@ -34,6 +37,16 @@ private int actionBarTitleId() {
MainActivity.class); MainActivity.class);


@Test @Test
public void initialStart_shouldShowStartFragmentOnly() throws Exception {
activityRule.launchActivity();

onView(withId(R.id.navigation_start_item)).check(matches(bottomNavItemIsChecked()));
onView(withId(R.id.navigation_workout_item)).check(matches(bottomNavItemIsNotChecked()));
onView(withId(R.id.navigation_statistics_item)).check(matches(bottomNavItemIsNotChecked()));
}

@Test
@Ignore
public void switchedToWorkout_shouldShowWorkoutActivity() throws Exception { public void switchedToWorkout_shouldShowWorkoutActivity() throws Exception {
BasicWorkout workout = new BasicWorkout(); BasicWorkout workout = new BasicWorkout();
Exercise exercise = workout.getExercises().createExercise(); Exercise exercise = workout.getExercises().createExercise();
Expand All @@ -43,18 +56,9 @@ public void switchedToWorkout_shouldShowWorkoutActivity() throws Exception {


activityRule.launchActivity(); activityRule.launchActivity();


onView(withId(R.id.continue_workout_button)).check(matches(isEnabled())); onView(withId(R.id.navigation_start_item)).check(matches(isEnabled()));
onView(withId(R.id.continue_workout_button)).perform(click()); onView(withId(R.id.navigation_start_item)).perform(click());


onView(withId(actionBarTitleId())).check(matches(withText("first_exercise"))); onView(withId(actionBarTitleId())).check(matches(withText("first_exercise")));
} }

@Test
public void noWorkoutCreated_shouldShowMainActivity() throws Exception {
activityRule.getWorkoutSession().switchWorkout(null);

activityRule.launchActivity();

onView(withId(R.id.continue_workout_button)).check(matches(not(isEnabled())));
}
} }
@@ -0,0 +1,40 @@
package de.avalax.fitbuddy.runner;

import android.annotation.SuppressLint;
import android.support.design.internal.BottomNavigationItemView;
import android.support.test.espresso.matcher.BoundedMatcher;
import android.view.View;

import org.hamcrest.Description;
import org.hamcrest.Matcher;

public class BottomNavigationMatcher {
public static Matcher<View> bottomNavItemIsChecked() {
return withBottomNavItemCheckedStatus(true);
}

public static Matcher<View> bottomNavItemIsNotChecked() {
return withBottomNavItemCheckedStatus(false);
}

private static Matcher<View> withBottomNavItemCheckedStatus(final boolean isChecked) {
return new BoundedMatcher<View, BottomNavigationItemView>(BottomNavigationItemView.class) {
boolean triedMatching;

@Override
public void describeTo(Description description) {
if (triedMatching) {
description.appendText("with BottomNavigationItem check status: " + String.valueOf(isChecked));
description.appendText("But was: " + String.valueOf(!isChecked));
}
}

@SuppressLint("RestrictedApi")
@Override
protected boolean matchesSafely(BottomNavigationItemView item) {
triedMatching = true;
return item.getItemData().isChecked() == isChecked;
}
};
}
}
Expand Up @@ -6,6 +6,7 @@
import javax.inject.Inject; import javax.inject.Inject;


import de.avalax.fitbuddy.application.workout.WorkoutSession; import de.avalax.fitbuddy.application.workout.WorkoutSession;
import de.avalax.fitbuddy.domain.model.workout.WorkoutRepository;
import de.avalax.fitbuddy.presentation.MainActivity; import de.avalax.fitbuddy.presentation.MainActivity;


import static de.avalax.fitbuddy.runner.TestFitbuddyApplication.TestComponent; import static de.avalax.fitbuddy.runner.TestFitbuddyApplication.TestComponent;
Expand All @@ -15,6 +16,9 @@ public class FitbuddyActivityTestRule extends ActivityTestRule<MainActivity> {
@Inject @Inject
WorkoutSession workoutSession; WorkoutSession workoutSession;


@Inject
WorkoutRepository workoutRepository;

public FitbuddyActivityTestRule(Class<MainActivity> activityClass) { public FitbuddyActivityTestRule(Class<MainActivity> activityClass) {
super(activityClass); super(activityClass);
} }
Expand All @@ -30,6 +34,10 @@ public WorkoutSession getWorkoutSession() {
return workoutSession; return workoutSession;
} }


public void setWorkoutRepository(WorkoutRepository workoutRepository) {
this.workoutRepository = workoutRepository;
}

public MainActivity launchActivity() { public MainActivity launchActivity() {
return super.launchActivity(new Intent()); return super.launchActivity(new Intent());
} }
Expand Down
11 changes: 10 additions & 1 deletion src/main/AndroidManifest.xml
Expand Up @@ -22,7 +22,16 @@
<data android:scheme="http" android:host="fitbuddy.de" /> <data android:scheme="http" android:host="fitbuddy.de" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".presentation.MainActivity" /> <activity android:name=".presentation.MainActivity" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="fitbuddy.de" />
</intent-filter>
</activity>
<activity android:name=".presentation.edit.workout.EditWorkoutActivity"/> <activity android:name=".presentation.edit.workout.EditWorkoutActivity"/>
<activity android:name=".presentation.edit.exercise.EditExerciseActivity"/> <activity android:name=".presentation.edit.exercise.EditExerciseActivity"/>
<activity android:name=".presentation.summary.FinishedWorkoutActivity"/> <activity android:name=".presentation.summary.FinishedWorkoutActivity"/>
Expand Down
21 changes: 13 additions & 8 deletions src/main/java/de/avalax/fitbuddy/presentation/MainActivity.java
@@ -1,23 +1,28 @@
package de.avalax.fitbuddy.presentation; package de.avalax.fitbuddy.presentation;


import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.FragmentActivity; import android.support.v7.app.AppCompatActivity;
import android.view.View; import android.support.v7.widget.Toolbar;
import android.view.Menu;


import de.avalax.fitbuddy.R; import de.avalax.fitbuddy.R;
import de.avalax.fitbuddy.presentation.workout.WorkoutActivity;


public class MainActivity extends FragmentActivity { public class MainActivity extends AppCompatActivity {


@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);

Toolbar toolbar = findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
} }


public void continueWorkout(View view) { // Menu icons are inflated just as they were with actionbar
Intent intent = new Intent(this, WorkoutActivity.class); @Override
startActivity(intent); public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
} }
} }
Expand Up @@ -27,8 +27,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
} }


private void init(View view) { private void init(View view) {
View continueWorkoutButton = view.findViewById(R.id.continue_workout_button);
continueWorkoutButton.setEnabled(workoutSession.hasWorkout());
} }




Expand Down
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_menu_home.xml
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_menu_summary.xml
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M4,6L2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6zM20,2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM20,12l-2.5,-1.5L15,12L15,4h5v8z"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/ic_menu_support.xml
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M11,17h2v-1h1c0.55,0 1,-0.45 1,-1v-3c0,-0.55 -0.45,-1 -1,-1h-3v-1h4L15,8h-2L13,7h-2v1h-1c-0.55,0 -1,0.45 -1,1v3c0,0.55 0.45,1 1,1h3v1L9,14v2h2v1zM20,4L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,6c0,-1.11 -0.89,-2 -2,-2zM20,18L4,18L4,6h16v12z"/>
</vector>
17 changes: 17 additions & 0 deletions src/main/res/drawable/ic_menu_workout.xml
@@ -0,0 +1,17 @@
<vector android:height="24dp" android:viewportHeight="442.0"
android:viewportWidth="459.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFF"
android:pathData="M111.4,44.9c-5.4,3.9 -7.1,6 -8.9,11 -1.3,3.8 -1.5,23.4 -1.5,164.1 0,177.4 -0.5,164.8 6.7,172.2 6.2,6.4 9.3,7 31.6,6.6l19.5,-0.3 4.4,-3c5,-3.6 8.4,-8.2 9.8,-13.6 0.7,-2.4 0.9,-58.4 0.8,-164.1l-0.3,-160.3 -2.8,-4.8c-1.6,-2.6 -4.7,-6.1 -6.9,-7.7l-4.1,-3 -22.2,0 -22.2,0 -3.9,2.9z" android:strokeColor="#00000000"/>
<path android:fillColor="#FFFFFF"
android:pathData="M293.8,45.3c-2.4,1.8 -5.4,5.3 -6.8,7.7l-2.5,4.5 -0.3,159.5c-0.2,118.5 0,160.9 0.8,164.9 1,4.3 2.2,6.3 6,10.2 2.9,2.9 6.3,5.2 8.6,5.8 2.2,0.6 12,1.1 21.9,1.1 20.2,0 23.2,-0.8 29.2,-7.1 6.7,-7.1 6.3,4.5 6.3,-171.9 0,-140.7 -0.2,-160.3 -1.5,-164.1 -1.8,-5 -3.5,-7.1 -8.9,-11l-3.9,-2.9 -22.3,0 -22.2,0 -4.4,3.3z" android:strokeColor="#00000000"/>
<path android:fillColor="#FFFFFF"
android:pathData="M38.3,85.1c-3.7,1.1 -9,6.1 -10.5,9.8 -0.6,1.7 -0.9,47.2 -1,125.3 0,137.2 -0.5,127.4 7.1,132.3 6.1,4 11.4,4.7 31.8,4.3 20,-0.4 22.3,-0.9 28.1,-6.2 5.5,-4.9 5.2,2.1 5.2,-130 0,-84.3 -0.3,-123.3 -1.1,-125.3 -1.5,-4 -4.8,-7.3 -9.4,-9.4 -3.5,-1.6 -6.6,-1.8 -25.5,-1.8 -11.8,0 -22.9,0.5 -24.7,1z" android:strokeColor="#00000000"/>
<path android:fillColor="#FFFFFF"
android:pathData="M371.5,84.7c-3.1,0.8 -9.4,6.2 -11.1,9.4 -1.3,2.5 -1.4,18.7 -1.4,126 0,136.2 -0.5,125.9 6.7,131.8 5,4.2 10.6,5.1 30.2,5.1 20.2,0 24.8,-1.1 30.6,-7l4,-4.1 0.5,-61.2c0.3,-33.7 0.3,-90.2 0,-125.7l-0.5,-64.5 -2.3,-3.1c-5,-6.6 -6.3,-6.9 -31.7,-7.1 -12.6,-0.1 -23.9,0.1 -25,0.4z" android:strokeColor="#00000000"/>
<path android:fillColor="#FFFFFF"
android:pathData="M175.6,192.6c-0.3,2.6 -0.6,16.5 -0.6,30.9 0,24.1 0.1,26.3 1.8,27.8 1.7,1.5 6.8,1.7 52.4,1.7 48.4,0 50.6,-0.1 52.2,-1.9 1.6,-1.7 1.7,-4.6 1.4,-31.3 -0.2,-16.1 -0.7,-29.9 -1.1,-30.6 -0.6,-0.9 -12.4,-1.2 -53.1,-1.2l-52.3,0 -0.7,4.6z" android:strokeColor="#00000000"/>
<path android:fillColor="#FFFFFF"
android:pathData="M6.7,199.8c-1.5,1.6 -1.7,4.5 -1.7,20.4 0,21.9 0,21.8 9.8,21.8 5.4,0 6.3,-0.3 8.1,-2.6 1.9,-2.5 2.1,-4 2.1,-19.6 0,-16.6 0,-16.9 -2.5,-19.3 -2,-2.1 -3.4,-2.5 -8.3,-2.5 -4.4,0 -6.3,0.5 -7.5,1.8z" android:strokeColor="#00000000"/>
<path android:fillColor="#FFFFFF"
android:pathData="M435.5,200.5c-2.5,2.4 -2.5,2.7 -2.5,19.3 0,15.6 0.2,17.1 2.1,19.6 1.8,2.3 2.7,2.6 8.3,2.6 9.6,0 9.6,0 9.6,-22.2 0,-21.8 0,-21.8 -9.4,-21.8 -4.7,0 -6.1,0.4 -8.1,2.5z" android:strokeColor="#00000000"/>
</vector>
9 changes: 9 additions & 0 deletions src/main/res/drawable/navigation_colors.xml
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="true"
android:color="@color/primary_background" />
<item
android:state_enabled="false"
android:color="@color/secondary_background" />
</selector>
37 changes: 30 additions & 7 deletions src/main/res/layout/activity_main.xml
@@ -1,14 +1,37 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragment_container"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
tools:context=".presentation.MainActivity">
<fragment <fragment
android:id="@+id/toolbar_fragment" android:id="@+id/toolbar_fragment"
android:name="de.avalax.fitbuddy.presentation.welcome_screen.WelcomeScreenFragment" android:name="de.avalax.fitbuddy.presentation.welcome_screen.WelcomeScreenFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</LinearLayout>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.v7.widget.Toolbar
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary_background"
app:layout_collapseMode="pin"
app:titleTextColor="@color/main_text" />

</android.support.design.widget.AppBarLayout>

<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/main_text"
app:itemBackground="@color/main_text"
app:itemIconTint="@drawable/navigation_colors"
app:itemTextColor="@drawable/navigation_colors"
app:menu="@menu/navigation_menu" />
</android.support.design.widget.CoordinatorLayout>

0 comments on commit b51d887

Please sign in to comment.