-
Notifications
You must be signed in to change notification settings - Fork 103
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
Target API 34 #571
Closed
Closed
Target API 34 #571
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
65034d1
Specify foreground service type in manifest
oakkitten ba5ff89
Request permission to schedule exact alarms
oakkitten 9d2eab8
Request permission to show notifications
oakkitten a0a2f60
Bump SDK version to 34 & update libraries
oakkitten 59e8fa7
Fix CI
oakkitten 6adda8d
Fix a lint error, temporarily, until using AGP 8
oakkitten 31ccdaf
Fix an R8 warning about missing class
oakkitten 2f8192f
Update translations
oakkitten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
app/src/main/java/com/ubergeek42/WeechatAndroid/dialogs/ScrollableDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.ubergeek42.WeechatAndroid.dialogs | ||
|
||
import android.app.Dialog | ||
import android.content.Context | ||
import android.widget.ScrollView | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.appcompat.widget.AppCompatTextView | ||
import com.ubergeek42.WeechatAndroid.R | ||
|
||
private class ButtonInfo( | ||
val title: CharSequence, | ||
val onClickListener: () -> Unit | ||
) | ||
|
||
private class ScrollableDialogInfo( | ||
var text: CharSequence? = null, | ||
var title: CharSequence? = null, | ||
var positiveButton: ButtonInfo? = null, | ||
var negativeButton: ButtonInfo? = null, | ||
) | ||
|
||
interface ScrollableDialogBuilder { | ||
fun setTitle(title: CharSequence) | ||
fun setTitle(titleResourceId: Int) | ||
fun setText(text: CharSequence) | ||
fun setText(textResourceId: Int) | ||
fun setPositiveButton(title: CharSequence, onClickListener: () -> Unit) | ||
fun setPositiveButton(titleResourceId: Int, onClickListener: () -> Unit) | ||
fun setNegativeButton(title: CharSequence, onClickListener: () -> Unit) | ||
fun setNegativeButton(titleResourceId: Int, onClickListener: () -> Unit) | ||
} | ||
|
||
private class ScrollableDialogBuilderImpl(val context: Context) : ScrollableDialogBuilder { | ||
val info = ScrollableDialogInfo() | ||
override fun setTitle(title: CharSequence) { | ||
info.title = title | ||
} | ||
|
||
override fun setTitle(titleResourceId: Int) { | ||
info.title = context.getString(titleResourceId) | ||
} | ||
|
||
override fun setText(text: CharSequence) { | ||
info.text = text | ||
} | ||
|
||
override fun setText(textResourceId: Int) { | ||
info.text = context.getString(textResourceId) | ||
} | ||
|
||
override fun setPositiveButton(title: CharSequence, onClickListener: () -> Unit) { | ||
info.positiveButton = ButtonInfo(title, onClickListener) | ||
} | ||
|
||
override fun setPositiveButton(titleResourceId: Int, onClickListener: () -> Unit) { | ||
info.positiveButton = ButtonInfo(context.getString(titleResourceId), onClickListener) | ||
} | ||
|
||
override fun setNegativeButton(title: CharSequence, onClickListener: () -> Unit) { | ||
info.negativeButton = ButtonInfo(title, onClickListener) | ||
} | ||
|
||
override fun setNegativeButton(titleResourceId: Int, onClickListener: () -> Unit) { | ||
info.negativeButton = ButtonInfo(context.getString(titleResourceId), onClickListener) | ||
} | ||
} | ||
|
||
fun Context.createScrollableDialog(builderBlock: ScrollableDialogBuilder.() -> Unit): Dialog { | ||
val info = ScrollableDialogBuilderImpl(this).apply(builderBlock).info | ||
|
||
val padding = resources.getDimension(R.dimen.dialog_padding_full).toInt() | ||
val scrollView = ScrollView(this) | ||
scrollView.addView(AppCompatTextView(this).apply { text = info.text }) | ||
scrollView.setPadding(padding, padding / 2, padding, 0) | ||
|
||
val builder: AlertDialog.Builder = FancyAlertDialogBuilder(this) | ||
.setTitle(info.title) | ||
.setView(scrollView) | ||
|
||
info.positiveButton?.let { | ||
builder.setPositiveButton(it.title) { _, _ -> it.onClickListener() } | ||
} | ||
|
||
info.negativeButton?.let { | ||
builder.setNegativeButton(it.title) { _, _ -> it.onClickListener() } | ||
} | ||
|
||
return builder.create() | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhh not really sure, did that commit a while back
I'm assuming that
connect()
was called too often but this wasn't a problem since if we were connected it was no-op. Now that it checks for permissions and stuff it was easier to fix the too much part than reworking the logic otherwise?Can't be sure tho