, private val actionListener:
val config = getItem(position)
val isActive = config == active
viewHolder.address.text = config.getAddress()
- viewHolder.port.text = config.getPort().toString()
+ viewHolder.port.text = String.format(Locale.US, "%d", config.getPort())
viewHolder.username.text = config.getUser()
val pass = StringBuilder()
if (config.getPass().nonNullNoEmpty()) {
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/requestexecute/RequestExecutePresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/requestexecute/RequestExecutePresenter.kt
index 7c8729a49..6703b50ce 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/requestexecute/RequestExecutePresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/requestexecute/RequestExecutePresenter.kt
@@ -40,8 +40,8 @@ class RequestExecutePresenter(accountId: Long, savedInstanceState: Bundle?) :
private var trimmedResponseBody: String? = null
private var loadingNow = false
private fun executeRequest() {
- val trimmedMethod = if (method.nonNullNoEmpty()) method?.trim { it <= ' ' } else null
- val trimmedBody = if (body.nonNullNoEmpty()) body?.trim { it <= ' ' } else null
+ val trimmedMethod = if (method.nonNullNoEmpty()) method?.trim() else null
+ val trimmedBody = if (body.nonNullNoEmpty()) body?.trim() else null
if (trimmedMethod.isNullOrEmpty()) {
showError(Exception("Method can't be empty"))
return
@@ -52,8 +52,8 @@ class RequestExecutePresenter(accountId: Long, savedInstanceState: Bundle?) :
val lines = trimmedBody.split(Regex("\\r?\\n")).toTypedArray()
for (line in lines) {
val parts = line.split(Regex("=>")).toTypedArray()
- val name = parts[0].lowercase(Locale.getDefault()).trim { it <= ' ' }
- var value = parts[1].trim { it <= ' ' }
+ val name = parts[0].lowercase(Locale.getDefault()).trim()
+ var value = parts[1].trim()
value = value.replace("\"".toRegex(), "")
if ((name == "user_id" || name == "peer_id" || name == "peer_ids" || name == "owner_id") && (value.equals(
"my",
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/SearchFragmentFactory.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/SearchFragmentFactory.kt
index 27ec5b3dc..4797eca18 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/SearchFragmentFactory.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/SearchFragmentFactory.kt
@@ -38,67 +38,67 @@ object SearchFragmentFactory {
return when (type) {
SearchContentType.PEOPLE -> newInstance(
accountId,
- if (criteria is PeopleSearchCriteria) criteria else null
+ criteria as? PeopleSearchCriteria
)
SearchContentType.COMMUNITIES -> CommunitiesSearchFragment.newInstance(
accountId,
- if (criteria is GroupSearchCriteria) criteria else null
+ criteria as? GroupSearchCriteria
)
SearchContentType.VIDEOS -> VideoSearchFragment.newInstance(
accountId,
- if (criteria is VideoSearchCriteria) criteria else null
+ criteria as? VideoSearchCriteria
)
SearchContentType.AUDIOS -> newInstance(
accountId,
- if (criteria is AudioSearchCriteria) criteria else null
+ criteria as? AudioSearchCriteria
)
SearchContentType.ARTISTS -> newInstance(
accountId,
- if (criteria is ArtistSearchCriteria) criteria else null
+ criteria as? ArtistSearchCriteria
)
SearchContentType.AUDIOS_SELECT -> newInstanceSelect(
accountId,
- if (criteria is AudioSearchCriteria) criteria else null
+ criteria as? AudioSearchCriteria
)
SearchContentType.AUDIO_PLAYLISTS -> newInstance(
accountId,
- if (criteria is AudioPlaylistSearchCriteria) criteria else null
+ criteria as? AudioPlaylistSearchCriteria
)
SearchContentType.DOCUMENTS -> newInstance(
accountId,
- if (criteria is DocumentSearchCriteria) criteria else null
+ criteria as? DocumentSearchCriteria
)
SearchContentType.NEWS -> newInstance(
accountId,
- if (criteria is NewsFeedCriteria) criteria else null
+ criteria as? NewsFeedCriteria
)
SearchContentType.MESSAGES -> newInstance(
accountId,
- if (criteria is MessageSearchCriteria) criteria else null
+ criteria as? MessageSearchCriteria
)
SearchContentType.WALL -> WallSearchFragment.newInstance(
accountId,
- if (criteria is WallSearchCriteria) criteria else null
+ criteria as? WallSearchCriteria
)
SearchContentType.DIALOGS -> newInstance(
accountId,
- if (criteria is DialogsSearchCriteria) criteria else null
+ criteria as? DialogsSearchCriteria
)
SearchContentType.PHOTOS -> newInstance(
accountId,
- if (criteria is PhotoSearchCriteria) criteria else null
+ criteria as? PhotoSearchCriteria
)
else -> throw UnsupportedOperationException()
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/abssearch/AbsSearchFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/abssearch/AbsSearchFragment.kt
index 162531cf9..ad9cf4942 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/abssearch/AbsSearchFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/abssearch/AbsSearchFragment.kt
@@ -29,6 +29,10 @@ abstract class AbsSearchFragment, V : IBaseSe
return inflater.inflate(R.layout.fragment_search, container, false)
}
+ fun recreateLayoutManager() {
+ recyclerView?.layoutManager = createLayoutManager()
+ }
+
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@@ -36,8 +40,7 @@ abstract class AbsSearchFragment
, V : IBaseSe
): View {
val root = createViewLayout(inflater, container)
recyclerView = root.findViewById(R.id.list)
- val manager = createLayoutManager()
- recyclerView?.layoutManager = manager
+ recyclerView?.layoutManager = createLayoutManager()
recyclerView?.addOnScrollListener(object : EndlessRecyclerOnScrollListener() {
override fun onScrollToLastElement() {
presenter?.fireScrollToEnd()
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/audiossearch/AudiosSearchFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/audiossearch/AudiosSearchFragment.kt
index 77357c5dd..5b78cf106 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/audiossearch/AudiosSearchFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/audiossearch/AudiosSearchFragment.kt
@@ -138,7 +138,6 @@ class AudiosSearchFragment :
return fragment
}
-
fun newInstanceSelect(
accountId: Long,
criteria: AudioSearchCriteria?
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/criteria/BaseSearchCriteria.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/criteria/BaseSearchCriteria.kt
index 70d4c4f8f..1b9213f15 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/criteria/BaseSearchCriteria.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/criteria/BaseSearchCriteria.kt
@@ -62,7 +62,7 @@ open class BaseSearchCriteria : Parcelable, Cloneable {
fun safellyClone(): BaseSearchCriteria {
return try {
clone()
- } catch (e: CloneNotSupportedException) {
+ } catch (_: CloneNotSupportedException) {
throw UnsupportedOperationException("Unable to clone criteria")
}
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/filteredit/FilterEditFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/filteredit/FilterEditFragment.kt
index fcbf1e74c..1adb00569 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/filteredit/FilterEditFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/filteredit/FilterEditFragment.kt
@@ -42,7 +42,6 @@ import dev.ragnarok.fenrir.getParcelableArrayListCompat
import dev.ragnarok.fenrir.trimmedIsNullOrEmpty
import dev.ragnarok.fenrir.util.AppPerms.requestPermissionsAbs
import dev.ragnarok.fenrir.util.InputTextDialog
-import dev.ragnarok.fenrir.util.Utils.hasMarshmallow
import dev.ragnarok.fenrir.util.toast.CustomToast.Companion.createCustomToast
import dev.ragnarok.fenrir.view.DateTimePicker
import java.util.Calendar
@@ -294,7 +293,7 @@ class FilterEditFragment : BottomSheetDialogFragment(), OptionClickListener {
null
} else try {
Integer.valueOf(line)
- } catch (ignored: NumberFormatException) {
+ } catch (_: NumberFormatException) {
null
}
}
@@ -452,7 +451,7 @@ class FilterEditFragment : BottomSheetDialogFragment(), OptionClickListener {
@SuppressLint("MissingPermission")
fun getLocation(context: Context, result: LocationResult?): Boolean {
- if (hasMarshmallow() && ContextCompat.checkSelfPermission(
+ if (ContextCompat.checkSelfPermission(
context,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(
@@ -472,12 +471,12 @@ class FilterEditFragment : BottomSheetDialogFragment(), OptionClickListener {
// Exceptions will be thrown if the provider is not permitted.
try {
gps_enabled = it.isProviderEnabled(LocationManager.GPS_PROVIDER)
- } catch (ignored: Exception) {
+ } catch (_: Exception) {
}
try {
network_enabled = it
.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
- } catch (ignored: Exception) {
+ } catch (_: Exception) {
}
// Don't start listeners if no provider is enabled.
@@ -499,7 +498,7 @@ class FilterEditFragment : BottomSheetDialogFragment(), OptionClickListener {
inner class GetLastLocation : TimerTask() {
@SuppressLint("MissingPermission")
override fun run() {
- if (hasMarshmallow() && ContextCompat.checkSelfPermission(
+ if (ContextCompat.checkSelfPermission(
requireActivity(),
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/messagessearch/MessagesSearchFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/messagessearch/MessagesSearchFragment.kt
index b2b151b92..3c2be2cca 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/messagessearch/MessagesSearchFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/messagessearch/MessagesSearchFragment.kt
@@ -121,7 +121,6 @@ class MessagesSearchFragment :
mAdapter?.disableVoiceMessagePlaying()
}
-
override fun onVoiceHolderBinded(voiceMessageId: Int, voiceHolderId: Int) {
presenter?.fireVoiceHolderCreated(
voiceMessageId,
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/messagessearch/MessagesSearchPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/messagessearch/MessagesSearchPresenter.kt
index 6c35335ba..4bec6e48f 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/messagessearch/MessagesSearchPresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/messagessearch/MessagesSearchPresenter.kt
@@ -153,7 +153,7 @@ class MessagesSearchPresenter(
isSpeed
)
}
- } catch (ignored: Exception) {
+ } catch (_: Exception) {
}
syncVoiceLookupState()
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/photosearch/PhotoSearchFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/photosearch/PhotoSearchFragment.kt
index b5b3dae12..c64aaaa42 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/photosearch/PhotoSearchFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/photosearch/PhotoSearchFragment.kt
@@ -13,6 +13,8 @@ import dev.ragnarok.fenrir.fragment.search.criteria.PhotoSearchCriteria
import dev.ragnarok.fenrir.getParcelableCompat
import dev.ragnarok.fenrir.model.Photo
import dev.ragnarok.fenrir.place.PlaceFactory.getSimpleGalleryPlace
+import dev.ragnarok.fenrir.settings.Settings
+import dev.ragnarok.fenrir.util.Utils
class PhotoSearchFragment :
AbsSearchFragment(),
@@ -44,6 +46,11 @@ class PhotoSearchFragment :
}
override fun createLayoutManager(): RecyclerView.LayoutManager {
+ if (Settings.get().main().single_line_photos) {
+ return Utils.getSingleElementsLayoutManager(
+ requireActivity()
+ )
+ }
val columnCount = resources.getInteger(R.integer.local_gallery_column_count)
return GridLayoutManager(requireActivity(), columnCount)
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/videosearch/VideoSearchFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/videosearch/VideoSearchFragment.kt
index 411746566..622afaf73 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/videosearch/VideoSearchFragment.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/search/videosearch/VideoSearchFragment.kt
@@ -13,6 +13,7 @@ import dev.ragnarok.fenrir.fragment.search.criteria.VideoSearchCriteria
import dev.ragnarok.fenrir.fragment.videos.VideosAdapter
import dev.ragnarok.fenrir.getParcelableCompat
import dev.ragnarok.fenrir.model.Video
+import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.util.Utils
class VideoSearchFragment :
@@ -30,6 +31,11 @@ class VideoSearchFragment :
}
override fun createLayoutManager(): RecyclerView.LayoutManager {
+ if (Settings.get().main().single_line_videos) {
+ return Utils.getSingleElementsLayoutManager(
+ requireActivity()
+ )
+ }
val columns = resources.getInteger(R.integer.videos_column_count)
return StaggeredGridLayoutManager(columns, StaggeredGridLayoutManager.VERTICAL)
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/shortcutsview/ShortcutsViewPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/shortcutsview/ShortcutsViewPresenter.kt
index 070c7d179..f1cee70ba 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/shortcutsview/ShortcutsViewPresenter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/shortcutsview/ShortcutsViewPresenter.kt
@@ -81,7 +81,7 @@ class ShortcutsViewPresenter(savedInstanceState: Bundle?) :
)
return true
}
- } catch (ignored: Exception) {
+ } catch (_: Exception) {
}
return false
}
@@ -122,7 +122,7 @@ class ShortcutsViewPresenter(savedInstanceState: Bundle?) :
)
return true
}
- } catch (ignored: Exception) {
+ } catch (_: Exception) {
}
return false
}
@@ -144,7 +144,7 @@ class ShortcutsViewPresenter(savedInstanceState: Bundle?) :
)
return true
}
- } catch (ignored: Exception) {
+ } catch (_: Exception) {
}
return false
}
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/theme/ThemeAdapter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/theme/ThemeAdapter.kt
index a9b930051..d0b0e8090 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/theme/ThemeAdapter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/theme/ThemeAdapter.kt
@@ -60,7 +60,7 @@ class ThemeAdapter(private var data: List, context: Context) :
holder.special_title.visibility = View.VISIBLE
var name = category.name
if (name.length > 4) name = name.substring(0, 4)
- name = name.trim { it <= ' ' }
+ name = name.trim()
holder.special_title.text = name
holder.special_title.setTextColor(
if (position % 2 == 0) getColorPrimary(holder.itemView.context) else getColorSecondary(
@@ -71,7 +71,7 @@ class ThemeAdapter(private var data: List, context: Context) :
holder.special_title.visibility = View.INVISIBLE
}
holder.selected.visibility = if (isSelected) View.VISIBLE else View.GONE
- if (Utils.hasMarshmallow() && FenrirNative.isNativeLoaded) {
+ if (FenrirNative.isNativeLoaded) {
if (isSelected) {
holder.selected.fromRes(
dev.ragnarok.fenrir_common.R.raw.theme_selected,
@@ -109,7 +109,7 @@ class ThemeAdapter(private var data: List, context: Context) :
holder.primary.setBackgroundColor(if (isDark) category.colorNightPrimary else category.colorDayPrimary)
holder.secondary.setBackgroundColor(if (isDark) category.colorNightSecondary else category.colorDaySecondary)
holder.selected.visibility = if (isSelected) View.VISIBLE else View.GONE
- if (Utils.hasMarshmallow() && FenrirNative.isNativeLoaded) {
+ if (FenrirNative.isNativeLoaded) {
if (isSelected) {
holder.selected.fromRes(
dev.ragnarok.fenrir_common.R.raw.theme_selected,
diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/videos/VideosAdapter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/videos/VideosAdapter.kt
index ffadf4193..574cb1537 100644
--- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/videos/VideosAdapter.kt
+++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/videos/VideosAdapter.kt
@@ -13,7 +13,9 @@ import dev.ragnarok.fenrir.model.Video
import dev.ragnarok.fenrir.nonNullNoEmpty
import dev.ragnarok.fenrir.picasso.PicassoInstance.Companion.with
import dev.ragnarok.fenrir.util.AppTextUtils
+import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.view.VideoServiceIcons.getIconByType
+import kotlin.String
class VideosAdapter(private val context: Context, private var data: List