Skip to content

Commit

Permalink
Merge pull request #30 from mazurio/develop
Browse files Browse the repository at this point in the history
1.2.1
  • Loading branch information
mazurio committed Apr 28, 2016
2 parents 1392d12 + f5f042b commit 8d2f0b3
Show file tree
Hide file tree
Showing 106 changed files with 2,841 additions and 3,660 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
captures
# Keys
api.xml
api.properties
Expand Down
50 changes: 27 additions & 23 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ apply plugin: 'realm-android'
apply plugin: 'io.fabric'

android {
dexOptions {
incremental true
maxProcessCount 4
}

compileSdkVersion 23
buildToolsVersion '24.0.0 rc2'
buildToolsVersion '23.0.3'
defaultConfig {
applicationId 'com.bodyweight.fitness'
minSdkVersion 14
targetSdkVersion 23
vectorDrawables.useSupportLibrary = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -36,14 +40,14 @@ android {
productFlavors {
pro {
applicationId 'com.bodyweight.fitness.pro'
versionCode 120
versionName "1.2.0"
versionCode 121
versionName "1.2.1"
}

free {
applicationId 'com.bodyweight.fitness.free'
versionCode 120
versionName "1.2.0"
versionCode 121
versionName "1.2.1"
}
}
buildTypes {
Expand Down Expand Up @@ -75,18 +79,19 @@ configurations {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')

testCompile 'org.jetbrains.spek:spek:0.1.199'
testCompile "com.nhaarman:mockito-kotlin:0.3.0"
testCompile 'org.jetbrains.spek:spek:1.0.9'
// testCompile "com.nhaarman:mockito-kotlin:0.3.0"
testCompile 'org.mockito:mockito-all:2.0.2-beta'

compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.android.support:design:23.3.0'

compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.google.code.gson:gson:2.4'

compile 'commons-io:commons-io:2.4'
compile 'net.danlew:android.joda:2.7.1'
compile 'net.danlew:android.joda:2.9.3'
compile 'com.github.bumptech.glide:glide:3.7.0'

compile 'com.jakewharton:butterknife:6.1.0'
Expand All @@ -96,16 +101,15 @@ dependencies {
compile 'io.reactivex:rxandroid:1.1.0'
compile 'io.reactivex:rxjava:1.1.0'

compile 'com.liulishuo.filedownloader:library:0.2.0'
compile 'com.github.johnkil.android-robototextview:robototextview:2.3.0'
compile 'com.gordonwong:material-sheet-fab:1.2'
compile 'com.github.bmarrdev:android-DecoView-charting:v0.9.4'
compile 'com.trello:rxlifecycle:0.5.0'
compile 'com.trello:rxlifecycle-components:0.5.0'
compile 'com.trello:rxlifecycle-kotlin:0.5.0'

compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
compile 'com.github.johnkil.android-robototextview:robototextview:2.5.0'
compile 'com.gordonwong:material-sheet-fab:1.2.1'
compile 'com.github.bmarrdev:android-DecoView-charting:v1.0.1'

compile('com.crashlytics.sdk.android:answers:1.3.6@aar') {
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}

Expand Down Expand Up @@ -134,4 +138,4 @@ repositories {
url "http://repository.jetbrains.com/all"
}
maven { url 'https://maven.fabric.io/public' }
}
}
13 changes: 4 additions & 9 deletions app/src/main/java/com/bodyweight/fitness/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@
import android.content.Context;

import com.bodyweight.fitness.model.persistence.Glacier;

import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.liulishuo.filedownloader.FileDownloader;

import net.danlew.android.joda.JodaTimeAndroid;

import io.fabric.sdk.android.Fabric;

/**
* TODO: Rename drawables to use the uniqueId's.
* TODO: Update all gif videos to match 16:9 format.
* TODO: Update videos for Antranik new video.
* TODO: If your default routine does not exist - revert back.
*/
public class App extends Application {
private static Context mContext;

Expand All @@ -36,9 +30,10 @@ public void onCreate() {
);
}

// FileDownloader.init(this);

mContext = getApplicationContext();

SchemaMigration schemaMigration = new SchemaMigration();
schemaMigration.migrateSchemaIfNeeded();
}

public static Context getContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import android.view.View;
import android.view.ViewGroup;

import com.bodyweight.fitness.view.CalendarItemView;
import com.bodyweight.fitness.view.CalendarPagePresenter;
import com.bodyweight.fitness.view.CalendarPageView;
import com.bodyweight.fitness.view.widget.ViewPager;

import com.bodyweight.fitness.R;
Expand All @@ -18,27 +19,24 @@ public class CalendarAdapter extends PagerAdapter {
public Object instantiateItem(ViewGroup viewGroup, int position) {
final ViewPager viewPager = (ViewPager) viewGroup;

CalendarItemView calendarItemView = (CalendarItemView) LayoutInflater
CalendarPageView calendarPageView = (CalendarPageView) LayoutInflater
.from(viewGroup.getContext())
.inflate(R.layout.view_calendar_item, viewGroup, false);
.inflate(R.layout.view_calendar_page, viewGroup, false);

calendarItemView.onCreate(position);
calendarItemView.onCreateView();
CalendarPagePresenter calendarPagePresenter = (CalendarPagePresenter) calendarPageView.getMPresenter();
calendarPagePresenter.setMViewPagerPosition(position);

viewPager.addView(calendarItemView);
calendarPageView.updateView();

return calendarItemView;
viewPager.addView(calendarPageView);

return calendarPageView;
}

/**
* Remove subscriptions made by item views to the day/page selected observables.
*/
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
CalendarItemView calendarItemView = (CalendarItemView) object;

ViewPager viewPager = (ViewPager) container;
viewPager.removeView(calendarItemView);
viewPager.removeView((View) object);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@
import com.bodyweight.fitness.model.repository.RepositoryRoutine;
import com.bodyweight.fitness.model.repository.RepositorySet;
import com.bodyweight.fitness.stream.RepositoryStream;
import com.bodyweight.fitness.stream.Stream;
import com.bodyweight.fitness.ui.ProgressActivity;
import com.bodyweight.fitness.utils.Logger;
import com.bodyweight.fitness.utils.PreferenceUtils;

import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.joda.time.format.PeriodFormatterBuilder;

import java.util.Locale;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
Expand All @@ -32,27 +30,28 @@
import io.realm.RealmResults;

public class CalendarListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
// private boolean mEmpty = true;
private RealmResults<RepositoryRoutine> mResults;

public CalendarListAdapter() {
super();
}

public void setItems(RealmResults<RepositoryRoutine> results) {
// mEmpty = false;
mResults = results;

notifyDataSetChanged();
}

// public void setEmpty() {
// mEmpty = true;
//
// notifyDataSetChanged();
// }

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// if (viewType == 1) {
// return new CalendarSummaryPresenter(
// LayoutInflater.from(parent.getContext()).inflate(
// R.layout.view_calendar_summary, parent, false)
// );
// }

return new CalendarRoutinePresenter(
LayoutInflater.from(parent.getContext()).inflate(
R.layout.view_calendar_card, parent, false)
Expand All @@ -61,16 +60,15 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// if (position == 0) {
// return;
// }

// ((CalendarRoutinePresenter) holder).onBindView(mResults.get(position - 1));
((CalendarRoutinePresenter) holder).onBindView(mResults.get(position));
}

@Override
public int getItemCount() {
// if (mEmpty) {
// return 0;
// }

if (mResults != null) {
return mResults.size();
}
Expand All @@ -80,19 +78,9 @@ public int getItemCount() {

@Override
public int getItemViewType(int position) {
// if (position == 0) {
// return 1;
// }

return 0;
}

public class CalendarSummaryPresenter extends RecyclerView.ViewHolder {
public CalendarSummaryPresenter(View itemView) {
super(itemView);
}
}

public class CalendarRoutinePresenter extends RecyclerView.ViewHolder {
@InjectView(R.id.view_calendar_routine_title)
TextView mTitle;
Expand Down Expand Up @@ -148,15 +136,16 @@ public void onClickRemoveButton(View view) {
.setPositiveButton("Ok", (dialog, which) -> {
Realm realm = RepositoryStream.getInstance().getRealm();

RepositoryRoutine repositoryRoutine = realm.where(RepositoryRoutine.class)
.equalTo("id", mRepositoryRoutine.getId())
.findFirst();

realm.beginTransaction();
repositoryRoutine.removeFromRealm();
mRepositoryRoutine.deleteFromRealm();
realm.commitTransaction();

mResults = null;
mRepositoryRoutine = null;

notifyDataSetChanged();

Stream.INSTANCE.setRepository();
})
.setNegativeButton("Cancel", (dialog, which) -> {});

Expand Down Expand Up @@ -211,41 +200,6 @@ private String exportHTML() {
return content;
}

// private void exportCSV() {
// String header = "Date, Start Time, End Time, Workout Length, Routine, Exercise, Set Order, Weight, Weight Unit, Reps, Minutes, Seconds";
//
// Logger.d(header);
//
// String routineTitle = mRepositoryRoutine.getTitle() + " - " + mRepositoryRoutine.getSubtitle();
// int index = 1;
// for (RepositoryExercise exercise : mRepositoryRoutine.getExercises()) {
// if (exercise.isVisible()) {
// String title = exercise.getTitle();
// String weightUnit = PreferenceUtils.getInstance().getWeightMeasurementUnit().toString();
//
// for (RepositorySet set : exercise.getSets()) {
// Logger.d(String.format(
// "%s,%s,%s,%s,%s,%s,%d,%.2f,%s,%d,%s,%s\n",
// new DateTime(mRepositoryRoutine.getStartTime()).toString("EEEE d MMMM", Locale.ENGLISH),
// new DateTime(mRepositoryRoutine.getStartTime()).toString("HH:mm", Locale.ENGLISH),
// new DateTime(mRepositoryRoutine.getLastUpdatedTime()).toString("HH:mm", Locale.ENGLISH),
// getWorkoutLength(),
// routineTitle,
// title,
// index,
// set.getWeight(),
// weightUnit,
// set.getReps(),
// formatMinutes(set.getSeconds()),
// formatSeconds(set.getSeconds())
// ));
// }
//
// index += 1;
// }
// }
// }

public String getWorkoutLength() {
DateTime startTime = new DateTime(mRepositoryRoutine.getStartTime());
DateTime lastUpdatedTime = new DateTime(mRepositoryRoutine.getLastUpdatedTime());
Expand All @@ -255,15 +209,13 @@ public String getWorkoutLength() {
if (duration.toStandardMinutes().getMinutes() < 10) {
return "--";
} else {
String formatted = new PeriodFormatterBuilder()
return new PeriodFormatterBuilder()
.appendHours()
.appendSuffix("h ")
.appendMinutes()
.appendSuffix("m")
.toFormatter()
.print(duration.toPeriod());

return formatted;
}
}

Expand Down
Loading

0 comments on commit 8d2f0b3

Please sign in to comment.