Skip to content

Commit b8974b2

Browse files
authored
Cummulative update for modules and events grid. (#16)
1 parent 94c5f77 commit b8974b2

File tree

85 files changed

+2066
-797
lines changed

Some content is hidden

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

85 files changed

+2066
-797
lines changed

AndroidClient/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ plugins {
44

55
android {
66
namespace 'com.tom.meeter'
7-
compileSdk 33
7+
compileSdk 35
88

99
defaultConfig {
1010
applicationId "com.tom.meeter"
1111
minSdk 21
12-
targetSdk 33
12+
targetSdk 35
1313
versionCode 1
1414
versionName "1.0"
1515

AndroidClient/src/main/AndroidManifest.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
<activity
5757
android:name=".context.profile.activity.ProfileActivity"
5858
android:label="@string/profile_activity_label"
59-
android:noHistory="true"
6059
android:parentActivityName=".context.auth.activity.LoginActivity">
6160
<meta-data
6261
android:name="android.support.PARENT_ACTIVITY"
@@ -74,8 +73,15 @@
7473
<activity
7574
android:name=".context.profile.activity.SettingsActivity"
7675
android:label="Settings"
77-
android:parentActivityName=".context.profile.activity.ProfileActivity">
78-
</activity>
76+
android:parentActivityName=".context.profile.activity.ProfileActivity" />
77+
78+
<activity
79+
android:name=".context.user.activity.UserActivity"
80+
android:label="UserActivity" />
81+
82+
<activity
83+
android:name=".context.event.activity.EventActivity"
84+
android:label="EventActivity" />
7985

8086
<meta-data
8187
android:name="com.google.android.gms.version"

AndroidClient/src/main/assets/app.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#Backend section
22
server.ip=192.168.61.59
33
server.port=8084
4+
server.proto=http
45
server.io_port=8085
6+
server.io_proto=ws
57

68
#Map section
79
#meters

AndroidClient/src/main/java/com/tom/meeter/App.java

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,30 @@
44

55
import android.app.Application;
66

7+
import com.tom.meeter.context.auth.AuthComponent;
8+
import com.tom.meeter.context.auth.DaggerAuthComponent;
9+
import com.tom.meeter.context.event.DaggerEventComponent;
10+
import com.tom.meeter.context.event.EventComponent;
11+
import com.tom.meeter.context.token.DaggerTokenComponent;
12+
import com.tom.meeter.context.token.TokenComponent;
13+
714
public class App extends Application {
815

916
private static final String TAG = App.class.getCanonicalName();
1017
private AppComponent component;
18+
private AuthComponent authComponent;
19+
private TokenComponent tokenComponent;
20+
private EventComponent eventComponent;
1121

1222
@Override
1323
public void onCreate() {
1424
super.onCreate();
1525
logMethod(TAG, this);
26+
27+
tokenComponent = buildTokenComponent();
28+
authComponent = buildAuthComponent();
29+
eventComponent = buildEventComponent();
30+
1631
component = buildComponent();
1732
}
1833

@@ -24,12 +39,44 @@ public void onTerminate() {
2439

2540
protected AppComponent buildComponent() {
2641
return DaggerAppComponent.builder()
27-
//.appModule(new AppModule(this))
42+
.tokenComponent(tokenComponent)
43+
.authComponent(authComponent)
44+
.eventComponent(eventComponent)
45+
.application(this)
46+
.build();
47+
}
48+
49+
protected AuthComponent buildAuthComponent() {
50+
return DaggerAuthComponent.builder()
51+
.application(this)
52+
.build();
53+
}
54+
55+
protected TokenComponent buildTokenComponent() {
56+
return DaggerTokenComponent.builder()
57+
.application(this)
58+
.build();
59+
}
60+
61+
protected EventComponent buildEventComponent() {
62+
return DaggerEventComponent.builder()
2863
.application(this)
2964
.build();
3065
}
3166

3267
public AppComponent getComponent() {
3368
return component;
3469
}
70+
71+
public AuthComponent getAuthComponent() {
72+
return authComponent;
73+
}
74+
75+
public TokenComponent getTokenComponent() {
76+
return tokenComponent;
77+
}
78+
79+
public EventComponent getEventComponent() {
80+
return eventComponent;
81+
}
3582
}

AndroidClient/src/main/java/com/tom/meeter/AppComponent.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,36 @@
22

33
import android.app.Application;
44

5-
import com.tom.meeter.context.auth.activity.LoginActivity;
6-
import com.tom.meeter.context.auth.activity.RegistrationActivity;
7-
import com.tom.meeter.context.auth.infrastructure.AccountAuthenticator;
8-
import com.tom.meeter.context.launcher.Launcher;
5+
import com.tom.meeter.context.auth.AuthComponent;
6+
import com.tom.meeter.context.event.EventComponent;
7+
import com.tom.meeter.context.event.activity.EventActivity;
98
import com.tom.meeter.context.profile.activity.ProfileActivity;
109
import com.tom.meeter.context.profile.activity.SettingsActivity;
1110
import com.tom.meeter.context.profile.fragment.ProfileFragment;
1211
import com.tom.meeter.context.profile.fragment.UserEventsFragment;
12+
import com.tom.meeter.context.token.TokenComponent;
13+
import com.tom.meeter.context.user.activity.UserActivity;
1314
import com.tom.meeter.infrastructure.injection.viewmodel.ViewModelModule;
1415

15-
import javax.inject.Singleton;
16-
1716
import dagger.BindsInstance;
1817
import dagger.Component;
1918

20-
@Component(modules = {AppModule.class, ViewModelModule.class})
21-
@Singleton
19+
@Component(
20+
modules = {AppModule.class, ViewModelModule.class},
21+
dependencies = {TokenComponent.class, AuthComponent.class, EventComponent.class})
22+
@AppScope
2223
public interface AppComponent {
2324

2425
@Component.Builder
2526
interface Builder {
2627

27-
/*@BindsInstance
28-
Builder appModule(AppModule appModule);*/
29-
3028
@BindsInstance
3129
Builder application(Application application);
3230

31+
Builder authComponent(AuthComponent authComponent);
32+
Builder tokenComponent(TokenComponent tokenComponent);
33+
Builder eventComponent(EventComponent eventComponent);
34+
3335
AppComponent build();
3436
}
3537

@@ -39,13 +41,9 @@ interface Builder {
3941

4042
void inject(UserEventsFragment userEventsFragment);
4143

42-
void inject(LoginActivity loginActivity);
43-
44-
void inject(RegistrationActivity registrationActivity);
45-
46-
void inject(AccountAuthenticator accountAuthenticator);
47-
4844
void inject(SettingsActivity settingsActivity);
4945

50-
void inject(Launcher launcher);
46+
void inject(UserActivity userActivity);
47+
48+
void inject(EventActivity eventActivity);
5149
}

AndroidClient/src/main/java/com/tom/meeter/AppModule.java

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
package com.tom.meeter;
22

3+
import static com.tom.meeter.infrastructure.common.Globals.getServerPath;
4+
35
import android.app.Application;
46
import android.util.Log;
57

68
import androidx.annotation.NonNull;
79
import androidx.room.Room;
810

9-
import com.tom.meeter.context.auth.service.AuthService;
1011
import com.tom.meeter.context.profile.event.database.EventDao;
1112
import com.tom.meeter.context.profile.event.database.EventDatabase;
1213
import com.tom.meeter.context.profile.event.service.EventService;
14+
import com.tom.meeter.context.profile.service.ProfileService;
1315
import com.tom.meeter.context.profile.settings.service.SettingsService;
1416
import com.tom.meeter.context.profile.user.database.UserDao;
1517
import com.tom.meeter.context.profile.user.database.UserDatabase;
16-
import com.tom.meeter.context.profile.user.service.UserService;
18+
import com.tom.meeter.context.user.service.UserService;
1719

1820
import java.util.concurrent.ArrayBlockingQueue;
1921
import java.util.concurrent.Executor;
2022
import java.util.concurrent.ThreadPoolExecutor;
2123
import java.util.concurrent.TimeUnit;
2224

23-
import javax.inject.Singleton;
24-
2525
import dagger.Module;
2626
import dagger.Provides;
2727
import retrofit2.Retrofit;
@@ -31,27 +31,34 @@
3131
public class AppModule {
3232

3333
private static final String TAG = AppModule.class.getCanonicalName();
34-
private static final String IP = "192.168.61.59";
35-
private static final int PORT = 8084;
36-
private static final String SERVER_URL = "http://" + IP + ":" + PORT + "/";
37-
3834

3935
public AppModule() {
40-
Log.d(TAG, "Configuring AppModule... Server URL is [" + SERVER_URL + "]");
36+
Log.d(TAG, "Configuring AppModule...");
4137
}
4238

43-
@Singleton
39+
@AppScope
4440
@NonNull
4541
@Provides
46-
public UserService provideUserService() {
42+
public ProfileService provideProfileService(Application app) {
4743
return new Retrofit.Builder()
48-
.baseUrl(SERVER_URL)
44+
.baseUrl(getServerPath(app))
45+
.addConverterFactory(GsonConverterFactory.create())
46+
.build()
47+
.create(ProfileService.class);
48+
}
49+
50+
@AppScope
51+
@NonNull
52+
@Provides
53+
public UserService provideUserService(Application app) {
54+
return new Retrofit.Builder()
55+
.baseUrl(getServerPath(app))
4956
.addConverterFactory(GsonConverterFactory.create())
5057
.build()
5158
.create(UserService.class);
5259
}
5360

54-
@Singleton
61+
@AppScope
5562
@NonNull
5663
@Provides
5764
public UserDatabase provideUserDb(Application app) {
@@ -60,33 +67,33 @@ public UserDatabase provideUserDb(Application app) {
6067
.build();
6168
}
6269

63-
@Singleton
70+
@AppScope
6471
@NonNull
6572
@Provides
6673
public UserDao provideUserDao(UserDatabase userDatabase) {
6774
return userDatabase.userDao();
6875
}
6976

70-
@Singleton
77+
@AppScope
7178
@NonNull
7279
@Provides
7380
public Executor provideExecutor() {
7481
return new ThreadPoolExecutor(4, 8, 1000, TimeUnit.SECONDS,
7582
new ArrayBlockingQueue<>(15, false));
7683
}
7784

78-
@Singleton
85+
@AppScope
7986
@NonNull
8087
@Provides
81-
public EventService provideEventService() {
88+
public EventService provideEventService(Application app) {
8289
return new Retrofit.Builder()
83-
.baseUrl(SERVER_URL)
90+
.baseUrl(getServerPath(app))
8491
.addConverterFactory(GsonConverterFactory.create())
8592
.build()
8693
.create(EventService.class);
8794
}
8895

89-
@Singleton
96+
@AppScope
9097
@NonNull
9198
@Provides
9299
public EventDatabase provideEventDb(Application app) {
@@ -95,30 +102,19 @@ public EventDatabase provideEventDb(Application app) {
95102
.build();
96103
}
97104

98-
@Singleton
105+
@AppScope
99106
@NonNull
100107
@Provides
101108
public EventDao provideEventDao(EventDatabase eventDatabase) {
102109
return eventDatabase.eventDao();
103110
}
104111

105-
@Singleton
106-
@NonNull
107-
@Provides
108-
public AuthService provideAuthService() {
109-
return new Retrofit.Builder()
110-
.baseUrl(SERVER_URL)
111-
.addConverterFactory(GsonConverterFactory.create())
112-
.build()
113-
.create(AuthService.class);
114-
}
115-
116-
@Singleton
112+
@AppScope
117113
@NonNull
118114
@Provides
119-
public SettingsService provideSettingsService() {
115+
public SettingsService provideSettingsService(Application app) {
120116
return new Retrofit.Builder()
121-
.baseUrl(SERVER_URL)
117+
.baseUrl(getServerPath(app))
122118
.addConverterFactory(GsonConverterFactory.create())
123119
.build()
124120
.create(SettingsService.class);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.tom.meeter;
2+
3+
import java.lang.annotation.Retention;
4+
import java.lang.annotation.RetentionPolicy;
5+
6+
import javax.inject.Scope;
7+
8+
@Scope
9+
@Retention(RetentionPolicy.RUNTIME)
10+
public @interface AppScope {
11+
}

0 commit comments

Comments
 (0)