feat: 更多 Proto API
This commit is contained in:
parent
21825a10e1
commit
a9ea94acbf
|
|
@ -370,7 +370,6 @@ class App : Application(), IApp, IGetter, SketchFactory {
|
|||
)
|
||||
} else context.getColorCompat(R.color.theme_color_background_light)
|
||||
}
|
||||
|
||||
R.attr.colorWindowBackground -> {
|
||||
if (ThemeUtil.isTranslucentTheme(theme)) {
|
||||
return context.getColorCompat(R.color.transparent)
|
||||
|
|
@ -385,7 +384,6 @@ class App : Application(), IApp, IGetter, SketchFactory {
|
|||
)
|
||||
} else context.getColorCompat(R.color.theme_color_window_background_light)
|
||||
}
|
||||
|
||||
R.attr.colorChip -> {
|
||||
if (ThemeUtil.isTranslucentTheme(theme)) {
|
||||
return context.getColorCompat(R.color.transparent)
|
||||
|
|
@ -400,7 +398,6 @@ class App : Application(), IApp, IGetter, SketchFactory {
|
|||
)
|
||||
} else context.getColorCompat(R.color.theme_color_chip_light)
|
||||
}
|
||||
|
||||
R.attr.colorOnChip -> {
|
||||
if (ThemeUtil.isTranslucentTheme(theme)) {
|
||||
return getColorByAttr(context, R.attr.colorTextSecondary, theme)
|
||||
|
|
@ -691,6 +688,9 @@ class App : Application(), IApp, IGetter, SketchFactory {
|
|||
}
|
||||
|
||||
override fun createSketch(): Sketch = Sketch.Builder(this).apply {
|
||||
httpStack(OkHttpStack.Builder().apply {
|
||||
userAgent(System.getProperty("http.agent"))
|
||||
}.build())
|
||||
components {
|
||||
addDrawableDecoder(
|
||||
when {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.huanchengfly.tieba.post.api
|
|||
import com.huanchengfly.tieba.post.api.retrofit.NullOnEmptyConverterFactory
|
||||
import com.huanchengfly.tieba.post.api.retrofit.adapter.DeferredCallAdapterFactory
|
||||
import com.huanchengfly.tieba.post.api.retrofit.converter.gson.GsonConverterFactory
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interceptors.CommonHeaderInterceptor
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interfaces.LiteApiInterface
|
||||
import okhttp3.ConnectionPool
|
||||
import okhttp3.OkHttpClient
|
||||
|
|
@ -18,6 +19,11 @@ object LiteApi {
|
|||
.addConverterFactory(NullOnEmptyConverterFactory())
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(OkHttpClient.Builder().apply {
|
||||
addInterceptor(
|
||||
CommonHeaderInterceptor(
|
||||
Header.USER_AGENT to { System.getProperty("http.agent") },
|
||||
)
|
||||
)
|
||||
connectionPool(connectionPool)
|
||||
}.build())
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.huanchengfly.tieba.post.App
|
|||
import com.huanchengfly.tieba.post.api.models.OAID
|
||||
import com.huanchengfly.tieba.post.api.models.protos.AppPosInfo
|
||||
import com.huanchengfly.tieba.post.api.models.protos.CommonRequest
|
||||
import com.huanchengfly.tieba.post.api.models.protos.frsPage.AdParam
|
||||
import com.huanchengfly.tieba.post.api.retrofit.RetrofitTiebaApi
|
||||
import com.huanchengfly.tieba.post.api.retrofit.body.MyMultipartBody
|
||||
import com.huanchengfly.tieba.post.toJson
|
||||
|
|
@ -36,6 +37,10 @@ fun buildProtobufRequestBody(
|
|||
.build()
|
||||
}
|
||||
|
||||
fun buildAdParam(): AdParam {
|
||||
return AdParam(load_count = 0, refresh_count = 4, yoga_lib_version = "1.0")
|
||||
}
|
||||
|
||||
fun buildAppPosInfo(): AppPosInfo {
|
||||
return AppPosInfo(
|
||||
addr_timestamp = 0L,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.huanchengfly.tieba.post.api.ForumSortType
|
|||
import com.huanchengfly.tieba.post.api.SearchThreadFilter
|
||||
import com.huanchengfly.tieba.post.api.SearchThreadOrder
|
||||
import com.huanchengfly.tieba.post.api.models.*
|
||||
import com.huanchengfly.tieba.post.api.models.protos.frsPage.FrsPageResponse
|
||||
import com.huanchengfly.tieba.post.api.models.protos.hotThreadList.HotThreadListResponse
|
||||
import com.huanchengfly.tieba.post.api.models.protos.personalized.PersonalizedResponse
|
||||
import com.huanchengfly.tieba.post.api.models.protos.userLike.UserLikeResponse
|
||||
|
|
@ -1082,4 +1083,15 @@ interface ITiebaApi {
|
|||
fun hotThreadListFlow(
|
||||
tabCode: String
|
||||
): Flow<HotThreadListResponse>
|
||||
|
||||
/**
|
||||
* 吧页面
|
||||
*
|
||||
* @param forumName 吧名
|
||||
* @param goodClassifyId 精品贴分类
|
||||
*/
|
||||
fun frsPage(
|
||||
forumName: String,
|
||||
goodClassifyId: Int? = 0
|
||||
): Flow<FrsPageResponse>
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import com.huanchengfly.tieba.post.api.Param
|
|||
import com.huanchengfly.tieba.post.api.SearchThreadFilter
|
||||
import com.huanchengfly.tieba.post.api.SearchThreadOrder
|
||||
import com.huanchengfly.tieba.post.api.booleanToString
|
||||
import com.huanchengfly.tieba.post.api.buildAdParam
|
||||
import com.huanchengfly.tieba.post.api.buildAppPosInfo
|
||||
import com.huanchengfly.tieba.post.api.buildCommonRequest
|
||||
import com.huanchengfly.tieba.post.api.buildProtobufRequestBody
|
||||
|
|
@ -44,6 +45,9 @@ import com.huanchengfly.tieba.post.api.models.UserLikeForumBean
|
|||
import com.huanchengfly.tieba.post.api.models.UserPostBean
|
||||
import com.huanchengfly.tieba.post.api.models.WebReplyResultBean
|
||||
import com.huanchengfly.tieba.post.api.models.WebUploadPicBean
|
||||
import com.huanchengfly.tieba.post.api.models.protos.frsPage.FrsPageRequest
|
||||
import com.huanchengfly.tieba.post.api.models.protos.frsPage.FrsPageRequestData
|
||||
import com.huanchengfly.tieba.post.api.models.protos.frsPage.FrsPageResponse
|
||||
import com.huanchengfly.tieba.post.api.models.protos.hotThreadList.HotThreadListRequest
|
||||
import com.huanchengfly.tieba.post.api.models.protos.hotThreadList.HotThreadListRequestData
|
||||
import com.huanchengfly.tieba.post.api.models.protos.hotThreadList.HotThreadListResponse
|
||||
|
|
@ -793,4 +797,33 @@ object MixedTiebaApiImpl : ITiebaApi {
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun frsPage(
|
||||
forumName: String,
|
||||
goodClassifyId: Int?
|
||||
): Flow<FrsPageResponse> {
|
||||
return RetrofitTiebaApi.OFFICIAL_PROTOBUF_TIEBA_API.frsPageFlow(
|
||||
buildProtobufRequestBody(
|
||||
FrsPageRequest(
|
||||
FrsPageRequestData(
|
||||
ad_param = buildAdParam(),
|
||||
app_pos = buildAppPosInfo(),
|
||||
call_from = 0,
|
||||
category_id = 0,
|
||||
cid = goodClassifyId ?: 0,
|
||||
common = buildCommonRequest(),
|
||||
ctime = 0,
|
||||
data_size = 0,
|
||||
scr_dip = App.ScreenInfo.DENSITY.toDouble(),
|
||||
scr_h = getScreenHeight(),
|
||||
scr_w = getScreenWidth(),
|
||||
is_good = if (goodClassifyId != null) 1 else 0,
|
||||
kw = forumName,
|
||||
rn = 90,
|
||||
rn_need = 30
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,16 @@ package com.huanchengfly.tieba.post.api.retrofit.interfaces
|
|||
|
||||
import com.huanchengfly.tieba.post.api.retrofit.ApiResult
|
||||
import kotlinx.coroutines.Deferred
|
||||
import okhttp3.ResponseBody
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Streaming
|
||||
import retrofit2.http.Url
|
||||
|
||||
interface LiteApiInterface {
|
||||
@GET("https://huancheng65.github.io/TiebaLite/wallpapers.json")
|
||||
fun wallpapersAsync(): Deferred<ApiResult<List<String>>>
|
||||
|
||||
@Streaming
|
||||
@GET
|
||||
suspend fun streamUrl(@Url url: String): ResponseBody
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.api.retrofit.interfaces
|
||||
|
||||
import com.huanchengfly.tieba.post.api.models.protos.frsPage.FrsPageResponse
|
||||
import com.huanchengfly.tieba.post.api.models.protos.hotThreadList.HotThreadListResponse
|
||||
import com.huanchengfly.tieba.post.api.models.protos.personalized.PersonalizedResponse
|
||||
import com.huanchengfly.tieba.post.api.models.protos.userLike.UserLikeResponse
|
||||
|
|
@ -23,4 +24,9 @@ interface OfficialProtobufTiebaApi {
|
|||
fun hotThreadListFlow(
|
||||
@Body body: MyMultipartBody,
|
||||
): Flow<HotThreadListResponse>
|
||||
|
||||
@POST("/c/f/frs/page?cmd=301001")
|
||||
fun frsPageFlow(
|
||||
@Body body: MyMultipartBody,
|
||||
): Flow<FrsPageResponse>
|
||||
}
|
||||
|
|
@ -4,6 +4,50 @@ package protos;
|
|||
|
||||
option java_package = "com.huanchengfly.tieba.post.api.models.protos";
|
||||
|
||||
message Page {
|
||||
int32 page_size = 1;
|
||||
int32 offset = 2;
|
||||
int32 current_page = 3;
|
||||
int32 total_count = 4;
|
||||
int32 total_page = 5;
|
||||
int32 has_more = 6;
|
||||
int32 has_prev = 7;
|
||||
int32 cur_good_id = 8;
|
||||
}
|
||||
|
||||
message FrsTabInfo {
|
||||
int32 tabId = 1;
|
||||
int32 tabType = 2;
|
||||
string tabName = 3;
|
||||
string tabUrl = 4;
|
||||
string tabGid = 5;
|
||||
string tabTitle = 6;
|
||||
int32 isGeneralTab = 7;
|
||||
string tabCode = 8;
|
||||
uint32 tabVersion = 9;
|
||||
int32 isDefault = 10;
|
||||
}
|
||||
|
||||
message DelThreadText {
|
||||
int32 text_id = 1;
|
||||
string text_info = 2;
|
||||
}
|
||||
|
||||
message Anti {
|
||||
string tbs = 1;
|
||||
int32 ifpost = 2;
|
||||
int32 ifposta = 3;
|
||||
int32 forbid_flag = 4;
|
||||
string forbid_info = 5;
|
||||
int32 block_stat = 6;
|
||||
int32 hide_stat = 7;
|
||||
int32 vcode_stat = 8;
|
||||
int32 days_tofree = 9;
|
||||
int32 has_chance = 10;
|
||||
int32 ifvoice = 11;
|
||||
repeated DelThreadText del_thread_text = 24;
|
||||
}
|
||||
|
||||
message AppPosInfo {
|
||||
int64 addr_timestamp = 6;
|
||||
bool ap_connected = 2;
|
||||
|
|
@ -23,15 +67,22 @@ message ProtoCommonResponse {
|
|||
}
|
||||
|
||||
message User {
|
||||
int32 is_login = 1;
|
||||
int64 id = 2;
|
||||
string name = 3;
|
||||
string nameShow = 4;
|
||||
string portrait = 5;
|
||||
int32 no_un = 6;
|
||||
int32 type = 7;
|
||||
int32 userhide = 9;
|
||||
int32 is_manager = 11;
|
||||
int32 is_bawu = 25;
|
||||
string bawu_type = 26;
|
||||
int32 has_concerned = 35;
|
||||
int32 gender = 42;
|
||||
PrivSets privSets = 45;
|
||||
string fansNickname = 57;
|
||||
int32 priv_thread = 92;
|
||||
int32 isDefaultAvatar = 106;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package protos;
|
||||
|
||||
option java_package = "com.huanchengfly.tieba.post.api.models.protos";
|
||||
|
||||
message FrsTabInfo {
|
||||
int32 tabId = 1;
|
||||
int32 tabType = 2;
|
||||
string tabName = 3;
|
||||
string tabUrl = 4;
|
||||
string tabGid = 5;
|
||||
string tabTitle = 6;
|
||||
int32 isGeneralTab = 7;
|
||||
string tabCode = 8;
|
||||
uint32 tabVersion = 9;
|
||||
int32 isDefault = 10;
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package protos;
|
||||
|
||||
option java_package = "com.huanchengfly.tieba.post.api.models.protos.frsPage";
|
||||
|
||||
import "Common.proto";
|
||||
import "CommonRequest.proto";
|
||||
import "ThreadInfo.proto";
|
||||
|
||||
message NavTabInfo {
|
||||
repeated FrsTabInfo tab = 1;
|
||||
repeated FrsTabInfo menu = 2;
|
||||
repeated FrsTabInfo head = 3;
|
||||
}
|
||||
|
||||
message Group {
|
||||
int32 hide_recommend_group = 1;
|
||||
int32 group_count = 2;
|
||||
}
|
||||
|
||||
message AdParam {
|
||||
int32 load_count = 1;
|
||||
int32 refresh_count = 2;
|
||||
string yoga_lib_version = 3;
|
||||
}
|
||||
|
||||
message Forum {
|
||||
int64 forum_id = 1;
|
||||
string level1_dir_name = 2;
|
||||
}
|
||||
|
||||
message RankInfo {
|
||||
int32 sign_count = 1;
|
||||
int32 sign_rank = 2;
|
||||
int32 member_count = 3;
|
||||
double dir_rate = 4;
|
||||
}
|
||||
|
||||
message SignForum {
|
||||
int32 is_on = 1;
|
||||
int32 is_filter = 2;
|
||||
optional Forum forum_info = 3;
|
||||
RankInfo current_rank_info = 4;
|
||||
}
|
||||
|
||||
message SignUser {
|
||||
int64 user_id = 1;
|
||||
int32 is_sign_in = 2;
|
||||
int32 user_sign_rank = 3;
|
||||
int32 sign_time = 4;
|
||||
int32 cont_sign_num = 5;
|
||||
int32 cout_total_sign_num = 6;
|
||||
int32 is_org_disabled = 7;
|
||||
int32 c_sign_num = 8;
|
||||
int32 hun_sign_num = 9;
|
||||
int32 total_resign_num = 10;
|
||||
int32 miss_sign_num = 11;
|
||||
}
|
||||
|
||||
message SignInfo {
|
||||
SignUser user_info = 1;
|
||||
SignForum forum_info = 2;
|
||||
}
|
||||
|
||||
message ForumInfo {
|
||||
int64 id = 1;
|
||||
string name = 2;
|
||||
string first_class = 3;
|
||||
string second_class = 4;
|
||||
int32 is_exists = 5;
|
||||
int32 is_like = 6;
|
||||
int32 user_level = 7;
|
||||
string level_name = 8;
|
||||
int32 member_num = 9;
|
||||
int32 thread_num = 10;
|
||||
int32 post_num = 11;
|
||||
int32 has_frs_star = 12;
|
||||
int32 cur_score = 13;
|
||||
int32 levelup_score = 14;
|
||||
SignInfo sign_in_info = 15;
|
||||
}
|
||||
|
||||
message FrsPageRequestData {
|
||||
string ad_context_list = 60;
|
||||
string ad_ext_params = 62;
|
||||
AdParam ad_param = 51;
|
||||
AppPosInfo app_pos = 50;
|
||||
int32 call_from = 56;
|
||||
int32 category_id = 44;
|
||||
int32 cid = 5;
|
||||
optional int32 class_id = 23;
|
||||
CommonRequest common = 39;
|
||||
int32 ctime = 17;
|
||||
int32 data_size = 18;
|
||||
int64 hot_thread_id = 58;
|
||||
int32 is_default_navtab = 59;
|
||||
int32 is_good = 4;
|
||||
int32 is_selection = 55;
|
||||
string kw = 1;
|
||||
uint64 last_click_tid = 48;
|
||||
string lastids = 40;
|
||||
int32 load_type = 49;
|
||||
int32 net_error = 19;
|
||||
string obj_locate = 52;
|
||||
string obj_source = 53;
|
||||
int32 pn = 15;
|
||||
int32 q_type = 14;
|
||||
int32 rn = 2;
|
||||
int32 rn_need = 3;
|
||||
double scr_dip = 13;
|
||||
int32 scr_h = 12;
|
||||
int32 scr_w = 11;
|
||||
int32 sort_type = 47;
|
||||
int32 st_param = 27;
|
||||
string st_type = 16;
|
||||
string up_schema = 61;
|
||||
int32 with_group = 8;
|
||||
string yuelaou_locate = 45;
|
||||
}
|
||||
|
||||
message FrsPageRequest {
|
||||
FrsPageRequestData data = 1;
|
||||
}
|
||||
|
||||
message FrsPageResponseData {
|
||||
User user = 1;
|
||||
ForumInfo forum = 2;
|
||||
Page page = 4;
|
||||
Anti anti = 5;
|
||||
Group group = 6;
|
||||
repeated ThreadInfo thread_list = 7;
|
||||
int32 is_new_url = 9;
|
||||
int32 time = 11;
|
||||
int32 ctime = 12;
|
||||
int64 logid = 13;
|
||||
int32 server_time = 14;
|
||||
repeated User user_list = 17;
|
||||
repeated FrsTabInfo frs_tab_info = 22;
|
||||
NavTabInfo nav_tab_info = 37;
|
||||
}
|
||||
|
||||
message FrsPageResponse {
|
||||
Error error = 1;
|
||||
FrsPageResponseData data = 2;
|
||||
}
|
||||
|
|
@ -7,7 +7,6 @@ option java_package = "com.huanchengfly.tieba.post.api.models.protos.hotThreadLi
|
|||
import "Common.proto";
|
||||
import "CommonRequest.proto";
|
||||
import "ThreadInfo.proto";
|
||||
import "Frs.proto";
|
||||
|
||||
message HotThreadListRequestData {
|
||||
CommonRequest common = 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue