Commit c0001036 authored by Dean's avatar Dean

Add MDD ALPR CAMERA

parent 004b86ff
......@@ -7,8 +7,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MddSimulatorCallerApp">
android:supportsRtl="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
......
......@@ -30,6 +30,7 @@ class FirstFragment : Fragment() {
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
MyBroadcastReceiver.typeReceiver = "ISIINAJA"
_binding = FragmentFirstBinding.inflate(inflater, container, false)
return binding.root
......@@ -47,6 +48,7 @@ class FirstFragment : Fragment() {
)
val br: BroadcastReceiver = MyBroadcastReceiver()
MyBroadcastReceiver.typeReceiver = "ISIINAJA"
val receiverPath = "com.mdd.mddsimulatorcallerapp.ON_RESULT"
val filter = IntentFilter(receiverPath)
......@@ -77,6 +79,7 @@ class FirstFragment : Fragment() {
)
val br: BroadcastReceiver = MyBroadcastReceiver()
MyBroadcastReceiver.typeReceiver = "ISIINAJA"
val receiverPath = "com.mdd.mddsimulatorcallerapp.ON_RESULT"
val filter = IntentFilter(receiverPath)
......@@ -99,6 +102,7 @@ class FirstFragment : Fragment() {
context?.let{act->
// WAJIB -> compileSdkVersion 29, minSdkVersion 22, targetSdkVersion 29
val br: BroadcastReceiver = MyBroadcastReceiver()
MyBroadcastReceiver.typeReceiver = "ISIINAJA"
val receiverPath = "com.mdd.mddsimulatorcallerapp.ON_RESULT"
val filter = IntentFilter(receiverPath)
......
package com.mdd.mddsimulatorcallerapp
import android.app.ActionBar
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
......@@ -37,6 +38,13 @@ class MainActivity : AppCompatActivity() {
override fun onCreateOptionsMenu(menu: Menu): Boolean {
// Inflate the menu; this adds items to the action bar if it is present.
menuInflater.inflate(R.menu.menu_main, menu)
// val actionBar = supportActionBar
// if (actionBar != null) {
// actionBar.setHomeButtonEnabled(false) // disable the button
// actionBar.setDisplayHomeAsUpEnabled(false) // remove the left caret
// actionBar.setDisplayShowHomeEnabled(false) // remove the icon
// actionBar.setHomeAsUpIndicator(null)
// }
return true
}
......@@ -45,7 +53,17 @@ class MainActivity : AppCompatActivity() {
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
return when (item.itemId) {
R.id.action_settings -> true
R.id.action_settings -> {
true
}
R.id.action_ToFirst -> {
findNavController(R.id.nav_host_fragment_content_main).navigate(R.id.action_SecondFragment_to_FirstFragment)
true
}
R.id.action_ToSeconds -> {
findNavController(R.id.nav_host_fragment_content_main).navigate(R.id.action_FirstFragment_to_SecondFragment)
true
}
else -> super.onOptionsItemSelected(item)
}
}
......
......@@ -8,11 +8,27 @@ import android.content.Intent;
import android.util.Log
class MyBroadcastReceiver : BroadcastReceiver() {
companion object{
var typeReceiver:String = "ISIINAJA"
}
override fun onReceive(context: Context?, intent: Intent) {
try{
Log.i("onReceive", "new_message")
if(typeReceiver == "ISIINAJA"){
Log.i("onReceive", "ISIINAJA")
val result = intent.getStringExtra("Result")
val status = intent.getStringExtra("Status")
showMessage(context, result, status)
}else if (typeReceiver == "ALPRCAMERA"){
Log.i("onReceive", "ALPRCAMERA")
val plateNumber = intent.getStringExtra("PlateNumber")
val result = intent.getStringExtra("ALPR_RESULT")
showMessage(context, result, plateNumber)
}
context?.unregisterReceiver(this)
}catch (ex:Exception){
Log.e("onReceive", ex.toString())
}
}
private fun showMessage(context: Context?, s:String, title:String) {
Log.i("MESSAGE", s)
......
package com.mdd.mddsimulatorcallerapp
import android.app.AlertDialog
import android.content.ActivityNotFoundException
import android.content.BroadcastReceiver
import android.content.Intent
import android.content.IntentFilter
import android.graphics.Color
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.navigation.fragment.findNavController
import com.mdd.mddsimulatorcallerapp.databinding.FragmentSecondBinding
......@@ -23,7 +30,7 @@ class SecondFragment : Fragment() {
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
MyBroadcastReceiver.typeReceiver = "ALPRCAMERA"
_binding = FragmentSecondBinding.inflate(inflater, container, false)
return binding.root
......@@ -31,9 +38,58 @@ class SecondFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.buttonSecond.setOnClickListener {
findNavController().navigate(R.id.action_SecondFragment_to_FirstFragment)
context?.let{act->
// WAJIB -> compileSdkVersion 29, minSdkVersion 22, targetSdkVersion 29
val br: MyBroadcastReceiver = MyBroadcastReceiver()
MyBroadcastReceiver.typeReceiver = "ALPRCAMERA"
val receiverPath = "com.mdd.mddsimulatorcallerapp.ON_RESULT"
val filter = IntentFilter(receiverPath)
act.registerReceiver(br, filter)
val intent = Intent(Intent.ACTION_SEND)
intent.`package` = "co.id.mdd.mddalprcamera"
intent.addCategory(Intent.CATEGORY_DEFAULT)
intent?.let { intent->
intent.putExtra("BroadcastReceiver", receiverPath)
intent.putExtra("ACTIVATION_SERVER_URL", "")
intent.putExtra("ACTIVATION_MASTER_OR_SLAVE_KEY", "")
// intent.putExtra("CONFIG_KLASS_LPCI_ENABLED", CONFIG_KLASS_LPCI_ENABLED) <- optional, untuk get license plate per negara
// intent.putExtra("CONFIG_KLASS_VBSR_ENABLED", CONFIG_KLASS_VBSR_ENABLED) <- optional, untuk get tipe body mobil
// intent.putExtra("CONFIG_KLASS_VCR_ENABLED", CONFIG_KLASS_VCR_ENABLED) <- optional, untuk get warna mobil
// intent.putExtra("CONFIG_KLASS_VMMR_ENABLED", CONFIG_KLASS_VMMR_ENABLED) <- optional, untuk get produsen mobil
// intent.putExtra("SavePhotoToFile", imageFilePath) <- optional, file path absolute image yg akan di save ke file
// intent.putExtra("GetAllJSON", true) <- optional
// intent.putExtra("CONFIG_DETECT_MINSCORE", binding.configDetectMinscore.text.toString().toDouble()) <- optional
// intent.putExtra("CONFIG_RECOGN_MINSCORE", binding.configRecognMinscore.text.toString().toDouble()) <- optional
try {
intent.putExtra("CONFIG_DETECT_MINSCORE", binding.configDetectMinscore.text.toString().toDouble())
}catch (ex:Exception){
ex.printStackTrace()
}
try {
intent.putExtra("CONFIG_RECOGN_MINSCORE", binding.configRecognMinscore.text.toString().toDouble())
}catch (ex:Exception){
ex.printStackTrace()
}
intent.putExtra("CONFIG_KLASS_LPCI_ENABLED", binding.configKLASSLPCIENABLED.isChecked)
intent.putExtra("CONFIG_KLASS_VBSR_ENABLED", binding.configKLASSVBSRENABLED.isChecked)
intent.putExtra("CONFIG_KLASS_VCR_ENABLED", binding.configKLASSVCRENABLED.isChecked)
intent.putExtra("CONFIG_KLASS_VMMR_ENABLED", binding.configKLASSVMMRENABLED.isChecked)
intent.putExtra("IS_SCREEN_ORIENTATION_LANDSCAPE", binding.configLANDSCAPE.isChecked)
intent.putExtra("GetAllJSON", true)
try {
startActivity(intent)
} catch (e: ActivityNotFoundException) {
showErrorMessage(e)
}
}
}
}
}
......@@ -41,4 +97,9 @@ class SecondFragment : Fragment() {
super.onDestroyView()
_binding = null
}
private fun showErrorMessage(e: Exception) {
AlertDialog.Builder(context)
.setMessage(e.message)
.show()
}
}
\ No newline at end of file
......@@ -16,6 +16,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:navigationIcon="@color/black"
app:popupTheme="@style/Theme.MddSimulatorCallerApp.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
......
......@@ -6,6 +6,64 @@
android:layout_height="match_parent"
tools:context=".SecondFragment">
<EditText
android:id="@+id/config_detect_minscore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:hint="CONFIG DETECT MINSCORE, EX: 0.25"
/>
<EditText
android:id="@+id/config_recogn_minscore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/config_detect_minscore"
android:hint="CONFIG RECOGN MINSCORE, EX: 0.3"
/>
<CheckBox
android:id="@+id/config_KLASS_LPCI_ENABLED"
app:layout_constraintTop_toBottomOf="@+id/config_recogn_minscore"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:text="CONFIG_KLASS_LPCI_ENABLED"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<CheckBox
android:id="@+id/config_KLASS_VCR_ENABLED"
app:layout_constraintTop_toBottomOf="@id/config_KLASS_LPCI_ENABLED"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:text="CONFIG_KLASS_VCR_ENABLED"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<CheckBox
android:id="@+id/config_KLASS_VMMR_ENABLED"
app:layout_constraintTop_toBottomOf="@id/config_KLASS_VCR_ENABLED"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:text="CONFIG_KLASS_VMMR_ENABLED"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<CheckBox
android:id="@+id/config_KLASS_VBSR_ENABLED"
app:layout_constraintTop_toBottomOf="@id/config_KLASS_VMMR_ENABLED"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:text="CONFIG_KLASS_VBSR_ENABLED"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<CheckBox
android:id="@+id/config_LANDSCAPE"
app:layout_constraintTop_toBottomOf="@id/config_KLASS_VBSR_ENABLED"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:text="CONFIG_LANDSCAPE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/textview_second"
android:layout_width="wrap_content"
......@@ -14,12 +72,11 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/previous"
android:text="ALPR CAMERA"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......
......@@ -5,6 +5,16 @@
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
android:title="Settings"
app:showAsAction="never" />
<item
android:id="@+id/action_ToFirst"
android:orderInCategory="100"
android:title="ISIIN AJA"
app:showAsAction="never" />
<item
android:id="@+id/action_ToSeconds"
android:orderInCategory="100"
android:title="ALPR CAMERA"
app:showAsAction="never" />
</menu>
\ No newline at end of file
......@@ -4,25 +4,28 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/FirstFragment">
<action
android:id="@+id/action_FirstFragment_to_SecondFragment"
app:destination="@id/SecondFragment"
app:popUpTo="@+id/SecondFragment"
app:popUpToInclusive="true"
/>
<action
android:id="@+id/action_SecondFragment_to_FirstFragment"
app:destination="@id/FirstFragment"
app:popUpTo="@+id/FirstFragment"
app:popUpToInclusive="true"
/>
<fragment
android:id="@+id/FirstFragment"
android:name="com.mdd.mddsimulatorcallerapp.FirstFragment"
android:label="Isiin Aja simulator"
tools:layout="@layout/fragment_first">
<action
android:id="@+id/action_FirstFragment_to_SecondFragment"
app:destination="@id/SecondFragment" />
</fragment>
<fragment
android:id="@+id/SecondFragment"
android:name="com.mdd.mddsimulatorcallerapp.SecondFragment"
android:label="@string/second_fragment_label"
android:label="ALPR CAMERA"
tools:layout="@layout/fragment_second">
<action
android:id="@+id/action_SecondFragment_to_FirstFragment"
app:destination="@id/FirstFragment" />
</fragment>
</navigation>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment