Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
NewParkAPP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YONG-LIN SU
NewParkAPP
Commits
ce06c300
Commit
ce06c300
authored
Aug 01, 2022
by
YONG-LIN SU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
累加時段功能 初步完成
parent
c6955aeb
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
419 additions
and
216 deletions
+419
-216
misc.xml
.idea/misc.xml
+1
-0
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+0
-6
Common.java
app/src/main/java/ecom/android/newparkapp/Common.java
+3
-3
CaseDao.java
app/src/main/java/ecom/android/newparkapp/dao/CaseDao.java
+5
-1
T02StartActivity.java
...n/java/ecom/android/newparkapp/view/T02StartActivity.java
+83
-5
T03CumulativeActivity.java
...a/ecom/android/newparkapp/view/T03CumulativeActivity.java
+0
-16
T02StartViewModel.java
.../ecom/android/newparkapp/viewModel/T02StartViewModel.java
+59
-3
ic_baseline_cancel_24.xml
app/src/main/res/drawable/ic_baseline_cancel_24.xml
+10
-0
activity_t03_cumulative.xml
app/src/main/res/layout/activity_t03_cumulative.xml
+0
-182
alert_dialog_t03_cumulative_time.xml
app/src/main/res/layout/alert_dialog_t03_cumulative_time.xml
+212
-0
PlateModifyByRuleUnitTest.java
...va/ecom/android/newparkapp/PlateModifyByRuleUnitTest.java
+46
-0
No files found.
.idea/misc.xml
View file @
ce06c300
...
...
@@ -30,6 +30,7 @@
<entry
key=
"..\:/Users/pp931/Desktop/RD/Projects/NewParkApp/app/src/main/res/layout/activity_t02_start.xml"
value=
"0.34375"
/>
<entry
key=
"..\:/Users/pp931/Desktop/RD/Projects/NewParkApp/app/src/main/res/layout/activity_t03_cumulative.xml"
value=
"0.34375"
/>
<entry
key=
"..\:/Users/pp931/Desktop/RD/Projects/NewParkApp/app/src/main/res/layout/activity_t03_img_viewer.xml"
value=
"0.34375"
/>
<entry
key=
"..\:/Users/pp931/Desktop/RD/Projects/NewParkApp/app/src/main/res/layout/alert_dialog_t03_cumulative_time.xml"
value=
"0.34375"
/>
<entry
key=
"..\:/Users/pp931/Desktop/RD/Projects/NewParkApp/app/src/main/res/layout/card_view_image_plate_number_item.xml"
value=
"0.34375"
/>
<entry
key=
"..\:/Users/pp931/Desktop/RD/Projects/NewParkApp/app/src/main/res/layout/content_t02_select_road.xml"
value=
"0.1875"
/>
<entry
key=
"..\:/Users/pp931/Desktop/RD/Projects/NewParkApp/app/src/main/res/layout/recycler_view_bulletin_board_item.xml"
value=
"0.34375"
/>
...
...
app/src/main/AndroidManifest.xml
View file @
ce06c300
...
...
@@ -76,12 +76,6 @@
android:exported=
"false"
/>
<activity
android:name=
".view.T03CumulativeActivity"
android:exported=
"false"
android:label=
"資料匯入"
android:theme=
"@style/Theme.AppCompat.Light.Dialog"
/>
<activity
android:name=
".view.T03ImgViewerActivity"
android:exported=
"false"
/>
...
...
app/src/main/java/ecom/android/newparkapp/Common.java
View file @
ce06c300
...
...
@@ -597,8 +597,8 @@ public class Common {
}
public
static
String
plateModifyByRule
(
String
plateNumber
){
if
(
plateNumber
.
length
()
<=
7
){
// 舊車牌 總共 7 字元 包含 '-' , 8052-LZ , X2-3512
int
dashIndex
=
plateNumber
.
indexOf
(
"-"
);
if
(
dashIndex
==
-
1
){
return
plateNumber
;
...
...
@@ -652,8 +652,8 @@ public class Common {
}
}
}
else
{
String
newPlateNumber
=
plateNumber
.
substring
(
0
,
7
);
return
plate
ModifyByRule
(
newPlateNumber
);
// 新車牌 總共 8 字元含 '-' , AXV-5918
return
plate
Number
.
substring
(
0
,
8
);
}
return
plateNumber
;
}
...
...
app/src/main/java/ecom/android/newparkapp/dao/CaseDao.java
View file @
ce06c300
...
...
@@ -5,6 +5,7 @@ import androidx.room.Dao;
import
androidx.room.Delete
;
import
androidx.room.Insert
;
import
androidx.room.Query
;
import
androidx.room.Update
;
import
java.util.List
;
...
...
@@ -24,8 +25,11 @@ public interface CaseDao {
void
insertAll
(
Case
...
cases
);
@Delete
void
delete
(
Case
this
_c
ase
);
void
delete
(
Case
this
C
ase
);
@Query
(
"DELETE FROM `case`"
)
void
deleteAll
();
@Update
void
update
(
Case
thisCase
);
}
app/src/main/java/ecom/android/newparkapp/view/T02StartActivity.java
View file @
ce06c300
...
...
@@ -14,19 +14,23 @@ import android.net.Uri;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.provider.MediaStore
;
import
android.view.LayoutInflater
;
import
android.widget.Toast
;
import
java.io.File
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
ecom.android.newparkapp.R
;
import
ecom.android.newparkapp.entity.Case
;
import
ecom.android.newparkapp.entity.CaseStatus
;
import
ecom.android.newparkapp.entity.Space
;
import
ecom.android.newparkapp.entity.User
;
import
ecom.android.newparkapp.entity.VehicleType
;
import
ecom.android.newparkapp.viewModel.T02StartViewModel
;
import
ecom.android.newparkapp.databinding.ActivityT02StartBinding
;
import
ecom.android.newparkapp.databinding.AlertDialogT03CumulativeTimeBinding
;
public
class
T02StartActivity
extends
AppCompatActivity
{
...
...
@@ -117,7 +121,12 @@ public class T02StartActivity extends AppCompatActivity {
});
cumulativeTimeActivityResultLauncher
=
registerForActivityResult
(
new
ActivityResultContracts
.
StartActivityForResult
(),
result
->
{
if
(
result
.
getResultCode
()
==
RESULT_OK
){
if
(
photoFile
==
null
){
return
;
}
t02StartViewModel
.
cumulativeTime
(
photoFile
);
}
});
}
...
...
@@ -180,7 +189,20 @@ public class T02StartActivity extends AppCompatActivity {
}
private
void
btnPhotographOnClicked
(){
takePhoto
(
takePhotosActivityResultLauncher
);
}
/**
* 拍照功能,傳入不同的 ActivityResultLauncher,來接收不同的拍照邏輯
* @param activityResultLauncher 不同的事件處理器
*/
private
void
takePhoto
(
ActivityResultLauncher
activityResultLauncher
){
Case
currentCase
=
t02StartViewModel
.
getCurrentCase
().
getValue
();
if
(
currentCase
==
null
){
return
;
}
Intent
takePhotoIntent
=
new
Intent
(
MediaStore
.
ACTION_IMAGE_CAPTURE
);
takePhotoIntent
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
// 檢查是否已取得權限
...
...
@@ -201,8 +223,8 @@ public class T02StartActivity extends AppCompatActivity {
Uri
photoURI
=
FileProvider
.
getUriForFile
(
this
,
"ecom.android.newparkapp.fileprovider"
,
photoFile
);
takePhotoIntent
.
putExtra
(
MediaStore
.
EXTRA_SCREEN_ORIENTATION
,
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
);
takePhotoIntent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
photoURI
);
takePhotosActivityResultLauncher
.
launch
(
takePhotoIntent
);
activityResultLauncher
.
launch
(
takePhotoIntent
);
}
private
void
btnNewPageOnClicked
(){
...
...
@@ -245,8 +267,64 @@ public class T02StartActivity extends AppCompatActivity {
}
private
void
btnCumulativeTimeOnClicked
(){
Intent
intent
=
new
Intent
();
intent
.
setClass
(
this
,
T03CumulativeActivity
.
class
);
cumulativeTimeActivityResultLauncher
.
launch
(
intent
);
Case
tempCase
=
t02StartViewModel
.
getCurrentCase
().
getValue
();
if
(
tempCase
==
null
){
return
;}
// if (tempCase.caseStatus == CaseStatus.NEW){
// Toast.makeText(this, "請先設定格位", Toast.LENGTH_SHORT).show();
// return;
// }
AlertDialogT03CumulativeTimeBinding
t03CumulativeTimeDataBinding
=
AlertDialogT03CumulativeTimeBinding
.
inflate
(
LayoutInflater
.
from
(
this
));
AlertDialog
.
Builder
alertDialog
=
new
AlertDialog
.
Builder
(
this
);
final
AlertDialog
tempDialog
=
alertDialog
.
create
();
// 設置基本參數
// 取得當前時間
tempCase
.
finalTime
=
new
Date
();
// 累加時間試算
int
newAddCount
=
t02StartViewModel
.
calcPeriodHourCount
(
tempCase
);
float
newPeriodHour
=
newAddCount
*
tempCase
.
space
.
spaceRate
.
perHours
;
int
newFinalExpenses
=
newAddCount
*
tempCase
.
space
.
fee
;
// 顯示 試算 停車時數 停車費
t03CumulativeTimeDataBinding
.
diaParkingExpensesTextView
.
setText
(
String
.
valueOf
(
newFinalExpenses
));
t03CumulativeTimeDataBinding
.
diaParkingHoursTextView
.
setText
(
String
.
valueOf
(
newPeriodHour
));
// 顯示 累加時間 開單時間
SimpleDateFormat
simpleDate
=
new
SimpleDateFormat
(
"HH:mm"
);
t03CumulativeTimeDataBinding
.
diaBillingTimeTextView
.
setText
(
simpleDate
.
format
(
tempCase
.
caseTime
));
t03CumulativeTimeDataBinding
.
diaCumulativeTimeTextView
.
setText
(
simpleDate
.
format
(
tempCase
.
finalTime
));
// 關閉視窗
t03CumulativeTimeDataBinding
.
dialogClose
.
setOnClickListener
(
view
->
{
tempDialog
.
dismiss
();
});
// 加段
t03CumulativeTimeDataBinding
.
diaPeriodAddButton
.
setOnClickListener
(
view
->
{
});
// 減段
t03CumulativeTimeDataBinding
.
diaPeriodAddButton
.
setOnClickListener
(
view
->
{
});
// 註銷
t03CumulativeTimeDataBinding
.
diaOffButton
.
setOnClickListener
(
view
->
{
});
// 累加確認
t03CumulativeTimeDataBinding
.
diaConfirmButton
.
setOnClickListener
(
view
->
{
takePhoto
(
cumulativeTimeActivityResultLauncher
);
});
tempDialog
.
setCanceledOnTouchOutside
(
false
);
tempDialog
.
setView
(
t03CumulativeTimeDataBinding
.
getRoot
());
tempDialog
.
show
();
}
}
\ No newline at end of file
app/src/main/java/ecom/android/newparkapp/view/T03CumulativeActivity.java
deleted
100644 → 0
View file @
c6955aeb
package
ecom
.
android
.
newparkapp
.
view
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.os.Bundle
;
import
ecom.android.newparkapp.R
;
public
class
T03CumulativeActivity
extends
AppCompatActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_t03_cumulative
);
}
}
\ No newline at end of file
app/src/main/java/ecom/android/newparkapp/viewModel/T02StartViewModel.java
View file @
ce06c300
...
...
@@ -56,7 +56,7 @@ public class T02StartViewModel extends AndroidViewModel {
cases
.
get
(
i
).
caseStatus
=
CaseStatus
.
LIST
;
}
caseCursor
.
setValue
(
1
);
caseCursor
.
setValue
(
cases
.
size
()
);
}
public
LiveData
<
List
<
VehicleType
>>
getVehicleTypes
(){
...
...
@@ -92,9 +92,9 @@ public class T02StartViewModel extends AndroidViewModel {
/**
* 計算 累加 時數的次數
* @param thisCase 當前案件
* @return
* @return
new_addCount 累加時間
*/
p
rivate
int
calcPeriodHourCount
(
Case
thisCase
){
p
ublic
int
calcPeriodHourCount
(
Case
thisCase
){
int
new_addCount
=
0
;
if
(
thisCase
.
caseTime
==
null
||
thisCase
.
finalTime
==
null
||
thisCase
.
space
==
null
||
thisCase
.
space
.
spaceRate
==
null
){
return
new_addCount
;
...
...
@@ -180,9 +180,24 @@ public class T02StartViewModel extends AndroidViewModel {
caseCursor
.
postValue
(
caseCursor
.
getValue
()
+
1
);
break
;
case
CHANGED:
// 更新資料
infoRepository
.
executorService
.
execute
(()->{
// 更新 Case
infoRepository
.
caseDao
.
update
(
tempCase
);
// 新增車牌辨識結果
for
(
int
i
=
0
;
i
<
tempCasePhoto
.
size
();
i
++){
infoRepository
.
casePhotoDao
.
insertAll
(
tempCasePhoto
.
get
(
i
));
}
tempCasePhoto
.
clear
();
// 更新當前list結果
cases
.
set
(
caseCursor
.
getValue
(),
tempCase
);
});
break
;
case
LOCK:
break
;
default
:
break
;
...
...
@@ -372,4 +387,45 @@ public class T02StartViewModel extends AndroidViewModel {
}
}
/**
* 累加時間處理
* @param photoFile 拍照傳回
*/
public
void
cumulativeTime
(
File
photoFile
)
{
Case
tempCase
=
currentCase
.
getValue
();
tempCase
.
caseStatus
=
CaseStatus
.
CHANGED
;
// 更新照片數量
tempCase
.
photoCount
+=
1
;
// 更新累加時間
int
addCount
=
calcPeriodHourCount
(
tempCase
);
tempCase
.
periodHour
=
addCount
*
tempCase
.
space
.
spaceRate
.
perHours
;
tempCase
.
finalExpenses
=
addCount
*
tempCase
.
space
.
fee
;
// 取得完整路徑
final
String
path
=
photoFile
.
getAbsolutePath
();
// TODO: 2022/7/29 加入車牌辨識功能
String
newPlateNumber
=
"8050-LZ"
;
// 車牌辨識結果 車牌規則 過濾
newPlateNumber
=
Common
.
plateModifyByRule
(
newPlateNumber
);
// 添加車牌辨識 結果
CasePhoto
newCasePhoto
=
new
CasePhoto
(
0
,
tempCase
.
billingNumber2
,
path
,
newPlateNumber
);
tempCasePhoto
.
add
(
newCasePhoto
);
// 為圖片壓制浮水印
Thread
ModifyPhotoT
=
new
Thread
(
new
ModifyPhoto
(
path
),
"ModifyPhoto_Thread"
);
ModifyPhotoT
.
start
();
// 重新搜尋檔案
MediaScannerConnection
.
scanFile
(
getApplication
().
getApplicationContext
(),
new
String
[]{
path
},
null
,
null
);
// 更新當前案件
currentCase
.
setValue
(
tempCase
);
// 寫入DB
saveCurrentCase
();
}
}
app/src/main/res/drawable/ic_baseline_cancel_24.xml
0 → 100644
View file @
ce06c300
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"48dp"
android:height=
"48dp"
android:tint=
"#FFFFFF"
android:viewportWidth=
"24"
android:viewportHeight=
"24"
>
<path
android:fillColor=
"@android:color/white"
android:pathData=
"M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2zM17,15.59L15.59,17 12,13.41 8.41,17 7,15.59 10.59,12 7,8.41 8.41,7 12,10.59 15.59,7 17,8.41 13.41,12 17,15.59z"
/>
</vector>
app/src/main/res/layout/activity_t03_cumulative.xml
deleted
100644 → 0
View file @
c6955aeb
<?xml version="1.0" encoding="utf-8"?>
<layout>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:paddingStart=
"10dp"
android:paddingTop=
"10dp"
android:paddingEnd=
"10dp"
android:paddingBottom=
"150dp"
tools:context=
".view.T03CumulativeActivity"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/textView5"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:gravity=
"center_vertical"
android:text=
"累加時間"
android:textSize=
"21sp"
tools:ignore=
"NestedWeights"
/>
<TextView
android:id=
"@+id/cumulativeTime_textView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:gravity=
"center"
android:text=
"00:00"
android:textSize=
"21sp"
/>
<Button
android:id=
"@+id/periodSub_button"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:text=
"減段"
android:textSize=
"21sp"
/>
<Button
android:id=
"@+id/periodAdd_button"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:text=
"加段"
android:textSize=
"21sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/textView10"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:gravity=
"center_vertical"
android:text=
"開單時間"
android:textSize=
"21sp"
tools:ignore=
"NestedWeights"
/>
<TextView
android:id=
"@+id/BillingTime_textView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:gravity=
"center"
android:text=
"00:00"
android:textColor=
"@color/yellow_2"
android:textSize=
"21sp"
/>
<Space
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"0.666"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/textView12"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:gravity=
"center_vertical"
android:text=
"停車時數"
android:textSize=
"21sp"
tools:ignore=
"NestedWeights"
/>
<TextView
android:id=
"@+id/parkingHours_textView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:gravity=
"center"
android:text=
"1"
android:textSize=
"21sp"
/>
<Space
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"0.666"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/textView15"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:gravity=
"center_vertical"
android:text=
"停車費"
android:textSize=
"21sp"
tools:ignore=
"NestedWeights"
/>
<TextView
android:id=
"@+id/parkingExpenses_textView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:gravity=
"center"
android:text=
"20"
android:textSize=
"21sp"
/>
<Space
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"0.666"
/>
</LinearLayout>
<Space
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"0.7"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:orientation=
"horizontal"
>
<Button
android:id=
"@+id/off_button"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:text=
"註銷本單"
android:textSize=
"21sp"
tools:ignore=
"ButtonStyle,NestedWeights"
/>
<Button
android:id=
"@+id/confirm_button"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:text=
"累加確認"
android:textSize=
"21sp"
tools:ignore=
"ButtonStyle"
/>
</LinearLayout>
</LinearLayout>
</layout>
\ No newline at end of file
app/src/main/res/layout/alert_dialog_t03_cumulative_time.xml
0 → 100644
View file @
ce06c300
<?xml version="1.0" encoding="utf-8"?>
<layout>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<TextView
android:id=
"@+id/title_cumulative_data"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:background=
"@color/colorPrimaryDark"
android:gravity=
"center"
android:padding=
"5dp"
android:text=
"累加時間"
android:textColor=
"#fff"
android:textSize=
"30sp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<ImageButton
android:id=
"@+id/dialog_close"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"5dp"
android:background=
"@drawable/ic_baseline_cancel_24"
app:layout_constraintBottom_toBottomOf=
"@+id/title_cumulative_data"
app:layout_constraintEnd_toEndOf=
"@+id/title_cumulative_data"
app:layout_constraintTop_toTopOf=
"@+id/title_cumulative_data"
/>
<TextView
android:id=
"@+id/textView5"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"30dp"
android:layout_marginTop=
"20dp"
android:layout_marginBottom=
"1dp"
android:layout_weight=
"1"
android:gravity=
"center_vertical"
android:text=
"累加時間"
android:textSize=
"21sp"
app:layout_constraintBottom_toTopOf=
"@+id/textView10"
app:layout_constraintEnd_toStartOf=
"@+id/dia_cumulativeTime_textView"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/title_cumulative_data"
tools:ignore=
"NestedWeights"
/>
<TextView
android:id=
"@+id/dia_cumulativeTime_textView"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:text=
"00:00"
android:textSize=
"21sp"
app:layout_constraintBottom_toBottomOf=
"@+id/textView5"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintStart_toEndOf=
"@+id/textView5"
app:layout_constraintTop_toTopOf=
"@+id/textView5"
/>
<Button
android:id=
"@+id/dia_periodSub_button"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:text=
"減段"
android:textSize=
"21sp"
app:layout_constraintBottom_toBottomOf=
"@+id/textView5"
app:layout_constraintEnd_toStartOf=
"@+id/dia_periodAdd_button"
app:layout_constraintStart_toEndOf=
"@+id/dia_cumulativeTime_textView"
app:layout_constraintTop_toTopOf=
"@+id/textView5"
app:layout_constraintVertical_bias=
"0.0"
/>
<Button
android:id=
"@+id/dia_periodAdd_button"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"30dp"
android:text=
"加段"
android:textSize=
"21sp"
app:layout_constraintBottom_toBottomOf=
"@+id/dia_periodSub_button"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@+id/dia_periodSub_button"
app:layout_constraintTop_toTopOf=
"@+id/dia_periodSub_button"
app:layout_constraintVertical_bias=
"1.0"
/>
<TextView
android:id=
"@+id/textView10"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"30dp"
android:layout_marginTop=
"20dp"
android:layout_weight=
"1"
android:gravity=
"center_vertical"
android:text=
"開單時間"
android:textSize=
"21sp"
app:layout_constraintBottom_toTopOf=
"@+id/textView12"
app:layout_constraintEnd_toStartOf=
"@+id/dia_BillingTime_textView"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView5"
tools:ignore=
"NestedWeights"
/>
<TextView
android:id=
"@+id/dia_BillingTime_textView"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:text=
"00:00"
android:textColor=
"@color/yellow_2"
android:textSize=
"21sp"
app:layout_constraintBottom_toBottomOf=
"@+id/textView10"
app:layout_constraintEnd_toEndOf=
"@+id/dia_cumulativeTime_textView"
app:layout_constraintStart_toEndOf=
"@+id/textView10"
app:layout_constraintTop_toTopOf=
"@+id/textView10"
/>
<TextView
android:id=
"@+id/textView12"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"30dp"
android:layout_marginTop=
"20dp"
android:layout_weight=
"1"
android:gravity=
"center_vertical"
android:text=
"停車時數"
android:textSize=
"21sp"
app:layout_constraintBottom_toTopOf=
"@+id/textView15"
app:layout_constraintEnd_toStartOf=
"@+id/dia_parkingHours_textView"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView10"
tools:ignore=
"NestedWeights"
/>
<TextView
android:id=
"@+id/dia_parkingHours_textView"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:text=
"1"
android:textSize=
"21sp"
app:layout_constraintBottom_toBottomOf=
"@+id/textView12"
app:layout_constraintEnd_toEndOf=
"@+id/dia_cumulativeTime_textView"
app:layout_constraintStart_toEndOf=
"@+id/textView12"
app:layout_constraintTop_toTopOf=
"@+id/textView12"
/>
<TextView
android:id=
"@+id/textView15"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"30dp"
android:layout_marginTop=
"20dp"
android:layout_weight=
"1"
android:gravity=
"center_vertical"
android:text=
"停車費"
android:textSize=
"21sp"
app:layout_constraintEnd_toStartOf=
"@+id/dia_parkingExpenses_textView"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView12"
tools:ignore=
"NestedWeights"
/>
<TextView
android:id=
"@+id/dia_parkingExpenses_textView"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:text=
"20"
android:textSize=
"21sp"
app:layout_constraintBottom_toBottomOf=
"@+id/textView15"
app:layout_constraintEnd_toEndOf=
"@+id/dia_cumulativeTime_textView"
app:layout_constraintStart_toEndOf=
"@+id/textView15"
app:layout_constraintTop_toTopOf=
"@+id/textView15"
/>
<Button
android:id=
"@+id/dia_off_button"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"30dp"
android:layout_marginTop=
"90dp"
android:layout_marginEnd=
"5dp"
android:layout_marginBottom=
"20dp"
android:layout_weight=
"1"
android:text=
"註銷本單"
android:textSize=
"24sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/dia_confirm_button"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView15"
tools:ignore=
"ButtonStyle,NestedWeights"
/>
<Button
android:id=
"@+id/dia_confirm_button"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"5dp"
android:layout_marginEnd=
"30dp"
android:layout_weight=
"1"
android:text=
"累加確認"
android:textSize=
"24sp"
app:layout_constraintBottom_toBottomOf=
"@+id/dia_off_button"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@+id/dia_off_button"
app:layout_constraintTop_toTopOf=
"@+id/dia_off_button"
tools:ignore=
"ButtonStyle"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
app/src/test/java/ecom/android/newparkapp/PlateModifyByRuleUnitTest.java
0 → 100644
View file @
ce06c300
package
ecom
.
android
.
newparkapp
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
ecom
.
android
.
newparkapp
.
Common
.
plateModifyByRule
;
import
org.junit.Test
;
public
class
PlateModifyByRuleUnitTest
{
@Test
public
void
seven_number_plate
(){
String
plateNumber
=
"AXV-5918"
;
String
newPlateNumber
=
plateModifyByRule
(
plateNumber
);
assertEquals
(
newPlateNumber
,
plateNumber
);
}
@Test
public
void
six_number_plate
(){
String
plateNumber
=
"8052-LZ"
;
String
newPlateNumber
=
plateModifyByRule
(
plateNumber
);
assertEquals
(
newPlateNumber
,
plateNumber
);
}
@Test
public
void
six_number_with_O_plate
(){
String
plateNumber
=
"0X-2532"
;
String
newPlateNumber
=
plateModifyByRule
(
plateNumber
);
assertEquals
(
newPlateNumber
,
"OX-2532"
);
}
@Test
public
void
six_number_with_I_plate
(){
String
plateNumber
=
"1F-5545"
;
String
newPlateNumber
=
plateModifyByRule
(
plateNumber
);
assertEquals
(
newPlateNumber
,
"IF-5545"
);
}
@Test
public
void
over_seven_number_plate
(){
String
plateNumber
=
"AXV-59187"
;
String
newPlateNumber
=
plateModifyByRule
(
plateNumber
);
assertEquals
(
newPlateNumber
,
"AXV-5918"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment