diff --git a/app/WikiSpot/app/src/main/java/com/example/wikispot/activities/MainActivity.kt b/app/WikiSpot/app/src/main/java/com/example/wikispot/activities/MainActivity.kt index f71cd19..e9e7b8c 100644 --- a/app/WikiSpot/app/src/main/java/com/example/wikispot/activities/MainActivity.kt +++ b/app/WikiSpot/app/src/main/java/com/example/wikispot/activities/MainActivity.kt @@ -9,7 +9,10 @@ import androidx.navigation.findNavController import androidx.navigation.ui.setupWithNavController import com.example.wikispot.* import com.example.wikispot.fragments.* +import com.example.wikispot.modelClasses.JsonManager import com.example.wikispot.modelClasses.SettingsSaveManager +import com.example.wikispot.modelsForAdapters.PlacePreview +import com.example.wikispot.modelsForAdapters.PlaceSupplier import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.fragment_home.* @@ -61,7 +64,8 @@ class MainActivity : AppCompatActivity() { } - ServerManagement.serverManager.addReceiverConnection(dataReceiver, this, "mainConnection", 0, "test0.json") + //ServerManagement.serverManager.addReceiverConnection(dataReceiver, this, "mainConnection", 0, "test0.json") + connectExploreFragmentAdapterModel() } override fun onPause() { @@ -85,6 +89,24 @@ class MainActivity : AppCompatActivity() { settingsSaveManager.loadSettings() } + private fun connectExploreFragmentAdapterModel () { + val dataReceiver: (String) -> Unit = {data: String -> + val json = JsonManager(this, data) + for (i in 0 until json.getLengthOfJsonArray()) { // todo change to 1 + json.getJsonObject(i) + json.getAttributeContent("description") + val title = json.getAttributeContent("title") + val shortDescription = json.getAttributeContent("description_s") + val place = PlacePreview(title, shortDescription) + if (!PlaceSupplier.places.contains(place)) { + PlaceSupplier.appendPlace(place) + } + } + } + + ServerManagement.serverManager.addReceiverConnection(dataReceiver, this, "exploreListConnection", 0, "", "GET_JSON_ARRAY") + } + private fun restartAppPartially() { val intent = Intent(applicationContext, MainActivity::class.java) diff --git a/app/WikiSpot/app/src/main/java/com/example/wikispot/adapters/PlacePreviewsAdapter.kt b/app/WikiSpot/app/src/main/java/com/example/wikispot/adapters/PlacePreviewsAdapter.kt index 08d694b..2693e9d 100644 --- a/app/WikiSpot/app/src/main/java/com/example/wikispot/adapters/PlacePreviewsAdapter.kt +++ b/app/WikiSpot/app/src/main/java/com/example/wikispot/adapters/PlacePreviewsAdapter.kt @@ -10,7 +10,7 @@ import com.example.wikispot.modelsForAdapters.PlacePreview import kotlinx.android.synthetic.main.explore_list_item.view.* -class PlacePreviewsAdapter(private val context: Context, private val placePreviews: Array) : RecyclerView.Adapter() { +class PlacePreviewsAdapter(private val context: Context, private val placePreviews: Array) : RecyclerView.Adapter() { inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){ diff --git a/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/homeFragment.kt b/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/homeFragment.kt index c2b8c0a..ef6b3b9 100644 --- a/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/homeFragment.kt +++ b/app/WikiSpot/app/src/main/java/com/example/wikispot/fragments/homeFragment.kt @@ -15,7 +15,7 @@ class homeFragment : Fragment(R.layout.fragment_home) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - loadCache() + //loadCache() } override fun onPause() { diff --git a/app/WikiSpot/app/src/main/java/com/example/wikispot/modelClasses/ServerManager.kt b/app/WikiSpot/app/src/main/java/com/example/wikispot/modelClasses/ServerManager.kt index 36be32e..eb31ba7 100644 --- a/app/WikiSpot/app/src/main/java/com/example/wikispot/modelClasses/ServerManager.kt +++ b/app/WikiSpot/app/src/main/java/com/example/wikispot/modelClasses/ServerManager.kt @@ -157,6 +157,10 @@ class ServerManager { val jsonManager = JsonManager(context, receivedString) if (path == "") { + if (attributePath == "GET_JSON_ARRAY") { + dataReceiver(jsonManager.jsonArray.toString()) + return + } jsonManager.getJsonObject(serverId) } else { if (attributePath == "") { @@ -195,7 +199,7 @@ class ServerManager { } }) - Thread.sleep(ServerManagement.dataRequestOnAttemptWait) + Thread.sleep(ServerManagement.receiverConnectionOnCheckWait) } } } diff --git a/app/WikiSpot/app/src/main/java/com/example/wikispot/modelsForAdapters/ExploreListModel.kt b/app/WikiSpot/app/src/main/java/com/example/wikispot/modelsForAdapters/ExploreListModel.kt index 7287c50..8c530e5 100644 --- a/app/WikiSpot/app/src/main/java/com/example/wikispot/modelsForAdapters/ExploreListModel.kt +++ b/app/WikiSpot/app/src/main/java/com/example/wikispot/modelsForAdapters/ExploreListModel.kt @@ -23,7 +23,7 @@ data class PlacePreview(var title: String, var description: String, var img: Ima object PlaceSupplier { - val places = arrayOf( + var 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."), @@ -36,4 +36,10 @@ object PlaceSupplier { PlacePreview("Bakery", "You can buy bread here.") ) + fun appendPlace(place: PlacePreview) { + val array = places.copyOf(places.size + 1) + array[places.size] = place + places = array + } + } \ No newline at end of file diff --git a/app/WikiSpot/app/src/main/java/com/example/wikispot/projectScopeVariables.kt b/app/WikiSpot/app/src/main/java/com/example/wikispot/projectScopeVariables.kt index ac96a1a..eeacbd6 100644 --- a/app/WikiSpot/app/src/main/java/com/example/wikispot/projectScopeVariables.kt +++ b/app/WikiSpot/app/src/main/java/com/example/wikispot/projectScopeVariables.kt @@ -3,12 +3,6 @@ package com.example.wikispot import com.example.wikispot.modelClasses.ServerManager -object ManifestRelatedVariables { - - val REQUEST_READ_EXTERNAL = 1 - -} - object GeneralVariables { var appRunningFirstTime = true @@ -24,7 +18,7 @@ object IntentsKeys { object ServerManagement { var serverManager = ServerManager() - const val activityConnectionOnCheckWait: Long = 4000 + const val receiverConnectionOnCheckWait: Long = 20000 const val viewConnectionOnCheckWait: Long = 5000 const val dataRequestOnAttemptWait: Long = 2000 const val baseUrl = "http://192.168.1.230:8000/" diff --git a/app/WikiSpot/app/src/main/res/drawable/gradient_fill_for_bottom_nav_bar.xml b/app/WikiSpot/app/src/main/res/drawable/gradient_fill_for_bottom_nav_bar.xml new file mode 100644 index 0000000..fb27ea9 --- /dev/null +++ b/app/WikiSpot/app/src/main/res/drawable/gradient_fill_for_bottom_nav_bar.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/app/WikiSpot/app/src/main/res/drawable/home_fragment_gradient_background.xml b/app/WikiSpot/app/src/main/res/drawable/home_fragment_gradient_background.xml new file mode 100644 index 0000000..c778e7a --- /dev/null +++ b/app/WikiSpot/app/src/main/res/drawable/home_fragment_gradient_background.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/WikiSpot/app/src/main/res/drawable/map_fragment_gradient_background.xml b/app/WikiSpot/app/src/main/res/drawable/map_fragment_gradient_background.xml new file mode 100644 index 0000000..6a9d51b --- /dev/null +++ b/app/WikiSpot/app/src/main/res/drawable/map_fragment_gradient_background.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/app/WikiSpot/app/src/main/res/drawable/settings_fragment_gradient_background.xml b/app/WikiSpot/app/src/main/res/drawable/settings_fragment_gradient_background.xml new file mode 100644 index 0000000..0c29434 --- /dev/null +++ b/app/WikiSpot/app/src/main/res/drawable/settings_fragment_gradient_background.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/app/WikiSpot/app/src/main/res/drawable/text_background_gradient.xml b/app/WikiSpot/app/src/main/res/drawable/text_background_gradient.xml new file mode 100644 index 0000000..a188395 --- /dev/null +++ b/app/WikiSpot/app/src/main/res/drawable/text_background_gradient.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file 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 0bdbd95..ab34a29 100644 --- a/app/WikiSpot/app/src/main/res/layout/activity_main.xml +++ b/app/WikiSpot/app/src/main/res/layout/activity_main.xml @@ -16,6 +16,7 @@ app:layout_constraintStart_toStartOf="parent" app:itemIconTint="@color/bottom_nav_bar_item_color" app:itemTextColor="@color/bottom_nav_bar_item_color" + android:background="@drawable/gradient_fill_for_bottom_nav_bar" app:menu="@menu/main_bottom_nav_menu" /> - - + app:layout_constraintTop_toTopOf="parent"> - - \ No newline at end of file diff --git a/app/WikiSpot/app/src/main/res/layout/fragment_home.xml b/app/WikiSpot/app/src/main/res/layout/fragment_home.xml index c052778..fa57f2f 100644 --- a/app/WikiSpot/app/src/main/res/layout/fragment_home.xml +++ b/app/WikiSpot/app/src/main/res/layout/fragment_home.xml @@ -4,22 +4,25 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="?attr/homeFragmentBg" - tools:background="@color/homeFragmentBackground" + android:background="@drawable/home_fragment_gradient_background" + tools:background="@drawable/home_fragment_gradient_background" tools:context=".fragments.homeFragment"> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.22000003" /> \ No newline at end of file diff --git a/app/WikiSpot/app/src/main/res/layout/fragment_map.xml b/app/WikiSpot/app/src/main/res/layout/fragment_map.xml index 764b67d..17a065c 100644 --- a/app/WikiSpot/app/src/main/res/layout/fragment_map.xml +++ b/app/WikiSpot/app/src/main/res/layout/fragment_map.xml @@ -4,21 +4,24 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="?attr/mapFragmentBg" - tools:background="@color/mapFragmentBackground" + android:background="@drawable/map_fragment_gradient_background" + tools:background="@drawable/map_fragment_gradient_background" tools:context=".fragments.mapFragment"> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.23000002" /> \ 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 379a60f..138891c 100644 --- a/app/WikiSpot/app/src/main/res/layout/fragment_settings.xml +++ b/app/WikiSpot/app/src/main/res/layout/fragment_settings.xml @@ -4,23 +4,10 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="?attr/settingsFragmentBg" - tools:background="@color/settingsFragmentBackground" + android:background="@drawable/settings_fragment_gradient_background" + tools:background="@drawable/settings_fragment_gradient_background" tools:context=".fragments.settingsFragment"> - - #FF000000 #FFFFFFFF - - #E11976D2 - #2EBFB2 - #7CB342 - #FBC02D - #F57C00 - #ECB269C8 + + + #E10A1C2F + #142448 + #DC17294D + #10132F + #CE131C33 + #ECD21A1A + #33C4BCC9 + #EC000000 - #422DA9 + + #422DA9 + #5829B1 + #6A1B9A + #AD1457 + #C62845 + #FFB571 + #33222222 + #4527A0 \ No newline at end of file diff --git a/app/WikiSpot/app/src/main/res/values/themes.xml b/app/WikiSpot/app/src/main/res/values/themes.xml index 20a7a5b..814b5fb 100644 --- a/app/WikiSpot/app/src/main/res/values/themes.xml +++ b/app/WikiSpot/app/src/main/res/values/themes.xml @@ -26,7 +26,7 @@ @style/Widget.App.BottomNavigationView - ?attr/colorPrimaryVariant + @color/statusBarColor @@ -64,7 +70,7 @@ @style/Widget.App.BottomNavigationViewDark - ?attr/colorPrimaryVariant + @color/statusBarColorDark