Skip to content

Commit

Permalink
5
Browse files Browse the repository at this point in the history
5
  • Loading branch information
umerov1999 committed Jan 8, 2023
1 parent 46164de commit ba34565
Show file tree
Hide file tree
Showing 251 changed files with 2,032 additions and 1,759 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.util.*

object Constants {
const val API_VERSION = "5.131"
const val DATABASE_FENRIR_VERSION = 25
const val DATABASE_FENRIR_VERSION = 26
const val DATABASE_TEMPORARY_VERSION = 5
const val EXPORT_SETTINGS_FORMAT = 1
const val forceDeveloperMode = BuildConfig.FORCE_DEVELOPER_MODE
Expand Down
13 changes: 8 additions & 5 deletions app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,13 @@ inline fun <reified T : Parcelable> Parcel.readTypedObjectCompat(c: Parcelable.C
}
}

inline fun <reified T : Parcelable> Parcel.writeTypedObjectCompat(`val`: T?, parcelableFlags: Int) {
if (`val` != null) {
inline fun <reified T : Parcelable> Parcel.writeTypedObjectCompat(
parcel: T?,
parcelableFlags: Int
) {
if (parcel != null) {
writeInt(1)
`val`.writeToParcel(this, parcelableFlags)
parcel.writeToParcel(this, parcelableFlags)
} else {
writeInt(0)
}
Expand Down Expand Up @@ -507,9 +510,9 @@ inline fun <reified T : Parcelable> Intent.getParcelableArrayListExtraCompat(key
}

fun Parcel.putBoolean(value: Boolean) {
writeInt(if (value) 1 else 0)
writeByte(if (value) 1 else 0)
}

fun Parcel.getBoolean(): Boolean {
return readInt() != 0
return readByte() != 0.toByte()
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class AudioPlaylistDtoAdapter : AbsAdapter<VKApiAudioPlaylist>("VKApiAudioPlayli
continue
}
if (isFirst) isFirst = false else build.append(", ")
val `val` = optString(i.asJsonObject, "name")
if (`val` != null) build.append(`val`)
val value = optString(i.asJsonObject, "name")
if (value != null) build.append(value)
}
album.genre = build.toString()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ class PostDtoAdapter : AbsAdapter<VKApiPost>("VKApiPost") {
kJson.decodeFromJsonElement(VKApiAttachments.serializer(), it)
}
}
if (hasObject(root, "donut")) {
val donut = root.getAsJsonObject("donut")
dto.is_donut = optBoolean(donut, "is_donut")
} else {
dto.is_donut = false
}
dto.can_edit = optBoolean(root, "can_edit")
dto.is_favorite = optBoolean(root, "is_favorite")
dto.signer_id = optInt(root, "signer_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class UploadApi internal constructor(private val provider: IUploadRestProvider)
override fun uploadAudioRx(
server: String,
filename: String?,
`is`: InputStream,
inputStream: InputStream,
listener: PercentagePublisher?
): Single<UploadAudioDto> {
val body = ProgressRequestBody(
`is`, wrapPercentageListener(listener),
inputStream, wrapPercentageListener(listener),
"*/*".toMediaTypeOrNull()
)
val part: MultipartBody.Part = MultipartBody.Part.createFormData("file", filename, body)
Expand All @@ -53,11 +53,11 @@ class UploadApi internal constructor(private val provider: IUploadRestProvider)
override fun remotePlayAudioRx(
server: String,
filename: String?,
`is`: InputStream,
inputStream: InputStream,
listener: PercentagePublisher?
): Single<BaseResponse<Int>> {
val body = ProgressRequestBody(
`is`, wrapPercentageListener(listener),
inputStream, wrapPercentageListener(listener),
"*/*".toMediaTypeOrNull()
)
val part: MultipartBody.Part = MultipartBody.Part.createFormData("audio", filename, body)
Expand All @@ -67,12 +67,12 @@ class UploadApi internal constructor(private val provider: IUploadRestProvider)
override fun uploadStoryRx(
server: String,
filename: String?,
`is`: InputStream,
inputStream: InputStream,
listener: PercentagePublisher?,
isVideo: Boolean
): Single<BaseResponse<UploadStoryDto>> {
val body = ProgressRequestBody(
`is`, wrapPercentageListener(listener),
inputStream, wrapPercentageListener(listener),
"*/*".toMediaTypeOrNull()
)
val part: MultipartBody.Part =
Expand Down Expand Up @@ -142,12 +142,12 @@ class UploadApi internal constructor(private val provider: IUploadRestProvider)

override fun uploadPhotoToMessageRx(
server: String,
`is`: InputStream,
inputStream: InputStream,
listener: PercentagePublisher?
): Single<UploadPhotoToMessageDto> {
val body =
ProgressRequestBody(
`is`, wrapPercentageListener(listener),
inputStream, wrapPercentageListener(listener),
"image/*".toMediaTypeOrNull()
)
val part: MultipartBody.Part = MultipartBody.Part.createFormData("photo", "photo.jpg", body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ internal class WallApi(accountId: Int, provider: IServiceProvider) : AbsApi(acco
groupId: Int?,
markAsAds: Boolean?
): Single<RepostReponse> {
val `object` = "wall" + postOwnerId + "_" + postId
val obj = "wall" + postOwnerId + "_" + postId
return provideService(IWallService(), TokenType.USER)
.flatMap { service ->
service.repost(`object`, message, groupId, integerFromBoolean(markAsAds))
service.repost(obj, message, groupId, integerFromBoolean(markAsAds))
.map(extractResponseWithErrorHandling())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ interface IUploadApi {
fun uploadAudioRx(
server: String,
filename: String?,
`is`: InputStream,
inputStream: InputStream,
listener: PercentagePublisher?
): Single<UploadAudioDto>

fun remotePlayAudioRx(
server: String,
filename: String?,
`is`: InputStream,
inputStream: InputStream,
listener: PercentagePublisher?
): Single<BaseResponse<Int>>

fun uploadStoryRx(
server: String,
filename: String?,
`is`: InputStream,
inputStream: InputStream,
listener: PercentagePublisher?,
isVideo: Boolean
): Single<BaseResponse<UploadStoryDto>>
Expand Down Expand Up @@ -63,7 +63,7 @@ interface IUploadApi {

fun uploadPhotoToMessageRx(
server: String,
`is`: InputStream,
inputStream: InputStream,
listener: PercentagePublisher?
): Single<UploadPhotoToMessageDto>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class VKApiPost : VKApiAttachment, Commentable, Likeable, Copyable {
*/
var is_pinned = false

var is_donut = false

/**
* List of history of the reposts.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class ResolveDomailResponse : Parcelable {

@Suppress("UNUSED")
constructor()
internal constructor(`in`: Parcel) {
type = `in`.readString()
object_id = `in`.readString()
internal constructor(parcel: Parcel) {
type = parcel.readString()
object_id = parcel.readString()
}

fun parse(jsonObject: JSONObject): ResolveDomailResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class VKApiAudioUploadServer : Parcelable, UploadServer {
this.url = url
}

internal constructor(`in`: Parcel) {
url = `in`.readString()
internal constructor(parcel: Parcel) {
url = parcel.readString()
}

override fun describeContents(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class VKApiChatPhotoUploadServer : Parcelable, UploadServer {

@Suppress("UNUSED")
constructor()
internal constructor(`in`: Parcel) {
url = `in`.readString()
internal constructor(parcel: Parcel) {
url = parcel.readString()
}

override fun describeContents(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class VKApiDocsUploadServer : UploadServer, Parcelable {

@Suppress("UNUSED")
constructor()
internal constructor(`in`: Parcel) {
url = `in`.readString()
internal constructor(parcel: Parcel) {
url = parcel.readString()
}

override fun describeContents(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class VKApiOwnerPhotoUploadServer : Parcelable, UploadServer {

@Suppress("UNUSED")
constructor()
internal constructor(`in`: Parcel) {
url = `in`.readString()
internal constructor(parcel: Parcel) {
url = parcel.readString()
}

override fun describeContents(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class VKApiPhotoMessageServer : Parcelable, UploadServer {

@Suppress("UNUSED")
constructor()
internal constructor(`in`: Parcel) {
url = `in`.readString()
album_id = `in`.readInt()
user_id = `in`.readInt()
internal constructor(parcel: Parcel) {
url = parcel.readString()
album_id = parcel.readInt()
user_id = parcel.readInt()
}

override fun describeContents(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class VKApiStoryUploadServer : Parcelable, UploadServer {
@Suppress("UNUSED")
constructor()

internal constructor(`in`: Parcel) {
url = `in`.readString()
internal constructor(parcel: Parcel) {
url = parcel.readString()
}

override fun describeContents(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class VKApiUploadServer : Parcelable, UploadServer {
*/
var user_id = 0

internal constructor(`in`: Parcel) {
url = `in`.readString()
album_id = `in`.readInt()
user_id = `in`.readInt()
internal constructor(parcel: Parcel) {
url = parcel.readString()
album_id = parcel.readInt()
user_id = parcel.readInt()
}

@Suppress("UNUSED")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class VKApiVideosUploadServer : UploadServer, Parcelable {

@Suppress("UNUSED")
constructor()
internal constructor(`in`: Parcel) {
url = `in`.readString()
internal constructor(parcel: Parcel) {
url = parcel.readString()
}

override fun describeContents(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class VKApiWallUploadServer : Parcelable, UploadServer {

@Suppress("UNUSED")
constructor()
internal constructor(`in`: Parcel) {
url = `in`.readString()
album_id = `in`.readInt()
user_id = `in`.readInt()
internal constructor(parcel: Parcel) {
url = parcel.readString()
album_id = parcel.readInt()
user_id = parcel.readInt()
}

override fun describeContents(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ class ExchangeMessage : Parcelable {
keyLocationPolicy = builder.keyLocationPolicy
}

internal constructor(`in`: Parcel) {
version = `in`.readInt()
sessionId = `in`.readLong()
publicKey = `in`.readString()
aesKey = `in`.readString()
@SessionState val s = `in`.readInt()
internal constructor(parcel: Parcel) {
version = parcel.readInt()
sessionId = parcel.readLong()
publicKey = parcel.readString()
aesKey = parcel.readString()
@SessionState val s = parcel.readInt()
senderSessionState = s
errorCode = `in`.readInt()
@KeyLocationPolicy val klp = readObjectInteger(`in`)
errorCode = parcel.readInt()
@KeyLocationPolicy val klp = readObjectInteger(parcel)
keyLocationPolicy = klp
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ class DBHelper private constructor(context: Context, aid: Int) :
" [" + PostsColumns.CREATED_BY + "] INTEGER, " +
" [" + PostsColumns.CAN_PIN + "] BOOLEAN, " +
" [" + PostsColumns.IS_PINNED + "] BOOLEAN, " +
" [" + PostsColumns.IS_DONUT + "] BOOLEAN, " +
" [" + PostsColumns.DELETED + "] BOOLEAN, " +
" [" + PostsColumns.POST_SOURCE + "] BLOB, " +
" [" + PostsColumns.COPYRIGHT_BLOB + "] BLOB, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class DatabaseIdRange : Parcelable {
this.last = last
}

internal constructor(`in`: Parcel) {
first = `in`.readInt()
last = `in`.readInt()
internal constructor(parcel: Parcel) {
first = parcel.readInt()
last = parcel.readInt()
}

override fun toString(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,8 @@ class FenrirContentProvider : ContentProvider() {
PostsColumns.FULL_CAN_EDIT
sPostsProjectionMap[PostsColumns.IS_FAVORITE] =
PostsColumns.FULL_IS_FAVORITE
sPostsProjectionMap[PostsColumns.IS_DONUT] =
PostsColumns.FULL_IS_DONUT
sPostsProjectionMap[PostsColumns.REPOSTS_COUNT] =
PostsColumns.FULL_REPOSTS_COUNT
sPostsProjectionMap[PostsColumns.USER_REPOSTED] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ object PostsColumns : BaseColumns {
const val SIGNED_ID = "signer_id"
const val CREATED_BY = "created_by"
const val CAN_PIN = "can_pin"
const val IS_DONUT = "is_donut"
const val IS_PINNED = "is_pinned"
const val IS_FAVORITE = "is_favorite"
const val DELETED = "deleted"
Expand Down Expand Up @@ -61,4 +62,5 @@ object PostsColumns : BaseColumns {
const val FULL_POST_SOURCE = "$TABLENAME.$POST_SOURCE"
const val FULL_VIEWS = "$TABLENAME.$VIEWS"
const val FULL_IS_FAVORITE = "$TABLENAME.$IS_FAVORITE"
const val FULL_IS_DONUT = "$TABLENAME.$IS_DONUT"
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ internal class LocalMediaStorage(mRepositoryContext: AppStorages) : AbsStorage(m
return try {
mediaMetadataRetriever.setDataSource(context, oo)
val cover = mediaMetadataRetriever.embeddedPicture ?: return null
val `is`: InputStream = ByteArrayInputStream(cover)
var bitmap = BitmapFactory.decodeStream(`is`)
val inputStream: InputStream = ByteArrayInputStream(cover)
var bitmap = BitmapFactory.decodeStream(inputStream)
if (bitmap != null) {
bitmap = Bitmap.createScaledBitmap(bitmap, 256, 256, false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ internal class WallStorage(base: AppStorages) : AbsStorage(base), IWallStorage {
.setViews(cursor.getInt(PostsColumns.VIEWS))
.setCanEdit(cursor.getBoolean(PostsColumns.CAN_EDIT))
.setFavorite(cursor.getBoolean(PostsColumns.IS_FAVORITE))
.setIsDonut(cursor.getBoolean(PostsColumns.IS_DONUT))
val postSourceText =
cursor.getBlob(PostsColumns.POST_SOURCE)
if (postSourceText.nonNullNoEmpty()) {
Expand Down Expand Up @@ -441,6 +442,7 @@ internal class WallStorage(base: AppStorages) : AbsStorage(base), IWallStorage {
cv.put(PostsColumns.CREATED_BY, dbo.createdBy)
cv.put(PostsColumns.CAN_PIN, dbo.isCanPin)
cv.put(PostsColumns.IS_PINNED, dbo.isPinned)
cv.put(PostsColumns.IS_DONUT, dbo.isDonut)
cv.put(PostsColumns.DELETED, dbo.isDeleted)
val attachmentsCount = safeCountOf(dbo.getAttachments())
val copiesCount = safeCountOf(dbo.copyHierarchy)
Expand Down
Loading

0 comments on commit ba34565

Please sign in to comment.