Skip to content

Commit

Permalink
Add action logic
Browse files Browse the repository at this point in the history
  • Loading branch information
cooltey committed Nov 29, 2023
1 parent 025f69c commit a754e58
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/src/main/java/org/wikipedia/page/PageFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import org.wikipedia.login.LoginActivity
import org.wikipedia.main.MainActivity
import org.wikipedia.media.AvPlayer
import org.wikipedia.navtab.NavTab
import org.wikipedia.nearby.NearbyActivity
import org.wikipedia.notifications.PollNotificationWorker
import org.wikipedia.page.action.PageActionItem
import org.wikipedia.page.campaign.CampaignDialog
Expand Down Expand Up @@ -1497,6 +1498,16 @@ class PageFragment : Fragment(), BackPressedHandler, CommunicationBridge.Communi
metricsPlatformArticleEventToolbarInteraction.logEditArticleClick()
}

override fun onViewOnMapSelected() {
title?.let {
if (page?.pageProperties?.geo != null) {
requireActivity().startActivity(NearbyActivity.newIntent(requireContext(), it.wikiSite))
} else {
FeedbackUtil.showMessage(this@PageFragment, getString(R.string.action_item_view_on_map_unavailable))
}
}
}

override fun forwardClick() {
goForward()
articleInteractionEvent?.logForwardClick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.widget.FrameLayout
import android.widget.PopupWindow
import androidx.core.view.doOnDetach
import androidx.core.widget.PopupWindowCompat
import androidx.core.widget.TextViewCompat
import com.google.android.material.textview.MaterialTextView
import org.wikipedia.R
import org.wikipedia.auth.AccountUtil
Expand All @@ -21,6 +22,7 @@ import org.wikipedia.page.action.PageActionItem
import org.wikipedia.page.customize.CustomizeToolbarActivity
import org.wikipedia.page.tabs.Tab
import org.wikipedia.settings.Prefs
import org.wikipedia.util.ResourceUtil

class PageActionOverflowView(context: Context) : FrameLayout(context) {

Expand Down Expand Up @@ -79,6 +81,12 @@ class PageActionOverflowView(context: Context) : FrameLayout(context) {
PageActionItem.EDIT_ARTICLE -> {
view.setCompoundDrawablesRelativeWithIntrinsicBounds(PageActionItem.editArticleIcon(model.page?.pageProperties?.canEdit != true), 0, 0, 0)
}
PageActionItem.VIEW_ON_MAP -> {
val geoAvailable = model.page?.pageProperties?.geo != null
val tintColor = ResourceUtil.getThemedColorStateList(context, if (geoAvailable) R.attr.primary_color else R.attr.inactive_color)
view.setTextColor(tintColor)
TextViewCompat.setCompoundDrawableTintList(view, tintColor)
}
else -> {
view.visibility = if (enabled) VISIBLE else GONE
}
Expand Down

0 comments on commit a754e58

Please sign in to comment.