Skip to content

Commit

Permalink
EOF-10
Browse files Browse the repository at this point in the history
EOF-10
  • Loading branch information
umerov1999 committed Apr 2, 2023
1 parent 5bcb6d3 commit 5fec70a
Show file tree
Hide file tree
Showing 111 changed files with 1,872 additions and 947 deletions.
4 changes: 2 additions & 2 deletions app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ object Constants {
const val FILE_PROVIDER_AUTHORITY: String = BuildConfig.APPLICATION_ID + ".file_provider"
const val VK_ANDROID_APP_VERSION_NAME = "8.15"
const val VK_ANDROID_APP_VERSION_CODE = "15271"
const val KATE_APP_VERSION_NAME = "97.1 lite"
const val KATE_APP_VERSION_CODE = "532"
const val KATE_APP_VERSION_NAME = "99 lite"
const val KATE_APP_VERSION_CODE = "535"
const val API_ID: Int = BuildConfig.VK_API_APP_ID
const val SECRET: String = BuildConfig.VK_CLIENT_SECRET
const val PHOTOS_PATH = "DCIM/Fenrir"
Expand Down
268 changes: 149 additions & 119 deletions app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -791,133 +791,161 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect
if (intent == null) {
return false
}
if (ACTION_OPEN_WALL == intent.action) {
val owner_id = intent.extras!!.getLong(Extra.OWNER_ID)
PlaceFactory.getOwnerWallPlace(mAccountId, owner_id, null).tryOpenWith(this)
return true
}
if (ACTION_SWITH_ACCOUNT == intent.action) {
val newAccountId = intent.extras!!.getLong(Extra.ACCOUNT_ID)
if (Settings.get().accounts().current != newAccountId) {
Settings.get()
.accounts().current = newAccountId
mAccountId = newAccountId
Logger.d(TAG, "handleIntent, extras: ${intent.extras}, action: ${intent.action}")
when {
ACTION_OPEN_WALL == intent.action -> {
val owner_id = intent.extras!!.getLong(Extra.OWNER_ID)
PlaceFactory.getOwnerWallPlace(mAccountId, owner_id, null).tryOpenWith(this)
return true
}
intent.action = ACTION_MAIN
}
if (ACTION_SHORTCUT_WALL == intent.action) {
val newAccountId = intent.extras!!.getLong(Extra.ACCOUNT_ID)
val ownerId = intent.extras!!.getLong(Extra.OWNER_ID)
if (Settings.get().accounts().current != newAccountId) {
Settings.get()
.accounts().current = newAccountId
mAccountId = newAccountId

ACTION_SWITCH_ACCOUNT == intent.action -> {
val newAccountId = intent.extras!!.getLong(Extra.ACCOUNT_ID)
if (Settings.get().accounts().current != newAccountId) {
if (!Settings.get().accounts().registered.contains(newAccountId)) {
createCustomToast(this).showToastError(R.string.account_not_registered)
} else {
Settings.get()
.accounts().current = newAccountId
mAccountId = newAccountId
}
}
intent.action = ACTION_MAIN
}
clearBackStack()
openPlace(PlaceFactory.getOwnerWallPlace(newAccountId, ownerId, null))
return true
}
val extras = intent.extras
val action = intent.action
Logger.d(TAG, "handleIntent, extras: $extras, action: $action")
if (Intent.ACTION_SEND_MULTIPLE == action) {
val mime = intent.type
if (getMainActivityTransform() == MainActivityTransforms.MAIN && extras != null && mime.nonNullNoEmpty() && isMimeAudio(
mime
) && extras.containsKey(Intent.EXTRA_STREAM)
) {
val uris = intent.getParcelableArrayListExtraCompat<Uri>(Intent.EXTRA_STREAM)
if (uris.nonNullNoEmpty()) {
val playlist = ArrayList<Audio>(
uris.size
)
for (i in uris) {
val track = UploadUtils.findFileName(this, i) ?: return false
var TrackName = track.replace(".mp3", "")
var Artist = ""
val arr = TrackName.split(Regex(" - ")).toTypedArray()
if (arr.size > 1) {
Artist = arr[0]
TrackName = TrackName.replace("$Artist - ", "")
}
val tmp = Audio().setIsLocal().setThumb_image_big(
"share_$i"
).setThumb_image_little("share_$i").setUrl(i.toString())
.setOwnerId(mAccountId).setArtist(Artist).setTitle(TrackName)
.setId(i.toString().hashCode())
playlist.add(tmp)

ACTION_SHORTCUT_WALL == intent.action -> {
var newAccountId = intent.extras!!.getLong(Extra.ACCOUNT_ID)
val prefsAid = Settings.get()
.accounts()
.current
val ownerId = intent.extras!!.getLong(Extra.OWNER_ID)
if (prefsAid != newAccountId) {
if (!Settings.get().accounts().registered.contains(newAccountId)) {
newAccountId = prefsAid
createCustomToast(this).showToastError(R.string.account_not_registered)
} else {
Settings.get()
.accounts().current = newAccountId
mAccountId = newAccountId
}
intent.removeExtra(Intent.EXTRA_STREAM)
startForPlayList(this, playlist, 0, false)
PlaceFactory.getPlayerPlace(mAccountId).tryOpenWith(this)
}
clearBackStack()
openPlace(PlaceFactory.getOwnerWallPlace(newAccountId, ownerId, null))
return true
}
}
if (extras != null && checkInputExist(this)) {
mCurrentFrontSection = AbsNavigationView.SECTION_ITEM_DIALOGS
openNavigationPage(AbsNavigationView.SECTION_ITEM_DIALOGS, false)
return true
}
if (ACTION_SEND_ATTACHMENTS == action) {
mCurrentFrontSection = AbsNavigationView.SECTION_ITEM_DIALOGS
openNavigationPage(AbsNavigationView.SECTION_ITEM_DIALOGS, false)
return true
}
if (ACTION_OPEN_PLACE == action) {
val place: Place = intent.getParcelableExtraCompat(Extra.PLACE) ?: return false
openPlace(place)
return if (place.type == Place.CHAT) {
Settings.get().ui().swipes_chat_mode != SwipesChatMode.SLIDR || Settings.get()

ACTION_CHAT_FROM_SHORTCUT == intent.action -> {
var aid = intent.extras!!.getLong(Extra.ACCOUNT_ID)
val prefsAid = Settings.get()
.accounts()
.current
if (prefsAid != aid) {
if (!Settings.get().accounts().registered.contains(aid)) {
aid = prefsAid
createCustomToast(this).showToastError(R.string.account_not_registered)
} else {
Settings.get()
.accounts().current = aid
}
}
val peerId = intent.extras!!.getLong(Extra.PEER_ID)
val title = intent.getStringExtra(Extra.TITLE)
val imgUrl = intent.getStringExtra(Extra.IMAGE)
val peer = Peer(peerId).setTitle(title).setAvaUrl(imgUrl)
PlaceFactory.getChatPlace(aid, aid, peer).tryOpenWith(this)
return Settings.get()
.ui().swipes_chat_mode != SwipesChatMode.SLIDR || Settings.get()
.ui().swipes_chat_mode == SwipesChatMode.DISABLED
} else true
}
if (ACTION_OPEN_AUDIO_PLAYER == action) {
openPlace(PlaceFactory.getPlayerPlace(mAccountId))
return false
}
if (ACTION_CHAT_FROM_SHORTCUT == action) {
val aid = intent.extras!!.getLong(Extra.ACCOUNT_ID)
val prefsAid = Settings.get()
.accounts()
.current
if (prefsAid != aid) {
Settings.get()
.accounts().current = aid
}
val peerId = intent.extras!!.getLong(Extra.PEER_ID)
val title = intent.getStringExtra(Extra.TITLE)
val imgUrl = intent.getStringExtra(Extra.IMAGE)
val peer = Peer(peerId).setTitle(title).setAvaUrl(imgUrl)
PlaceFactory.getChatPlace(aid, aid, peer).tryOpenWith(this)
return Settings.get().ui().swipes_chat_mode != SwipesChatMode.SLIDR || Settings.get()
.ui().swipes_chat_mode == SwipesChatMode.DISABLED
}
if (Intent.ACTION_VIEW == action) {
val data = intent.data
val mime = intent.type ?: ""
if (getMainActivityTransform() == MainActivityTransforms.MAIN && mime.nonNullNoEmpty() && isMimeAudio(
mime
)
) {
val track = UploadUtils.findFileName(this, data) ?: return false
var TrackName = track.replace(".mp3", "")
var Artist = ""
val arr = TrackName.split(Regex(" - ")).toTypedArray()
if (arr.size > 1) {
Artist = arr[0]
TrackName = TrackName.replace("$Artist - ", "")

Intent.ACTION_SEND_MULTIPLE == intent.action -> {
val mime = intent.type
if (getMainActivityTransform() == MainActivityTransforms.MAIN && intent.extras != null && mime.nonNullNoEmpty() && isMimeAudio(
mime
) && intent.extras?.containsKey(Intent.EXTRA_STREAM) == true
) {
val uris = intent.getParcelableArrayListExtraCompat<Uri>(Intent.EXTRA_STREAM)
if (uris.nonNullNoEmpty()) {
val playlist = ArrayList<Audio>(
uris.size
)
for (i in uris) {
val track = UploadUtils.findFileName(this, i) ?: return false
var TrackName = track.replace(".mp3", "")
var Artist = ""
val arr = TrackName.split(Regex(" - ")).toTypedArray()
if (arr.size > 1) {
Artist = arr[0]
TrackName = TrackName.replace("$Artist - ", "")
}
val tmp = Audio().setIsLocal().setThumb_image_big(
"share_$i"
).setThumb_image_little("share_$i").setUrl(i.toString())
.setOwnerId(mAccountId).setArtist(Artist).setTitle(TrackName)
.setId(i.toString().hashCode())
playlist.add(tmp)
}
intent.removeExtra(Intent.EXTRA_STREAM)
startForPlayList(this, playlist, 0, false)
PlaceFactory.getPlayerPlace(mAccountId).tryOpenWith(this)
}
}
val tmp =
Audio().setIsLocal().setThumb_image_big("share_$data").setThumb_image_little(
"share_$data"
).setUrl(data.toString()).setOwnerId(mAccountId).setArtist(Artist)
.setTitle(TrackName).setId(data.toString().hashCode())
startForPlayList(this, ArrayList(listOf(tmp)), 0, false)
PlaceFactory.getPlayerPlace(mAccountId).tryOpenWith(this)
}

ACTION_SEND_ATTACHMENTS == intent.action -> {
mCurrentFrontSection = AbsNavigationView.SECTION_ITEM_DIALOGS
openNavigationPage(AbsNavigationView.SECTION_ITEM_DIALOGS, false)
return true
}

ACTION_OPEN_PLACE == intent.action -> {
val place: Place = intent.getParcelableExtraCompat(Extra.PLACE) ?: return false
openPlace(place)
return if (place.type == Place.CHAT) {
Settings.get().ui().swipes_chat_mode != SwipesChatMode.SLIDR || Settings.get()
.ui().swipes_chat_mode == SwipesChatMode.DISABLED
} else true
}

ACTION_OPEN_AUDIO_PLAYER == intent.action -> {
openPlace(PlaceFactory.getPlayerPlace(mAccountId))
return false
}
LinkHelper.openUrl(this, mAccountId, data.toString(), isMain)
return true

Intent.ACTION_VIEW == intent.action -> {
val data = intent.data
val mime = intent.type ?: ""
if (getMainActivityTransform() == MainActivityTransforms.MAIN && mime.nonNullNoEmpty() && isMimeAudio(
mime
)
) {
val track = UploadUtils.findFileName(this, data) ?: return false
var TrackName = track.replace(".mp3", "")
var Artist = ""
val arr = TrackName.split(Regex(" - ")).toTypedArray()
if (arr.size > 1) {
Artist = arr[0]
TrackName = TrackName.replace("$Artist - ", "")
}
val tmp =
Audio().setIsLocal().setThumb_image_big("share_$data")
.setThumb_image_little(
"share_$data"
).setUrl(data.toString()).setOwnerId(mAccountId).setArtist(Artist)
.setTitle(TrackName).setId(data.toString().hashCode())
startForPlayList(this, ArrayList(listOf(tmp)), 0, false)
PlaceFactory.getPlayerPlace(mAccountId).tryOpenWith(this)
return false
}
LinkHelper.openUrl(this, mAccountId, data.toString(), isMain)
return true
}

intent.extras != null && checkInputExist(this) -> {
mCurrentFrontSection = AbsNavigationView.SECTION_ITEM_DIALOGS
openNavigationPage(AbsNavigationView.SECTION_ITEM_DIALOGS, false)
return true
}
}
return false
}
Expand Down Expand Up @@ -1861,14 +1889,16 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect

companion object {
const val ACTION_MAIN = "android.intent.action.MAIN"
const val ACTION_CHAT_FROM_SHORTCUT = "dev.ragnarok.fenrir.ACTION_CHAT_FROM_SHORTCUT"
const val ACTION_OPEN_PLACE = "dev.ragnarok.fenrir.activity.MainActivity.openPlace"
const val ACTION_OPEN_AUDIO_PLAYER =
"dev.ragnarok.fenrir.activity.MainActivity.openAudioPlayer"
const val ACTION_SEND_ATTACHMENTS = "dev.ragnarok.fenrir.ACTION_SEND_ATTACHMENTS"
const val ACTION_SWITH_ACCOUNT = "dev.ragnarok.fenrir.ACTION_SWITH_ACCOUNT"

const val ACTION_SWITCH_ACCOUNT = "dev.ragnarok.fenrir.ACTION_SWITCH_ACCOUNT"
const val ACTION_SHORTCUT_WALL = "dev.ragnarok.fenrir.ACTION_SHORTCUT_WALL"
const val ACTION_OPEN_WALL = "dev.ragnarok.fenrir.ACTION_OPEN_WALL"
const val ACTION_CHAT_FROM_SHORTCUT = "dev.ragnarok.fenrir.ACTION_CHAT_FROM_SHORTCUT"

const val EXTRA_NO_REQUIRE_PIN = "no_require_pin"

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ open class PhotoPagerPresenter internal constructor(

override fun onViewHostAttached(view: IPhotoPagerView) {
super.onViewHostAttached(view)
resolveOptionMenu()
resolveOptionMenu(view)
}

private fun resolveOptionMenu() {
view?.setupOptionMenu(
private fun resolveOptionMenu(view: IPhotoPagerView) {
view.setupOptionMenu(
canSaveYourself(),
canDelete()
)
Expand Down Expand Up @@ -198,7 +198,7 @@ open class PhotoPagerPresenter internal constructor(
private fun onPositionChanged() {
refreshInfoViews(true)
resolveRestoreButtonVisibility()
resolveOptionMenu()
view?.let { resolveOptionMenu(it) }
}

private fun showPhotoInfo(photo: Photo, album: PhotoAlbum?, bundle: IOwnersBundle?) {
Expand Down Expand Up @@ -301,7 +301,7 @@ open class PhotoPagerPresenter internal constructor(
resolveWithUserView()
resolveShareView()
resolveCommentsView()
resolveOptionMenu()
view?.let { resolveOptionMenu(it) }
if (need_update && need_update_info() && hasPhotos()) {
val photo = current
if (photo.albumId != -311) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ object HttpLoggerAndParser {
return this
}

val DEFAULT_LOGGING_INTERCEPTOR: OkHttp3LoggingInterceptor by lazy {
private val DEFAULT_LOGGING_INTERCEPTOR: OkHttp3LoggingInterceptor by lazy {
OkHttp3LoggingInterceptor().setLevel(OkHttp3LoggingInterceptor.Level.BODY)
}

val UPLOAD_LOGGING_INTERCEPTOR: OkHttp3LoggingInterceptor by lazy {
private val UPLOAD_LOGGING_INTERCEPTOR: OkHttp3LoggingInterceptor by lazy {
//OkHttp3LoggingInterceptor().setLevel(OkHttp3LoggingInterceptor.Level.HEADERS)
OkHttp3LoggingInterceptor().setLevel(OkHttp3LoggingInterceptor.Level.BODY)
}
Expand Down
13 changes: 0 additions & 13 deletions app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/impl/DocsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import dev.ragnarok.fenrir.api.model.AccessIdPair
import dev.ragnarok.fenrir.api.model.Items
import dev.ragnarok.fenrir.api.model.VKApiDoc
import dev.ragnarok.fenrir.api.model.server.VKApiDocsUploadServer
import dev.ragnarok.fenrir.api.model.server.VKApiVideosUploadServer
import dev.ragnarok.fenrir.api.services.IDocsService
import io.reactivex.rxjava3.core.Single

Expand Down Expand Up @@ -75,18 +74,6 @@ internal class DocsApi(accountId: Long, provider: IServiceProvider) : AbsApi(acc
}
}

override fun getVideoServer(
isPrivate: Int?,
group_id: Long?,
name: String?
): Single<VKApiVideosUploadServer> {
return provideService(IDocsService(), TokenType.USER)
.flatMap { service ->
service.getVideoServer(isPrivate, group_id, name)
.map(extractResponseWithErrorHandling())
}
}

override fun get(
ownerId: Long?,
count: Int?,
Expand Down
Loading

0 comments on commit 5fec70a

Please sign in to comment.