Browse Source

-Optimize session for data gate, site and permit
-Add sound util for dynamic sound (must import in project)

ilhamitubagoes 4 years ago
parent
commit
9d4b0859db

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -16,7 +16,7 @@
16
         android:theme="@style/AppTheme">
16
         android:theme="@style/AppTheme">
17
         <activity
17
         <activity
18
             android:name=".SplashScreenActivity"
18
             android:name=".SplashScreenActivity"
19
-            android:screenOrientation="fullSensor"
19
+            android:screenOrientation="portrait"
20
             android:theme="@style/Theme.AppCompat.Light.NoActionBar">
20
             android:theme="@style/Theme.AppCompat.Light.NoActionBar">
21
         <intent-filter>
21
         <intent-filter>
22
             <action android:name="android.intent.action.MAIN" />
22
             <action android:name="android.intent.action.MAIN" />

+ 1 - 1
app/src/main/java/com/fusi24/entryPermitScanner/config/Constant.java

@@ -30,7 +30,7 @@ public final class Constant {
30
     /*===================================================================================================*/
30
     /*===================================================================================================*/
31
 
31
 
32
     //Direct API Service
32
     //Direct API Service
33
-    public final static String BASE_URL_DEV = "http://bcui2.fusi24.com"; // Development
33
+    public final static String BASE_URL_DEV = "https://bcui2.fusi24.com"; // Development
34
     public final static String BASE_URL_PROD = "http://hseautomation.beraucoal.co.id"; // Production
34
     public final static String BASE_URL_PROD = "http://hseautomation.beraucoal.co.id"; // Production
35
 
35
 
36
     public final static String BEATS_ENDPOINT = "/beats";
36
     public final static String BEATS_ENDPOINT = "/beats";

+ 37 - 10
app/src/main/java/com/fusi24/entryPermitScanner/ui/home/HomeActivity.java

@@ -39,6 +39,7 @@ import com.fusi24.entryPermitScanner.data.entity.DataSite;
39
 import com.fusi24.entryPermitScanner.databinding.ActivityHomeBinding;
39
 import com.fusi24.entryPermitScanner.databinding.ActivityHomeBinding;
40
 import com.fusi24.entryPermitScanner.ui.ScanActivity;
40
 import com.fusi24.entryPermitScanner.ui.ScanActivity;
41
 import com.fusi24.entryPermitScanner.ui.setting.SettingActivity;
41
 import com.fusi24.entryPermitScanner.ui.setting.SettingActivity;
42
+import com.google.gson.Gson;
42
 
43
 
43
 import java.util.ArrayList;
44
 import java.util.ArrayList;
44
 import java.util.List;
45
 import java.util.List;
@@ -82,6 +83,7 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
82
         initView();
83
         initView();
83
         getDataDeviceId();
84
         getDataDeviceId();
84
         loadingData();
85
         loadingData();
86
+        getDataFromService();
85
     }
87
     }
86
 
88
 
87
     @Override
89
     @Override
@@ -118,6 +120,7 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
118
     @Override
120
     @Override
119
     protected void onResume() {
121
     protected void onResume() {
120
         super.onResume();
122
         super.onResume();
123
+        loadingData();
121
         initEvent();
124
         initEvent();
122
     }
125
     }
123
 
126
 
@@ -146,7 +149,26 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
146
         binding.tvRfidGunId.setText(idDevice);
149
         binding.tvRfidGunId.setText(idDevice);
147
         binding.tvRfidCardNumber.setText(getSessionManager().getUserRfidNumber());
150
         binding.tvRfidCardNumber.setText(getSessionManager().getUserRfidNumber());
148
         binding.tvEmployeeName.setText(getSessionManager().getEmployeeName());
151
         binding.tvEmployeeName.setText(getSessionManager().getEmployeeName());
152
+        binding.tvGateName.setText(getSessionManager().getGate());
153
+
154
+        if (getSessionManager().getSiteList() != null) {
155
+            siteAdapter.updateSiteList(getSessionManager().getSiteList());
156
+            siteAdapter.notifyDataSetChanged();
157
+        }
158
+
159
+        if (getSessionManager().getPermitList() != null) {
160
+            entryPermitList.clear();
161
+            entryPermitList.addAll(getSessionManager().getPermitList());
162
+        }
163
+        setDataPermit();
164
+
165
+        Gson gson = new Gson();
166
+        System.out.println("Developer Gate : " + gson.toJson(getSessionManager().getGate()));
167
+        System.out.println("Developer Site : " + gson.toJson(getSessionManager().getSiteList()));
168
+        System.out.println("Developer Permit : " + gson.toJson(getSessionManager().getPermitList()));
169
+    }
149
 
170
 
171
+    private void getDataFromService(){
150
         presenter.getEntryPermit();
172
         presenter.getEntryPermit();
151
         presenter.getStatusScan();
173
         presenter.getStatusScan();
152
         presenter.getDataDevice(idDevice);
174
         presenter.getDataDevice(idDevice);
@@ -186,7 +208,7 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
186
             startActivity(intent);
208
             startActivity(intent);
187
         });
209
         });
188
 
210
 
189
-        binding.refresh.setOnRefreshListener(this::loadingData);
211
+        binding.refresh.setOnRefreshListener(this::getDataFromService);
190
 
212
 
191
     }
213
     }
192
 
214
 
@@ -198,10 +220,8 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
198
 
220
 
199
     @Override
221
     @Override
200
     public void showDataPermit(List<DataEntryPermit> dataEntryPermitList) {
222
     public void showDataPermit(List<DataEntryPermit> dataEntryPermitList) {
223
+        binding.refresh.setRefreshing(false);
201
         getSessionManager().setPermitList(dataEntryPermitList);
224
         getSessionManager().setPermitList(dataEntryPermitList);
202
-        entryPermitList.clear();
203
-        entryPermitList.addAll(getSessionManager().getPermitList());
204
-        setDataPermit();
205
     }
225
     }
206
 
226
 
207
     @Override
227
     @Override
@@ -216,11 +236,19 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
216
 
236
 
217
     @Override
237
     @Override
218
     public void showDataDevice(List<DataDevice> dataDevices) {
238
     public void showDataDevice(List<DataDevice> dataDevices) {
219
-        getSessionManager().setGate(dataDevices.get(0).getGate().getName());
220
-        getSessionManager().setSiteList(Stream.of(dataDevices.get(0).getGate().getSites()).filter(DataSite::getActive).sortBy(DataSite::getId).toList());
221
-        binding.tvGateName.setText(getSessionManager().getGate());
222
-        siteAdapter.updateSiteList(getSessionManager().getSiteList());
223
-        siteAdapter.notifyDataSetChanged();
239
+        // If data empty clear session
240
+        if (dataDevices.isEmpty()){
241
+            List<DataSite> siteList = new ArrayList<>();
242
+            getSessionManager().setSiteList(siteList);
243
+            getSessionManager().setGate("");
244
+        } else {
245
+            getSessionManager().setGate(dataDevices.get(0).getGate().getName()); // Data Gate
246
+            getSessionManager().setSiteList(Stream.of(dataDevices.get(0).getGate().getSites()) // Data Site
247
+                    .filter(DataSite::getActive)
248
+                    .sortBy(DataSite::getId).toList());
249
+        }
250
+        binding.refresh.setRefreshing(false);
251
+        loadingData();
224
     }
252
     }
225
 
253
 
226
     private void setDataPermit(){
254
     private void setDataPermit(){
@@ -239,7 +267,6 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
239
         }
267
         }
240
 
268
 
241
         // Inisiasi pertama saat muncul halaman default true
269
         // Inisiasi pertama saat muncul halaman default true
242
-        binding.swStatusScan.setOn(true);
243
         idCheckType = statusScanList.get(0).getId(); // <-- Check In Code (649)
270
         idCheckType = statusScanList.get(0).getId(); // <-- Check In Code (649)
244
         checkTypeName = statusScanList.get(0).getName(); // <-- Check In Name
271
         checkTypeName = statusScanList.get(0).getName(); // <-- Check In Name
245
 
272
 

+ 2 - 5
app/src/main/java/com/fusi24/entryPermitScanner/ui/login/LoginActivity.java

@@ -6,6 +6,7 @@ import android.os.Bundle;
6
 import android.view.View;
6
 import android.view.View;
7
 import android.widget.Toast;
7
 import android.widget.Toast;
8
 
8
 
9
+import com.fusi24.entryPermitScanner.R;
9
 import com.fusi24.entryPermitScanner.data.SessionManager;
10
 import com.fusi24.entryPermitScanner.data.SessionManager;
10
 import com.fusi24.entryPermitScanner.data.entity.DataAuth;
11
 import com.fusi24.entryPermitScanner.data.entity.DataAuth;
11
 import com.fusi24.entryPermitScanner.data.entity.DataUser;
12
 import com.fusi24.entryPermitScanner.data.entity.DataUser;
@@ -98,11 +99,7 @@ public class LoginActivity extends LFScanProcessing implements LoginView {
98
             setResult(Activity.RESULT_OK, result);
99
             setResult(Activity.RESULT_OK, result);
99
             finish();
100
             finish();
100
         } else {
101
         } else {
101
-            Intent intent = new Intent(this, ErrorLoginActivity.class);
102
-            if (dataUser.getMessage() != null){
103
-                intent.putExtra(ErrorLoginActivity.MESSAGE, dataUser.getMessage());
104
-            }
105
-            startActivity(intent);
102
+            Toast.makeText(this, getString(R.string.error_only_security), Toast.LENGTH_SHORT).show();
106
         }
103
         }
107
     }
104
     }
108
 
105
 

+ 4 - 0
app/src/main/java/com/fusi24/entryPermitScanner/ui/scanresult/ScanResultActivity.java

@@ -23,6 +23,7 @@ import com.fusi24.entryPermitScanner.data.entity.DataProblems;
23
 import com.fusi24.entryPermitScanner.data.entity.DataResultRfid;
23
 import com.fusi24.entryPermitScanner.data.entity.DataResultRfid;
24
 import com.fusi24.entryPermitScanner.databinding.ActivityScanResultNewBinding;
24
 import com.fusi24.entryPermitScanner.databinding.ActivityScanResultNewBinding;
25
 import com.fusi24.entryPermitScanner.ui.home.HomeActivity;
25
 import com.fusi24.entryPermitScanner.ui.home.HomeActivity;
26
+import com.fusi24.entryPermitScanner.util.SoundUtil;
26
 
27
 
27
 import java.util.ArrayList;
28
 import java.util.ArrayList;
28
 import java.util.List;
29
 import java.util.List;
@@ -64,6 +65,8 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
64
             getSupportActionBar().setDisplayShowTitleEnabled(false);
65
             getSupportActionBar().setDisplayShowTitleEnabled(false);
65
         }
66
         }
66
 
67
 
68
+        SoundUtil.initSound(this, R.raw.rfid_error);
69
+
67
         presenter = new ScanResultPresenter(getManager(), getAndroidScheduler(), getProcessScheduler());
70
         presenter = new ScanResultPresenter(getManager(), getAndroidScheduler(), getProcessScheduler());
68
         presenter.attachView(this);
71
         presenter.attachView(this);
69
 
72
 
@@ -172,6 +175,7 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
172
             binding.tvProfileStatus.setText(R.string.label_status_passed);
175
             binding.tvProfileStatus.setText(R.string.label_status_passed);
173
             binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.greenPassed));
176
             binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.greenPassed));
174
         } else {
177
         } else {
178
+            SoundUtil.playSound();
175
             if (dataResultRfid.getAlertType() != null) {
179
             if (dataResultRfid.getAlertType() != null) {
176
                 if (dataResultRfid.getAlertType().equalsIgnoreCase("ERROR")) {
180
                 if (dataResultRfid.getAlertType().equalsIgnoreCase("ERROR")) {
177
                     binding.tvProfileStatus.setText(R.string.label_status_not_passed);
181
                     binding.tvProfileStatus.setText(R.string.label_status_not_passed);

+ 1 - 2
app/src/main/java/com/fusi24/entryPermitScanner/ui/setting/SettingActivity.java

@@ -30,7 +30,7 @@ public class SettingActivity extends BaseActivity {
30
     private List<DataSerialPort> serialPortList;
30
     private List<DataSerialPort> serialPortList;
31
     private List<DataDirectURL> directURLList;
31
     private List<DataDirectURL> directURLList;
32
     private ActivitySettingBinding binding;
32
     private ActivitySettingBinding binding;
33
-    private boolean isFromLogin = false;
33
+    boolean isFromLogin = false;
34
 
34
 
35
     @Override
35
     @Override
36
     protected void onCreate(Bundle savedInstanceState) {
36
     protected void onCreate(Bundle savedInstanceState) {
@@ -174,7 +174,6 @@ public class SettingActivity extends BaseActivity {
174
     @Override
174
     @Override
175
     protected void onDestroy() {
175
     protected void onDestroy() {
176
         super.onDestroy();
176
         super.onDestroy();
177
-        System.out.println("DEVELOPER Setting onDestroy");
178
         binding = null;
177
         binding = null;
179
     }
178
     }
180
 }
179
 }

+ 29 - 0
app/src/main/java/com/fusi24/entryPermitScanner/util/SoundUtil.java

@@ -0,0 +1,29 @@
1
+package com.fusi24.entryPermitScanner.util;
2
+
3
+import android.content.Context;
4
+import android.media.AudioAttributes;
5
+import android.media.SoundPool;
6
+
7
+public class SoundUtil {
8
+
9
+  protected static int soundid;
10
+  protected static SoundPool soundpool = null;
11
+  protected static AudioAttributes attributes = null;
12
+
13
+  public static void initSound(Context context, Integer soundId){
14
+    attributes = new AudioAttributes.Builder()
15
+            .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
16
+            .setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT)
17
+            .build();
18
+
19
+    soundpool = new SoundPool.Builder()
20
+            .setMaxStreams(1)
21
+            .setAudioAttributes(attributes)
22
+            .build();
23
+    soundid = soundpool.load(context, soundId, 1);
24
+  }
25
+
26
+  public static void playSound(){
27
+    soundpool.play(soundid, 1, 1, 0, 0, 1);
28
+  }
29
+}

+ 1 - 1
app/src/main/res/layout/activity_home.xml

@@ -245,7 +245,7 @@
245
                             android:textSize="14sp"
245
                             android:textSize="14sp"
246
                             android:visibility="visible"
246
                             android:visibility="visible"
247
                             android:layout_gravity="start"
247
                             android:layout_gravity="start"
248
-                            app:on="false"
248
+                            app:on="true"
249
                             app:colorOn="@color/colorPrimary"
249
                             app:colorOn="@color/colorPrimary"
250
                             app:colorOff="@color/colorWhite"
250
                             app:colorOff="@color/colorWhite"
251
                             app:colorDisabled="@color/backgroundLayoutGreyDark"
251
                             app:colorDisabled="@color/backgroundLayoutGreyDark"

BIN
app/src/main/res/raw/error_yamete.ogg


BIN
app/src/main/res/raw/rfid_error.ogg