Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging tharee #39

Open
wants to merge 19 commits into
base: shabina-sapumal-integrate
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
deb40ae
Merge pull request #22 from Thareendra2000/staging-sapumal
saputhebeast May 5, 2023
099cc3c
Merge pull request #23 from Thareendra2000/staging-sapumal
saputhebeast May 5, 2023
334c055
Added GardenDashboard
Thareendra2000 May 6, 2023
e35a1e7
Added Garden Dashboard
Thareendra2000 May 6, 2023
557bc4b
Intergrated with the volunteering
mrmihi May 6, 2023
dd4e8ee
Merge pull request #25 from Thareendra2000/staging-dinal
mrmihi May 6, 2023
0f6c9a5
Merge pull request #26 from Thareendra2000/staging-sapumal
saputhebeast May 6, 2023
b89ed14
Passed gardenID & name to VolunteerBtn
Thareendra2000 May 6, 2023
783b208
Merge pull request #27 from Thareendra2000/staging-sapumal
saputhebeast May 6, 2023
babac66
Merge pull request #28 from Thareendra2000/staging-sapumal
saputhebeast May 6, 2023
51d764b
Fixed Garden activity bottom nav bar errors
Thareendra2000 May 6, 2023
729454b
Merge pull request #29 from Thareendra2000/staging-sapumal
saputhebeast May 6, 2023
f21e97f
Merge branch 'staging' of github.com:Thareendra2000/Gro-app into stag…
Thareendra2000 May 6, 2023
45bbfb7
Image view id
Thareendra2000 May 6, 2023
cb579d9
Merge pull request #30 from Thareendra2000/staging-sapumal
saputhebeast May 6, 2023
de71627
Merge branch 'staging' of github.com:Thareendra2000/Gro-app into stag…
Thareendra2000 May 6, 2023
57021e3
Completed the Dashboard
Thareendra2000 May 6, 2023
c5417b8
Added changes to Dashboard
Thareendra2000 May 6, 2023
06a06c5
Merge branch 'shabina-sapumal-integrate' into staging-tharee
Thareendra2000 May 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}

testOptions {
unitTests {
includeAndroidResources = true
}
}


}

dependencies {
Expand All @@ -59,8 +61,10 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test:rules:1.4.0'
implementation 'com.google.android.material:material:1.5.0'


implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.1.1'

// Import the Firebase BoM
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.example.groapp
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.*
import androidx.test.espresso.assertion.ViewAssertions.*
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.example.groapp.Activities.Garden.AddGardenActivity
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class AddGardenActivityTest {

@get:Rule
val activityRule = ActivityScenarioRule(AddGardenActivity::class.java)

private lateinit var name: String
private lateinit var address: String
private lateinit var phoneNo: String
private lateinit var location: String
private lateinit var description: String
private lateinit var area: String

@Before
fun setUp() {
name = "Test Garden"
address = "Test Address"
phoneNo = "1234567890"
location = "Test Location URL"
description = "Test Description"
area = "Test Area"
}

@Test
fun testSaveGardenData() {
onView(withId(R.id.gardenName)).perform(clearText(), typeText(name), closeSoftKeyboard())
onView(withId(R.id.gardenAddress)).perform(clearText(), typeText(address), closeSoftKeyboard())
onView(withId(R.id.gardenPhoneNo)).perform(clearText(), typeText(phoneNo), closeSoftKeyboard())
onView(withId(R.id.gardenLocation)).perform(clearText(), typeText(location), closeSoftKeyboard())
onView(withId(R.id.gardenArea)).perform(clearText(), typeText(area), closeSoftKeyboard())
onView(withId(R.id.gardenDescription)).perform(clearText(), typeText(description), closeSoftKeyboard())
onView(withId(R.id.gardenSubmitBtn)).perform(click())
onView(withText("Data inserted successfully")).check(matches(isDisplayed()))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.groapp
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import com.example.groapp.Activities.Garden.GardenDashboardActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class GardenDashboardActivityTest {

@get:Rule
val activityRule = ActivityTestRule(GardenDashboardActivity::class.java)

@Test
fun testMostProfitableProduct() {
onView(withId(R.id.pName)).check(matches(withText("product")))
}
}
17 changes: 17 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".Activities.NotificationActivity"
android:exported="false" />
Expand Down Expand Up @@ -90,6 +91,13 @@
<activity
android:name=".Activities.Product.ManageItemsActivity"
android:exported="false" />
<activity
android:name=".Activities.Garden.GardenActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity
android:name=".Activities.Product.EditDeleteItemActivity"
android:exported="false" />
Expand All @@ -114,6 +122,15 @@
<activity
android:name=".Activities.Garden.GardenListActivity"
android:exported="false"/>
<activity
android:name=".Activities.Garden.GardenDashboardActivity"
android:exported="false" />
<activity
android:name=".Activities.Garden.GardenActivity"
android:exported="false" />
<activity
android:name=".Activities.HomeActivity"
android:exported="false" />

<!--Miscellaneous-->
<activity
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.example.groapp.Activities.Garden

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import com.example.groapp.Activities.HomeActivity
import com.example.groapp.Activities.LoginActivity
import com.example.groapp.R

class GardenActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_garden)


val Btn3 = findViewById<View>(R.id.button4)
Btn3.setOnClickListener {
val intent = Intent(this, MyGardensActivity::class.java)
startActivity(intent)
}
val Btn4 = findViewById<View>(R.id.button5)
Btn4.setOnClickListener {
val intent = Intent(this, GardenListActivity::class.java)
startActivity(intent)
}

val Btn5 = findViewById<View>(R.id.button3)
Btn5.setOnClickListener {
val intent = Intent(this, GardenDashboardActivity::class.java)
startActivity(intent)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.example.groapp.Activities.Garden

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import com.example.groapp.R
import com.google.firebase.database.*

class GardenDashboardActivity : AppCompatActivity() {

private lateinit var database: DatabaseReference
private lateinit var gardensCountTextView: TextView
private lateinit var productsCountTextView: TextView
private lateinit var mostProfitableProduct: TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_garden_dashboard)

database = FirebaseDatabase.getInstance().reference
gardensCountTextView = findViewById(R.id.Amount)
productsCountTextView = findViewById(R.id.pTotal)
mostProfitableProduct = findViewById(R.id.pName)

database.addValueEventListener(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
val gardensCount = dataSnapshot.child("Garden").childrenCount
val productsCount = dataSnapshot.child("products").childrenCount

gardensCountTextView.text = gardensCount.toString()
productsCountTextView.text = productsCount.toString()

var maxProfit = 0.0
var mostProfitableProductName = ""

for (productSnapshot in dataSnapshot.child("products").children) {
val productName = productSnapshot.child("name").value.toString()
val quantity = productSnapshot.child("quantity").value.toString().toDouble()
val unitPrice = productSnapshot.child("unit_price").value.toString().toDouble()

val profit = quantity * unitPrice
if (profit > maxProfit) {
maxProfit = profit
mostProfitableProductName = productName
}
}

mostProfitableProduct.text = "$mostProfitableProductName"
}



override fun onCancelled(databaseError: DatabaseError) {
// Handle errors
}
})

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class GardenDetailsOwnerViewActivity : AppCompatActivity() {
private lateinit var productionAddBtn: Button
private lateinit var editBtn: ImageButton
private lateinit var deleteBtn: ImageButton
private lateinit var shareBtn: ImageButton



Expand All @@ -35,6 +36,15 @@ class GardenDetailsOwnerViewActivity : AppCompatActivity() {
initView()
setValuesToViews()

// Set a click listener on the share button.
shareBtn.setOnClickListener {
val shareIntent = Intent(Intent.ACTION_SEND)
shareIntent.type = "text/plain"
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Check out this garden")
shareIntent.putExtra(Intent.EXTRA_TEXT, "Name: ${gardenName.text}\nAddress: ${gardenAddress.text}\nArea: ${gardenArea.text}\nLocation: ${gardenLocation.text}\nPhone number: ${gardenPhoneNo.text}\nDescription: ${gardenDescription.text}")
startActivity(Intent.createChooser(shareIntent, "Share via"))
}

editBtn.setOnClickListener {
openUpdateDialog(
intent.getStringExtra("gardenId").toString(),
Expand Down Expand Up @@ -93,15 +103,17 @@ class GardenDetailsOwnerViewActivity : AppCompatActivity() {
productionAddBtn = findViewById(R.id.viewProducts)
editBtn =findViewById(R.id.btnEdit)
deleteBtn = findViewById(R.id.btnDelete)
shareBtn = findViewById(R.id.btnshare)

}

// Set the values of the UI elements with data passed from the previous activity.
private fun setValuesToViews() {

val area = intent.getStringExtra("area")
gardenId.text = intent.getStringExtra("gardenId")
gardenName.text = intent.getStringExtra("name")
gardenAddress.text = intent.getStringExtra("address")
gardenArea.text = intent.getStringExtra("area")
gardenArea.text = "$area Acre"
gardenPhoneNo.text = intent.getStringExtra("phoneNo")
gardenDescription.text = intent.getStringExtra("description")
gardenLocation.text = intent.getStringExtra("location")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.example.groapp.R

class GardenDetailsVolunteerViewActivity : AppCompatActivity() {
// Declare variables for the UI elements.
private lateinit var gardenId: TextView
private lateinit var gardenName: TextView
private lateinit var gardenAddress: TextView
private lateinit var gardenArea: TextView
Expand All @@ -17,8 +18,6 @@ class GardenDetailsVolunteerViewActivity : AppCompatActivity() {
private lateinit var gardenPhoneNo: TextView
private lateinit var volunteerBtn: Button

private var gardenId: Int = 0

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_garden_details_volunteer_view)
Expand All @@ -32,15 +31,16 @@ class GardenDetailsVolunteerViewActivity : AppCompatActivity() {
// Create an intent to start the volunteer register activity.
//val intent = Intent(this, VolunteerRegisterActivity::class.java) //put registration activity name here
// Add the garden ID as an extra to the intent.
intent.putExtra("gardenId", gardenId)
intent.getStringExtra("gardenId").toString()
intent.getStringExtra("name").toString()
// Start the activity with the intent.
startActivity(intent)
}

}
// Initialize the UI elements by finding them in the layout file.
private fun initView() {

gardenId = findViewById(R.id.gardenId)
gardenName = findViewById(R.id.gardenName)
gardenAddress = findViewById(R.id.gardenAddress)
gardenArea = findViewById(R.id.gardenArea)
Expand All @@ -54,7 +54,7 @@ class GardenDetailsVolunteerViewActivity : AppCompatActivity() {
// Set the values of the UI elements with data passed from the previous activity.
private fun setValuesToViews() {

gardenId = intent.getIntExtra("gardenId", 0)
gardenId.text = intent.getStringExtra("gardenId")
gardenName.text = intent.getStringExtra("gardenName")
gardenAddress.text = intent.getStringExtra("gardenAddress")
gardenArea.text = intent.getStringExtra("gardenArea")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.ImageButton
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
Expand All @@ -12,6 +13,7 @@ import com.example.groapp.Adapters.GardenAdapter
import com.example.groapp.Models.GardenModel
import com.example.groapp.R
import com.google.firebase.database.*
import kotlin.collections.ArrayList

class MyGardensActivity : AppCompatActivity() {

Expand All @@ -20,7 +22,8 @@ class MyGardensActivity : AppCompatActivity() {
private lateinit var gardenList: ArrayList<GardenModel>
private lateinit var dbRef: DatabaseReference


private lateinit var searchEditText: TextView
private lateinit var searchBtn: ImageButton

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -94,4 +97,7 @@ class MyGardensActivity : AppCompatActivity() {

})
}
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class SignUpActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sign_up)

nameBox = findViewById(R.id.name)
emailBox = findViewById(R.id.email)
passwordBox = findViewById(R.id.password)
retypePasswordBox = findViewById(R.id.retypePassword)
loginText = findViewById(R.id.AlreadyAccountLayout)
signUpBtn = findViewById(R.id.signUpBtn)
// nameBox = findViewById(R.id.name)
// emailBox = findViewById(R.id.email)
// passwordBox = findViewById(R.id.password)
// retypePasswordBox = findViewById(R.id.retypePassword)
// loginText = findViewById(R.id.AlreadyAccountLayout)
// signUpBtn = findViewById(R.id.signUpBtn)


signUpBtn.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.example.groapp.Models.GardenModel
import com.example.groapp.R

class GardenAdapter(private val gardenList: ArrayList<GardenModel>) :
class GardenAdapter(private var gardenList: ArrayList<GardenModel>) :
RecyclerView.Adapter<GardenAdapter.ViewHolder>() {

private lateinit var mListener: onItemClickListener
Expand Down Expand Up @@ -37,6 +37,7 @@ class GardenAdapter(private val gardenList: ArrayList<GardenModel>) :
return gardenList.size
}


class ViewHolder(itemView: View, clickListener: onItemClickListener) : RecyclerView.ViewHolder(itemView) {

val gardenName : TextView = itemView.findViewById(R.id.gLName)
Expand Down
Loading