mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-02-07 15:48:47 +01:00
サイドメニュー内部でテキストが途切れる問題の修正
This commit is contained in:
parent
c031bde8d6
commit
256a3952b9
@ -7,7 +7,9 @@ import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Rect
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.StateListDrawable
|
||||
import android.net.Uri
|
||||
import android.os.AsyncTask
|
||||
import android.os.Build
|
||||
@ -23,8 +25,10 @@ import android.widget.*
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.google.android.material.navigation.NavigationView
|
||||
import jp.juggler.subwaytooter.action.*
|
||||
import jp.juggler.subwaytooter.api.*
|
||||
@ -41,6 +45,7 @@ import jp.juggler.subwaytooter.util.PostHelper
|
||||
import jp.juggler.subwaytooter.view.*
|
||||
import jp.juggler.util.*
|
||||
import org.apache.commons.io.IOUtils
|
||||
import org.jetbrains.anko.backgroundColor
|
||||
import org.jetbrains.anko.backgroundDrawable
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
@ -54,11 +59,10 @@ import kotlin.math.abs
|
||||
import kotlin.math.min
|
||||
|
||||
class ActMain : AppCompatActivity()
|
||||
, NavigationView.OnNavigationItemSelectedListener
|
||||
, View.OnClickListener
|
||||
, androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||
, Column.Callback
|
||||
, androidx.drawerlayout.widget.DrawerLayout.DrawerListener {
|
||||
, View.OnClickListener
|
||||
, ViewPager.OnPageChangeListener
|
||||
, DrawerLayout.DrawerListener {
|
||||
|
||||
companion object {
|
||||
|
||||
@ -127,7 +131,7 @@ class ActMain : AppCompatActivity()
|
||||
internal var listItemPopup : StatusButtonsPopup? = null
|
||||
|
||||
private lateinit var llEmpty : View
|
||||
internal lateinit var drawer : androidx.drawerlayout.widget.DrawerLayout
|
||||
internal lateinit var drawer : DrawerLayout
|
||||
private lateinit var llColumnStrip : ColumnStripLinearLayout
|
||||
private lateinit var svColumnStrip : HorizontalScrollView
|
||||
private lateinit var btnMenu : ImageButton
|
||||
@ -996,7 +1000,6 @@ class ActMain : AppCompatActivity()
|
||||
override fun onBackPressed() {
|
||||
|
||||
// メニューが開いていたら閉じる
|
||||
val drawer = findViewById<androidx.drawerlayout.widget.DrawerLayout>(R.id.drawer_layout)
|
||||
if(drawer.isDrawerOpen(GravityCompat.START)) {
|
||||
drawer.closeDrawer(GravityCompat.START)
|
||||
return
|
||||
@ -1090,191 +1093,6 @@ class ActMain : AppCompatActivity()
|
||||
}
|
||||
}
|
||||
|
||||
// Handle navigation view item clicks here.
|
||||
override fun onNavigationItemSelected(item : MenuItem) : Boolean {
|
||||
|
||||
when(item.itemId) {
|
||||
// アカウント
|
||||
R.id.nav_account_add -> Action_Account.add(this)
|
||||
R.id.nav_account_setting -> Action_Account.setting(this)
|
||||
|
||||
// カラム
|
||||
R.id.nav_column_list -> Action_App.columnList(this)
|
||||
|
||||
R.id.nav_close_all_columns -> closeColumnAll()
|
||||
|
||||
R.id.nav_add_tl_home -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.HOME
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
|
||||
R.id.nav_add_tl_local -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.LOCAL
|
||||
, bAllowPseudo = true
|
||||
)
|
||||
|
||||
R.id.nav_add_tl_misskey_hybrid -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.MISSKEY_HYBRID
|
||||
, bAllowPseudo = true
|
||||
, bAllowMastodon = false
|
||||
)
|
||||
|
||||
R.id.nav_add_tl_federate -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.FEDERATE
|
||||
, bAllowPseudo = true
|
||||
)
|
||||
R.id.nav_add_favourites -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.FAVOURITES
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
R.id.nav_add_statuses -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.PROFILE
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
R.id.nav_add_notifications -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.NOTIFICATIONS
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
|
||||
R.id.nav_add_direct_message -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.DIRECT_MESSAGES
|
||||
, bAllowPseudo = false
|
||||
, bAllowMisskey = false
|
||||
)
|
||||
R.id.nav_add_tl_search -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.SEARCH
|
||||
, bAllowPseudo = false
|
||||
, args = arrayOf("", false)
|
||||
)
|
||||
|
||||
R.id.nav_add_mutes -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.MUTES
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
|
||||
R.id.nav_add_blocks -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.BLOCKS
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
|
||||
R.id.nav_keyword_filter -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.KEYWORD_FILTER
|
||||
, bAllowPseudo = false
|
||||
, bAllowMisskey = false
|
||||
)
|
||||
R.id.nav_add_domain_blocks -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.DOMAIN_BLOCKS
|
||||
, bAllowPseudo = false
|
||||
, bAllowMisskey = false
|
||||
)
|
||||
R.id.nav_scheduled_statuses_list -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.SCHEDULED_STATUS
|
||||
, bAllowPseudo = false
|
||||
, bAllowMisskey = false
|
||||
)
|
||||
R.id.nav_add_list -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.LIST_LIST
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
|
||||
R.id.nav_follow_requests -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.FOLLOW_REQUESTS
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
|
||||
R.id.nav_follow_suggestion -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.FOLLOW_SUGGESTION
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
R.id.nav_endorsement -> Action_Account.timeline(
|
||||
this
|
||||
, defaultInsertPosition
|
||||
, ColumnType.ENDORSEMENT
|
||||
, bAllowPseudo = false
|
||||
, bAllowMisskey = false
|
||||
)
|
||||
|
||||
R.id.nav_trend_tag -> Action_Account.timeline(
|
||||
this,
|
||||
defaultInsertPosition,
|
||||
ColumnType.TREND_TAG,
|
||||
bAllowPseudo = true,
|
||||
bAllowMastodon = true,
|
||||
bAllowMisskey = false
|
||||
)
|
||||
|
||||
// トゥート検索
|
||||
|
||||
R.id.tootsearch -> addColumn(
|
||||
defaultInsertPosition
|
||||
, SavedAccount.na
|
||||
, ColumnType.SEARCH_TS
|
||||
, ""
|
||||
)
|
||||
|
||||
// R.id.mastodon_search_portal -> addColumn(
|
||||
// defaultInsertPosition
|
||||
// , SavedAccount.na
|
||||
// , ColumnType.SEARCH_MSP
|
||||
// , ""
|
||||
// )
|
||||
|
||||
// 設定
|
||||
R.id.nav_app_setting -> ActAppSetting.open(this, REQUEST_CODE_APP_SETTING)
|
||||
R.id.nav_muted_app -> startActivity(Intent(this, ActMutedApp::class.java))
|
||||
R.id.nav_muted_word -> startActivity(Intent(this, ActMutedWord::class.java))
|
||||
R.id.nav_fav_mute -> startActivity(Intent(this, ActFavMute::class.java))
|
||||
R.id.nav_highlight_word -> startActivity(Intent(this, ActHighlightWordList::class.java))
|
||||
|
||||
R.id.nav_pseudo_account_mute -> startActivity(Intent(this, ActMutedPseudoAccount::class.java))
|
||||
|
||||
R.id.nav_app_about -> startActivityForResult(
|
||||
Intent(this, ActAbout::class.java),
|
||||
REQUEST_APP_ABOUT
|
||||
)
|
||||
R.id.nav_oss_license -> startActivity(Intent(this, ActOSSLicense::class.java))
|
||||
R.id.nav_app_exit -> finish()
|
||||
}
|
||||
|
||||
val drawer = findViewById<androidx.drawerlayout.widget.DrawerLayout>(R.id.drawer_layout)
|
||||
drawer.closeDrawer(GravityCompat.START)
|
||||
return true
|
||||
}
|
||||
|
||||
internal fun initUI() {
|
||||
setContentView(R.layout.act_main)
|
||||
|
||||
@ -1370,7 +1188,7 @@ class ActMain : AppCompatActivity()
|
||||
drawer.addDrawerListener(this)
|
||||
|
||||
val navigationView = findViewById<NavigationView>(R.id.nav_view)
|
||||
navigationView.setNavigationItemSelectedListener(this)
|
||||
initSideMenu(navigationView)
|
||||
|
||||
btnMenu = findViewById(R.id.btnMenu)
|
||||
btnToot = findViewById(R.id.btnToot)
|
||||
@ -3120,4 +2938,365 @@ class ActMain : AppCompatActivity()
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
class MyMenuItem(val title : Int, val icon : Int, val action : () -> Unit = {})
|
||||
|
||||
val sideMenuContents = ArrayList<MyMenuItem>().apply {
|
||||
fun add(title : Int = 0, icon : Int = 0, action : () -> Unit = {}) {
|
||||
add(MyMenuItem(title, icon, action))
|
||||
}
|
||||
|
||||
add(title = R.string.account)
|
||||
|
||||
add(title = R.string.account_add, icon = R.drawable.ic_account_add) {
|
||||
Action_Account.add(this@ActMain)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_account_setting" */
|
||||
add(icon = R.drawable.ic_settings, title = R.string.account_setting) {
|
||||
Action_Account.setting(this@ActMain)
|
||||
}
|
||||
|
||||
add()
|
||||
add(title = R.string.column)
|
||||
/* android:id="@+id/nav_column_list" */
|
||||
add(icon = R.drawable.ic_list_numbered, title = R.string.column_list) {
|
||||
Action_App.columnList(this@ActMain)
|
||||
}
|
||||
/* android:id="@+id/nav_close_all_columns" */
|
||||
add(
|
||||
icon = R.drawable.ic_close, title = R.string.close_all_columns
|
||||
) {
|
||||
closeColumnAll()
|
||||
}
|
||||
/* android:id="@+id/nav_add_tl_home" */
|
||||
|
||||
add(icon = R.drawable.ic_home, title = R.string.home) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.HOME
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
}
|
||||
/* android:id="@+id/nav_add_notifications" */
|
||||
add(icon = R.drawable.ic_announcement, title = R.string.notifications) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.NOTIFICATIONS
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_add_direct_message" */
|
||||
add(icon = R.drawable.ic_mail, title = R.string.direct_messages) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.DIRECT_MESSAGES
|
||||
, bAllowPseudo = false
|
||||
, bAllowMisskey = false
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_add_tl_misskey_hybrid" */
|
||||
add(icon = R.drawable.ic_share, title = R.string.misskey_hybrid_timeline_long) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.MISSKEY_HYBRID
|
||||
, bAllowPseudo = true
|
||||
, bAllowMastodon = false
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_add_tl_local" */
|
||||
add(icon = R.drawable.ic_run, title = R.string.local_timeline) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.LOCAL
|
||||
, bAllowPseudo = true
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_add_tl_federate" */
|
||||
add(icon = R.drawable.ic_bike, title = R.string.federate_timeline) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.FEDERATE
|
||||
, bAllowPseudo = true
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_add_list" */
|
||||
add(icon = R.drawable.ic_list_list, title = R.string.lists) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.LIST_LIST
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_add_tl_search" */
|
||||
add(icon = R.drawable.ic_search, title = R.string.search) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.SEARCH
|
||||
, bAllowPseudo = false
|
||||
, args = arrayOf("", false)
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_trend_tag" */
|
||||
add(icon = R.drawable.ic_hashtag, title = R.string.trend_tag) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain,
|
||||
defaultInsertPosition,
|
||||
ColumnType.TREND_TAG,
|
||||
bAllowPseudo = true,
|
||||
bAllowMastodon = true,
|
||||
bAllowMisskey = false
|
||||
)
|
||||
}
|
||||
/* android:id="@+id/nav_add_favourites" */
|
||||
add(icon = R.drawable.ic_star, title = R.string.favourites) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.FAVOURITES
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_add_statuses" */
|
||||
add(icon = R.drawable.ic_account_box, title = R.string.profile) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.PROFILE
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_follow_requests" */
|
||||
add(icon = R.drawable.ic_follow_wait, title = R.string.follow_requests) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.FOLLOW_REQUESTS
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_follow_suggestion" */
|
||||
add(icon = R.drawable.ic_follow_plus, title = R.string.follow_suggestion) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.FOLLOW_SUGGESTION
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
}
|
||||
/* android:id="@+id/nav_endorsement" */
|
||||
add(icon = R.drawable.ic_follow_plus, title = R.string.endorse_set) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.ENDORSEMENT
|
||||
, bAllowPseudo = false
|
||||
, bAllowMisskey = false
|
||||
)
|
||||
}
|
||||
/* android:id="@+id/nav_add_mutes" */
|
||||
add(icon = R.drawable.ic_volume_off, title = R.string.muted_users) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.MUTES
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_add_blocks" */
|
||||
add(icon = R.drawable.ic_block, title = R.string.blocked_users) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.BLOCKS
|
||||
, bAllowPseudo = false
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_keyword_filter" */
|
||||
add(icon = R.drawable.ic_volume_off, title = R.string.keyword_filters) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.KEYWORD_FILTER
|
||||
, bAllowPseudo = false
|
||||
, bAllowMisskey = false
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_add_domain_blocks" */
|
||||
add(icon = R.drawable.ic_cloud_off, title = R.string.blocked_domains) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.DOMAIN_BLOCKS
|
||||
, bAllowPseudo = false
|
||||
, bAllowMisskey = false
|
||||
)
|
||||
}
|
||||
|
||||
/* android:id="@+id/nav_scheduled_statuses_list" */
|
||||
add(icon = R.drawable.ic_timer, title = R.string.scheduled_status_list) {
|
||||
Action_Account.timeline(
|
||||
this@ActMain
|
||||
, defaultInsertPosition
|
||||
, ColumnType.SCHEDULED_STATUS
|
||||
, bAllowPseudo = false
|
||||
, bAllowMisskey = false
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
add()
|
||||
add(title = R.string.toot_search)
|
||||
|
||||
add(icon = R.drawable.ic_search, title = R.string.tootsearch) {
|
||||
addColumn(
|
||||
defaultInsertPosition
|
||||
, SavedAccount.na
|
||||
, ColumnType.SEARCH_TS
|
||||
, ""
|
||||
)
|
||||
}
|
||||
|
||||
add()
|
||||
add(title = R.string.setting)
|
||||
|
||||
add(icon = R.drawable.ic_settings, title = R.string.app_setting) {
|
||||
ActAppSetting.open(this@ActMain, REQUEST_CODE_APP_SETTING)
|
||||
}
|
||||
|
||||
add(icon = R.drawable.ic_settings, title = R.string.highlight_word) {
|
||||
startActivity(Intent(this@ActMain, ActHighlightWordList::class.java))
|
||||
}
|
||||
|
||||
add(icon = R.drawable.ic_volume_off, title = R.string.muted_app) {
|
||||
startActivity(Intent(this@ActMain, ActMutedApp::class.java))
|
||||
}
|
||||
|
||||
add(icon = R.drawable.ic_volume_off, title = R.string.muted_word) {
|
||||
startActivity(Intent(this@ActMain, ActMutedWord::class.java))
|
||||
}
|
||||
|
||||
add(icon = R.drawable.ic_volume_off, title = R.string.fav_muted_user) {
|
||||
startActivity(Intent(this@ActMain, ActFavMute::class.java))
|
||||
}
|
||||
|
||||
add(
|
||||
icon = R.drawable.ic_volume_off,
|
||||
title = R.string.muted_users_from_pseudo_account
|
||||
) {
|
||||
startActivity(Intent(this@ActMain, ActMutedPseudoAccount::class.java))
|
||||
}
|
||||
|
||||
add(icon = R.drawable.ic_info, title = R.string.app_about) {
|
||||
startActivityForResult(Intent(this@ActMain, ActAbout::class.java), REQUEST_APP_ABOUT)
|
||||
}
|
||||
|
||||
add(icon = R.drawable.ic_info, title = R.string.oss_license) {
|
||||
startActivity(Intent(this@ActMain, ActOSSLicense::class.java))
|
||||
}
|
||||
|
||||
add(icon = R.drawable.ic_hot_tub, title = R.string.app_exit) {
|
||||
finish()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inner class SideMenuAdapter : BaseAdapter() {
|
||||
|
||||
private val iconColor = getAttributeColor(this@ActMain, R.attr.colorTimeSmall)
|
||||
|
||||
override fun getCount() : Int =
|
||||
sideMenuContents.size
|
||||
|
||||
override fun getItem(position : Int) : Any =
|
||||
sideMenuContents[position]
|
||||
|
||||
override fun getItemId(position : Int) : Long = 0L
|
||||
|
||||
override fun getViewTypeCount() : Int = 3
|
||||
|
||||
override fun getItemViewType(position : Int) : Int {
|
||||
val item = sideMenuContents[position]
|
||||
return when {
|
||||
item.title == 0 -> 0
|
||||
item.icon == 0 -> 1
|
||||
else -> 2
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun <reified T : View> viewOrInflate(
|
||||
view : View?,
|
||||
parent : ViewGroup?,
|
||||
resId : Int
|
||||
) : T {
|
||||
val v = view ?: layoutInflater.inflate(resId, parent, false)
|
||||
return if(v is T) v else error("invalid view type! $v")
|
||||
}
|
||||
|
||||
override fun getView(position : Int, view : View?, parent : ViewGroup?) : View {
|
||||
|
||||
val item = sideMenuContents[position]
|
||||
return when {
|
||||
item.title == 0 -> viewOrInflate(view, parent, R.layout.lv_sidemenu_separator)
|
||||
|
||||
item.icon == 0 -> viewOrInflate<TextView>(view, parent, R.layout.lv_sidemenu_group)
|
||||
.apply {
|
||||
text = getString(item.title)
|
||||
|
||||
}
|
||||
else -> viewOrInflate<TextView>(view, parent, R.layout.lv_sidemenu_item)
|
||||
.apply {
|
||||
isAllCaps = false
|
||||
text = getString(item.title)
|
||||
val drawable = createColoredDrawable(this@ActMain, item.icon, iconColor, 1f)
|
||||
setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, null, null, null)
|
||||
|
||||
setOnClickListener {
|
||||
item.action()
|
||||
drawer.closeDrawer(GravityCompat.START)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initSideMenu(navigationView : NavigationView) {
|
||||
|
||||
navigationView.addView(ListView(this).apply {
|
||||
adapter = SideMenuAdapter()
|
||||
layoutParams = FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
backgroundColor = getAttributeColor(this@ActMain, R.attr.colorWindowBackground)
|
||||
selector = StateListDrawable()
|
||||
divider = null
|
||||
dividerHeight = 0
|
||||
|
||||
val pad_tb = (density *12f + 0.5f) .toInt()
|
||||
setPadding(0,pad_tb,0,pad_tb)
|
||||
clipToPadding = false
|
||||
scrollBarStyle =ListView.SCROLLBARS_OUTSIDE_OVERLAY
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="jp.juggler.subwaytooter.ActMain"
|
||||
tools:openDrawer="start"
|
||||
>
|
||||
@ -185,9 +184,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:fitsSystemWindows="true"
|
||||
>
|
||||
|
||||
app:menu="@menu/menu_navi_drawer"
|
||||
/>
|
||||
</com.google.android.material.navigation.NavigationView>
|
||||
<!-- app:headerLayout="@layout/nav_header_act_main" -->
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
|
13
app/src/main/res/layout/lv_sidemenu_group.xml
Normal file
13
app/src/main/res/layout/lv_sidemenu_group.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/colorSettingDivider"
|
||||
android:gravity="center_vertical|start"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
/>
|
||||
|
17
app/src/main/res/layout/lv_sidemenu_item.xml
Normal file
17
app/src/main/res/layout/lv_sidemenu_item.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Button
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/btn_bg_transparent"
|
||||
android:textColor="?attr/colorContentText"
|
||||
android:gravity="center_vertical|start"
|
||||
android:drawablePadding="12dp"
|
||||
android:minHeight="44dp"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
|
||||
/>
|
||||
|
11
app/src/main/res/layout/lv_sidemenu_separator.xml
Normal file
11
app/src/main/res/layout/lv_sidemenu_separator.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<View android:layout_width="match_parent" android:layout_height="1dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:background="?attr/colorTimeSmall"
|
||||
/>
|
||||
</FrameLayout>
|
@ -1,219 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<group android:checkableBehavior="single">
|
||||
|
||||
<item android:title="@string/account">
|
||||
<menu>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_account_add"
|
||||
android:icon="@drawable/ic_account_add"
|
||||
android:title="@string/account_add"/>
|
||||
<item
|
||||
android:id="@+id/nav_account_setting"
|
||||
android:icon="@drawable/ic_settings"
|
||||
android:title="@string/account_setting"/>
|
||||
</menu>
|
||||
</item>
|
||||
<item android:title="@string/column">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/nav_column_list"
|
||||
android:icon="@drawable/ic_list_numbered"
|
||||
android:title="@string/column_list"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_close_all_columns"
|
||||
android:icon="@drawable/ic_close"
|
||||
android:title="@string/close_all_columns"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_add_tl_home"
|
||||
android:icon="@drawable/ic_home"
|
||||
android:title="@string/home"/>
|
||||
<item
|
||||
android:id="@+id/nav_add_notifications"
|
||||
android:icon="@drawable/ic_announcement"
|
||||
android:title="@string/notifications"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_add_direct_message"
|
||||
android:icon="@drawable/ic_mail"
|
||||
android:title="@string/direct_messages"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_add_tl_misskey_hybrid"
|
||||
android:icon="@drawable/ic_share"
|
||||
android:title="@string/misskey_hybrid_timeline_long"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_add_tl_local"
|
||||
android:icon="@drawable/ic_run"
|
||||
android:title="@string/local_timeline"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_add_tl_federate"
|
||||
android:icon="@drawable/ic_bike"
|
||||
android:title="@string/federate_timeline"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_add_list"
|
||||
android:icon="@drawable/ic_list_list"
|
||||
android:title="@string/lists"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_add_tl_search"
|
||||
android:icon="@drawable/ic_search"
|
||||
android:title="@string/search"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_trend_tag"
|
||||
android:icon="@drawable/ic_hashtag"
|
||||
android:title="@string/trend_tag"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_add_favourites"
|
||||
android:icon="@drawable/ic_star"
|
||||
android:title="@string/favourites"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_add_statuses"
|
||||
android:icon="@drawable/ic_account_box"
|
||||
android:title="@string/profile"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_follow_requests"
|
||||
android:icon="@drawable/ic_follow_wait"
|
||||
android:title="@string/follow_requests"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_follow_suggestion"
|
||||
android:icon="@drawable/ic_follow_plus"
|
||||
android:title="@string/follow_suggestion"/>
|
||||
<item
|
||||
android:id="@+id/nav_endorsement"
|
||||
android:icon="@drawable/ic_follow_plus"
|
||||
android:title="@string/endorse_set"/>
|
||||
<item
|
||||
android:id="@+id/nav_add_mutes"
|
||||
android:icon="@drawable/ic_volume_off"
|
||||
android:title="@string/muted_users"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_add_blocks"
|
||||
android:icon="@drawable/ic_block"
|
||||
android:title="@string/blocked_users"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_keyword_filter"
|
||||
android:icon="@drawable/ic_volume_off"
|
||||
android:title="@string/keyword_filters"/>
|
||||
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_add_domain_blocks"
|
||||
android:icon="@drawable/ic_cloud_off"
|
||||
android:title="@string/blocked_domains"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_scheduled_statuses_list"
|
||||
android:icon="@drawable/ic_timer"
|
||||
android:title="@string/scheduled_status_list"/>
|
||||
|
||||
<!--<item-->
|
||||
<!--android:id="@+id/nav_add_reports"-->
|
||||
<!--android:icon="@drawable/ic_report"-->
|
||||
<!--android:title="@string/your_reports"/>-->
|
||||
|
||||
<!--<item-->
|
||||
<!--android:id="@+id/nav_slideshow"-->
|
||||
<!--android:icon="@drawable/ic_menu_slideshow"-->
|
||||
<!--android:title="Slideshow"/>-->
|
||||
<!--<item-->
|
||||
<!--android:id="@+id/nav_manage"-->
|
||||
<!--android:icon="@drawable/ic_menu_manage"-->
|
||||
<!--android:title="Tools"/>-->
|
||||
</menu>
|
||||
</item>
|
||||
<item android:title="@string/toot_search">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/tootsearch"
|
||||
android:icon="@drawable/ic_search"
|
||||
android:title="@string/tootsearch"/>
|
||||
<!--<item-->
|
||||
<!--android:id="@+id/mastodon_search_portal"-->
|
||||
<!--android:icon="@drawable/ic_search"-->
|
||||
<!--android:title="@string/mastodon_search_portal"/>-->
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<item android:title="@string/setting">
|
||||
<menu>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_app_setting"
|
||||
android:icon="@drawable/ic_settings"
|
||||
android:title="@string/app_setting"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_highlight_word"
|
||||
android:icon="@drawable/ic_settings"
|
||||
android:title="@string/highlight_word"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_muted_app"
|
||||
android:icon="@drawable/ic_volume_off"
|
||||
android:title="@string/muted_app"/>
|
||||
<item
|
||||
android:id="@+id/nav_muted_word"
|
||||
android:icon="@drawable/ic_volume_off"
|
||||
android:title="@string/muted_word"/>
|
||||
<item
|
||||
android:id="@+id/nav_fav_mute"
|
||||
android:icon="@drawable/ic_volume_off"
|
||||
android:title="@string/fav_muted_user"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_pseudo_account_mute"
|
||||
android:icon="@drawable/ic_volume_off"
|
||||
android:title="@string/muted_users_from_pseudo_account"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_app_about"
|
||||
android:icon="@drawable/ic_info"
|
||||
android:title="@string/app_about"/>
|
||||
|
||||
<!--<item-->
|
||||
<!--android:id="@+id/nav_translation"-->
|
||||
<!--android:icon="@drawable/ic_info"-->
|
||||
<!--android:title="@string/help_translation"/>-->
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_oss_license"
|
||||
android:icon="@drawable/ic_info"
|
||||
android:title="@string/oss_license"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_app_exit"
|
||||
android:icon="@drawable/ic_hot_tub"
|
||||
android:title="@string/app_exit"/>
|
||||
</menu>
|
||||
</item>
|
||||
</group>
|
||||
|
||||
<!--<item android:title="Communicate">-->
|
||||
<!--<menu>-->
|
||||
<!--<item-->
|
||||
<!--android:id="@+id/nav_share"-->
|
||||
<!--android:icon="@drawable/ic_menu_share"-->
|
||||
<!--android:title="Share"/>-->
|
||||
<!--<item-->
|
||||
<!--android:id="@+id/nav_send"-->
|
||||
<!--android:icon="@drawable/ic_menu_send"-->
|
||||
<!--android:title="Send"/>-->
|
||||
<!--</menu>-->
|
||||
<!--</item>-->
|
||||
|
||||
</menu>
|
Loading…
x
Reference in New Issue
Block a user