Skip to content

Commit

Permalink
29
Browse files Browse the repository at this point in the history
29
  • Loading branch information
umerov1999 committed May 27, 2023
1 parent c00579a commit bb170c2
Show file tree
Hide file tree
Showing 34 changed files with 279 additions and 323 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect

2 -> {
mCompositeDisposable.add(InteractorFactory.createStoriesInteractor()
.getStory(
.getStories(
Settings.get().accounts().current,
null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ class FeedbackVKOfficialDtoAdapter :
val dto = FeedbackVKOfficial()
if (hasObject(root_item, "action")) {
val action_item = root_item["action"]?.jsonObject
if ("authorize" == optString(action_item, "type") || "custom" == optString(
if ("authorize" == optString(action_item, "type")) {
dto.action = ActionBrowserURL(optString(action_item, "url"))
} else if ("custom" == optString(
action_item,
"type"
) && optString(root_item, "icon_type") == "friend_found"
) && optString(
root_item,
"icon_type"
) == "friend_found"
) {
dto.action = ActionURL(optString(action_item, "url"))
} else if ("message_open" == optString(
Expand Down Expand Up @@ -182,6 +187,13 @@ class FeedbackVKOfficialDtoAdapter :
kJson.decodeFromJsonElement(ImageAdditional.serializer(), s)
dto.images?.add(imgh)
}

if (hasObject(additional_item, "action")) {
val action_item = additional_item["action"]?.jsonObject
if ("custom" == optString(action_item, "type")) {
dto.images_action = ActionURL(optString(action_item, "url"))
}
}
}
if ("photo" == optString(additional_item, "type")) {
attachments.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import dev.ragnarok.fenrir.api.model.Items
import dev.ragnarok.fenrir.api.model.VKApiNarratives
import dev.ragnarok.fenrir.api.model.VKApiStory
import dev.ragnarok.fenrir.api.model.response.ShortVideosResponse
import dev.ragnarok.fenrir.api.model.response.StoriesResponse
import dev.ragnarok.fenrir.api.model.response.StoryGetResponse
import dev.ragnarok.fenrir.api.model.response.StoryResponse
import dev.ragnarok.fenrir.api.model.response.ViewersListResponse
import dev.ragnarok.fenrir.api.model.server.VKApiStoryUploadServer
import dev.ragnarok.fenrir.api.services.IStoriesShortVideosService
Expand All @@ -19,10 +19,14 @@ import io.reactivex.rxjava3.core.Single
internal class StoriesShortVideosApi(accountId: Long, provider: IServiceProvider) :
AbsApi(accountId, provider), IStoriesShortVideosApi {

override fun getStory(owner_id: Long?, extended: Int?, fields: String?): Single<StoryResponse> {
override fun getStories(
owner_id: Long?,
extended: Int?,
fields: String?
): Single<StoriesResponse> {
return provideService(IStoriesShortVideosService(), TokenType.USER, TokenType.COMMUNITY)
.flatMap { service ->
service.getStory(owner_id, extended, fields)
service.getStories(owner_id, extended, fields)
.map(extractResponseWithErrorHandling())
}
}
Expand Down Expand Up @@ -67,16 +71,16 @@ internal class StoriesShortVideosApi(accountId: Long, provider: IServiceProvider
}
}

override fun searchStory(
override fun searchStories(
q: String?,
mentioned_id: Long?,
count: Int?,
extended: Int?,
fields: String?
): Single<StoryResponse> {
): Single<StoriesResponse> {
return provideService(IStoriesShortVideosService(), TokenType.USER, TokenType.COMMUNITY)
.flatMap { service ->
service.searchStory(q, mentioned_id, count, extended, fields)
service.searchStories(q, mentioned_id, count, extended, fields)
.map(extractResponseWithErrorHandling())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import dev.ragnarok.fenrir.api.model.Items
import dev.ragnarok.fenrir.api.model.VKApiNarratives
import dev.ragnarok.fenrir.api.model.VKApiStory
import dev.ragnarok.fenrir.api.model.response.ShortVideosResponse
import dev.ragnarok.fenrir.api.model.response.StoriesResponse
import dev.ragnarok.fenrir.api.model.response.StoryGetResponse
import dev.ragnarok.fenrir.api.model.response.StoryResponse
import dev.ragnarok.fenrir.api.model.response.ViewersListResponse
import dev.ragnarok.fenrir.api.model.server.VKApiStoryUploadServer
import io.reactivex.rxjava3.core.Single
Expand Down Expand Up @@ -40,7 +40,7 @@ interface IStoriesShortVideosApi {
fun stories_save(upload_results: String?): Single<Items<VKApiStory>>

@CheckResult
fun getStory(owner_id: Long?, extended: Int?, fields: String?): Single<StoryResponse>
fun getStories(owner_id: Long?, extended: Int?, fields: String?): Single<StoriesResponse>

@CheckResult
fun getNarratives(owner_id: Long, offset: Int?, count: Int?): Single<Items<VKApiNarratives>>
Expand All @@ -53,13 +53,13 @@ interface IStoriesShortVideosApi {
): Single<StoryGetResponse>

@CheckResult
fun searchStory(
fun searchStories(
q: String?,
mentioned_id: Long?,
count: Int?,
extended: Int?,
fields: String?
): Single<StoryResponse>
): Single<StoriesResponse>

@CheckResult
fun getShortVideos(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
class StoryResponse {
class StoriesResponse {
@SerialName("items")
var items: List<StoryBlockResponce>? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import dev.ragnarok.fenrir.api.model.VKApiNarratives
import dev.ragnarok.fenrir.api.model.VKApiStory
import dev.ragnarok.fenrir.api.model.response.BaseResponse
import dev.ragnarok.fenrir.api.model.response.ShortVideosResponse
import dev.ragnarok.fenrir.api.model.response.StoriesResponse
import dev.ragnarok.fenrir.api.model.response.StoryGetResponse
import dev.ragnarok.fenrir.api.model.response.StoryResponse
import dev.ragnarok.fenrir.api.model.response.ViewersListResponse
import dev.ragnarok.fenrir.api.model.server.VKApiStoryUploadServer
import dev.ragnarok.fenrir.api.rest.IServiceRest
Expand Down Expand Up @@ -82,17 +82,17 @@ class IStoriesShortVideosService : IServiceRest() {
)
}

fun getStory(
fun getStories(
owner_id: Long?,
extended: Int?,
fields: String?
): Single<BaseResponse<StoryResponse>> {
): Single<BaseResponse<StoriesResponse>> {
return rest.request(
"stories.get", form(
"owner_id" to owner_id,
"extended" to extended,
"fields" to fields
), base(StoryResponse.serializer())
), base(StoriesResponse.serializer())
)
}

Expand Down Expand Up @@ -124,21 +124,21 @@ class IStoriesShortVideosService : IServiceRest() {
)
}

fun searchStory(
fun searchStories(
q: String?,
mentioned_id: Long?,
count: Int?,
extended: Int?,
fields: String?
): Single<BaseResponse<StoryResponse>> {
): Single<BaseResponse<StoriesResponse>> {
return rest.request(
"stories.search", form(
"q" to q,
"mentioned_id" to mentioned_id,
"count" to count,
"extended" to extended,
"fields" to fields
), base(StoryResponse.serializer())
), base(StoriesResponse.serializer())
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ interface IStoriesShortVideosInteractor {
offset: Int
): Single<List<Pair<Owner, Boolean>>>

fun searchStory(accountId: Long, q: String?, mentioned_id: Long?): Single<List<Story>>
fun getStory(accountId: Long, owner_id: Long?): Single<List<Story>>
fun searchStories(accountId: Long, q: String?, mentioned_id: Long?): Single<List<Story>>
fun getStories(accountId: Long, owner_id: Long?): Single<List<Story>>
fun stories_delete(accountId: Long, owner_id: Long, story_id: Int): Single<Int>
fun getNarratives(
accountId: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ class StoriesShortVideosInteractor(
.stories().stories_delete(owner_id, story_id)
}

override fun getStory(accountId: Long, owner_id: Long?): Single<List<Story>> {
override fun getStories(accountId: Long, owner_id: Long?): Single<List<Story>> {
return networker.vkDefault(accountId)
.stories()
.getStory(owner_id, 1, Fields.FIELDS_BASE_OWNER)
.getStories(owner_id, 1, Fields.FIELDS_BASE_OWNER)
.flatMap { story ->
val dtos_multy = listEmptyIfNull(story.items)
val dtos: MutableList<VKApiStory> = ArrayList()
Expand Down Expand Up @@ -156,14 +156,14 @@ class StoriesShortVideosInteractor(
}
}

override fun searchStory(
override fun searchStories(
accountId: Long,
q: String?,
mentioned_id: Long?
): Single<List<Story>> {
return networker.vkDefault(accountId)
.stories()
.searchStory(q, mentioned_id, 1000, 1, Fields.FIELDS_BASE_OWNER)
.searchStories(q, mentioned_id, 1000, 1, Fields.FIELDS_BASE_OWNER)
.flatMap { story ->
val dtos_multy = listEmptyIfNull(story.items)
val dtos: MutableList<VKApiStory> = ArrayList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,15 @@ class FeedbackVKOfficialAdapter(
holder.time.text = AppTextUtils.getDateFromUnixTime(context, Page.time)
val Img = Page.getImage(256)
if (Img == null) {
holder.additional.setOnClickListener { }
holder.additional.visibility = View.GONE
with().cancelRequest(holder.additional)
} else {
holder.additional.setOnClickListener {
Page.images_action.requireNonNull { sc ->
clickListener?.openAction(sc)
}
}
holder.additional.visibility = View.VISIBLE
with()
.load(Img.url)
Expand Down Expand Up @@ -297,7 +303,7 @@ class FeedbackVKOfficialAdapter(
}
}
Page.action.ifNonNull({
if (it.getActionType() == FeedbackVKOfficial.Action_Types.URL) {
if (it.getActionType() == FeedbackVKOfficial.Action_Types.URL || it.getActionType() == FeedbackVKOfficial.Action_Types.BROWSER_URL) {
holder.actionButton.setText(R.string.more_info)
} else {
holder.actionButton.setText(R.string.open)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import dev.ragnarok.fenrir.listener.EndlessRecyclerOnScrollListener
import dev.ragnarok.fenrir.listener.OnSectionResumeCallback
import dev.ragnarok.fenrir.listener.PicassoPauseOnScrollListener
import dev.ragnarok.fenrir.model.FeedbackVKOfficial
import dev.ragnarok.fenrir.model.FeedbackVKOfficial.ActionBrowserURL
import dev.ragnarok.fenrir.model.FeedbackVKOfficial.ActionMessage
import dev.ragnarok.fenrir.model.FeedbackVKOfficial.ActionURL
import dev.ragnarok.fenrir.model.FeedbackVKOfficialList
Expand Down Expand Up @@ -154,16 +155,32 @@ class FeedbackVKOfficialFragment :
}

override fun openAction(action: FeedbackVKOfficial.Action) {
if (action.getActionType() == FeedbackVKOfficial.Action_Types.URL) {
LinkHelper.openLinkInBrowser(requireActivity(), (action as ActionURL).getUrl())
} else if (action.getActionType() == FeedbackVKOfficial.Action_Types.MESSAGE) {
val msg = action as ActionMessage
getMessagesLookupPlace(
Settings.get().accounts().current,
msg.getPeerId(),
msg.getMessageId(),
null
).tryOpenWith(requireActivity())
when (action.getActionType()) {
FeedbackVKOfficial.Action_Types.BROWSER_URL -> {
LinkHelper.openLinkInBrowser(
requireActivity(),
(action as ActionBrowserURL).getUrl()
)
}

FeedbackVKOfficial.Action_Types.URL -> {
LinkHelper.openUrl(
requireActivity(),
Settings.get().accounts().current,
(action as ActionURL).getUrl(),
false
)
}

FeedbackVKOfficial.Action_Types.MESSAGE -> {
val msg = action as ActionMessage
getMessagesLookupPlace(
Settings.get().accounts().current,
msg.getPeerId(),
msg.getMessageId(),
null
).tryOpenWith(requireActivity())
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ abstract class AbsWallPresenter<V : IWallView> internal constructor(
cacheCompositeDisposable.clear()
requestWall(0)
if (!Settings.get().other().isDisable_history) {
appendDisposable(storiesInteractor.getStory(
appendDisposable(storiesInteractor.getStories(
accountId,
if (accountId == ownerId) null else ownerId
)
Expand Down Expand Up @@ -904,7 +904,7 @@ abstract class AbsWallPresenter<V : IWallView> internal constructor(
storiesInteractor = InteractorFactory.createStoriesInteractor()
loadWallCachedData()
if (!Settings.get().other().isDisable_history) {
appendDisposable(storiesInteractor.getStory(
appendDisposable(storiesInteractor.getStories(
accountId,
if (accountId == ownerId) null else ownerId
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ class GroupWallPresenter(
}

override fun searchStory(ByName: Boolean) {
appendDisposable(storiesInteractor.searchStory(
appendDisposable(storiesInteractor.searchStories(
accountId,
if (ByName) community.fullName else null,
if (ByName) null else ownerId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ class UserWallPresenter(
}

override fun searchStory(ByName: Boolean) {
appendDisposable(storiesInteractor.searchStory(
appendDisposable(storiesInteractor.searchStories(
accountId,
if (ByName) user.fullName else null,
if (ByName) null else ownerId
Expand Down
15 changes: 15 additions & 0 deletions app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/link/LinkHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.browser.customtabs.CustomTabsIntent
import androidx.browser.customtabs.CustomTabsService
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import dev.ragnarok.fenrir.R
import dev.ragnarok.fenrir.api.model.AccessIdPair
import dev.ragnarok.fenrir.domain.InteractorFactory
import dev.ragnarok.fenrir.fragment.fave.FaveTabsFragment
import dev.ragnarok.fenrir.fragment.photos.vkphotos.IVKPhotosView
Expand All @@ -23,6 +24,7 @@ import dev.ragnarok.fenrir.link.types.*
import dev.ragnarok.fenrir.link.types.FaveLink
import dev.ragnarok.fenrir.media.music.MusicPlaybackService.Companion.startForPlayList
import dev.ragnarok.fenrir.model.*
import dev.ragnarok.fenrir.place.PlaceFactory
import dev.ragnarok.fenrir.place.PlaceFactory.getArtistPlace
import dev.ragnarok.fenrir.place.PlaceFactory.getAudiosInAlbumPlace
import dev.ragnarok.fenrir.place.PlaceFactory.getAudiosPlace
Expand Down Expand Up @@ -352,6 +354,19 @@ object LinkHelper {
}) { e -> createCustomToast(context).showToastThrowable(e) }
}

AbsLink.STORY -> {
val storyLink = link as StoryLink
InteractorFactory.createStoriesInteractor().getStoryById(
accountId,
listOf(AccessIdPair(storyLink.storyId, storyLink.ownerId, storyLink.access_key))
)
.fromIOToMain()
.subscribe({
PlaceFactory.getHistoryVideoPreviewPlace(accountId, ArrayList(it), 0)
.tryOpenWith(context)
}) { e -> createCustomToast(context).showToastThrowable(e) }
}

else -> return false
}
return true
Expand Down
Loading

0 comments on commit bb170c2

Please sign in to comment.