Просмотр исходного кода

Cleaned up the code. There may be a bug ('vegetable' button not showing) in the filters area that Andrés and I missed.

Víctor Hernández 4 лет назад
Родитель
Сommit
274ff1cd0a
38 измененных файлов: 146 добавлений и 912 удалений
  1. 6
    0
      Floradex20/.idea/vcs.xml
  2. 4
    4
      Floradex20/app/src/main/AndroidManifest.xml
  3. 25
    25
      Floradex20/app/src/main/java/com/example/floradex20/ApiManager.kt
  4. 7
    32
      Floradex20/app/src/main/java/com/example/floradex20/activities/DiscoverActivity.kt
  5. 5
    7
      Floradex20/app/src/main/java/com/example/floradex20/activities/FilteringActivity.kt
  6. 12
    14
      Floradex20/app/src/main/java/com/example/floradex20/activities/FlowerDetailActivity.kt
  7. 5
    5
      Floradex20/app/src/main/java/com/example/floradex20/activities/LoginActivity.kt
  8. 5
    27
      Floradex20/app/src/main/java/com/example/floradex20/activities/RegisterActivity.kt
  9. 6
    7
      Floradex20/app/src/main/java/com/example/floradex20/adapters/FlowerAdapter.kt
  10. 9
    8
      Floradex20/app/src/main/java/com/example/floradex20/interfaces/RestApi.kt
  11. 4
    4
      Floradex20/app/src/main/java/com/example/floradex20/interfaces/TrefleService.kt
  12. 2
    2
      Floradex20/app/src/main/java/com/example/floradex20/models/Flower.kt
  13. 1
    1
      Floradex20/app/src/main/java/com/example/floradex20/models/FlowerLinks.kt
  14. 7
    0
      Floradex20/app/src/main/java/com/example/floradex20/models/FlowersResponse.kt
  15. 1
    1
      Floradex20/app/src/main/java/com/example/floradex20/models/FlowersResponseLinks.kt
  16. 1
    1
      Floradex20/app/src/main/java/com/example/floradex20/models/FlowersResponseMetadata.kt
  17. 0
    11
      Floradex20/app/src/main/java/com/example/floradex20/models/PlantListss.kt
  18. 11
    0
      Floradex20/app/src/main/java/com/example/floradex20/models/User.kt
  19. 0
    11
      Floradex20/app/src/main/java/com/example/floradex20/models/UserInfo.kt
  20. 22
    0
      Floradex20/app/src/main/java/com/example/floradex20/services/ServiceBuilder.kt
  21. 0
    0
      Floradex20/app/src/main/res/drawable/star_empty.png
  22. 0
    0
      Floradex20/app/src/main/res/drawable/star_filled.png
  23. 6
    3
      Floradex20/app/src/main/res/layout/activity_discover.xml
  24. 1
    1
      Floradex20/app/src/main/res/layout/activity_flower_detail.xml
  25. 0
    0
      Floradex20/app/src/main/res/layout/activity_login.xml
  26. 0
    0
      Floradex20/app/src/main/res/layout/activity_register.xml
  27. 1
    1
      Floradex20/app/src/main/res/layout/row_flower.xml
  28. 1
    7
      Floradex20/app/src/main/res/values/strings.xml
  29. 0
    23
      Planta_Display/AndroidManifest.xml
  30. 0
    81
      Planta_Display/MainActivity.kt
  31. 0
    468
      Planta_Display/Plant.kt
  32. 0
    14
      Planta_Display/TrefleService.kt
  33. 0
    73
      Planta_Display/activity_main.xml
  34. 0
    54
      Planta_Display/build.gradle
  35. 0
    9
      Planta_Display/strings.xml
  36. 0
    10
      Planta_Display/styles.xml
  37. 4
    7
      README.md
  38. 0
    1
      README2.md

+ 6
- 0
Floradex20/.idea/vcs.xml Просмотреть файл

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="VcsDirectoryMappings">
4
+    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5
+  </component>
6
+</project>

+ 4
- 4
Floradex20/app/src/main/AndroidManifest.xml Просмотреть файл

@@ -13,15 +13,15 @@
13 13
         android:theme="@style/AppTheme">
14 14
         <activity
15 15
             android:name=".activities.FilteringActivity"
16
-            android:parentActivityName=".activities.MainActivity" />
16
+            android:parentActivityName=".activities.RegisterActivity" />
17 17
         <activity
18 18
             android:name=".activities.LoginActivity"
19
-            android:parentActivityName=".activities.MainActivity" />
19
+            android:parentActivityName=".activities.RegisterActivity" />
20 20
         <activity android:name=".activities.DiscoverActivity">
21 21
 <!--            android:parentActivityName=".activities.MainActivity">-->
22 22
 
23 23
         </activity>
24
-        <activity android:name=".activities.MainActivity">
24
+        <activity android:name=".activities.RegisterActivity">
25 25
             <intent-filter>
26 26
                 <action android:name="android.intent.action.MAIN" />
27 27
 
@@ -29,7 +29,7 @@
29 29
             </intent-filter>
30 30
         </activity>
31 31
         <activity
32
-            android:name=".activities.VentantaActivity"
32
+            android:name=".activities.FlowerDetailActivity"
33 33
             android:parentActivityName=".activities.DiscoverActivity">
34 34
 
35 35
 

+ 25
- 25
Floradex20/app/src/main/java/com/example/floradex20/ApiManager.kt Просмотреть файл

@@ -1,11 +1,10 @@
1 1
 package com.example.floradex20
2 2
 
3 3
 import android.view.View
4
-import com.example.floradex20.activities.ServiceBuilder
5 4
 import com.example.floradex20.interfaces.RestApi
6
-import com.example.floradex20.interfaces.TrefleService
7
-import com.example.floradex20.models.PlantListss
8
-import com.example.floradex20.models.UserInfo
5
+import com.example.floradex20.models.FlowersResponse
6
+import com.example.floradex20.models.User
7
+import com.example.floradex20.services.ServiceBuilder
9 8
 import com.google.android.material.snackbar.Snackbar
10 9
 import org.json.JSONObject
11 10
 import retrofit2.Call
@@ -15,13 +14,13 @@ import retrofit2.Response
15 14
 class ApiManager(val parent: View) {
16 15
 
17 16
 
18
-    fun addUser(userData: UserInfo, onResult: (UserInfo?) -> Unit){
17
+    fun addUser(userData: User, onResult: (User?) -> Unit){
19 18
         val retrofit = ServiceBuilder.buildService(RestApi::class.java)
20
-        retrofit.addUser(userData).enqueue(object: Callback<UserInfo> {
21
-            override fun onFailure(call: Call<UserInfo>, t: Throwable) {
19
+        retrofit.addUser(userData).enqueue(object: Callback<User> {
20
+            override fun onFailure(call: Call<User>, t: Throwable) {
22 21
                 Snackbar.make(parent, "${t.message}", Snackbar.LENGTH_SHORT).show()
23 22
             }
24
-            override fun onResponse(call: Call<UserInfo>, response: Response<UserInfo>) {
23
+            override fun onResponse(call: Call<User>, response: Response<User>) {
25 24
                 if(response.code() == 500 || response.code() == 400) {
26 25
                     val responseString = response.errorBody()!!.string()
27 26
                     val message = JSONObject(responseString).getString("error")
@@ -34,13 +33,13 @@ class ApiManager(val parent: View) {
34 33
     }
35 34
 
36 35
 
37
-    fun logInUser(userData: UserInfo, onResult: (UserInfo?) -> Unit) {
36
+    fun logInUser(userData: User, onResult: (User?) -> Unit) {
38 37
         val retrofit = ServiceBuilder.buildService(RestApi::class.java)
39
-        retrofit.logInUser(userData).enqueue(object: Callback<UserInfo> {
40
-            override fun onFailure(call: Call<UserInfo>, t: Throwable) {
38
+        retrofit.logInUser(userData).enqueue(object: Callback<User> {
39
+            override fun onFailure(call: Call<User>, t: Throwable) {
41 40
                 Snackbar.make(parent, "${t.message}", Snackbar.LENGTH_SHORT).show()
42 41
             }
43
-            override fun onResponse(call: Call<UserInfo>, response: Response<UserInfo>) {
42
+            override fun onResponse(call: Call<User>, response: Response<User>) {
44 43
 
45 44
                 if(response.code() == 500 || response.code() == 400) {
46 45
                     val responseString = response.errorBody()!!.string()
@@ -54,13 +53,13 @@ class ApiManager(val parent: View) {
54 53
     }
55 54
 
56 55
 
57
-    fun getPlants(user_id: String, onResult: (PlantListss) -> Unit) {
56
+    fun getPlants(user_id: String, onResult: (FlowersResponse) -> Unit) {
58 57
         val request = ServiceBuilder.buildService(RestApi::class.java)
59
-        request.getPlants(user_id).enqueue(object: Callback<PlantListss> {
60
-            override fun onFailure(call: Call<PlantListss>, t: Throwable) {
58
+        request.getPlants(user_id).enqueue(object: Callback<FlowersResponse> {
59
+            override fun onFailure(call: Call<FlowersResponse>, t: Throwable) {
61 60
                 Snackbar.make(parent, "${t.message}", Snackbar.LENGTH_SHORT).show()
62 61
             }
63
-            override fun onResponse(call: Call<PlantListss>, response: Response<PlantListss>) {
62
+            override fun onResponse(call: Call<FlowersResponse>, response: Response<FlowersResponse>) {
64 63
                 if (response.code() == 500 || response.code() == 400) {
65 64
                     val responseString = response.errorBody()!!.string()
66 65
                     val message = JSONObject(responseString).getString("error")
@@ -72,13 +71,14 @@ class ApiManager(val parent: View) {
72 71
         })
73 72
     }
74 73
 
75
-    fun getPlantsByName(user_id: String, search_input: String, onResult: (PlantListss) -> Unit) {
74
+
75
+    fun getPlantsByName(user_id: String, search_input: String, onResult: (FlowersResponse) -> Unit) {
76 76
         val request = ServiceBuilder.buildService(RestApi::class.java)
77
-        request.getPlantsbyName(user_id, search_input).enqueue(object: Callback<PlantListss> {
78
-            override fun onFailure(call: Call<PlantListss>, t: Throwable) {
77
+        request.getPlantsbyName(user_id, search_input).enqueue(object: Callback<FlowersResponse> {
78
+            override fun onFailure(call: Call<FlowersResponse>, t: Throwable) {
79 79
                 Snackbar.make(parent, "${t.message}", Snackbar.LENGTH_SHORT).show()
80 80
             }
81
-            override fun onResponse(call: Call<PlantListss>, response: Response<PlantListss>) {
81
+            override fun onResponse(call: Call<FlowersResponse>, response: Response<FlowersResponse>) {
82 82
                 if (response.code() == 500 || response.code() == 400) {
83 83
                     val responseString = response.errorBody()!!.string()
84 84
                     val message = JSONObject(responseString).getString("error")
@@ -90,13 +90,14 @@ class ApiManager(val parent: View) {
90 90
         })
91 91
     }
92 92
 
93
-    fun getFiltered(user_id: String, edible: String, vegetable: String, color: String, scientificName: String, onResult: (PlantListss) -> Unit) {
93
+
94
+    fun getFiltered(user_id: String, edible: String, vegetable: String, color: String, scientificName: String, onResult: (FlowersResponse) -> Unit) {
94 95
         val request = ServiceBuilder.buildService(RestApi::class.java)
95
-        request.getFiltered(user_id, edible, vegetable, color, scientificName).enqueue(object: Callback<PlantListss> {
96
-            override fun onFailure(call: Call<PlantListss>, t: Throwable) {
96
+        request.getFiltered(user_id, edible, vegetable, color, scientificName).enqueue(object: Callback<FlowersResponse> {
97
+            override fun onFailure(call: Call<FlowersResponse>, t: Throwable) {
97 98
                 Snackbar.make(parent, "${t.message}", Snackbar.LENGTH_SHORT).show()
98 99
             }
99
-            override fun onResponse(call: Call<PlantListss>, response: Response<PlantListss>) {
100
+            override fun onResponse(call: Call<FlowersResponse>, response: Response<FlowersResponse>) {
100 101
                 if (response.code() == 500 || response.code() == 400) {
101 102
                     val responseString = response.errorBody()!!.string()
102 103
                     val message = JSONObject(responseString).getString("error")
@@ -109,5 +110,4 @@ class ApiManager(val parent: View) {
109 110
     }
110 111
 
111 112
 
112
-
113 113
 }

+ 7
- 32
Floradex20/app/src/main/java/com/example/floradex20/activities/DiscoverActivity.kt Просмотреть файл

@@ -15,37 +15,12 @@ import androidx.recyclerview.widget.LinearLayoutManager
15 15
 import androidx.recyclerview.widget.RecyclerView
16 16
 import com.example.floradex20.ApiManager
17 17
 import com.example.floradex20.R
18
-import com.example.floradex20.models.Data
19
-
20
-
21
-//Cosas para que lleguen las flores
22
-//private const val TOKEN: String = "cMyugCJvk-U_xoi31FVBgoEqZiuRnDYpP8fv8Vfiejg"
23
-//private const val  BASE_URL = "https://trefle.io/"
24
-//var slug: String = "prunella-vulgaris"
25
-//private const val ada_link = "https://ada.uprrp.edu/"
26
-//Creo que mas cosas para que lleguen las flores
27
-//object ServiceBuilder {
28
-//
29
-//    val client = OkHttpClient.Builder().build()
30
-//
31
-//    var retrofit: Retrofit = Retrofit.Builder()
32
-//            .baseUrl(ada_link)
33
-//            .addConverterFactory(GsonConverterFactory.create())
34
-//            .client(client)
35
-//            .build()
36
-//
37
-//    fun <T> buildService(service: Class<T>): T {
38
-//        return retrofit.create(service)
39
-//    }
40
-//}
41
-
42
-
43
-//Main Activity
18
+import com.example.floradex20.adapters.FlowerAdapter
19
+import com.example.floradex20.models.Flower
20
+
44 21
 class DiscoverActivity : AppCompatActivity(), FlowerAdapter.OnItemClickListener {
45 22
     private lateinit var recyclerView: RecyclerView
46
-    private lateinit var plants: List<Data>
47
-
48
-    var search_input: String = ""     //Guarda search input de user
23
+    private lateinit var plants: List<Flower>
49 24
 
50 25
 
51 26
     //Para desplegar el boton de filtro en Discover Page
@@ -57,7 +32,7 @@ class DiscoverActivity : AppCompatActivity(), FlowerAdapter.OnItemClickListener
57 32
 
58 33
     override fun onCreate(savedInstanceState: Bundle?) {
59 34
         super.onCreate(savedInstanceState)
60
-        setContentView(R.layout.discover_activity)
35
+        setContentView(R.layout.activity_discover)
61 36
 
62 37
         //Donde se guarda el input del search bar y el search button
63 38
         val enterButton = findViewById<Button>(R.id.search_enter)
@@ -90,7 +65,7 @@ class DiscoverActivity : AppCompatActivity(), FlowerAdapter.OnItemClickListener
90 65
         //Esto se ejecuta cuando el usuario hace un search con el search bar
91 66
         enterButton?.setOnClickListener {
92 67
 
93
-            search_input = input.text.toString()
68
+            val search_input = input.text.toString()
94 69
 
95 70
             apimanager.getPlantsByName(userID, search_input) {
96 71
 
@@ -114,7 +89,7 @@ class DiscoverActivity : AppCompatActivity(), FlowerAdapter.OnItemClickListener
114 89
         //Empezar el activity de Jose
115 90
         val plantInfo = arrayOf<String>(plants[position].common_name.toString(), plants[position].scientific_name.toString()
116 91
                 , plants[position].year.toString(), plants[position].author.toString(), plants[position].image_url.toString())
117
-        val intent = Intent(this, VentantaActivity::class.java).apply {
92
+        val intent = Intent(this, FlowerDetailActivity::class.java).apply {
118 93
             putExtra("plant_info", plantInfo)
119 94
         }
120 95
         startActivity(intent)

+ 5
- 7
Floradex20/app/src/main/java/com/example/floradex20/activities/FilteringActivity.kt Просмотреть файл

@@ -28,25 +28,23 @@ class FilteringActivity : AppCompatActivity() {
28 28
         var nom_cientifico: String = ""
29 29
         var color_flor: String = ""
30 30
 
31
-        edibleToggle.setOnCheckedChangeListener{ _, isChecked ->
31
+        edibleToggle.setOnCheckedChangeListener{_, isChecked ->
32 32
             if (isChecked){
33 33
                 edible = "true"
34
-            }
35
-            else{
34
+            } else {
36 35
                 edible = "false"
37 36
             }
38 37
         }
39
-        vegetableToggle.setOnCheckedChangeListener{ _, isChecked ->
38
+        vegetableToggle.setOnCheckedChangeListener{_, isChecked ->
40 39
             if (isChecked){
41 40
                 vegetable = "true"
42
-            }
43
-            else{
41
+            } else {
44 42
                 vegetable = "false"
45 43
             }
46 44
         }
47 45
 
48 46
         //Cuando usuario le da apply se envia los filter values a main activity
49
-        apply.setOnClickListener(){
47
+        apply.setOnClickListener {
50 48
 
51 49
             color_flor = colorTxt.text.toString()
52 50
             nom_cientifico = sciTxt.text.toString()

Floradex20/app/src/main/java/com/example/floradex20/activities/VentantaActivity.kt → Floradex20/app/src/main/java/com/example/floradex20/activities/FlowerDetailActivity.kt Просмотреть файл

@@ -8,12 +8,11 @@ import androidx.appcompat.app.AppCompatActivity
8 8
 import com.example.floradex20.R
9 9
 import com.squareup.picasso.Picasso
10 10
 
11
-class VentantaActivity(): AppCompatActivity() {
11
+class FlowerDetailActivity : AppCompatActivity() {
12 12
 
13
-//    val planta:Data = plant
14 13
     override fun onCreate(savedInstanceState: Bundle?) {
15 14
         super.onCreate(savedInstanceState)
16
-        setContentView(R.layout.ventanita)
15
+        setContentView(R.layout.activity_flower_detail)
17 16
 
18 17
         val plant = intent.getStringArrayExtra("plant_info")
19 18
 
@@ -25,19 +24,18 @@ class VentantaActivity(): AppCompatActivity() {
25 24
 
26 25
         nom_planta.text = "Salu2"
27 26
 
28
-    if (plant != null) {
27
+        if (plant != null) {
29 28
 
30
-        nom_planta.text = plant.get(0)
31
-        nom_sci.text = plant.get(1)
32
-        year.text = plant.get(2)
33
-        author.text = plant.get(3)
34
-        Picasso.get().load(plant.get(4)).into(imagen_planta)
35
-    }
36
-
37
-    else {
38
-        Log.i("Desde ventana kt", "Llega null el valor. Te la mamaste")
39
-    }
29
+            nom_planta.text = plant.get(0)
30
+            nom_sci.text = plant.get(1)
31
+            year.text = plant.get(2)
32
+            author.text = plant.get(3)
33
+            Picasso.get().load(plant.get(4)).into(imagen_planta)
34
+        }
40 35
 
36
+        else {
37
+            Log.i("Desde ventana kt", "Llega null el valor. Te la mamaste")
38
+        }
41 39
 
42 40
     }
43 41
 }

+ 5
- 5
Floradex20/app/src/main/java/com/example/floradex20/activities/LoginActivity.kt Просмотреть файл

@@ -10,7 +10,7 @@ import android.widget.TextView
10 10
 import androidx.appcompat.app.AppCompatActivity
11 11
 import com.example.floradex20.ApiManager
12 12
 import com.example.floradex20.R
13
-import com.example.floradex20.models.UserInfo
13
+import com.example.floradex20.models.User
14 14
 //import com.example.login.ApiManager
15 15
 //import com.example.login.UserInfo
16 16
 import com.google.android.material.snackbar.Snackbar
@@ -19,7 +19,7 @@ class LoginActivity: AppCompatActivity() {
19 19
 
20 20
     override fun onCreate(savedInstanceState: Bundle?) {
21 21
         super.onCreate(savedInstanceState)
22
-        setContentView(R.layout.login)
22
+        setContentView(R.layout.activity_login)
23 23
 
24 24
 
25 25
         val b: Button
@@ -47,7 +47,7 @@ class LoginActivity: AppCompatActivity() {
47 47
 
48 48
 
49 49
             //Hasta aqui funciona
50
-            val user_info = UserInfo(null, user_email, user_password, null, null)
50
+            val user_info = User(null, user_email, user_password, null, null)
51 51
             val apimanager = ApiManager(it)
52 52
             val thisActivity = it
53 53
 //            user_info.user_email?.let { it1 -> Log.i("check instance info", it1) }
@@ -69,11 +69,11 @@ class LoginActivity: AppCompatActivity() {
69 69
                     ).setAction("Action", null).show()
70 70
 
71 71
                     val user_id: String? = it?.id
72
-//                    val user_name: String? = it?.user_name
72
+//                    val user_name: String? = it?.username
73 73
                     val sharedPref: SharedPreferences = applicationContext.getSharedPreferences("user_info", Context.MODE_PRIVATE)
74 74
                     val editor = sharedPref.edit()
75 75
                     editor.putString("user_id", user_id)
76
-//                    editor.putString("user_name", user_name)
76
+//                    editor.putString("user_name", username)
77 77
                     editor.apply()
78 78
 
79 79
 

Floradex20/app/src/main/java/com/example/floradex20/activities/MainActivity.kt → Floradex20/app/src/main/java/com/example/floradex20/activities/RegisterActivity.kt Просмотреть файл

@@ -10,37 +10,15 @@ import android.widget.TextView
10 10
 import androidx.appcompat.app.AppCompatActivity
11 11
 import com.example.floradex20.ApiManager
12 12
 import com.example.floradex20.R
13
-import com.example.floradex20.models.UserInfo
13
+import com.example.floradex20.models.User
14 14
 import com.google.android.material.snackbar.Snackbar
15
-import okhttp3.OkHttpClient
16
-import retrofit2.Retrofit
17
-import retrofit2.converter.gson.GsonConverterFactory
18 15
 
19
-
20
-private const val ada_link = "https://ada.uprrp.edu/"
21
-
22
-object ServiceBuilder {
23
-    private val client = OkHttpClient.Builder().build()
24
-
25
-    private val retrofit = Retrofit.Builder()
26
-            .baseUrl(ada_link) // change this IP for testing by your actual machine IP
27
-
28
-            .addConverterFactory(GsonConverterFactory.create())
29
-            .client(client)
30
-            .build()
31
-
32
-    fun<T> buildService(service: Class<T>): T{
33
-        return retrofit.create(service)
34
-    }
35
-}
36
-
37
-class MainActivity() : AppCompatActivity() {
16
+class RegisterActivity : AppCompatActivity() {
38 17
 
39 18
     override fun onCreate(savedInstanceState: Bundle?) {
40 19
 
41
-
42 20
         super.onCreate(savedInstanceState)
43
-        setContentView(R.layout.register)
21
+        setContentView(R.layout.activity_register)
44 22
 
45 23
         val sharedPref: SharedPreferences = applicationContext.getSharedPreferences("user_info", Context.MODE_PRIVATE)
46 24
 
@@ -92,7 +70,7 @@ class MainActivity() : AppCompatActivity() {
92 70
             //Manda el info a la base de datos
93 71
             else {
94 72
 
95
-                val user_info = UserInfo(full_name, user_email, user_password, null, null)
73
+                val user_info = User(full_name, user_email, user_password, null, null)
96 74
                 val apimanager = ApiManager(it)
97 75
                 val thisActivity = it
98 76
 
@@ -106,7 +84,7 @@ class MainActivity() : AppCompatActivity() {
106 84
 
107 85
                     //Se guarda el username y id
108 86
                     val user_id: String? = it?.id
109
-                    val user_name: String? = it?.user_name
87
+                    val user_name: String? = it?.username
110 88
                     val sharedPref: SharedPreferences = applicationContext.getSharedPreferences("user_info", Context.MODE_PRIVATE)
111 89
                     val editor = sharedPref.edit()
112 90
                     editor.putString("user_id", user_id)

Floradex20/app/src/main/java/com/example/floradex20/activities/FlowerAdapter.kt → Floradex20/app/src/main/java/com/example/floradex20/adapters/FlowerAdapter.kt Просмотреть файл

@@ -1,4 +1,4 @@
1
-package com.example.floradex20.activities
1
+package com.example.floradex20.adapters
2 2
 
3 3
 import android.view.LayoutInflater
4 4
 import android.view.View
@@ -7,17 +7,16 @@ import android.widget.ImageView
7 7
 import android.widget.TextView
8 8
 import androidx.recyclerview.widget.RecyclerView
9 9
 import com.example.floradex20.R
10
-import com.example.floradex20.models.Data
10
+import com.example.floradex20.models.Flower
11 11
 import com.squareup.picasso.Picasso
12 12
 
13
-
14
-class FlowerAdapter(val flowers: List<Data>, private val listener: OnItemClickListener): RecyclerView.Adapter<FlowerAdapter.PlantViewHolder>() {
13
+class FlowerAdapter(val flowers: List<Flower>, private val listener: OnItemClickListener): RecyclerView.Adapter<FlowerAdapter.PlantViewHolder>() {
15 14
 
16 15
 //    var listen: onItemClickListener
17 16
 //    this.listen = listener
18 17
 //    val listen:OnItemClickListener = listener
19 18
     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlantViewHolder {
20
-        val view = LayoutInflater.from(parent.context).inflate(R.layout.layout, parent, false)
19
+        val view = LayoutInflater.from(parent.context).inflate(R.layout.row_flower, parent, false)
21 20
         return PlantViewHolder(view)
22 21
     }
23 22
 
@@ -48,7 +47,7 @@ class FlowerAdapter(val flowers: List<Data>, private val listener: OnItemClickLi
48 47
 
49 48
         }
50 49
 
51
-        fun bind(plant: Data, plantviewer: PlantViewHolder) {
50
+        fun bind(plant: Flower, plantviewer: PlantViewHolder) {
52 51
             //Pone foto y nombre de la planta a la tarjeta
53 52
             val imageurl: String = plant.image_url
54 53
             Picasso.get().load(imageurl).into(photo)
@@ -60,7 +59,7 @@ class FlowerAdapter(val flowers: List<Data>, private val listener: OnItemClickLi
60 59
 
61 60
     }
62 61
 
63
-    public interface OnItemClickListener {
62
+    interface OnItemClickListener {
64 63
 
65 64
         //Metodo que va a usar el activity pa hacer cosas
66 65
         fun onItemClick(position: Int)

+ 9
- 8
Floradex20/app/src/main/java/com/example/floradex20/interfaces/RestApi.kt Просмотреть файл

@@ -1,7 +1,7 @@
1 1
 package com.example.floradex20.interfaces
2 2
 
3
-import com.example.floradex20.models.PlantListss
4
-import com.example.floradex20.models.UserInfo
3
+import com.example.floradex20.models.FlowersResponse
4
+import com.example.floradex20.models.User
5 5
 import retrofit2.Call
6 6
 import retrofit2.http.*
7 7
 
@@ -9,28 +9,29 @@ interface RestApi {
9 9
 
10 10
     @Headers("Content-Type: application/json")
11 11
     @POST("~victor.hernandez17/flowerdex/signup.php")
12
-    fun addUser(@Body userData: UserInfo): Call<UserInfo>
12
+    fun addUser(@Body userData: User): Call<User>
13 13
 
14 14
     @Headers("Content-Type: application/json")
15 15
     @POST("~victor.hernandez17/flowerdex/login.php")
16
-    fun logInUser(@Body UserData: UserInfo): Call<UserInfo>
16
+    fun logInUser(@Body userData: User): Call<User>
17 17
 
18 18
 
19 19
     @GET("~victor.hernandez17/flowerdex/listFlowers.php") // /api/v1/plants/
20 20
     //Quite el id de la planta para recibir mas cosas
21 21
     //Posiblemente se puede overload la funcion para q funcione sin id y con id
22
-    fun getPlants(@Query("user_id") user_id: String): Call<PlantListss>
22
+    fun getPlants(@Query("user_id") user_id: String): Call<FlowersResponse>
23 23
 
24 24
     //El Api Query que se usa cuando se hace un search
25 25
     @GET("~victor.hernandez17/flowerdex/listFlowers.php") // /api/v1/plants/search/
26 26
     fun getPlantsbyName(@Query("user_id") user_id: String,
27
-                        @Query("q") q: String): Call<PlantListss>
27
+                        @Query("q") q: String): Call<FlowersResponse>
28 28
 
29 29
     //Api query para el filter
30 30
     @GET("~victor.hernandez17/flowerdex/listFlowers.php") // api/v1/plants/
31 31
     fun getFiltered(@Query("user_id") user_id: String,
32 32
                     @Query("edible") edible: String,
33 33
                     @Query("vegetable") vegetable: String,
34
-                    @Query("flower_color") color: String,
35
-                    @Query("scientific_name") scientificName: String): Call<PlantListss>
34
+                    @Query("flower_color") color: String, // TODO: get rid of this, as it it's not used by ADA
35
+                    @Query("scientific_name") scientificName: String): Call<FlowersResponse>
36
+    
36 37
 }

+ 4
- 4
Floradex20/app/src/main/java/com/example/floradex20/interfaces/TrefleService.kt Просмотреть файл

@@ -1,6 +1,6 @@
1 1
 package com.example.floradex20.interfaces
2 2
 
3
-import com.example.floradex20.models.PlantListss
3
+import com.example.floradex20.models.FlowersResponse
4 4
 import retrofit2.Call
5 5
 import retrofit2.http.GET
6 6
 import retrofit2.http.Query
@@ -9,12 +9,12 @@ interface TrefleService {
9 9
     @GET("/api/v1/plants/")
10 10
     //Quite el id de la planta para recibir mas cosas
11 11
     //Posiblemente se puede overload la funcion para q funcione sin id y con id
12
-    fun getPlants(@Query("token") token: String): Call<PlantListss>
12
+    fun getPlants(@Query("token") token: String): Call<FlowersResponse>
13 13
 
14 14
     //El Api Query que se usa cuando se hace un search
15 15
     @GET("/api/v1/plants/search/")
16 16
     fun getPlantsbyName(@Query("token") token: String,
17
-                        @Query("q") q: String): Call<PlantListss>
17
+                        @Query("q") q: String): Call<FlowersResponse>
18 18
 
19 19
     //Api query para el filter
20 20
     @GET("api/v1/plants/")
@@ -22,7 +22,7 @@ interface TrefleService {
22 22
                     @Query("filter[edible]") edible: String,
23 23
                     @Query("filter[vegetable]") vegetable: String,
24 24
                     @Query("filter[flower_color]") color: String,
25
-                    @Query("filter[scientific_name]") cien_name: String): Call<PlantListss>
25
+                    @Query("filter[scientific_name]") cien_name: String): Call<FlowersResponse>
26 26
 }
27 27
 
28 28
 //@Query("filter[id]") id: Int

Floradex20/app/src/main/java/com/example/floradex20/models/Data.kt → Floradex20/app/src/main/java/com/example/floradex20/models/Flower.kt Просмотреть файл

@@ -1,6 +1,6 @@
1 1
 package com.example.floradex20.models
2 2
 
3
-data class Data(
3
+data class Flower (
4 4
     val author: String,
5 5
     val bibliography: String,
6 6
     val common_name: String,
@@ -10,7 +10,7 @@ data class Data(
10 10
     val genus_id: Int,
11 11
     val id: Int,
12 12
     val image_url: String,
13
-    val links: Links,
13
+    val links: FlowerLinks,
14 14
     val rank: String,
15 15
     val scientific_name: String,
16 16
     val slug: String,

Floradex20/app/src/main/java/com/example/floradex20/models/Links.kt → Floradex20/app/src/main/java/com/example/floradex20/models/FlowerLinks.kt Просмотреть файл

@@ -1,6 +1,6 @@
1 1
 package com.example.floradex20.models
2 2
 
3
-data class Links(
3
+data class FlowerLinks (
4 4
     val genus: String,
5 5
     val plant: String,
6 6
     val self: String

+ 7
- 0
Floradex20/app/src/main/java/com/example/floradex20/models/FlowersResponse.kt Просмотреть файл

@@ -0,0 +1,7 @@
1
+package com.example.floradex20.models
2
+
3
+data class FlowersResponse (
4
+    val `data`: List<Flower>,
5
+    val links: FlowersResponseLinks,
6
+    val meta: FlowersResponseMetadata
7
+)

Floradex20/app/src/main/java/com/example/floradex20/models/LinksX.kt → Floradex20/app/src/main/java/com/example/floradex20/models/FlowersResponseLinks.kt Просмотреть файл

@@ -1,6 +1,6 @@
1 1
 package com.example.floradex20.models
2 2
 
3
-data class LinksX(
3
+data class FlowersResponseLinks (
4 4
     val first: String,
5 5
     val last: String,
6 6
     val next: String,

Floradex20/app/src/main/java/com/example/floradex20/models/Meta.kt → Floradex20/app/src/main/java/com/example/floradex20/models/FlowersResponseMetadata.kt Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 package com.example.floradex20.models
2 2
 
3
-data class Meta(
3
+data class FlowersResponseMetadata (
4 4
     val total: Int
5 5
 )

+ 0
- 11
Floradex20/app/src/main/java/com/example/floradex20/models/PlantListss.kt Просмотреть файл

@@ -1,11 +0,0 @@
1
-package com.example.floradex20.models
2
-
3
-import com.example.floradex20.models.Data
4
-import com.example.floradex20.models.LinksX
5
-import com.example.floradex20.models.Meta
6
-
7
-data class PlantListss(
8
-    val `data`: List<Data>,
9
-    val links: LinksX,
10
-    val meta: Meta
11
-)

+ 11
- 0
Floradex20/app/src/main/java/com/example/floradex20/models/User.kt Просмотреть файл

@@ -0,0 +1,11 @@
1
+package com.example.floradex20.models
2
+
3
+import com.google.gson.annotations.SerializedName
4
+
5
+data class User (
6
+   @SerializedName("username") val username: String?,
7
+   @SerializedName("email") val email: String?,
8
+   @SerializedName("password") val password: String?,
9
+   @SerializedName("id") val id: String?,
10
+   @SerializedName("error") val error: String?
11
+)

+ 0
- 11
Floradex20/app/src/main/java/com/example/floradex20/models/UserInfo.kt Просмотреть файл

@@ -1,11 +0,0 @@
1
-package com.example.floradex20.models
2
-
3
-import com.google.gson.annotations.SerializedName
4
-
5
-data class UserInfo (
6
-        @SerializedName("username") val user_name: String?,
7
-        @SerializedName("email") val user_email: String?,
8
-        @SerializedName("password") val user_password: String?,
9
-        @SerializedName("id") val id: String?,
10
-        @SerializedName("error") val error: String?
11
-)

+ 22
- 0
Floradex20/app/src/main/java/com/example/floradex20/services/ServiceBuilder.kt Просмотреть файл

@@ -0,0 +1,22 @@
1
+package com.example.floradex20.services
2
+
3
+import okhttp3.OkHttpClient
4
+import retrofit2.Retrofit
5
+import retrofit2.converter.gson.GsonConverterFactory
6
+
7
+private const val TOKEN_ANDRES: String = "cMyugCJvk-U_xoi31FVBgoEqZiuRnDYpP8fv8Vfiejg"
8
+private const val BASE_URL = "https://ada.uprrp.edu/" // "https://trefle.io/"
9
+
10
+object ServiceBuilder {
11
+    private val client = OkHttpClient.Builder().build()
12
+
13
+    private val retrofit = Retrofit.Builder()
14
+        .baseUrl(BASE_URL)
15
+        .addConverterFactory(GsonConverterFactory.create())
16
+        .client(client)
17
+        .build()
18
+
19
+    fun<T> buildService(service: Class<T>): T{
20
+        return retrofit.create(service)
21
+    }
22
+}

Floradex20/app/src/main/res/drawable/star.png → Floradex20/app/src/main/res/drawable/star_empty.png Просмотреть файл


Floradex20/app/src/main/res/drawable/star_1.png → Floradex20/app/src/main/res/drawable/star_filled.png Просмотреть файл


Floradex20/app/src/main/res/layout/discover_activity.xml → Floradex20/app/src/main/res/layout/activity_discover.xml Просмотреть файл

@@ -5,7 +5,7 @@
5 5
     android:id="@+id/discover_activity"
6 6
     android:layout_width="match_parent"
7 7
     android:layout_height="match_parent"
8
-    tools:context=".activities.MainActivity">
8
+    tools:context=".activities.RegisterActivity">
9 9
 
10 10
 
11 11
     <Button
@@ -37,8 +37,11 @@
37 37
         android:layout_width="wrap_content"
38 38
         android:layout_height="wrap_content"
39 39
         android:layout_centerHorizontal="true"
40
-        android:layout_margin="20dp"
41
-        android:text="Floradex"
40
+        android:layout_marginStart="20dp"
41
+        android:layout_marginTop="20dp"
42
+        android:layout_marginEnd="20dp"
43
+        android:layout_marginBottom="20dp"
44
+        android:text="Flowerdex"
42 45
         android:textSize="20sp" />
43 46
 
44 47
     <androidx.recyclerview.widget.RecyclerView

Floradex20/app/src/main/res/layout/ventanita.xml → Floradex20/app/src/main/res/layout/activity_flower_detail.xml Просмотреть файл

@@ -6,7 +6,7 @@
6 6
     android:id="@+id/Plant_info"
7 7
     android:layout_width="match_parent"
8 8
     android:layout_height="match_parent"
9
-    tools:context=".activities.MainActivity">
9
+    tools:context=".activities.RegisterActivity">
10 10
 
11 11
     <TextView
12 12
         android:id="@+id/author"

Floradex20/app/src/main/res/layout/login.xml → Floradex20/app/src/main/res/layout/activity_login.xml Просмотреть файл


Floradex20/app/src/main/res/layout/register.xml → Floradex20/app/src/main/res/layout/activity_register.xml Просмотреть файл


Floradex20/app/src/main/res/layout/layout.xml → Floradex20/app/src/main/res/layout/row_flower.xml Просмотреть файл

@@ -43,7 +43,7 @@
43 43
                 android:layout_alignParentEnd="true"
44 44
                 android:layout_marginTop="21dp"
45 45
                 android:layout_marginEnd="332dp"
46
-                app:srcCompat="@drawable/star" />
46
+                app:srcCompat="@drawable/star_empty" />
47 47
 
48 48
 
49 49
         </RelativeLayout>

+ 1
- 7
Floradex20/app/src/main/res/values/strings.xml Просмотреть файл

@@ -1,11 +1,10 @@
1 1
 <resources>
2
-    <string name="app_name">Floradex20</string>
2
+    <string name="app_name">Flowerdex</string>
3 3
     <string name="TOKEN">-wNgf1Lzwh__BwM_7iGot107arhbUbkFtFsCWtZI8lY</string>
4 4
 
5 5
     <string name="BASE_URL">"https://trefle.io/"</string>
6 6
 
7 7
     <string name="plant_name">Plant Name</string>
8
-    <string name="testuri">TestUri</string>
9 8
     <string name="scientific_name">Scientific Name</string>
10 9
     <string name="year">Year</string>
11 10
     <string name="author">Author</string>
@@ -20,13 +19,8 @@
20 19
     <string name="not_vegetable">Not Vegetable</string>
21 20
     <string name="vegetable">Vegetable</string>
22 21
     <string name="apply">Apply</string>
23
-    <string name="hello_blank_fragment">Hello blank fragment</string>
24
-    <string name="swipe_left_for_register">Swipe Left for Register</string>
25
-    <string name="login">Login</string>
26 22
     <string name="password">Password</string>
27 23
     <string name="e_mail">Email</string>
28
-    <string name="tag">Lets look at flowers</string>
29
-    <string name="swipe_right_for_login">Swipe Right for Login</string>
30 24
     <string name="register">Register</string>
31 25
     <string name="re_type_password">Re-type Password</string>
32 26
     <string name="your_name">Full Name</string>

+ 0
- 23
Planta_Display/AndroidManifest.xml Просмотреть файл

@@ -1,23 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
-    package="com.example.trefletest">
4
-
5
-    <uses-permission android:name="android.permission.INTERNET"/>
6
-
7
-    <application
8
-        android:allowBackup="true"
9
-        android:icon="@mipmap/ic_launcher"
10
-        android:label="@string/app_name"
11
-        android:roundIcon="@mipmap/ic_launcher_round"
12
-        android:supportsRtl="true"
13
-        android:theme="@style/AppTheme">
14
-        <activity android:name=".MainActivity">
15
-            <intent-filter>
16
-                <action android:name="android.intent.action.MAIN" />
17
-
18
-                <category android:name="android.intent.category.LAUNCHER" />
19
-            </intent-filter>
20
-        </activity>
21
-    </application>
22
-
23
-</manifest>

+ 0
- 81
Planta_Display/MainActivity.kt Просмотреть файл

@@ -1,81 +0,0 @@
1
-package com.example.trefletest
2
-
3
-import android.os.Bundle
4
-import android.widget.ImageView
5
-import android.widget.TextView
6
-import android.widget.Toast
7
-import androidx.appcompat.app.AppCompatActivity
8
-import com.example.trefletest.models.Plant
9
-import com.squareup.picasso.Picasso
10
-import okhttp3.OkHttpClient
11
-import retrofit2.Call
12
-import retrofit2.Callback
13
-import retrofit2.Response
14
-import retrofit2.Retrofit
15
-import retrofit2.converter.gson.GsonConverterFactory
16
-
17
-private const val TOKEN = "cMyugCJvk-U_xoi31FVBgoEqZiuRnDYpP8fv8Vfiejg"
18
-private const val  BASE_URL = "https://trefle.io/"
19
-var slug: String = "prunella-vulgaris"
20
-
21
-object ServiceBuilder {
22
-
23
-    val client = OkHttpClient.Builder().build()
24
-
25
-    var retrofit: Retrofit = Retrofit.Builder()
26
-        .baseUrl(BASE_URL)
27
-        .addConverterFactory(GsonConverterFactory.create())
28
-        .client(client)
29
-        .build()
30
-
31
-    fun <T> buildService(service: Class<T>): T {
32
-        return retrofit.create(service)
33
-    }
34
-}
35
-
36
-class MainActivity : AppCompatActivity() {
37
-    override fun onCreate(savedInstanceState: Bundle?) {
38
-        super.onCreate(savedInstanceState)
39
-        setContentView(R.layout.activity_main)
40
-        val nom_planta = findViewById(R.id.plant_name) as TextView
41
-        //val uri_test = findViewById(R.id.uri) as TextView   Por si acaso
42
-        val nom_sci = findViewById(R.id.sci_name) as TextView
43
-        val year = findViewById(R.id.year) as TextView
44
-        val author = findViewById(R.id.author) as TextView
45
-        val imagen_planta = findViewById(R.id.plantview) as ImageView
46
-
47
-        nom_planta.text = ("Loading...")
48
-        nom_sci.text = ("Loading...")
49
-        year.text = ("Loading...")
50
-        author.text = ("Loading...")
51
-
52
-        val request = ServiceBuilder.buildService(TrefleService::class.java)
53
-        val call = request.getPlants(slug, TOKEN)
54
-        val uri = call.request().url.toString()
55
-
56
-        //uri_test.text = (uri)
57
-
58
-        call.enqueue(object : Callback<Plant> {
59
-            override fun onFailure(call: Call<Plant>, t: Throwable) {
60
-                Toast.makeText(this@MainActivity, t.message, Toast.LENGTH_LONG).show()
61
-            }
62
-
63
-            override fun onResponse(call: Call<Plant>, response: Response<Plant>) {
64
-                if (response.isSuccessful) {
65
-                    val planta: Plant = response.body()!!
66
-                    nom_planta.text = planta.data.commonName.toString()
67
-                    nom_sci.text = planta.data.scientificName
68
-                    year.text = planta.data.year.toString()
69
-                    author.text = planta.data.author
70
-                    Picasso.get().load(planta.data.imageUrl).into(imagen_planta)
71
-                }
72
-                else{
73
-                    Toast.makeText(this@MainActivity, response.message(), Toast.LENGTH_LONG).show()
74
-                }
75
-
76
-            }
77
-        })
78
-
79
-    }
80
-
81
-}

+ 0
- 468
Planta_Display/Plant.kt Просмотреть файл

@@ -1,468 +0,0 @@
1
-package com.example.trefletest.models
2
-import com.google.gson.annotations.SerializedName
3
-
4
-
5
-data class Plant(
6
-    @SerializedName("data")
7
-    val `data`: Data,
8
-    @SerializedName("meta")
9
-    val meta: Meta
10
-) {
11
-    data class Data(
12
-        @SerializedName("author")
13
-        val author: String,
14
-        @SerializedName("bibliography")
15
-        val bibliography: String,
16
-        @SerializedName("common_name")
17
-        val commonName: Any?,
18
-        @SerializedName("family")
19
-        val family: Family,
20
-        @SerializedName("family_common_name")
21
-        val familyCommonName: Any?,
22
-        @SerializedName("forms")
23
-        val forms: List<Any>,
24
-        @SerializedName("genus")
25
-        val genus: Genus,
26
-        @SerializedName("genus_id")
27
-        val genusId: Int,
28
-        @SerializedName("hybrids")
29
-        val hybrids: List<Any>,
30
-        @SerializedName("id")
31
-        val id: Int,
32
-        @SerializedName("image_url")
33
-        val imageUrl: String,
34
-        @SerializedName("links")
35
-        val links: Links,
36
-        @SerializedName("main_species")
37
-        val mainSpecies: MainSpecies,
38
-        @SerializedName("main_species_id")
39
-        val mainSpeciesId: Int,
40
-        @SerializedName("observations")
41
-        val observations: String,
42
-        @SerializedName("scientific_name")
43
-        val scientificName: String,
44
-        @SerializedName("slug")
45
-        val slug: String,
46
-        @SerializedName("sources")
47
-        val sources: List<Source>,
48
-        @SerializedName("species")
49
-        val species: List<Specy>,
50
-        @SerializedName("subspecies")
51
-        val subspecies: List<Any>,
52
-        @SerializedName("subvarieties")
53
-        val subvarieties: List<Any>,
54
-        @SerializedName("varieties")
55
-        val varieties: List<Any>,
56
-        @SerializedName("vegetable")
57
-        val vegetable: Boolean,
58
-        @SerializedName("year")
59
-        val year: Int
60
-    ) {
61
-        data class Family(
62
-            @SerializedName("common_name")
63
-            val commonName: Any?,
64
-            @SerializedName("id")
65
-            val id: Int,
66
-            @SerializedName("links")
67
-            val links: Links,
68
-            @SerializedName("name")
69
-            val name: String,
70
-            @SerializedName("slug")
71
-            val slug: String
72
-        ) {
73
-            data class Links(
74
-                @SerializedName("division_order")
75
-                val divisionOrder: String,
76
-                @SerializedName("genus")
77
-                val genus: String,
78
-                @SerializedName("self")
79
-                val self: String
80
-            )
81
-        }
82
-
83
-        data class Genus(
84
-            @SerializedName("id")
85
-            val id: Int,
86
-            @SerializedName("links")
87
-            val links: Links,
88
-            @SerializedName("name")
89
-            val name: String,
90
-            @SerializedName("slug")
91
-            val slug: String
92
-        ) {
93
-            data class Links(
94
-                @SerializedName("family")
95
-                val family: String,
96
-                @SerializedName("plants")
97
-                val plants: String,
98
-                @SerializedName("self")
99
-                val self: String,
100
-                @SerializedName("species")
101
-                val species: String
102
-            )
103
-        }
104
-
105
-        data class Links(
106
-            @SerializedName("genus")
107
-            val genus: String,
108
-            @SerializedName("self")
109
-            val self: String,
110
-            @SerializedName("species")
111
-            val species: String
112
-        )
113
-
114
-        data class MainSpecies(
115
-            @SerializedName("author")
116
-            val author: String,
117
-            @SerializedName("bibliography")
118
-            val bibliography: String,
119
-            @SerializedName("common_name")
120
-            val commonName: Any?,
121
-            @SerializedName("common_names")
122
-            val commonNames: CommonNames,
123
-            @SerializedName("distribution")
124
-            val distribution: Distribution,
125
-            @SerializedName("distributions")
126
-            val distributions: Distributions,
127
-            @SerializedName("duration")
128
-            val duration: Any?,
129
-            @SerializedName("edible")
130
-            val edible: Boolean,
131
-            @SerializedName("edible_part")
132
-            val ediblePart: Any?,
133
-            @SerializedName("family")
134
-            val family: String,
135
-            @SerializedName("family_common_name")
136
-            val familyCommonName: Any?,
137
-            @SerializedName("flower")
138
-            val flower: Flower,
139
-            @SerializedName("foliage")
140
-            val foliage: Foliage,
141
-            @SerializedName("fruit_or_seed")
142
-            val fruitOrSeed: FruitOrSeed,
143
-            @SerializedName("genus")
144
-            val genus: String,
145
-            @SerializedName("genus_id")
146
-            val genusId: Int,
147
-            @SerializedName("growth")
148
-            val growth: Growth,
149
-            @SerializedName("id")
150
-            val id: Int,
151
-            @SerializedName("image_url")
152
-            val imageUrl: String,
153
-            @SerializedName("images")
154
-            val images: Images,
155
-            @SerializedName("links")
156
-            val links: Links,
157
-            @SerializedName("observations")
158
-            val observations: String,
159
-            @SerializedName("rank")
160
-            val rank: String,
161
-            @SerializedName("scientific_name")
162
-            val scientificName: String,
163
-            @SerializedName("slug")
164
-            val slug: String,
165
-            @SerializedName("sources")
166
-            val sources: List<Source>,
167
-            @SerializedName("specifications")
168
-            val specifications: Specifications,
169
-            @SerializedName("status")
170
-            val status: String,
171
-            @SerializedName("synonyms")
172
-            val synonyms: List<Any>,
173
-            @SerializedName("vegetable")
174
-            val vegetable: Boolean,
175
-            @SerializedName("year")
176
-            val year: Int
177
-        ) {
178
-            class CommonNames(
179
-            )
180
-
181
-            data class Distribution(
182
-                @SerializedName("native")
183
-                val native: List<String>
184
-            )
185
-
186
-            data class Distributions(
187
-                @SerializedName("native")
188
-                val native: List<Native>
189
-            ) {
190
-                data class Native(
191
-                    @SerializedName("id")
192
-                    val id: Int,
193
-                    @SerializedName("links")
194
-                    val links: Links,
195
-                    @SerializedName("name")
196
-                    val name: String,
197
-                    @SerializedName("slug")
198
-                    val slug: String,
199
-                    @SerializedName("species_count")
200
-                    val speciesCount: Int,
201
-                    @SerializedName("tdwg_code")
202
-                    val tdwgCode: String,
203
-                    @SerializedName("tdwg_level")
204
-                    val tdwgLevel: Int
205
-                ) {
206
-                    data class Links(
207
-                        @SerializedName("plants")
208
-                        val plants: String,
209
-                        @SerializedName("self")
210
-                        val self: String,
211
-                        @SerializedName("species")
212
-                        val species: String
213
-                    )
214
-                }
215
-            }
216
-
217
-            data class Flower(
218
-                @SerializedName("color")
219
-                val color: Any?,
220
-                @SerializedName("conspicuous")
221
-                val conspicuous: Any?
222
-            )
223
-
224
-            data class Foliage(
225
-                @SerializedName("color")
226
-                val color: Any?,
227
-                @SerializedName("leaf_retention")
228
-                val leafRetention: Any?,
229
-                @SerializedName("texture")
230
-                val texture: Any?
231
-            )
232
-
233
-            data class FruitOrSeed(
234
-                @SerializedName("color")
235
-                val color: Any?,
236
-                @SerializedName("conspicuous")
237
-                val conspicuous: Any?,
238
-                @SerializedName("seed_persistence")
239
-                val seedPersistence: Any?,
240
-                @SerializedName("shape")
241
-                val shape: Any?
242
-            )
243
-
244
-            data class Growth(
245
-                @SerializedName("atmospheric_humidity")
246
-                val atmosphericHumidity: Any?,
247
-                @SerializedName("bloom_months")
248
-                val bloomMonths: Any?,
249
-                @SerializedName("days_to_harvest")
250
-                val daysToHarvest: Any?,
251
-                @SerializedName("description")
252
-                val description: Any?,
253
-                @SerializedName("fruit_months")
254
-                val fruitMonths: Any?,
255
-                @SerializedName("growth_months")
256
-                val growthMonths: Any?,
257
-                @SerializedName("light")
258
-                val light: Any?,
259
-                @SerializedName("maximum_precipitation")
260
-                val maximumPrecipitation: MaximumPrecipitation,
261
-                @SerializedName("maximum_temperature")
262
-                val maximumTemperature: MaximumTemperature,
263
-                @SerializedName("minimum_precipitation")
264
-                val minimumPrecipitation: MinimumPrecipitation,
265
-                @SerializedName("minimum_root_depth")
266
-                val minimumRootDepth: MinimumRootDepth,
267
-                @SerializedName("minimum_temperature")
268
-                val minimumTemperature: MinimumTemperature,
269
-                @SerializedName("ph_maximum")
270
-                val phMaximum: Any?,
271
-                @SerializedName("ph_minimum")
272
-                val phMinimum: Any?,
273
-                @SerializedName("row_spacing")
274
-                val rowSpacing: RowSpacing,
275
-                @SerializedName("soil_humidity")
276
-                val soilHumidity: Any?,
277
-                @SerializedName("soil_nutriments")
278
-                val soilNutriments: Any?,
279
-                @SerializedName("soil_salinity")
280
-                val soilSalinity: Any?,
281
-                @SerializedName("soil_texture")
282
-                val soilTexture: Any?,
283
-                @SerializedName("sowing")
284
-                val sowing: Any?,
285
-                @SerializedName("spread")
286
-                val spread: Spread
287
-            ) {
288
-                data class MaximumPrecipitation(
289
-                    @SerializedName("mm")
290
-                    val mm: Any?
291
-                )
292
-
293
-                data class MaximumTemperature(
294
-                    @SerializedName("deg_c")
295
-                    val degC: Any?,
296
-                    @SerializedName("deg_f")
297
-                    val degF: Any?
298
-                )
299
-
300
-                data class MinimumPrecipitation(
301
-                    @SerializedName("mm")
302
-                    val mm: Any?
303
-                )
304
-
305
-                data class MinimumRootDepth(
306
-                    @SerializedName("cm")
307
-                    val cm: Any?
308
-                )
309
-
310
-                data class MinimumTemperature(
311
-                    @SerializedName("deg_c")
312
-                    val degC: Any?,
313
-                    @SerializedName("deg_f")
314
-                    val degF: Any?
315
-                )
316
-
317
-                data class RowSpacing(
318
-                    @SerializedName("cm")
319
-                    val cm: Any?
320
-                )
321
-
322
-                data class Spread(
323
-                    @SerializedName("cm")
324
-                    val cm: Any?
325
-                )
326
-            }
327
-
328
-            data class Images(
329
-                @SerializedName("bark")
330
-                val bark: List<Any>,
331
-                @SerializedName("flower")
332
-                val flower: List<Flower>,
333
-                @SerializedName("fruit")
334
-                val fruit: List<Any>,
335
-                @SerializedName("habit")
336
-                val habit: List<Any>,
337
-                @SerializedName("leaf")
338
-                val leaf: List<Any>,
339
-                @SerializedName("other")
340
-                val other: List<Any>
341
-            ) {
342
-                data class Flower(
343
-                    @SerializedName("copyright")
344
-                    val copyright: String,
345
-                    @SerializedName("id")
346
-                    val id: Int,
347
-                    @SerializedName("image_url")
348
-                    val imageUrl: String
349
-                )
350
-            }
351
-
352
-            data class Links(
353
-                @SerializedName("genus")
354
-                val genus: String,
355
-                @SerializedName("plant")
356
-                val plant: String,
357
-                @SerializedName("self")
358
-                val self: String
359
-            )
360
-
361
-            data class Source(
362
-                @SerializedName("citation")
363
-                val citation: String?,
364
-                @SerializedName("id")
365
-                val id: String,
366
-                @SerializedName("last_update")
367
-                val lastUpdate: String,
368
-                @SerializedName("name")
369
-                val name: String,
370
-                @SerializedName("url")
371
-                val url: String
372
-            )
373
-
374
-            data class Specifications(
375
-                @SerializedName("average_height")
376
-                val averageHeight: AverageHeight,
377
-                @SerializedName("growth_form")
378
-                val growthForm: Any?,
379
-                @SerializedName("growth_habit")
380
-                val growthHabit: Any?,
381
-                @SerializedName("growth_rate")
382
-                val growthRate: Any?,
383
-                @SerializedName("ligneous_type")
384
-                val ligneousType: Any?,
385
-                @SerializedName("maximum_height")
386
-                val maximumHeight: MaximumHeight,
387
-                @SerializedName("nitrogen_fixation")
388
-                val nitrogenFixation: Any?,
389
-                @SerializedName("shape_and_orientation")
390
-                val shapeAndOrientation: Any?,
391
-                @SerializedName("toxicity")
392
-                val toxicity: Any?
393
-            ) {
394
-                data class AverageHeight(
395
-                    @SerializedName("cm")
396
-                    val cm: Any?
397
-                )
398
-
399
-                data class MaximumHeight(
400
-                    @SerializedName("cm")
401
-                    val cm: Any?
402
-                )
403
-            }
404
-        }
405
-
406
-        data class Source(
407
-            @SerializedName("citation")
408
-            val citation: String?,
409
-            @SerializedName("id")
410
-            val id: String,
411
-            @SerializedName("last_update")
412
-            val lastUpdate: String,
413
-            @SerializedName("name")
414
-            val name: String,
415
-            @SerializedName("url")
416
-            val url: String
417
-        )
418
-
419
-        data class Specy(
420
-            @SerializedName("author")
421
-            val author: String,
422
-            @SerializedName("bibliography")
423
-            val bibliography: String,
424
-            @SerializedName("common_name")
425
-            val commonName: Any?,
426
-            @SerializedName("family")
427
-            val family: String,
428
-            @SerializedName("family_common_name")
429
-            val familyCommonName: Any?,
430
-            @SerializedName("genus")
431
-            val genus: String,
432
-            @SerializedName("genus_id")
433
-            val genusId: Int,
434
-            @SerializedName("id")
435
-            val id: Int,
436
-            @SerializedName("image_url")
437
-            val imageUrl: String,
438
-            @SerializedName("links")
439
-            val links: Links,
440
-            @SerializedName("rank")
441
-            val rank: String,
442
-            @SerializedName("scientific_name")
443
-            val scientificName: String,
444
-            @SerializedName("slug")
445
-            val slug: String,
446
-            @SerializedName("status")
447
-            val status: String,
448
-            @SerializedName("synonyms")
449
-            val synonyms: List<Any>,
450
-            @SerializedName("year")
451
-            val year: Int
452
-        ) {
453
-            data class Links(
454
-                @SerializedName("genus")
455
-                val genus: String,
456
-                @SerializedName("plant")
457
-                val plant: String,
458
-                @SerializedName("self")
459
-                val self: String
460
-            )
461
-        }
462
-    }
463
-
464
-    data class Meta(
465
-        @SerializedName("last_modified")
466
-        val lastModified: String
467
-    )
468
-}

+ 0
- 14
Planta_Display/TrefleService.kt Просмотреть файл

@@ -1,14 +0,0 @@
1
-package com.example.trefletest
2
-
3
-import com.example.trefletest.models.Plant
4
-import retrofit2.Call
5
-import retrofit2.http.GET
6
-import retrofit2.http.Path
7
-import retrofit2.http.Query
8
-
9
-interface TrefleService {
10
-    @GET("/api/v1/plants/{id}")
11
-    fun getPlants(@Path("id") id: String, @Query("token") token: String): Call<Plant>
12
-}
13
-
14
-//@Query("filter[id]") id: Int

+ 0
- 73
Planta_Display/activity_main.xml Просмотреть файл

@@ -1,73 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
-    xmlns:app="http://schemas.android.com/apk/res-auto"
4
-    xmlns:tools="http://schemas.android.com/tools"
5
-    android:id="@+id/Plant_info"
6
-    android:layout_width="match_parent"
7
-    android:layout_height="match_parent"
8
-    tools:context=".MainActivity">
9
-
10
-    <TextView
11
-        android:id="@+id/author"
12
-        android:layout_width="wrap_content"
13
-        android:layout_height="wrap_content"
14
-        android:text="@string/author"
15
-        android:textAppearance="@style/TextAppearance.AppCompat.Large"
16
-        app:layout_constraintBottom_toBottomOf="parent"
17
-        app:layout_constraintEnd_toEndOf="parent"
18
-        app:layout_constraintHorizontal_bias="0.506"
19
-        app:layout_constraintStart_toStartOf="parent"
20
-        app:layout_constraintTop_toBottomOf="@+id/year"
21
-        app:layout_constraintVertical_bias="0.239" />
22
-
23
-    <TextView
24
-        android:id="@+id/sci_name"
25
-        android:layout_width="wrap_content"
26
-        android:layout_height="wrap_content"
27
-        android:text="@string/scientific_name"
28
-        android:textAppearance="@style/TextAppearance.AppCompat.Large"
29
-        app:layout_constraintBottom_toBottomOf="parent"
30
-        app:layout_constraintEnd_toEndOf="parent"
31
-        app:layout_constraintHorizontal_bias="0.507"
32
-        app:layout_constraintStart_toStartOf="parent"
33
-        app:layout_constraintTop_toBottomOf="@+id/plant_name"
34
-        app:layout_constraintVertical_bias="0.155" />
35
-
36
-    <TextView
37
-        android:id="@+id/plant_name"
38
-        android:layout_width="wrap_content"
39
-        android:layout_height="wrap_content"
40
-        android:text="@string/plant_name"
41
-        android:textAppearance="@style/TextAppearance.AppCompat.Large"
42
-        app:layout_constraintBottom_toBottomOf="parent"
43
-        app:layout_constraintEnd_toEndOf="parent"
44
-        app:layout_constraintHorizontal_bias="0.511"
45
-        app:layout_constraintStart_toStartOf="parent"
46
-        app:layout_constraintTop_toTopOf="parent"
47
-        app:layout_constraintVertical_bias="0.57" />
48
-
49
-    <TextView
50
-        android:id="@+id/year"
51
-        android:layout_width="wrap_content"
52
-        android:layout_height="wrap_content"
53
-        android:text="@string/year"
54
-        android:textAppearance="@style/TextAppearance.AppCompat.Large"
55
-        app:layout_constraintBottom_toBottomOf="parent"
56
-        app:layout_constraintEnd_toEndOf="parent"
57
-        app:layout_constraintHorizontal_bias="0.506"
58
-        app:layout_constraintStart_toStartOf="parent"
59
-        app:layout_constraintTop_toBottomOf="@+id/sci_name"
60
-        app:layout_constraintVertical_bias="0.186" />
61
-
62
-    <ImageView
63
-        android:id="@+id/plantview"
64
-        android:layout_width="wrap_content"
65
-        android:layout_height="wrap_content"
66
-        android:contentDescription="@string/plant_display"
67
-        app:layout_constraintBottom_toTopOf="@+id/plant_name"
68
-        app:layout_constraintEnd_toEndOf="parent"
69
-        app:layout_constraintHorizontal_bias="0.498"
70
-        app:layout_constraintStart_toStartOf="parent"
71
-        app:layout_constraintTop_toTopOf="parent"
72
-        app:srcCompat="@drawable/ic_launcher_foreground" />
73
-</androidx.constraintlayout.widget.ConstraintLayout>

+ 0
- 54
Planta_Display/build.gradle Просмотреть файл

@@ -1,54 +0,0 @@
1
-apply plugin: 'com.android.application'
2
-apply plugin: 'kotlin-android'
3
-apply plugin: 'kotlin-android-extensions'
4
-
5
-android {
6
-    compileSdkVersion 30
7
-    buildToolsVersion "30.0.2"
8
-
9
-    compileOptions {
10
-        sourceCompatibility JavaVersion.VERSION_1_8
11
-        targetCompatibility JavaVersion.VERSION_1_8
12
-    }
13
-
14
-    kotlinOptions {
15
-        jvmTarget = JavaVersion.VERSION_1_8.toString()
16
-    }
17
-
18
-    defaultConfig {
19
-        applicationId "com.example.trefletest"
20
-        minSdkVersion 16
21
-        targetSdkVersion 30
22
-        versionCode 1
23
-        versionName "1.0"
24
-        vectorDrawables{
25
-            useSupportLibrary true
26
-        }
27
-
28
-        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
-    }
30
-
31
-    buildTypes {
32
-        release {
33
-            minifyEnabled false
34
-            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
35
-        }
36
-    }
37
-}
38
-
39
-dependencies {
40
-    implementation fileTree(dir: "libs", include: ["*.jar"])
41
-    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
42
-    implementation 'androidx.core:core-ktx:1.3.2'
43
-    implementation 'androidx.appcompat:appcompat:1.2.0'
44
-    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
45
-    //implementation 'org.junit.jupiter:junit-jupiter'
46
-    testImplementation 'junit:junit:4.13.1'
47
-    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
48
-    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
49
-    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
50
-    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
51
-    implementation "com.squareup.picasso:picasso:2.71828"
52
-    implementation "org.jetbrains.anko:anko-common:0.9"
53
-    implementation 'com.squareup.okhttp3:okhttp:4.9.0'
54
-}

+ 0
- 9
Planta_Display/strings.xml Просмотреть файл

@@ -1,9 +0,0 @@
1
-<resources>
2
-    <string name="app_name">TrefleTest</string>
3
-    <string name="plant_name">Plant Name</string>
4
-    <string name="testuri">TestUri</string>
5
-    <string name="scientific_name">Scientific Name</string>
6
-    <string name="year">Year</string>
7
-    <string name="author">Author</string>
8
-    <string name="plant_display">Plant Display</string>
9
-</resources>

+ 0
- 10
Planta_Display/styles.xml Просмотреть файл

@@ -1,10 +0,0 @@
1
-<resources>
2
-    <!-- Base application theme. -->
3
-    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
4
-        <!-- Customize your theme here. -->
5
-        <item name="colorPrimary">@color/colorPrimary</item>
6
-        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
7
-        <item name="colorAccent">@color/colorAccent</item>
8
-    </style>
9
-
10
-</resources>

+ 4
- 7
README.md Просмотреть файл

@@ -1,9 +1,6 @@
1
-Este es el repositorio para el proyecto Flowerdex. Los miembros somos Andrés, Víctor, José e Ismael.
2
-
3
-Falta subir todos los detalles y especificaciones.
1
+# Flowerdex
4 2
 
5
-Saludos, dice Andrés
6
-
7
-Jose puso esto
3
+Este es el repositorio para el proyecto Flowerdex. Los miembros somos Andrés, Víctor, José e Ismael.
8 4
 
9
-Andres ahora si modifico
5
+`Flowerdex` es el folder que contiene el código de iOS (Swift)
6
+`Floradex20` es el folder que contiene el código de Android (Kotlin)

+ 0
- 1
README2.md Просмотреть файл

@@ -1 +0,0 @@
1
-esto es un nuevo test document