Compare commits
2 Commits
bbcaa46b36
...
d2148de633
Author | SHA1 | Date |
---|---|---|
Fred | d2148de633 | |
Fred | 25582ef9b9 |
|
@ -394,13 +394,13 @@ class MainActivity : BaseActivity() {
|
||||||
val tabsCheckedString = sharedPreferences.getString("tabsChecked", null)
|
val tabsCheckedString = sharedPreferences.getString("tabsChecked", null)
|
||||||
val pageIds = listOf(R.id.page_1, R.id.page_2, R.id.page_3, R.id.page_4, R.id.page_5)
|
val pageIds = listOf(R.id.page_1, R.id.page_2, R.id.page_3, R.id.page_4, R.id.page_5)
|
||||||
|
|
||||||
fun getDrawable(title: String): Drawable? {
|
fun getDrawable(titleId: Int): Drawable? {
|
||||||
val resId = when (title) {
|
val resId = when (titleId) {
|
||||||
getString(R.string.home_feed) -> R.drawable.selector_home_feed
|
R.string.home_feed -> R.drawable.selector_home_feed
|
||||||
getString(R.string.search_discover_feed) -> R.drawable.ic_search_white_24dp
|
R.string.search_discover_feed -> R.drawable.ic_search_white_24dp
|
||||||
getString(R.string.create_feed) -> R.drawable.selector_camera
|
R.string.create_feed -> R.drawable.selector_camera
|
||||||
getString(R.string.notifications_feed) -> R.drawable.selector_notifications
|
R.string.notifications_feed -> R.drawable.selector_notifications
|
||||||
getString(R.string.public_feed) -> R.drawable.ic_filter_black_24dp
|
R.string.public_feed -> R.drawable.ic_filter_black_24dp
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
if (resId == 0) {
|
if (resId == 0) {
|
||||||
|
@ -410,18 +410,18 @@ class MainActivity : BaseActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getFragment(title: String): (() -> Fragment)? {
|
fun getFragment(titleId: Int): (() -> Fragment)? {
|
||||||
return when (title) {
|
return when (titleId) {
|
||||||
getString(R.string.home_feed) -> { {
|
R.string.home_feed -> { {
|
||||||
PostFeedFragment<HomeStatusDatabaseEntity>()
|
PostFeedFragment<HomeStatusDatabaseEntity>()
|
||||||
.apply {
|
.apply {
|
||||||
arguments = Bundle().apply { putBoolean("home", true) }
|
arguments = Bundle().apply { putBoolean("home", true) }
|
||||||
}
|
}
|
||||||
} }
|
} }
|
||||||
getString(R.string.search_discover_feed) -> { { SearchDiscoverFragment() } }
|
R.string.search_discover_feed -> { { SearchDiscoverFragment() } }
|
||||||
getString(R.string.create_feed) -> { { CameraFragment() } }
|
R.string.create_feed -> { { CameraFragment() } }
|
||||||
getString(R.string.notifications_feed) -> { { NotificationsFragment() } }
|
R.string.notifications_feed -> { { NotificationsFragment() } }
|
||||||
getString(R.string.public_feed) -> { {
|
R.string.public_feed -> { {
|
||||||
PostFeedFragment<PublicFeedStatusDatabaseEntity>()
|
PostFeedFragment<PublicFeedStatusDatabaseEntity>()
|
||||||
.apply {
|
.apply {
|
||||||
arguments = Bundle().apply { putBoolean("home", false) }
|
arguments = Bundle().apply { putBoolean("home", false) }
|
||||||
|
@ -433,17 +433,17 @@ class MainActivity : BaseActivity() {
|
||||||
|
|
||||||
val tabs = if (tabsCheckedString == null) {
|
val tabs = if (tabsCheckedString == null) {
|
||||||
// Load default menu
|
// Load default menu
|
||||||
loadDefaultMenuTabs(applicationContext, binding.root)
|
loadDefaultMenuTabs(applicationContext, binding.root).map { it.toInt() }
|
||||||
} else {
|
} else {
|
||||||
// Get current menu visibility and order from settings
|
// Get current menu visibility and order from settings
|
||||||
val tabsChecked = loadJsonMenuTabs(tabsCheckedString).filter { it.second }.map { it.first }
|
val tabsChecked = loadJsonMenuTabs(tabsCheckedString).filter { it.second }.map { it.first.toInt() }
|
||||||
|
|
||||||
val bottomNavigationMenu: Menu = binding.tabs.menu
|
val bottomNavigationMenu: Menu = binding.tabs.menu
|
||||||
bottomNavigationMenu.clear()
|
bottomNavigationMenu.clear()
|
||||||
|
|
||||||
tabsChecked.zip(pageIds).forEach { (tabTitle, pageId) ->
|
tabsChecked.zip(pageIds).forEach { (tabId, pageId) ->
|
||||||
with(bottomNavigationMenu.add(0, pageId, Menu.NONE, tabTitle)) {
|
with(bottomNavigationMenu.add(0, pageId, Menu.NONE, getString(tabId))) {
|
||||||
val tabIcon = getDrawable(tabTitle)
|
val tabIcon = getDrawable(tabId)
|
||||||
if (tabIcon != null) {
|
if (tabIcon != null) {
|
||||||
icon = tabIcon
|
icon = tabIcon
|
||||||
}
|
}
|
||||||
|
@ -467,7 +467,7 @@ class MainActivity : BaseActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val notificationId = tabs.zip(pageIds).find {
|
val notificationId = tabs.zip(pageIds).find {
|
||||||
it.first == getString(R.string.notifications_feed)
|
it.first == R.string.notifications_feed
|
||||||
}?.second
|
}?.second
|
||||||
|
|
||||||
fun doAtPageId(pageId: Int): Int {
|
fun doAtPageId(pageId: Int): Int {
|
||||||
|
|
|
@ -287,7 +287,7 @@ class ArrangeTabsFragment: DialogFragment() {
|
||||||
val dragHandle: ImageView = holder.itemView.findViewById(R.id.dragHandle)
|
val dragHandle: ImageView = holder.itemView.findViewById(R.id.dragHandle)
|
||||||
|
|
||||||
// Set content of each entry
|
// Set content of each entry
|
||||||
textView.text = tabsChecked[position].first
|
textView.text = getString(tabsChecked[position].first.toInt())
|
||||||
checkBox.isChecked = tabsChecked[position].second
|
checkBox.isChecked = tabsChecked[position].second
|
||||||
|
|
||||||
// Also interact with checkbox when button is clicked
|
// Also interact with checkbox when button is clicked
|
||||||
|
|
|
@ -10,6 +10,8 @@ import android.graphics.Color
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.provider.MediaStore
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
@ -33,6 +35,12 @@ import okhttp3.HttpUrl
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.pixeldroid.app.R
|
import org.pixeldroid.app.R
|
||||||
|
import org.pixeldroid.app.postCreation.camera.CameraFragment
|
||||||
|
import org.pixeldroid.app.posts.feeds.cachedFeeds.notifications.NotificationsFragment
|
||||||
|
import org.pixeldroid.app.posts.feeds.cachedFeeds.postFeeds.PostFeedFragment
|
||||||
|
import org.pixeldroid.app.searchDiscover.SearchDiscoverFragment
|
||||||
|
import org.pixeldroid.app.utils.db.entities.HomeStatusDatabaseEntity
|
||||||
|
import org.pixeldroid.app.utils.db.entities.PublicFeedStatusDatabaseEntity
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
@ -207,7 +215,7 @@ fun loadDefaultMenuTabs(context: Context, anchor: View): List<String> {
|
||||||
return with(PopupMenu(context, anchor)) {
|
return with(PopupMenu(context, anchor)) {
|
||||||
val menu = this.menu
|
val menu = this.menu
|
||||||
menuInflater.inflate(R.menu.bottom_navigation_main, menu)
|
menuInflater.inflate(R.menu.bottom_navigation_main, menu)
|
||||||
(0 until menu.size()).map { menu.getItem(it).title.toString() }
|
(0 until menu.size()).map { getResIdFromString(context, menu.getItem(it).title.toString()).toString() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,3 +225,14 @@ fun loadJsonMenuTabs(jsonString: String): List<Pair<String, Boolean>> {
|
||||||
val checked = tabsCheckedJson.getJSONArray("checked").toList().map { v -> v.toBoolean() }
|
val checked = tabsCheckedJson.getJSONArray("checked").toList().map { v -> v.toBoolean() }
|
||||||
return tabs.zip(checked)
|
return tabs.zip(checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getResIdFromString(ctx: Context, title: String): Int {
|
||||||
|
return when (title) {
|
||||||
|
ctx.getString(R.string.home_feed) -> R.string.home_feed
|
||||||
|
ctx.getString(R.string.search_discover_feed) -> R.string.search_discover_feed
|
||||||
|
ctx.getString(R.string.create_feed) -> R.string.create_feed
|
||||||
|
ctx.getString(R.string.notifications_feed) -> R.string.notifications_feed
|
||||||
|
ctx.getString(R.string.public_feed) -> R.string.public_feed
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 956bd5f88d6189009f2ba0a8cb2860a1bfee0ee6
|
Subproject commit c093bde49b53f61628289be08d09f4e9dee4a48f
|
Loading…
Reference in New Issue