Commit df953f27 by Joosep L

added features/bug fixes

parent 4ffec09d
Showing with 1554 additions and 274 deletions
...@@ -62,6 +62,7 @@ dependencies { ...@@ -62,6 +62,7 @@ dependencies {
compile 'com.github.deano2390:MaterialShowcaseView:1.1.0' compile 'com.github.deano2390:MaterialShowcaseView:1.1.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile ('com.github.worker8:tourguide:1.0.17-SNAPSHOT@aar'){ compile ('com.github.worker8:tourguide:1.0.17-SNAPSHOT@aar'){
transitive=true transitive=true
......
...@@ -7,28 +7,52 @@ ...@@ -7,28 +7,52 @@
<uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PROFILE" /> <uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.NFC" /> <uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.nfc" android:required="true" /> <uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<application <application
android:name=".ThesisApp" android:name=".ThesisApp"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<activity <activity
android:name=".ui.login.LoginActivity" android:name=".ui.login.LoginActivity"
android:screenOrientation="portrait" android:label="@string/app_name"
android:label="@string/app_name"> android:screenOrientation="portrait">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
...@@ -38,34 +62,28 @@ ...@@ -38,34 +62,28 @@
<activity <activity
android:name=".ui.list.ListActivity" android:name=".ui.list.ListActivity"
android:screenOrientation="portrait"> android:screenOrientation="portrait"></activity>
</activity>
<activity <activity
android:name=".ui.start.StartActivity" android:name=".ui.start.StartActivity"
android:screenOrientation="portrait"> android:screenOrientation="portrait"></activity>
</activity>
<activity <activity
android:name=".ui.game.GameActivity" android:name=".ui.game.GameActivity"
android:screenOrientation="portrait"> android:screenOrientation="portrait"></activity>
</activity>
<activity <activity
android:name=".ui.future.FutureGameActivity" android:name=".ui.future.FutureGameActivity"
android:screenOrientation="portrait"> android:screenOrientation="portrait"></activity>
</activity>
<activity <activity
android:name=".ui.past.HistoryActivity" android:name=".ui.past.HistoryActivity"
android:screenOrientation="portrait"> android:screenOrientation="portrait"></activity>
</activity>
<meta-data <meta-data
android:name="com.google.android.geo.API_KEY" android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCVOu0A8kPjB3jfA09CzqoEwrZ-VAbJuyQ"/> android:value="AIzaSyCVOu0A8kPjB3jfA09CzqoEwrZ-VAbJuyQ" />
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -8,6 +8,7 @@ import javax.inject.Inject; ...@@ -8,6 +8,7 @@ import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import ee.ttu.thesis.data.model.Answer; import ee.ttu.thesis.data.model.Answer;
import ee.ttu.thesis.data.model.Bound;
import ee.ttu.thesis.data.model.CheckIn; import ee.ttu.thesis.data.model.CheckIn;
import ee.ttu.thesis.data.model.CheckInResponse; import ee.ttu.thesis.data.model.CheckInResponse;
import ee.ttu.thesis.data.model.Game; import ee.ttu.thesis.data.model.Game;
...@@ -67,6 +68,11 @@ public class AppDataManager implements DataManager { ...@@ -67,6 +68,11 @@ public class AppDataManager implements DataManager {
} }
@Override @Override
public Observable<String> endGame(String userGameId) {
return mApiHelper.endGame(userGameId);
}
@Override
public Observable<List<Game>> getGame(String gameCode) { public Observable<List<Game>> getGame(String gameCode) {
return mApiHelper.getGame(gameCode); return mApiHelper.getGame(gameCode);
} }
...@@ -82,16 +88,31 @@ public class AppDataManager implements DataManager { ...@@ -82,16 +88,31 @@ public class AppDataManager implements DataManager {
} }
@Override @Override
public Observable<List<Bound>> getBounds(String gameId) {
return mApiHelper.getBounds(gameId);
}
@Override
public Observable<String> postAnswer(Answer answer) { public Observable<String> postAnswer(Answer answer) {
return mApiHelper.postAnswer(answer); return mApiHelper.postAnswer(answer);
} }
@Override @Override
public Observable<String> login(String service, String access_token) {
return mApiHelper.login(service, access_token);
}
@Override
public Observable<List<CheckIn>> getStats(String user_id, String game_id) { public Observable<List<CheckIn>> getStats(String user_id, String game_id) {
return mApiHelper.getStats(user_id, game_id); return mApiHelper.getStats(user_id, game_id);
} }
@Override @Override
public Observable<UserGame> getUserGame(String gameCode, String userId) {
return mApiHelper.getUserGame(gameCode, userId);
}
@Override
public int getCurrentUserId() { public int getCurrentUserId() {
return mPreferencesHelper.getCurrentUserId(); return mPreferencesHelper.getCurrentUserId();
} }
...@@ -102,12 +123,33 @@ public class AppDataManager implements DataManager { ...@@ -102,12 +123,33 @@ public class AppDataManager implements DataManager {
} }
@Override @Override
public int getCurrentGame() { public String getCurrentGameCode() {
return 0; return mPreferencesHelper.getCurrentGameCode();
} }
@Override @Override
public void setCurrentGameId(int gameId) { public void setCurrentGameCode(String gameCode) {
mPreferencesHelper.setCurrentGameCode(gameCode);
}
@Override
public String getService() {
return mPreferencesHelper.getService();
}
@Override
public void setService(String service) {
mPreferencesHelper.setService(service);
}
@Override
public int getCurrentPoint() {
return mPreferencesHelper.getCurrentPoint();
}
@Override
public void setCurrentPoint(int currentPoint) {
mPreferencesHelper.setCurrentPoint(currentPoint);
} }
} }
...@@ -30,9 +30,21 @@ public class Answer { ...@@ -30,9 +30,21 @@ public class Answer {
private String answer; private String answer;
@Expose @Expose
@SerializedName("photo")
private String photoInBase64;
@Expose
@SerializedName("is_correct") @SerializedName("is_correct")
private boolean is_correct; private boolean is_correct;
public String getPhotoInBase64() {
return photoInBase64;
}
public void setPhotoInBase64(String photoInBase64) {
this.photoInBase64 = photoInBase64;
}
public int getId() { public int getId() {
return id; return id;
} }
...@@ -89,6 +101,9 @@ public class Answer { ...@@ -89,6 +101,9 @@ public class Answer {
this.is_correct = is_correct; this.is_correct = is_correct;
} }
public Answer() {
}
public Answer(String answer) { public Answer(String answer) {
this.answer = answer; this.answer = answer;
} }
......
package ee.ttu.thesis.data.model;
/**
* Created by hajola on 5.06.17.
*/
public class AnswerResponse {
String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
...@@ -21,6 +21,17 @@ public class Bound { ...@@ -21,6 +21,17 @@ public class Bound {
@SerializedName("notification_text") @SerializedName("notification_text")
private String text; private String text;
@Expose
@SerializedName("mpoly")
private String mpoly;
public String getMpoly() {
return mpoly;
}
public void setMpoly(String mpoly) {
this.mpoly = mpoly;
}
@Expose @Expose
@SerializedName("violated_on") @SerializedName("violated_on")
......
package ee.ttu.thesis.data.model;
import java.util.ArrayList;
import java.util.List;
/**
* Created by hajola on 4.06.17.
*/
public class BoundResponse {
List<Bound> mBounds;
public List<Bound> getmBounds() {
return mBounds;
}
public void setmBounds(List<Bound> mBounds) {
this.mBounds = mBounds;
}
}
package ee.ttu.thesis.data.model; package ee.ttu.thesis.data.model;
import com.google.android.gms.maps.model.LatLng;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
...@@ -42,9 +43,21 @@ public class CheckIn { ...@@ -42,9 +43,21 @@ public class CheckIn {
private int current_point_id; private int current_point_id;
@Expose @Expose
@SerializedName("current_point")
private int current_point;
@Expose
@SerializedName("latest_answer_id") @SerializedName("latest_answer_id")
private int latest_answer_id; private int latest_answer_id;
public int getCurrent_point() {
return current_point;
}
public void setCurrent_point(int current_point) {
this.current_point = current_point;
}
public int getUser_game_id() { public int getUser_game_id() {
return user_game_id; return user_game_id;
} }
...@@ -77,6 +90,10 @@ public class CheckIn { ...@@ -77,6 +90,10 @@ public class CheckIn {
this.current_point_id = current_point_id; this.current_point_id = current_point_id;
} }
public LatLng getLatLng(){
return new LatLng(lat, lon);
}
public int getLatest_answer_id() { public int getLatest_answer_id() {
return latest_answer_id; return latest_answer_id;
} }
......
...@@ -5,8 +5,6 @@ import com.google.gson.annotations.SerializedName; ...@@ -5,8 +5,6 @@ import com.google.gson.annotations.SerializedName;
import java.util.List; import java.util.List;
import io.reactivex.Observable;
/** /**
* Created by hajola on 17.05.17. * Created by hajola on 17.05.17.
*/ */
...@@ -25,6 +23,17 @@ public class CheckInResponse { ...@@ -25,6 +23,17 @@ public class CheckInResponse {
@SerializedName("answer") @SerializedName("answer")
private Answer answer; private Answer answer;
@Expose
@SerializedName("isover")
private int isOver;
public int getIsOver() {
return isOver;
}
public void setIsOver(int isOver) {
this.isOver = isOver;
}
public List<Bound> getBounds() { public List<Bound> getBounds() {
return bounds; return bounds;
......
...@@ -12,11 +12,22 @@ import com.google.gson.annotations.SerializedName; ...@@ -12,11 +12,22 @@ import com.google.gson.annotations.SerializedName;
public class User implements Parcelable { public class User implements Parcelable {
@Expose @Expose
@SerializedName("user_id") @SerializedName("user_id")
private int id; private int id;
@Expose
@SerializedName("service")
private String service;
public String getService() {
return service;
}
public void setService(String service) {
this.service = service;
}
public int getId() { public int getId() {
return id; return id;
} }
...@@ -25,6 +36,9 @@ public class User implements Parcelable { ...@@ -25,6 +36,9 @@ public class User implements Parcelable {
this.id = id; this.id = id;
} }
public User() {
}
@Override @Override
public int describeContents() { public int describeContents() {
return 0; return 0;
...@@ -33,16 +47,15 @@ public class User implements Parcelable { ...@@ -33,16 +47,15 @@ public class User implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.id); dest.writeInt(this.id);
} dest.writeString(this.service);
public User() {
} }
protected User(Parcel in) { protected User(Parcel in) {
this.id = in.readInt(); this.id = in.readInt();
this.service = in.readString();
} }
public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() { public static final Creator<User> CREATOR = new Creator<User>() {
@Override @Override
public User createFromParcel(Parcel source) { public User createFromParcel(Parcel source) {
return new User(source); return new User(source);
......
package ee.ttu.thesis.data.model; package ee.ttu.thesis.data.model;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.util.Date;
/** /**
* Created by hajola on 9.05.17. * Created by hajola on 9.05.17.
*/ */
public class UserGame { public class UserGame implements Parcelable {
@Expose @Expose
@SerializedName("user_game_id") @SerializedName("user_game_id")
...@@ -17,6 +22,14 @@ public class UserGame { ...@@ -17,6 +22,14 @@ public class UserGame {
@SerializedName("game") @SerializedName("game")
private Game game; private Game game;
@Expose
@SerializedName("start_time")
private Date start;
@Expose
@SerializedName("end_time")
private Date end;
public int getUserGameId() { public int getUserGameId() {
return UserGameId; return UserGameId;
} }
...@@ -33,8 +46,61 @@ public class UserGame { ...@@ -33,8 +46,61 @@ public class UserGame {
this.game = game; this.game = game;
} }
public Date getStart() {
return start;
}
public void setStart(Date start) {
this.start = start;
}
public Date getEnd() {
return end;
}
public void setEnd(Date end) {
this.end = end;
}
@Override @Override
public String toString() { public String toString() {
return "id: " + UserGameId + " game: " + game.toString(); return "id: " + UserGameId + " game: " + game.toString();
} }
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.UserGameId);
dest.writeParcelable(this.game, flags);
dest.writeLong(this.start != null ? this.start.getTime() : -1);
dest.writeLong(this.end != null ? this.end.getTime() : -1);
}
public UserGame() {
}
protected UserGame(Parcel in) {
this.UserGameId = in.readInt();
this.game = in.readParcelable(Game.class.getClassLoader());
long tmpStart = in.readLong();
this.start = tmpStart == -1 ? null : new Date(tmpStart);
long tmpEnd = in.readLong();
this.end = tmpEnd == -1 ? null : new Date(tmpEnd);
}
public static final Parcelable.Creator<UserGame> CREATOR = new Parcelable.Creator<UserGame>() {
@Override
public UserGame createFromParcel(Parcel source) {
return new UserGame(source);
}
@Override
public UserGame[] newArray(int size) {
return new UserGame[size];
}
};
} }
...@@ -7,7 +7,7 @@ package ee.ttu.thesis.data.network; ...@@ -7,7 +7,7 @@ package ee.ttu.thesis.data.network;
public final class ApiEndPoint { public final class ApiEndPoint {
// //
public static final String BASE_URL = "http://127.0.0.1/api"; public static final String BASE_URL = "http://128.199.63.125/api";
public static final String ENDPOINT_GET_GAMES = BASE_URL public static final String ENDPOINT_GET_GAMES = BASE_URL
+ "/user/games"; + "/user/games";
...@@ -24,15 +24,24 @@ public final class ApiEndPoint { ...@@ -24,15 +24,24 @@ public final class ApiEndPoint {
public static final String ENDPOINT_GET_CHECK_INS = BASE_URL public static final String ENDPOINT_GET_CHECK_INS = BASE_URL
+ "/game/stats"; + "/game/stats";
public static final String ENDPOINT_GET_BOUNDS = BASE_URL
+ "/game/bounds";
public static final String ENDPOINT_START_GAME = BASE_URL public static final String ENDPOINT_START_GAME = BASE_URL
+ "/game/start"; + "/game/start";
public static final String ENDPOINT_END_GAME = BASE_URL
+ "/game/end";
public static final String ENDPOINT_GET_GAME = BASE_URL public static final String ENDPOINT_GET_GAME = BASE_URL
+ "/games"; + "/games";
public static final String ENDPOINT_MAKE_USER = BASE_URL public static final String ENDPOINT_MAKE_USER = BASE_URL
+ "/user/add"; + "/user/add";
public static final String ENDPOINT_LOGIN = BASE_URL
+ "/user/login";
public static final String ENDPOINT_POST_MESSAGE = BASE_URL public static final String ENDPOINT_POST_MESSAGE = BASE_URL
+ "/game/message"; + "/game/message";
......
...@@ -3,6 +3,7 @@ package ee.ttu.thesis.data.network; ...@@ -3,6 +3,7 @@ package ee.ttu.thesis.data.network;
import java.util.List; import java.util.List;
import ee.ttu.thesis.data.model.Answer; import ee.ttu.thesis.data.model.Answer;
import ee.ttu.thesis.data.model.Bound;
import ee.ttu.thesis.data.model.CheckIn; import ee.ttu.thesis.data.model.CheckIn;
import ee.ttu.thesis.data.model.CheckInResponse; import ee.ttu.thesis.data.model.CheckInResponse;
import ee.ttu.thesis.data.model.Game; import ee.ttu.thesis.data.model.Game;
...@@ -32,14 +33,22 @@ public interface ApiHelper { ...@@ -32,14 +33,22 @@ public interface ApiHelper {
Observable<String> startGame(String userGameId); Observable<String> startGame(String userGameId);
Observable<String> endGame(String userGameId);
Observable<List<Game>> getGame(String gameCode); Observable<List<Game>> getGame(String gameCode);
Observable<User> makeUser(String userName, String deviceId); Observable<User> makeUser(String userName, String deviceId);
Observable<String> postMessage(Message request); Observable<String> postMessage(Message request);
Observable<List<Bound>> getBounds(String gameId);
Observable<String> postAnswer(Answer answer); Observable<String> postAnswer(Answer answer);
Observable<String> login(String service, String access_token);
Observable<List<CheckIn>> getStats(String user_id, String game_id); Observable<List<CheckIn>> getStats(String user_id, String game_id);
Observable<UserGame> getUserGame(String gameCode, String userId);
} }
...@@ -8,6 +8,7 @@ import javax.inject.Inject; ...@@ -8,6 +8,7 @@ import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import ee.ttu.thesis.data.model.Answer; import ee.ttu.thesis.data.model.Answer;
import ee.ttu.thesis.data.model.Bound;
import ee.ttu.thesis.data.model.CheckIn; import ee.ttu.thesis.data.model.CheckIn;
import ee.ttu.thesis.data.model.CheckInResponse; import ee.ttu.thesis.data.model.CheckInResponse;
import ee.ttu.thesis.data.model.Game; import ee.ttu.thesis.data.model.Game;
...@@ -87,6 +88,14 @@ public class AppApiHelper implements ApiHelper { ...@@ -87,6 +88,14 @@ public class AppApiHelper implements ApiHelper {
} }
@Override @Override
public Observable<String> endGame(String userGameId) {
return Rx2AndroidNetworking.post(ApiEndPoint.ENDPOINT_END_GAME)
.addBodyParameter("user_game_id", userGameId)
.build()
.getObjectObservable(String.class);
}
@Override
public Observable<List<Game>> getGame(String gameCode) { public Observable<List<Game>> getGame(String gameCode) {
return Rx2AndroidNetworking.get(ApiEndPoint.ENDPOINT_GET_GAME) return Rx2AndroidNetworking.get(ApiEndPoint.ENDPOINT_GET_GAME)
.addQueryParameter("game_code", gameCode) .addQueryParameter("game_code", gameCode)
...@@ -114,23 +123,63 @@ public class AppApiHelper implements ApiHelper { ...@@ -114,23 +123,63 @@ public class AppApiHelper implements ApiHelper {
} }
@Override @Override
public Observable<List<Bound>> getBounds(String gameId) {
return Rx2AndroidNetworking.get(ApiEndPoint.ENDPOINT_GET_BOUNDS)
.addQueryParameter("game", gameId)
.build()
.getObjectListObservable(Bound.class);
}
@Override
public Observable<String> postAnswer(Answer answer) { public Observable<String> postAnswer(Answer answer) {
return Rx2AndroidNetworking.post(ApiEndPoint.ENDPOINT_POST_ANSWER) if(answer.getPhotoInBase64() == null) {
.addBodyParameter("user_game_id", Integer.toString(answer.getUser_game_id())) return Rx2AndroidNetworking.post(ApiEndPoint.ENDPOINT_POST_ANSWER)
.addBodyParameter("point_id", Integer.toString(answer.getPoint_id())) .addBodyParameter("user_game_id", Integer.toString(answer.getUser_game_id()))
.addBodyParameter("problem_type_id", Integer.toString(answer.getProblem_type().getId())) .addBodyParameter("point_id", Integer.toString(answer.getPoint_id()))
.addBodyParameter("given_answer", answer.getAnswer()) .addBodyParameter("problem_type_id", Integer.toString(answer.getProblem_type().getId()))
.addBodyParameter("is_correct", answer.is_correct() ? "1" : "0") .addBodyParameter("given_answer", answer.getAnswer())
.addBodyParameter("is_correct", answer.is_correct() ? "1" : "0")
.build()
.getObjectObservable(String.class);
}else{
return Rx2AndroidNetworking.post(ApiEndPoint.ENDPOINT_POST_ANSWER)
.addBodyParameter("user_game_id", Integer.toString(answer.getUser_game_id()))
.addBodyParameter("point_id", Integer.toString(answer.getPoint_id()))
.addBodyParameter("problem_type_id", Integer.toString(answer.getProblem_type().getId()))
.addBodyParameter("given_answer", answer.getAnswer())
.addBodyParameter("photo", answer.getPhotoInBase64())
.addBodyParameter("is_correct", answer.is_correct() ? "1" : "0")
.build()
.getObjectObservable(String.class);
}
}
@Override
public Observable<String> login(String service, String access_token) {
return Rx2AndroidNetworking.post(ApiEndPoint.ENDPOINT_LOGIN)
.addBodyParameter("service", service)
.addBodyParameter("access_token", access_token)
.build() .build()
.getObjectObservable(String.class); .getObjectObservable(String.class);
} }
@Override @Override
public Observable<List<CheckIn>> getStats(String user_id, String game_id) { public Observable<List<CheckIn>> getStats(String user_id, String game_id) {
return Rx2AndroidNetworking.get(ApiEndPoint.ENDPOINT_GET_POINTS) return Rx2AndroidNetworking.get(ApiEndPoint.ENDPOINT_GET_CHECK_INS)
.addQueryParameter("user_id", user_id) .addQueryParameter("user_id", user_id)
.addQueryParameter("game_id", game_id) .addQueryParameter("game_id", game_id)
.build() .build()
.getObjectListObservable(CheckIn.class); .getObjectListObservable(CheckIn.class);
} }
@Override
public Observable<UserGame> getUserGame(String gameCode, String userId) {
return Rx2AndroidNetworking.post(ApiEndPoint.ENDPOINT_ADD_USER_GAME)
.addBodyParameter("game_code", gameCode)
.addBodyParameter("user_id", userId)
.build()
.getObjectObservable(UserGame.class);
}
} }
...@@ -20,6 +20,10 @@ public class AppPreferencesHelper implements PreferencesHelper { ...@@ -20,6 +20,10 @@ public class AppPreferencesHelper implements PreferencesHelper {
private static final String PREF_KEY_CURRENT_GAME = "PREF_KEY_CURRENT_GAME"; private static final String PREF_KEY_CURRENT_GAME = "PREF_KEY_CURRENT_GAME";
private static final String PREF_KEY_SERVICE = "PREF_KEY_SERVICE";
private static final String PREF_KEY_CURRENT_POINT = "PREF_KEY_CURRENT_POINT";
private final SharedPreferences mPrefs; private final SharedPreferences mPrefs;
@Inject @Inject
...@@ -31,8 +35,6 @@ public class AppPreferencesHelper implements PreferencesHelper { ...@@ -31,8 +35,6 @@ public class AppPreferencesHelper implements PreferencesHelper {
@Override @Override
public int getCurrentUserId() { public int getCurrentUserId() {
int userId = mPrefs.getInt(PREF_KEY_CURRENT_USER_ID, 0); int userId = mPrefs.getInt(PREF_KEY_CURRENT_USER_ID, 0);
if(userId == 0)
return 1;
return userId; return userId;
} }
...@@ -43,14 +45,35 @@ public class AppPreferencesHelper implements PreferencesHelper { ...@@ -43,14 +45,35 @@ public class AppPreferencesHelper implements PreferencesHelper {
} }
@Override @Override
public int getCurrentGame() { public String getCurrentGameCode() {
int id = mPrefs.getInt(PREF_KEY_CURRENT_GAME, 0); String gameCode = mPrefs.getString(PREF_KEY_CURRENT_GAME, null);
return id; return gameCode;
}
@Override
public void setCurrentGameCode(String gameCode) {
mPrefs.edit().putString(PREF_KEY_CURRENT_GAME, gameCode).apply();
}
@Override
public String getService() {
String service = mPrefs.getString(PREF_KEY_SERVICE, null);
return service;
} }
@Override @Override
public void setCurrentGameId(int gameId) { public void setService(String service) {
int id = gameId; mPrefs.edit().putString(PREF_KEY_SERVICE, service).apply();
mPrefs.edit().putInt(PREF_KEY_CURRENT_GAME, id).apply();
} }
@Override
public int getCurrentPoint() {
return mPrefs.getInt(PREF_KEY_CURRENT_POINT, -1);
}
@Override
public void setCurrentPoint(int currentPoint) {
mPrefs.edit().putInt(PREF_KEY_CURRENT_POINT, currentPoint).apply();
}
} }
...@@ -10,8 +10,17 @@ public interface PreferencesHelper { ...@@ -10,8 +10,17 @@ public interface PreferencesHelper {
void setCurrentUserId(int userId); void setCurrentUserId(int userId);
int getCurrentGame(); String getCurrentGameCode();
void setCurrentGameCode(String gameCode);
String getService();
void setService(String service);
int getCurrentPoint();
void setCurrentPoint(int currentPoint);
void setCurrentGameId(int gameId);
} }
package ee.ttu.thesis.ui.future; package ee.ttu.thesis.ui.future;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.CountDownTimer; import android.os.CountDownTimer;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
...@@ -13,10 +14,16 @@ import butterknife.BindView; ...@@ -13,10 +14,16 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import ee.ttu.thesis.R; import ee.ttu.thesis.R;
import ee.ttu.thesis.data.model.User;
import ee.ttu.thesis.data.model.UserGame;
import ee.ttu.thesis.ui.base.BaseActivity; import ee.ttu.thesis.ui.base.BaseActivity;
import ee.ttu.thesis.data.model.Game; import ee.ttu.thesis.data.model.Game;
import ee.ttu.thesis.ui.list.ListActivity;
import ee.ttu.thesis.ui.start.StartActivity;
import static ee.ttu.thesis.ui.game.GameActivity.GAME_KEY; import static ee.ttu.thesis.ui.game.GameActivity.GAME_KEY;
import static ee.ttu.thesis.ui.game.GameActivity.USER_GAME_KEY;
import static ee.ttu.thesis.ui.game.GameActivity.USER_KEY;
/** /**
* Created by hajola on 28.04.17. * Created by hajola on 28.04.17.
...@@ -38,6 +45,8 @@ public class FutureGameActivity extends BaseActivity { ...@@ -38,6 +45,8 @@ public class FutureGameActivity extends BaseActivity {
TextView mDescription; TextView mDescription;
Game mGame; Game mGame;
User mUser;
UserGame mUserGame;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
...@@ -46,6 +55,8 @@ public class FutureGameActivity extends BaseActivity { ...@@ -46,6 +55,8 @@ public class FutureGameActivity extends BaseActivity {
ButterKnife.bind(this); ButterKnife.bind(this);
mGame = getIntent().getParcelableExtra(GAME_KEY); mGame = getIntent().getParcelableExtra(GAME_KEY);
mUserGame = getIntent().getParcelableExtra(USER_GAME_KEY);
mUser = getIntent().getParcelableExtra(USER_KEY);
mTitle.setText(mGame.getTitle()); mTitle.setText(mGame.getTitle());
mDescription.setText(mGame.getDescription()); mDescription.setText(mGame.getDescription());
...@@ -78,7 +89,12 @@ public class FutureGameActivity extends BaseActivity { ...@@ -78,7 +89,12 @@ public class FutureGameActivity extends BaseActivity {
} }
public void onFinish() { public void onFinish() {
// mTextField.setText("done!"); Intent intent = new Intent(FutureGameActivity.this, StartActivity.class);
intent.putExtra(GAME_KEY, mGame);
intent.putExtra(USER_GAME_KEY, mUserGame);
intent.putExtra(USER_KEY, mUser);
startActivity(intent);
finish();
} }
}.start(); }.start();
......
...@@ -6,6 +6,9 @@ import javax.inject.Inject; ...@@ -6,6 +6,9 @@ import javax.inject.Inject;
import ee.ttu.thesis.data.DataManager; import ee.ttu.thesis.data.DataManager;
import ee.ttu.thesis.data.model.Answer; import ee.ttu.thesis.data.model.Answer;
import ee.ttu.thesis.data.model.AnswerResponse;
import ee.ttu.thesis.data.model.Bound;
import ee.ttu.thesis.data.model.BoundResponse;
import ee.ttu.thesis.data.model.CheckIn; import ee.ttu.thesis.data.model.CheckIn;
import ee.ttu.thesis.data.model.CheckInResponse; import ee.ttu.thesis.data.model.CheckInResponse;
import ee.ttu.thesis.data.model.GamesRequest; import ee.ttu.thesis.data.model.GamesRequest;
...@@ -105,6 +108,7 @@ public class GamePresenter<V extends GameView> extends BasePresenter<V> implemen ...@@ -105,6 +108,7 @@ public class GamePresenter<V extends GameView> extends BasePresenter<V> implemen
})); }));
} }
@Override @Override
public void postAnswer(Answer answer) { public void postAnswer(Answer answer) {
getmThesisView().showLoading(); getmThesisView().showLoading();
...@@ -120,8 +124,65 @@ public class GamePresenter<V extends GameView> extends BasePresenter<V> implemen ...@@ -120,8 +124,65 @@ public class GamePresenter<V extends GameView> extends BasePresenter<V> implemen
if (!isViewAttached()) { if (!isViewAttached()) {
return; return;
} }
AnswerResponse answerResponse = new AnswerResponse();
answerResponse.setId(s);
getmThesisView().answerPosted(answerResponse);
}
}, new Consumer<Throwable>() {
@Override
public void accept(@NonNull Throwable throwable) throws Exception {
getmThesisView().onError(throwable.getMessage());
getmThesisView().hideLoading();
}
}));
}
@Override
public void getBounds(String gameId) {
getCompositeDisposable().add(getDataManager()
.getBounds(gameId)
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribe(new Consumer<List<Bound>>() {
@Override
public void accept(@NonNull List<Bound> bounds) throws Exception {
BoundResponse boundResponse = new BoundResponse();
boundResponse.setmBounds(bounds);
getmThesisView().loadBounds(boundResponse);
}
}, new Consumer<Throwable>() {
@Override
public void accept(@NonNull Throwable throwable) throws Exception {
getmThesisView().hideLoading();
getmThesisView().onError(throwable.getMessage());
}
}));
}
@Override
public void deleteGameFromMemory() {
getDataManager().setCurrentPoint(-1);
getDataManager().setCurrentGameCode(null);
}
@Override
public void saveCurrentPoint(int currentPoint) {
getDataManager().setCurrentPoint(currentPoint);
}
@Override
public void gameEnded(String userGameId) {
getmThesisView().showLoading();
getmThesisView().answerPosted(s); getCompositeDisposable().add(getDataManager()
.endGame(userGameId)
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribe(new Consumer<String>() {
@Override
public void accept(@NonNull String s) throws Exception {
getmThesisView().gameEnded();
} }
}, new Consumer<Throwable>() { }, new Consumer<Throwable>() {
@Override @Override
...@@ -130,4 +191,9 @@ public class GamePresenter<V extends GameView> extends BasePresenter<V> implemen ...@@ -130,4 +191,9 @@ public class GamePresenter<V extends GameView> extends BasePresenter<V> implemen
} }
})); }));
} }
@Override
public int getCurrentPoint() {
return getDataManager().getCurrentPoint();
}
} }
...@@ -20,4 +20,14 @@ public interface GameTreasureHuntPresenter<V extends GameView> extends TreauseHu ...@@ -20,4 +20,14 @@ public interface GameTreasureHuntPresenter<V extends GameView> extends TreauseHu
void postAnswer(Answer answer); void postAnswer(Answer answer);
void getBounds(String gameId);
void deleteGameFromMemory();
void saveCurrentPoint(int currentPoint);
void gameEnded(String userGameId);
int getCurrentPoint();
} }
...@@ -2,6 +2,9 @@ package ee.ttu.thesis.ui.game; ...@@ -2,6 +2,9 @@ package ee.ttu.thesis.ui.game;
import java.util.List; import java.util.List;
import ee.ttu.thesis.data.model.AnswerResponse;
import ee.ttu.thesis.data.model.Bound;
import ee.ttu.thesis.data.model.BoundResponse;
import ee.ttu.thesis.data.model.CheckInResponse; import ee.ttu.thesis.data.model.CheckInResponse;
import ee.ttu.thesis.data.model.Point; import ee.ttu.thesis.data.model.Point;
import ee.ttu.thesis.ui.base.TreasureHuntView; import ee.ttu.thesis.ui.base.TreasureHuntView;
...@@ -14,9 +17,14 @@ public interface GameView extends TreasureHuntView { ...@@ -14,9 +17,14 @@ public interface GameView extends TreasureHuntView {
void loadPoints(List<Point> response); void loadPoints(List<Point> response);
void loadBounds(BoundResponse boundResponse);
void checkInResponse(CheckInResponse checkInResponse); void checkInResponse(CheckInResponse checkInResponse);
void messagePosted(); void messagePosted();
void answerPosted(String id); void answerPosted(AnswerResponse id);
void gameEnded();
} }
package ee.ttu.thesis.ui.game;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ee.ttu.thesis.R;
/**
* Created by hajola on 4.06.17.
*/
public class InfoDialogFragment extends DialogFragment {
@BindView(R.id.dialog_info_ok)
Button mOk;
@BindView(R.id.dialog_info_textview)
TextView mInfo;
public static final String INFO_KEY = "info";
public InfoDialogFragment() {
}
public static InfoDialogFragment newInstance(String info) {
Bundle args = new Bundle();
InfoDialogFragment fragment = new InfoDialogFragment();
args.putString(INFO_KEY, info);
fragment.setArguments(args);
return fragment;
}
@OnClick(R.id.dialog_info_ok)
public void onOkClicked(View v) {
dismiss();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.dialog_info, container);
ButterKnife.bind(this, v);
return v;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mInfo.setText(getArguments().getString(INFO_KEY));
}
}
...@@ -2,6 +2,7 @@ package ee.ttu.thesis.ui.game.map; ...@@ -2,6 +2,7 @@ package ee.ttu.thesis.ui.game.map;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.location.Location; import android.location.Location;
...@@ -22,14 +23,19 @@ import com.google.android.gms.maps.model.CameraPosition; ...@@ -22,14 +23,19 @@ import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MapStyleOptions; import com.google.android.gms.maps.model.MapStyleOptions;
import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polygon;
import com.google.android.gms.maps.model.PolygonOptions;
import com.orhanobut.logger.Logger; import com.orhanobut.logger.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ee.ttu.thesis.R; import ee.ttu.thesis.R;
import ee.ttu.thesis.data.model.Answer; import ee.ttu.thesis.data.model.Answer;
import ee.ttu.thesis.data.model.Bound;
import ee.ttu.thesis.data.model.BoundResponse;
import ee.ttu.thesis.data.model.Game; import ee.ttu.thesis.data.model.Game;
import ee.ttu.thesis.data.model.Point; import ee.ttu.thesis.data.model.Point;
import ee.ttu.thesis.data.model.PointType; import ee.ttu.thesis.data.model.PointType;
...@@ -48,7 +54,8 @@ import static ee.ttu.thesis.ui.game.GameActivity.POINT_KEY; ...@@ -48,7 +54,8 @@ import static ee.ttu.thesis.ui.game.GameActivity.POINT_KEY;
* Created by hajola on 18.04.17. * Created by hajola on 18.04.17.
*/ */
public class MapFragment extends Fragment implements OnMapReadyCallback { public class MapFragment extends Fragment
implements OnMapReadyCallback, GoogleMap.OnPolygonClickListener {
private CameraPosition mCameraPosition; private CameraPosition mCameraPosition;
...@@ -105,12 +112,38 @@ public class MapFragment extends Fragment implements OnMapReadyCallback { ...@@ -105,12 +112,38 @@ public class MapFragment extends Fragment implements OnMapReadyCallback {
mCurrentPoint++; mCurrentPoint++;
newPoint(); newPoint();
} }
} else if(o instanceof BoundResponse){
boundsToMap(((BoundResponse) o).getmBounds());
} }
} }
})); }));
} }
private void boundsToMap(List<Bound> bounds){
for(Bound b: bounds){
String mpoly = b.getMpoly();
List<LatLng> latLngs = new ArrayList<>();
String lat, lng;
mpoly = mpoly.substring(mpoly.lastIndexOf('(')+1,mpoly.indexOf(')') );
String[] together = mpoly.split(", ");
for(String s: together){
String[] ltln = s.split(" ");
LatLng latLng = new LatLng(Double.parseDouble(ltln[1]), Double.parseDouble(ltln[0]));
latLngs.add(latLng);
}
LatLng[] arr = new LatLng[latLngs.size()];
arr = latLngs.toArray(arr);
Polygon polygon = mMap.addPolygon(new PolygonOptions()
.add(arr)
.strokeColor(getResources().getColor(R.color.colorAccent))
.fillColor(getResources().getColor(R.color.mapBoundFillColor)));
}
}
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
...@@ -218,4 +251,9 @@ public class MapFragment extends Fragment implements OnMapReadyCallback { ...@@ -218,4 +251,9 @@ public class MapFragment extends Fragment implements OnMapReadyCallback {
if(!isCameraAboveUser && mMap != null) if(!isCameraAboveUser && mMap != null)
getDeviceLocation(); getDeviceLocation();
} }
@Override
public void onPolygonClick(Polygon polygon) {
}
} }
...@@ -80,7 +80,8 @@ public class DialogFragmentSolveQuestion extends DialogFragment { ...@@ -80,7 +80,8 @@ public class DialogFragmentSolveQuestion extends DialogFragment {
Answer answer = new Answer(mPoint.getId(), mPoint.getProblemType(), correctSolution, correctId == mRadioGroup.getCheckedRadioButtonId()); Answer answer = new Answer(mPoint.getId(), mPoint.getProblemType(), correctSolution, correctId == mRadioGroup.getCheckedRadioButtonId());
if ( _rxBus.hasObservers() ) if ( _rxBus.hasObservers() )
_rxBus.send(answer); _rxBus.send(answer);
if(!answer.is_correct())
((SolveFragment)getParentFragment()).onWrongAnswer(answer);
dismiss(); dismiss();
} }
......
package ee.ttu.thesis.ui.game.point; package ee.ttu.thesis.ui.game.point;
import android.content.Context;
import android.location.Location; import android.location.Location;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.os.Bundle; import android.os.Bundle;
import android.os.Vibrator;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -31,6 +30,7 @@ import ee.ttu.thesis.data.model.Point; ...@@ -31,6 +30,7 @@ import ee.ttu.thesis.data.model.Point;
import ee.ttu.thesis.data.model.PointType; import ee.ttu.thesis.data.model.PointType;
import ee.ttu.thesis.data.model.ProblemType; import ee.ttu.thesis.data.model.ProblemType;
import ee.ttu.thesis.ui.game.GameActivity; import ee.ttu.thesis.ui.game.GameActivity;
import ee.ttu.thesis.ui.game.InfoDialogFragment;
import ee.ttu.thesis.utils.RxBus; import ee.ttu.thesis.utils.RxBus;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull; import io.reactivex.annotations.NonNull;
...@@ -56,8 +56,8 @@ public class GameFragment extends Fragment { ...@@ -56,8 +56,8 @@ public class GameFragment extends Fragment {
TextView mOrder; TextView mOrder;
@BindView(R.id.fragment_solve_point_description) @BindView(R.id.fragment_solve_point_description)
TextView mDescription; TextView mDescription;
TextView mDistance; LinearLayout mDistance;
CompassView mCompassView; LinearLayout mCompassView;
@BindView(R.id.fragment_compass_hint_root) @BindView(R.id.fragment_compass_hint_root)
LinearLayout mHintRoot; LinearLayout mHintRoot;
@BindView(R.id.fragment_compass_compass_root) @BindView(R.id.fragment_compass_compass_root)
...@@ -78,10 +78,11 @@ public class GameFragment extends Fragment { ...@@ -78,10 +78,11 @@ public class GameFragment extends Fragment {
List<Point> mPoints; List<Point> mPoints;
public static GameFragment newInstance(Game game, ArrayList<Point> points) { public static GameFragment newInstance(Game game, ArrayList<Point> points, int mCurrentPoint) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putParcelable(GAME_KEY, game); args.putParcelable(GAME_KEY, game);
args.putParcelableArrayList(POINT_KEY, points); args.putParcelableArrayList(POINT_KEY, points);
args.putInt("currentpoint", mCurrentPoint);
GameFragment fragment = new GameFragment(); GameFragment fragment = new GameFragment();
fragment.setArguments(args); fragment.setArguments(args);
return fragment; return fragment;
...@@ -93,6 +94,7 @@ public class GameFragment extends Fragment { ...@@ -93,6 +94,7 @@ public class GameFragment extends Fragment {
View v = inflater.inflate(R.layout.fragment_game, container, false); View v = inflater.inflate(R.layout.fragment_game, container, false);
ButterKnife.bind(this, v); ButterKnife.bind(this, v);
mGame = getArguments().getParcelable(GAME_KEY); mGame = getArguments().getParcelable(GAME_KEY);
mCurrentPoint = getArguments().getInt("currentpoint");
mPoints = getArguments().getParcelableArrayList(POINT_KEY); mPoints = getArguments().getParcelableArrayList(POINT_KEY);
return v; return v;
} }
...@@ -195,10 +197,13 @@ public class GameFragment extends Fragment { ...@@ -195,10 +197,13 @@ public class GameFragment extends Fragment {
if (degrees < 0) { if (degrees < 0) {
degrees += 360; degrees += 360;
} }
if (mDistance != null) if (mDistance != null) {
mDistance.setText("" + distanceInMeters + " meters away from the point "); ((TextView) mDistance.findViewById(R.id.fragment_compass_distance)).setText("" + distanceInMeters + " meters away from the point ");
((TextView) mDistance.findViewById(R.id.fragment_compass_distance_accuracy)).setText("accuracy: " + mCurrentLocation.getAccuracy() + " meters");
}
if (mCompassView != null) if (mCompassView != null)
mCompassView.updateUI(degrees, distanceInMeters); ((CompassView) mCompassView.findViewById(R.id.compassView)).updateUI(degrees, distanceInMeters);
} }
} }
...@@ -211,7 +216,7 @@ public class GameFragment extends Fragment { ...@@ -211,7 +216,7 @@ public class GameFragment extends Fragment {
mHintRoot.removeAllViews(); mHintRoot.removeAllViews();
mHintView = null; mHintView = null;
} else { } else {
if ( mHintView == null) { if (mHintView == null) {
mHintView = (TextView) getActivity().getLayoutInflater().inflate(R.layout.layout_hint, null); mHintView = (TextView) getActivity().getLayoutInflater().inflate(R.layout.layout_hint, null);
mHintRoot.addView(mHintView); mHintRoot.addView(mHintView);
} }
...@@ -222,8 +227,8 @@ public class GameFragment extends Fragment { ...@@ -222,8 +227,8 @@ public class GameFragment extends Fragment {
mCompassRoot.removeAllViews(); mCompassRoot.removeAllViews();
mCompassView = null; mCompassView = null;
} else { } else {
if ( mCompassView == null) { if (mCompassView == null) {
mCompassView = (CompassView) getActivity().getLayoutInflater().inflate(R.layout.layout_compass, null); mCompassView = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.layout_compass, null);
mCompassRoot.addView(mCompassView); mCompassRoot.addView(mCompassView);
} }
} }
...@@ -232,8 +237,8 @@ public class GameFragment extends Fragment { ...@@ -232,8 +237,8 @@ public class GameFragment extends Fragment {
mDistanceRoot.removeAllViews(); mDistanceRoot.removeAllViews();
mDistance = null; mDistance = null;
} else { } else {
if ( mDistance == null) { if (mDistance == null) {
mDistance = (TextView) getActivity().getLayoutInflater().inflate(R.layout.layout_distance, null); mDistance = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.layout_distance, null);
mDistanceRoot.addView(mDistance); mDistanceRoot.addView(mDistance);
} }
} }
...@@ -254,11 +259,15 @@ public class GameFragment extends Fragment { ...@@ -254,11 +259,15 @@ public class GameFragment extends Fragment {
e.printStackTrace(); e.printStackTrace();
} }
if (mPoints.size() - 1 <= mCurrentPoint) { if (mPoints.size() - 1 <= mCurrentPoint) {
// TODO WON GAME
Toast.makeText(getActivity(), "Game won!", Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), "Game won!", Toast.LENGTH_SHORT).show();
((GameActivity) getActivity()).onGameFinished();
} else { } else {
mCurrentPoint++; mCurrentPoint++;
displayNewPoint(); displayNewPoint();
FragmentManager fm = getFragmentManager();
InfoDialogFragment infoDialogFragment = InfoDialogFragment.newInstance("Point completed!");
infoDialogFragment.show(fm, "info_fragment");
} }
} }
......
...@@ -2,11 +2,13 @@ package ee.ttu.thesis.ui.game.point; ...@@ -2,11 +2,13 @@ package ee.ttu.thesis.ui.game.point;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.location.Location; import android.location.Location;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.view.View; import android.view.View;
import com.google.android.gms.maps.model.LatLng;
import com.orhanobut.logger.Logger; import com.orhanobut.logger.Logger;
import butterknife.OnClick; import butterknife.OnClick;
...@@ -56,7 +58,21 @@ public class GameLocationFragment extends SolveFragment { ...@@ -56,7 +58,21 @@ public class GameLocationFragment extends SolveFragment {
@Override @Override
public void accept(@NonNull Object o) throws Exception { public void accept(@NonNull Object o) throws Exception {
if (o instanceof Location) { if (o instanceof Location) {
Location loc = (Location) o;
Location pointLoc = new Location("");
pointLoc.setLatitude(mPoint.getLat());
pointLoc.setLongitude(mPoint.getLon());
double distance = loc.distanceTo(pointLoc);
if(distance < loc.getAccuracy()+5 && loc.getAccuracy() < 10){
if (mPoint.getProblemType().getTitle().equals(ProblemType.QUIZ)) {
onAskAQuestion();
} else {
Answer answer = new Answer(mPoint.getId(), mPoint.getProblemType(), "automaatne", true);
if (_rxBus.hasObservers())
_rxBus.send(answer);
}
}
} }
} }
})); }));
...@@ -85,8 +101,10 @@ public class GameLocationFragment extends SolveFragment { ...@@ -85,8 +101,10 @@ public class GameLocationFragment extends SolveFragment {
mIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_create_black_24dp)); mIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_create_black_24dp));
mIcon.setBackground(getActivity().getResources().getDrawable(R.drawable.circle_login_icons)); mIcon.setBackground(getActivity().getResources().getDrawable(R.drawable.circle_login_icons));
mInstructions.setText(mPoint.getProblemDescription()); mInstructions.setText(mPoint.getProblemDescription());
mIcon.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.DST_OUT); mIcon.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN);
mIcon.setElevation(DeviceDimensionsHelper.convertDpToPixel(4, getActivity())); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mIcon.setElevation(DeviceDimensionsHelper.convertDpToPixel(4, getActivity()));
}
mIcon.setOnClickListener(new View.OnClickListener() { mIcon.setOnClickListener(new View.OnClickListener() {
@Override @Override
......
...@@ -5,12 +5,26 @@ import android.graphics.Bitmap; ...@@ -5,12 +5,26 @@ import android.graphics.Bitmap;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.util.Base64;
import android.view.View; import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import com.orhanobut.logger.Logger;
import java.io.ByteArrayOutputStream;
import butterknife.OnClick; import butterknife.OnClick;
import ee.ttu.thesis.R; import ee.ttu.thesis.R;
import ee.ttu.thesis.data.model.Answer;
import ee.ttu.thesis.data.model.AnswerResponse;
import ee.ttu.thesis.data.model.CheckInResponse;
import ee.ttu.thesis.data.model.Point; import ee.ttu.thesis.data.model.Point;
import ee.ttu.thesis.ui.game.GameActivity;
import ee.ttu.thesis.utils.RxBus;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.functions.Consumer;
import static android.app.Activity.RESULT_OK; import static android.app.Activity.RESULT_OK;
import static ee.ttu.thesis.ui.game.GameActivity.POINT_KEY; import static ee.ttu.thesis.ui.game.GameActivity.POINT_KEY;
...@@ -23,6 +37,9 @@ public class GamePhotoFragment extends SolveFragment { ...@@ -23,6 +37,9 @@ public class GamePhotoFragment extends SolveFragment {
static final int REQUEST_IMAGE_CAPTURE = 1; static final int REQUEST_IMAGE_CAPTURE = 1;
Answer answer;
CompositeDisposable mDisposables;
public static GamePhotoFragment newInstance(Point point) { public static GamePhotoFragment newInstance(Point point) {
Bundle args = new Bundle(); Bundle args = new Bundle();
...@@ -41,18 +58,23 @@ public class GamePhotoFragment extends SolveFragment { ...@@ -41,18 +58,23 @@ public class GamePhotoFragment extends SolveFragment {
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
Toast.makeText(getActivity(), "Mängujuht hindaks pilti (oota 4s)", Toast.LENGTH_LONG).show(); Toast.makeText(getActivity(), "Game coordinator will verify the picture", Toast.LENGTH_LONG).show();
onPhotoTaken(); onPhotoTaken();
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) { if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras(); Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data"); Bitmap imageBitmap = (Bitmap) extras.get("data");
new Handler().postDelayed(new Runnable() { ByteArrayOutputStream baos = new ByteArrayOutputStream();
@Override imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
public void run() { byte[] imageBytes = baos.toByteArray();
// mOnPointCompletedListener.onPointCompleted(); String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
} answer = new Answer();
answer.setPoint_id(mPoint.getId());
}, 4000); answer.setProblem_type(mPoint.getProblemType());
answer.setAnswer("photo");
answer.setIs_correct(false);
answer.setPhotoInBase64(encodedImage);
Logger.d(answer.getPhotoInBase64());
((GameActivity)getActivity()).postAnswer(answer);
} }
} }
...@@ -62,15 +84,6 @@ public class GamePhotoFragment extends SolveFragment { ...@@ -62,15 +84,6 @@ public class GamePhotoFragment extends SolveFragment {
mIcon.setVisibility(View.INVISIBLE); mIcon.setVisibility(View.INVISIBLE);
mProgressBar.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.VISIBLE);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mInstructions.setText("Please wait");
mIcon.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.INVISIBLE);
}
}, 6000);
} }
private void dispatchTakePictureIntent() { private void dispatchTakePictureIntent() {
...@@ -80,4 +93,38 @@ public class GamePhotoFragment extends SolveFragment { ...@@ -80,4 +93,38 @@ public class GamePhotoFragment extends SolveFragment {
} }
} }
@Override
public void onStart() {
super.onStart();
_rxBus = ((GameActivity) getActivity()).getRxBusSingleton();
mDisposables = new CompositeDisposable();
mDisposables.add(_rxBus.asFlowable()
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Object>() {
@Override
public void accept(@NonNull Object o) throws Exception {
if(o instanceof AnswerResponse){
answer.setId(Integer.parseInt(((AnswerResponse) o).getId()));
} else if (o instanceof CheckInResponse) {
Logger.d(o.toString());
Answer a = ((CheckInResponse) o).getAnswer();
if(a != null && a.getId() == answer.getId()){
if(!a.is_correct()){
mInstructions.setText("Please try again");
mIcon.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.INVISIBLE);
onWrongAnswer(a);
}else{
mInstructions.setText("Well done!!");
mIcon.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.INVISIBLE);
((GameFragment)getParentFragment()).onPointCompleted();
}
}
}
}
}));
}
} }
...@@ -113,6 +113,8 @@ public class QRScannerDialogFragment extends DialogFragment { ...@@ -113,6 +113,8 @@ public class QRScannerDialogFragment extends DialogFragment {
Answer answer = new Answer(mPoint.getId(), mPoint.getProblemType(), data, Answer.isAnswerCorrect(mPoint, data)); Answer answer = new Answer(mPoint.getId(), mPoint.getProblemType(), data, Answer.isAnswerCorrect(mPoint, data));
if (_rxBus.hasObservers()) if (_rxBus.hasObservers())
_rxBus.send(answer); _rxBus.send(answer);
if(!answer.is_correct())
((SolveFragment)getParentFragment()).onWrongAnswer(answer);
} }
dismiss(); dismiss();
......
...@@ -2,10 +2,10 @@ package ee.ttu.thesis.ui.game.point; ...@@ -2,10 +2,10 @@ package ee.ttu.thesis.ui.game.point;
import android.content.Context; import android.content.Context;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Vibrator; import android.os.Vibrator;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -19,16 +19,13 @@ import butterknife.BindView; ...@@ -19,16 +19,13 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ee.ttu.thesis.R; import ee.ttu.thesis.R;
import ee.ttu.thesis.data.model.Answer; import ee.ttu.thesis.data.model.Answer;
import ee.ttu.thesis.data.model.CheckInResponse;
import ee.ttu.thesis.data.model.Point; import ee.ttu.thesis.data.model.Point;
import ee.ttu.thesis.data.model.ProblemType; import ee.ttu.thesis.data.model.ProblemType;
import ee.ttu.thesis.data.model.Solution; import ee.ttu.thesis.data.model.Solution;
import ee.ttu.thesis.ui.game.GameActivity; import ee.ttu.thesis.ui.game.GameActivity;
import ee.ttu.thesis.utils.DeviceDimensionsHelper; import ee.ttu.thesis.utils.DeviceDimensionsHelper;
import ee.ttu.thesis.utils.RxBus; import ee.ttu.thesis.utils.RxBus;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.functions.Consumer;
import static ee.ttu.thesis.ui.game.GameActivity.POINT_KEY; import static ee.ttu.thesis.ui.game.GameActivity.POINT_KEY;
...@@ -68,7 +65,9 @@ public class SolveFragment extends Fragment implements onAnswerGivenListener { ...@@ -68,7 +65,9 @@ public class SolveFragment extends Fragment implements onAnswerGivenListener {
case (ProblemType.QR): case (ProblemType.QR):
mIcon.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.ic_qrcode_scan)); mIcon.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.ic_qrcode_scan));
mIcon.setBackground(getActivity().getResources().getDrawable(R.drawable.circle_login_icons)); mIcon.setBackground(getActivity().getResources().getDrawable(R.drawable.circle_login_icons));
mIcon.setElevation(DeviceDimensionsHelper.convertDpToPixel(6, getActivity())); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mIcon.setElevation(DeviceDimensionsHelper.convertDpToPixel(6, getActivity()));
}
mIcon.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN); mIcon.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN);
mInstructions.setText(getResources().getString(R.string.solve_qr)); mInstructions.setText(getResources().getString(R.string.solve_qr));
...@@ -88,8 +87,10 @@ public class SolveFragment extends Fragment implements onAnswerGivenListener { ...@@ -88,8 +87,10 @@ public class SolveFragment extends Fragment implements onAnswerGivenListener {
case (ProblemType.CAMERA): case (ProblemType.CAMERA):
mIcon.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.ic_photo_camera_black_24dp)); mIcon.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.ic_photo_camera_black_24dp));
mIcon.setBackground(getActivity().getResources().getDrawable(R.drawable.circle_login_icons)); mIcon.setBackground(getActivity().getResources().getDrawable(R.drawable.circle_login_icons));
mIcon.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.DST_OUT); mIcon.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN);
mIcon.setElevation(DeviceDimensionsHelper.convertDpToPixel(6, getActivity())); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mIcon.setElevation(DeviceDimensionsHelper.convertDpToPixel(6, getActivity()));
}
mInstructions.setText(getResources().getString(R.string.solve_photo)); mInstructions.setText(getResources().getString(R.string.solve_photo));
break; break;
...@@ -109,17 +110,17 @@ public class SolveFragment extends Fragment implements onAnswerGivenListener { ...@@ -109,17 +110,17 @@ public class SolveFragment extends Fragment implements onAnswerGivenListener {
super.onStart(); super.onStart();
_rxBus = ((GameActivity) getActivity()).getRxBusSingleton(); _rxBus = ((GameActivity) getActivity()).getRxBusSingleton();
mDisposables = new CompositeDisposable(); mDisposables = new CompositeDisposable();
mDisposables.add(_rxBus.asFlowable() // mDisposables.add(_rxBus.asFlowable()
.subscribeOn(AndroidSchedulers.mainThread()) // .subscribeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Object>() { // .subscribe(new Consumer<Object>() {
@Override // @Override
public void accept(@NonNull Object o) throws Exception { // public void accept(@NonNull Object o) throws Exception {
if (o instanceof CheckInResponse) { // if (o instanceof CheckInResponse) {
if (isUserWaitingForAnswer && ((CheckInResponse) o).getAnswer().getProblem_type().getTitle().equals(ProblemType.CAMERA)) // if (isUserWaitingForAnswer && ((CheckInResponse) o).getAnswer().getProblem_type().getTitle().equals(ProblemType.CAMERA))
onWrongAnswer(((CheckInResponse) o).getAnswer()); // onWrongAnswer(((CheckInResponse) o).getAnswer());
} // }
} // }
})); // }));
} }
@Override @Override
...@@ -137,14 +138,14 @@ public class SolveFragment extends Fragment implements onAnswerGivenListener { ...@@ -137,14 +138,14 @@ public class SolveFragment extends Fragment implements onAnswerGivenListener {
} }
} }
} }
if(!answer.getProblem_type().getTitle().equals(ProblemType.CAMERA))
onWrongAnswer(answer); onWrongAnswer(answer);
} }
private void onWrongAnswer(Answer answer) { public void onWrongAnswer(Answer answer) {
isUserWaitingForAnswer = false; isUserWaitingForAnswer = false;
mInstructions.setText(getActivity().getResources().getString(R.string.solve_wrong_answer, mPoint.getTimePenalty())); mInstructions.setText(getActivity().getResources().getString(R.string.solve_wrong_answer, mPoint.getTimePenalty()/1000));
Vibrator v = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); Vibrator v = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(500); v.vibrate(500);
......
...@@ -11,6 +11,7 @@ import java.util.List; ...@@ -11,6 +11,7 @@ import java.util.List;
import ee.ttu.thesis.R; import ee.ttu.thesis.R;
import ee.ttu.thesis.data.model.Game; import ee.ttu.thesis.data.model.Game;
import ee.ttu.thesis.ui.game.messages.ViewHolderGameNotification;
import ee.ttu.thesis.ui.list.ViewHolderGamesCategory; import ee.ttu.thesis.ui.list.ViewHolderGamesCategory;
import ee.ttu.thesis.ui.list.ViewHolderGamesGame; import ee.ttu.thesis.ui.list.ViewHolderGamesGame;
...@@ -22,12 +23,13 @@ public class GamesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> ...@@ -22,12 +23,13 @@ public class GamesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
private List<Object> mObjects; private List<Object> mObjects;
private Context mContext; private Context mContext;
private int mCurrentPoint;
public final static int CATEGORY_TITLE = 0, GAME = 1, BUTTON = 2;
public final static int CATEGORY_TITLE = 0, GAME = 1; public GamesAdapter(List<Object> mObjects, Context mContext, int currentPoint) {
public GamesAdapter(List<Object> mObjects, Context mContext) {
this.mObjects = mObjects; this.mObjects = mObjects;
this.mContext = mContext; this.mContext = mContext;
this.mCurrentPoint = currentPoint;
} }
public Context getContext() { public Context getContext() {
...@@ -48,6 +50,10 @@ public class GamesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> ...@@ -48,6 +50,10 @@ public class GamesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
View game_view = inflater.inflate(R.layout.item_game, parent, false); View game_view = inflater.inflate(R.layout.item_game, parent, false);
viewHolder = new ViewHolderGamesGame(game_view); viewHolder = new ViewHolderGamesGame(game_view);
break; break;
case BUTTON:
View button_view = inflater.inflate(R.layout.item_game_button, parent, false);
viewHolder = new ViewHolderGamesButtons(button_view);
break;
default: default:
View default_view = inflater.inflate(R.layout.item_game_category, parent, false); View default_view = inflater.inflate(R.layout.item_game_category, parent, false);
viewHolder = new ViewHolderGamesCategory(default_view); viewHolder = new ViewHolderGamesCategory(default_view);
...@@ -67,15 +73,28 @@ public class GamesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> ...@@ -67,15 +73,28 @@ public class GamesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
ViewHolderGamesGame viewHolderGamesGame = (ViewHolderGamesGame) holder; ViewHolderGamesGame viewHolderGamesGame = (ViewHolderGamesGame) holder;
configureGameViewHolder(viewHolderGamesGame , position); configureGameViewHolder(viewHolderGamesGame , position);
break; break;
case BUTTON:
ViewHolderGamesButtons viewHolderGamesButtons = (ViewHolderGamesButtons) holder;
configureGameButtonViewHolder(viewHolderGamesButtons , position);
break;
} }
} }
private void configureGameButtonViewHolder(ViewHolderGamesButtons holder, int position){
}
private void configureGameViewHolder(ViewHolderGamesGame viewHolderGamesGame, int position) { private void configureGameViewHolder(ViewHolderGamesGame viewHolderGamesGame, int position) {
Game game = (Game)mObjects.get(position); Game game = (Game)mObjects.get(position);
viewHolderGamesGame.getGameNameTV().setText(game.getTitle()); viewHolderGamesGame.getGameNameTV().setText(game.getTitle());
viewHolderGamesGame.getGameLocationTV().setText("@"+game.getLocationName()); viewHolderGamesGame.getGameLocationTV().setText("@"+game.getLocationName());
if(position == 1){ if(position == 1){
viewHolderGamesGame.getGameTimeTV().setText("• Now"); if(mCurrentPoint >= 0)
viewHolderGamesGame.getGameTimeTV().setText("• Continue");
else
viewHolderGamesGame.getGameTimeTV().setText("• Start");
viewHolderGamesGame.getGameTimeTV().setTextColor(getContext().getResources().getColor(R.color.colorAccent)); viewHolderGamesGame.getGameTimeTV().setTextColor(getContext().getResources().getColor(R.color.colorAccent));
}else{ }else{
SimpleDateFormat dateFormatter = new SimpleDateFormat("E, d-M-y"); SimpleDateFormat dateFormatter = new SimpleDateFormat("E, d-M-y");
...@@ -93,7 +112,9 @@ public class GamesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> ...@@ -93,7 +112,9 @@ public class GamesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
if(mObjects.get(position) instanceof String) if(position == mObjects.size()-1)
return BUTTON;
else if(mObjects.get(position) instanceof String)
return CATEGORY_TITLE; return CATEGORY_TITLE;
else else
return GAME; return GAME;
......
...@@ -83,4 +83,27 @@ public class ListPresenter<V extends ListView> extends BasePresenter<V> implemen ...@@ -83,4 +83,27 @@ public class ListPresenter<V extends ListView> extends BasePresenter<V> implemen
})); }));
} }
@Override
public String getService() {
return getDataManager().getService();
}
@Override
public String getGameCode() {
return getDataManager().getCurrentGameCode();
}
@Override
public int getCurrentPoint() {
return getDataManager().getCurrentPoint();
}
@Override
public void logOut() {
getDataManager().setService(null);
getDataManager().setCurrentUserId(0);
getDataManager().setCurrentGameCode(null);
getDataManager().setCurrentPoint(-1);
}
} }
...@@ -15,4 +15,11 @@ public interface ListTreasureHuntPresenter<V extends ListView> extends TreauseHu ...@@ -15,4 +15,11 @@ public interface ListTreasureHuntPresenter<V extends ListView> extends TreauseHu
void onAddGame(GamesRequest.AddGameRequest userGamesRequest); void onAddGame(GamesRequest.AddGameRequest userGamesRequest);
String getService();
String getGameCode();
int getCurrentPoint();
void logOut();
} }
package ee.ttu.thesis.ui.list;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import ee.ttu.thesis.R;
/**
* Created by hajola on 4.06.17.
*/
public class ViewHolderGamesButtons extends RecyclerView.ViewHolder {
@BindView(R.id.logout)
TextView logOut;
public ViewHolderGamesButtons(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
public TextView getLogOut() {
return logOut;
}
public void setLogOut(TextView logOut) {
this.logOut = logOut;
}
}
\ No newline at end of file
...@@ -113,4 +113,74 @@ public class LoginPresenter<V extends LoginView> extends BasePresenter<V> implem ...@@ -113,4 +113,74 @@ public class LoginPresenter<V extends LoginView> extends BasePresenter<V> implem
public void saveUser(User user) { public void saveUser(User user) {
getDataManager().setCurrentUserId(user.getId()); getDataManager().setCurrentUserId(user.getId());
} }
@Override
public void saveService(String service) {
getDataManager().setService(service);
}
@Override
public String getService() {
return getDataManager().getService();
}
@Override
public String getGameCode() {
return getDataManager().getCurrentGameCode();
}
@Override
public String getUserId() {
return Integer.toString(getDataManager().getCurrentUserId());
}
@Override
public void getUserGame(String gameCode, String userId) {
getmThesisView().showLargeLoading();
getCompositeDisposable().add(getDataManager()
.getUserGame(gameCode, userId)
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribe(new Consumer<UserGame>() {
@Override
public void accept(@NonNull UserGame userGame) throws Exception {
getmThesisView().hideLargeLoading();
if (!isViewAttached()) {
return;
}
if (userGame != null) {
getmThesisView().loadUserGame(userGame);
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(@NonNull Throwable throwable) throws Exception {
getmThesisView().hideLargeLoading();
getmThesisView().onError(throwable.getMessage());
}
}));
}
@Override
public void logIn(String service, String access_token) {
getmThesisView().showLargeLoading();
getCompositeDisposable().add(getDataManager()
.login(service, access_token)
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribe(new Consumer<String>() {
@Override
public void accept(@NonNull String s) throws Exception {
getmThesisView().hideLargeLoading();
getmThesisView().loggedIn(s);
}
}, new Consumer<Throwable>() {
@Override
public void accept(@NonNull Throwable throwable) throws Exception {
getmThesisView().hideLargeLoading();
getmThesisView().onError(throwable.getMessage());
}
}));
}
} }
...@@ -18,4 +18,16 @@ public interface LoginTreasureHuntPresenter<V extends LoginView> extends Treause ...@@ -18,4 +18,16 @@ public interface LoginTreasureHuntPresenter<V extends LoginView> extends Treause
void saveUser(User user); void saveUser(User user);
void saveService(String service);
String getService();
String getGameCode();
String getUserId();
void getUserGame(String gameCode, String userId);
void logIn(String service, String access_token);
} }
...@@ -17,10 +17,14 @@ public interface LoginView extends TreasureHuntView { ...@@ -17,10 +17,14 @@ public interface LoginView extends TreasureHuntView {
void userAdded(User user); void userAdded(User user);
void loggedIn(String userId);
void showLargeLoading(); void showLargeLoading();
void hideLargeLoading(); void hideLargeLoading();
void gameAdded(UserGame userGame); void gameAdded(UserGame userGame);
void loadUserGame(UserGame userGame);
} }
package ee.ttu.thesis.ui.past; package ee.ttu.thesis.ui.past;
import android.location.Location;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.JointType; import com.google.android.gms.maps.model.JointType;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MapStyleOptions; import com.google.android.gms.maps.model.MapStyleOptions;
import com.google.android.gms.maps.model.Polyline; import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions; import com.google.android.gms.maps.model.PolylineOptions;
import com.google.android.gms.maps.model.RoundCap; import com.google.android.gms.maps.model.RoundCap;
import com.orhanobut.logger.Logger; import com.orhanobut.logger.Logger;
import java.text.SimpleDateFormat;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject; import javax.inject.Inject;
...@@ -24,11 +29,13 @@ import butterknife.BindView; ...@@ -24,11 +29,13 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ee.ttu.thesis.R; import ee.ttu.thesis.R;
import ee.ttu.thesis.data.model.CheckIn; import ee.ttu.thesis.data.model.CheckIn;
import ee.ttu.thesis.data.model.Game; import ee.ttu.thesis.data.model.User;
import ee.ttu.thesis.data.model.UserGame;
import ee.ttu.thesis.ui.base.BaseActivity; import ee.ttu.thesis.ui.base.BaseActivity;
import ee.ttu.thesis.ui.game.map.WorkAroundMapFragment; import ee.ttu.thesis.ui.game.map.WorkAroundMapFragment;
import ee.ttu.thesis.ui.start.StartTreasureHuntPresenter;
import ee.ttu.thesis.ui.start.StartView; import static ee.ttu.thesis.ui.game.GameActivity.USER_GAME_KEY;
import static ee.ttu.thesis.ui.game.GameActivity.USER_KEY;
/** /**
* Created by hajola on 29.04.17. * Created by hajola on 29.04.17.
...@@ -37,27 +44,51 @@ import ee.ttu.thesis.ui.start.StartView; ...@@ -37,27 +44,51 @@ import ee.ttu.thesis.ui.start.StartView;
public class HistoryActivity extends BaseActivity public class HistoryActivity extends BaseActivity
implements OnMapReadyCallback, implements OnMapReadyCallback,
GoogleMap.OnPolylineClickListener, GoogleMap.OnPolylineClickListener,
HistoryView{ HistoryView {
GoogleMap mMap; GoogleMap mMap;
@Inject @Inject
HistoryTreasureHuntPresenter<HistoryView> mPresenter; HistoryTreasureHuntPresenter<HistoryView> mPresenter;
Game mGame; UserGame mGame;
User mUser;
@BindView(R.id.activity_history_scrollview) @BindView(R.id.activity_history_scrollview)
ScrollView mScrollView; ScrollView mScrollView;
// @BindView(R.id.activity_history_rank)
// TextView mRank;
@BindView(R.id.activity_history_distance_traveled)
TextView mDistance;
@BindView(R.id.activity_history_time_taken)
TextView mTimeTaken;
@BindView(R.id.activity_history_number_of_points)
TextView mNumbOfPoints;
@BindView(R.id.activityV_history_average_speed)
TextView mAverageSpeed;
@BindView(R.id.activity_history_average_point_speed)
TextView mAveragePointSpeed;
@BindView(R.id.activity_history_start_time)
TextView mStart;
@BindView(R.id.activity_history_end_time)
TextView mEnd;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getActivityComponent().inject(this);
setContentView(R.layout.activity_history); setContentView(R.layout.activity_history);
mPresenter.onAttach(this);
ButterKnife.bind(this); ButterKnife.bind(this);
mGame = getIntent().getParcelableExtra(USER_GAME_KEY);
mUser = getIntent().getParcelableExtra(USER_KEY);
WorkAroundMapFragment mapFragment = (WorkAroundMapFragment) getSupportFragmentManager() WorkAroundMapFragment mapFragment = (WorkAroundMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map); .findFragmentById(R.id.map);
mapFragment.getMapAsync(this); mapFragment.getMapAsync(this);
mPresenter.getStats(Integer.toString(mUser.getId()), Integer.toString(mGame.getGame().getId()));
} }
@Override @Override
...@@ -80,25 +111,6 @@ public class HistoryActivity extends BaseActivity ...@@ -80,25 +111,6 @@ public class HistoryActivity extends BaseActivity
mScrollView.requestDisallowInterceptTouchEvent(true); mScrollView.requestDisallowInterceptTouchEvent(true);
} }
}); });
// a single polyline. Read the rest of the tutorial to learn more.
Polyline polyline1 = googleMap.addPolyline(new PolylineOptions()
.add(
new LatLng(-35.016, 143.321),
new LatLng(-34.747, 145.592),
new LatLng(-34.364, 147.891),
new LatLng(-33.501, 150.217),
new LatLng(-32.306, 149.248),
new LatLng(-32.491, 147.309)));
// Position the map's camera near Alice Springs in the center of Australia,
// and set the zoom factor so most of Australia shows on the screen.
polyline1.setEndCap(new RoundCap());
polyline1.setColor(getResources().getColor(R.color.colorAccent));
polyline1.setJointType(JointType.ROUND);
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-23.684, 133.903), 4));
// Set listeners for click events.
googleMap.setOnPolylineClickListener(this);
} }
@Override @Override
...@@ -107,16 +119,6 @@ public class HistoryActivity extends BaseActivity ...@@ -107,16 +119,6 @@ public class HistoryActivity extends BaseActivity
} }
@Override @Override
public void showLoading() {
}
@Override
public void hideLoading() {
}
@Override
public void openActivityOnTokenExpire() { public void openActivityOnTokenExpire() {
} }
...@@ -128,7 +130,7 @@ public class HistoryActivity extends BaseActivity ...@@ -128,7 +130,7 @@ public class HistoryActivity extends BaseActivity
@Override @Override
public void onError(String message) { public void onError(String message) {
Toast.makeText(this, message, Toast.LENGTH_LONG ).show();
} }
@Override @Override
...@@ -143,6 +145,76 @@ public class HistoryActivity extends BaseActivity ...@@ -143,6 +145,76 @@ public class HistoryActivity extends BaseActivity
@Override @Override
public void loadStats(List<CheckIn> checkIns) { public void loadStats(List<CheckIn> checkIns) {
if (checkIns.size() > 0) {
int numbOfPoints = 0;
PolylineOptions polylineOptions = new PolylineOptions();
int lastPointId = -1;
for (CheckIn c : checkIns) {
if(c.getCurrent_point() > 0){
if(lastPointId != c.getCurrent_point()){
lastPointId = c.getCurrent_point();
numbOfPoints++;
}
}
polylineOptions.add(c.getLatLng());
}
Polyline polyline1 = mMap.addPolyline(polylineOptions);
polyline1.setEndCap(new RoundCap());
polyline1.setColor(getResources().getColor(R.color.colorAccent));
polyline1.setJointType(JointType.ROUND);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(checkIns.get(0).getLatLng(), 4));
// Set listener for click events.
mMap.setOnPolylineClickListener(this);
// DISTANCE
float distance = 0;
if(checkIns.size() > 1) {
for (int i = 1; i < checkIns.size(); i++) {
Location loc1 = new Location("");
loc1.setLatitude(checkIns.get(i-1).getLat());
loc1.setLongitude(checkIns.get(i-1).getLon());
Location loc2 = new Location("");
loc2.setLatitude(checkIns.get(i).getLat());
loc2.setLongitude(checkIns.get(i).getLon());
distance += loc1.distanceTo(loc2);
}
String s = String.format("%.0f meters", distance);
mDistance.setText(s);
} else {
mDistance.setText("0 meters");
}
// TIME TAKEN
long duration = mGame.getEnd().getTime() - mGame.getStart().getTime();
// long diffInSeconds = TimeUnit.MILLISECONDS.toSeconds(duration);
float diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(duration);
String s = String.format("%.0f minutes", diffInMinutes);
mTimeTaken.setText(s);
// NUMBER OF POINTS
mNumbOfPoints.setText(Integer.toString(numbOfPoints));
// AVERAGE SPEEDS
double averageSpeed = (distance/1000)/(diffInMinutes/60);
s = String.format("%.2f", averageSpeed);
mAverageSpeed.setText(s + " km / h");
averageSpeed = (numbOfPoints)/(diffInMinutes/60);
s = String.format("%.2f", averageSpeed);
mAveragePointSpeed.setText(s + " point / h");
// START AND END TIME
SimpleDateFormat dateFormatter = new SimpleDateFormat("E, d-M-y hh:mm", Locale.US);
mStart.setText(dateFormatter.format(mGame.getStart()));
mEnd.setText(dateFormatter.format(mGame.getEnd()));
hideLoading();
}
} }
} }
...@@ -13,6 +13,8 @@ import android.support.v4.view.ViewPager; ...@@ -13,6 +13,8 @@ import android.support.v4.view.ViewPager;
import android.view.View; import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import java.util.Date;
import javax.inject.Inject; import javax.inject.Inject;
import butterknife.BindView; import butterknife.BindView;
...@@ -20,11 +22,13 @@ import butterknife.ButterKnife; ...@@ -20,11 +22,13 @@ import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import ee.ttu.thesis.R; import ee.ttu.thesis.R;
import ee.ttu.thesis.data.model.User; import ee.ttu.thesis.data.model.User;
import ee.ttu.thesis.data.model.UserGame;
import ee.ttu.thesis.ui.base.BaseActivity; import ee.ttu.thesis.ui.base.BaseActivity;
import ee.ttu.thesis.ui.game.GameActivity; import ee.ttu.thesis.ui.game.GameActivity;
import ee.ttu.thesis.data.model.Game; import ee.ttu.thesis.data.model.Game;
import static ee.ttu.thesis.ui.game.GameActivity.GAME_KEY; import static ee.ttu.thesis.ui.game.GameActivity.GAME_KEY;
import static ee.ttu.thesis.ui.game.GameActivity.USER_GAME_KEY;
import static ee.ttu.thesis.ui.game.GameActivity.USER_KEY; import static ee.ttu.thesis.ui.game.GameActivity.USER_KEY;
/** /**
...@@ -36,6 +40,7 @@ public class StartActivity extends BaseActivity implements StartView { ...@@ -36,6 +40,7 @@ public class StartActivity extends BaseActivity implements StartView {
StartTreasureHuntPresenter<StartView> mPresenter; StartTreasureHuntPresenter<StartView> mPresenter;
Game mGame; Game mGame;
UserGame mUserGame;
User mUser; User mUser;
@BindView(R.id.activity_start_viewpager) @BindView(R.id.activity_start_viewpager)
...@@ -55,6 +60,7 @@ public class StartActivity extends BaseActivity implements StartView { ...@@ -55,6 +60,7 @@ public class StartActivity extends BaseActivity implements StartView {
mPresenter.onAttach(this); mPresenter.onAttach(this);
mGame = getIntent().getParcelableExtra(GAME_KEY); mGame = getIntent().getParcelableExtra(GAME_KEY);
mUser = getIntent().getParcelableExtra(USER_KEY); mUser = getIntent().getParcelableExtra(USER_KEY);
mUserGame = getIntent().getParcelableExtra(USER_GAME_KEY);
mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager(), this); mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager(), this);
mPager.setAdapter(mPagerAdapter); mPager.setAdapter(mPagerAdapter);
mTabLayout.setupWithViewPager(mPager, true); mTabLayout.setupWithViewPager(mPager, true);
...@@ -62,6 +68,7 @@ public class StartActivity extends BaseActivity implements StartView { ...@@ -62,6 +68,7 @@ public class StartActivity extends BaseActivity implements StartView {
@OnClick(R.id.activity_start_button) @OnClick(R.id.activity_start_button)
public void onStartClicked(View v){ public void onStartClicked(View v){
mUserGame.setStart(new Date());
mPresenter.startGame(Integer.toString(mGame.getUserGameId())); mPresenter.startGame(Integer.toString(mGame.getUserGameId()));
} }
...@@ -92,12 +99,13 @@ public class StartActivity extends BaseActivity implements StartView { ...@@ -92,12 +99,13 @@ public class StartActivity extends BaseActivity implements StartView {
@Override @Override
public void gameStarted() { public void gameStarted() {
mPresenter.saveUserAndGame(mUser.getId(), mGame.getGameCode());
Intent intent = new Intent(StartActivity.this, GameActivity.class); Intent intent = new Intent(StartActivity.this, GameActivity.class);
intent.putExtra(GAME_KEY, mGame); intent.putExtra(GAME_KEY, mGame);
intent.putExtra(USER_GAME_KEY, mUserGame);
intent.putExtra(USER_KEY, mUser); intent.putExtra(USER_KEY, mUser);
startActivity(intent); startActivity(intent);
finish(); finish();
} }
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter { private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
...@@ -122,7 +130,6 @@ public class StartActivity extends BaseActivity implements StartView { ...@@ -122,7 +130,6 @@ public class StartActivity extends BaseActivity implements StartView {
fragment = new TutorialThreeFragment(); fragment = new TutorialThreeFragment();
} else if (position == 3) { } else if (position == 3) {
fragment = new TutorialFourFragment(); fragment = new TutorialFourFragment();
} else{ } else{
fragment = new TutorialFiveFragment(); fragment = new TutorialFiveFragment();
......
...@@ -41,4 +41,10 @@ public class StartPresenter<V extends StartView> extends BasePresenter<V> implem ...@@ -41,4 +41,10 @@ public class StartPresenter<V extends StartView> extends BasePresenter<V> implem
} }
})); }));
} }
@Override
public void saveUserAndGame(int userId, String gameCode) {
getDataManager().setCurrentUserId(userId);
getDataManager().setCurrentGameCode(gameCode);
}
} }
...@@ -9,4 +9,6 @@ import ee.ttu.thesis.ui.base.TreauseHuntPresenter; ...@@ -9,4 +9,6 @@ import ee.ttu.thesis.ui.base.TreauseHuntPresenter;
public interface StartTreasureHuntPresenter<V extends StartView> extends TreauseHuntPresenter<V> { public interface StartTreasureHuntPresenter<V extends StartView> extends TreauseHuntPresenter<V> {
void startGame(String userGameId); void startGame(String userGameId);
void saveUserAndGame(int userId, String gameCode);
} }
\ No newline at end of file
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<gradient <gradient
android:startColor="@color/colorPrimary" android:startColor="@color/colorPrimaryDark"
android:endColor="@android:color/transparent" android:endColor="@android:color/transparent"
android:angle="90" android:angle="90"
android:type="linear" android:type="linear"
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
android:id="@+id/activity_history_scrollview" android:id="@+id/activity_history_scrollview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorPrimary"> android:background="@color/colorPrimaryDark">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorPrimary" android:background="@color/colorPrimaryDark"
android:orientation="vertical"> android:orientation="vertical">
<RelativeLayout <RelativeLayout
...@@ -40,31 +40,31 @@ ...@@ -40,31 +40,31 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="16dp"> android:padding="16dp">
<LinearLayout <!--<LinearLayout-->
android:layout_width="match_parent" <!--android:layout_width="match_parent"-->
android:layout_height="wrap_content" <!--android:layout_height="wrap_content"-->
android:orientation="horizontal" <!--android:orientation="horizontal"-->
android:paddingBottom="32dp"> <!--android:paddingBottom="32dp">-->
<TextView <!--<TextView-->
android:id="@+id/textView15" <!--android:id="@+id/textView15"-->
android:layout_width="wrap_content" <!--android:layout_width="wrap_content"-->
android:layout_height="wrap_content" <!--android:layout_height="wrap_content"-->
android:paddingRight="16dp" <!--android:paddingRight="16dp"-->
android:text="Rank:" <!--android:text="Rank:"-->
android:textColor="@color/colorSecondaryMain" <!--android:textColor="@color/colorSecondaryMain"-->
android:textSize="24sp" /> <!--android:textSize="24sp" />-->
<TextView <!--<TextView-->
android:id="@+id/textView17" <!--android:id="@+id/activity_history_rank"-->
android:layout_width="0px" <!--android:layout_width="0px"-->
android:layout_height="wrap_content" <!--android:layout_height="wrap_content"-->
android:layout_weight="1" <!--android:layout_weight="1"-->
android:text="2nd" <!--android:text="NULL"-->
android:textAlignment="textStart" <!--android:textAlignment="textStart"-->
android:textColor="@color/white" <!--android:textColor="@color/white"-->
android:textSize="24sp" /> <!--android:textSize="24sp" />-->
</LinearLayout> <!--</LinearLayout>-->
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
android:layout_width="0px" android:layout_width="0px"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="12.4 km" android:text="NULL"
android:textAlignment="textStart" android:textAlignment="textStart"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="24sp" /> android:textSize="24sp" />
...@@ -108,11 +108,11 @@ ...@@ -108,11 +108,11 @@
android:textSize="24sp" /> android:textSize="24sp" />
<TextView <TextView
android:id="@+id/textView175" android:id="@+id/activity_history_time_taken"
android:layout_width="0px" android:layout_width="0px"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="147 minutes" android:text="NULL"
android:textAlignment="textStart" android:textAlignment="textStart"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="24sp" /> android:textSize="24sp" />
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
android:layout_width="0px" android:layout_width="0px"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="12" android:text="NULL"
android:textAlignment="textStart" android:textAlignment="textStart"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="24sp" /> android:textSize="24sp" />
...@@ -164,7 +164,7 @@ ...@@ -164,7 +164,7 @@
android:layout_width="0px" android:layout_width="0px"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="6.27 km/h" android:text="NULL"
android:textAlignment="textStart" android:textAlignment="textStart"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="24sp" /> android:textSize="24sp" />
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
android:layout_width="0px" android:layout_width="0px"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="12 min/point" android:text="NULL"
android:textAlignment="textStart" android:textAlignment="textStart"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="24sp" /> android:textSize="24sp" />
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
android:layout_width="0px" android:layout_width="0px"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="DD/MM hh:mm" android:text="NULL"
android:textAlignment="textStart" android:textAlignment="textStart"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="24sp" /> android:textSize="24sp" />
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
android:layout_width="0px" android:layout_width="0px"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="DD/MM hh:mm" android:text="NULL"
android:textAlignment="textStart" android:textAlignment="textStart"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="24sp" /> android:textSize="24sp" />
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout <android.support.design.widget.CoordinatorLayout xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content" android:id="@+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
...@@ -7,21 +7,6 @@ ...@@ -7,21 +7,6 @@
android:background="@color/colorPrimaryDark" android:background="@color/colorPrimaryDark"
android:layout_height="match_parent"> android:layout_height="match_parent">
<!--<TextView-->
<!--android:id="@+id/activity_main_textview"-->
<!--android:text="text"-->
<!--android:layout_margin="20dp"-->
<!--android:textSize="24sp"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content" />-->
<!--<Button-->
<!--android:id="@+id/button2"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="LogOut" />-->
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/activity_main_recyclerview" android:id="@+id/activity_main_recyclerview"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -42,6 +27,7 @@ ...@@ -42,6 +27,7 @@
app:layout_behavior="ee.ttu.thesis.utils.ScrollAwareFABBehavior" app:layout_behavior="ee.ttu.thesis.utils.ScrollAwareFABBehavior"
app:layout_anchor="@id/activity_main_recyclerview" app:layout_anchor="@id/activity_main_recyclerview"
app:layout_anchorGravity="bottom|right|end" app:layout_anchorGravity="bottom|right|end"
app:srcCompat="@drawable/ic_add_black_48dp" /> app:srcCompat="@drawable/ic_add_black_48dp"
tools:ignore="VectorDrawableCompat" />
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>
\ 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="@color/colorPrimaryDark"
android:orientation="vertical">
<TextView
android:id="@+id/dialog_info_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="Welcome Back!"
android:textAlignment="center"
android:textColor="@color/white" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingRight="4dp"
android:paddingTop="8dp">
<Button
android:id="@+id/dialog_info_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="4dp"
android:background="@android:color/transparent"
android:text="OK"
android:textColor="@color/colorAccent" />
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
android:textSize="14sp" /> android:textSize="14sp" />
<LinearLayout <LinearLayout
android:id="@+id/fragment_compass_hint_root" android:id="@+id/fragment_compass_hint_rooreret"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/fragment_compass_compass_root" android:id="@+id/fragment_compass_compass_rdsadsaoot"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
......
<?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:layout_gravity="bottom|center_horizontal"
android:layout_marginTop="64dp"
android:orientation="vertical">
<TextView
android:id="@+id/logout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_gravity="bottom|center_horizontal"
android:layout_margin="4dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/login_rounded_rectangle_filled"
android:elevation="8dp"
android:paddingBottom="8dp"
android:paddingEnd="32dp"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:paddingStart="32dp"
android:paddingTop="8dp"
android:text="LOGOUT"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="18sp" />'
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ee.ttu.thesis.ui.game.point.CompassView xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/compassView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="400dp" android:layout_height="wrap_content"
android:padding="16dp" /> android:orientation="vertical">
\ No newline at end of file <ee.ttu.thesis.ui.game.point.CompassView
android:id="@+id/compassView"
android:layout_width="match_parent"
android:layout_height="500dp"
android:padding="16dp" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_compass_distance" android:id="@+id/fragment_compass_distance_ll"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="32dp" android:orientation="vertical">
android:paddingLeft="32dp"
android:paddingRight="32dp" <TextView
android:paddingTop="24dp" android:id="@+id/fragment_compass_distance"
android:textAlignment="center" android:layout_width="match_parent"
android:textColor="@color/colorSecondaryMain" android:layout_height="wrap_content"
android:textSize="24sp" /> android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="24dp"
android:textAlignment="center"
android:textColor="@color/colorSecondaryMain"
android:textSize="24sp" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_compass_distance_accuracy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="32dp"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:textAlignment="center"
android:textColor="@color/colorSecondaryMain"
android:textSize="14sp" />
</LinearLayout>
\ No newline at end of file
...@@ -38,4 +38,7 @@ ...@@ -38,4 +38,7 @@
<color name="OrderSelectedTabTextColor">@color/colorAccent</color> <color name="OrderSelectedTabTextColor">@color/colorAccent</color>
<color name="OrderUnSelectedTabTextColor">@color/colorPrimary</color> <color name="OrderUnSelectedTabTextColor">@color/colorPrimary</color>
<color name="mapBoundFillColor">#642d303c</color>
</resources> </resources>
...@@ -20,4 +20,8 @@ ...@@ -20,4 +20,8 @@
<string name="api_default_error">Something went wrong</string> <string name="api_default_error">Something went wrong</string>
<string name="connection_error">Internet connection lost</string> <string name="connection_error">Internet connection lost</string>
<string name="api_retry_error">Try again</string> <string name="api_retry_error">Try again</string>
<string name="facebook_app_id">122204701691617</string>
<string name="fb_login_protocol_scheme">fb122204701691617</string>
</resources> </resources>
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