[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preference Migration Part-1: Migrated NotificationsSettingsDialogPreference #19986

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
detekt issues
  • Loading branch information
07jasjeet committed Jan 19, 2024
commit 98d1e793cfe61f0ff147c0fe26f26206c3b12561
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,21 @@ class NotificationsSettingsDialogFragment(

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = requireContext()

@SuppressLint("InflateParams")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could avoid the use the suppress by using the onCreateView method. This is an example DialogFragment that does this.

val layout = requireActivity().layoutInflater.inflate(
R.layout.notifications_settings_types_dialog, null)
val outerView = layout.findViewById<ScrollView>(R.id.outer_view)

val outerView = layout.findViewById<ScrollView>(R.id.outer_view)
outerView.layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
LinearLayout.LayoutParams.WRAP_CONTENT)

val innerView = LinearLayout(context)
innerView.layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
)
LinearLayout.LayoutParams.MATCH_PARENT)
innerView.orientation = LinearLayout.VERTICAL

if (mShouldDisplayMainSwitch) {
val dividerView = View(context)
val dividerHeight = context.resources.getDimensionPixelSize(
Expand All @@ -89,16 +88,16 @@ class NotificationsSettingsDialogFragment(
spacerView.layoutParams = ViewGroup.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, spacerHeight)
innerView.addView(spacerView)
}

mDisabledView = View.inflate(context, R.layout.notifications_tab_disabled_text_layout, null)
mDisabledView?.layoutParams = ViewGroup.LayoutParams(
ActionBar.LayoutParams.MATCH_PARENT,
ActionBar.LayoutParams.WRAP_CONTENT
)
ActionBar.LayoutParams.WRAP_CONTENT)

mOptionsView = LinearLayout(context)
mOptionsView?.layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
)
LinearLayout.LayoutParams.MATCH_PARENT)
mOptionsView?.orientation = LinearLayout.VERTICAL
innerView.addView(mDisabledView)
innerView.addView(mOptionsView)
Expand All @@ -111,14 +110,15 @@ class NotificationsSettingsDialogFragment(
setNegativeButton(R.string.cancel, this@NotificationsSettingsDialogFragment)
setView(layout)
}

if (mShouldDisplayMainSwitch) {
setupTitleViewWithMainSwitch(outerView)
if (mTitleViewWithMainSwitch == null) {
if (mTitleViewWithMainSwitch == null)
AppLog.e(AppLog.T.NOTIFS, "Main switch enabled but layout not set")
} else {
else
builder.setCustomTitle(mTitleViewWithMainSwitch)
}
}

return builder.create()
}

Expand Down
Loading