some changes

This commit is contained in:
Tucan444 2021-03-31 19:23:37 +02:00
parent 42ea609e52
commit 4161f49870
50 changed files with 827 additions and 208 deletions

@ -53,4 +53,7 @@ dependencies {
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

@ -1,20 +1,24 @@
package com.example.wikispot.activities package com.example.wikispot.activities
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import androidx.navigation.findNavController import androidx.navigation.findNavController
import androidx.navigation.ui.setupWithNavController import androidx.navigation.ui.setupWithNavController
import com.example.wikispot.* import com.example.wikispot.IntentsKeys
import com.example.wikispot.R
import com.example.wikispot.ServerManagement
import com.example.wikispot.fragments.* import com.example.wikispot.fragments.*
import com.example.wikispot.getThemeId
import com.example.wikispot.modelClasses.JsonManager import com.example.wikispot.modelClasses.JsonManager
import com.example.wikispot.modelClasses.JsonManagerLite
import com.example.wikispot.modelClasses.SettingsSaveManager import com.example.wikispot.modelClasses.SettingsSaveManager
import com.example.wikispot.modelsForAdapters.PlacePreview import com.example.wikispot.modelsForAdapters.PlacePreview
import com.example.wikispot.modelsForAdapters.PlaceSupplier import com.example.wikispot.modelsForAdapters.PlaceSupplier
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_home.*
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
@ -51,12 +55,7 @@ class MainActivity : AppCompatActivity() {
when (mainFragmentHost.childFragmentManager.fragments[0]) { when (mainFragmentHost.childFragmentManager.fragments[0]) {
is chatFragment -> {} is chatFragment -> {}
is exploreFragment -> {} is exploreFragment -> {}
is homeFragment -> { is homeFragment -> {}
val view = mainFragmentHost.childFragmentManager.fragments[0].homeFragmentTextIdTest
view.post {
view.text = data
}
}
is mapFragment -> {} is mapFragment -> {}
is settingsFragment -> {} is settingsFragment -> {}
} }
@ -64,13 +63,15 @@ class MainActivity : AppCompatActivity() {
} }
//ServerManagement.serverManager.addReceiverConnection(dataReceiver, this, "mainConnection", 0, "test0.json") ServerManagement.serverManager.addReceiverConnection(dataReceiver, this, "mainConnection", 0, "test0.json")
connectExploreFragmentAdapterModel() connectExploreFragmentAdapterModel()
} }
override fun onPause() { override fun onPause() {
super.onPause() PlaceSupplier.saveToCache(this)
ServerManagement.serverManager.deleteConnection("mainConnection") ServerManagement.serverManager.deleteConnection("mainConnection")
ServerManagement.serverManager.deleteConnection("exploreListConnection")
super.onPause()
} }
private fun handleExtras() { private fun handleExtras() {
@ -90,27 +91,69 @@ class MainActivity : AppCompatActivity() {
} }
private fun connectExploreFragmentAdapterModel () { private fun connectExploreFragmentAdapterModel () {
// loading from cache
PlaceSupplier.loadFromCache(this)
// connecting to server
val dataReceiver: (String) -> Unit = {data: String -> val dataReceiver: (String) -> Unit = {data: String ->
val json = JsonManager(this, data) val json = JsonManager(this, data)
for (i in 0 until json.getLengthOfJsonArray()) { // todo change to 1
if (PlaceSupplier.controlJson == null) {
PlaceSupplier.controlJson = JsonManagerLite(data)
}
for (i in 1 until json.getLengthOfJsonArray()) { // todo change to 1
json.getJsonObject(i) json.getJsonObject(i)
val id = json.getAttributeContent("ID").toInt()
json.getAttributeContent("description") json.getAttributeContent("description")
val title = json.getAttributeContent("title") val title = json.getAttributeContent("title")
val shortDescription = json.getAttributeContent("description_s") val shortDescription = json.getAttributeContent("description_s")
val place = PlacePreview(title, shortDescription) val place = PlacePreview(title, shortDescription, null, id)
if (!PlaceSupplier.places.contains(place)) {
if (!PlaceSupplier.checkIfContains(place)) {
val imageReceiver: (Bitmap) -> Unit = {bitmap: Bitmap ->
place.img = bitmap
}
ServerManagement.serverManager.getImage(imageReceiver, id, "test.png", 3)
PlaceSupplier.appendPlace(place) PlaceSupplier.appendPlace(place)
} else {
val containingPlace = PlaceSupplier.getContainingInstance(place)
if ((containingPlace != null) and (containingPlace?.img == null)) {
val imageReceiver: (Bitmap) -> Unit = {bitmap: Bitmap ->
containingPlace?.img = bitmap
}
ServerManagement.serverManager.getImage(imageReceiver, id, "test.png", 3)
}
} }
json.clearSelectedAttribute()
} }
} }
ServerManagement.serverManager.addReceiverConnection(dataReceiver, this, "exploreListConnection", 0, "", "GET_JSON_ARRAY") ServerManagement.serverManager.addReceiverConnection(dataReceiver, this, "exploreListConnection", 0, "", "GET_WHOLE_ARRAY", 10000)
} }
private fun restartAppPartially() { private fun restartAppPartially() { // todo remove if not used
val intent = Intent(applicationContext, MainActivity::class.java) val intent = Intent(applicationContext, MainActivity::class.java)
intent.putExtra(IntentsKeys.startFragment, "settingsFragment") var currentNavHostFragmentName = "homeFragment"
try {
when (mainFragmentHost.childFragmentManager.fragments[0]) {
is chatFragment -> {currentNavHostFragmentName = "chatFragment"}
is exploreFragment -> {currentNavHostFragmentName= "exploreFragment"}
is homeFragment -> {currentNavHostFragmentName = "homeFragment"}
is mapFragment -> {currentNavHostFragmentName = "mapFragment"}
is settingsFragment -> {currentNavHostFragmentName = "settingsFragment"}
}
} catch (e: Throwable) { println(e) }
intent.putExtra(IntentsKeys.startFragment, currentNavHostFragmentName)
startActivity(intent) startActivity(intent)
finish() finish()

@ -4,9 +4,12 @@ import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.navigation.Navigation
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.example.wikispot.R import com.example.wikispot.R
import com.example.wikispot.ServerManagement
import com.example.wikispot.modelsForAdapters.PlacePreview import com.example.wikispot.modelsForAdapters.PlacePreview
import com.example.wikispot.showToast
import kotlinx.android.synthetic.main.explore_list_item.view.* import kotlinx.android.synthetic.main.explore_list_item.view.*
@ -18,6 +21,10 @@ class PlacePreviewsAdapter(private val context: Context, private val placePrevie
var pos: Int = 0 var pos: Int = 0
init { init {
itemView.setOnClickListener {
ServerManagement.selectedServerId = currentPlacePreview?.id!!
Navigation.findNavController(it).navigate(R.id.navigateToInfoFragment)
}
} }
fun setData(placePreview: PlacePreview?, pos: Int) { fun setData(placePreview: PlacePreview?, pos: Int) {
@ -25,7 +32,7 @@ class PlacePreviewsAdapter(private val context: Context, private val placePrevie
itemView.item_title.text = placePreview.title itemView.item_title.text = placePreview.title
itemView.item_description.text = placePreview.description itemView.item_description.text = placePreview.description
placePreview.img?.let { placePreview.img?.let {
// TODO set image somehow itemView.item_img.setImageBitmap(placePreview.img)
} }
} }

@ -1,10 +1,15 @@
package com.example.wikispot.fragments package com.example.wikispot.fragments
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.example.wikispot.GeneralVariables
import com.example.wikispot.IntentsKeys
import com.example.wikispot.R import com.example.wikispot.R
import com.example.wikispot.ServerManagement
import com.example.wikispot.activities.MainActivity
import com.example.wikispot.adapters.PlacePreviewsAdapter import com.example.wikispot.adapters.PlacePreviewsAdapter
import com.example.wikispot.modelsForAdapters.PlaceSupplier import com.example.wikispot.modelsForAdapters.PlaceSupplier
import kotlinx.android.synthetic.main.fragment_explore.* import kotlinx.android.synthetic.main.fragment_explore.*

@ -1,21 +1,50 @@
package com.example.wikispot.fragments package com.example.wikispot.fragments
import android.os.Bundle import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import androidx.fragment.app.Fragment
import com.example.wikispot.R import com.example.wikispot.R
import com.example.wikispot.getStringFromSharedPreferences import com.example.wikispot.ServerManagement
import com.example.wikispot.saveString import com.example.wikispot.modelClasses.JsonManager
import kotlinx.android.synthetic.main.fragment_home.* import kotlinx.android.synthetic.main.fragment_home.*
import kotlinx.android.synthetic.main.fragment_info.view.*
class homeFragment : Fragment(R.layout.fragment_home) { class homeFragment : Fragment(R.layout.fragment_home) {
var infoFragmentLoadedIn = false
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
//loadCache() loadCache()
}
override fun onResume() {
super.onResume()
// connecting to server
val dataReceiver: (String) -> Unit = {data: String ->
try {
val json = JsonManager(requireContext(), data)
json.findJsonObjectByAttribute("ID", json.getAttributeContent("connected_id"))
if (!infoFragmentLoadedIn) {
infoFragmentLoadedIn = true
homeFragmentInnerFragment.post {
homeFragmentInnerFragment.let { fragment ->
fragment.mainTitle.text = json.getAttributeContentByPath("description/title")
fragment.mainDescription.text = json.getAttributeContentByPath("description/description_l")
}
}
}
} catch (e: Throwable) { println(e) }
}
ServerManagement.serverManager.getData(dataReceiver, requireContext(), 0, "", "GET_JSON_ARRAY", 3)
} }
override fun onPause() { override fun onPause() {
@ -23,11 +52,7 @@ class homeFragment : Fragment(R.layout.fragment_home) {
saveCache() saveCache()
} }
private fun loadCache() { private fun loadCache() {}
homeFragmentTextIdTest.text = requireContext().getStringFromSharedPreferences("title", "homeFragmentCache" )
}
private fun saveCache() { private fun saveCache() {}
requireContext().saveString("title", homeFragmentTextIdTest.text.toString(), "homeFragmentCache")
}
} }

@ -0,0 +1,19 @@
package com.example.wikispot.fragments
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.wikispot.R
import com.example.wikispot.modelClasses.JsonManager
import kotlinx.android.synthetic.main.fragment_info.*
class infoFragment() : Fragment(R.layout.fragment_info) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}

@ -7,7 +7,7 @@ import com.example.wikispot.showToast
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
data class JsonManager(val context: Context, val data: String, val inputType: String = "JSONArray", val debug: Boolean = false) { data class JsonManager(private val context: Context, val data: String, val inputType: String = "JSONArray", val debug: Boolean = false) {
var jsonArray: JSONArray? = null var jsonArray: JSONArray? = null
var currentJsonObject: JSONObject? = null var currentJsonObject: JSONObject? = null
@ -66,7 +66,9 @@ data class JsonManager(val context: Context, val data: String, val inputType: St
try { try {
return currentJsonAttribute0!!.get(name).toString() return currentJsonAttribute0!!.get(name).toString()
} catch (exception: Throwable) { } catch (exception: Throwable) {
context.showToast("Invalid attribute name") if (debug) {
context.showToast("Invalid attribute name: $name")
}
} }
} }
} }
@ -83,7 +85,9 @@ data class JsonManager(val context: Context, val data: String, val inputType: St
try { try {
return currentJsonAttribute1!!.get(name.toInt()).toString() return currentJsonAttribute1!!.get(name.toInt()).toString()
} catch (exception: Throwable) { } catch (exception: Throwable) {
context.showToast("Invalid attribute name") if (debug) {
context.showToast("Invalid attribute name: $name")
}
} }
} }
} }
@ -100,13 +104,17 @@ data class JsonManager(val context: Context, val data: String, val inputType: St
try { try {
return currentJsonObject!!.get(name).toString() return currentJsonObject!!.get(name).toString()
} catch (exception: Throwable) { } catch (exception: Throwable) {
context.showToast("Invalid attribute name") if (debug) {
context.showToast("Invalid attribute name: $name")
}
} }
} }
} }
} }
} else { } else {
context.showToast("Json file is null") if (debug) {
context.showToast("Invalid attribute name: $name")
}
} }
return "" return ""
@ -166,6 +174,30 @@ data class JsonManager(val context: Context, val data: String, val inputType: St
return "get json attribute first" return "get json attribute first"
} }
fun findJsonObjectByAttribute(attributePath: String, value: Any): String {
val currentJsonObjectSave = currentJsonObject
for (i in 0 until getLengthOfJsonArray()) {
getJsonObject(i)
val attributeContent = getAttributeContentByPath(attributePath)
if (attributeContent != "null") {
if (attributeContent == value.toString()) {
return currentJsonObject.toString()
}
}
}
currentJsonObject = currentJsonObjectSave
return currentJsonObject.toString()
}
// saving and loading // saving and loading
fun saveJson(accessKey: String) { fun saveJson(accessKey: String) {

@ -0,0 +1,139 @@
package com.example.wikispot.modelClasses
import android.content.Context
import com.example.wikispot.getStringFromSharedPreferences
import com.example.wikispot.saveString
import com.example.wikispot.showToast
import org.json.JSONArray
import org.json.JSONObject
data class JsonManagerLite(val data: String, val inputType: String = "JSONArray") {
var jsonArray: JSONArray? = null
var currentJsonObject: JSONObject? = null
private var currentJsonAttribute0: JSONObject? = null
private var currentJsonAttribute1: JSONArray? = null
init {
if (inputType == "JSONArray") {
jsonArray = JSONArray(data)
try {
currentJsonObject = jsonArray!!.getJSONObject(0)
} catch (exception: Throwable) {}
} else if (inputType == "JSONObject") {
currentJsonObject = JSONObject(data)
}
}
fun getJsonObject(i: Int): JSONObject? {
jsonArray?.let {
currentJsonObject = jsonArray?.getJSONObject(i)
return currentJsonObject
}
return null
}
fun getAttributeContent(name: String): String {
if (currentJsonObject != null) {
if (currentJsonAttribute0 != null) {
try {
currentJsonAttribute0 = currentJsonAttribute0!!.getJSONObject(name)
return currentJsonAttribute0.toString()
} catch (exception: Throwable) {
try {
currentJsonAttribute1 = currentJsonAttribute0!!.getJSONArray(name)
currentJsonAttribute0 = null
return currentJsonAttribute1.toString()
} catch (exception: Throwable) {
try {
return currentJsonAttribute0!!.get(name).toString()
} catch (exception: Throwable) { }
}
}
} else if (currentJsonAttribute1 != null) {
try {
currentJsonAttribute0 = currentJsonAttribute1!!.getJSONObject(name.toInt())
return currentJsonAttribute0.toString()
} catch (exception: Throwable) {
try {
currentJsonAttribute1 = currentJsonAttribute1!!.getJSONArray(name.toInt())
currentJsonAttribute0 = null
return currentJsonAttribute1.toString()
} catch (exception: Throwable) {
try {
return currentJsonAttribute1!!.get(name.toInt()).toString()
} catch (exception: Throwable) { }
}
}
} else {
try {
currentJsonAttribute0 = currentJsonObject!!.getJSONObject(name)
return currentJsonAttribute0.toString()
} catch (exception: Throwable) {
try {
currentJsonAttribute1 = currentJsonObject!!.getJSONArray(name)
currentJsonAttribute0 = null
return currentJsonAttribute1.toString()
} catch (exception: Throwable) {
try {
return currentJsonObject!!.get(name).toString()
} catch (exception: Throwable) { }
}
}
}
}
return ""
}
fun getAttributeContentByPath(path: String): String {
val steps = path.split("/")
val currentJsonAttributesBackup = listOf(currentJsonAttribute0, currentJsonAttribute1) // backing up selected jsonAttributes
// getting the attribute
clearSelectedAttribute()
var result: Any? = null
for (step in steps) {
try {
result = getAttributeContent(step)
} catch (exception: Throwable) {
// loading back saved json attributes
currentJsonAttribute0 = currentJsonAttributesBackup[0] as JSONObject?
currentJsonAttribute1 = currentJsonAttributesBackup[1] as JSONArray?
return ""
}
}
// loading back saved json attributes
currentJsonAttribute0 = currentJsonAttributesBackup[0] as JSONObject?
currentJsonAttribute1 = currentJsonAttributesBackup[1] as JSONArray?
// returning result
return result.toString()
}
fun clearSelectedAttribute() {
currentJsonAttribute0 = null
currentJsonAttribute1 = null
}
fun getLengthOfJsonArray(): Int {
return if (jsonArray != null) {
jsonArray!!.length()
} else {
0
}
}
fun getCurrentJsonAttributeContent(): String {
if (currentJsonAttribute0 != null) {
return currentJsonAttribute0.toString()
} else if (currentJsonAttribute1 != null) {
return currentJsonAttribute1.toString()
}
return "get json attribute first"
}
}

@ -1,12 +1,15 @@
package com.example.wikispot.modelClasses package com.example.wikispot.modelClasses
import android.content.Context import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.widget.TextView import android.widget.TextView
import com.example.wikispot.ServerManagement import com.example.wikispot.ServerManagement
import okhttp3.* import okhttp3.*
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
import java.io.IOException import java.io.IOException
import java.io.InputStream
class ServerManager { class ServerManager {
@ -43,6 +46,10 @@ class ServerManager {
val jsonManager = JsonManager(context, receivedString) val jsonManager = JsonManager(context, receivedString)
if (path == "") { if (path == "") {
if (attributePath == "GET_JSON_ARRAY") {
dataReceiver(jsonManager.jsonArray.toString())
return
}
jsonManager.getJsonObject(serverId) jsonManager.getJsonObject(serverId)
} else { } else {
if (attributePath == "") { if (attributePath == "") {
@ -86,44 +93,74 @@ class ServerManager {
} }
} }
fun getImage(imageReceiver: (Bitmap) -> Unit, serverId: Int, path: String, numberOfAttempts: Int) {
val imageRequestThread = Thread(ImageRequest(imageReceiver, serverId, path, numberOfAttempts))
imageRequestThread.start()
}
inner class ImageRequest(val imageReceiver: (Bitmap) -> Unit, val serverId: Int, val path: String, private val numberOfAttempts: Int): Runnable {
override fun run() {
for (i in 0 until numberOfAttempts) {
val url = "${ServerManagement.baseUrl}files/$serverId/$path"
try {
val inputStream = java.net.URL(url).openStream()
val bitmap = BitmapFactory.decodeStream(inputStream)
imageReceiver(bitmap)
} catch (e: Throwable) { println(e) }
Thread.sleep(ServerManagement.imageRequestOnAttemptWait)
}
}
}
// connections // connections
fun clearConnections() { fun clearConnections() {
for (i in 0 until receiverConnections.size) { for (i in 0 until receiverConnections.size) {
receiverConnections[i].running = false try {
receiverConnections.removeAt(i) receiverConnections[i].running = false
receiverConnections.removeAt(i)
} catch (e: Throwable) { println("In clearConnections: $e") }
} }
for (i in 0 until viewConnections.size) { for (i in 0 until viewConnections.size) {
viewConnections[i].running = false try {
viewConnections.removeAt(i) viewConnections[i].running = false
viewConnections.removeAt(i)
} catch (e: Throwable) { println("In clearConnections: $e") }
} }
} }
fun deleteConnection(connectionName: String, connectionType: String="any") { // other types are any, activity and view fun deleteConnection(connectionName: String, connectionType: String="any") { // other types are any, activity and view
if ((connectionType == "any") or (connectionType == "activity")) { if ((connectionType == "any") or (connectionType == "activity")) {
for (i in 0 until receiverConnections.size) { // checking in connections for (i in 0 until receiverConnections.size) { // checking in connections
if (receiverConnections[i].connectionName == connectionName) { try {
receiverConnections[i].running = false if (receiverConnections[i].connectionName == connectionName) {
receiverConnections.removeAt(i) receiverConnections[i].running = false
} receiverConnections.removeAt(i)
}
} catch (e: Throwable) { println("In deleteConnection: $e") }
} }
} }
if ((connectionType == "any") or (connectionType == "view")) { if ((connectionType == "any") or (connectionType == "view")) {
for (i in 0 until viewConnections.size) { // checking in connections for (i in 0 until viewConnections.size) { // checking in connections
if (viewConnections[i].connectionName == connectionName) { try {
viewConnections[i].running = false if (viewConnections[i].connectionName == connectionName) {
viewConnections.removeAt(i) viewConnections[i].running = false
} viewConnections.removeAt(i)
}
} catch (e: Throwable) { println("In deleteConnection: $e") }
} }
} }
} }
fun addReceiverConnection(dataReceiver: (String) -> Unit, context: Context, connectionName: String, serverId: Int, path: String?=null, attributePath: String="") { fun addReceiverConnection(dataReceiver: (String) -> Unit, context: Context, connectionName: String, serverId: Int, path: String?=null, attributePath: String="", waitTime: Long=ServerManagement.receiverConnectionOnCheckWait) {
receiverConnections.add(ReceiverConnection(dataReceiver, context, connectionName, serverId, path, attributePath)) receiverConnections.add(ReceiverConnection(dataReceiver, context, connectionName, serverId, path, attributePath, waitTime))
} }
inner class ReceiverConnection(val dataReceiver: (String) -> Unit, val context: Context, val connectionName: String, val serverId: Int, val path: String?=null, val attributePath: String) { inner class ReceiverConnection(val dataReceiver: (String) -> Unit, val context: Context, val connectionName: String, val serverId: Int, val path: String?=null, val attributePath: String, val waitTime: Long) {
var running = true var running = true
@ -157,7 +194,7 @@ class ServerManager {
val jsonManager = JsonManager(context, receivedString) val jsonManager = JsonManager(context, receivedString)
if (path == "") { if (path == "") {
if (attributePath == "GET_JSON_ARRAY") { if (attributePath == "GET_WHOLE_ARRAY") {
dataReceiver(jsonManager.jsonArray.toString()) dataReceiver(jsonManager.jsonArray.toString())
return return
} }
@ -199,7 +236,7 @@ class ServerManager {
} }
}) })
Thread.sleep(ServerManagement.receiverConnectionOnCheckWait) Thread.sleep(waitTime)
} }
} }
} }
@ -245,6 +282,10 @@ class ServerManager {
val jsonManager = JsonManager(context, receivedString) val jsonManager = JsonManager(context, receivedString)
if (path == "") { if (path == "") {
if (attributePath == "GET_WHOLE_ARRAY") {
view.text = jsonManager.jsonArray.toString()
return
}
jsonManager.getJsonObject(serverId) jsonManager.getJsonObject(serverId)
} else { } else {
if (attributePath == "") { if (attributePath == "") {

@ -1,8 +1,15 @@
package com.example.wikispot.modelsForAdapters package com.example.wikispot.modelsForAdapters
import android.content.Context
import android.graphics.Bitmap
import android.media.Image import android.media.Image
import com.example.wikispot.getStringFromSharedPreferences
import com.example.wikispot.modelClasses.JsonManager
import com.example.wikispot.modelClasses.JsonManagerLite
import com.example.wikispot.saveString
import org.json.JSONArray
data class PlacePreview(var title: String, var description: String, var img: Image? = null) { data class PlacePreview(var title: String, var description: String, var img: Bitmap? = null, val id: Int?=null) {
init { init {
val words = description.split(" ") val words = description.split(" ")
@ -11,11 +18,15 @@ data class PlacePreview(var title: String, var description: String, var img: Ima
for (word in words) { for (word in words) {
if (lastLine.length + word.length < 40) { if (lastLine.length + word.length < 40) {
lastLine += " $word" if (lastLine != "") {
description += " $word" lastLine += " "
description += " "
}
lastLine += word
description += word
} else { } else {
description += "\n $word" description += "\n$word"
lastLine = " $word" lastLine = word
} }
} }
} }
@ -23,18 +34,9 @@ data class PlacePreview(var title: String, var description: String, var img: Ima
object PlaceSupplier { object PlaceSupplier {
var places = arrayOf<PlacePreview?>( var controlJson: JsonManagerLite? = null
PlacePreview("Castle", "Its ruins had been repaired to stable state."),
PlacePreview("Library", "You can find books here."), var places = arrayOf<PlacePreview?>()
PlacePreview("Bakery", "You can buy bread here."),
PlacePreview("School", "You can learn stuff here."),
PlacePreview("Castle", "Its ruins had been repaired to stable state."),
PlacePreview("Library", "You can find books here."),
PlacePreview("Bakery", "You can buy bread here."),
PlacePreview("School", "You can learn stuff here."),
PlacePreview("Library", "You can find books here."),
PlacePreview("Bakery", "You can buy bread here.")
)
fun appendPlace(place: PlacePreview) { fun appendPlace(place: PlacePreview) {
val array = places.copyOf(places.size + 1) val array = places.copyOf(places.size + 1)
@ -42,4 +44,83 @@ object PlaceSupplier {
places = array places = array
} }
fun checkIfContains(place: PlacePreview): Boolean {
for (n in places.indices) {
places[n]?.let {
if (places[n]?.title == place.title) {
if (places[n]?.description == place.description) {
return true
}
}
}
}
return false
}
fun getContainingInstance(place: PlacePreview): PlacePreview? {
for (n in places.indices) {
places[n]?.let {
if (places[n]?.title == place.title) {
if (places[n]?.description == place.description) {
return places[n]
}
}
}
}
return null
}
// loading from and saving to cache
fun loadFromCache(context: Context) {
println("loading")
var save = context.getStringFromSharedPreferences("placePreviews", "exploreFragmentCache")
if (save.isEmpty()) {
save = "[]"
}
val jsonManager = JsonManager(context, save)
for (n in 0 until jsonManager.getLengthOfJsonArray()) {
val savedData = jsonManager.jsonArray?.get(n).toString().split("|||||")
val place = PlacePreview(savedData[0], savedData[1], null, savedData[2].toInt())
if (!checkIfContains(place)) {
appendPlace(place)
}
}
}
fun saveToCache(context: Context) {
val save = JSONArray()
for (n in places.indices) {
val place = places[n]
if (getSavePermission(place)) {
save.put(n, "${place!!.title}|||||${place.description}|||||${place.id}")
}
}
//save.put("hi|||||sdhsiujdghsiuy|||||45")
context.saveString("placePreviews", save.toString(), "exploreFragmentCache")
}
private fun getSavePermission(place: PlacePreview?): Boolean {
if (controlJson == null) {
return true
}
place?.let {
for (n in 1 until controlJson!!.getLengthOfJsonArray()) {
controlJson!!.getJsonObject(n)
if (place.id == controlJson!!.getAttributeContent("ID").toInt()) {
if (place.title == controlJson!!.getAttributeContentByPath("description/title")) {
val tempPlace = PlacePreview("", controlJson!!.getAttributeContentByPath("description/description_s"))
if (place.description == tempPlace.description) {
return true
}
}
}
}
}
return false
}
} }

@ -18,10 +18,12 @@ object IntentsKeys {
object ServerManagement { object ServerManagement {
var serverManager = ServerManager() var serverManager = ServerManager()
const val receiverConnectionOnCheckWait: Long = 20000 const val receiverConnectionOnCheckWait: Long = 4000
const val viewConnectionOnCheckWait: Long = 5000 const val viewConnectionOnCheckWait: Long = 5000
const val dataRequestOnAttemptWait: Long = 2000 const val dataRequestOnAttemptWait: Long = 2000
const val imageRequestOnAttemptWait: Long = 2000
const val baseUrl = "http://192.168.1.230:8000/" const val baseUrl = "http://192.168.1.230:8000/"
var selectedServerId = 0
} }

@ -3,8 +3,15 @@
android:shape="rectangle"> android:shape="rectangle">
<gradient <gradient
android:centerX="1" android:centerX="1"
android:startColor="#FCDD94" android:startColor="?attr/bottomNavBarGradientStartColor"
android:endColor="#C5F8AB" android:endColor="?attr/bottomNavBarGradientEndColor"
android:angle="45" android:angle="45"
android:type="sweep" /> android:type="sweep" />
</shape> </shape>
<!-- <gradient
android:centerX="1"
android:startColor="#FCDD94"
android:endColor="#C5F8AB"
android:angle="45"
android:type="sweep" /> -->

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="?attr/chatFragmentGradientStartColor"
android:centerColor="?attr/chatFragmentGradientCenterColor"
android:endColor="?attr/chatFragmentGradientEndColor"
android:angle="90"
/>
<stroke
android:color="#7FFFFFFF"
android:width="10dp"/>
</shape>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="?attr/exploreFragmentGradientStartColor"
android:centerColor="?attr/exploreFragmentGradientCenterColor"
android:endColor="?attr/exploreFragmentGradientEndColor"
android:type="linear"
android:angle="-90"
/>
</shape>

@ -2,8 +2,14 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<gradient <gradient
android:startColor="#650822" android:startColor="?attr/homeFragmentGradientStartColor"
android:centerColor="#A7451E" android:centerColor="?attr/homeFragmentGradientCenterColor"
android:endColor="#CB7715" android:endColor="?attr/homeFragmentGradientEndColor"
android:angle="135" /> android:angle="135" />
</shape> </shape>
<!-- <gradient
android:startColor="#79AFFB"
android:centerColor="#9E94F8"
android:endColor="#EB8FFB"
android:angle="135" /> -->

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108"
android:tint="#2E0F4B">
<group android:scaleX="0.21506493"
android:scaleY="0.21506493"
android:translateX="29.16"
android:translateY="36.080723">
<group android:translateY="136.26562">
<path android:pathData="M83.765625,-16.046875L67.109375,-78L50.234375,-16.046875Q48.265625,-9,47.09375,-5.921875Q45.9375,-2.859375,43.046875,-0.421875Q40.171875,2,35.390625,2Q31.53125,2,29.03125,0.546875Q26.53125,-0.890625,24.984375,-3.53125Q23.4375,-6.1875,22.453125,-9.8125Q21.46875,-13.453125,20.703125,-16.5625L3.546875,-86.21875Q2,-92.296875,2,-95.46875Q2,-99.5,4.8125,-102.25Q7.625,-105,11.765625,-105Q17.46875,-105,19.4375,-101.3125Q21.40625,-97.640625,22.875,-90.625L36.375,-30L51.5,-86.734375Q53.1875,-93.25,54.515625,-96.640625Q55.859375,-100.046875,58.875,-102.515625Q61.90625,-105,67.109375,-105Q72.375,-105,75.296875,-102.40625Q78.21875,-99.828125,79.34375,-96.78125Q80.46875,-93.734375,82.359375,-86.734375L97.625,-30L111.125,-90.625Q112.109375,-95.375,112.984375,-98.0625Q113.859375,-100.75,116,-102.875Q118.15625,-105,122.234375,-105Q126.3125,-105,129.15625,-102.28125Q132,-99.5625,132,-95.46875Q132,-92.578125,130.45312,-86.21875L113.296875,-16.5625Q111.546875,-9.5,110.375,-6.21875Q109.21875,-2.9375,106.4375,-0.46875Q103.671875,2,98.609375,2Q93.828125,2,90.9375,-0.390625Q88.0625,-2.796875,86.9375,-5.78125Q85.8125,-8.78125,83.765625,-16.046875Z"
android:fillColor="#2E0F4B"/>
<path android:pathData="M224,-30.5Q224,-21.203125,219.23438,-13.796875Q214.46875,-6.390625,205.28125,-2.1875Q196.10938,2,183.51562,2Q168.42188,2,158.60938,-3.640625Q151.6875,-7.78125,147.35938,-14.703125Q143.03125,-21.625,143.03125,-28.171875Q143.03125,-31.96875,145.625,-34.671875Q148.21875,-37.375,152.23438,-37.375Q155.48438,-37.375,157.73438,-35.25Q159.98438,-33.125,161.57812,-28.9375Q163.54688,-23.984375,165.82812,-20.65625Q168.10938,-17.328125,172.25,-15.15625Q176.39062,-13,183.14062,-13Q192.40625,-13,198.20312,-17.359375Q204,-21.71875,204,-28.234375Q204,-33.40625,200.875,-36.625Q197.75,-39.84375,192.78125,-41.546875Q187.82812,-43.25,179.53125,-45.15625Q168.53125,-47.78125,161.10938,-51.28125Q153.70312,-54.796875,149.34375,-60.859375Q145,-66.921875,145,-75.921875Q145,-84.515625,149.59375,-91.171875Q154.1875,-97.84375,162.875,-101.421875Q171.5625,-105,183.32812,-105Q192.70312,-105,199.54688,-102.625Q206.40625,-100.25,210.92188,-96.3125Q215.45312,-92.375,217.53125,-88.046875Q219.625,-83.71875,219.625,-79.609375Q219.625,-75.84375,217.04688,-72.828125Q214.48438,-69.8125,210.65625,-69.8125Q207.15625,-69.8125,205.34375,-71.71875Q203.53125,-73.640625,201.40625,-78Q198.59375,-83.65625,194.65625,-86.828125Q190.71875,-90,182,-90Q173.92188,-90,168.95312,-86.421875Q164,-82.84375,164,-77.8125Q164,-74.703125,165.6875,-72.4375Q167.375,-70.171875,170.32812,-68.53125Q173.28125,-66.90625,176.29688,-65.984375Q179.32812,-65.0625,186.28125,-63.296875Q194.85938,-61.25,201.8125,-58.765625Q208.78125,-56.28125,213.65625,-52.734375Q218.53125,-49.203125,221.26562,-43.78125Q224,-38.359375,224,-30.5Z"
android:fillColor="#2E0F4B"/>
</group>
</group>
</vector>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="?attr/infoFragmentGradientStartColor"
android:centerColor="?attr/infoFragmentGradientCenterColor"
android:endColor="?attr/infoFragmentGradientEndColor"
android:angle="225"/>
</shape>

@ -3,9 +3,9 @@
android:shape="rectangle"> android:shape="rectangle">
<gradient <gradient
android:centerY="0.6" android:centerY="0.6"
android:startColor="#851D30" android:startColor="?attr/mapFragmentGradientStartColor"
android:centerColor="#B45B14" android:centerColor="?attr/mapFragmentGradientCenterColor"
android:endColor="#D5661F" android:endColor="?attr/mapFragmentGradientEndColor"
android:type="linear" android:type="linear"
android:angle="225"/> android:angle="225"/>
</shape> </shape>

@ -1,14 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<gradient
android:startColor="#650822"
android:centerColor="#A7451E"
android:endColor="#CB7715"
android:angle="135" />
<gradient <gradient
android:centerY="0.7" android:centerY="0.7"
android:startColor="#92DD4B4B" android:startColor="?attr/settingsFragmentGradientStartColor"
android:endColor="#CD742B" android:centerColor="?attr/settingsFragmentGradientCenterColor"
android:endColor="?attr/settingsFragmentGradientEndColor"
android:type="sweep"/> android:type="sweep"/>
</shape> </shape>

@ -2,8 +2,8 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<gradient <gradient
android:startColor="#80FBBE17" android:startColor="?attr/textBackgroundGradientStartColor"
android:endColor="#8039E38B" android:endColor="?attr/textBackgroundGradientEndColor"
android:angle="45" android:angle="45"
android:type="linear" /> android:type="linear" />
</shape> </shape>

@ -16,7 +16,7 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:itemIconTint="@color/bottom_nav_bar_item_color" app:itemIconTint="@color/bottom_nav_bar_item_color"
app:itemTextColor="@color/bottom_nav_bar_item_color" app:itemTextColor="@color/bottom_nav_bar_item_color"
android:background="@drawable/gradient_fill_for_bottom_nav_bar" android:background="@drawable/bottom_nav_bar_gradient_background"
app:menu="@menu/main_bottom_nav_menu" /> app:menu="@menu/main_bottom_nav_menu" />
<fragment <fragment

@ -4,8 +4,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/chatFragmentBg" android:background="@drawable/chat_fragment_gradient_background"
tools:background="@color/chatFragmentBackground" tools:background="@drawable/chat_fragment_gradient_background"
tools:context=".fragments.chatFragment"> tools:context=".fragments.chatFragment">
<TextView <TextView

@ -4,8 +4,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/exploreFragmentBg" android:background="@drawable/explore_fragment_gradient_background"
tools:background="@color/exploreFragmentBackground" tools:background="@drawable/explore_fragment_gradient_background"
tools:context=".fragments.exploreFragment"> tools:context=".fragments.exploreFragment">
<ScrollView <ScrollView

@ -9,20 +9,35 @@
tools:context=".fragments.homeFragment"> tools:context=".fragments.homeFragment">
<TextView <TextView
android:id="@+id/homeFragmentTextIdTest" android:id="@+id/textView4"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:background="@drawable/text_background_gradient" android:background="@drawable/text_background_gradient"
android:padding="5dp" android:padding="5dp"
android:text="Home Fragment" android:text="@string/home"
android:textColor="#fff" android:textColor="@color/white"
android:textSize="24sp" android:textSize="28sp"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.fragment.app.FragmentContainerView
android:name="com.example.wikispot.fragments.infoFragment"
android:id="@+id/homeFragmentInnerFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView4">
app:layout_constraintVertical_bias="0.22000003" />
</androidx.fragment.app.FragmentContainerView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/info_fragment_gradient_background"
tools:background="@drawable/info_fragment_gradient_background"
tools:context=".fragments.infoFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/mainTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:background="@drawable/text_background_gradient"
android:padding="5dp"
android:text=""
android:textColor="#fff"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/mainImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:src="@drawable/ic_baseline_image_24"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/mainTitle" />
<TextView
android:id="@+id/mainDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text=""
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/mainImage" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="32dp"
android:layout_marginBottom="32dp"
android:src="@drawable/ic_baseline_chat_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp"
android:src="@drawable/loacation_vector_asset"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</ScrollView>

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" /> <background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground" /> <foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon> </adaptive-icon>

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" /> <background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground" /> <foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon> </adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 12 KiB

@ -21,6 +21,9 @@
<action <action
android:id="@+id/action_exploreFragment_to_homeFragment" android:id="@+id/action_exploreFragment_to_homeFragment"
app:destination="@id/homeFragment" /> app:destination="@id/homeFragment" />
<action
android:id="@+id/navigateToInfoFragment"
app:destination="@id/infoFragment" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/homeFragment" android:id="@+id/homeFragment"
@ -67,4 +70,13 @@
android:id="@+id/navigateBackToDebugFragment" android:id="@+id/navigateBackToDebugFragment"
app:destination="@id/debugFragment" /> app:destination="@id/debugFragment" />
</fragment> </fragment>
<fragment
android:id="@+id/infoFragment"
android:name="com.example.wikispot.fragments.infoFragment"
android:label="fragment_info"
tools:layout="@layout/fragment_info" >
<action
android:id="@+id/navigateBackToExploreFragmentFromInfoFragment"
app:destination="@id/exploreFragment" />
</fragment>
</navigation> </navigation>

@ -1,39 +0,0 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Dark themes below -->
<style name="Theme.WikiSpot" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#B078F4</item>
<item name="colorPrimaryVariant">#5100B3</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Backgrounds -->
<item name="chatFragmentBg">#3A4460</item>
<item name="exploreFragmentBg">#2E3E43</item>
<item name="homeFragmentBg">#424F34</item>
<item name="mapFragmentBg">#48443B</item>
<item name="settingsFragmentBg">#453C32</item>
<!-- BottomNavCheckedItemColor -->
<item name="bottomNavBarCheckedItemColor">@color/bottomNavBarCheckedItemColorDark</item>
<!-- Other items -->
<item name="bottomNavigationStyle">@style/Widget.App.BottomNavigationViewDark</item>
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
</style>
<style name="Widget.App.BottomNavigationViewDark" parent="Widget.MaterialComponents.BottomNavigationView.Colored">
<item name="materialThemeOverlay">@style/ThemeOverlay.App.BottomNavigationViewDark</item>
</style>
<style name="ThemeOverlay.App.BottomNavigationViewDark" parent="">
<item name="colorPrimary">#9758BC</item>
<item name="colorOnPrimary">#41254E</item>
</style>
</resources>

@ -1,12 +1,37 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<!-- Backgrounds --> <!-- For gradient Backgrounds -->
<attr name="chatFragmentBg" format="color"/>
<attr name="exploreFragmentBg" format="color"/> <attr name="textBackgroundGradientStartColor" format="color"/>
<attr name="homeFragmentBg" format="color"/> <attr name="textBackgroundGradientEndColor" format="color"/>
<attr name="mapFragmentBg" format="color"/>
<attr name="settingsFragmentBg" format="color"/> <attr name="bottomNavBarGradientStartColor" format="color"/>
<attr name="bottomNavBarGradientEndColor" format="color"/>
<attr name="chatFragmentGradientStartColor" format="color"/>
<attr name="chatFragmentGradientCenterColor" format="color"/>
<attr name="chatFragmentGradientEndColor" format="color"/>
<attr name="exploreFragmentGradientStartColor" format="color"/>
<attr name="exploreFragmentGradientCenterColor" format="color"/>
<attr name="exploreFragmentGradientEndColor" format="color"/>
<attr name="homeFragmentGradientStartColor" format="color"/>
<attr name="homeFragmentGradientCenterColor" format="color"/>
<attr name="homeFragmentGradientEndColor" format="color"/>
<attr name="mapFragmentGradientStartColor" format="color"/>
<attr name="mapFragmentGradientCenterColor" format="color"/>
<attr name="mapFragmentGradientEndColor" format="color"/>
<attr name="settingsFragmentGradientStartColor" format="color"/>
<attr name="settingsFragmentGradientCenterColor" format="color"/>
<attr name="settingsFragmentGradientEndColor" format="color"/>
<attr name="infoFragmentGradientStartColor" format="color"/>
<attr name="infoFragmentGradientCenterColor" format="color"/>
<attr name="infoFragmentGradientEndColor" format="color"/>
<!-- For bottomNavBar --> <!-- For bottomNavBar -->
<attr name="bottomNavBarCheckedItemColor" format="color"/> <attr name="bottomNavBarCheckedItemColor" format="color"/>

@ -8,48 +8,45 @@
<color name="black">#FF000000</color> <color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<!-- Light Theme --> <!-- Pink one <!-- Light Theme -->
<color name="chatFragmentBackground">#E1C1ABE6</color>
<color name="exploreFragmentBackground">#A892DE</color>
<color name="homeFragmentBackground">#DCB59BDD</color>
<color name="mapFragmentBackground">#D3ACD9</color>
<color name="settingsFragmentBackground">#CEDC8AC6</color>
<color name="bottomNavBarCheckedItemColor">#ECC87AE0</color>
<color name="bottomNavBarRippleColor">#43E8E8E8</color>
<color name="statusBarColor">#ECB988D7</color> -->
<!-- Blue-Green one
<color name="chatFragmentBackground">#E1ABD8E6</color>
<color name="exploreFragmentBackground">#92DED8</color>
<color name="homeFragmentBackground">#DC9BF1ED</color>
<color name="mapFragmentBackground">#C5F2E5</color>
<color name="settingsFragmentBackground">#CEA7F2E1</color>
<color name="bottomNavBarCheckedItemColor">#EC37DC7C</color>
<color name="bottomNavBarRippleColor">#43E8E8E8</color>
<color name="statusBarColor">#EC8ECDED</color> -->
<color name="chatFragmentBackground">#E10A1C2F</color>
<color name="exploreFragmentBackground">#142448</color>
<color name="homeFragmentBackground">#DC17294D</color>
<color name="mapFragmentBackground">#10132F</color>
<color name="settingsFragmentBackground">#CE131C33</color>
<color name="bottomNavBarCheckedItemColor">#ECD21A1A</color> <color name="bottomNavBarCheckedItemColor">#ECD21A1A</color>
<color name="bottomNavBarItemColor">#320747</color>
<color name="bottomNavBarRippleColor">#33C4BCC9</color> <color name="bottomNavBarRippleColor">#33C4BCC9</color>
<color name="statusBarColor">#EC000000</color> <color name="statusBarColor">#EC000000</color>
<color name="textBackgroundGradientStartColor" >#80E5BEFF</color>
<color name="textBackgroundGradientEndColor" >#80FFB5F0</color>
<color name="bottomNavBarGradientStartColor" >#FCDD94</color>
<color name="bottomNavBarGradientEndColor" >#C5F8AB</color>
<color name="chatFragmentGradientStartColor" >#FCB0EF</color>
<color name="chatFragmentGradientCenterColor" >#9ECFFF</color>
<color name="chatFragmentGradientEndColor" >#9FE7FF</color>
<color name="exploreFragmentGradientStartColor" >#A1DEFC</color>
<color name="exploreFragmentGradientCenterColor" >#A5CBFF</color>
<color name="exploreFragmentGradientEndColor" >#F9B6F6</color>
<color name="homeFragmentGradientStartColor" >#83E1FF</color>
<color name="homeFragmentGradientCenterColor" >#9EC6FF</color>
<color name="homeFragmentGradientEndColor" >#FEBBFF</color>
<color name="mapFragmentGradientStartColor" >#FBBEFC</color>
<color name="mapFragmentGradientCenterColor" >#A5CBFF</color>
<color name="mapFragmentGradientEndColor" >#95DDFC</color>
<color name="settingsFragmentGradientStartColor" >#92EB97FC</color>
<color name="settingsFragmentGradientCenterColor" >#A198F9</color>
<color name="settingsFragmentGradientEndColor" >#74C7F7</color>
<color name="infoFragmentGradientStartColor" >#FFB6FB</color>
<color name="infoFragmentGradientCenterColor" >#A7D2FF</color>
<color name="infoFragmentGradientEndColor" >#96E7FF</color>
<!-- Dark Theme --> <!-- Dark Theme -->
<!--<color name="chatFragmentBackgroundDark">#422DA9</color>
<color name="exploreFragmentBackgroundDark">#5829B1</color>
<color name="homeFragmentBackgroundDark">#6A1B9A</color>
<color name="mapFragmentBackgroundDark">#AD1457</color>
<color name="settingsFragmentBackgroundDark">#C62845</color>
<color name="bottomNavBarCheckedItemColorDark">#D7BEDE</color>
<color name="bottomNavBarRippleColorDark">#33222222</color>
<color name="statusBarColorDark">#4527A0</color>-->
<color name="chatFragmentBackgroundDark">#422DA9</color>
<color name="exploreFragmentBackgroundDark">#5829B1</color>
<color name="homeFragmentBackgroundDark">#6A1B9A</color>
<color name="mapFragmentBackgroundDark">#AD1457</color>
<color name="settingsFragmentBackgroundDark">#C62845</color>
<color name="bottomNavBarCheckedItemColorDark">#FFB571</color> <color name="bottomNavBarCheckedItemColorDark">#FFB571</color>
<color name="bottomNavBarItemColorDark">#320747</color>
<color name="bottomNavBarRippleColorDark">#33222222</color> <color name="bottomNavBarRippleColorDark">#33222222</color>
<color name="statusBarColorDark">#4527A0</color> <color name="statusBarColorDark">#4527A0</color>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#84ABFC</color>
</resources>

@ -12,20 +12,45 @@
<item name="colorSecondaryVariant">#F48FB1</item> <item name="colorSecondaryVariant">#F48FB1</item>
<item name="colorOnSecondary">@color/black</item> <item name="colorOnSecondary">@color/black</item>
<!-- Backgrounds --> <!-- For gradient Backgrounds -->
<item name="chatFragmentBg">@color/chatFragmentBackground</item>
<item name="exploreFragmentBg">@color/exploreFragmentBackground</item> <item name="textBackgroundGradientStartColor" >@color/textBackgroundGradientStartColor</item>
<item name="homeFragmentBg">@color/homeFragmentBackground</item> <item name="textBackgroundGradientEndColor" >@color/textBackgroundGradientEndColor</item>
<item name="mapFragmentBg">@color/mapFragmentBackground</item>
<item name="settingsFragmentBg">@color/settingsFragmentBackground</item> <item name="bottomNavBarGradientStartColor" >@color/bottomNavBarGradientStartColor</item>
<item name="bottomNavBarGradientEndColor" >@color/bottomNavBarGradientEndColor</item>
<item name="chatFragmentGradientStartColor" >@color/chatFragmentGradientStartColor</item>
<item name="chatFragmentGradientCenterColor" >@color/chatFragmentGradientCenterColor</item>
<item name="chatFragmentGradientEndColor" >@color/chatFragmentGradientEndColor</item>
<item name="exploreFragmentGradientStartColor" >@color/exploreFragmentGradientStartColor</item>
<item name="exploreFragmentGradientCenterColor" >@color/exploreFragmentGradientCenterColor</item>
<item name="exploreFragmentGradientEndColor" >@color/exploreFragmentGradientEndColor</item>
<item name="homeFragmentGradientStartColor" >@color/homeFragmentGradientStartColor</item>
<item name="homeFragmentGradientCenterColor" >@color/homeFragmentGradientCenterColor</item>
<item name="homeFragmentGradientEndColor" >@color/homeFragmentGradientEndColor</item>
<item name="mapFragmentGradientStartColor" >@color/mapFragmentGradientStartColor</item>
<item name="mapFragmentGradientCenterColor" >@color/mapFragmentGradientCenterColor</item>
<item name="mapFragmentGradientEndColor" >@color/mapFragmentGradientEndColor</item>
<item name="settingsFragmentGradientStartColor" >@color/settingsFragmentGradientStartColor</item>
<item name="settingsFragmentGradientCenterColor" >@color/settingsFragmentGradientCenterColor</item>
<item name="settingsFragmentGradientEndColor" >@color/settingsFragmentGradientEndColor</item>
<item name="infoFragmentGradientStartColor" >@color/infoFragmentGradientStartColor</item>
<item name="infoFragmentGradientCenterColor" >@color/infoFragmentGradientCenterColor</item>
<item name="infoFragmentGradientEndColor" >@color/infoFragmentGradientEndColor</item>
<!-- BottomNavCheckedItemColor --> <!-- BottomNavCheckedItemColor -->
<item name="bottomNavBarCheckedItemColor">@color/bottomNavBarCheckedItemColor</item> <item name="bottomNavBarCheckedItemColor">@color/bottomNavBarCheckedItemColor</item>
<item name="bottomNavBarRippleColor">@color/bottomNavBarRippleColor</item> <item name="bottomNavBarRippleColor">@color/bottomNavBarRippleColor</item>
<!-- Other items -->
<item name="bottomNavigationStyle">@style/Widget.App.BottomNavigationView</item> <item name="bottomNavigationStyle">@style/Widget.App.BottomNavigationView</item>
<!-- StatusBarColor -->
<item name="android:statusBarColor" tools:targetApi="l">@color/statusBarColor</item> <item name="android:statusBarColor" tools:targetApi="l">@color/statusBarColor</item>
</style> </style>
@ -34,14 +59,7 @@
</style> </style>
<style name="ThemeOverlay.App.BottomNavigationView" parent=""> <style name="ThemeOverlay.App.BottomNavigationView" parent="">
<!-- <item name="colorOnPrimary">@color/bottomNavBarItemColor</item>
<item name="colorPrimary">#EDD9F8</item>
<item name="colorOnPrimary">#C788EB</item> -->
<!--
<item name="colorPrimary">#FAF1FF</item>
<item name="colorOnPrimary">#6DBEED</item> #E4D539-->
<item name="colorPrimary">#0A0A1F</item>
<item name="colorOnPrimary">#320747</item>
</style> </style>
<!-- Dark theme--> <!-- Dark theme-->
@ -56,20 +74,45 @@
<item name="colorSecondaryVariant">@color/teal_200</item> <item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item> <item name="colorOnSecondary">@color/black</item>
<!-- Backgrounds --> <!-- For gradient Backgrounds -->
<item name="chatFragmentBg">@color/chatFragmentBackgroundDark</item>
<item name="exploreFragmentBg">@color/exploreFragmentBackgroundDark</item>
<item name="homeFragmentBg">@color/homeFragmentBackgroundDark</item>
<item name="mapFragmentBg">@color/mapFragmentBackgroundDark</item>
<item name="settingsFragmentBg">@color/settingsFragmentBackgroundDark</item>
<!-- for BottomNavBar --> <item name="textBackgroundGradientStartColor" >@color/textBackgroundGradientStartColor</item>
<item name="textBackgroundGradientEndColor" >@color/textBackgroundGradientEndColor</item>
<item name="bottomNavBarGradientStartColor" >@color/bottomNavBarGradientStartColor</item>
<item name="bottomNavBarGradientEndColor" >@color/bottomNavBarGradientEndColor</item>
<item name="chatFragmentGradientStartColor" >@color/chatFragmentGradientStartColor</item>
<item name="chatFragmentGradientCenterColor" >@color/chatFragmentGradientCenterColor</item>
<item name="chatFragmentGradientEndColor" >@color/chatFragmentGradientEndColor</item>
<item name="exploreFragmentGradientStartColor" >@color/exploreFragmentGradientStartColor</item>
<item name="exploreFragmentGradientCenterColor" >@color/exploreFragmentGradientCenterColor</item>
<item name="exploreFragmentGradientEndColor" >@color/exploreFragmentGradientEndColor</item>
<item name="homeFragmentGradientStartColor" >@color/homeFragmentGradientStartColor</item>
<item name="homeFragmentGradientCenterColor" >@color/homeFragmentGradientCenterColor</item>
<item name="homeFragmentGradientEndColor" >@color/homeFragmentGradientEndColor</item>
<item name="mapFragmentGradientStartColor" >@color/mapFragmentGradientStartColor</item>
<item name="mapFragmentGradientCenterColor" >@color/mapFragmentGradientCenterColor</item>
<item name="mapFragmentGradientEndColor" >@color/mapFragmentGradientEndColor</item>
<item name="settingsFragmentGradientStartColor" >@color/settingsFragmentGradientStartColor</item>
<item name="settingsFragmentGradientCenterColor" >@color/settingsFragmentGradientCenterColor</item>
<item name="settingsFragmentGradientEndColor" >@color/settingsFragmentGradientEndColor</item>
<item name="infoFragmentGradientStartColor" >@color/infoFragmentGradientStartColor</item>
<item name="infoFragmentGradientCenterColor" >@color/infoFragmentGradientCenterColor</item>
<item name="infoFragmentGradientEndColor" >@color/infoFragmentGradientEndColor</item>
<!-- BottomNavCheckedItemColor -->
<item name="bottomNavBarCheckedItemColor">@color/bottomNavBarCheckedItemColorDark</item> <item name="bottomNavBarCheckedItemColor">@color/bottomNavBarCheckedItemColorDark</item>
<item name="bottomNavBarRippleColor">@color/bottomNavBarRippleColorDark</item> <item name="bottomNavBarRippleColor">@color/bottomNavBarRippleColorDark</item>
<!-- Other items -->
<item name="bottomNavigationStyle">@style/Widget.App.BottomNavigationViewDark</item> <item name="bottomNavigationStyle">@style/Widget.App.BottomNavigationViewDark</item>
<!-- StatusBarColor -->
<item name="android:statusBarColor" tools:targetApi="l">@color/statusBarColorDark</item> <item name="android:statusBarColor" tools:targetApi="l">@color/statusBarColorDark</item>
</style> </style>
@ -79,7 +122,6 @@
</style> </style>
<style name="ThemeOverlay.App.BottomNavigationViewDark" parent=""> <style name="ThemeOverlay.App.BottomNavigationViewDark" parent="">
<item name="colorPrimary">#9758BC</item> <item name="colorOnPrimary">@color/bottomNavBarItemColorDark</item>
<item name="colorOnPrimary">#41254E</item>
</style> </style>
</resources> </resources>

@ -4,6 +4,7 @@ buildscript {
repositories { repositories {
google() google()
jcenter() jcenter()
mavenCentral()
} }
dependencies { dependencies {
classpath "com.android.tools.build:gradle:4.1.1" classpath "com.android.tools.build:gradle:4.1.1"