Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.apollographql.apollo3.cache.normalized.api.*
import com.apollographql.apollo3.cache.normalized.fetchPolicy
import com.apollographql.apollo3.cache.normalized.normalizedCache
import com.apollographql.apollo3.network.http.DefaultHttpEngine
import com.dzen.campfire.api.API
import com.sup.dev.android.app.SupAndroid
import com.sup.dev.android.libs.image_loader.ImageLoader
import com.sup.dev.android.libs.image_loader.ImageLoaderRef
Expand All @@ -19,7 +20,7 @@ import sh.sit.schema.pagination.Pagination
object ApolloController {
@OptIn(ApolloExperimental::class)
val apolloClient: ApolloClient = ApolloClient.Builder()
.serverUrl("https://api.bonfire.moe")
.serverUrl(API.MELIOR_ROOT)
.httpEngine(DefaultHttpEngine(
OkHttpController.getClient(SupAndroid.appContext!!) {
addInterceptor(AuthInterceptor())
Expand Down
32 changes: 27 additions & 5 deletions Campfire/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,48 @@ apply plugin: 'com.mikepenz.aboutlibraries.plugin'
android {
compileSdk 35

def localPropertiesFile = rootProject.file('local.properties')
def localProperties = new Properties()
if (localPropertiesFile.exists()) {
localProperties.load(localPropertiesFile.newDataInputStream())
Copy link
Owner

Choose a reason for hiding this comment

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

Стрим надо надо закрыть. В котлине я делал так, в Groovy надо посмотреть:

val localProperties = Properties()
val localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
    localPropertiesFile.inputStream().use { localProperties.load(it) }
}

}

def posthogApiKey = localProperties.getProperty("POSTHOG_API_KEY", POSTHOG_API_KEY)
def host = localProperties.getProperty("HOST", HOST)
def serverPosthog = localProperties.getProperty("SERVER_POSTHOG", SERVER_POSTHOG)
def serverRoot = localProperties.getProperty("SERVER_ROOT", SERVER_ROOT)
def serverMelior = localProperties.getProperty("SERVER_MELIOR", SERVER_MELIOR)
def serverS3 = localProperties.getProperty("SERVER_S3", SERVER_S3)
def appId = localProperties.getProperty("APP_ID", APP_ID)
def appName = localProperties.getProperty("APP_NAME", APP_NAME)

defaultConfig {
minSdkVersion 23
targetSdk 35
versionCode 4_12_01
versionName "4.12.1"
applicationId "sh.sit.bonfire"
applicationId appId
Comment on lines -16 to +31
Copy link
Owner

Choose a reason for hiding this comment

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

Не совсем понимаю смысл делать кастомный ID приложения, если в дебаг сборке и так добавляется в конец .debug


buildConfigField "String", "POSTHOG_API_KEY", "\"$posthogApiKey\""

buildConfigField "String", "POSTHOG_API_KEY", "\"$POSTHOG_API_KEY\""
buildConfigField "String", "POSTHOG_HOST", "\"$POSTHOG_HOST\""
buildConfigField "String", "HOST", "\"$host\""
buildConfigField "String", "SERVER_POSTHOG", "\"$serverPosthog\""
buildConfigField "String", "SERVER_ROOT", "\"$serverRoot\""
buildConfigField "String", "SERVER_MELIOR", "\"$serverMelior\""
buildConfigField "String", "SERVER_S3", "\"$serverS3\""
}

buildTypes {
release {
manifestPlaceholders = [crashlyticsEnabled: false]
resValue "string", "app_name", appName
manifestPlaceholders = [crashlyticsEnabled: false, usesCleartextTraffic: false, host: HOST]
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
manifestPlaceholders = [crashlyticsEnabled: false]
resValue "string", "app_name", appName
manifestPlaceholders = [crashlyticsEnabled: false, usesCleartextTraffic: true, host: HOST]
applicationIdSuffix ".debug"
}
}
Expand Down
5 changes: 0 additions & 5 deletions Campfire/src/debug/AndroidManifest.xml

This file was deleted.

6 changes: 0 additions & 6 deletions Campfire/src/debug/res/xml/network_security_config.xml

This file was deleted.

5 changes: 3 additions & 2 deletions Campfire/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/CampfireSplash"
android:largeHeap="true">
android:largeHeap="true"
android:usesCleartextTraffic="${usesCleartextTraffic}">

<activity
android:name="com.dzen.campfire.app.AppActivity"
Expand All @@ -38,7 +39,7 @@
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https" />
<data android:host="bonfire.moe" />
<data android:host="${host}" />
<data android:pathPrefix="/r" />
</intent-filter>

Expand Down
7 changes: 6 additions & 1 deletion Campfire/src/main/java/com/dzen/campfire/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@ class App : Application() {

FirebaseApp.initializeApp(applicationContext)

API.SERV_ROOT = BuildConfig.SERVER_ROOT
API.MELIOR_ROOT = BuildConfig.SERVER_MELIOR
API.S3_ROOT = BuildConfig.SERVER_S3
API.DOMEN = "https://${BuildConfig.HOST}/r/"

SupAndroid.init(applicationContext, BuildConfig.APPLICATION_ID, AppActivity::class.java)
SupAndroid.imgErrorGone = ImageLoader.load(ApiResources.IMAGE_BACKGROUND_17).noHolder()
SupAndroid.imgErrorNetwork = ImageLoader.load(ApiResources.IMAGE_BACKGROUND_20).noHolder()
ApiRequestsSupporter.USE_ID_RESOURCES = true

PostHogAndroid.setup(this, PostHogAndroidConfig(
apiKey = BuildConfig.POSTHOG_API_KEY,
host = BuildConfig.POSTHOG_HOST,
host = BuildConfig.SERVER_POSTHOG,
).apply {
optOut = !canSendAnalytics()
})
Expand Down
1 change: 0 additions & 1 deletion Campfire/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<resources>
<string name="app_name" translatable="false">Bonfire</string>
</resources>
25 changes: 6 additions & 19 deletions CampfireApi/src/main/java/com/dzen/campfire/api/API.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class API(
const val PORT_SERV_JL_V1 = 7070
const val PORT_SERV_JL = 7071

const val S3_ROOT = "https://data.bonfire.moe/bonfire"
const val MELIOR_ROOT = "https://api.bonfire.moe"
const val SERV_ROOT = "https://cf2.bonfire.moe"
lateinit var SERV_ROOT: String
lateinit var MELIOR_ROOT: String
lateinit var S3_ROOT: String
const val TL_ROOT = "https://tlp.bonfire.moe"

const val DOMEN = "https://bonfire.moe/r/"
lateinit var DOMEN: String
const val DOMEN_DL = "bf://link/"
const val VERSION = "3.1"
const val SUPPORTED_VERSION = "2.0"
Expand Down Expand Up @@ -67,6 +67,7 @@ class API(
val LINK_CONF = Link("conf")
val LINK_FANDOM = Link("fandom")
val LINK_PROFILE_ID = Link("profileid")
val LINK_PROFILE_NAME = Link("profile")
val LINK_MODERATION = Link("moderation")
val LINK_STICKER = Link("sticker")
val LINK_STICKERS_PACK = Link("stickers")
Expand Down Expand Up @@ -125,7 +126,6 @@ class API(
const val LINK_TAG_PROFILE_NAME = "profile"
const val LINK_SHORT_PROFILE = "@"
const val LINK_SHORT_PROFILE_SECOND = "#"
const val LINK_PROFILE_NAME = "$DOMEN$LINK_TAG_PROFILE_NAME-"

const val ERROR_GONE = "ERROR_GONE"
const val ERROR_BAD_COMMENT = "ERROR_BAD_COMMENT"
Expand Down Expand Up @@ -831,6 +831,7 @@ class API(
const val HISTORY_PUBLICATION_TYPE_ADMIN_REMOVE_MEDIA = 29L
const val HISTORY_PUBLICATION_TYPE_SET_NSFW = 30L
const val HISTORY_PUBLICATION_TYPE_ADMIN_SET_NSFW = 31L
const val HISTORY_PUBLICATION_TYPE_PENDING = 32L

//
// Post
Expand Down Expand Up @@ -1115,20 +1116,6 @@ class API(
const val QUEST_PART_TYPE_ACTION = 3L
const val QUEST_PART_TYPE_UNKNOWN = 100L

//
// Reactions
//

val REACTIONS = arrayOf(
ApiResources.EMOJI_1,
ApiResources.EMOJI_2,
ApiResources.EMOJI_3,
ApiResources.EMOJI_4,
ApiResources.EMOJI_5,
ApiResources.EMOJI_6,
ApiResources.EMOJI_7
)

//
// Language
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,7 @@ object API_TRANSLATE {
var history_admin_close_no = 0L
var history_set_nsfw_true = 0L
var history_set_nsfw_false = 0L
var history_pending = 0L

var campfire_hello_annotation = 0L
var campfire_hello_1 = 0L
Expand Down
10 changes: 10 additions & 0 deletions CampfireApi/src/main/java/com/dzen/campfire/api/ApiResources.kt
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,14 @@ object ApiResources {
QUEST_NEW_YEAR_9,
QUEST_NEW_YEAR_10
)

val REACTIONS = arrayOf(
ApiResources.EMOJI_1,
ApiResources.EMOJI_2,
ApiResources.EMOJI_3,
ApiResources.EMOJI_4,
ApiResources.EMOJI_5,
ApiResources.EMOJI_6,
ApiResources.EMOJI_7
Comment on lines +476 to +482
Copy link
Owner

Choose a reason for hiding this comment

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

ApiResources. можно вырезать

)
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ abstract class History : JsonParsable, ImageHolder {
API.HISTORY_PUBLICATION_TYPE_ADMIN_REMOVE_MEDIA -> HistoryAdminRemoveMedia()
API.HISTORY_PUBLICATION_TYPE_SET_NSFW -> HistorySetNsfw()
API.HISTORY_PUBLICATION_TYPE_ADMIN_SET_NSFW -> HistoryAdminSetNsfw()
API.HISTORY_PUBLICATION_TYPE_PENDING -> HistoryPending()
else -> HistoryUnknown()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.dzen.campfire.api.models.publications.history

import com.dzen.campfire.api.API
import com.sup.dev.java.libs.json.Json

class HistoryPending : History {
var pendingTime = 0L

override fun getType() = API.HISTORY_PUBLICATION_TYPE_PENDING

override fun json(inp: Boolean, json: Json): Json {
pendingTime = json.m(inp, "pendingTime", pendingTime)
return super.json(inp, json)
}

constructor()

constructor(
userId: Long,
userImageId: Long,
userName: String,
pendingTime: Long
) : super(userId, userImageId, userName, "") {
this.pendingTime = pendingTime
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dzen.campfire.api.requests.publications

import com.dzen.campfire.api.models.images.ImageHolderReceiver
import com.dzen.campfire.api.models.publications.PublicationReport
import com.dzen.campfire.api.tools.client.Request
import com.sup.dev.java.libs.json.Json
Expand Down Expand Up @@ -42,6 +43,11 @@ open class RPublicationsReportsGetAll(
reports = json.m(inp, "reports", reports, Array<PublicationReport>::class)
}

override fun fillImageRefs(receiver: ImageHolderReceiver) {
for (report in reports) {
report.account.fillImageRefs(receiver)
}
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import com.dzen.campfire.api.API
import com.dzen.campfire.api.ApiResources
import com.dzen.campfire.api.models.publications.Publication
import com.dzen.campfire.api.requests.publications.RPublicationsReactionAdd
Expand Down Expand Up @@ -55,9 +54,9 @@ fun PublicationReactions(
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = modifier,
) {
for (reactionIndex in API.REACTIONS.indices.map { it.toLong() }) {
for (reactionIndex in ApiResources.REACTIONS.indices.map { it.toLong() }) {
val reactionCount = data.counts[reactionIndex] ?: 0
val image = API.REACTIONS.getOrNull(reactionIndex.toInt()) ?: ApiResources.EMOJI_5
val image = ApiResources.REACTIONS.getOrNull(reactionIndex.toInt()) ?: ApiResources.EMOJI_5

val windowOffset = remember { mutableStateOf<Offset?>(null) }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sayzen.campfiresdk.compose.publication.comment

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.material3.MaterialTheme
Expand All @@ -16,6 +17,7 @@ import com.sayzen.campfiresdk.R
import com.sayzen.campfiresdk.screens.account.profile.SProfile
import com.sayzen.campfiresdk.screens.fandoms.view.SFandom
import com.sup.dev.android.libs.screens.navigator.Navigator
import com.sup.dev.android.tools.ToolsToast
import com.sup.dev.java.tools.ToolsDate

@Composable
Expand Down Expand Up @@ -55,7 +57,11 @@ internal fun CommentHeader(
style = MaterialTheme.typography.bodyLarge,
overflow = TextOverflow.Ellipsis,
softWrap = false,
modifier = Modifier.alpha(0.6f)
modifier = Modifier
.alpha(0.6f)
.clickable {
ToolsToast.show(ToolsDate.dateToStringFull(comment.dateCreate))
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ internal fun PostHeader(post: PublicationPost) {
modifier = Modifier
.then(if (overflowsWidth) Modifier.weight(1f, fill = false) else Modifier)
.clickable {
ToolsToast.show(ToolsDate.dateToString(creationTimestamp))
ToolsToast.show(ToolsDate.dateToStringFull(creationTimestamp))
},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private fun UserActivityCountdown(stopAt: Long) {
val remaining = stopAt - currentTime.longValue

Text(
text = ToolsDate.dayTimeToString_Ms_HH_MM_SS(remaining),
text = ToolsDate.timeToString(remaining),
style = MaterialTheme.typography.bodyMedium,
softWrap = false,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.widget.FrameLayout
import android.widget.LinearLayout
import com.dzen.campfire.api.API
import com.dzen.campfire.api.API_TRANSLATE
import com.dzen.campfire.api.ApiResources
import com.dzen.campfire.api.models.publications.PublicationComment
import com.dzen.campfire.api.requests.publications.RPublicationsReactionAdd
import com.dzen.campfire.api.requests.publications.RPublicationsReactionRemove
Expand Down Expand Up @@ -95,12 +96,12 @@ object ControllerComment {


val p = ToolsView.dpToPx(4).toInt()
for (i in API.REACTIONS.indices) {
for (i in ApiResources.REACTIONS.indices) {
val v: ViewIcon = ToolsView.inflate(vMenuReactionsLinear, R.layout.z_icon_18)
v.setPadding(p, p, p, p)
v.setOnClickListener { sendReaction(publication, i.toLong()); w?.hide(); }
vMenuReactionsLinear.addView(v)
ImageLoader.load(API.REACTIONS[i]).into(v)
ImageLoader.load(ApiResources.REACTIONS[i]).into(v)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ object ControllerEffects {
.setOnEnter(t(API_TRANSLATE.app_choose)) { _, date ->
SplashChooseTime()
.setOnEnter(t(API_TRANSLATE.app_choose)) { _, h, m ->
val endDate = ToolsDate.getStartOfDay_GlobalTimeZone(date) + (h * 60L * 60 * 1000) + (m * 60L * 1000)
val endDate = ToolsDate.getStartOfDay(date) + (h * 60L * 60 * 1000) + (m * 60L * 1000)
if (endDate < System.currentTimeMillis()) {
ToolsToast.show(t(API_TRANSLATE.effect_error_time))
return@setOnEnter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ object ControllerFandoms {
.setOnCancel(t(API_TRANSLATE.app_cancel))
.setMin(API.MODERATION_COMMENT_MIN_L)
.setMax(API.MODERATION_COMMENT_MAX_L)
.addChecker(t(API_TRANSLATE.error_use_english)) { ToolsText.isOnly(it, API.ENGLISH) }
.setOnEnter(t(API_TRANSLATE.app_change)) { w, comment ->
ApiRequestsSupporter.executeEnabled(w, RFandomsAdminChangeCategory(xFandom.getId(), c.index, comment)) {
EventBus.post(EventFandomCategoryChanged(xFandom.getId(), c.index))
Expand Down Expand Up @@ -180,7 +179,6 @@ object ControllerFandoms {
.setOnCancel(t(API_TRANSLATE.app_cancel))
.setMin(API.MODERATION_COMMENT_MIN_L)
.setMax(API.MODERATION_COMMENT_MAX_L)
.addChecker(t(API_TRANSLATE.error_use_english)) { ToolsText.isOnly(it, API.ENGLISH) }
.setOnEnter(t(API_TRANSLATE.app_remove)) { _, comment ->
ApiRequestsSupporter.executeEnabledConfirm(t(API_TRANSLATE.fandom_remove_confirm), t(API_TRANSLATE.app_remove), RFandomsAdminRemove(xFandom.getId(), comment)) {
EventBus.post(EventFandomRemove(xFandom.getId()))
Expand Down Expand Up @@ -208,7 +206,6 @@ object ControllerFandoms {
.setMin_2(API.MODERATION_COMMENT_MIN_L)
.setMax_2(API.MODERATION_COMMENT_MAX_L)
.setHint_2(t(API_TRANSLATE.comments_hint))
.addChecker_2(t(API_TRANSLATE.error_use_english)) { ToolsText.isOnly(it, API.ENGLISH) }
.setOnEnter(t(API_TRANSLATE.app_rename)) { _, name, comment ->
ApiRequestsSupporter.executeEnabledConfirm(t(API_TRANSLATE.fandoms_menu_rename_confirm), t(API_TRANSLATE.fandoms_menu_rename), RFandomsAdminChangeName(xFandom.getId(), name, comment)) {
EventBus.post(EventFandomChanged(xFandom.getId(), name))
Expand Down
Loading
Loading