diff --git a/app/WikiSpot/.idea/dictionaries/ben44.xml b/app/WikiSpot/.idea/dictionaries/ben44.xml
new file mode 100644
index 0000000..99a2559
--- /dev/null
+++ b/app/WikiSpot/.idea/dictionaries/ben44.xml
@@ -0,0 +1,7 @@
+
+
+
+ initing
+
+
+
\ No newline at end of file
diff --git a/app/WikiSpot/.idea/inspectionProfiles/Project_Default.xml b/app/WikiSpot/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..ac21435
--- /dev/null
+++ b/app/WikiSpot/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/WikiSpot/.idea/vcs.xml b/app/WikiSpot/.idea/vcs.xml
deleted file mode 100644
index b2bdec2..0000000
--- a/app/WikiSpot/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/WikiSpot/app/build.gradle b/app/WikiSpot/app/build.gradle
index ffc9d79..626736c 100644
--- a/app/WikiSpot/app/build.gradle
+++ b/app/WikiSpot/app/build.gradle
@@ -2,6 +2,7 @@ plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.chaquo.python'
+ id 'kotlin-android-extensions'
}
android {
@@ -15,6 +16,8 @@ android {
versionCode 1
versionName "1.0"
+ vectorDrawables.useSupportLibrary = true
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
sourceSets {
@@ -25,8 +28,9 @@ android {
}
}
python {
- buildPython "/urs/local/bin/python3"
- buildPython "python3"
+ pip {
+ install "requests"
+ }
}
ndk {
@@ -54,7 +58,6 @@ android {
}
dependencies {
-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
diff --git a/app/WikiSpot/app/src/main/AndroidManifest.xml b/app/WikiSpot/app/src/main/AndroidManifest.xml
index b16dbab..3a494d4 100644
--- a/app/WikiSpot/app/src/main/AndroidManifest.xml
+++ b/app/WikiSpot/app/src/main/AndroidManifest.xml
@@ -2,6 +2,9 @@
+
+
+
finish()}
- builder.setNegativeButton("No") {_, _ -> }
+ builder.setPositiveButton("Yes") { _, _ -> finish()}
+ builder.setNegativeButton("No") { _, _ -> }
builder.show()
}
@@ -24,8 +31,8 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)
val navController = findNavController(R.id.mainFragmentHost)
- val bottomNavView = findViewById(R.id.mainBottomNavigationView)
- bottomNavView.setupWithNavController(navController)
+ mainBottomNavigationView.setupWithNavController(navController)
}
-}
\ No newline at end of file
+
+}
diff --git a/app/WikiSpot/app/src/main/java/com/example/wikispot/extentions.kt b/app/WikiSpot/app/src/main/java/com/example/wikispot/extentions.kt
index e694871..1ce3859 100644
--- a/app/WikiSpot/app/src/main/java/com/example/wikispot/extentions.kt
+++ b/app/WikiSpot/app/src/main/java/com/example/wikispot/extentions.kt
@@ -3,12 +3,37 @@ package com.example.wikispot
import android.content.Context
import android.view.View
import android.widget.Toast
+import com.chaquo.python.Python
+import com.chaquo.python.android.AndroidPlatform
import com.google.android.material.snackbar.Snackbar
+import org.json.JSONObject
fun Context.showToast(message: String, length: Int=Toast.LENGTH_SHORT) {
Toast.makeText(this, message, length).show()
}
-fun Context.showSnack(message: String, view: View, length: Int=Snackbar.LENGTH_LONG) {
+fun Context.showSnack(message: String, view: View, length: Int = Snackbar.LENGTH_LONG) {
Snackbar.make(this, view, message, length).show()
+}
+
+fun Context.getDataFromServer(): MutableList {
+ // initing
+ if (!Python.isStarted()) {
+ Python.start(AndroidPlatform(this))
+ }
+
+ // getting file
+ val python = Python.getInstance()
+ val pythonFile = python.getModule("server_manager")
+
+ // getting the data
+ pythonFile.callAttr("init")
+ val size = pythonFile.callAttr("get_length").toInt()
+ val jsonList = mutableListOf()
+
+ for (n in 0 until size) {
+ jsonList.add(n, JSONObject(pythonFile.callAttr("get_json", n).toString()))
+ }
+
+ return jsonList
}
\ No newline at end of file
diff --git a/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/debugFragment.kt b/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/debugFragment.kt
new file mode 100644
index 0000000..bd99a56
--- /dev/null
+++ b/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/debugFragment.kt
@@ -0,0 +1,40 @@
+package com.example.wikispot.fragments
+
+import android.annotation.SuppressLint
+import android.os.Bundle
+import android.view.View
+import androidx.fragment.app.Fragment
+import com.example.wikispot.R
+import com.example.wikispot.getDataFromServer
+import com.example.wikispot.showSnack
+import kotlinx.android.synthetic.main.fragment_debug.*
+import org.json.JSONObject
+
+
+class debugFragment : Fragment(R.layout.fragment_debug) {
+
+ private var jsonList: MutableList = mutableListOf()
+
+ @SuppressLint("SetTextI18n")
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+
+ getDataBtn.setOnClickListener {
+ context?.let {
+ jsonList = requireContext().getDataFromServer()
+ sizeView.text = "Amount of json's: ${jsonList.size}"
+ }
+ }
+
+ displayJsonFileBtn.setOnClickListener {
+ val id = idInput.text.toString().toInt()
+ if (id >= jsonList.size) {
+ context?.let {
+ requireContext().showSnack("Id out of range.", displayJsonFileBtn)
+ }
+ } else {
+ jsonFileOutputView.text = jsonList[id].toString()
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/exploreFragment.kt b/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/exploreFragment.kt
index c290ca6..057e6e9 100644
--- a/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/exploreFragment.kt
+++ b/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/exploreFragment.kt
@@ -1,8 +1,33 @@
package com.example.wikispot.fragments
+import android.os.Bundle
+import android.view.View
+import androidx.activity.addCallback
import androidx.fragment.app.Fragment
+import androidx.navigation.Navigation
+import androidx.recyclerview.widget.LinearLayoutManager
import com.example.wikispot.R
+import com.example.wikispot.models_and_adapters.PlacePreviewsAdapter
+import com.example.wikispot.models_and_adapters.PlaceSupplier
+import kotlinx.android.synthetic.main.fragment_explore.*
class exploreFragment : Fragment(R.layout.fragment_explore) {
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+
+ setupRecyclerView()
+ }
+
+ private fun setupRecyclerView() {
+
+ val layoutManager = LinearLayoutManager(context)
+ layoutManager.orientation = LinearLayoutManager.VERTICAL
+ explore_recycler_view.layoutManager = layoutManager
+
+ val adapter = context?.let { PlacePreviewsAdapter(it, PlaceSupplier.places) }
+ explore_recycler_view.adapter = adapter
+ }
+
}
\ No newline at end of file
diff --git a/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/settingsFragment.kt b/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/settingsFragment.kt
index 1c45fef..1226405 100644
--- a/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/settingsFragment.kt
+++ b/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/settingsFragment.kt
@@ -5,8 +5,19 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.navigation.Navigation
import com.example.wikispot.R
+import kotlinx.android.synthetic.main.fragment_settings.*
class settingsFragment : Fragment(R.layout.fragment_settings) {
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+
+ debugBtn.setOnClickListener {
+ Navigation.findNavController(it).navigate(R.id.navigateToDebugFragment)
+ }
+ }
+
}
\ No newline at end of file
diff --git a/app/WikiSpot/app/src/main/java/com/example/wikispot/models_and_adapters/ExploreListModel.kt b/app/WikiSpot/app/src/main/java/com/example/wikispot/models_and_adapters/ExploreListModel.kt
new file mode 100644
index 0000000..97763ec
--- /dev/null
+++ b/app/WikiSpot/app/src/main/java/com/example/wikispot/models_and_adapters/ExploreListModel.kt
@@ -0,0 +1,39 @@
+package com.example.wikispot.models_and_adapters
+
+import android.media.Image
+
+data class PlacePreview(var title: String, var description: String, var img: Image? = null) {
+
+ init {
+ val words = description.split(" ")
+ description = ""
+ var lastLine = ""
+
+ for (word in words) {
+ if (lastLine.length + word.length < 40) {
+ lastLine += " $word"
+ description += " $word"
+ } else {
+ description += "\n $word"
+ lastLine = " $word"
+ }
+ }
+ }
+}
+
+object PlaceSupplier {
+
+ val places = arrayOf(
+ 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("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.")
+ )
+
+}
\ No newline at end of file
diff --git a/app/WikiSpot/app/src/main/java/com/example/wikispot/models_and_adapters/PlacePreviewsAdapter.kt b/app/WikiSpot/app/src/main/java/com/example/wikispot/models_and_adapters/PlacePreviewsAdapter.kt
new file mode 100644
index 0000000..7e3eaf9
--- /dev/null
+++ b/app/WikiSpot/app/src/main/java/com/example/wikispot/models_and_adapters/PlacePreviewsAdapter.kt
@@ -0,0 +1,49 @@
+package com.example.wikispot.models_and_adapters
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.recyclerview.widget.RecyclerView
+import com.example.wikispot.R
+import kotlinx.android.synthetic.main.explore_list_item.view.*
+
+
+class PlacePreviewsAdapter(private val context: Context, private val placePreviews: Array) : RecyclerView.Adapter() {
+
+ inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
+
+ var currentPlacePreview: PlacePreview? = null
+ var pos: Int = 0
+
+ init {
+ }
+
+ fun setData(placePreview: PlacePreview?, pos: Int) {
+ placePreview?.let {
+ itemView.item_title.text = placePreview.title
+ itemView.item_description.text = placePreview.description
+ placePreview.img?.let {
+ // TODO set image somehow
+ }
+ }
+
+ this.currentPlacePreview = placePreview
+ this.pos = pos
+ }
+ }
+
+ override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
+ val placePreview = placePreviews[position]
+ holder.setData(placePreview, position)
+ }
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
+ val view = LayoutInflater.from(context).inflate(R.layout.explore_list_item, parent, false)
+ return MyViewHolder(view)
+ }
+
+ override fun getItemCount(): Int {
+ return placePreviews.size
+ }
+}
diff --git a/app/WikiSpot/app/src/main/python/server_manager.py b/app/WikiSpot/app/src/main/python/server_manager.py
new file mode 100644
index 0000000..dbe1a12
--- /dev/null
+++ b/app/WikiSpot/app/src/main/python/server_manager.py
@@ -0,0 +1,15 @@
+import requests
+json_list = []
+
+
+def init():
+ global json_list
+ json_list = eval(requests.get("http://192.168.1.120:8000/devices_list").text)
+
+
+def get_length():
+ return len(json_list)
+
+
+def get_json(i):
+ return json_list[i]
diff --git a/app/WikiSpot/app/src/main/res/drawable/blank.png b/app/WikiSpot/app/src/main/res/drawable/blank.png
new file mode 100644
index 0000000..64cb20e
Binary files /dev/null and b/app/WikiSpot/app/src/main/res/drawable/blank.png differ
diff --git a/app/WikiSpot/app/src/main/res/drawable/debug_vector_asset.xml b/app/WikiSpot/app/src/main/res/drawable/debug_vector_asset.xml
new file mode 100644
index 0000000..7853f61
--- /dev/null
+++ b/app/WikiSpot/app/src/main/res/drawable/debug_vector_asset.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/WikiSpot/app/src/main/res/drawable/ic_baseline_image_24.xml b/app/WikiSpot/app/src/main/res/drawable/ic_baseline_image_24.xml
new file mode 100644
index 0000000..8232c4d
--- /dev/null
+++ b/app/WikiSpot/app/src/main/res/drawable/ic_baseline_image_24.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/WikiSpot/app/src/main/res/drawable/loacation_vector_asset.xml b/app/WikiSpot/app/src/main/res/drawable/loacation_vector_asset.xml
new file mode 100644
index 0000000..e6dfeb4
--- /dev/null
+++ b/app/WikiSpot/app/src/main/res/drawable/loacation_vector_asset.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/WikiSpot/app/src/main/res/layout/activity_main.xml b/app/WikiSpot/app/src/main/res/layout/activity_main.xml
index cfe0e9b..4838199 100644
--- a/app/WikiSpot/app/src/main/res/layout/activity_main.xml
+++ b/app/WikiSpot/app/src/main/res/layout/activity_main.xml
@@ -10,6 +10,7 @@
android:id="@+id/mainBottomNavigationView"
android:layout_width="match_parent"
android:layout_height="70dp"
+ app:itemRippleColor="#43E8E8E8"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
diff --git a/app/WikiSpot/app/src/main/res/layout/explore_list_item.xml b/app/WikiSpot/app/src/main/res/layout/explore_list_item.xml
new file mode 100644
index 0000000..cb4eed7
--- /dev/null
+++ b/app/WikiSpot/app/src/main/res/layout/explore_list_item.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/WikiSpot/app/src/main/res/layout/fragment_debug.xml b/app/WikiSpot/app/src/main/res/layout/fragment_debug.xml
new file mode 100644
index 0000000..5fb372a
--- /dev/null
+++ b/app/WikiSpot/app/src/main/res/layout/fragment_debug.xml
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/WikiSpot/app/src/main/res/layout/fragment_explore.xml b/app/WikiSpot/app/src/main/res/layout/fragment_explore.xml
index c6efd2e..c6016cf 100644
--- a/app/WikiSpot/app/src/main/res/layout/fragment_explore.xml
+++ b/app/WikiSpot/app/src/main/res/layout/fragment_explore.xml
@@ -4,20 +4,60 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="#C200897B"
+ android:background="#2EBFB2"
tools:context=".fragments.exploreFragment">
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/WikiSpot/app/src/main/res/layout/fragment_settings.xml b/app/WikiSpot/app/src/main/res/layout/fragment_settings.xml
index 35d69c5..635676b 100644
--- a/app/WikiSpot/app/src/main/res/layout/fragment_settings.xml
+++ b/app/WikiSpot/app/src/main/res/layout/fragment_settings.xml
@@ -20,4 +20,12 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
+
+
\ No newline at end of file
diff --git a/app/WikiSpot/app/src/main/res/navigation/main_activity_navigation.xml b/app/WikiSpot/app/src/main/res/navigation/main_activity_navigation.xml
index d2b6544..687ac79 100644
--- a/app/WikiSpot/app/src/main/res/navigation/main_activity_navigation.xml
+++ b/app/WikiSpot/app/src/main/res/navigation/main_activity_navigation.xml
@@ -16,14 +16,21 @@
android:label="fragment_explore"
tools:layout="@layout/fragment_explore">
+
+ tools:layout="@layout/fragment_home" >
+
+
+ tools:layout="@layout/fragment_settings" >
+
+
+
\ No newline at end of file