Commit 4ffec09d by Joosep L

final

parent 8e97c163
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -6,7 +6,7 @@ android {
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "ee.ttu.thesis"
minSdkVersion 21
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
......
......@@ -87,6 +87,11 @@ public class AppDataManager implements DataManager {
}
@Override
public Observable<List<CheckIn>> getStats(String user_id, String game_id) {
return mApiHelper.getStats(user_id, game_id);
}
@Override
public int getCurrentUserId() {
return mPreferencesHelper.getCurrentUserId();
}
......@@ -95,4 +100,14 @@ public class AppDataManager implements DataManager {
public void setCurrentUserId(int userId) {
mPreferencesHelper.setCurrentUserId(userId);
}
@Override
public int getCurrentGame() {
return 0;
}
@Override
public void setCurrentGameId(int gameId) {
}
}
......@@ -6,8 +6,8 @@ package ee.ttu.thesis.data.network;
public final class ApiEndPoint {
public static final String BASE_URL = "http://128.199.63.125/api";
//
public static final String BASE_URL = "http://127.0.0.1/api";
public static final String ENDPOINT_GET_GAMES = BASE_URL
+ "/user/games";
......@@ -21,6 +21,9 @@ public final class ApiEndPoint {
public static final String ENDPOINT_POST_CHECK_IN = BASE_URL
+ "/game/checkin";
public static final String ENDPOINT_GET_CHECK_INS = BASE_URL
+ "/game/stats";
public static final String ENDPOINT_START_GAME = BASE_URL
+ "/game/start";
......
......@@ -40,4 +40,6 @@ public interface ApiHelper {
Observable<String> postAnswer(Answer answer);
Observable<List<CheckIn>> getStats(String user_id, String game_id);
}
......@@ -124,4 +124,13 @@ public class AppApiHelper implements ApiHelper {
.build()
.getObjectObservable(String.class);
}
@Override
public Observable<List<CheckIn>> getStats(String user_id, String game_id) {
return Rx2AndroidNetworking.get(ApiEndPoint.ENDPOINT_GET_POINTS)
.addQueryParameter("user_id", user_id)
.addQueryParameter("game_id", game_id)
.build()
.getObjectListObservable(CheckIn.class);
}
}
......@@ -18,6 +18,8 @@ public class AppPreferencesHelper implements PreferencesHelper {
private static final String PREF_KEY_CURRENT_USER_ID = "PREFS_KEY_CURRENT_USER_ID";
private static final String PREF_KEY_CURRENT_GAME = "PREF_KEY_CURRENT_GAME";
private final SharedPreferences mPrefs;
@Inject
......@@ -39,4 +41,16 @@ public class AppPreferencesHelper implements PreferencesHelper {
int id = userId;
mPrefs.edit().putInt(PREF_KEY_CURRENT_USER_ID, id).apply();
}
@Override
public int getCurrentGame() {
int id = mPrefs.getInt(PREF_KEY_CURRENT_GAME, 0);
return id;
}
@Override
public void setCurrentGameId(int gameId) {
int id = gameId;
mPrefs.edit().putInt(PREF_KEY_CURRENT_GAME, id).apply();
}
}
......@@ -10,4 +10,8 @@ public interface PreferencesHelper {
void setCurrentUserId(int userId);
int getCurrentGame();
void setCurrentGameId(int gameId);
}
......@@ -4,6 +4,7 @@ import dagger.Component;
import ee.ttu.thesis.ui.game.GameActivity;
import ee.ttu.thesis.ui.list.ListActivity;
import ee.ttu.thesis.ui.login.LoginActivity;
import ee.ttu.thesis.ui.past.HistoryActivity;
import ee.ttu.thesis.ui.start.StartActivity;
import ee.ttu.thesis.di.PerActivity;
import ee.ttu.thesis.di.module.ActivityModule;
......@@ -23,4 +24,5 @@ public interface ActivityComponent {
void inject(LoginActivity activity);
void inject(HistoryActivity activity);
}
......@@ -13,6 +13,9 @@ import ee.ttu.thesis.ui.list.ListPresenter;
import ee.ttu.thesis.ui.list.ListTreasureHuntPresenter;
import ee.ttu.thesis.ui.login.LoginPresenter;
import ee.ttu.thesis.ui.login.LoginTreasureHuntPresenter;
import ee.ttu.thesis.ui.past.HistoryPresenter;
import ee.ttu.thesis.ui.past.HistoryTreasureHuntPresenter;
import ee.ttu.thesis.ui.past.HistoryView;
import ee.ttu.thesis.ui.start.StartPresenter;
import ee.ttu.thesis.ui.start.StartTreasureHuntPresenter;
import ee.ttu.thesis.utils.AppSchedulerProvider;
......@@ -87,4 +90,12 @@ public class ActivityModule {
return presenter;
}
@Provides
@PerActivity
HistoryTreasureHuntPresenter<HistoryView> providesHistoryPresenter(HistoryPresenter<HistoryView>
presenter) {
return presenter;
}
}
......@@ -16,11 +16,19 @@ import com.google.android.gms.maps.model.PolylineOptions;
import com.google.android.gms.maps.model.RoundCap;
import com.orhanobut.logger.Logger;
import java.util.List;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import ee.ttu.thesis.R;
import ee.ttu.thesis.data.model.CheckIn;
import ee.ttu.thesis.data.model.Game;
import ee.ttu.thesis.ui.base.BaseActivity;
import ee.ttu.thesis.ui.game.map.WorkAroundMapFragment;
import ee.ttu.thesis.ui.start.StartTreasureHuntPresenter;
import ee.ttu.thesis.ui.start.StartView;
/**
* Created by hajola on 29.04.17.
......@@ -28,10 +36,16 @@ import ee.ttu.thesis.ui.game.map.WorkAroundMapFragment;
public class HistoryActivity extends BaseActivity
implements OnMapReadyCallback,
GoogleMap.OnPolylineClickListener {
GoogleMap.OnPolylineClickListener,
HistoryView{
GoogleMap mMap;
@Inject
HistoryTreasureHuntPresenter<HistoryView> mPresenter;
Game mGame;
@BindView(R.id.activity_history_scrollview)
ScrollView mScrollView;
......@@ -126,4 +140,9 @@ public class HistoryActivity extends BaseActivity
public void hideKeyboard() {
}
@Override
public void loadStats(List<CheckIn> checkIns) {
}
}
package ee.ttu.thesis.ui.past;
import java.util.List;
import javax.inject.Inject;
import ee.ttu.thesis.data.DataManager;
import ee.ttu.thesis.data.model.CheckIn;
import ee.ttu.thesis.ui.base.BasePresenter;
import ee.ttu.thesis.ui.start.StartTreasureHuntPresenter;
import ee.ttu.thesis.ui.start.StartView;
import ee.ttu.thesis.utils.SchedulerProvider;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.functions.Consumer;
/**
* Created by hajola on 22.05.17.
*/
public class HistoryPresenter <V extends HistoryView> extends BasePresenter<V> implements HistoryTreasureHuntPresenter<V> {
@Inject
public HistoryPresenter(DataManager dataManager, SchedulerProvider schedulerProvider, CompositeDisposable compositeDisposable) {
super(dataManager, schedulerProvider, compositeDisposable);
}
@Override
public void getStats(String user_id, String game_id) {
getmThesisView().showLoading();
getCompositeDisposable().add(getDataManager()
.getStats(user_id, game_id)
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribe(new Consumer<List<CheckIn>>() {
@Override
public void accept(@NonNull List<CheckIn> s) throws Exception {
getmThesisView().loadStats(s);
}
}, new Consumer<Throwable>() {
@Override
public void accept(@NonNull Throwable throwable) throws Exception {
getmThesisView().hideLoading();
getmThesisView().onError(throwable.getMessage());
}
}));
}
}
package ee.ttu.thesis.ui.past;
/**
* Created by hajola on 22.05.17.
*/
import ee.ttu.thesis.ui.base.TreauseHuntPresenter;
import ee.ttu.thesis.ui.login.LoginView;
public interface HistoryTreasureHuntPresenter<V extends HistoryView> extends TreauseHuntPresenter<V> {
void getStats(String user_id, String game_id);
}
\ No newline at end of file
package ee.ttu.thesis.ui.past;
import java.util.List;
import ee.ttu.thesis.data.model.CheckIn;
import ee.ttu.thesis.ui.base.TreasureHuntView;
/**
* Created by hajola on 22.05.17.
*/
public interface HistoryView extends TreasureHuntView {
void loadStats( List<CheckIn> checkIns);
}
\ No newline at end of file
......@@ -116,9 +116,16 @@ public class StartActivity extends BaseActivity implements StartView {
if (position == 0) {
fragment = TutorialIntroFragment.newInstance(mGame);
} else if (position == 1) {
fragment = TutorialIntroFragment.newInstance(mGame);
fragment = new TutorialTwoFragment();
} else if (position == 2) {
fragment = new TutorialThreeFragment();
} else if (position == 3) {
fragment = new TutorialFourFragment();
} else{
fragment = TutorialIntroFragment.newInstance(mGame);
fragment = new TutorialFiveFragment();
}
return fragment;
......
package ee.ttu.thesis.ui.start;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.ButterKnife;
import ee.ttu.thesis.R;
/**
* Created by hajola on 22.05.17.
*/
public class TutorialFiveFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_tutorial_five, container, false);
ButterKnife.bind(this, v);
return v;
}
}
package ee.ttu.thesis.ui.start;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.ButterKnife;
import ee.ttu.thesis.R;
/**
* Created by hajola on 22.05.17.
*/
public class TutorialFourFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_tutorial_four, container, false);
ButterKnife.bind(this, v);
return v;
}
}
package ee.ttu.thesis.ui.start;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.ButterKnife;
import ee.ttu.thesis.R;
/**
* Created by hajola on 22.05.17.
*/
public class TutorialThreeFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_tutorial_three, container, false);
ButterKnife.bind(this, v);
return v;
}
}
package ee.ttu.thesis.ui.start;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.ButterKnife;
import ee.ttu.thesis.R;
import static ee.ttu.thesis.ui.game.GameActivity.GAME_KEY;
/**
* Created by hajola on 22.05.17.
*/
public class TutorialTwoFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_tutorial_two, container, false);
ButterKnife.bind(this, v);
return v;
}
}
......@@ -39,7 +39,7 @@
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:layout_marginStart="32dp"
android:layout_marginTop="80dp"
android:layout_marginTop="16dp"
android:background="@drawable/login_rounded_rectangle_filled"
android:elevation="8dp"
android:paddingBottom="64dp"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimaryDark"
android:orientation="vertical"
android:paddingTop="32dp">
<TextView
android:id="@+id/fragment_tutorial_intro_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="How do complete a point?"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="@drawable/circle_solve_not_button"
android:gravity="center_horizontal"
android:padding="16dp"
android:src="@drawable/ic_nfc"
android:tint="@color/colorAccent" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="8dp"
android:text="This is a cool one! Points with this icon require you to find a NFC chip. Find it and just move the back of your phone close to it. Thats it!"
android:textAlignment="textStart"
android:textColor="@color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="@drawable/circle_login_icons"
android:elevation="6dp"
android:gravity="center_horizontal"
android:padding="16dp"
android:src="@drawable/ic_qrcode_scan"
android:tint="@color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="8dp"
android:text="Points with this button require a QR-code to be completed. Find the code, press the button, up will come a cool scanner. Scan the code and you are good to go!"
android:textAlignment="textStart"
android:textColor="@color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="@drawable/circle_login_icons"
android:elevation="6dp"
android:gravity="center_horizontal"
android:padding="16dp"
android:src="@drawable/ic_photo_camera_black_24dp"
android:tint="@color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="8dp"
android:text="This requires you to show off your epic photography skills."
android:textAlignment="textStart"
android:textColor="@color/white" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimaryDark"
android:orientation="vertical"
android:paddingTop="32dp">
<TextView
android:id="@+id/fragment_tutorial_intro_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="How do complete a point?"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/fragment_tutorial_intro_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="There are 5 ways you can complete a point. Let's look at them more closely:"
android:textColor="@color/white" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:id="@+id/fragment_solve_icon"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="@drawable/circle_solve_not_button"
android:gravity="center_horizontal"
android:padding="16dp"
android:src="@drawable/ic_location_on_black_24dp"
android:tint="@color/colorAccent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="8dp"
android:text="Points with this icon just need to be found in order to complete them. However! Some points may initially display this icon, and once you find them, they will change."
android:textAlignment="textStart"
android:textColor="@color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:background="@drawable/circle_login_icons"
android:elevation="6dp"
android:gravity="center_horizontal"
android:padding="16dp"
android:src="@drawable/ic_create_black_24dp"
android:tint="@color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="8dp"
android:text="If you see this button appear, just click on it. Up will come a quiz."
android:textAlignment="textStart"
android:textColor="@color/white" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimaryDark"
android:orientation="vertical"
android:paddingTop="32dp">
<TextView
android:id="@+id/fragment_tutorial_intro_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="Compass example"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<ee.ttu.thesis.ui.game.point.CompassView
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_gravity="center_horizontal"
android:padding="16dp" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimaryDark"
android:orientation="vertical"
android:paddingTop="32dp">
<TextView
android:id="@+id/fragment_tutorial_intro_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="How do find a point?"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/fragment_tutorial_intro_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="To complete the game you have to find real locations. \nAt maximum there are 4 ways you are guided to your point:\n1. Hint - a puzzle that leads you to your location\n2. Map - Although map is always visible, the point on it might not be. If it is, you can easily use it to navigate.\n3. Distance - This shows you how far away the point is\n4. Compass - this shows you the direction of the point. Your point will be displayed as a red dot. It isn't a true compass, as the the upper part always points to north. Next slide will show an example."
android:textColor="@color/white" />
</LinearLayout>
\ No newline at end of file
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 sign in to comment