Browse Source

-Add login for security
-Add error page when login not security
-Change home page
-Add some data for home page

ilhamitubagoes 4 years ago
parent
commit
45b76fb23e
36 changed files with 1518 additions and 21 deletions
  1. 5 1
      app/build.gradle
  2. 28 0
      app/src/androidTest/java/com/fusi24/rfid/DeviceUnitTest.java
  3. 29 8
      app/src/main/AndroidManifest.xml
  4. 219 0
      app/src/main/java/com/fusi24/rfid/HomeActivity.java
  5. 5 0
      app/src/main/java/com/fusi24/rfid/MainActivity.java
  6. 59 0
      app/src/main/java/com/fusi24/rfid/SplashScreenActivity.java
  7. 10 0
      app/src/main/java/com/fusi24/rfid/base/BaseActivity.java
  8. 4 4
      app/src/main/java/com/fusi24/rfid/config/Constant.java
  9. 6 0
      app/src/main/java/com/fusi24/rfid/data/DataManager.java
  10. 114 0
      app/src/main/java/com/fusi24/rfid/data/SessionManager.java
  11. 11 0
      app/src/main/java/com/fusi24/rfid/data/api/RestService.java
  12. 14 0
      app/src/main/java/com/fusi24/rfid/data/entity/DataAuth.java
  13. 68 0
      app/src/main/java/com/fusi24/rfid/data/entity/DataDetail.java
  14. 131 0
      app/src/main/java/com/fusi24/rfid/data/entity/DataUser.java
  15. 57 0
      app/src/main/java/com/fusi24/rfid/ui/login/ErrorLoginActivity.java
  16. 109 0
      app/src/main/java/com/fusi24/rfid/ui/login/LoginActivity.java
  17. 37 0
      app/src/main/java/com/fusi24/rfid/ui/login/LoginPresenter.java
  18. 10 0
      app/src/main/java/com/fusi24/rfid/ui/login/LoginView.java
  19. 23 0
      app/src/main/java/com/fusi24/rfid/util/Helper.java
  20. 2 3
      app/src/main/java/com/fusi24/rfid/util/LFSerialPortActivity.java
  21. BIN
      app/src/main/res/drawable/beats_logo_green.png
  22. 5 0
      app/src/main/res/drawable/ic_more_three_dots.xml
  23. 31 0
      app/src/main/res/drawable/ic_only_security.xml
  24. 79 0
      app/src/main/res/drawable/ic_scan_card.xml
  25. BIN
      app/src/main/res/font/helvetica.otf
  26. BIN
      app/src/main/res/font/shadeerah.ttf
  27. 43 0
      app/src/main/res/layout/activity_error_login.xml
  28. 244 0
      app/src/main/res/layout/activity_home.xml
  29. 47 0
      app/src/main/res/layout/activity_login.xml
  30. 8 0
      app/src/main/res/layout/activity_main.xml
  31. 20 0
      app/src/main/res/layout/activity_splash_screen.xml
  32. 44 0
      app/src/main/res/layout/default_toolbar.xml
  33. 25 0
      app/src/main/res/menu/menu_home.xml
  34. 1 0
      app/src/main/res/values/colors.xml
  35. 14 5
      app/src/main/res/values/strings.xml
  36. 16 0
      app/src/main/res/values/styles.xml

+ 5 - 1
app/build.gradle

@@ -12,6 +12,9 @@ android {
12 12
         versionCode gitVersionCode
13 13
         versionName gitVersionName
14 14
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15
+
16
+        // Make generated archive contain version name and code.
17
+        archivesBaseName = "Entry Permit Scanner-${gitVersionName}"
15 18
     }
16 19
     buildFeatures {
17 20
         viewBinding = true
@@ -41,12 +44,13 @@ dependencies {
41 44
     implementation 'androidx.appcompat:appcompat:1.1.0'
42 45
     implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
43 46
     implementation "androidx.recyclerview:recyclerview:1.1.0"
47
+    implementation "com.google.android.material:material:1.1.0"
44 48
 
45 49
     //Timber
46 50
     implementation 'com.jakewharton.timber:timber:4.7.1'
47 51
 
48 52
     //RX JAVA
49
-    implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
53
+    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
50 54
     implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
51 55
 
52 56
     //GSON

+ 28 - 0
app/src/androidTest/java/com/fusi24/rfid/DeviceUnitTest.java

@@ -0,0 +1,28 @@
1
+package com.fusi24.rfid;
2
+
3
+import android.os.Build;
4
+
5
+import androidx.test.ext.junit.runners.AndroidJUnit4;
6
+
7
+import org.junit.Test;
8
+import org.junit.runner.RunWith;
9
+
10
+import static org.junit.Assert.assertEquals;
11
+
12
+/**
13
+ * Example local unit test, which will execute on the development machine (host).
14
+ *
15
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16
+ */
17
+@RunWith(AndroidJUnit4.class)
18
+public class DeviceUnitTest {
19
+
20
+    @Test
21
+    public void getBuildId() {
22
+        try {
23
+            assertEquals("BuildId", Build.ID);
24
+        } catch (Exception e) {
25
+            e.printStackTrace();
26
+        }
27
+    }
28
+}

+ 29 - 8
app/src/main/AndroidManifest.xml

@@ -3,6 +3,7 @@
3 3
     package="com.fusi24.rfid">
4 4
 
5 5
     <uses-permission android:name="android.permission.INTERNET" />
6
+    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
6 7
 
7 8
     <application
8 9
         android:allowBackup="true"
@@ -11,20 +12,40 @@
11 12
         android:roundIcon="@drawable/logo_hse_autimation"
12 13
         android:supportsRtl="true"
13 14
         android:theme="@style/AppTheme">
14
-        <activity android:name=".ui.scanresult.ScanResultActivity"
15
-            android:screenOrientation="fullSensor"/>
15
+        <activity
16
+            android:name=".SplashScreenActivity"
17
+            android:screenOrientation="fullSensor"
18
+            android:theme="@style/Theme.AppCompat.Light.NoActionBar">
19
+        <intent-filter>
20
+            <action android:name="android.intent.action.MAIN" />
21
+            <category android:name="android.intent.category.LAUNCHER" />
22
+        </intent-filter>
23
+        </activity>
24
+        <activity
25
+            android:name=".ui.login.LoginActivity"
26
+            android:screenOrientation="fullSensor"
27
+            android:theme="@style/Theme.AppCompat.Light.NoActionBar">
28
+        </activity>
16 29
         <activity
17 30
             android:name=".MainActivity"
18 31
             android:screenOrientation="fullSensor"
19 32
             android:theme="@style/Theme.AppCompat.Light.NoActionBar">
20
-            <intent-filter>
21
-                <action android:name="android.intent.action.MAIN" />
22
-
23
-                <category android:name="android.intent.category.LAUNCHER" />
24
-            </intent-filter>
25 33
         </activity>
26
-        <activity android:name=".ui.ScanActivity"
34
+        <activity
35
+            android:name=".HomeActivity"
36
+            android:screenOrientation="fullSensor"
37
+            android:theme="@style/Theme.AppCompat.Light.NoActionBar">
38
+        </activity>
39
+        <activity
40
+            android:name=".ui.ScanActivity"
27 41
             android:screenOrientation="fullSensor"/>
42
+        <activity
43
+            android:name=".ui.scanresult.ScanResultActivity"
44
+            android:screenOrientation="fullSensor"/>
45
+        <activity
46
+            android:name=".ui.login.ErrorLoginActivity"
47
+            android:screenOrientation="fullSensor"
48
+            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
28 49
     </application>
29 50
 
30 51
 </manifest>

+ 219 - 0
app/src/main/java/com/fusi24/rfid/HomeActivity.java

@@ -0,0 +1,219 @@
1
+package com.fusi24.rfid;
2
+
3
+import android.annotation.SuppressLint;
4
+import android.content.Intent;
5
+import android.os.Build;
6
+import android.os.Bundle;
7
+import android.view.Menu;
8
+import android.view.MenuItem;
9
+import android.view.View;
10
+import android.widget.AdapterView;
11
+import android.widget.ArrayAdapter;
12
+import android.widget.LinearLayout;
13
+import android.widget.RadioButton;
14
+import android.widget.TextView;
15
+import android.widget.Toast;
16
+
17
+import androidx.annotation.NonNull;
18
+import androidx.appcompat.widget.Toolbar;
19
+
20
+import com.fusi24.rfid.base.BaseActivity;
21
+import com.fusi24.rfid.config.Constant;
22
+import com.fusi24.rfid.data.api.RestService;
23
+import com.fusi24.rfid.data.api.RestServiceFactory;
24
+import com.fusi24.rfid.data.entity.DataDetail;
25
+import com.fusi24.rfid.data.entity.DataEntryPermit;
26
+import com.fusi24.rfid.databinding.ActivityHomeBinding;
27
+import com.fusi24.rfid.ui.ScanActivity;
28
+
29
+import org.jetbrains.annotations.NotNull;
30
+
31
+import java.util.ArrayList;
32
+import java.util.List;
33
+
34
+import retrofit2.Call;
35
+import retrofit2.Callback;
36
+import retrofit2.Response;
37
+import timber.log.Timber;
38
+
39
+public class HomeActivity extends BaseActivity implements View.OnClickListener {
40
+
41
+    private DataEntryPermit dataEntryPermit;
42
+    private List<DataEntryPermit> entryPermitList;
43
+    private List<DataDetail> statusScanList;
44
+    private ActivityHomeBinding binding;
45
+    Toolbar toolbar;
46
+    TextView toolbarTitle;
47
+    RadioButton rb;
48
+
49
+    @Override
50
+    protected void onCreate(Bundle savedInstanceState) {
51
+        super.onCreate(savedInstanceState);
52
+        binding = ActivityHomeBinding.inflate(getLayoutInflater());
53
+        View view = binding.getRoot();
54
+        setContentView(view);
55
+
56
+        toolbar = findViewById(R.id.toolbar);
57
+        toolbarTitle = findViewById(R.id.toolbar_text);
58
+
59
+        if(toolbarTitle!=null && toolbar!=null) {
60
+            toolbarTitle.setText(getString(R.string.app_name));
61
+            setSupportActionBar(toolbar);
62
+        }
63
+
64
+        if (getSupportActionBar() != null){
65
+            getSupportActionBar().setDisplayShowTitleEnabled(false);
66
+        }
67
+
68
+        entryPermitList = new ArrayList<>();
69
+        statusScanList = new ArrayList<>();
70
+
71
+        initView();
72
+        getDataPermit();
73
+        getDataStatusScan();
74
+    }
75
+
76
+    @Override
77
+    public boolean onPrepareOptionsMenu(Menu menu) {
78
+        menu.findItem(R.id.app_version)
79
+                .setEnabled(false)
80
+                .setTitle(BuildConfig.VERSION_NAME);
81
+        return super.onPrepareOptionsMenu(menu);
82
+    }
83
+
84
+    @Override
85
+    public boolean onCreateOptionsMenu(Menu menu) {
86
+        getMenuInflater().inflate(R.menu.menu_home, menu);
87
+        return super.onCreateOptionsMenu(menu);
88
+    }
89
+
90
+    @Override
91
+    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
92
+
93
+        if (item.getItemId() == R.id.action_logout) {
94
+            getSessionManager().clearData();
95
+            startActivity(new Intent(this, SplashScreenActivity.class));
96
+            return true;
97
+        }
98
+
99
+        return super.onOptionsItemSelected(item);
100
+    }
101
+
102
+    @Override
103
+    protected void onResume() {
104
+        super.onResume();
105
+        initEvent();
106
+    }
107
+
108
+    @SuppressLint("SetTextI18n")
109
+    private void initView(){
110
+        binding.tvRfidGunId.setText("RFID-" + Build.ID + "-" + Build.DEVICE);
111
+        binding.tvRfidCardNumber.setText(getSessionManager().getUserRfidNumber());
112
+        binding.tvEmployeeName.setText(getSessionManager().getEmployeeName());
113
+        //TODO STILL HARDCODE
114
+        binding.tvGateName.setText("Suzuran");
115
+        binding.tvSiteName.setText("BMO 1");
116
+    }
117
+
118
+    private void initEvent(){
119
+
120
+        binding.spinnerPermit.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
121
+            @Override
122
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
123
+                dataEntryPermit = (DataEntryPermit) parent.getItemAtPosition(position);
124
+            }
125
+
126
+            @Override
127
+            public void onNothingSelected(AdapterView<?> parent) {
128
+                dataEntryPermit = (DataEntryPermit) parent.getSelectedItem();
129
+            }
130
+        });
131
+
132
+        binding.btnScan.setOnClickListener(v -> {
133
+
134
+            if (binding.spinnerPermit.getSelectedItem() == null){
135
+                Toast.makeText(this, "Data Permit Belum Terpilih", Toast.LENGTH_SHORT).show();
136
+                return;
137
+            }
138
+
139
+            Intent intent = new Intent(this, ScanActivity.class);
140
+            intent.putExtra(ScanActivity.ID_PERMIT, String.valueOf(dataEntryPermit.getId()));
141
+            startActivity(intent);
142
+        });
143
+
144
+        binding.rgStatusScan.setOnCheckedChangeListener((group, checkedId) -> Timber.i("DEVELOPER : %s", checkedId));
145
+
146
+    }
147
+
148
+    private void getDataPermit() {
149
+        RestService restService = RestServiceFactory.create(Constant.JWT_TOKEN);
150
+        Call<List<DataEntryPermit>> call = restService.getEntryPermit();
151
+        call.enqueue(new Callback<List<DataEntryPermit>>() {
152
+            @Override
153
+            public void onResponse(@NotNull Call<List<DataEntryPermit>> call, @NotNull Response<List<DataEntryPermit>> response) {
154
+                if (response.body() != null) {
155
+                    entryPermitList.addAll(response.body());
156
+                    setDataPermit();
157
+                }
158
+            }
159
+
160
+            @Override
161
+            public void onFailure(@NotNull Call<List<DataEntryPermit>> call, @NotNull Throwable t) {
162
+                Toast.makeText(HomeActivity.this, "Failed to get data permit", Toast.LENGTH_SHORT).show();
163
+                Timber.i("DEVELOPER : %s", t.getMessage());
164
+            }
165
+        });
166
+    }
167
+
168
+    private void getDataStatusScan(){
169
+        RestService restService = RestServiceFactory.create(Constant.JWT_TOKEN);
170
+        Call<List<DataDetail>> call = restService.getLookUp("BeSCAN_CHECK_TYPE");
171
+        call.enqueue(new Callback<List<DataDetail>>() {
172
+            @Override
173
+            public void onResponse(@NotNull Call<List<DataDetail>> call, @NotNull Response<List<DataDetail>> response) {
174
+                if (response.body() != null){
175
+                    statusScanList.addAll(response.body());
176
+                    setDataStatusScan();
177
+                }
178
+            }
179
+
180
+            @Override
181
+            public void onFailure(@NotNull Call<List<DataDetail>> call, @NotNull Throwable t) {
182
+                Toast.makeText(HomeActivity.this, "Failed to get data status Scan", Toast.LENGTH_SHORT).show();
183
+                Timber.i("DEVELOPER : %s", t.getMessage());
184
+            }
185
+        });
186
+    }
187
+
188
+    private void setDataPermit(){
189
+        ArrayAdapter<DataEntryPermit> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, entryPermitList);
190
+        binding.spinnerPermit.setAdapter(adapter);
191
+    }
192
+
193
+    private void setDataStatusScan(){
194
+        binding.rgStatusScan.setOrientation(LinearLayout.VERTICAL);
195
+        for (int i=0; i<statusScanList.size(); i++){
196
+            rb = new RadioButton(this);
197
+            rb.setId(View.generateViewId());
198
+            rb.setText(statusScanList.get(i).getName());
199
+            rb.setOnClickListener(this);
200
+            binding.rgStatusScan.addView(rb);
201
+        }
202
+    }
203
+
204
+    @Override
205
+    protected void onDestroy() {
206
+        super.onDestroy();
207
+        binding = null;
208
+    }
209
+
210
+    @Override
211
+    public void onClick(View v) {
212
+
213
+        rb.setOnClickListener(v1 -> {
214
+            Timber.i("DEVELOPER RB : %s", v1.getId());
215
+        });
216
+
217
+        Timber.tag(HomeActivity.class.getName()).d("DEVELOPER : Name " + ((RadioButton) v).getText() + " Id is " + v.getId());
218
+    }
219
+}

+ 5 - 0
app/src/main/java/com/fusi24/rfid/MainActivity.java

@@ -1,6 +1,8 @@
1 1
 package com.fusi24.rfid;
2 2
 
3
+import android.annotation.SuppressLint;
3 4
 import android.content.Intent;
5
+import android.os.Build;
4 6
 import android.os.Bundle;
5 7
 import android.view.View;
6 8
 import android.widget.AdapterView;
@@ -34,6 +36,7 @@ public class MainActivity extends BaseActivity {
34 36
     private List<DataEntryPermit> entryPermitList;
35 37
     private ActivityMainBinding binding;
36 38
 
39
+    @SuppressLint("SetTextI18n")
37 40
     @Override
38 41
     protected void onCreate(Bundle savedInstanceState) {
39 42
         super.onCreate(savedInstanceState);
@@ -47,6 +50,8 @@ public class MainActivity extends BaseActivity {
47 50
         siteList = new ArrayList<>();
48 51
         entryPermitList = new ArrayList<>();
49 52
 
53
+        binding.tvBebas.setText(Build.DEVICE + " " + Build.ID + " " + Build.HARDWARE + " " + Build.MANUFACTURER + " " + Build.TYPE + " " + Build.HOST);
54
+
50 55
         getDataSite();
51 56
         getDataPermit();
52 57
     }

+ 59 - 0
app/src/main/java/com/fusi24/rfid/SplashScreenActivity.java

@@ -0,0 +1,59 @@
1
+package com.fusi24.rfid;
2
+
3
+import android.app.Activity;
4
+import android.content.Intent;
5
+import android.os.Bundle;
6
+import android.os.Handler;
7
+
8
+import androidx.annotation.Nullable;
9
+
10
+import com.fusi24.rfid.base.BaseActivity;
11
+import com.fusi24.rfid.data.SessionManager;
12
+import com.fusi24.rfid.ui.login.LoginActivity;
13
+
14
+public class SplashScreenActivity extends BaseActivity {
15
+
16
+    public static final int REQUEST_LOGIN = 1100;
17
+
18
+    @Override
19
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
20
+        super.onCreate(savedInstanceState);
21
+        setContentView(R.layout.activity_splash_screen);
22
+    }
23
+
24
+    @Override
25
+    protected void onResume() {
26
+        super.onResume();
27
+
28
+        new Handler().postDelayed(() -> {
29
+            SessionManager sessionManager = getSessionManager();
30
+            if (!sessionManager.isUserLogin()) {
31
+                Intent intent = new Intent(SplashScreenActivity.this, LoginActivity.class);
32
+                startActivityForResult(intent, REQUEST_LOGIN);
33
+            }else {
34
+            goToHome();
35
+        }
36
+        },2000);
37
+    }
38
+
39
+    @Override
40
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
41
+        super.onActivityResult(requestCode, resultCode, data);
42
+
43
+        if (resultCode != Activity.RESULT_OK) {
44
+            return;
45
+        }
46
+
47
+        if (requestCode == REQUEST_LOGIN) {
48
+            goToHome();
49
+        }
50
+    }
51
+
52
+    private void goToHome() {
53
+        Intent intent = new Intent(SplashScreenActivity.this, HomeActivity.class);
54
+        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
55
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
56
+        startActivity(intent);
57
+        finish();
58
+    }
59
+}

+ 10 - 0
app/src/main/java/com/fusi24/rfid/base/BaseActivity.java

@@ -4,8 +4,10 @@ import androidx.appcompat.app.AppCompatActivity;
4 4
 
5 5
 import com.fusi24.rfid.config.Constant;
6 6
 import com.fusi24.rfid.data.DataManager;
7
+import com.fusi24.rfid.data.SessionManager;
7 8
 import com.fusi24.rfid.data.api.RestService;
8 9
 import com.fusi24.rfid.data.api.RestServiceFactory;
10
+import com.fusi24.rfid.util.Helper;
9 11
 
10 12
 import io.reactivex.Scheduler;
11 13
 import io.reactivex.android.schedulers.AndroidSchedulers;
@@ -14,6 +16,7 @@ import io.reactivex.schedulers.Schedulers;
14 16
 public abstract class BaseActivity extends AppCompatActivity {
15 17
 
16 18
     private RestService restService;
19
+    private SessionManager sessionManager;
17 20
     private DataManager manager;
18 21
 
19 22
     public RestService getRestService() {
@@ -23,6 +26,13 @@ public abstract class BaseActivity extends AppCompatActivity {
23 26
         return restService;
24 27
     }
25 28
 
29
+    public SessionManager getSessionManager() {
30
+        if (sessionManager == null) {
31
+            sessionManager = new SessionManager(Helper.getDefaultPreferences(this));
32
+        }
33
+        return sessionManager;
34
+    }
35
+
26 36
     public DataManager getManager() {
27 37
         if (manager == null) {
28 38
             manager = new DataManager(getRestService());

+ 4 - 4
app/src/main/java/com/fusi24/rfid/config/Constant.java

@@ -20,7 +20,7 @@ public final class Constant {
20 20
     /*===================================================================================================*/
21 21
 
22 22
     //Direct ke BCUI
23
-    /*public final static String BASE_URL = "http://bcui2.fusi24.com";
23
+    public final static String BASE_URL = "http://bcui2.fusi24.com";
24 24
 
25 25
     public final static String BEATS_ENDPOINT = "/beats";
26 26
     public final static String BEATS2_ENDPOINT = "/beats2";
@@ -28,10 +28,10 @@ public final class Constant {
28 28
     public final static String SID2_ENDPOINT = "/sid2";
29 29
     public final static String RFID_ENDPOINT = "/rfid";
30 30
 
31
-    public static final String URL_PHOTO = BASE_URL + BEATS2_ENDPOINT + "/file?path=";*/
31
+    public static final String URL_PHOTO = BASE_URL + BEATS2_ENDPOINT + "/file?path=";
32 32
 
33 33
     //Direct ke Production
34
-    public final static String BASE_URL = "http://hseautomation.beraucoal.co.id";
34
+    /*public final static String BASE_URL = "http://hseautomation.beraucoal.co.id";
35 35
 
36 36
     public final static String BEATS_ENDPOINT = "/beats";
37 37
     public final static String BEATS2_ENDPOINT = "/beats2";
@@ -39,7 +39,7 @@ public final class Constant {
39 39
     public final static String SID2_ENDPOINT = "/sid2";
40 40
     public final static String RFID_ENDPOINT = "/rfid";
41 41
 
42
-    public static final String URL_PHOTO = BASE_URL + BEATS2_ENDPOINT + "/file?path=";
42
+    public static final String URL_PHOTO = BASE_URL + BEATS2_ENDPOINT + "/file?path=";*/
43 43
 
44 44
     /*===================================================================================================*/
45 45
 

+ 6 - 0
app/src/main/java/com/fusi24/rfid/data/DataManager.java

@@ -1,7 +1,9 @@
1 1
 package com.fusi24.rfid.data;
2 2
 
3 3
 import com.fusi24.rfid.data.api.RestService;
4
+import com.fusi24.rfid.data.entity.DataAuth;
4 5
 import com.fusi24.rfid.data.entity.DataResultRfid;
6
+import com.fusi24.rfid.data.entity.DataUser;
5 7
 
6 8
 import io.reactivex.Observable;
7 9
 
@@ -13,6 +15,10 @@ public class DataManager {
13 15
         this.restService = restService;
14 16
     }
15 17
 
18
+    public Observable<DataUser> userLogin(DataAuth dataAuth) {
19
+        return restService.userLogin(dataAuth);
20
+    }
21
+
16 22
     public Observable<DataResultRfid> checkRfidCard(String numberRfid, Integer permitId, Integer siteId, String[] expand) {
17 23
         return restService.checkRfidCard(numberRfid, permitId, siteId, expand);
18 24
     }

+ 114 - 0
app/src/main/java/com/fusi24/rfid/data/SessionManager.java

@@ -0,0 +1,114 @@
1
+package com.fusi24.rfid.data;
2
+
3
+import android.content.SharedPreferences;
4
+
5
+public class SessionManager {
6
+
7
+    private static final String IS_LOGIN                = "is_login";
8
+    private static final String USER_ID                 = "user_id";
9
+    private static final String USER_NAME               = "user_name";
10
+    private static final String EMPLOYEE_NAME           = "employee_name";
11
+    private static final String USER_SID                = "user_sid";
12
+    private static final String USER_EMAIL              = "user_email";
13
+    private static final String USER_TELEPHONE          = "user_telephone";
14
+    private static final String USER_RFID_NUMBER        = "user_rfid_number";
15
+
16
+    private final SharedPreferences preferences;
17
+
18
+    public SessionManager(SharedPreferences preferences) {
19
+        this.preferences = preferences;
20
+    }
21
+
22
+    public Boolean isUserLogin() {
23
+        return preferences.getBoolean(IS_LOGIN, false);
24
+    }
25
+
26
+    public void setUserLogin() {
27
+        SharedPreferences.Editor editor = preferences.edit();
28
+        editor.putBoolean(IS_LOGIN, true);
29
+        editor.apply();
30
+    }
31
+
32
+    public Integer getUserId() {
33
+        return preferences.getInt(USER_ID, 0);
34
+    }
35
+
36
+    public void setUserId(Integer userID) {
37
+        SharedPreferences.Editor editor = preferences.edit();
38
+        editor.putInt(USER_ID, userID);
39
+        editor.apply();
40
+    }
41
+
42
+    public String getUserName() {
43
+        return preferences.getString(USER_NAME, "");
44
+    }
45
+
46
+    public void setUserName(String userName) {
47
+        SharedPreferences.Editor editor = preferences.edit();
48
+        editor.putString(USER_NAME, userName);
49
+        editor.apply();
50
+    }
51
+
52
+    public String getEmployeeName() {
53
+        return preferences.getString(EMPLOYEE_NAME, "");
54
+    }
55
+
56
+    public void setEmployeeName(String employeeName) {
57
+        SharedPreferences.Editor editor = preferences.edit();
58
+        editor.putString(EMPLOYEE_NAME, employeeName);
59
+        editor.apply();
60
+    }
61
+
62
+    public String getUserSid() {
63
+        return preferences.getString(USER_SID, "");
64
+    }
65
+
66
+    public void setUserSid(String userSid) {
67
+        SharedPreferences.Editor editor = preferences.edit();
68
+        editor.putString(USER_SID, userSid);
69
+        editor.apply();
70
+    }
71
+
72
+    public String getUserEmail() {
73
+        return preferences.getString(USER_EMAIL, "");
74
+    }
75
+
76
+    public void setUserEmail(String userEmail) {
77
+        SharedPreferences.Editor editor = preferences.edit();
78
+        editor.putString(USER_EMAIL, userEmail);
79
+        editor.apply();
80
+    }
81
+
82
+    public String getUserTelephone() {
83
+        return preferences.getString(USER_TELEPHONE, "");
84
+    }
85
+
86
+    public void setUserTelephone(String userTelephone) {
87
+        SharedPreferences.Editor editor = preferences.edit();
88
+        editor.putString(USER_TELEPHONE, userTelephone);
89
+        editor.apply();
90
+    }
91
+
92
+    public String getUserRfidNumber() {
93
+        return preferences.getString(USER_RFID_NUMBER, "");
94
+    }
95
+
96
+    public void setUserRfidNumber(String userRfidNumber) {
97
+        SharedPreferences.Editor editor = preferences.edit();
98
+        editor.putString(USER_RFID_NUMBER, userRfidNumber);
99
+        editor.apply();
100
+    }
101
+
102
+    public void clearData() {
103
+        SharedPreferences.Editor editor = preferences.edit();
104
+        editor.remove(IS_LOGIN);
105
+        editor.remove(USER_ID);
106
+        editor.remove(USER_NAME);
107
+        editor.remove(EMPLOYEE_NAME);
108
+        editor.remove(USER_SID);
109
+        editor.remove(USER_EMAIL);
110
+        editor.remove(USER_TELEPHONE);
111
+        editor.remove(USER_RFID_NUMBER);
112
+        editor.apply();
113
+    }
114
+}

+ 11 - 0
app/src/main/java/com/fusi24/rfid/data/api/RestService.java

@@ -1,20 +1,31 @@
1 1
 package com.fusi24.rfid.data.api;
2 2
 
3 3
 import com.fusi24.rfid.config.Constant;
4
+import com.fusi24.rfid.data.entity.DataAuth;
5
+import com.fusi24.rfid.data.entity.DataDetail;
4 6
 import com.fusi24.rfid.data.entity.DataEntryPermit;
5 7
 import com.fusi24.rfid.data.entity.DataResultRfid;
6 8
 import com.fusi24.rfid.data.entity.DataSite;
9
+import com.fusi24.rfid.data.entity.DataUser;
7 10
 
8 11
 import java.util.List;
9 12
 
10 13
 import io.reactivex.Observable;
11 14
 import retrofit2.Call;
15
+import retrofit2.http.Body;
12 16
 import retrofit2.http.GET;
17
+import retrofit2.http.POST;
13 18
 import retrofit2.http.Path;
14 19
 import retrofit2.http.Query;
15 20
 
16 21
 public interface RestService {
17 22
 
23
+    @POST(Constant.BEATS_ENDPOINT + "/api/mobile/login/rfid")
24
+    Observable<DataUser> userLogin(@Body DataAuth dataAuth);
25
+
26
+    @GET(Constant.BEATS2_ENDPOINT + "/api/lookup")
27
+    Call<List<DataDetail>> getLookUp(@Query("filter[parent.code]") String code);
28
+
18 29
     @GET(Constant.BEATS2_ENDPOINT + "/api/location")
19 30
     Call<List<DataSite>> getDataSite(@Query("filter[type.id]") Integer typeId);
20 31
 

+ 14 - 0
app/src/main/java/com/fusi24/rfid/data/entity/DataAuth.java

@@ -0,0 +1,14 @@
1
+package com.fusi24.rfid.data.entity;
2
+
3
+public class DataAuth {
4
+
5
+    private String rfidCode;
6
+
7
+    public String getRfidCode() {
8
+        return rfidCode;
9
+    }
10
+
11
+    public void setRfidCode(String rfidCode) {
12
+        this.rfidCode = rfidCode;
13
+    }
14
+}

+ 68 - 0
app/src/main/java/com/fusi24/rfid/data/entity/DataDetail.java

@@ -0,0 +1,68 @@
1
+package com.fusi24.rfid.data.entity;
2
+
3
+public class DataDetail {
4
+
5
+    private Integer id;
6
+    private String code;
7
+    private String name;
8
+    private String shortName;
9
+    private String description;
10
+    private boolean isActive;
11
+    private Integer sortOrder;
12
+
13
+    public Integer getId() {
14
+        return id;
15
+    }
16
+
17
+    public void setId(Integer id) {
18
+        this.id = id;
19
+    }
20
+
21
+    public String getCode() {
22
+        return code;
23
+    }
24
+
25
+    public void setCode(String code) {
26
+        this.code = code;
27
+    }
28
+
29
+    public String getName() {
30
+        return name;
31
+    }
32
+
33
+    public void setName(String name) {
34
+        this.name = name;
35
+    }
36
+
37
+    public String getShortName() {
38
+        return shortName;
39
+    }
40
+
41
+    public void setShortName(String shortName) {
42
+        this.shortName = shortName;
43
+    }
44
+
45
+    public String getDescription() {
46
+        return description;
47
+    }
48
+
49
+    public void setDescription(String description) {
50
+        this.description = description;
51
+    }
52
+
53
+    public boolean isActive() {
54
+        return isActive;
55
+    }
56
+
57
+    public void setActive(boolean active) {
58
+        isActive = active;
59
+    }
60
+
61
+    public Integer getSortOrder() {
62
+        return sortOrder;
63
+    }
64
+
65
+    public void setSortOrder(Integer sortOrder) {
66
+        this.sortOrder = sortOrder;
67
+    }
68
+}

+ 131 - 0
app/src/main/java/com/fusi24/rfid/data/entity/DataUser.java

@@ -0,0 +1,131 @@
1
+package com.fusi24.rfid.data.entity;
2
+
3
+public class DataUser {
4
+
5
+    private Integer id;
6
+    private String username;
7
+    private String namaKaryawan;
8
+    private String email;
9
+    private String selular;
10
+    private String idUser;
11
+    private String idKaryawan;
12
+    private String kodeKaryawan;
13
+    private String idPerusahaan;
14
+    private String kodePerusahaan;
15
+    private String namaPerusahaan;
16
+    private String token;
17
+    private boolean success;
18
+    private String message;
19
+
20
+    public Integer getId() {
21
+        return id;
22
+    }
23
+
24
+    public void setId(Integer id) {
25
+        this.id = id;
26
+    }
27
+
28
+    public String getUsername() {
29
+        return username;
30
+    }
31
+
32
+    public void setUsername(String username) {
33
+        this.username = username;
34
+    }
35
+
36
+    public String getNamaKaryawan() {
37
+        return namaKaryawan;
38
+    }
39
+
40
+    public void setNamaKaryawan(String namaKaryawan) {
41
+        this.namaKaryawan = namaKaryawan;
42
+    }
43
+
44
+    public String getEmail() {
45
+        return email;
46
+    }
47
+
48
+    public void setEmail(String email) {
49
+        this.email = email;
50
+    }
51
+
52
+    public String getSelular() {
53
+        return selular;
54
+    }
55
+
56
+    public void setSelular(String selular) {
57
+        this.selular = selular;
58
+    }
59
+
60
+    public String getIdUser() {
61
+        return idUser;
62
+    }
63
+
64
+    public void setIdUser(String idUser) {
65
+        this.idUser = idUser;
66
+    }
67
+
68
+    public String getIdKaryawan() {
69
+        return idKaryawan;
70
+    }
71
+
72
+    public void setIdKaryawan(String idKaryawan) {
73
+        this.idKaryawan = idKaryawan;
74
+    }
75
+
76
+    public String getKodeKaryawan() {
77
+        return kodeKaryawan;
78
+    }
79
+
80
+    public void setKodeKaryawan(String kodeKaryawan) {
81
+        this.kodeKaryawan = kodeKaryawan;
82
+    }
83
+
84
+    public String getIdPerusahaan() {
85
+        return idPerusahaan;
86
+    }
87
+
88
+    public void setIdPerusahaan(String idPerusahaan) {
89
+        this.idPerusahaan = idPerusahaan;
90
+    }
91
+
92
+    public String getKodePerusahaan() {
93
+        return kodePerusahaan;
94
+    }
95
+
96
+    public void setKodePerusahaan(String kodePerusahaan) {
97
+        this.kodePerusahaan = kodePerusahaan;
98
+    }
99
+
100
+    public String getNamaPerusahaan() {
101
+        return namaPerusahaan;
102
+    }
103
+
104
+    public void setNamaPerusahaan(String namaPerusahaan) {
105
+        this.namaPerusahaan = namaPerusahaan;
106
+    }
107
+
108
+    public String getToken() {
109
+        return token;
110
+    }
111
+
112
+    public void setToken(String token) {
113
+        this.token = token;
114
+    }
115
+
116
+    public boolean isSuccess() {
117
+        return success;
118
+    }
119
+
120
+    public void setSuccess(boolean success) {
121
+        this.success = success;
122
+    }
123
+
124
+    public String getMessage() {
125
+        return message;
126
+    }
127
+
128
+    public void setMessage(String message) {
129
+        this.message = message;
130
+    }
131
+}

+ 57 - 0
app/src/main/java/com/fusi24/rfid/ui/login/ErrorLoginActivity.java

@@ -0,0 +1,57 @@
1
+package com.fusi24.rfid.ui.login;
2
+
3
+import android.os.Bundle;
4
+import android.view.MenuItem;
5
+import android.widget.TextView;
6
+import android.widget.Toast;
7
+
8
+import androidx.appcompat.widget.Toolbar;
9
+
10
+import com.fusi24.rfid.R;
11
+import com.fusi24.rfid.base.BaseActivity;
12
+
13
+public class ErrorLoginActivity extends BaseActivity {
14
+
15
+    public static final String MESSAGE = "";
16
+
17
+    Toolbar toolbar;
18
+    TextView toolbarTitle;
19
+
20
+    @Override
21
+    protected void onCreate(Bundle savedInstanceState) {
22
+        super.onCreate(savedInstanceState);
23
+        setContentView(R.layout.activity_error_login);
24
+
25
+        toolbar = findViewById(R.id.toolbar);
26
+        toolbarTitle = findViewById(R.id.toolbar_text);
27
+
28
+        if(toolbarTitle!=null && toolbar!=null) {
29
+            toolbarTitle.setText(getString(R.string.app_name));
30
+            setSupportActionBar(toolbar);
31
+        }
32
+
33
+        if (getSupportActionBar() != null){
34
+            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
35
+            getSupportActionBar().setDisplayShowTitleEnabled(false);
36
+        }
37
+
38
+        if (getIntent() != null){
39
+            String message = getIntent().getStringExtra(MESSAGE);
40
+            Toast.makeText(this, message, Toast.LENGTH_LONG).show();
41
+        }
42
+    }
43
+
44
+    @Override
45
+    public boolean onOptionsItemSelected(MenuItem item) {
46
+        if (item.getItemId()==android.R.id.home){
47
+            finish();
48
+        }
49
+        return super.onOptionsItemSelected(item);
50
+    }
51
+
52
+    @Override
53
+    public void onBackPressed() {
54
+        super.onBackPressed();
55
+        finish();
56
+    }
57
+}

+ 109 - 0
app/src/main/java/com/fusi24/rfid/ui/login/LoginActivity.java

@@ -0,0 +1,109 @@
1
+package com.fusi24.rfid.ui.login;
2
+
3
+import android.app.Activity;
4
+import android.content.Intent;
5
+import android.os.Bundle;
6
+import android.widget.Toast;
7
+
8
+import com.fusi24.rfid.R;
9
+import com.fusi24.rfid.data.SessionManager;
10
+import com.fusi24.rfid.data.entity.DataAuth;
11
+import com.fusi24.rfid.data.entity.DataUser;
12
+import com.fusi24.rfid.util.Helper;
13
+import com.fusi24.rfid.util.LFScanProcessing;
14
+
15
+import timber.log.Timber;
16
+
17
+public class LoginActivity extends LFScanProcessing implements LoginView {
18
+
19
+    private SessionManager session;
20
+    private LoginPresenter presenter;
21
+
22
+    @Override
23
+    protected void onCreate(Bundle savedInstanceState) {
24
+        super.onCreate(savedInstanceState);
25
+        setContentView(R.layout.activity_login);
26
+
27
+        presenter = new LoginPresenter(getManager(), getAndroidScheduler(), getProcessScheduler());
28
+        presenter.attachView(this);
29
+        session = new SessionManager(Helper.getDefaultPreferences(this));
30
+
31
+        initSound();
32
+        onStart();
33
+    }
34
+
35
+    void startInstance(String numberRfidTemp){
36
+        DataAuth dataAuth = new DataAuth();
37
+        dataAuth.setRfidCode(Helper.formatRfidNumber(numberRfidTemp));
38
+        presenter.userLogin(dataAuth);
39
+    }
40
+
41
+    // This method for read chip number in the card
42
+    @Override
43
+    protected void onDataReceived(byte[] buffer, int size) {
44
+        runOnUiThread(() -> {
45
+            if (rfidCardNumber != null) {
46
+                if (size > 0) {
47
+                    if (size >= 5) {
48
+                        byte[] tempBuf = new byte[size - 4];
49
+                        System.arraycopy(buffer, 4, tempBuf, 0, size - 4);//discard 4 bit
50
+                        String temStr = new String(tempBuf);
51
+                        int temInt = Integer.parseInt(temStr, 16);
52
+                        soundpool.play(soundid, 1, 1, 0, 0, 1);
53
+                        rfidCardNumber = Integer.toString(temInt);
54
+
55
+                        Timber.i("Hasil dari RFID LF: %s", rfidCardNumber);
56
+                        startInstance(rfidCardNumber);
57
+                    } else {
58
+                        // receipt data 4 digit to start
59
+                        rfidCardNumber = new String(buffer, 0, size);
60
+                    }
61
+                }
62
+            }
63
+        });
64
+    }
65
+
66
+    @Override
67
+    public void showLoginSuccess(DataUser dataUser) {
68
+        if (dataUser.isSuccess()){
69
+            session.setUserLogin();
70
+            session.setUserId(Integer.valueOf(dataUser.getIdUser()));
71
+            session.setUserName(dataUser.getUsername());
72
+            session.setEmployeeName(dataUser.getNamaKaryawan());
73
+            session.setUserSid(dataUser.getKodeKaryawan());
74
+            session.setUserEmail(dataUser.getEmail());
75
+            session.setUserTelephone(dataUser.getSelular());
76
+            session.setUserRfidNumber(Helper.formatRfidNumber(rfidCardNumber));
77
+
78
+            Intent result = new Intent();
79
+            setResult(Activity.RESULT_OK, result);
80
+            finish();
81
+        } else {
82
+            Intent intent = new Intent(this, ErrorLoginActivity.class);
83
+            if (dataUser.getMessage() != null){
84
+                intent.putExtra(ErrorLoginActivity.MESSAGE, dataUser.getMessage());
85
+            }
86
+            startActivity(intent);
87
+        }
88
+    }
89
+
90
+    @Override
91
+    public void onBackPressed() {
92
+        super.onBackPressed();
93
+        Intent startMain = new Intent(Intent.ACTION_MAIN);
94
+        startMain.addCategory(Intent.CATEGORY_HOME);
95
+        startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
96
+        startActivity(startMain);
97
+    }
98
+
99
+    @Override
100
+    public void showError(Throwable e) {
101
+        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
102
+    }
103
+
104
+    @Override
105
+    protected void onDestroy() {
106
+        super.onDestroy();
107
+        presenter.detachView();
108
+    }
109
+}

+ 37 - 0
app/src/main/java/com/fusi24/rfid/ui/login/LoginPresenter.java

@@ -0,0 +1,37 @@
1
+package com.fusi24.rfid.ui.login;
2
+
3
+import com.fusi24.rfid.base.BasePresenter;
4
+import com.fusi24.rfid.data.DataManager;
5
+import com.fusi24.rfid.data.entity.DataAuth;
6
+
7
+import io.reactivex.Scheduler;
8
+
9
+class LoginPresenter extends BasePresenter<LoginView> {
10
+
11
+    private DataManager manager;
12
+
13
+    private Scheduler androidScheduler;
14
+    private Scheduler processScheduler;
15
+
16
+    LoginPresenter(DataManager manager, Scheduler androidScheduler, Scheduler processScheduler) {
17
+        this.manager = manager;
18
+        this.androidScheduler = androidScheduler;
19
+        this.processScheduler = processScheduler;
20
+    }
21
+
22
+    void userLogin(DataAuth dataAuth) {
23
+        disposable.add(manager.userLogin(dataAuth)
24
+                .observeOn(androidScheduler)
25
+                .subscribeOn(processScheduler)
26
+                .subscribe(result -> {
27
+                    if (isViewAttached()) {
28
+                        getView().showLoginSuccess(result);
29
+                    }
30
+                }, throwable -> {
31
+                    if (isViewAttached()) {
32
+                        getView().showError(throwable);
33
+                    }
34
+                }));
35
+    }
36
+
37
+}

+ 10 - 0
app/src/main/java/com/fusi24/rfid/ui/login/LoginView.java

@@ -0,0 +1,10 @@
1
+package com.fusi24.rfid.ui.login;
2
+
3
+import com.fusi24.rfid.base.BaseView;
4
+import com.fusi24.rfid.data.entity.DataUser;
5
+
6
+public interface LoginView extends BaseView {
7
+
8
+    void showLoginSuccess(DataUser dataUser);
9
+
10
+}

+ 23 - 0
app/src/main/java/com/fusi24/rfid/util/Helper.java

@@ -0,0 +1,23 @@
1
+package com.fusi24.rfid.util;
2
+
3
+import android.content.Context;
4
+import android.content.SharedPreferences;
5
+
6
+import java.util.Locale;
7
+
8
+public class Helper {
9
+
10
+    private static final String PREF_NAME = "hse_pref_name";
11
+
12
+    public static SharedPreferences getDefaultPreferences(Context context) {
13
+        return context.getSharedPreferences(PREF_NAME, 0);
14
+    }
15
+
16
+    public static String formatRfidNumber(String numberRfidTemp){
17
+        if (numberRfidTemp.length() < 10){
18
+            return String.format(Locale.getDefault(), "%010d", Integer.valueOf(numberRfidTemp));
19
+        } else {
20
+            return numberRfidTemp;
21
+        }
22
+    }
23
+}

+ 2 - 3
app/src/main/java/com/fusi24/rfid/util/LFSerialPortActivity.java

@@ -19,9 +19,8 @@ package com.fusi24.rfid.util;
19 19
 import android.app.AlertDialog;
20 20
 import android.os.Bundle;
21 21
 
22
-import androidx.appcompat.app.AppCompatActivity;
23
-
24 22
 import com.fusi24.rfid.R;
23
+import com.fusi24.rfid.base.BaseActivity;
25 24
 import com.fusi24.rfid.config.Constant;
26 25
 
27 26
 import java.io.IOException;
@@ -32,7 +31,7 @@ import java.security.InvalidParameterException;
32 31
 import android_serialport_api.SerialPort;
33 32
 import android_serialport_api.SerialPortTool;
34 33
 
35
-public abstract class LFSerialPortActivity extends AppCompatActivity {
34
+public abstract class LFSerialPortActivity extends BaseActivity {
36 35
 
37 36
   public static final String PATH = Constant.PATH;
38 37
   public static final int BAUTRATE = Constant.BAUTRATE;

BIN
app/src/main/res/drawable/beats_logo_green.png


+ 5 - 0
app/src/main/res/drawable/ic_more_three_dots.xml

@@ -0,0 +1,5 @@
1
+<vector android:autoMirrored="true" android:height="24dp"
2
+    android:tint="?attr/colorControlNormal" android:viewportHeight="24"
3
+    android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4
+    <path android:fillColor="@android:color/white" android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
5
+</vector>

File diff suppressed because it is too large
+ 31 - 0
app/src/main/res/drawable/ic_only_security.xml


File diff suppressed because it is too large
+ 79 - 0
app/src/main/res/drawable/ic_scan_card.xml


BIN
app/src/main/res/font/helvetica.otf


BIN
app/src/main/res/font/shadeerah.ttf


+ 43 - 0
app/src/main/res/layout/activity_error_login.xml

@@ -0,0 +1,43 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:tools="http://schemas.android.com/tools"
4
+    android:layout_width="match_parent"
5
+    android:layout_height="match_parent"
6
+    android:orientation="vertical"
7
+    tools:context=".ui.ScanActivity"
8
+    tools:viewBindingIgnore="true">
9
+
10
+    <include layout="@layout/default_toolbar"/>
11
+
12
+    <RelativeLayout
13
+        android:layout_width="match_parent"
14
+        android:layout_height="match_parent">
15
+
16
+        <TextView
17
+            android:id="@+id/tv_login_note"
18
+            style="@style/BodyTextMedium"
19
+            android:layout_marginTop="24dp"
20
+            android:layout_width="match_parent"
21
+            android:layout_height="wrap_content"
22
+            android:gravity="center"
23
+            android:text="@string/error_only_security"
24
+            android:fontFamily="@font/helvetica"/>
25
+
26
+        <ImageView
27
+            android:id="@+id/iv_icon_scan"
28
+            android:layout_width="match_parent"
29
+            android:layout_height="300dp"
30
+            android:src="@drawable/ic_only_security"
31
+            android:layout_below="@+id/tv_login_note"
32
+            android:layout_alignParentStart="true"
33
+            android:layout_alignParentEnd="true"
34
+            android:layout_marginStart="0dp"
35
+            android:layout_marginTop="0dp"
36
+            android:layout_marginEnd="0dp"
37
+            android:layout_marginBottom="0dp"
38
+            android:gravity="center"
39
+            android:contentDescription="@string/cd_image" />
40
+
41
+    </RelativeLayout>
42
+
43
+</LinearLayout>

+ 244 - 0
app/src/main/res/layout/activity_home.xml

@@ -0,0 +1,244 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:tools="http://schemas.android.com/tools"
4
+    android:layout_width="match_parent"
5
+    android:layout_height="wrap_content"
6
+    android:orientation="vertical"
7
+    tools:context=".HomeActivity">
8
+
9
+    <include layout="@layout/default_toolbar"/>
10
+
11
+    <RelativeLayout
12
+        android:layout_width="match_parent"
13
+        android:layout_height="wrap_content">
14
+
15
+        <LinearLayout
16
+            android:id="@+id/ll_rfid_user"
17
+            android:layout_marginStart="16dp"
18
+            android:layout_marginTop="24dp"
19
+            android:layout_width="match_parent"
20
+            android:layout_height="wrap_content"
21
+            android:layout_below="@+id/tv_title_label"
22
+            android:orientation="horizontal">
23
+
24
+            <TextView
25
+                android:textSize="14sp"
26
+                android:textColor="@color/colorBlack"
27
+                android:layout_width="230dp"
28
+                android:layout_height="wrap_content"
29
+                android:layout_marginEnd="2dp"
30
+                android:layout_marginLeft="2dp"
31
+                android:layout_marginRight="2dp"
32
+                android:layout_weight="1"
33
+                android:textStyle="bold"
34
+                android:text="Nomor RFID Gun" />
35
+
36
+            <TextView
37
+                android:id="@+id/tv_rfid_gun_id"
38
+                android:layout_width="match_parent"
39
+                android:layout_height="wrap_content"
40
+                android:layout_marginStart="12dp"
41
+                android:layout_weight="1"
42
+                android:textSize="14sp"
43
+                android:textColor="@color/colorBlack"
44
+                tools:text="RFID-AN70-N650" />
45
+        </LinearLayout>
46
+
47
+        <LinearLayout
48
+            android:id="@+id/ll_rfid_card"
49
+            android:layout_marginStart="16dp"
50
+            android:layout_marginTop="12dp"
51
+            android:layout_width="match_parent"
52
+            android:layout_height="wrap_content"
53
+            android:layout_below="@+id/ll_rfid_user"
54
+            android:orientation="horizontal">
55
+            <TextView
56
+                android:textSize="14sp"
57
+                android:textColor="@color/colorBlack"
58
+                android:layout_width="230dp"
59
+                android:layout_height="wrap_content"
60
+                android:layout_marginEnd="2dp"
61
+                android:layout_marginLeft="2dp"
62
+                android:layout_marginRight="2dp"
63
+                android:layout_weight="1"
64
+                android:textStyle="bold"
65
+                android:text="Nomor RFID Card" />
66
+
67
+            <TextView
68
+                android:id="@+id/tv_rfid_card_number"
69
+                android:layout_width="match_parent"
70
+                android:layout_height="wrap_content"
71
+                android:layout_weight="1"
72
+                android:layout_marginStart="12dp"
73
+                android:textSize="14sp"
74
+                android:textColor="@color/colorBlack"
75
+                tools:text="0009449244" />
76
+        </LinearLayout>
77
+
78
+        <LinearLayout
79
+            android:id="@+id/ll_employee"
80
+            android:layout_marginStart="16dp"
81
+            android:layout_marginTop="12dp"
82
+            android:layout_width="match_parent"
83
+            android:layout_height="wrap_content"
84
+            android:layout_below="@+id/ll_rfid_card"
85
+            android:orientation="horizontal">
86
+            <TextView
87
+                android:textSize="14sp"
88
+                android:textColor="@color/colorBlack"
89
+                android:layout_width="230dp"
90
+                android:layout_height="wrap_content"
91
+                android:layout_marginEnd="2dp"
92
+                android:layout_marginLeft="2dp"
93
+                android:layout_marginRight="2dp"
94
+                android:layout_weight="1"
95
+                android:textStyle="bold"
96
+                android:text="Nama Karyawan" />
97
+
98
+            <TextView
99
+                android:id="@+id/tv_employee_name"
100
+                android:layout_width="match_parent"
101
+                android:layout_height="wrap_content"
102
+                android:layout_weight="1"
103
+                android:layout_marginStart="12dp"
104
+                android:textSize="14sp"
105
+                android:textColor="@color/colorBlack"
106
+                tools:text="Deddy Corbuzier" />
107
+        </LinearLayout>
108
+
109
+        <LinearLayout
110
+            android:id="@+id/ll_gate"
111
+            android:layout_marginStart="16dp"
112
+            android:layout_marginTop="12dp"
113
+            android:layout_width="match_parent"
114
+            android:layout_height="wrap_content"
115
+            android:layout_below="@+id/ll_employee"
116
+            android:orientation="horizontal">
117
+            <TextView
118
+                android:textSize="14sp"
119
+                android:textColor="@color/colorBlack"
120
+                android:layout_width="230dp"
121
+                android:layout_height="wrap_content"
122
+                android:layout_marginEnd="2dp"
123
+                android:layout_marginLeft="2dp"
124
+                android:layout_marginRight="2dp"
125
+                android:layout_weight="1"
126
+                android:textStyle="bold"
127
+                android:text="Gate" />
128
+
129
+            <TextView
130
+                android:id="@+id/tv_gate_name"
131
+                android:layout_width="match_parent"
132
+                android:layout_height="wrap_content"
133
+                android:layout_weight="1"
134
+                android:layout_marginStart="12dp"
135
+                android:textSize="14sp"
136
+                android:textColor="@color/colorBlack"
137
+                tools:text="Crown Palace" />
138
+        </LinearLayout>
139
+
140
+        <LinearLayout
141
+            android:id="@+id/ll_site"
142
+            android:layout_marginStart="16dp"
143
+            android:layout_marginTop="12dp"
144
+            android:layout_width="match_parent"
145
+            android:layout_height="wrap_content"
146
+            android:layout_below="@+id/ll_gate"
147
+            android:orientation="horizontal">
148
+            <TextView
149
+                android:textSize="14sp"
150
+                android:textColor="@color/colorBlack"
151
+                android:layout_width="230dp"
152
+                android:layout_height="wrap_content"
153
+                android:layout_marginEnd="2dp"
154
+                android:layout_marginLeft="2dp"
155
+                android:layout_marginRight="2dp"
156
+                android:layout_weight="1"
157
+                android:textStyle="bold"
158
+                android:text="Site" />
159
+
160
+            <TextView
161
+                android:id="@+id/tv_site_name"
162
+                android:layout_width="match_parent"
163
+                android:layout_height="wrap_content"
164
+                android:layout_weight="1"
165
+                android:layout_marginStart="12dp"
166
+                android:textSize="14sp"
167
+                android:textColor="@color/colorBlack"
168
+                tools:text="BMO 1" />
169
+        </LinearLayout>
170
+
171
+        <LinearLayout
172
+            android:id="@+id/ll_permit"
173
+            android:layout_marginStart="16dp"
174
+            android:layout_marginTop="12dp"
175
+            android:layout_width="match_parent"
176
+            android:layout_height="wrap_content"
177
+            android:layout_below="@+id/ll_site"
178
+            android:orientation="horizontal">
179
+            <TextView
180
+                android:textSize="14sp"
181
+                android:textColor="@color/colorBlack"
182
+                android:layout_width="230dp"
183
+                android:layout_height="wrap_content"
184
+                android:layout_marginEnd="2dp"
185
+                android:layout_marginLeft="2dp"
186
+                android:layout_marginRight="2dp"
187
+                android:layout_weight="1"
188
+                android:textStyle="bold"
189
+                android:text="Izin Masuk" />
190
+
191
+            <androidx.appcompat.widget.AppCompatSpinner
192
+                android:id="@+id/spinner_permit"
193
+                android:layout_width="165dp"
194
+                android:layout_height="wrap_content"
195
+                android:layout_marginStart="12dp"
196
+                android:layout_marginEnd="12dp"
197
+                style="@style/spinner_style" />
198
+        </LinearLayout>
199
+
200
+        <LinearLayout
201
+            android:id="@+id/ll_status_scan"
202
+            android:layout_marginStart="16dp"
203
+            android:layout_marginTop="12dp"
204
+            android:layout_width="match_parent"
205
+            android:layout_height="wrap_content"
206
+            android:layout_below="@+id/ll_permit"
207
+            android:orientation="horizontal">
208
+            <TextView
209
+                android:textSize="14sp"
210
+                android:textColor="@color/colorBlack"
211
+                android:layout_width="230dp"
212
+                android:layout_height="wrap_content"
213
+                android:layout_marginEnd="2dp"
214
+                android:layout_marginLeft="2dp"
215
+                android:layout_marginRight="2dp"
216
+                android:layout_weight="1"
217
+                android:textStyle="bold"
218
+                android:text="Status Scan" />
219
+
220
+            <RadioGroup
221
+                android:id="@+id/rg_status_scan"
222
+                android:layout_width="175dp"
223
+                android:layout_height="wrap_content"
224
+                android:layout_marginStart="12dp"
225
+                android:layout_marginEnd="12dp" />
226
+
227
+        </LinearLayout>
228
+
229
+        <Button
230
+            android:id="@+id/btn_scan"
231
+            style="@style/ButtonCommon"
232
+            android:layout_width="match_parent"
233
+            android:layout_height="wrap_content"
234
+            android:layout_below="@+id/ll_status_scan"
235
+            android:layout_alignParentStart="true"
236
+            android:layout_alignParentEnd="true"
237
+            android:layout_marginStart="16dp"
238
+            android:layout_marginTop="24dp"
239
+            android:layout_marginEnd="16dp"
240
+            android:text="@string/label_btn_scan" />
241
+
242
+    </RelativeLayout>
243
+
244
+</LinearLayout>

+ 47 - 0
app/src/main/res/layout/activity_login.xml

@@ -0,0 +1,47 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:tools="http://schemas.android.com/tools"
4
+    android:layout_width="match_parent"
5
+    android:layout_height="match_parent"
6
+    tools:context=".ui.ScanActivity"
7
+    tools:viewBindingIgnore="true">
8
+
9
+    <TextView
10
+        android:id="@+id/tv_login_note"
11
+        style="@style/BodyTextMedium"
12
+        android:layout_marginTop="24dp"
13
+        android:layout_width="match_parent"
14
+        android:layout_height="wrap_content"
15
+        android:gravity="center"
16
+        android:text="@string/label_login_scan" />
17
+
18
+    <ImageView
19
+        android:id="@+id/iv_icon_scan"
20
+        android:layout_width="match_parent"
21
+        android:layout_height="400dp"
22
+        android:src="@drawable/ic_scan_card"
23
+        android:layout_below="@+id/tv_login_note"
24
+        android:layout_alignParentStart="true"
25
+        android:layout_alignParentEnd="true"
26
+        android:layout_marginStart="0dp"
27
+        android:layout_marginTop="0dp"
28
+        android:layout_marginEnd="0dp"
29
+        android:layout_marginBottom="0dp"
30
+        android:gravity="center"
31
+        android:contentDescription="@string/cd_image" />
32
+
33
+    <TextView
34
+        android:id="@+id/tv_company_label"
35
+        style="@style/BottomText"
36
+        android:layout_width="match_parent"
37
+        android:layout_height="wrap_content"
38
+        android:layout_alignParentStart="true"
39
+        android:layout_alignParentEnd="true"
40
+        android:layout_alignParentBottom="true"
41
+        android:layout_marginStart="0dp"
42
+        android:layout_marginEnd="0dp"
43
+        android:layout_marginBottom="16dp"
44
+        android:gravity="center"
45
+        android:text="@string/label_company_app" />
46
+
47
+</RelativeLayout>

+ 8 - 0
app/src/main/res/layout/activity_main.xml

@@ -84,4 +84,12 @@
84 84
         android:gravity="center"
85 85
         android:text="@string/label_company_app" />
86 86
 
87
+    <TextView
88
+        android:id="@+id/tv_bebas"
89
+        android:layout_width="match_parent"
90
+        android:layout_height="wrap_content"
91
+        android:layout_marginStart="0dp"
92
+        android:layout_marginEnd="0dp"
93
+        tools:text="bebas"/>
94
+
87 95
 </RelativeLayout>

+ 20 - 0
app/src/main/res/layout/activity_splash_screen.xml

@@ -0,0 +1,20 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:tools="http://schemas.android.com/tools"
4
+    android:layout_width="match_parent"
5
+    android:layout_height="match_parent"
6
+    android:background="@color/colorPrimary"
7
+    android:orientation="vertical"
8
+    tools:context=".SplashScreenActivity"
9
+    tools:viewBindingIgnore="true">
10
+
11
+    <TextView
12
+        android:layout_width="wrap_content"
13
+        android:layout_height="wrap_content"
14
+        android:layout_centerInParent="true"
15
+        android:gravity="center"
16
+        android:text="@string/app_name"
17
+        android:textColor="@color/colorWhite"
18
+        android:textSize="36sp" />
19
+
20
+</RelativeLayout>

+ 44 - 0
app/src/main/res/layout/default_toolbar.xml

@@ -0,0 +1,44 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<com.google.android.material.appbar.AppBarLayout
3
+    xmlns:android="http://schemas.android.com/apk/res/android"
4
+    xmlns:app="http://schemas.android.com/apk/res-auto"
5
+    xmlns:tools="http://schemas.android.com/tools"
6
+    android:layout_width="match_parent"
7
+    android:layout_height="wrap_content"
8
+    android:orientation="vertical">
9
+
10
+    <androidx.appcompat.widget.Toolbar
11
+        android:id="@+id/toolbar"
12
+        android:layout_width="match_parent"
13
+        android:layout_height="wrap_content"
14
+        android:minHeight="?attr/actionBarSize"
15
+        android:background="@color/colorWhite"
16
+        android:theme="@style/ToolbarTheme"
17
+        app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
18
+
19
+        <ImageView
20
+            android:id="@+id/toolbar_logo"
21
+            android:layout_width="60dp"
22
+            android:layout_height="wrap_content"
23
+            android:scaleType="fitCenter"
24
+            android:src="@drawable/beats_logo_green"
25
+            android:layout_alignParentStart="true"
26
+            android:layout_centerVertical="true"
27
+            android:visibility="gone" />
28
+
29
+        <TextView
30
+            android:id="@+id/toolbar_text"
31
+            style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
32
+            android:layout_width="wrap_content"
33
+            android:layout_height="wrap_content"
34
+            android:textColor="@color/colorBlack"
35
+            android:textSize="20sp"
36
+            tools:text="@string/app_name"
37
+            android:maxLines="1"
38
+            android:ellipsize="end"
39
+            android:fontFamily="@font/shadeerah"
40
+            android:layout_gravity="center"/>
41
+
42
+    </androidx.appcompat.widget.Toolbar>
43
+
44
+</com.google.android.material.appbar.AppBarLayout>

+ 25 - 0
app/src/main/res/menu/menu_home.xml

@@ -0,0 +1,25 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:app="http://schemas.android.com/apk/res-auto">
4
+
5
+    <item
6
+        android:id="@+id/action_change_info"
7
+        android:orderInCategory="1"
8
+        android:icon="@drawable/ic_more_three_dots"
9
+        android:title="@string/label_more_options"
10
+        app:showAsAction="ifRoom">
11
+
12
+        <menu>
13
+            <item
14
+                android:id="@+id/app_version"
15
+                android:title="@string/label_app_version"
16
+                app:showAsAction="withText"/>
17
+
18
+            <item
19
+                android:id="@+id/action_logout"
20
+                android:title="@string/label_logout"
21
+                app:showAsAction="withText"/>
22
+        </menu>
23
+    </item>
24
+
25
+</menu>

+ 1 - 0
app/src/main/res/values/colors.xml

@@ -14,4 +14,5 @@
14 14
 
15 15
     <color name="colorWhite">#FFFFFF</color>
16 16
     <color name="colorBlack">#000000</color>
17
+    <color name="grey">#8e8e8e</color>
17 18
 </resources>

+ 14 - 5
app/src/main/res/values/strings.xml

@@ -3,19 +3,28 @@
3 3
     <string name="label_scanner_off">Scanner Mati</string>
4 4
     <string name="label_scanner_on">Scanner Hidup</string>
5 5
     <string name="label_header_app">HSE AUTOMATION \n ENTRY PERMIT SCANNER</string>
6
+    <string name="label_be_scan">BeScan</string>
6 7
     <string name="label_company_app">PT. Berau Coal</string>
7 8
     <string name="label_btn_scan">Start Scanning</string>
8 9
     <string name="label_info_scan">Tempelkan RFID Gun \n pada RFID Card</string>
10
+    <string name="label_login_scan">Tempelkan \n RFID Card untuk login</string>
11
+    <string name="label_more_options">More Options</string>
12
+    <string name="label_app_version">App version</string>
13
+    <string name="label_logout">Keluar</string>
14
+    <string name="label_home">Home</string>
15
+    <string name="label_scan_other">Scan Other</string>
16
+    <string name="label_status_passed">PASSED</string>
17
+    <string name="label_status_not_passed">NOT PASSED</string>
18
+    <string name="label_status_not_valid">NOT VALID</string>
19
+
20
+    //Content Description
21
+    <string name="cd_image">IMAGE</string>
9 22
 
10 23
     //Error
11 24
     <string name="error_configuration">Please configure your serial port first.</string>
12 25
     <string name="error_security">You do not have read/write permission to the serialport.</string>
13 26
     <string name="error_unknown">The serial port can not be opened for an unknown reason.</string>
14 27
     <string name="error_scan_id">Mohon maaf sistem sedang sibuk</string>
15
-    <string name="label_home">Home</string>
16
-    <string name="label_scan_other">Scan Other</string>
17
-    <string name="label_status_passed">PASSED</string>
18
-    <string name="label_status_not_passed">NOT PASSED</string>
19
-    <string name="label_status_not_valid">NOT VALID</string>
28
+    <string name="error_only_security">Oops……… \n sepertinya anda bukan Security</string>
20 29
 
21 30
 </resources>

+ 16 - 0
app/src/main/res/values/styles.xml

@@ -20,6 +20,12 @@
20 20
         <item name="android:textStyle">bold</item>
21 21
     </style>
22 22
 
23
+    <style name="BodyTextMedium">
24
+        <item name="android:textSize">20sp</item>
25
+        <item name="android:textColor">@color/colorGreenDark</item>
26
+        <item name="android:textStyle">bold</item>
27
+    </style>
28
+
23 29
     <style name="BottomText">
24 30
         <item name="android:textSize">16sp</item>
25 31
         <item name="android:textColor">@color/colorGreenDark</item>
@@ -55,4 +61,14 @@
55 61
         <item name="android:padding">8dp</item>
56 62
     </style>
57 63
 
64
+    <style name="ToolbarTheme" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
65
+        <item name="android:textColorPrimary">@color/colorBlack</item>
66
+        <item name="actionMenuTextColor">@color/colorAccent</item>
67
+        <item name="colorAccent">@color/colorAccent</item>
68
+        <item name="colorControlNormal">@color/colorAccent</item>
69
+        <item name="colorControlActivated">@color/colorAccent</item>
70
+        <item name="colorControlHighlight">@color/colorAccent</item>
71
+        <item name="android:fontFamily">@font/helvetica</item>
72
+    </style>
73
+
58 74
 </resources>