Skip to content

Commit

Permalink
Fix #184 Add action bar to computer vision activity
Browse files Browse the repository at this point in the history
  • Loading branch information
yashk2000 committed Aug 28, 2020
1 parent 7a34e5d commit 37c46a6
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.net.Uri
import android.os.Bundle
import android.provider.MediaStore
import android.util.Log
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
Expand All @@ -27,6 +28,7 @@ import kotlinx.android.synthetic.main.activity_computer_vision.open_camera_btn
import kotlinx.android.synthetic.main.activity_computer_vision.res_list
import kotlinx.android.synthetic.main.activity_computer_vision.selected_images_list
import kotlinx.android.synthetic.main.activity_computer_vision.upload_from_gallery_btn
import kotlinx.android.synthetic.main.toolbar.*
import org.mifos.visionppi.R
import org.mifos.visionppi.adapters.ObjectDetectionResultAdapter
import org.mifos.visionppi.adapters.SelectedImageAdapter
Expand Down Expand Up @@ -55,6 +57,13 @@ class ComputerVisionActivity : AppCompatActivity(), ComputerVisionMVPView {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_computer_vision)

setSupportActionBar(appToolbar)
val actionBar = supportActionBar
actionBar?.title = "Analyse Images"

actionBar?.setDisplayHomeAsUpEnabled(true)
actionBar?.setDisplayShowHomeEnabled(true)

upload_from_gallery_btn.setOnClickListener {
fetchFromGallery()
}
Expand All @@ -80,6 +89,15 @@ class ComputerVisionActivity : AppCompatActivity(), ComputerVisionMVPView {
initDetector()
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.getItemId()) {
android.R.id.home -> {
onBackPressed()
}
}
return true
}

private fun initDetector() {
localModel =
LocalModel.Builder()
Expand Down
86 changes: 44 additions & 42 deletions visionppi/app/src/main/res/layout/activity_computer_vision.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="org.mifos.visionppi.ui.computer_vision.ComputerVisionActivity"
android:padding="@dimen/twenty_four_sp">
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="org.mifos.visionppi.ui.computer_vision.ComputerVisionActivity">

<include layout="@layout/toolbar" />

<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:padding="24dp"
android:orientation="horizontal">

<ImageView
Expand All @@ -22,49 +23,50 @@
android:layout_marginRight="@dimen/text_size"
android:layout_marginBottom="@dimen/large_spacing"/>

<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<Button
android:text="@string/open_camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_design"
android:id="@+id/open_camera_btn"
android:padding="5dp"
android:layout_marginBottom="10dp"
style="@style/Button2"/>
<Button
android:text="@string/open_camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_design"
android:id="@+id/open_camera_btn"
android:padding="5dp"
android:layout_marginBottom="10dp"
style="@style/Button2"/>

<Button
android:text="@string/upload_from_gallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_design"
android:id="@+id/upload_from_gallery_btn"
android:padding="5dp"
style="@style/Button2" />
</LinearLayout>
<Button
android:text="@string/upload_from_gallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_design"
android:id="@+id/upload_from_gallery_btn"
android:padding="5dp"
style="@style/Button2" />
</LinearLayout>
</LinearLayout>

<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="24dp">

<androidx.recyclerview.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/selected_images_list"
android:layout_width="match_parent"
android:background="@drawable/search_bar"
android:layout_height="305dp"/>
<Button
android:id="@+id/analyse"
android:text="@string/analyze_images"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_design"
android:padding="5dp"
style="@style/Button2"
android:layout_marginTop="@dimen/ll_margin"/>
<Button
android:id="@+id/analyse"
android:text="@string/analyze_images"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_design"
android:padding="5dp"
style="@style/Button2"
android:layout_marginTop="@dimen/ll_margin"/>

<TextView
android:id="@+id/listHeading"
Expand Down

0 comments on commit 37c46a6

Please sign in to comment.