Commit df953f27 by Joosep L

added features/bug fixes

parent 4ffec09d
Showing with 1554 additions and 274 deletions
......@@ -62,6 +62,7 @@ dependencies {
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'){
transitive=true
......
......@@ -7,28 +7,52 @@
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<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.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<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
android:name=".ThesisApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
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
android:name=".ui.login.LoginActivity"
android:screenOrientation="portrait"
android:label="@string/app_name">
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -38,34 +62,28 @@
<activity
android:name=".ui.list.ListActivity"
android:screenOrientation="portrait">
</activity>
android:screenOrientation="portrait"></activity>
<activity
android:name=".ui.start.StartActivity"
android:screenOrientation="portrait">
</activity>
android:screenOrientation="portrait"></activity>
<activity
android:name=".ui.game.GameActivity"
android:screenOrientation="portrait">
</activity>
android:screenOrientation="portrait"></activity>
<activity
android:name=".ui.future.FutureGameActivity"
android:screenOrientation="portrait">
</activity>
android:screenOrientation="portrait"></activity>
<activity
android:name=".ui.past.HistoryActivity"
android:screenOrientation="portrait">
</activity>
android:screenOrientation="portrait"></activity>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCVOu0A8kPjB3jfA09CzqoEwrZ-VAbJuyQ"/>
android:value="AIzaSyCVOu0A8kPjB3jfA09CzqoEwrZ-VAbJuyQ" />
</application>
</manifest>
\ No newline at end of file
......@@ -8,6 +8,7 @@ import javax.inject.Inject;
import javax.inject.Singleton;
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.CheckInResponse;
import ee.ttu.thesis.data.model.Game;
......@@ -67,6 +68,11 @@ public class AppDataManager implements DataManager {
}
@Override
public Observable<String> endGame(String userGameId) {
return mApiHelper.endGame(userGameId);
}
@Override
public Observable<List<Game>> getGame(String gameCode) {
return mApiHelper.getGame(gameCode);
}
......@@ -82,16 +88,31 @@ public class AppDataManager implements DataManager {
}
@Override
public Observable<List<Bound>> getBounds(String gameId) {
return mApiHelper.getBounds(gameId);
}
@Override
public Observable<String> postAnswer(Answer answer) {
return mApiHelper.postAnswer(answer);
}
@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) {
return mApiHelper.getStats(user_id, game_id);
}
@Override
public Observable<UserGame> getUserGame(String gameCode, String userId) {
return mApiHelper.getUserGame(gameCode, userId);
}
@Override
public int getCurrentUserId() {
return mPreferencesHelper.getCurrentUserId();
}
......@@ -102,12 +123,33 @@ public class AppDataManager implements DataManager {
}
@Override
public int getCurrentGame() {
return 0;
public String getCurrentGameCode() {
return mPreferencesHelper.getCurrentGameCode();
}
@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 {
private String answer;
@Expose
@SerializedName("photo")
private String photoInBase64;
@Expose
@SerializedName("is_correct")
private boolean is_correct;
public String getPhotoInBase64() {
return photoInBase64;
}
public void setPhotoInBase64(String photoInBase64) {
this.photoInBase64 = photoInBase64;
}
public int getId() {
return id;
}
......@@ -89,6 +101,9 @@ public class Answer {
this.is_correct = is_correct;
}
public Answer() {
}
public Answer(String 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 {
@SerializedName("notification_text")
private String text;
@Expose
@SerializedName("mpoly")
private String mpoly;
public String getMpoly() {
return mpoly;
}
public void setMpoly(String mpoly) {
this.mpoly = mpoly;
}
@Expose
@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;
import com.google.android.gms.maps.model.LatLng;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
......@@ -42,9 +43,21 @@ public class CheckIn {
private int current_point_id;
@Expose
@SerializedName("current_point")
private int current_point;
@Expose
@SerializedName("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() {
return user_game_id;
}
......@@ -77,6 +90,10 @@ public class CheckIn {
this.current_point_id = current_point_id;
}
public LatLng getLatLng(){
return new LatLng(lat, lon);
}
public int getLatest_answer_id() {
return latest_answer_id;
}
......
......@@ -5,8 +5,6 @@ import com.google.gson.annotations.SerializedName;
import java.util.List;
import io.reactivex.Observable;
/**
* Created by hajola on 17.05.17.
*/
......@@ -25,6 +23,17 @@ public class CheckInResponse {
@SerializedName("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() {
return bounds;
......
......@@ -12,11 +12,22 @@ import com.google.gson.annotations.SerializedName;
public class User implements Parcelable {
@Expose
@SerializedName("user_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() {
return id;
}
......@@ -25,6 +36,9 @@ public class User implements Parcelable {
this.id = id;
}
public User() {
}
@Override
public int describeContents() {
return 0;
......@@ -33,16 +47,15 @@ public class User implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.id);
}
public User() {
dest.writeString(this.service);
}
protected User(Parcel in) {
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
public User createFromParcel(Parcel source) {
return new User(source);
......
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.SerializedName;
import java.util.Date;
/**
* Created by hajola on 9.05.17.
*/
public class UserGame {
public class UserGame implements Parcelable {
@Expose
@SerializedName("user_game_id")
......@@ -17,6 +22,14 @@ public class UserGame {
@SerializedName("game")
private Game game;
@Expose
@SerializedName("start_time")
private Date start;
@Expose
@SerializedName("end_time")
private Date end;
public int getUserGameId() {
return UserGameId;
}
......@@ -33,8 +46,61 @@ public class UserGame {
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
public String 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;
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
+ "/user/games";
......@@ -24,15 +24,24 @@ public final class ApiEndPoint {
public static final String ENDPOINT_GET_CHECK_INS = BASE_URL
+ "/game/stats";
public static final String ENDPOINT_GET_BOUNDS = BASE_URL
+ "/game/bounds";
public static final String ENDPOINT_START_GAME = BASE_URL
+ "/game/start";
public static final String ENDPOINT_END_GAME = BASE_URL
+ "/game/end";
public static final String ENDPOINT_GET_GAME = BASE_URL
+ "/games";
public static final String ENDPOINT_MAKE_USER = BASE_URL
+ "/user/add";
public static final String ENDPOINT_LOGIN = BASE_URL
+ "/user/login";
public static final String ENDPOINT_POST_MESSAGE = BASE_URL
+ "/game/message";
......
......@@ -3,6 +3,7 @@ package ee.ttu.thesis.data.network;
import java.util.List;
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.CheckInResponse;
import ee.ttu.thesis.data.model.Game;
......@@ -32,14 +33,22 @@ public interface ApiHelper {
Observable<String> startGame(String userGameId);
Observable<String> endGame(String userGameId);
Observable<List<Game>> getGame(String gameCode);
Observable<User> makeUser(String userName, String deviceId);
Observable<String> postMessage(Message request);
Observable<List<Bound>> getBounds(String gameId);
Observable<String> postAnswer(Answer answer);
Observable<String> login(String service, String access_token);
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;
import javax.inject.Singleton;
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.CheckInResponse;
import ee.ttu.thesis.data.model.Game;
......@@ -87,6 +88,14 @@ public class AppApiHelper implements ApiHelper {
}
@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) {
return Rx2AndroidNetworking.get(ApiEndPoint.ENDPOINT_GET_GAME)
.addQueryParameter("game_code", gameCode)
......@@ -114,23 +123,63 @@ public class AppApiHelper implements ApiHelper {
}
@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) {
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("is_correct", answer.is_correct() ? "1" : "0")
if(answer.getPhotoInBase64() == null) {
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("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()
.getObjectObservable(String.class);
}
@Override
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("game_id", game_id)
.build()
.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 {
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;
@Inject
......@@ -31,8 +35,6 @@ public class AppPreferencesHelper implements PreferencesHelper {
@Override
public int getCurrentUserId() {
int userId = mPrefs.getInt(PREF_KEY_CURRENT_USER_ID, 0);
if(userId == 0)
return 1;
return userId;
}
......@@ -43,14 +45,35 @@ public class AppPreferencesHelper implements PreferencesHelper {
}
@Override
public int getCurrentGame() {
int id = mPrefs.getInt(PREF_KEY_CURRENT_GAME, 0);
return id;
public String getCurrentGameCode() {
String gameCode = mPrefs.getString(PREF_KEY_CURRENT_GAME, null);
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
public void setCurrentGameId(int gameId) {
int id = gameId;
mPrefs.edit().putInt(PREF_KEY_CURRENT_GAME, id).apply();
public void setService(String service) {
mPrefs.edit().putString(PREF_KEY_SERVICE, service).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 {
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;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.annotation.Nullable;
......@@ -13,10 +14,16 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
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.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.USER_GAME_KEY;
import static ee.ttu.thesis.ui.game.GameActivity.USER_KEY;
/**
* Created by hajola on 28.04.17.
......@@ -38,6 +45,8 @@ public class FutureGameActivity extends BaseActivity {
TextView mDescription;
Game mGame;
User mUser;
UserGame mUserGame;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
......@@ -46,6 +55,8 @@ public class FutureGameActivity extends BaseActivity {
ButterKnife.bind(this);
mGame = getIntent().getParcelableExtra(GAME_KEY);
mUserGame = getIntent().getParcelableExtra(USER_GAME_KEY);
mUser = getIntent().getParcelableExtra(USER_KEY);
mTitle.setText(mGame.getTitle());
mDescription.setText(mGame.getDescription());
......@@ -78,7 +89,12 @@ public class FutureGameActivity extends BaseActivity {
}
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();
......
......@@ -21,6 +21,7 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
......@@ -48,18 +49,24 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ee.ttu.thesis.R;
import ee.ttu.thesis.data.model.Answer;
import ee.ttu.thesis.data.model.Message;
import ee.ttu.thesis.data.model.User;
import ee.ttu.thesis.ui.base.BaseActivity;
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.CheckInResponse;
import ee.ttu.thesis.data.model.Game;
import ee.ttu.thesis.data.model.GamesRequest;
import ee.ttu.thesis.data.model.Message;
import ee.ttu.thesis.data.model.Point;
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.game.map.MapFragment;
import ee.ttu.thesis.ui.game.messages.NotificationFragment;
import ee.ttu.thesis.ui.game.point.GameFragment;
import ee.ttu.thesis.ui.list.AddGameDialogFragment;
import ee.ttu.thesis.ui.list.ListActivity;
import ee.ttu.thesis.ui.past.HistoryActivity;
import ee.ttu.thesis.utils.RxBus;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
......@@ -74,12 +81,13 @@ public class GameActivity extends BaseActivity
GoogleApiClient.OnConnectionFailedListener,
GoogleApiClient.ConnectionCallbacks,
LocationListener,
GameView{
GameView {
@Inject
GameTreasureHuntPresenter<GameView> mPresenter;
public static final String GAME_KEY = "game";
public static final String USER_GAME_KEY = "UserGame";
// Keys for storing activity state in the Bundle.
protected final static String KEY_REQUESTING_LOCATION_UPDATES = "requesting-location-updates";
protected final static String KEY_LOCATION = "location";
......@@ -107,6 +115,7 @@ public class GameActivity extends BaseActivity
TabLayout mTabLayout;
Game mGame;
UserGame mUserGame;
User mUser;
Answer mLatestAnswer = null;
ArrayList<Point> mPoints;
......@@ -115,7 +124,8 @@ public class GameActivity extends BaseActivity
RxBus _rxBus = null;
CompositeDisposable mDisposables;
ScreenSlidePagerAdapter mPagerAdapter;
// Et ainult iga teine asukoha muutus salvestataks
boolean isNeedToCheckIn = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -126,9 +136,21 @@ public class GameActivity extends BaseActivity
mPresenter.onAttach(this);
mGame = getIntent().getParcelableExtra(GAME_KEY);
mUser = getIntent().getParcelableExtra(USER_KEY);
mPresenter.onViewInitialized(new GamesRequest.PointsRequest(mGame.getId()));
mUserGame = getIntent().getParcelableExtra(USER_GAME_KEY);
if(mPresenter.getCurrentPoint() >= 0){
mCurrentPoint = mPresenter.getCurrentPoint();
FragmentManager fm = getSupportFragmentManager();
InfoDialogFragment infoDialogFragment = InfoDialogFragment.newInstance("Welcome back!");
infoDialogFragment.show(fm, "info_fragment");
} else {
mPresenter.saveCurrentPoint(mCurrentPoint);
}
mPresenter.onViewInitialized(new GamesRequest.PointsRequest(mGame.getId()));
updateValuesFromBundle(savedInstanceState);
buildGoogleApiClient();
......@@ -145,6 +167,11 @@ public class GameActivity extends BaseActivity
return _rxBus;
}
public void onGameFinished(){
mPresenter.gameEnded(Integer.toString(mUserGame.getUserGameId()));
}
/**
* Updates fields based on data stored in the bundle.
*
......@@ -359,18 +386,35 @@ public class GameActivity extends BaseActivity
@Override
public void accept(@io.reactivex.annotations.NonNull Object o) throws Exception {
if (o instanceof Answer) {
((Answer) o).setUser_game_id(mGame.getUserGameId());
if(((Answer) o).is_correct())
mCurrentPoint++;
mLatestAnswer = (Answer) o;
mPresenter.postAnswer((Answer) o);
} else if(o instanceof Message){
postAnswer((Answer) o);
} else if (o instanceof Message) {
mPresenter.postMessage((Message) o);
} else if(o instanceof CheckInResponse){
Answer a = ((CheckInResponse) o).getAnswer();
if(a != null) {
if (a.getId() == mLatestAnswer.getId() && a.is_correct()) {
mCurrentPoint++;
mPresenter.saveCurrentPoint(mCurrentPoint);
} else {
}
}
}
}
}));
}
public void postAnswer(Answer answer){
answer.setUser_game_id(mGame.getUserGameId());
if (answer.is_correct()){
mCurrentPoint++;
mPresenter.saveCurrentPoint(mCurrentPoint);
}
mLatestAnswer = answer;
mPresenter.postAnswer(answer);
}
@Override
protected void onNewIntent(Intent intent) {
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
......@@ -476,10 +520,24 @@ public class GameActivity extends BaseActivity
public void onLocationChanged(Location location) {
mCurrentLocation = location;
mLastUpdateTime = DateFormat.getTimeInstance().format(new Date());
if(mLatestAnswer != null && mLatestAnswer.getId() > 0 && mPoints != null && mPoints.get(mCurrentPoint) != null)
mPresenter.postCheckIn(new CheckIn(mGame.getUserGameId(), location.getLatitude(), location.getLongitude(), mPoints.get(mCurrentPoint).getId(),mLatestAnswer.getId()));
else
mPresenter.postCheckIn(new CheckIn(mGame.getUserGameId(), location.getLatitude(), location.getLongitude(), mPoints.get(mCurrentPoint).getId()));
if(mPoints.size() >= mCurrentPoint)
Logger.wtf("might happen with debugging, if not then bug");
if (mLatestAnswer != null && mLatestAnswer.getId() > 0 && mPoints != null && mPoints.get(mCurrentPoint) != null) {
if (isNeedToCheckIn && location.getAccuracy() < 8) {
mPresenter.postCheckIn(new CheckIn(mGame.getUserGameId(), location.getLatitude(), location.getLongitude(), mPoints.get(mCurrentPoint).getId(), mLatestAnswer.getId()));
isNeedToCheckIn = false;
}else {
isNeedToCheckIn = true;
}
} else {
if (isNeedToCheckIn && location.getAccuracy() < 8) {
mPresenter.postCheckIn(new CheckIn(mGame.getUserGameId(), location.getLatitude(), location.getLongitude(), mPoints.get(mCurrentPoint).getId()));
isNeedToCheckIn = false;
}else{
isNeedToCheckIn = true;
}
}
updateLocationUI();
}
......@@ -540,7 +598,7 @@ public class GameActivity extends BaseActivity
Collections.sort(mPoints, new Comparator<Point>() {
@Override
public int compare(Point p1, Point p2) {
return p1.getOrder()-p2.getOrder();
return p1.getOrder() - p2.getOrder();
}
});
......@@ -551,12 +609,25 @@ public class GameActivity extends BaseActivity
setUpTabLayout();
hideLoading();
mPresenter.getBounds(Integer.toString(mGame.getId()));
}
@Override
public void loadBounds(BoundResponse boundResponse) {
if (_rxBus.hasObservers())
_rxBus.send(boundResponse);
}
@Override
public void checkInResponse(CheckInResponse checkInResponse) {
if(_rxBus.hasObservers())
_rxBus.send(checkInResponse);
if(checkInResponse.getIsOver() == 1){
gameEnded();
} else {
if (_rxBus.hasObservers())
_rxBus.send(checkInResponse);
}
}
@Override
......@@ -565,8 +636,22 @@ public class GameActivity extends BaseActivity
}
@Override
public void answerPosted(String id) {
mLatestAnswer.setId(Integer.parseInt(id));
public void answerPosted(AnswerResponse id) {
mLatestAnswer.setId(Integer.parseInt(id.getId()));
if(_rxBus.hasObservers())
_rxBus.send(id);
}
@Override
public void gameEnded() {
// delete game from preferences
mPresenter.deleteGameFromMemory();
mUserGame.setEnd(new Date());
Intent intent = new Intent(GameActivity.this, HistoryActivity.class);
intent.putExtra(USER_GAME_KEY, mUserGame);
intent.putExtra(USER_KEY, mUser);
startActivity(intent);
finish();
}
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
......@@ -584,10 +669,10 @@ public class GameActivity extends BaseActivity
public Fragment getItem(int position) {
Fragment fragment;
if (position == 0) {
fragment = GameFragment.newInstance(mGame, mPoints);
fragment = GameFragment.newInstance(mGame, mPoints, mCurrentPoint);
} else if (position == 1) {
fragment = MapFragment.newInstance(mGame, mPoints);
} else{
} else {
fragment = NotificationFragment.newInstance(mGame, mPoints, mUser);
}
......
......@@ -6,6 +6,9 @@ import javax.inject.Inject;
import ee.ttu.thesis.data.DataManager;
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.CheckInResponse;
import ee.ttu.thesis.data.model.GamesRequest;
......@@ -105,6 +108,7 @@ public class GamePresenter<V extends GameView> extends BasePresenter<V> implemen
}));
}
@Override
public void postAnswer(Answer answer) {
getmThesisView().showLoading();
......@@ -120,8 +124,65 @@ public class GamePresenter<V extends GameView> extends BasePresenter<V> implemen
if (!isViewAttached()) {
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>() {
@Override
......@@ -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
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;
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.Point;
import ee.ttu.thesis.ui.base.TreasureHuntView;
......@@ -14,9 +17,14 @@ public interface GameView extends TreasureHuntView {
void loadPoints(List<Point> response);
void loadBounds(BoundResponse boundResponse);
void checkInResponse(CheckInResponse checkInResponse);
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;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.location.Location;
......@@ -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.MapStyleOptions;
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 java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import butterknife.ButterKnife;
import ee.ttu.thesis.R;
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.Point;
import ee.ttu.thesis.data.model.PointType;
......@@ -48,7 +54,8 @@ import static ee.ttu.thesis.ui.game.GameActivity.POINT_KEY;
* 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;
......@@ -105,12 +112,38 @@ public class MapFragment extends Fragment implements OnMapReadyCallback {
mCurrentPoint++;
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
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
......@@ -218,4 +251,9 @@ public class MapFragment extends Fragment implements OnMapReadyCallback {
if(!isCameraAboveUser && mMap != null)
getDeviceLocation();
}
@Override
public void onPolygonClick(Polygon polygon) {
}
}
......@@ -80,7 +80,8 @@ public class DialogFragmentSolveQuestion extends DialogFragment {
Answer answer = new Answer(mPoint.getId(), mPoint.getProblemType(), correctSolution, correctId == mRadioGroup.getCheckedRadioButtonId());
if ( _rxBus.hasObservers() )
_rxBus.send(answer);
if(!answer.is_correct())
((SolveFragment)getParentFragment()).onWrongAnswer(answer);
dismiss();
}
......
package ee.ttu.thesis.ui.game.point;
import android.content.Context;
import android.location.Location;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Vibrator;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
......@@ -31,6 +30,7 @@ import ee.ttu.thesis.data.model.Point;
import ee.ttu.thesis.data.model.PointType;
import ee.ttu.thesis.data.model.ProblemType;
import ee.ttu.thesis.ui.game.GameActivity;
import ee.ttu.thesis.ui.game.InfoDialogFragment;
import ee.ttu.thesis.utils.RxBus;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
......@@ -56,8 +56,8 @@ public class GameFragment extends Fragment {
TextView mOrder;
@BindView(R.id.fragment_solve_point_description)
TextView mDescription;
TextView mDistance;
CompassView mCompassView;
LinearLayout mDistance;
LinearLayout mCompassView;
@BindView(R.id.fragment_compass_hint_root)
LinearLayout mHintRoot;
@BindView(R.id.fragment_compass_compass_root)
......@@ -78,10 +78,11 @@ public class GameFragment extends Fragment {
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();
args.putParcelable(GAME_KEY, game);
args.putParcelableArrayList(POINT_KEY, points);
args.putInt("currentpoint", mCurrentPoint);
GameFragment fragment = new GameFragment();
fragment.setArguments(args);
return fragment;
......@@ -93,6 +94,7 @@ public class GameFragment extends Fragment {
View v = inflater.inflate(R.layout.fragment_game, container, false);
ButterKnife.bind(this, v);
mGame = getArguments().getParcelable(GAME_KEY);
mCurrentPoint = getArguments().getInt("currentpoint");
mPoints = getArguments().getParcelableArrayList(POINT_KEY);
return v;
}
......@@ -195,10 +197,13 @@ public class GameFragment extends Fragment {
if (degrees < 0) {
degrees += 360;
}
if (mDistance != null)
mDistance.setText("" + distanceInMeters + " meters away from the point ");
if (mDistance != null) {
((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)
mCompassView.updateUI(degrees, distanceInMeters);
((CompassView) mCompassView.findViewById(R.id.compassView)).updateUI(degrees, distanceInMeters);
}
}
......@@ -211,7 +216,7 @@ public class GameFragment extends Fragment {
mHintRoot.removeAllViews();
mHintView = null;
} else {
if ( mHintView == null) {
if (mHintView == null) {
mHintView = (TextView) getActivity().getLayoutInflater().inflate(R.layout.layout_hint, null);
mHintRoot.addView(mHintView);
}
......@@ -222,8 +227,8 @@ public class GameFragment extends Fragment {
mCompassRoot.removeAllViews();
mCompassView = null;
} else {
if ( mCompassView == null) {
mCompassView = (CompassView) getActivity().getLayoutInflater().inflate(R.layout.layout_compass, null);
if (mCompassView == null) {
mCompassView = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.layout_compass, null);
mCompassRoot.addView(mCompassView);
}
}
......@@ -232,8 +237,8 @@ public class GameFragment extends Fragment {
mDistanceRoot.removeAllViews();
mDistance = null;
} else {
if ( mDistance == null) {
mDistance = (TextView) getActivity().getLayoutInflater().inflate(R.layout.layout_distance, null);
if (mDistance == null) {
mDistance = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.layout_distance, null);
mDistanceRoot.addView(mDistance);
}
}
......@@ -254,11 +259,15 @@ public class GameFragment extends Fragment {
e.printStackTrace();
}
if (mPoints.size() - 1 <= mCurrentPoint) {
// TODO WON GAME
Toast.makeText(getActivity(), "Game won!", Toast.LENGTH_SHORT).show();
((GameActivity) getActivity()).onGameFinished();
} else {
mCurrentPoint++;
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;
import android.graphics.PorterDuff;
import android.location.Location;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.view.View;
import com.google.android.gms.maps.model.LatLng;
import com.orhanobut.logger.Logger;
import butterknife.OnClick;
......@@ -56,7 +58,21 @@ public class GameLocationFragment extends SolveFragment {
@Override
public void accept(@NonNull Object o) throws Exception {
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 {
mIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_create_black_24dp));
mIcon.setBackground(getActivity().getResources().getDrawable(R.drawable.circle_login_icons));
mInstructions.setText(mPoint.getProblemDescription());
mIcon.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.DST_OUT);
mIcon.setElevation(DeviceDimensionsHelper.convertDpToPixel(4, getActivity()));
mIcon.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mIcon.setElevation(DeviceDimensionsHelper.convertDpToPixel(4, getActivity()));
}
mIcon.setOnClickListener(new View.OnClickListener() {
@Override
......
......@@ -5,12 +5,26 @@ import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.provider.MediaStore;
import android.util.Base64;
import android.view.View;
import android.widget.Toast;
import com.orhanobut.logger.Logger;
import java.io.ByteArrayOutputStream;
import butterknife.OnClick;
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.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 ee.ttu.thesis.ui.game.GameActivity.POINT_KEY;
......@@ -23,6 +37,9 @@ public class GamePhotoFragment extends SolveFragment {
static final int REQUEST_IMAGE_CAPTURE = 1;
Answer answer;
CompositeDisposable mDisposables;
public static GamePhotoFragment newInstance(Point point) {
Bundle args = new Bundle();
......@@ -41,18 +58,23 @@ public class GamePhotoFragment extends SolveFragment {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent 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();
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// mOnPointCompletedListener.onPointCompleted();
}
}, 4000);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] imageBytes = baos.toByteArray();
String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
answer = new Answer();
answer.setPoint_id(mPoint.getId());
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 {
mIcon.setVisibility(View.INVISIBLE);
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() {
......@@ -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 {
Answer answer = new Answer(mPoint.getId(), mPoint.getProblemType(), data, Answer.isAnswerCorrect(mPoint, data));
if (_rxBus.hasObservers())
_rxBus.send(answer);
if(!answer.is_correct())
((SolveFragment)getParentFragment()).onWrongAnswer(answer);
}
dismiss();
......
......@@ -2,10 +2,10 @@ package ee.ttu.thesis.ui.game.point;
import android.content.Context;
import android.graphics.PorterDuff;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Vibrator;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
......@@ -19,16 +19,13 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ee.ttu.thesis.R;
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.ProblemType;
import ee.ttu.thesis.data.model.Solution;
import ee.ttu.thesis.ui.game.GameActivity;
import ee.ttu.thesis.utils.DeviceDimensionsHelper;
import ee.ttu.thesis.utils.RxBus;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.functions.Consumer;
import static ee.ttu.thesis.ui.game.GameActivity.POINT_KEY;
......@@ -68,7 +65,9 @@ public class SolveFragment extends Fragment implements onAnswerGivenListener {
case (ProblemType.QR):
mIcon.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.ic_qrcode_scan));
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);
mInstructions.setText(getResources().getString(R.string.solve_qr));
......@@ -88,8 +87,10 @@ public class SolveFragment extends Fragment implements onAnswerGivenListener {
case (ProblemType.CAMERA):
mIcon.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.ic_photo_camera_black_24dp));
mIcon.setBackground(getActivity().getResources().getDrawable(R.drawable.circle_login_icons));
mIcon.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.DST_OUT);
mIcon.setElevation(DeviceDimensionsHelper.convertDpToPixel(6, getActivity()));
mIcon.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mIcon.setElevation(DeviceDimensionsHelper.convertDpToPixel(6, getActivity()));
}
mInstructions.setText(getResources().getString(R.string.solve_photo));
break;
......@@ -109,17 +110,17 @@ public class SolveFragment extends Fragment implements onAnswerGivenListener {
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 CheckInResponse) {
if (isUserWaitingForAnswer && ((CheckInResponse) o).getAnswer().getProblem_type().getTitle().equals(ProblemType.CAMERA))
onWrongAnswer(((CheckInResponse) o).getAnswer());
}
}
}));
// mDisposables.add(_rxBus.asFlowable()
// .subscribeOn(AndroidSchedulers.mainThread())
// .subscribe(new Consumer<Object>() {
// @Override
// public void accept(@NonNull Object o) throws Exception {
// if (o instanceof CheckInResponse) {
// if (isUserWaitingForAnswer && ((CheckInResponse) o).getAnswer().getProblem_type().getTitle().equals(ProblemType.CAMERA))
// onWrongAnswer(((CheckInResponse) o).getAnswer());
// }
// }
// }));
}
@Override
......@@ -137,14 +138,14 @@ public class SolveFragment extends Fragment implements onAnswerGivenListener {
}
}
}
onWrongAnswer(answer);
if(!answer.getProblem_type().getTitle().equals(ProblemType.CAMERA))
onWrongAnswer(answer);
}
private void onWrongAnswer(Answer answer) {
public void onWrongAnswer(Answer answer) {
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);
v.vibrate(500);
......
......@@ -11,6 +11,7 @@ import java.util.List;
import ee.ttu.thesis.R;
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.ViewHolderGamesGame;
......@@ -22,12 +23,13 @@ public class GamesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
private List<Object> mObjects;
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) {
public GamesAdapter(List<Object> mObjects, Context mContext, int currentPoint) {
this.mObjects = mObjects;
this.mContext = mContext;
this.mCurrentPoint = currentPoint;
}
public Context getContext() {
......@@ -48,6 +50,10 @@ public class GamesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
View game_view = inflater.inflate(R.layout.item_game, parent, false);
viewHolder = new ViewHolderGamesGame(game_view);
break;
case BUTTON:
View button_view = inflater.inflate(R.layout.item_game_button, parent, false);
viewHolder = new ViewHolderGamesButtons(button_view);
break;
default:
View default_view = inflater.inflate(R.layout.item_game_category, parent, false);
viewHolder = new ViewHolderGamesCategory(default_view);
......@@ -67,15 +73,28 @@ public class GamesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
ViewHolderGamesGame viewHolderGamesGame = (ViewHolderGamesGame) holder;
configureGameViewHolder(viewHolderGamesGame , position);
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) {
Game game = (Game)mObjects.get(position);
viewHolderGamesGame.getGameNameTV().setText(game.getTitle());
viewHolderGamesGame.getGameLocationTV().setText("@"+game.getLocationName());
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));
}else{
SimpleDateFormat dateFormatter = new SimpleDateFormat("E, d-M-y");
......@@ -93,7 +112,9 @@ public class GamesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
@Override
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;
else
return GAME;
......
......@@ -2,6 +2,7 @@ package ee.ttu.thesis.ui.list;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v4.app.FragmentManager;
......@@ -10,6 +11,14 @@ import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;
import com.facebook.login.LoginManager;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.plus.Plus;
import com.orhanobut.logger.Logger;
import java.util.ArrayList;
......@@ -22,25 +31,28 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ee.ttu.thesis.R;
import ee.ttu.thesis.data.model.Game;
import ee.ttu.thesis.data.model.GamesRequest;
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.future.FutureGameActivity;
import ee.ttu.thesis.ui.game.GameActivity;
import ee.ttu.thesis.ui.login.LoginActivity;
import ee.ttu.thesis.ui.past.HistoryActivity;
import ee.ttu.thesis.ui.start.StartActivity;
import ee.ttu.thesis.data.model.Game;
import ee.ttu.thesis.data.model.GamesRequest;
import ee.ttu.thesis.data.model.UserGame;
import ee.ttu.thesis.utils.DividerDecoration;
import ee.ttu.thesis.utils.ItemClickSupport;
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 22.03.17.
*/
public class ListActivity extends BaseActivity implements AddGameDialogFragment.OnGameAddListener, ListView {
public class ListActivity extends BaseActivity implements AddGameDialogFragment.OnGameAddListener, ListView, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
@Inject
ListTreasureHuntPresenter<ListView> mPresenter;
......@@ -53,6 +65,8 @@ public class ListActivity extends BaseActivity implements AddGameDialogFragment.
List<UserGame> mUserGames = new ArrayList<>();
GoogleApiClient mGoogleApiClient;
User mUser;
@Override
......@@ -60,13 +74,28 @@ public class ListActivity extends BaseActivity implements AddGameDialogFragment.
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestId()
.requestIdToken(getString(R.string.server_client_id))
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
mUser = getIntent().getParcelableExtra(USER_KEY);
getActivityComponent().inject(this);
ButterKnife.bind(this);
mPresenter.onAttach(this);
mPresenter.onViewInitialized(new GamesRequest.UserGamesRequest(1));
mUser = getIntent().getParcelableExtra(USER_KEY);
mAdapter = new GamesAdapter(mObjects, this);
mPresenter.onViewInitialized(new GamesRequest.UserGamesRequest(mUser.getId()));
mObjects.add("logout");
mAdapter = new GamesAdapter(mObjects, this, mPresenter.getCurrentPoint());
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
......@@ -78,24 +107,79 @@ public class ListActivity extends BaseActivity implements AddGameDialogFragment.
new ItemClickSupport.OnItemClickListener() {
@Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
if (mObjects.get(position) instanceof Game) {
if (mObjects.size() - 1 == position) {
if (mPresenter.getService().equals("fb")) {
LoginManager.getInstance().logOut();
mPresenter.logOut();
Intent intent = new Intent(ListActivity.this, LoginActivity.class);
startActivity(intent);
finish();
} else {
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
mGoogleApiClient.disconnect();
mPresenter.logOut();
Intent intent = new Intent(ListActivity.this, LoginActivity.class);
startActivity(intent);
finish();
}
});
}
}
} else if (mObjects.get(position) instanceof Game) {
Game game = (Game) mObjects.get(position);
Date now = new Date();
Date start = game.getStartTime();
Date end = game.getEndTime();
if (start.before(now) && end.after(now)) {
Intent intent = new Intent(ListActivity.this, StartActivity.class);
Intent intent;
if(mPresenter.getCurrentPoint() >= 0)
intent = new Intent(ListActivity.this, GameActivity.class);
else
intent = new Intent(ListActivity.this, StartActivity.class);
intent.putExtra(GAME_KEY, ((Game) mObjects.get(position)));
UserGame userGame = null;
for (UserGame g : mUserGames) {
if (((Game) mObjects.get(position)).getId() == g.getGame().getId()) {
userGame = g;
break;
}
}
intent.putExtra(USER_GAME_KEY, userGame);
intent.putExtra(USER_KEY, mUser);
startActivity(intent);
finish();
} else if (start.after(now)) {
Intent intent = new Intent(ListActivity.this, FutureGameActivity.class);
intent.putExtra(GAME_KEY, ((Game) mObjects.get(position)));
UserGame userGame = null;
for (UserGame g : mUserGames) {
if (((Game) mObjects.get(position)).getId() == g.getGame().getId()) {
userGame = g;
break;
}
}
intent.putExtra(USER_GAME_KEY, userGame);
intent.putExtra(USER_KEY, mUser);
startActivity(intent);
} else {
Intent intent = new Intent(ListActivity.this, HistoryActivity.class);
intent.putExtra(GAME_KEY, ((Game) mObjects.get(position)));
UserGame userGame = null;
for (UserGame g : mUserGames) {
if (((Game) mObjects.get(position)).getId() == g.getGame().getId()) {
userGame = g;
break;
}
}
intent.putExtra(USER_GAME_KEY, userGame);
intent.putExtra(USER_KEY, mUser);
startActivity(intent);
}
......@@ -116,7 +200,7 @@ public class ListActivity extends BaseActivity implements AddGameDialogFragment.
@Override
public void onFinishEditDialog(String gameName) {
Toast.makeText(this, gameName, Toast.LENGTH_SHORT).show();
mPresenter.onAddGame(new GamesRequest.AddGameRequest(1, gameName));
mPresenter.onAddGame(new GamesRequest.AddGameRequest(mUser.getId(), gameName));
}
@Override
......@@ -176,11 +260,11 @@ public class ListActivity extends BaseActivity implements AddGameDialogFragment.
mObjects.add(past, g);
}
}
if(_bpast)
if (_bpast)
mObjects.add(past, "Past");
if(_bupcoming)
if (_bupcoming)
mObjects.add(upcoming, "Upcoming");
if(_bcurrent)
if (_bcurrent)
mObjects.add(0, "Current");
mAdapter.notifyDataSetChanged();
......@@ -237,4 +321,34 @@ public class ListActivity extends BaseActivity implements AddGameDialogFragment.
}
mAdapter.notifyDataSetChanged();
}
@Override
public void onConnected(@Nullable Bundle bundle) {
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Override
protected void onStop() {
super.onStop();
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
}
......@@ -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
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
package ee.ttu.thesis.ui.login;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
......@@ -14,6 +15,14 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.facebook.AccessToken;
import com.facebook.AccessTokenTracker;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
......@@ -22,7 +31,9 @@ import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.OptionalPendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.orhanobut.logger.Logger;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
......@@ -35,6 +46,7 @@ import ee.ttu.thesis.R;
import ee.ttu.thesis.data.model.GamesRequest;
import ee.ttu.thesis.data.model.User;
import ee.ttu.thesis.ui.base.BaseActivity;
import ee.ttu.thesis.ui.game.GameActivity;
import ee.ttu.thesis.ui.list.ListActivity;
import ee.ttu.thesis.data.model.Game;
import ee.ttu.thesis.data.model.UserGame;
......@@ -43,6 +55,7 @@ import ee.ttu.thesis.utils.CommonUtils;
import ee.ttu.thesis.utils.DeviceDimensionsHelper;
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;
public class LoginActivity extends BaseActivity implements GoogleApiClient.OnConnectionFailedListener, LoginView {
......@@ -58,11 +71,14 @@ public class LoginActivity extends BaseActivity implements GoogleApiClient.OnCon
String userName = "";
Game mGame;
UserGame mUserGame;
User mUser;
boolean isGameReady = false;
@BindView(R.id.signInButton_activity_login_google)
View mGoogleSignInButton;
@BindView(R.id.signInButton_activity_login_facebook)
View mFacebookSignIn;
@BindView(R.id.activity_login_game_code_editText)
EditText mGameCodeET;
@BindView(R.id.activity_login_user_name_editText)
......@@ -80,6 +96,16 @@ public class LoginActivity extends BaseActivity implements GoogleApiClient.OnCon
@BindView(R.id.activity_login_gameInfo)
TextView mInfo;
AccessToken accessToken;
CallbackManager callbackManager;
// saada user_id ja game_id
// Saad vastu user_game_id ja game'i, sealt toimetad edasi nagu tavaliselt
//
// Erinevus
//-Listview current
// - mäng on alustatud
// - mängu pole alustatud
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -89,6 +115,52 @@ public class LoginActivity extends BaseActivity implements GoogleApiClient.OnCon
ButterKnife.bind(this);
mPresenter.onAttach(this);
// Kas vaja automaatselt liigutada kasutaja mangu
if(mPresenter.getService() == null){
if(mPresenter.getGameCode() != null){//Liigume automaatselt mangu
showLargeLoading();
mPresenter.getUserGame(mPresenter.getGameCode(), mPresenter.getUserId());
}
}
FacebookSdk.sdkInitialize(this.getApplicationContext());
callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
if(accessToken != null)
logIn("fb", accessToken.getToken());
}
@Override
public void onCancel() {
Logger.d("cancel");
}
@Override
public void onError(FacebookException error) {
Logger.d(error.toString());
}
});
final AccessTokenTracker accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(
AccessToken oldAccessToken,
AccessToken currentAccessToken) {
// Set the access token using
// currentAccessToken when it's loaded or set.
if(accessToken == null) {
accessToken = AccessToken.getCurrentAccessToken();
logIn("fb", accessToken.getToken());
}
accessToken = AccessToken.getCurrentAccessToken();
}
};
// If the access token is available already assign it.
accessToken = AccessToken.getCurrentAccessToken();
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestId()
......@@ -142,6 +214,16 @@ public class LoginActivity extends BaseActivity implements GoogleApiClient.OnCon
}
});
if(mPresenter.getService() != null && mPresenter.getService().equals("fb")){
mFacebookSignIn.callOnClick();
}
}
@OnClick(R.id.signInButton_activity_login_facebook)
public void onFaceBookSignIn(View v){
LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("email", "public_profile"));
}
@OnClick(R.id.activity_login_enter_button)
......@@ -193,22 +275,20 @@ public class LoginActivity extends BaseActivity implements GoogleApiClient.OnCon
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
}
callbackManager.onActivityResult(requestCode, resultCode, data);
}
private void handleSignInResult(GoogleSignInResult result) {
Log.d("LoginActivity", "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
// Signed in successfully, show authenticated UI.
GoogleSignInAccount acct = result.getSignInAccount();
String idToken = acct.getIdToken();
// TODO(user): send token to server and validate server-side
goToGame(true);
logIn("google", idToken);
} else {
// Signed out, show unauthenticated UI.
// goToGame(false, null;
......@@ -216,9 +296,8 @@ public class LoginActivity extends BaseActivity implements GoogleApiClient.OnCon
}
private void goToGame(boolean isRegisterdUser){
mPresenter.saveUser(mUser);
if(isRegisterdUser){
mUser = new User();
mUser.setId(1);
Intent intent = new Intent(this, ListActivity.class);
intent.putExtra(USER_KEY, mUser);
startActivity(intent);
......@@ -227,6 +306,7 @@ public class LoginActivity extends BaseActivity implements GoogleApiClient.OnCon
Intent intent = new Intent(this, StartActivity.class);
intent.putExtra(GAME_KEY, mGame);
intent.putExtra(USER_KEY, mUser);
intent.putExtra(USER_GAME_KEY, mUserGame);
startActivity(intent);
finish();
}
......@@ -240,16 +320,28 @@ public class LoginActivity extends BaseActivity implements GoogleApiClient.OnCon
mGameTitle.setVisibility(View.INVISIBLE);
}
private void logIn(String service, String access_token){
Logger.d("accesstoken log in: " +access_token);
mUser = new User();
mUser.setService(service);
mPresenter.saveService(service);
mPresenter.logIn(service, access_token);
}
private void elevateEnter(boolean elevate) {
isGameReady = elevate;
if (elevate) {
mEnterButton.setBackground(getResources().getDrawable(R.drawable.login_rounded_rectangle_filled));
mEnterButton.setTextColor(getResources().getColor(R.color.white));
mEnterButton.setElevation(DeviceDimensionsHelper.convertDpToPixel(6, LoginActivity.this));
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
mEnterButton.setElevation(DeviceDimensionsHelper.convertDpToPixel(6, LoginActivity.this));
}
} else {
mEnterButton.setBackground(getResources().getDrawable(R.drawable.rounded_rectangle));
mEnterButton.setTextColor(getResources().getColor(R.color.colorPrimaryLight));
mEnterButton.setElevation(DeviceDimensionsHelper.convertDpToPixel(0, LoginActivity.this));
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
mEnterButton.setElevation(DeviceDimensionsHelper.convertDpToPixel(0, LoginActivity.this));
}
}
}
......@@ -283,11 +375,6 @@ public class LoginActivity extends BaseActivity implements GoogleApiClient.OnCon
}
@Override
public void hideKeyboard() {
}
@Override
public void loadGame(List<Game> games) {
if (games == null || games.size() < 1) {
mJoinTheAdventure.setVisibility(View.VISIBLE);
......@@ -327,14 +414,23 @@ public class LoginActivity extends BaseActivity implements GoogleApiClient.OnCon
@Override
public void userAdded(User user) {
mUser = user;
mPresenter.saveUser(user);
mPresenter.addUserToAGame(new GamesRequest.AddGameRequest(user.getId(), gameCode));
}
@Override
public void loggedIn(String userId) {
if(mUser == null)
mUser = new User();
mUser.setId(Integer.parseInt(userId));
goToGame(true);
}
@Override
public void showLargeLoading() {
super.hideKeyboard();
super.showLoading();
if(!isFinishing()) {
super.hideKeyboard();
super.showLoading();
}
}
@Override
......@@ -345,8 +441,28 @@ public class LoginActivity extends BaseActivity implements GoogleApiClient.OnCon
@Override
public void gameAdded(UserGame userGame) {
mGame = userGame.getGame();
mUserGame = userGame;
mGame.setUserGameId(userGame.getUserGameId());
goToGame(false);
}
// Automaatselt mangu
@Override
public void loadUserGame(UserGame userGame) {
mGame = userGame.getGame();
mGame.setUserGameId(userGame.getUserGameId());
mUserGame = userGame;
if(mUser == null){
mUser = new User();
mUser.setId(Integer.parseInt(mPresenter.getUserId()));
}
Intent intent = new Intent(this, GameActivity.class);
intent.putExtra(GAME_KEY, mGame);
intent.putExtra(USER_KEY, mUser);
intent.putExtra(USER_GAME_KEY, mUserGame);
startActivity(intent);
finish();
}
}
......@@ -113,4 +113,74 @@ public class LoginPresenter<V extends LoginView> extends BasePresenter<V> implem
public void saveUser(User user) {
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
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 {
void userAdded(User user);
void loggedIn(String userId);
void showLargeLoading();
void hideLargeLoading();
void gameAdded(UserGame userGame);
void loadUserGame(UserGame userGame);
}
package ee.ttu.thesis.ui.past;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
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.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
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.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.android.gms.maps.model.RoundCap;
import com.orhanobut.logger.Logger;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
......@@ -24,11 +29,13 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ee.ttu.thesis.R;
import ee.ttu.thesis.data.model.CheckIn;
import ee.ttu.thesis.data.model.Game;
import ee.ttu.thesis.data.model.User;
import ee.ttu.thesis.data.model.UserGame;
import ee.ttu.thesis.ui.base.BaseActivity;
import ee.ttu.thesis.ui.game.map.WorkAroundMapFragment;
import ee.ttu.thesis.ui.start.StartTreasureHuntPresenter;
import ee.ttu.thesis.ui.start.StartView;
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.
......@@ -37,27 +44,51 @@ import ee.ttu.thesis.ui.start.StartView;
public class HistoryActivity extends BaseActivity
implements OnMapReadyCallback,
GoogleMap.OnPolylineClickListener,
HistoryView{
HistoryView {
GoogleMap mMap;
@Inject
HistoryTreasureHuntPresenter<HistoryView> mPresenter;
Game mGame;
UserGame mGame;
User mUser;
@BindView(R.id.activity_history_scrollview)
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
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivityComponent().inject(this);
setContentView(R.layout.activity_history);
mPresenter.onAttach(this);
ButterKnife.bind(this);
mGame = getIntent().getParcelableExtra(USER_GAME_KEY);
mUser = getIntent().getParcelableExtra(USER_KEY);
WorkAroundMapFragment mapFragment = (WorkAroundMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
mPresenter.getStats(Integer.toString(mUser.getId()), Integer.toString(mGame.getGame().getId()));
}
@Override
......@@ -80,25 +111,6 @@ public class HistoryActivity extends BaseActivity
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
......@@ -107,16 +119,6 @@ public class HistoryActivity extends BaseActivity
}
@Override
public void showLoading() {
}
@Override
public void hideLoading() {
}
@Override
public void openActivityOnTokenExpire() {
}
......@@ -128,7 +130,7 @@ public class HistoryActivity extends BaseActivity
@Override
public void onError(String message) {
Toast.makeText(this, message, Toast.LENGTH_LONG ).show();
}
@Override
......@@ -143,6 +145,76 @@ public class HistoryActivity extends BaseActivity
@Override
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;
import android.view.View;
import android.widget.Toast;
import java.util.Date;
import javax.inject.Inject;
import butterknife.BindView;
......@@ -20,11 +22,13 @@ import butterknife.ButterKnife;
import butterknife.OnClick;
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.game.GameActivity;
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.USER_GAME_KEY;
import static ee.ttu.thesis.ui.game.GameActivity.USER_KEY;
/**
......@@ -36,6 +40,7 @@ public class StartActivity extends BaseActivity implements StartView {
StartTreasureHuntPresenter<StartView> mPresenter;
Game mGame;
UserGame mUserGame;
User mUser;
@BindView(R.id.activity_start_viewpager)
......@@ -55,6 +60,7 @@ public class StartActivity extends BaseActivity implements StartView {
mPresenter.onAttach(this);
mGame = getIntent().getParcelableExtra(GAME_KEY);
mUser = getIntent().getParcelableExtra(USER_KEY);
mUserGame = getIntent().getParcelableExtra(USER_GAME_KEY);
mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager(), this);
mPager.setAdapter(mPagerAdapter);
mTabLayout.setupWithViewPager(mPager, true);
......@@ -62,6 +68,7 @@ public class StartActivity extends BaseActivity implements StartView {
@OnClick(R.id.activity_start_button)
public void onStartClicked(View v){
mUserGame.setStart(new Date());
mPresenter.startGame(Integer.toString(mGame.getUserGameId()));
}
......@@ -92,12 +99,13 @@ public class StartActivity extends BaseActivity implements StartView {
@Override
public void gameStarted() {
mPresenter.saveUserAndGame(mUser.getId(), mGame.getGameCode());
Intent intent = new Intent(StartActivity.this, GameActivity.class);
intent.putExtra(GAME_KEY, mGame);
intent.putExtra(USER_GAME_KEY, mUserGame);
intent.putExtra(USER_KEY, mUser);
startActivity(intent);
finish();
}
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
......@@ -122,7 +130,6 @@ public class StartActivity extends BaseActivity implements StartView {
fragment = new TutorialThreeFragment();
} else if (position == 3) {
fragment = new TutorialFourFragment();
} else{
fragment = new TutorialFiveFragment();
......
......@@ -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;
public interface StartTreasureHuntPresenter<V extends StartView> extends TreauseHuntPresenter<V> {
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"
android:shape="rectangle">
<gradient
android:startColor="@color/colorPrimary"
android:startColor="@color/colorPrimaryDark"
android:endColor="@android:color/transparent"
android:angle="90"
android:type="linear"
......
......@@ -3,12 +3,12 @@
android:id="@+id/activity_history_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary">
android:background="@color/colorPrimaryDark">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:background="@color/colorPrimaryDark"
android:orientation="vertical">
<RelativeLayout
......@@ -40,31 +40,31 @@
android:orientation="vertical"
android:padding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="32dp">
<TextView
android:id="@+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="16dp"
android:text="Rank:"
android:textColor="@color/colorSecondaryMain"
android:textSize="24sp" />
<TextView
android:id="@+id/textView17"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="2nd"
android:textAlignment="textStart"
android:textColor="@color/white"
android:textSize="24sp" />
</LinearLayout>
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:orientation="horizontal"-->
<!--android:paddingBottom="32dp">-->
<!--<TextView-->
<!--android:id="@+id/textView15"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:paddingRight="16dp"-->
<!--android:text="Rank:"-->
<!--android:textColor="@color/colorSecondaryMain"-->
<!--android:textSize="24sp" />-->
<!--<TextView-->
<!--android:id="@+id/activity_history_rank"-->
<!--android:layout_width="0px"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_weight="1"-->
<!--android:text="NULL"-->
<!--android:textAlignment="textStart"-->
<!--android:textColor="@color/white"-->
<!--android:textSize="24sp" />-->
<!--</LinearLayout>-->
<LinearLayout
android:layout_width="match_parent"
......@@ -86,7 +86,7 @@
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="12.4 km"
android:text="NULL"
android:textAlignment="textStart"
android:textColor="@color/white"
android:textSize="24sp" />
......@@ -108,11 +108,11 @@
android:textSize="24sp" />
<TextView
android:id="@+id/textView175"
android:id="@+id/activity_history_time_taken"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="147 minutes"
android:text="NULL"
android:textAlignment="textStart"
android:textColor="@color/white"
android:textSize="24sp" />
......@@ -138,7 +138,7 @@
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="12"
android:text="NULL"
android:textAlignment="textStart"
android:textColor="@color/white"
android:textSize="24sp" />
......@@ -164,7 +164,7 @@
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="6.27 km/h"
android:text="NULL"
android:textAlignment="textStart"
android:textColor="@color/white"
android:textSize="24sp" />
......@@ -190,7 +190,7 @@
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="12 min/point"
android:text="NULL"
android:textAlignment="textStart"
android:textColor="@color/white"
android:textSize="24sp" />
......@@ -216,7 +216,7 @@
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="DD/MM hh:mm"
android:text="NULL"
android:textAlignment="textStart"
android:textColor="@color/white"
android:textSize="24sp" />
......@@ -242,7 +242,7 @@
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="DD/MM hh:mm"
android:text="NULL"
android:textAlignment="textStart"
android:textColor="@color/white"
android:textSize="24sp" />
......
<?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"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
......@@ -7,21 +7,6 @@
android:background="@color/colorPrimaryDark"
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:id="@+id/activity_main_recyclerview"
android:layout_width="match_parent"
......@@ -42,6 +27,7 @@
app:layout_behavior="ee.ttu.thesis.utils.ScrollAwareFABBehavior"
app:layout_anchor="@id/activity_main_recyclerview"
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>
\ 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 @@
android:textSize="14sp" />
<LinearLayout
android:id="@+id/fragment_compass_hint_root"
android:id="@+id/fragment_compass_hint_rooreret"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
......@@ -71,7 +71,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/fragment_compass_compass_root"
android:id="@+id/fragment_compass_compass_rdsadsaoot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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"?>
<ee.ttu.thesis.ui.game.point.CompassView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/compassView"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="400dp"
android:padding="16dp" />
\ No newline at end of file
android:layout_height="wrap_content"
android:orientation="vertical">
<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"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_compass_distance"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_compass_distance_ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="32dp"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:paddingTop="24dp"
android:textAlignment="center"
android:textColor="@color/colorSecondaryMain"
android:textSize="24sp" />
android:orientation="vertical">
<TextView
android:id="@+id/fragment_compass_distance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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 @@
<color name="OrderSelectedTabTextColor">@color/colorAccent</color>
<color name="OrderUnSelectedTabTextColor">@color/colorPrimary</color>
<color name="mapBoundFillColor">#642d303c</color>
</resources>
......@@ -20,4 +20,8 @@
<string name="api_default_error">Something went wrong</string>
<string name="connection_error">Internet connection lost</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>
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