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

lo logramos bb. Login con el Discover Page, se conecta a Ada en vez de treffle, se organizaron los files, las flores tienen estrellitas, register y login funcionan

Andres Ramos 4 лет назад
Родитель
Сommit
4fa274c65e
33 измененных файлов: 1013 добавлений и 269 удалений
  1. 3
    1
      Floradex20/app/build.gradle
  2. 12
    3
      Floradex20/app/src/main/AndroidManifest.xml
  3. 113
    0
      Floradex20/app/src/main/java/com/example/floradex20/ApiManager.kt
  4. 0
    100
      Floradex20/app/src/main/java/com/example/floradex20/MainActivity.kt
  5. 0
    5
      Floradex20/app/src/main/java/com/example/floradex20/Meta.kt
  6. 0
    7
      Floradex20/app/src/main/java/com/example/floradex20/PlantListss.kt
  7. 0
    20
      Floradex20/app/src/main/java/com/example/floradex20/TrefleService.kt
  8. 176
    0
      Floradex20/app/src/main/java/com/example/floradex20/activities/DiscoverActivity.kt
  9. 66
    0
      Floradex20/app/src/main/java/com/example/floradex20/activities/FilteringActivity.kt
  10. 3
    2
      Floradex20/app/src/main/java/com/example/floradex20/activities/FlowerAdapter.kt
  11. 91
    0
      Floradex20/app/src/main/java/com/example/floradex20/activities/LoginActivity.kt
  12. 132
    0
      Floradex20/app/src/main/java/com/example/floradex20/activities/MainActivity.kt
  13. 3
    3
      Floradex20/app/src/main/java/com/example/floradex20/activities/VentantaActivity.kt
  14. 36
    0
      Floradex20/app/src/main/java/com/example/floradex20/interfaces/RestApi.kt
  15. 28
    0
      Floradex20/app/src/main/java/com/example/floradex20/interfaces/TrefleService.kt
  16. 4
    2
      Floradex20/app/src/main/java/com/example/floradex20/models/Data.kt
  17. 1
    1
      Floradex20/app/src/main/java/com/example/floradex20/models/Links.kt
  18. 1
    1
      Floradex20/app/src/main/java/com/example/floradex20/models/LinksX.kt
  19. 5
    0
      Floradex20/app/src/main/java/com/example/floradex20/models/Meta.kt
  20. 11
    0
      Floradex20/app/src/main/java/com/example/floradex20/models/PlantListss.kt
  21. 11
    0
      Floradex20/app/src/main/java/com/example/floradex20/models/UserInfo.kt
  22. 5
    0
      Floradex20/app/src/main/res/drawable-v24/filter.xml
  23. Двоичные данные
      Floradex20/app/src/main/res/drawable/star.png
  24. Двоичные данные
      Floradex20/app/src/main/res/drawable/star_1.png
  25. 66
    0
      Floradex20/app/src/main/res/layout/activity_filtering.xml
  26. 0
    123
      Floradex20/app/src/main/res/layout/activity_main.xml
  27. 62
    0
      Floradex20/app/src/main/res/layout/discover_activity.xml
  28. 9
    0
      Floradex20/app/src/main/res/layout/layout.xml
  29. 44
    0
      Floradex20/app/src/main/res/layout/login.xml
  30. 101
    0
      Floradex20/app/src/main/res/layout/register.xml
  31. 1
    1
      Floradex20/app/src/main/res/layout/ventanita.xml
  32. 9
    0
      Floradex20/app/src/main/res/menu/filter_menu.xml
  33. 20
    0
      Floradex20/app/src/main/res/values/strings.xml

+ 3
- 1
Floradex20/app/build.gradle Просмотреть файл

@@ -35,6 +35,7 @@ android {
35 35
 dependencies {
36 36
 
37 37
     //noinspection GradleCompatible
38
+    implementation 'org.jetbrains.anko:anko-common:0.9'
38 39
     implementation 'com.android.support:recyclerview-v7:28.0.0'
39 40
     implementation 'com.squareup.retrofit2:retrofit:2.9.0'
40 41
     implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
@@ -44,7 +45,8 @@ dependencies {
44 45
     implementation 'androidx.recyclerview:recyclerview:1.1.0'
45 46
     implementation 'com.github.bumptech.glide:glide:4.10.0'
46 47
     implementation 'androidx.appcompat:appcompat:1.2.0'
47
-    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'//Glide
48
+    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
49
+    implementation 'androidx.viewpager:viewpager:1.0.0'//Glide
48 50
     annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
49 51
     implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
50 52
 //    implementation 'androidx.core:core-ktx:1.3.2'

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

@@ -11,8 +11,17 @@
11 11
         android:roundIcon="@drawable/ic_launcher_foreground"
12 12
         android:supportsRtl="true"
13 13
         android:theme="@style/AppTheme">
14
+        <activity
15
+            android:name=".activities.FilteringActivity"
16
+            android:parentActivityName=".activities.MainActivity" />
17
+        <activity
18
+            android:name=".activities.LoginActivity"
19
+            android:parentActivityName=".activities.MainActivity" />
20
+        <activity android:name=".activities.DiscoverActivity">
21
+<!--            android:parentActivityName=".activities.MainActivity">-->
14 22
 
15
-        <activity android:name=".MainActivity">
23
+        </activity>
24
+        <activity android:name=".activities.MainActivity">
16 25
             <intent-filter>
17 26
                 <action android:name="android.intent.action.MAIN" />
18 27
 
@@ -20,8 +29,8 @@
20 29
             </intent-filter>
21 30
         </activity>
22 31
         <activity
23
-            android:name=".ventana"
24
-            android:parentActivityName=".MainActivity">
32
+            android:name=".activities.VentantaActivity"
33
+            android:parentActivityName=".activities.DiscoverActivity">
25 34
 
26 35
 
27 36
         </activity>

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

@@ -0,0 +1,113 @@
1
+package com.example.floradex20
2
+
3
+import android.view.View
4
+import com.example.floradex20.activities.ServiceBuilder
5
+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
9
+import com.google.android.material.snackbar.Snackbar
10
+import org.json.JSONObject
11
+import retrofit2.Call
12
+import retrofit2.Callback
13
+import retrofit2.Response
14
+
15
+class ApiManager(val parent: View) {
16
+
17
+
18
+    fun addUser(userData: UserInfo, onResult: (UserInfo?) -> Unit){
19
+        val retrofit = ServiceBuilder.buildService(RestApi::class.java)
20
+        retrofit.addUser(userData).enqueue(object: Callback<UserInfo> {
21
+            override fun onFailure(call: Call<UserInfo>, t: Throwable) {
22
+                Snackbar.make(parent, "${t.message}", Snackbar.LENGTH_SHORT).show()
23
+            }
24
+            override fun onResponse(call: Call<UserInfo>, response: Response<UserInfo>) {
25
+                if(response.code() == 500 || response.code() == 400) {
26
+                    val responseString = response.errorBody()!!.string()
27
+                    val message = JSONObject(responseString).getString("error")
28
+                    Snackbar.make(parent, message, Snackbar.LENGTH_SHORT).show()
29
+                } else {
30
+                    onResult(response.body())
31
+                }
32
+            }
33
+        })
34
+    }
35
+
36
+
37
+    fun logInUser(userData: UserInfo, onResult: (UserInfo?) -> Unit) {
38
+        val retrofit = ServiceBuilder.buildService(RestApi::class.java)
39
+        retrofit.logInUser(userData).enqueue(object: Callback<UserInfo> {
40
+            override fun onFailure(call: Call<UserInfo>, t: Throwable) {
41
+                Snackbar.make(parent, "${t.message}", Snackbar.LENGTH_SHORT).show()
42
+            }
43
+            override fun onResponse(call: Call<UserInfo>, response: Response<UserInfo>) {
44
+
45
+                if(response.code() == 500 || response.code() == 400) {
46
+                    val responseString = response.errorBody()!!.string()
47
+                    val message = JSONObject(responseString).getString("error")
48
+                    Snackbar.make(parent, message, Snackbar.LENGTH_SHORT).show()
49
+                } else {
50
+                    onResult(response.body())
51
+                }
52
+            }
53
+        })
54
+    }
55
+
56
+
57
+    fun getPlants(user_id: String, onResult: (PlantListss) -> Unit) {
58
+        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) {
61
+                Snackbar.make(parent, "${t.message}", Snackbar.LENGTH_SHORT).show()
62
+            }
63
+            override fun onResponse(call: Call<PlantListss>, response: Response<PlantListss>) {
64
+                if (response.code() == 500 || response.code() == 400) {
65
+                    val responseString = response.errorBody()!!.string()
66
+                    val message = JSONObject(responseString).getString("error")
67
+                    Snackbar.make(parent, message, Snackbar.LENGTH_SHORT).show()
68
+                } else {
69
+                    onResult(response.body()!!)
70
+                }
71
+            }
72
+        })
73
+    }
74
+
75
+    fun getPlantsByName(user_id: String, search_input: String, onResult: (PlantListss) -> Unit) {
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) {
79
+                Snackbar.make(parent, "${t.message}", Snackbar.LENGTH_SHORT).show()
80
+            }
81
+            override fun onResponse(call: Call<PlantListss>, response: Response<PlantListss>) {
82
+                if (response.code() == 500 || response.code() == 400) {
83
+                    val responseString = response.errorBody()!!.string()
84
+                    val message = JSONObject(responseString).getString("error")
85
+                    Snackbar.make(parent, message, Snackbar.LENGTH_SHORT).show()
86
+                } else {
87
+                    onResult(response.body()!!)
88
+                }
89
+            }
90
+        })
91
+    }
92
+
93
+    fun getFiltered(user_id: String, edible: String, vegetable: String, color: String, scientificName: String, onResult: (PlantListss) -> Unit) {
94
+        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) {
97
+                Snackbar.make(parent, "${t.message}", Snackbar.LENGTH_SHORT).show()
98
+            }
99
+            override fun onResponse(call: Call<PlantListss>, response: Response<PlantListss>) {
100
+                if (response.code() == 500 || response.code() == 400) {
101
+                    val responseString = response.errorBody()!!.string()
102
+                    val message = JSONObject(responseString).getString("error")
103
+                    Snackbar.make(parent, message, Snackbar.LENGTH_SHORT).show()
104
+                } else {
105
+                    onResult(response.body()!!)
106
+                }
107
+            }
108
+        })
109
+    }
110
+
111
+
112
+
113
+}

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

@@ -1,100 +0,0 @@
1
-package com.example.floradex20
2
-
3
-//import com.example.floradex20.R
4
-//import com.example.floradex20.Plant
5
-//import com.squareup.picasso.Picasso
6
-//import android.support.v4.app.FragmentActivity
7
-import android.content.Intent
8
-import android.os.Bundle
9
-import android.util.Log
10
-import android.view.View
11
-import android.widget.Toast
12
-import androidx.appcompat.app.AppCompatActivity
13
-import androidx.recyclerview.widget.LinearLayoutManager
14
-import androidx.recyclerview.widget.RecyclerView
15
-import okhttp3.OkHttpClient
16
-import retrofit2.Call
17
-import retrofit2.Callback
18
-import retrofit2.Response
19
-import retrofit2.Retrofit
20
-import retrofit2.converter.gson.GsonConverterFactory
21
-import androidx.constraintlayout.widget.ConstraintLayout
22
-
23
-
24
-//Cosas para que lleguen las flores
25
-//private const val TOKEN: String = "cMyugCJvk-U_xoi31FVBgoEqZiuRnDYpP8fv8Vfiejg"
26
-private const val  BASE_URL = "https://trefle.io/"
27
-//var slug: String = "prunella-vulgaris"
28
-
29
-//Creo que mas cosas para que lleguen las flores
30
-object ServiceBuilder {
31
-
32
-    val client = OkHttpClient.Builder().build()
33
-
34
-    var retrofit: Retrofit = Retrofit.Builder()
35
-        .baseUrl(BASE_URL)
36
-        .addConverterFactory(GsonConverterFactory.create())
37
-        .client(client)
38
-        .build()
39
-
40
-    fun <T> buildService(service: Class<T>): T {
41
-        return retrofit.create(service)
42
-    }
43
-}
44
-
45
-
46
-//Main Activity
47
-class MainActivity : AppCompatActivity(), FlowerAdapter.OnItemClickListener {
48
-    private lateinit var recyclerView: RecyclerView
49
-    private lateinit var plants: List<Data>
50
-
51
-    override fun onCreate(savedInstanceState: Bundle?) {
52
-        super.onCreate(savedInstanceState)
53
-        setContentView(R.layout.activity_main)
54
-
55
-        val request = ServiceBuilder.buildService(TrefleService::class.java)
56
-        val call : Call<PlantListss> = request.getPlants(getString(R.string.TOKEN))
57
-
58
-
59
-        //Esta parte hay que loop it para que haga mas de 1 request al API
60
-        call.enqueue(object : Callback<PlantListss> {
61
-            override fun onResponse(call: Call<PlantListss>, response: Response<PlantListss>) {
62
-
63
-                if (response.isSuccessful) {
64
-
65
-                    recyclerView = findViewById<RecyclerView>(R.id.recyclerView)
66
-
67
-                    recyclerView.apply {
68
-
69
-                        setHasFixedSize(true)
70
-                        plants = response.body()!!.data
71
-                        adapter = FlowerAdapter(plants, this@MainActivity)
72
-                        layoutManager = LinearLayoutManager(this@MainActivity)
73
-
74
-                        //Aqui hay que chequiar si el API response llega bien
75
-                        recyclerView.setAdapter(adapter)
76
-                        recyclerView.setLayoutManager(layoutManager)
77
-                    }
78
-//
79
-                }
80
-            }
81
-
82
-            override fun onFailure(call: Call<PlantListss>, t: Throwable) {
83
-                Toast.makeText(this@MainActivity, "${t.message}", Toast.LENGTH_SHORT).show()
84
-            }
85
-        })
86
-        }
87
-
88
-    override fun onItemClick(position: Int){
89
-        //Empezar el activity de Jose
90
-        var plant_info = arrayOf<String>(plants[position].common_name.toString(), plants[position].scientific_name.toString()
91
-        , plants[position].year.toString(), plants[position].author.toString(), plants[position].image_url.toString())
92
-        val intent = Intent(this, ventana::class.java).apply {
93
-            putExtra("plant_info", plant_info)
94
-        }
95
-        startActivity(intent)
96
-        Log.i("Position", plant_info.get(0))
97
-    }
98
-
99
-}
100
-

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

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

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

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

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

@@ -1,20 +0,0 @@
1
-package com.example.floradex20
2
-
3
-import com.example.floradex20.PlantListss
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/")
11
-    //Quite el id de la planta para recibir mas cosas
12
-    //Posiblemente se puede overload la funcion para q funcione sin id y con id
13
-    fun getPlants(@Query("token") token: String): Call<PlantListss>
14
-
15
-}
16
-
17
-
18
-
19
-
20
-//@Query("filter[id]") id: Int

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

@@ -0,0 +1,176 @@
1
+package com.example.floradex20.activities
2
+
3
+import android.content.Context
4
+import android.content.Intent
5
+import android.content.SharedPreferences
6
+import android.os.Bundle
7
+import android.util.Log
8
+import android.view.Menu
9
+import android.view.MenuInflater
10
+import android.view.MenuItem
11
+import android.widget.Button
12
+import android.widget.EditText
13
+import androidx.appcompat.app.AppCompatActivity
14
+import androidx.recyclerview.widget.LinearLayoutManager
15
+import androidx.recyclerview.widget.RecyclerView
16
+import com.example.floradex20.ApiManager
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
44
+class DiscoverActivity : AppCompatActivity(), FlowerAdapter.OnItemClickListener {
45
+    private lateinit var recyclerView: RecyclerView
46
+    private lateinit var plants: List<Data>
47
+
48
+    var search_input: String = ""     //Guarda search input de user
49
+
50
+
51
+    //Para desplegar el boton de filtro en Discover Page
52
+    override fun onCreateOptionsMenu(menu: Menu?): Boolean {
53
+        val inflater: MenuInflater = menuInflater
54
+        inflater.inflate(R.menu.filter_menu, menu)
55
+        return true
56
+    }
57
+
58
+    override fun onCreate(savedInstanceState: Bundle?) {
59
+        super.onCreate(savedInstanceState)
60
+        setContentView(R.layout.discover_activity)
61
+
62
+        //Donde se guarda el input del search bar y el search button
63
+        val enterButton = findViewById<Button>(R.id.search_enter)
64
+        val input = findViewById<EditText>(R.id.search)
65
+
66
+        // Get user_id
67
+        val sharedPref: SharedPreferences = applicationContext.getSharedPreferences("user_info", Context.MODE_PRIVATE)
68
+        val userID = sharedPref.getString("user_id", "")!!
69
+        Log.i("preferences", userID)
70
+
71
+        // Get flowers with user_id
72
+//        val thisActivity = this@Discover_activity
73
+        val apimanager = ApiManager(findViewById(R.id.discover_activity))
74
+        apimanager.getPlants(userID) {
75
+            recyclerView = findViewById<RecyclerView>(R.id.recyclerView)
76
+
77
+            recyclerView.apply {
78
+
79
+                setHasFixedSize(true)
80
+                plants = it.data
81
+                adapter = FlowerAdapter(plants, this@DiscoverActivity)
82
+                layoutManager = LinearLayoutManager(this@DiscoverActivity)
83
+
84
+                //Aqui hay que chequiar si el API response llega bien
85
+                recyclerView.setAdapter(adapter)
86
+                recyclerView.setLayoutManager(layoutManager)
87
+            }
88
+        }
89
+
90
+        //Esto se ejecuta cuando el usuario hace un search con el search bar
91
+        enterButton?.setOnClickListener {
92
+
93
+            search_input = input.text.toString()
94
+
95
+            apimanager.getPlantsByName(userID, search_input) {
96
+
97
+//                progress_bar.visibility = View.GONE
98
+                recyclerView.apply {
99
+//                    Log.i("velllllllllllllllllllll", response.body().toString())
100
+                    setHasFixedSize(true)
101
+                    plants = it.data
102
+                    adapter = FlowerAdapter(plants, this@DiscoverActivity)
103
+                    layoutManager = LinearLayoutManager(this@DiscoverActivity)
104
+
105
+                    recyclerView.setAdapter(adapter)
106
+                    recyclerView.setLayoutManager(layoutManager)
107
+                }
108
+            }
109
+
110
+        }
111
+    }
112
+
113
+    override fun onItemClick(position: Int){
114
+        //Empezar el activity de Jose
115
+        val plantInfo = arrayOf<String>(plants[position].common_name.toString(), plants[position].scientific_name.toString()
116
+                , plants[position].year.toString(), plants[position].author.toString(), plants[position].image_url.toString())
117
+        val intent = Intent(this, VentantaActivity::class.java).apply {
118
+            putExtra("plant_info", plantInfo)
119
+        }
120
+        startActivity(intent)
121
+        Log.i("Position", plantInfo.get(0))
122
+    }
123
+
124
+
125
+    //Esto es lo que se ejecuta cuando se preciona el boton de filter en el UI.
126
+    //Ejecuta Filtering.kt
127
+    override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
128
+        R.id.filterIcon -> {
129
+            val intent = Intent(this, FilteringActivity::class.java)
130
+            startActivityForResult(intent, 1)
131
+            true
132
+        }
133
+
134
+        else -> {
135
+            super.onOptionsItemSelected(item)   //Error handling?
136
+        }
137
+    }
138
+
139
+    //Esta es la funcion que se ejecuta cuando se recibe los filtros de
140
+    //filtering.kt. Hace un call al api con los filtros.
141
+    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
142
+        super.onActivityResult(requestCode, resultCode, data)
143
+
144
+        val edible = data?.getStringExtra("edible").toString().toLowerCase()
145
+        val vegetable = data?.getStringExtra("vegetable").toString().toLowerCase()
146
+        val scientificName = data?.getStringExtra("cientifico").toString().toLowerCase()
147
+        val color = data?.getStringExtra("color").toString().toLowerCase()
148
+
149
+        // Get user_id
150
+        val sharedPref: SharedPreferences = applicationContext.getSharedPreferences("user_info", Context.MODE_PRIVATE)
151
+        val userID = sharedPref.getString("user_id", "")!!
152
+        Log.i("preferences", userID)
153
+
154
+        // Get flowers (with filters)
155
+        val apiManager = ApiManager(findViewById(R.id.discover_activity))
156
+        apiManager.getFiltered(userID, edible, vegetable, color, scientificName) {
157
+
158
+            recyclerView = findViewById<RecyclerView>(R.id.recyclerView)
159
+
160
+            recyclerView.apply {
161
+
162
+                setHasFixedSize(true)
163
+                plants = it.data
164
+                adapter = FlowerAdapter(plants, this@DiscoverActivity)
165
+                layoutManager = LinearLayoutManager(this@DiscoverActivity)
166
+
167
+                //Aqui hay que chequiar si el API response llega bien
168
+                recyclerView.setAdapter(adapter)
169
+                recyclerView.setLayoutManager(layoutManager)
170
+            }
171
+        }
172
+
173
+    }
174
+
175
+}
176
+

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

@@ -0,0 +1,66 @@
1
+package com.example.floradex20.activities
2
+
3
+import android.app.Activity
4
+import android.content.Intent
5
+import androidx.appcompat.app.AppCompatActivity
6
+import android.os.Bundle
7
+import android.widget.Button
8
+import android.widget.EditText
9
+import android.widget.ToggleButton
10
+import com.example.floradex20.R
11
+
12
+class FilteringActivity : AppCompatActivity() {
13
+    override fun onCreate(savedInstanceState: Bundle?) {
14
+        super.onCreate(savedInstanceState)
15
+        setContentView(R.layout.activity_filtering)
16
+
17
+        title = "Filter"
18
+
19
+        val sciTxt = findViewById<EditText>(R.id.editTextNombreSci)
20
+        val colorTxt = findViewById<EditText>(R.id.editTextFlowerColor)
21
+        val edibleToggle = findViewById<ToggleButton>(R.id.toggleButtonEdible)
22
+        val vegetableToggle = findViewById<ToggleButton>(R.id.toggleButtonVegetable)
23
+        val apply = findViewById<Button>(R.id.buttonApply)
24
+
25
+        //Los filter values
26
+        var edible: String = ""
27
+        var vegetable: String = ""
28
+        var nom_cientifico: String = ""
29
+        var color_flor: String = ""
30
+
31
+        edibleToggle.setOnCheckedChangeListener{ _, isChecked ->
32
+            if (isChecked){
33
+                edible = "true"
34
+            }
35
+            else{
36
+                edible = "false"
37
+            }
38
+        }
39
+        vegetableToggle.setOnCheckedChangeListener{ _, isChecked ->
40
+            if (isChecked){
41
+                vegetable = "true"
42
+            }
43
+            else{
44
+                vegetable = "false"
45
+            }
46
+        }
47
+
48
+        //Cuando usuario le da apply se envia los filter values a main activity
49
+        apply.setOnClickListener(){
50
+
51
+            color_flor = colorTxt.text.toString()
52
+            nom_cientifico = sciTxt.text.toString()
53
+            //Log.d("variables", edible + vegetable + nom_cientifico + color_flor)
54
+
55
+            val returnIntent = Intent()
56
+            returnIntent.putExtra("edible", edible)
57
+            returnIntent.putExtra("vegetable", vegetable)
58
+            returnIntent.putExtra("cientifico", nom_cientifico)
59
+            returnIntent.putExtra("color", color_flor)
60
+
61
+            //Log.d("retintent", returnIntent.toString())
62
+            setResult(Activity.RESULT_OK, returnIntent)
63
+            finish()
64
+        }
65
+    }
66
+}

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

@@ -1,12 +1,13 @@
1
-package com.example.floradex20
1
+package com.example.floradex20.activities
2 2
 
3
-import android.util.Log
4 3
 import android.view.LayoutInflater
5 4
 import android.view.View
6 5
 import android.view.ViewGroup
7 6
 import android.widget.ImageView
8 7
 import android.widget.TextView
9 8
 import androidx.recyclerview.widget.RecyclerView
9
+import com.example.floradex20.R
10
+import com.example.floradex20.models.Data
10 11
 import com.squareup.picasso.Picasso
11 12
 
12 13
 

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

@@ -0,0 +1,91 @@
1
+package com.example.floradex20.activities
2
+
3
+import android.content.Context
4
+import android.content.Intent
5
+import android.content.SharedPreferences
6
+import android.os.Bundle
7
+import android.widget.Button
8
+import android.widget.EditText
9
+import android.widget.TextView
10
+import androidx.appcompat.app.AppCompatActivity
11
+import com.example.floradex20.ApiManager
12
+import com.example.floradex20.R
13
+import com.example.floradex20.models.UserInfo
14
+//import com.example.login.ApiManager
15
+//import com.example.login.UserInfo
16
+import com.google.android.material.snackbar.Snackbar
17
+
18
+class LoginActivity: AppCompatActivity() {
19
+
20
+    override fun onCreate(savedInstanceState: Bundle?) {
21
+        super.onCreate(savedInstanceState)
22
+        setContentView(R.layout.login)
23
+
24
+
25
+        val b: Button
26
+        val user_email: EditText
27
+        val user_password: EditText
28
+        val login: String
29
+        val password: String
30
+        val email: String
31
+        user_email = findViewById(R.id.email)
32
+        user_password = findViewById(R.id.password)
33
+        email = user_email.getText().toString()
34
+        password = user_password.getText().toString()
35
+
36
+
37
+        val button: Button = findViewById(R.id.login_button)
38
+
39
+
40
+        //Coger estas cosas y mandarlas a la base de datos
41
+        button.setOnClickListener {
42
+            //Somehow hacer que esto llegue a la base de datos
43
+
44
+            val user_email: String = (findViewById(R.id.email) as TextView).getText().toString()
45
+            val user_password: String = (findViewById(R.id.password) as TextView).getText().toString()
46
+//            val user_password_confirm: String = (findViewById(R.id.et_repassword) as TextView).getText().toString()
47
+
48
+
49
+            //Hasta aqui funciona
50
+            val user_info = UserInfo(null, user_email, user_password, null, null)
51
+            val apimanager = ApiManager(it)
52
+            val thisActivity = it
53
+//            user_info.user_email?.let { it1 -> Log.i("check instance info", it1) }
54
+//            user_info.user_password?.let { it1 -> Log.i("check instance info", it1) }
55
+
56
+            if(user_email == "" || user_password == ""){
57
+                Snackbar.make(
58
+                        it, "All Fields Required",
59
+                        Snackbar.LENGTH_LONG
60
+                ).setAction("Action", null).show()
61
+            }
62
+            else {
63
+                //
64
+                apimanager.logInUser(user_info) {
65
+
66
+                    Snackbar.make(
67
+                            thisActivity, "Succesfully logged in",
68
+                            Snackbar.LENGTH_LONG
69
+                    ).setAction("Action", null).show()
70
+
71
+                    val user_id: String? = it?.id
72
+//                    val user_name: String? = it?.user_name
73
+                    val sharedPref: SharedPreferences = applicationContext.getSharedPreferences("user_info", Context.MODE_PRIVATE)
74
+                    val editor = sharedPref.edit()
75
+                    editor.putString("user_id", user_id)
76
+//                    editor.putString("user_name", user_name)
77
+                    editor.apply()
78
+
79
+
80
+                    //Guardar Id y mover a discover page
81
+
82
+                    val intent = Intent(this, DiscoverActivity::class.java)
83
+                    startActivity(intent)
84
+                }
85
+
86
+            }
87
+        }
88
+
89
+    }
90
+
91
+}

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

@@ -0,0 +1,132 @@
1
+package com.example.floradex20.activities
2
+
3
+import android.content.Context
4
+import android.content.Intent
5
+import android.content.SharedPreferences
6
+import android.os.Bundle
7
+import android.util.Log
8
+import android.widget.Button
9
+import android.widget.TextView
10
+import androidx.appcompat.app.AppCompatActivity
11
+import com.example.floradex20.ApiManager
12
+import com.example.floradex20.R
13
+import com.example.floradex20.models.UserInfo
14
+import com.google.android.material.snackbar.Snackbar
15
+import okhttp3.OkHttpClient
16
+import retrofit2.Retrofit
17
+import retrofit2.converter.gson.GsonConverterFactory
18
+
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() {
38
+
39
+    override fun onCreate(savedInstanceState: Bundle?) {
40
+
41
+
42
+        super.onCreate(savedInstanceState)
43
+        setContentView(R.layout.register)
44
+
45
+        val sharedPref: SharedPreferences = applicationContext.getSharedPreferences("user_info", Context.MODE_PRIVATE)
46
+
47
+        if(sharedPref.getString("user_id", "no se")!! != "no se"){
48
+            val intent = Intent(this, DiscoverActivity::class.java)
49
+            startActivity(intent)
50
+            return
51
+        }
52
+        Log.i("preferences", sharedPref.getString("user_id", "no se").toString())
53
+        //Boton para el usuario que ya se registro
54
+        val log_in_button: Button = findViewById(R.id.to_login_activity)
55
+
56
+        //Si el usuario ya se registro abre un intent para hacer login
57
+        log_in_button.setOnClickListener {
58
+//            Log.i("Debug", "Desde el clicl del register thing")
59
+            val intent = Intent(this, LoginActivity::class.java)
60
+            startActivity(intent)
61
+
62
+        }
63
+
64
+        //Boton para registrar usuario
65
+        val register_button: Button = findViewById(R.id.btn_register)
66
+
67
+        //cuando quickear el register button
68
+        register_button.setOnClickListener {
69
+
70
+            //Extrae los fields
71
+            val full_name: String =  (findViewById(R.id.et_name) as TextView).getText().toString()
72
+            val user_email: String = (findViewById(R.id.et_email) as TextView).getText().toString()
73
+            val user_password: String = (findViewById(R.id.et_password) as TextView).getText().toString()
74
+            val user_password_confirm: String = (findViewById(R.id.et_repassword) as TextView).getText().toString()
75
+
76
+            //Verifica que no esten vacios
77
+            if(full_name == "" || user_email == "" || user_password == "" || user_password_confirm == ""){
78
+                Snackbar.make(
79
+                        it, "All Fields Required",
80
+                        Snackbar.LENGTH_LONG
81
+                ).setAction("Action", null).show()
82
+            }
83
+
84
+            //Verifica que passwords match
85
+            else if(user_password != user_password_confirm){
86
+                Snackbar.make(
87
+                        it, "Passwords don't match",
88
+                        Snackbar.LENGTH_LONG
89
+                ).setAction("Action", null).show()
90
+            }
91
+
92
+            //Manda el info a la base de datos
93
+            else {
94
+
95
+                val user_info = UserInfo(full_name, user_email, user_password, null, null)
96
+                val apimanager = ApiManager(it)
97
+                val thisActivity = it
98
+
99
+                //Manda el info al
100
+                apimanager.addUser(user_info) {
101
+
102
+                    Snackbar.make(
103
+                            thisActivity, "Succesfully registered",
104
+                            Snackbar.LENGTH_LONG
105
+                    ).setAction("Action", null).show()
106
+
107
+                    //Se guarda el username y id
108
+                    val user_id: String? = it?.id
109
+                    val user_name: String? = it?.user_name
110
+                    val sharedPref: SharedPreferences = applicationContext.getSharedPreferences("user_info", Context.MODE_PRIVATE)
111
+                    val editor = sharedPref.edit()
112
+                    editor.putString("user_id", user_id)
113
+                    editor.putString("user_name", user_name)
114
+                    editor.apply()
115
+
116
+
117
+                    //Guardar Id y mover a discover page
118
+
119
+                    val intent = Intent(this, DiscoverActivity::class.java)
120
+                    startActivity(intent)
121
+
122
+                }
123
+
124
+            }
125
+
126
+
127
+        }
128
+
129
+    }
130
+
131
+
132
+}

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

@@ -1,14 +1,14 @@
1
-package com.example.floradex20
1
+package com.example.floradex20.activities
2 2
 
3
-import android.content.res.Configuration
4 3
 import android.os.Bundle
5 4
 import android.util.Log
6 5
 import android.widget.ImageView
7 6
 import android.widget.TextView
8 7
 import androidx.appcompat.app.AppCompatActivity
8
+import com.example.floradex20.R
9 9
 import com.squareup.picasso.Picasso
10 10
 
11
-class ventana(): AppCompatActivity() {
11
+class VentantaActivity(): AppCompatActivity() {
12 12
 
13 13
 //    val planta:Data = plant
14 14
     override fun onCreate(savedInstanceState: Bundle?) {

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

@@ -0,0 +1,36 @@
1
+package com.example.floradex20.interfaces
2
+
3
+import com.example.floradex20.models.PlantListss
4
+import com.example.floradex20.models.UserInfo
5
+import retrofit2.Call
6
+import retrofit2.http.*
7
+
8
+interface RestApi {
9
+
10
+    @Headers("Content-Type: application/json")
11
+    @POST("~victor.hernandez17/flowerdex/signup.php")
12
+    fun addUser(@Body userData: UserInfo): Call<UserInfo>
13
+
14
+    @Headers("Content-Type: application/json")
15
+    @POST("~victor.hernandez17/flowerdex/login.php")
16
+    fun logInUser(@Body UserData: UserInfo): Call<UserInfo>
17
+
18
+
19
+    @GET("~victor.hernandez17/flowerdex/listFlowers.php") // /api/v1/plants/
20
+    //Quite el id de la planta para recibir mas cosas
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>
23
+
24
+    //El Api Query que se usa cuando se hace un search
25
+    @GET("~victor.hernandez17/flowerdex/listFlowers.php") // /api/v1/plants/search/
26
+    fun getPlantsbyName(@Query("user_id") user_id: String,
27
+                        @Query("q") q: String): Call<PlantListss>
28
+
29
+    //Api query para el filter
30
+    @GET("~victor.hernandez17/flowerdex/listFlowers.php") // api/v1/plants/
31
+    fun getFiltered(@Query("user_id") user_id: String,
32
+                    @Query("edible") edible: String,
33
+                    @Query("vegetable") vegetable: String,
34
+                    @Query("flower_color") color: String,
35
+                    @Query("scientific_name") scientificName: String): Call<PlantListss>
36
+}

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

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

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

@@ -1,4 +1,4 @@
1
-package com.example.floradex20
1
+package com.example.floradex20.models
2 2
 
3 3
 data class Data(
4 4
     val author: String,
@@ -16,5 +16,7 @@ data class Data(
16 16
     val slug: String,
17 17
     val status: String,
18 18
     val synonyms: List<String>,
19
-    val year: Int
19
+    val year: Int,
20
+    val isFavorite: Boolean,
21
+    val hasBeenFound: Boolean
20 22
 )

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

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

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

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

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

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

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

@@ -0,0 +1,11 @@
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/UserInfo.kt Просмотреть файл

@@ -0,0 +1,11 @@
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
+)

+ 5
- 0
Floradex20/app/src/main/res/drawable-v24/filter.xml Просмотреть файл

@@ -0,0 +1,5 @@
1
+<vector android:height="24dp" android:tint="#FAFAFA"
2
+    android:viewportHeight="24" android:viewportWidth="24"
3
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4
+    <path android:fillColor="@android:color/white" android:pathData="M4.25,5.61C6.27,8.2 10,13 10,13v6c0,0.55 0.45,1 1,1h2c0.55,0 1,-0.45 1,-1v-6c0,0 3.72,-4.8 5.74,-7.39C20.25,4.95 19.78,4 18.95,4H5.04C4.21,4 3.74,4.95 4.25,5.61z"/>
5
+</vector>

Двоичные данные
Floradex20/app/src/main/res/drawable/star.png Просмотреть файл


Двоичные данные
Floradex20/app/src/main/res/drawable/star_1.png Просмотреть файл


+ 66
- 0
Floradex20/app/src/main/res/layout/activity_filtering.xml Просмотреть файл

@@ -0,0 +1,66 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout 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:layout_width="match_parent"
6
+    android:layout_height="match_parent"
7
+    tools:context=".activities.FilteringActivity">
8
+
9
+
10
+    <EditText
11
+        android:id="@+id/editTextNombreSci"
12
+        android:layout_width="wrap_content"
13
+        android:layout_height="wrap_content"
14
+        android:layout_alignParentTop="true"
15
+        android:layout_centerHorizontal="true"
16
+        android:layout_marginTop="153dp"
17
+        android:ems="10"
18
+        android:hint="@string/nombre_sci"
19
+        android:inputType="textPersonName"
20
+        android:importantForAutofill="no" />
21
+
22
+    <EditText
23
+        android:id="@+id/editTextFlowerColor"
24
+        android:layout_width="wrap_content"
25
+        android:layout_height="wrap_content"
26
+        android:layout_alignParentBottom="true"
27
+        android:layout_centerHorizontal="true"
28
+        android:layout_marginBottom="441dp"
29
+        android:ems="10"
30
+        android:hint="@string/flower_color"
31
+        android:importantForAutofill="no"
32
+        android:inputType="textPersonName" />
33
+
34
+    <ToggleButton
35
+        android:id="@+id/toggleButtonEdible"
36
+        android:layout_width="wrap_content"
37
+        android:layout_height="wrap_content"
38
+        android:layout_alignParentTop="true"
39
+        android:layout_centerHorizontal="true"
40
+        android:layout_marginTop="315dp"
41
+        android:textOff="@string/not_edible"
42
+        android:textOn="@string/edible" />
43
+
44
+    <ToggleButton
45
+        android:id="@+id/toggleButtonVegetable"
46
+        android:layout_width="wrap_content"
47
+        android:layout_height="wrap_content"
48
+        android:layout_below="@+id/toggleButtonEdible"
49
+        android:layout_alignParentBottom="true"
50
+        android:layout_centerHorizontal="true"
51
+        android:layout_marginTop="26dp"
52
+        android:layout_marginBottom="294dp"
53
+        android:textOff="@string/not_vegetable"
54
+        android:textOn="@string/vegetable" />
55
+
56
+    <Button
57
+        android:id="@+id/buttonApply"
58
+        style="@style/Widget.AppCompat.Button.Borderless.Colored"
59
+        android:layout_width="wrap_content"
60
+        android:layout_height="wrap_content"
61
+        android:layout_alignParentBottom="true"
62
+        android:layout_centerHorizontal="true"
63
+        android:layout_marginBottom="159dp"
64
+        android:text="@string/apply" />
65
+
66
+</RelativeLayout>

+ 0
- 123
Floradex20/app/src/main/res/layout/activity_main.xml Просмотреть файл

@@ -1,123 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<RelativeLayout
3
-    xmlns:android="http://schemas.android.com/apk/res/android"
4
-    xmlns:app="http://schemas.android.com/apk/res-auto"
5
-    xmlns:tools="http://schemas.android.com/tools"
6
-    android:layout_width="match_parent"
7
-    android:layout_height="match_parent"
8
-    tools:context=".MainActivity">
9
-    <TextView
10
-        android:layout_centerHorizontal="true"
11
-        android:layout_width="wrap_content"
12
-        android:layout_height="wrap_content"
13
-        android:text="Floradex"
14
-        android:layout_margin="20dp"
15
-        android:id="@+id/title"
16
-        android:textSize="20sp"/>
17
-
18
-    <androidx.recyclerview.widget.RecyclerView
19
-        android:id="@+id/recyclerView"
20
-        android:layout_width="match_parent"
21
-        android:layout_height="wrap_content"
22
-        android:layout_margin="10dp"
23
-        android:layout_below="@+id/title" />
24
-
25
-    <ProgressBar
26
-        android:id="@+id/progress_bar"
27
-        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
28
-        android:layout_width="match_parent"
29
-        android:layout_height="5dp"
30
-        android:scaleY="4"
31
-        android:indeterminateTint="@color/purple_200"
32
-        android:indeterminateBehavior="repeat"
33
-        android:indeterminate="true" />
34
-</RelativeLayout>
35
-
36
-    <!--<?xml version="1.0" encoding="utf-8"?>-->
37
-<!--<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
38
-<!--    android:layout_width="match_parent"-->
39
-<!--    android:layout_height="match_parent"-->
40
-<!--    android:orientation="vertical" >-->
41
-<!--    <TextView android:id="@+id/text"-->
42
-<!--        android:layout_width="wrap_content"-->
43
-<!--        android:layout_height="wrap_content"-->
44
-<!--        android:text="Hello, I am a TextView" />-->
45
-<!--    <Button android:id="@+id/button"-->
46
-<!--        android:layout_width="wrap_content"-->
47
-<!--        android:layout_height="wrap_content"-->
48
-<!--        android:text="Hello, I am a Button" />-->
49
-<!--</LinearLayout>-->
50
-
51
-<!--<android.support.v7.widget.RecyclerView android:id="@+id/my_recycler_view"-->
52
-<!--    android:scrollbars="vertical"-->
53
-<!--    android:layout_width="match_parent"-->
54
-<!--    android:layout_height="match_parent"-->
55
-<!--    layout_height="8"-->
56
-<!--    xmlns:android="http://schemas.android.com/apk/res/android" />-->
57
-
58
-
59
-
60
-<!--    <TextView-->
61
-<!--        android:id="@+id/author"-->
62
-<!--        android:layout_width="wrap_content"-->
63
-<!--        android:layout_height="wrap_content"-->
64
-<!--        android:text="@string/author"-->
65
-<!--        android:textAppearance="@style/TextAppearance.AppCompat.Large"-->
66
-<!--        app:layout_constraintBottom_toBottomOf="parent"-->
67
-<!--        app:layout_constraintEnd_toEndOf="parent"-->
68
-<!--        app:layout_constraintHorizontal_bias="0.506"-->
69
-<!--        app:layout_constraintStart_toStartOf="parent"-->
70
-<!--        app:layout_constraintTop_toBottomOf="@+id/year"-->
71
-<!--        app:layout_constraintVertical_bias="0.239" />-->
72
-
73
-<!--    <TextView-->
74
-<!--        android:id="@+id/sci_name"-->
75
-<!--        android:layout_width="wrap_content"-->
76
-<!--        android:layout_height="wrap_content"-->
77
-<!--        android:text="@string/scientific_name"-->
78
-<!--        android:textAppearance="@style/TextAppearance.AppCompat.Large"-->
79
-<!--        app:layout_constraintBottom_toBottomOf="parent"-->
80
-<!--        app:layout_constraintEnd_toEndOf="parent"-->
81
-<!--        app:layout_constraintHorizontal_bias="0.507"-->
82
-<!--        app:layout_constraintStart_toStartOf="parent"-->
83
-<!--        app:layout_constraintTop_toBottomOf="@+id/plant_name"-->
84
-<!--        app:layout_constraintVertical_bias="0.155" />-->
85
-
86
-<!--    <TextView-->
87
-<!--        android:id="@+id/plant_name"-->
88
-<!--        android:layout_width="wrap_content"-->
89
-<!--        android:layout_height="wrap_content"-->
90
-<!--        android:text="@string/plant_name"-->
91
-<!--        android:textAppearance="@style/TextAppearance.AppCompat.Large"-->
92
-<!--        app:layout_constraintBottom_toBottomOf="parent"-->
93
-<!--        app:layout_constraintEnd_toEndOf="parent"-->
94
-<!--        app:layout_constraintHorizontal_bias="0.511"-->
95
-<!--        app:layout_constraintStart_toStartOf="parent"-->
96
-<!--        app:layout_constraintTop_toTopOf="parent"-->
97
-<!--        app:layout_constraintVertical_bias="0.57" />-->
98
-
99
-<!--    <TextView-->
100
-<!--        android:id="@+id/year"-->
101
-<!--        android:layout_width="wrap_content"-->
102
-<!--        android:layout_height="wrap_content"-->
103
-<!--        android:text="@string/year"-->
104
-<!--        android:textAppearance="@style/TextAppearance.AppCompat.Large"-->
105
-<!--        app:layout_constraintBottom_toBottomOf="parent"-->
106
-<!--        app:layout_constraintEnd_toEndOf="parent"-->
107
-<!--        app:layout_constraintHorizontal_bias="0.506"-->
108
-<!--        app:layout_constraintStart_toStartOf="parent"-->
109
-<!--        app:layout_constraintTop_toBottomOf="@+id/sci_name"-->
110
-<!--        app:layout_constraintVertical_bias="0.186" />-->
111
-
112
-<!--    <ImageView-->
113
-<!--        android:id="@+id/plantview"-->
114
-<!--        android:layout_width="wrap_content"-->
115
-<!--        android:layout_height="wrap_content"-->
116
-<!--        android:contentDescription="@string/plant_display"-->
117
-<!--        app:layout_constraintBottom_toTopOf="@+id/plant_name"-->
118
-<!--        app:layout_constraintEnd_toEndOf="parent"-->
119
-<!--        app:layout_constraintHorizontal_bias="0.498"-->
120
-<!--        app:layout_constraintStart_toStartOf="parent"-->
121
-<!--        app:layout_constraintTop_toTopOf="parent"-->
122
-<!--        app:srcCompat="@drawable/ic_launcher_foreground" />-->
123
-<!--</androidx.constraintlayout.widget.ConstraintLayout>-->

+ 62
- 0
Floradex20/app/src/main/res/layout/discover_activity.xml Просмотреть файл

@@ -0,0 +1,62 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout 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/discover_activity"
6
+    android:layout_width="match_parent"
7
+    android:layout_height="match_parent"
8
+    tools:context=".activities.MainActivity">
9
+
10
+
11
+    <Button
12
+        android:id="@+id/search_enter"
13
+        android:layout_width="60dp"
14
+        android:layout_height="40dp"
15
+        android:layout_alignParentTop="true"
16
+        android:layout_alignParentEnd="true"
17
+        android:layout_marginTop="79dp"
18
+        android:layout_marginEnd="38dp"
19
+        android:text="@string/enter"
20
+        android:textSize="10sp" />
21
+
22
+
23
+    <EditText
24
+        android:id="@+id/search"
25
+        android:layout_width="200dp"
26
+        android:layout_height="40dp"
27
+        android:layout_alignParentTop="true"
28
+        android:layout_centerHorizontal="true"
29
+        android:layout_marginTop="77dp"
30
+        android:ems="10"
31
+        android:hint="@string/escriba_nombre_de_planta"
32
+        android:inputType="textPersonName"
33
+        android:textSize="14sp" />
34
+
35
+    <TextView
36
+        android:id="@+id/title"
37
+        android:layout_width="wrap_content"
38
+        android:layout_height="wrap_content"
39
+        android:layout_centerHorizontal="true"
40
+        android:layout_margin="20dp"
41
+        android:text="Floradex"
42
+        android:textSize="20sp" />
43
+
44
+    <androidx.recyclerview.widget.RecyclerView
45
+        android:id="@+id/recyclerView"
46
+        android:layout_width="match_parent"
47
+        android:layout_height="wrap_content"
48
+        android:layout_below="@+id/title"
49
+        android:layout_alignParentStart="true"
50
+        android:layout_marginTop="83dp"
51
+        android:layout_marginBottom="10dp" />
52
+
53
+    <ProgressBar
54
+        android:id="@+id/progress_bar"
55
+        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
56
+        android:layout_width="match_parent"
57
+        android:layout_height="5dp"
58
+        android:indeterminate="true"
59
+        android:indeterminateBehavior="repeat"
60
+        android:indeterminateTint="@color/purple_200"
61
+        android:scaleY="4" />
62
+</RelativeLayout>

+ 9
- 0
Floradex20/app/src/main/res/layout/layout.xml Просмотреть файл

@@ -1,6 +1,7 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3
 
4
+    xmlns:app="http://schemas.android.com/apk/res-auto"
4 5
     android:orientation="vertical"
5 6
     android:layout_width="match_parent"
6 7
     android:layout_height="wrap_content">
@@ -35,6 +36,14 @@
35 36
                 android:textSize="15sp"
36 37
                 android:text="Flower Name "/>
37 38
 
39
+            <ImageView
40
+                android:id="@+id/imageView"
41
+                android:layout_width="26dp"
42
+                android:layout_height="21dp"
43
+                android:layout_alignParentEnd="true"
44
+                android:layout_marginTop="21dp"
45
+                android:layout_marginEnd="332dp"
46
+                app:srcCompat="@drawable/star" />
38 47
 
39 48
 
40 49
         </RelativeLayout>

+ 44
- 0
Floradex20/app/src/main/res/layout/login.xml Просмотреть файл

@@ -0,0 +1,44 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:tools="http://schemas.android.com/tools"
4
+    android:layout_width="match_parent"
5
+    android:layout_height="match_parent"
6
+    >
7
+
8
+    <EditText
9
+        android:id="@+id/email"
10
+        android:layout_width="match_parent"
11
+        android:layout_height="50dp"
12
+        android:hint="juan.delpueblo@upr.edu"
13
+        android:layout_marginLeft="20dp"
14
+        android:layout_marginRight="20dp"
15
+        android:padding="15dp"
16
+        android:inputType="textEmailAddress"
17
+        android:layout_above="@id/password"
18
+        android:textSize="15sp" />
19
+
20
+    <EditText
21
+        android:id="@+id/password"
22
+        android:layout_width="match_parent"
23
+        android:layout_height="50dp"
24
+        android:hint="password"
25
+        android:layout_marginLeft="20dp"
26
+        android:layout_marginRight="20dp"
27
+        android:layout_marginTop="10dp"
28
+        android:padding="15dp"
29
+        android:inputType="textPassword"
30
+        android:layout_centerInParent="true"
31
+        android:textSize="15sp" />
32
+
33
+    <Button
34
+        android:id="@+id/login_button"
35
+        android:layout_width="match_parent"
36
+        android:layout_height="wrap_content"
37
+        android:layout_below="@id/password"
38
+        android:layout_marginLeft="20dp"
39
+        android:layout_marginRight="20dp"
40
+        android:layout_marginTop="15dp"
41
+        android:textColor="@android:color/white"
42
+        android:text="Log In"/>
43
+
44
+</RelativeLayout>

+ 101
- 0
Floradex20/app/src/main/res/layout/register.xml Просмотреть файл

@@ -0,0 +1,101 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<LinearLayout
3
+    xmlns:android="http://schemas.android.com/apk/res/android"
4
+    xmlns:tools="http://schemas.android.com/tools"
5
+    android:layout_width="match_parent"
6
+    android:layout_height="match_parent"
7
+    android:orientation="vertical">
8
+<!--    tools:context=".RegisterFragment">-->
9
+
10
+    <TextView
11
+        android:id="@+id/tv_logo"
12
+        android:layout_width="wrap_content"
13
+        android:layout_height="wrap_content"
14
+        android:text="@string/register"
15
+        android:textAlignment="center"
16
+        android:textSize="50sp"
17
+        android:layout_marginStart="25dp"
18
+        android:layout_marginBottom="5dp"
19
+        android:layout_marginTop="60dp"/>
20
+
21
+    <EditText
22
+        android:id="@+id/et_name"
23
+        android:layout_width="match_parent"
24
+        android:layout_height="50dp"
25
+        android:hint="@string/your_name"
26
+        android:layout_marginLeft="20dp"
27
+        android:layout_marginRight="20dp"
28
+        android:layout_marginBottom="10dp"
29
+        android:padding="15dp"
30
+        android:inputType="textPersonName"
31
+        android:textSize="15sp" />
32
+
33
+    <EditText
34
+        android:id="@+id/et_email"
35
+        android:layout_width="match_parent"
36
+        android:layout_height="50dp"
37
+        android:hint="@string/e_mail"
38
+        android:layout_marginLeft="20dp"
39
+        android:layout_marginRight="20dp"
40
+        android:layout_marginBottom="10dp"
41
+        android:padding="15dp"
42
+        android:inputType="textEmailAddress"
43
+        android:textSize="15sp" />
44
+
45
+    <EditText
46
+        android:id="@+id/et_password"
47
+        android:layout_width="match_parent"
48
+        android:layout_height="50dp"
49
+        android:hint="@string/password"
50
+        android:layout_marginLeft="20dp"
51
+        android:layout_marginRight="20dp"
52
+        android:layout_marginBottom="10dp"
53
+        android:padding="15dp"
54
+        android:inputType="textPassword"
55
+        android:textSize="15sp" />
56
+
57
+    <EditText
58
+        android:id="@+id/et_repassword"
59
+        android:layout_width="match_parent"
60
+        android:layout_height="50dp"
61
+        android:hint="@string/re_type_password"
62
+        android:layout_marginLeft="20dp"
63
+        android:layout_marginRight="20dp"
64
+        android:padding="15dp"
65
+        android:inputType="textPassword"
66
+        android:textSize="15sp" />
67
+
68
+    <RelativeLayout
69
+        android:layout_width="match_parent"
70
+        android:layout_height="0dp"
71
+        android:layout_weight="1">
72
+
73
+        <Button
74
+            android:id="@+id/btn_register"
75
+            android:layout_width="match_parent"
76
+            android:layout_height="wrap_content"
77
+            android:layout_marginLeft="20dp"
78
+            android:layout_marginRight="20dp"
79
+            android:layout_marginBottom="30dp"
80
+            android:layout_centerInParent="true"
81
+            android:textColor="@android:color/white"
82
+            android:text="@string/register"/>
83
+
84
+        <ImageView
85
+            android:layout_width="30dp"
86
+            android:layout_height="30dp"
87
+            android:layout_above="@id/to_login_activity"
88
+            android:layout_centerHorizontal="true"/>
89
+
90
+        <Button
91
+            android:id="@+id/to_login_activity"
92
+            android:layout_width="wrap_content"
93
+            android:layout_height="wrap_content"
94
+            android:text="Already registered?"
95
+            android:layout_centerHorizontal="true"
96
+            android:layout_alignParentBottom="true"
97
+            android:layout_marginBottom="20dp"/>
98
+
99
+    </RelativeLayout>
100
+
101
+</LinearLayout>

+ 1
- 1
Floradex20/app/src/main/res/layout/ventanita.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=".MainActivity">
9
+    tools:context=".activities.MainActivity">
10 10
 
11 11
     <TextView
12 12
         android:id="@+id/author"

+ 9
- 0
Floradex20/app/src/main/res/menu/filter_menu.xml Просмотреть файл

@@ -0,0 +1,9 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:app="http://schemas.android.com/apk/res-auto">
4
+
5
+    <item android:id = "@+id/filterIcon"
6
+        android:icon= "@drawable/filter"
7
+        android:title= "@string/filter_menu"
8
+        app:showAsAction="ifRoom" />
9
+</menu>

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

@@ -10,5 +10,25 @@
10 10
     <string name="year">Year</string>
11 11
     <string name="author">Author</string>
12 12
     <string name="plant_display">Plant Display</string>
13
+    <string name="enter">Enter</string>
14
+    <string name="escriba_nombre_de_planta">Search for plant</string>
15
+    <string name="filter_menu">Filter Menu</string>
16
+    <string name="nombre_sci">Scientific Name</string>
17
+    <string name="edible">Edible</string>
18
+    <string name="flower_color">Flower Color</string>
19
+    <string name="not_edible">Not Edible</string>
20
+    <string name="not_vegetable">Not Vegetable</string>
21
+    <string name="vegetable">Vegetable</string>
22
+    <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
+    <string name="password">Password</string>
27
+    <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
+    <string name="register">Register</string>
31
+    <string name="re_type_password">Re-type Password</string>
32
+    <string name="your_name">Full Name</string>
13 33
 
14 34
 </resources>