Skip to content

Commit 36cad1b

Browse files
author
Georgy Lebedik
authored
Cumulative update to align with v0.0.9 server capabilities (v2). (#21)
1 parent f8c38df commit 36cad1b

File tree

79 files changed

+3271
-1693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3271
-1693
lines changed

AndroidClient/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ dependencies {
104104

105105
implementation libs.core
106106

107+
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
108+
107109

108110
/*TESTS*/
109111

AndroidClient/src/main/AndroidManifest.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@
5858
</activity>
5959
<activity
6060
android:name=".context.profile.component.activity.ProfileActivity"
61-
android:label="@string/profile_activity_label"
62-
android:parentActivityName=".context.auth.activity.LoginActivity">
63-
<meta-data
64-
android:name="android.support.PARENT_ACTIVITY"
65-
android:value=".context.auth.activity.LoginActivity" />
61+
android:label="@string/profile_activity_label">
6662
</activity>
6763
<activity
6864
android:name=".context.auth.activity.RegistrationActivity"
@@ -98,6 +94,8 @@
9894
<activity android:name=".context.image.activity.UploadUserImageActivity" />
9995
<activity android:name=".context.image.activity.UploadEventImageActivity" />
10096
<activity android:name=".context.profile.component.activity.NewEventOnMapActivity" />
97+
<activity android:name=".context.event.activity.PublishEventActivity" />
98+
<activity android:name=".context.event.activity.ScheduleEventActivity" />
10199

102100
<meta-data
103101
android:name="com.google.android.gms.version"

AndroidClient/src/main/java/com/tom/meeter/context/auth/infrastructure/AuthHelper.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.accounts.AuthenticatorException;
1010
import android.accounts.OperationCanceledException;
1111
import android.app.Activity;
12+
import android.content.Context;
1213
import android.os.Bundle;
1314
import android.os.Handler;
1415
import android.os.Looper;
@@ -50,6 +51,11 @@ public static String getUserUuid(AccountManager am) {
5051
return am.getUserData(getSingleAccount(am), USER_UUID_KEY);
5152
}
5253

54+
public static String getUserUuid(Context ctx) {
55+
AccountManager am = AccountManager.get(ctx);
56+
return am.getUserData(getSingleAccount(am), USER_UUID_KEY);
57+
}
58+
5359
public static void setToken(AccountManager am, String token) {
5460
am.setAuthToken(getSingleAccount(am), AccountAuthenticator.AUTH_TYPE, token);
5561
}
@@ -68,7 +74,8 @@ public static Account getSingleAccount(AccountManager am) {
6874

6975
public static void checkToken(
7076
Consumer<String> onToken, Runnable onCancelledAuth,
71-
AccountManager am, Activity activity, TokenService tokenService) {
77+
Activity activity, TokenService tokenService) {
78+
AccountManager am = AccountManager.get(activity);
7279
Account account = getSingleAccount(am);
7380
String token = am.peekAuthToken(account, AUTH_TYPE);
7481
if (token != null) {

AndroidClient/src/main/java/com/tom/meeter/context/event/EventComponent.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import com.tom.meeter.context.event.activity.EventLocationMapActivity;
88
import com.tom.meeter.context.event.activity.EventOnMapActivity;
99
import com.tom.meeter.context.event.activity.ProfileEventActivity;
10+
import com.tom.meeter.context.event.activity.PublishEventActivity;
11+
import com.tom.meeter.context.event.activity.ScheduleEventActivity;
1012
import com.tom.meeter.context.event.activity.UserEventActivity;
1113

1214
import dagger.BindsInstance;
@@ -29,13 +31,18 @@ interface Builder {
2931
EventComponent build();
3032
}
3133

32-
void inject(EventDispatcherActivity eventDispatcherActivity);
34+
void inject(EventDispatcherActivity activity);
3335

34-
void inject(ProfileEventActivity profileEventActivity);
36+
void inject(ProfileEventActivity activity);
3537

36-
void inject(UserEventActivity userEventActivity);
38+
void inject(UserEventActivity activity);
3739

38-
void inject(EventOnMapActivity eventOnMapActivity);
40+
void inject(EventOnMapActivity activity);
41+
42+
void inject(EventLocationMapActivity activity);
43+
44+
void inject(PublishEventActivity activity);
45+
46+
void inject(ScheduleEventActivity activity);
3947

40-
void inject(EventLocationMapActivity eventLocationMapActivity);
4148
}

AndroidClient/src/main/java/com/tom/meeter/context/event/activity/EventDispatcherActivity.java

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import static com.tom.meeter.infrastructure.common.InfrastructureHelper.logMethod;
77

88
import android.accounts.AccountManager;
9+
import android.app.Activity;
910
import android.content.Context;
1011
import android.content.Intent;
1112
import android.os.Bundle;
@@ -30,41 +31,30 @@ public class EventDispatcherActivity extends AppCompatActivity {
3031
public static final String EVENT_ID_KEY = "event_id";
3132

3233
private static final String TAG = EventDispatcherActivity.class.getCanonicalName();
34+
3335
@Inject
3436
TokenService tokenService;
3537
@Inject
3638
EventService eventService;
37-
private AccountManager accountManager;
3839

3940
@Override
4041
protected void onCreate(Bundle savedInstanceState) {
4142
super.onCreate(savedInstanceState);
4243

4344
logMethod(TAG, this);
4445

45-
Bundle extras = getIntent().getExtras();
46-
if (extras == null) {
47-
Log.d(TAG, "Unable to create event activity without extras.");
48-
finish();
49-
return;
50-
}
51-
String eventId = extras.getString(EVENT_ID_KEY);
52-
if (eventId == null) {
53-
Log.d(TAG, "Unable to create event activity without 'event_id' provided.");
54-
finish();
46+
if (EventDispatcherActivity.isIncorrect(this)) {
5547
return;
5648
}
5749

5850
((App) getApplication()).getEventComponent().inject(this);
5951

60-
accountManager = AccountManager.get(this);
61-
6252
//setToken(accountManager, Launcher.EXPIRED);
63-
checkToken((token) -> onInit(token, eventId), this::finish,
64-
accountManager, this, tokenService);
53+
checkToken(this::onInit, this::finish, this, tokenService);
6554
}
6655

67-
private void onInit(String token, String eventId) {
56+
private void onInit(String token) {
57+
String eventId = getEventId(this);
6858
eventService.amICreator(Globals.getAuthHeader(token), eventId)
6959
.enqueue(new BaseOnNotAuthenticatedCallback<>(this, this::recreate) {
7060
@Override
@@ -81,6 +71,28 @@ public void onResponse(Call<Boolean> call, Response<Boolean> resp) {
8171
});
8272
}
8373

74+
public static boolean isIncorrect(Activity activity) {
75+
Bundle extras = activity.getIntent().getExtras();
76+
if (extras == null) {
77+
Log.e(TAG, "Unable to create ["
78+
+ activity.getClass().getCanonicalName()
79+
+ "] without extras.");
80+
activity.finish();
81+
return true;
82+
}
83+
if (extras.getString(EVENT_ID_KEY) == null) {
84+
Log.e(TAG, "Unable to create ["
85+
+ activity.getClass().getCanonicalName()
86+
+ "] without [" + EVENT_ID_KEY + "] provided.");
87+
activity.finish();
88+
return true;
89+
}
90+
return false;
91+
}
92+
93+
public static String getEventId(Activity activity) {
94+
return activity.getIntent().getExtras().getString(EVENT_ID_KEY);
95+
}
8496

8597
public static void dispatchToEventActivity(Context ctx, String eventId) {
8698
ctx.startActivity(createEventActivityIntent(ctx, eventId));

AndroidClient/src/main/java/com/tom/meeter/context/event/activity/EventLocationMapActivity.java

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package com.tom.meeter.context.event.activity;
22

3-
import static com.tom.meeter.context.auth.infrastructure.AuthHelper.getAuthHeader;
43
import static com.tom.meeter.context.profile.component.fragment.GoogleMapsFragment.ZOOM_VALUE;
54
import static com.tom.meeter.infrastructure.common.InfrastructureHelper.logMethod;
6-
import static com.tom.meeter.infrastructure.common.InfrastructureHelper.showMessage;
75

86
import android.accounts.AccountManager;
97
import android.content.ComponentName;
@@ -30,6 +28,7 @@
3028
import com.google.android.gms.maps.model.MarkerOptions;
3129
import com.tom.meeter.App;
3230
import com.tom.meeter.R;
31+
import com.tom.meeter.context.auth.infrastructure.AuthHelper;
3332
import com.tom.meeter.context.event.service.EventService;
3433
import com.tom.meeter.context.gps.domain.LocationTrackerListener;
3534
import com.tom.meeter.context.gps.service.LocationTrackerService;
@@ -52,40 +51,29 @@ public class EventLocationMapActivity extends AppCompatActivity
5251
public static final String EXTRA_LNG = "extra_lng";
5352

5453
private static final String TAG = EventLocationMapActivity.class.getCanonicalName();
55-
private Marker eventMarker;
56-
private GoogleMap gmap;
57-
private ActivityEventPositionBinding binding;
5854

59-
private ServiceConnection locationServiceConn;
60-
private LocationTrackerService locationService;
61-
private boolean cameraMoved = false;
55+
@Inject
56+
EventService service;
57+
@Inject
58+
ImageDownloader imgDownloader;
6259

60+
private ActivityEventPositionBinding binding;
61+
private LocationTrackerService locationService;
62+
private ServiceConnection sConn;
6363
private LocationTrackerListener singleLocationUpdateListener;
64-
private String eventId;
64+
private final Runnable onNotAuthenticated = this::finish;
65+
private GoogleMap gmap;
6566

66-
@Inject
67-
EventService eventService;
68-
@Inject
69-
ImageDownloader imageDownloader;
70-
private AccountManager accountManager;
67+
private Marker eventMarker;
68+
private boolean cameraMoved = false;
7169
private LatLng userLocation;
7270

73-
private final Runnable onNotAuthenticated = this::finish;
7471

7572
@Override
7673
protected void onCreate(Bundle savedInstanceState) {
7774
super.onCreate(savedInstanceState);
7875

79-
Bundle extras = getIntent().getExtras();
80-
if (extras == null) {
81-
showMessage(this, "Unable to show map without extras provided.");
82-
finish();
83-
return;
84-
}
85-
eventId = extras.getString(EventDispatcherActivity.EVENT_ID_KEY);
86-
if (eventId == null) {
87-
showMessage(this, "Unable to show map without event_id provided.");
88-
finish();
76+
if (EventDispatcherActivity.isIncorrect(this)) {
8977
return;
9078
}
9179

@@ -94,13 +82,14 @@ protected void onCreate(Bundle savedInstanceState) {
9482
setContentView(view);
9583

9684
((App) getApplication()).getEventComponent().inject(this);
97-
accountManager = AccountManager.get(this);
9885

9986
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
10087
.findFragmentById(R.id.eventSelectPosition);
101-
if (mapFragment != null) {
102-
mapFragment.getMapAsync(this);
88+
if (mapFragment == null) {
89+
return;
10390
}
91+
mapFragment.getMapAsync(this);
92+
10493
binding.btnConfirm.setOnClickListener(v -> {
10594
if (eventMarker != null) {
10695
Intent resultIntent = new Intent();
@@ -127,13 +116,13 @@ public void onLocationChanged(Location location) {
127116
cameraMoved = true;
128117
locationService.removeLocationTrackerListener(this);
129118
singleLocationUpdateListener = null;
130-
unbindService(locationServiceConn);
119+
unbindService(sConn);
131120
locationService = null;
132-
locationServiceConn = null;
121+
sConn = null;
133122
}
134123
}
135124
};
136-
locationServiceConn = new ServiceConnection() {
125+
sConn = new ServiceConnection() {
137126
public void onServiceConnected(ComponentName name, IBinder binder) {
138127
logMethod(TAG, this);
139128
locationService = ((LocationTrackerService.ServiceBinder) binder).getService();
@@ -143,11 +132,12 @@ public void onServiceConnected(ComponentName name, IBinder binder) {
143132
public void onServiceDisconnected(ComponentName name) {
144133
logMethod(TAG, this);
145134
locationService = null;
146-
locationServiceConn = null;
135+
sConn = null;
147136
}
148137
};
149-
Intent service = new Intent(this, LocationTrackerService.class);
150-
bindService(service, locationServiceConn, BIND_AUTO_CREATE);
138+
bindService(
139+
new Intent(this, LocationTrackerService.class),
140+
sConn, BIND_AUTO_CREATE);
151141
}
152142

153143
@Override
@@ -156,7 +146,9 @@ public void onMapReady(GoogleMap googleMap) {
156146
UiSettings uiSettings = gmap.getUiSettings();
157147
uiSettings.setZoomControlsEnabled(true);
158148

159-
eventService.getEvent(getAuthHeader(accountManager), eventId).enqueue(
149+
service.getEvent(
150+
AuthHelper.getAuthHeader(AccountManager.get(this)),
151+
EventDispatcherActivity.getEventId(this)).enqueue(
160152
new BaseOnNotAuthenticatedCallback<>(this, onNotAuthenticated) {
161153
@Override
162154
public void onResponse(Call<EventDTO> call, Response<EventDTO> resp) {
@@ -199,7 +191,7 @@ private void setupEventMarker(LatLng latLng, EventDTO event) {
199191
if (photoPath == null) {
200192
return;
201193
}
202-
imageDownloader.downloadEventImage(
194+
imgDownloader.downloadEventImage(
203195
photoPath, this, ImagesHelper::circleImage,
204196
(photo) -> eventMarker.setIcon(BitmapDescriptorFactory.fromBitmap(photo)),
205197
onNotAuthenticated);
@@ -212,8 +204,8 @@ protected void onDestroy() {
212204
if (locationService != null && singleLocationUpdateListener != null) {
213205
locationService.removeLocationTrackerListener(singleLocationUpdateListener);
214206
}
215-
if (locationServiceConn != null) {
216-
unbindService(locationServiceConn);
207+
if (sConn != null) {
208+
unbindService(sConn);
217209
}
218210
}
219211

0 commit comments

Comments
 (0)