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

Expand search functionality #1315

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 2 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ ktlint_standard_if-else-wrapping = disabled
ktlint_standard_no-wildcard-imports = disabled
ktlint_standard_comment-wrapping = disabled
ktlint_function_naming_ignore_when_annotated_with=Composable

[app/src/main/java/com/jerboa/datatypes/**.{kt,kts}]
ktlint = disabled
ktlint_standard_multiline-expression-wrapping = disabled
ktlint_standard_string-template-indent = disabled

[app/src/main/java/com/jerboa/DefaultInstances.kt]
ktlint = disabled
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/jerboa/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ package com.jerboa
const val DEBOUNCE_DELAY = 1000L
const val MAX_POST_TITLE_LENGTH = 200
const val DEFAULT_FONT_SIZE = 16

const val COMMENTS_DEPTH_MAX = 6
11 changes: 6 additions & 5 deletions app/src/main/java/com/jerboa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.os.Build
import android.os.Bundle
import android.util.Patterns
import android.widget.TextView
import android.widget.Toast
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
Expand Down Expand Up @@ -49,7 +48,6 @@ import com.jerboa.ui.components.common.Route
import com.jerboa.ui.components.common.ShowChangelog
import com.jerboa.ui.components.common.SwipeToNavigateBack
import com.jerboa.ui.components.community.CommunityActivity
import com.jerboa.ui.components.community.list.CommunityListActivity
import com.jerboa.ui.components.community.sidebar.CommunitySidebarActivity
import com.jerboa.ui.components.home.BottomNavActivity
import com.jerboa.ui.components.home.sidebar.SiteSidebarActivity
Expand All @@ -64,6 +62,7 @@ import com.jerboa.ui.components.privatemessage.CreatePrivateMessageActivity
import com.jerboa.ui.components.privatemessage.PrivateMessageReplyActivity
import com.jerboa.ui.components.report.comment.CreateCommentReportActivity
import com.jerboa.ui.components.report.post.CreatePostReportActivity
import com.jerboa.ui.components.search.SearchActivity
import com.jerboa.ui.components.settings.SettingsActivity
import com.jerboa.ui.components.settings.about.AboutActivity
import com.jerboa.ui.components.settings.account.AccountSettingsActivity
Expand Down Expand Up @@ -366,12 +365,14 @@ class MainActivity : AppCompatActivity() {
),
) {
val args = Route.CommunityListArgs(it)
CommunityListActivity(
SearchActivity(
appState = appState,
selectMode = args.select,
blurNSFW = appSettings.blurNSFW,
selectCommunityMode = args.select,
appSettings = appSettings,
drawerState = drawerState,
followList = siteViewModel.getFollowList(),
accountViewModel = accountViewModel,
siteViewModel = siteViewModel,
)
}

Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/jerboa/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import coil.annotation.ExperimentalCoilApi
import coil.imageLoader
import com.jerboa.api.API
import com.jerboa.api.ApiState
import com.jerboa.datatypes.getDisplayName
import com.jerboa.db.APP_SETTINGS_DEFAULT
import com.jerboa.db.entity.AppSettings
import com.jerboa.ui.components.common.Route
Expand Down Expand Up @@ -1098,7 +1099,7 @@ fun showBlockPersonToast(
is ApiState.Success -> {
Toast.makeText(
ctx,
"${blockPersonRes.data.person_view.person.name} Blocked",
"${blockPersonRes.data.person_view.person.getDisplayName()} Blocked",
Toast.LENGTH_SHORT,
)
.show()
Expand Down Expand Up @@ -1233,10 +1234,9 @@ fun findAndUpdatePost(
posts: List<PostView>,
updatedPostView: PostView,
): List<PostView> {
val foundIndex =
posts.indexOfFirst {
it.post.id == updatedPostView.post.id
}
val foundIndex = posts.indexOfFirst {
it.post.id == updatedPostView.post.id
}
return if (foundIndex != -1) {
val mutable = posts.toMutableList()
mutable[foundIndex] = updatedPostView
Expand Down
82 changes: 35 additions & 47 deletions app/src/main/java/com/jerboa/datatypes/Others.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import it.vercruysse.lemmyapi.dto.CommentSortType
import it.vercruysse.lemmyapi.dto.ListingType
import it.vercruysse.lemmyapi.dto.SortType


data class CommentSortData(
@StringRes val text: Int,
val icon: ImageVector,
Expand Down Expand Up @@ -51,7 +50,7 @@ val SortType.data: SortData
SortType.Controversial -> SortData(
R.string.sorttype_controversial,
R.string.sorttype_controversial,
Icons.Outlined.ThumbsUpDown
Icons.Outlined.ThumbsUpDown,
)

SortType.TopDay -> SortData(R.string.sorttype_topday, R.string.dialogs_top_day, Icons.Outlined.BarChart)
Expand All @@ -62,64 +61,61 @@ val SortType.data: SortData
SortType.MostComments -> SortData(
R.string.sorttype_mostcomments,
R.string.sorttype_mostcomments,
Icons.Outlined.FormatListNumbered
Icons.Outlined.FormatListNumbered,
)

SortType.NewComments -> SortData(
R.string.sorttype_newcomments,
R.string.sorttype_newcomments,
Icons.Outlined.NewReleases
Icons.Outlined.NewReleases,
)

SortType.TopHour -> SortData(R.string.sorttype_tophour, R.string.dialogs_top_hour, Icons.Outlined.BarChart)
SortType.TopSixHour -> SortData(
R.string.sorttype_topsixhour,
R.string.dialogs_top_six_hour,
Icons.Outlined.BarChart
Icons.Outlined.BarChart,
)

SortType.TopTwelveHour -> SortData(
R.string.sorttype_toptwelvehour,
R.string.dialogs_top_twelve_hour,
Icons.Outlined.BarChart
Icons.Outlined.BarChart,
)

SortType.TopThreeMonths -> SortData(
R.string.sorttype_topthreemonths,
R.string.dialogs_top_three_month,
Icons.Outlined.BarChart
Icons.Outlined.BarChart,
)

SortType.TopSixMonths -> SortData(
R.string.sorttype_topsixmonths,
R.string.dialogs_top_six_month,
Icons.Outlined.BarChart
Icons.Outlined.BarChart,
)

SortType.TopNineMonths -> SortData(
R.string.sorttype_topninemonths,
R.string.dialogs_top_nine_month,
Icons.Outlined.BarChart
Icons.Outlined.BarChart,
)

SortType.Scaled -> SortData(R.string.sorttype_scaled, R.string.sorttype_scaled, Icons.Outlined.Scale)
}


/**
* Returns localized Strings for UserTab Enum
*/
fun getLocalizedStringForUserTab(
ctx: Context,
tab: UserTab,
): String {
val returnString =
when (tab) {
UserTab.About -> ctx.getString(R.string.person_profile_activity_about)
UserTab.Posts -> ctx.getString(R.string.person_profile_activity_posts)
UserTab.Comments -> ctx.getString(R.string.person_profile_activity_comments)
}
return returnString
return when (tab) {
UserTab.About -> ctx.getString(R.string.person_profile_activity_about)
UserTab.Posts -> ctx.getString(R.string.person_profile_activity_posts)
UserTab.Comments -> ctx.getString(R.string.person_profile_activity_comments)
}
}

/**
Expand All @@ -129,14 +125,12 @@ fun getLocalizedListingTypeName(
ctx: Context,
listingType: ListingType,
): String {
val returnString =
when (listingType) {
ListingType.All -> ctx.getString(R.string.home_all)
ListingType.Local -> ctx.getString(R.string.home_local)
ListingType.Subscribed -> ctx.getString(R.string.home_subscribed)
ListingType.ModeratorView -> ctx.getString(R.string.home_moderator_view)
}
return returnString
return when (listingType) {
ListingType.All -> ctx.getString(R.string.home_all)
ListingType.Local -> ctx.getString(R.string.home_local)
ListingType.Subscribed -> ctx.getString(R.string.home_subscribed)
ListingType.ModeratorView -> ctx.getString(R.string.home_moderator_view)
}
}

/**
Expand All @@ -146,15 +140,13 @@ fun getLocalizedCommentSortTypeName(
ctx: Context,
commentSortType: CommentSortType,
): String {
val returnString =
when (commentSortType) {
CommentSortType.Hot -> ctx.getString(R.string.sorttype_hot)
CommentSortType.New -> ctx.getString(R.string.sorttype_new)
CommentSortType.Old -> ctx.getString(R.string.sorttype_old)
CommentSortType.Top -> ctx.getString(R.string.dialogs_top)
CommentSortType.Controversial -> ctx.getString(R.string.sorttype_controversial)
}
return returnString
return when (commentSortType) {
CommentSortType.Hot -> ctx.getString(R.string.sorttype_hot)
CommentSortType.New -> ctx.getString(R.string.sorttype_new)
CommentSortType.Old -> ctx.getString(R.string.sorttype_old)
CommentSortType.Top -> ctx.getString(R.string.dialogs_top)
CommentSortType.Controversial -> ctx.getString(R.string.sorttype_controversial)
}
}

/**
Expand All @@ -164,12 +156,10 @@ fun getLocalizedUnreadOrAllName(
ctx: Context,
unreadOrAll: UnreadOrAll,
): String {
val returnString =
when (unreadOrAll) {
UnreadOrAll.Unread -> ctx.getString(R.string.dialogs_unread)
UnreadOrAll.All -> ctx.getString(R.string.dialogs_all)
}
return returnString
return when (unreadOrAll) {
UnreadOrAll.Unread -> ctx.getString(R.string.dialogs_unread)
UnreadOrAll.All -> ctx.getString(R.string.dialogs_all)
}
}

/**
Expand All @@ -179,11 +169,9 @@ fun getLocalizedStringForInboxTab(
ctx: Context,
tab: InboxTab,
): String {
val returnString =
when (tab) {
InboxTab.Replies -> ctx.getString(R.string.inbox_activity_replies)
InboxTab.Mentions -> ctx.getString(R.string.inbox_activity_mentions)
InboxTab.Messages -> ctx.getString(R.string.inbox_activity_messages)
}
return returnString
return when (tab) {
InboxTab.Replies -> ctx.getString(R.string.inbox_activity_replies)
InboxTab.Mentions -> ctx.getString(R.string.inbox_activity_mentions)
InboxTab.Messages -> ctx.getString(R.string.inbox_activity_messages)
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/jerboa/datatypes/SampleData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ val samplePerson =
updated = "2021-10-11T07:14:53.548707",
actor_id = "https://lemmy.ml/u/homeless",
bio =
"This is my bio.\n\nI like trucks, trains, and geese. This is *one* longer line " +
"This is my bio.\n\nI like trucks, trains, and geese. This is *one* longer line " +
"that I have in here. But I'm not sure blah blah blah\n\nI have " +
"**tres ojos**.",
local = true,
Expand Down Expand Up @@ -311,7 +311,7 @@ val sampleComment =
creator_id = 56450,
post_id = 139549,
content =
"This *looks* really cool and similar to Joplin. **Having issues** getting LaTeX to" +
"This *looks* really cool and similar to Joplin. **Having issues** getting LaTeX to" +
" " +
"work" +
".\n\nIts kind of a long comment\n\nbut I don't want...",
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/jerboa/datatypes/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ package com.jerboa.datatypes

import it.vercruysse.lemmyapi.v0x19.datatypes.Person


fun Person.getDisplayName(): String = this.display_name ?: this.name
86 changes: 0 additions & 86 deletions app/src/main/java/com/jerboa/model/CommunityListViewModel.kt

This file was deleted.

Loading