Skip to content

Commit bdaa089

Browse files
committed
parsing, content and bug fixes
1 parent ce494a9 commit bdaa089

File tree

13 files changed

+38
-42
lines changed

13 files changed

+38
-42
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Photosight Gallery
22

3-
Photosight.ru is a photographic community of talented photographers mostly from Europe. You can find there daily updated archive of creative artistic photos or share your own.
4-
Photosight Gallery is an easy way to browse photos from www.photosight.ru on your Android device.
3+
sight.photo is a photographic community of talented photographers mostly from Europe. You can find there daily updated archive of creative artistic photos or share your own.
4+
Photosight Gallery is an easy way to browse photos from https://sight.photo on your Android device.
55

66
<img src="media/photosight.gif" width=25%>
77

app/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ android {
6565
}
6666

6767
compileOptions {
68-
//coreLibraryDesugaringEnabled = true
68+
isCoreLibraryDesugaringEnabled = true
6969
sourceCompatibility = JavaVersion.VERSION_1_8
7070
targetCompatibility = JavaVersion.VERSION_1_8
7171
}
@@ -105,6 +105,8 @@ dependencies {
105105

106106
implementation(project(":parser"))
107107

108+
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5")
109+
108110
// androidx
109111
implementation("androidx.core:core-ktx:$androidX")
110112
implementation("androidx.appcompat:appcompat:$appCompatVersion")

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
android:icon="@mipmap/ic_launcher"
1111
android:label="@string/app_name"
1212
android:theme="@style/AppTheme"
13+
android:usesCleartextTraffic="true"
1314
>
1415

1516
<activity

app/src/main/java/ds/photosight/ui/SharedElementsHelper.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ class SharedElementsHelper(private val fragment: Fragment) {
2020
private var isScrollingToPosition = false
2121

2222
fun postpone(position: Int) {
23-
//Timber.v("${fragment.javaClass.simpleName}:postpone animation for element $position")
2423
isRunning = true
2524
fragment.postponeEnterTransition(2000, TimeUnit.MILLISECONDS)
2625
elementPosition = position
2726
}
2827

2928
fun animate(position: Int) {
3029
fun doAnimate() {
31-
//Timber.v("start new animation at position $position")
3230
fragment.startPostponedEnterTransition()
3331
isRunning = false
3432
}
@@ -44,7 +42,6 @@ class SharedElementsHelper(private val fragment: Fragment) {
4442
}
4543

4644
fun setupEnterAnimation(onEnd: () -> Unit) = with(fragment) {
47-
//Timber.d("${fragment.javaClass.simpleName}:setup animations")
4845
sharedElementEnterTransition = TransitionInflater.from(requireContext()).inflateTransition(R.transition.image_transition)
4946
.addListener(object : TransitionListenerAdapter() {
5047
override fun onTransitionEnd(transition: Transition) {
@@ -64,7 +61,6 @@ class SharedElementsHelper(private val fragment: Fragment) {
6461
}
6562

6663
fun setupEnterCallback(view: View) {
67-
//Timber.v("${fragment.javaClass.simpleName}: setting new enter callback")
6864
if (isRunning) {
6965
Timber.e("can't set callback when animation is running")
7066
return
@@ -80,19 +76,13 @@ class SharedElementsHelper(private val fragment: Fragment) {
8076
Timber.e("can't set callback when animation is stopped")
8177
return
8278
}
83-
//if (!isScrollingToPosition) {
8479
fragment.setExitSharedElementCallback(TransitionCallback("exit", view) {
8580
fragment.setExitSharedElementCallback(null)
8681
})
87-
/*} else {
88-
fragment.setExitSharedElementCallback(null)
89-
}*/
90-
9182
}
9283

9384
fun moveToCurrentItem(recyclerView: RecyclerView) {
9485
if (isRunning && elementPosition >= 0) {
95-
//Timber.v("${fragment.javaClass.simpleName}: scroll grid to updated position")
9686
val selectedViewHolder = recyclerView.findViewHolderForAdapterPosition(elementPosition)
9787
if (selectedViewHolder == null) {
9888
Timber.w("view not found for position $elementPosition. scrolling!")
@@ -107,14 +97,10 @@ class SharedElementsHelper(private val fragment: Fragment) {
10797
if (isScrollingToPosition) {
10898
isScrollingToPosition = false
10999
}
110-
//photosAdapter.notifyItemChanged(elementPosition)
111-
//photosAdapter.notifyDataSetChanged()
112100
elementPosition = -1
113101
}
114102
}
115103

116-
//fun denyUpdate(position: Int): Boolean = isScrollingToPosition && elementPosition != position
117-
118104
class TransitionCallback(val name: String, val view: View, val onFinish: () -> Unit) : SharedElementCallback() {
119105
override fun onMapSharedElements(names: MutableList<String>, sharedElements: MutableMap<String, View>) {
120106
sharedElements[names.first()] = view

app/src/main/java/ds/photosight/ui/view/GalleryFragment.kt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import androidx.navigation.fragment.findNavController
1717
import androidx.paging.LoadState
1818
import androidx.recyclerview.widget.RecyclerView
1919
import androidx.recyclerview.widget.StaggeredGridLayoutManager
20-
import androidx.transition.TransitionInflater
2120
import com.google.android.material.bottomsheet.BottomSheetBehavior
2221
import com.google.android.material.snackbar.Snackbar
2322
import com.google.android.material.tabs.TabLayoutMediator
@@ -82,6 +81,20 @@ class GalleryFragment : Fragment() {
8281

8382
}
8483

84+
private fun navigateTo(clickedItem: GalleryAdapter.ClickedItem) {
85+
val extras = FragmentNavigatorExtras(
86+
clickedItem.view to clickedItem.view.transitionName
87+
)
88+
with(findNavController()) {
89+
log.v("current destination: ${currentDestination?.id}")
90+
if (R.id.galleryFragment == currentDestination?.id) {
91+
navigate(GalleryFragmentDirections.openViewer(clickedItem.position), extras)
92+
} else {
93+
log.w("wrong destination")
94+
}
95+
}
96+
}
97+
8598
private fun observeData() {
8699
val onMenuSelected = { item: MenuItemState ->
87100
viewModel.onMenuSelected(item)
@@ -100,17 +113,7 @@ class GalleryFragment : Fragment() {
100113
if (clickedItem.isLoading) {
101114
viewModel.loadingState.value = true
102115
} else {
103-
val extras = FragmentNavigatorExtras(
104-
clickedItem.view to clickedItem.view.transitionName
105-
)
106-
with(findNavController()) {
107-
log.v("current destination: ${currentDestination?.id}")
108-
if (R.id.galleryFragment == currentDestination?.id) {
109-
navigate(GalleryFragmentDirections.openViewer(clickedItem.position), extras)
110-
} else {
111-
log.w("wrong destination")
112-
}
113-
}
116+
navigateTo(clickedItem)
114117
}
115118
}
116119

app/src/main/java/ds/photosight/ui/view/ViewerFragment.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import android.view.ViewGroup
1010
import androidx.activity.addCallback
1111
import androidx.appcompat.app.ActionBarDrawerToggle
1212
import androidx.core.content.ContextCompat
13-
import androidx.core.view.GravityCompat
14-
import androidx.core.view.ViewCompat
15-
import androidx.core.view.isInvisible
16-
import androidx.core.view.isVisible
13+
import androidx.core.view.*
1714
import androidx.fragment.app.Fragment
1815
import androidx.fragment.app.activityViewModels
1916
import androidx.fragment.app.viewModels
@@ -41,6 +38,8 @@ import ds.photosight.utils.position
4138
import ds.photosight.utils.recyclerView
4239
import ds.photosight.utils.snack
4340
import kotlinx.android.synthetic.main.fragment_viewer.*
41+
import kotlinx.android.synthetic.main.fragment_viewer.toolbar
42+
import kotlinx.android.synthetic.main.view_menu.*
4443
import kotlinx.coroutines.launch
4544
import timber.log.Timber
4645
import javax.inject.Inject
@@ -149,8 +148,11 @@ class ViewerFragment : Fragment() {
149148
}
150149

151150
private fun setupInsets() {
152-
ViewCompat.setOnApplyWindowInsetsListener(shareMenuView) { v, insets ->
153-
v.setPadding(0, 0, 0, 0) // buggy NavigationView fix
151+
ViewCompat.setOnApplyWindowInsetsListener(drawerLayout) { view, insets ->
152+
val sbInset = insets.systemWindowInsetTop
153+
val nbInset = insets.systemWindowInsetBottom
154+
appBar.updatePadding(top = sbInset)
155+
bottomToolbar.updatePadding(bottom = nbInset)
154156
insets
155157
}
156158
}

app/src/main/java/ds/photosight/ui/viewmodel/ViewerViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class ViewerViewModel @Inject constructor(
3737
val details = photoDetailsMap.getOrPut(photoId) { photosightRepo.getPhotoDetails(photoId) }
3838
_commentsState.value = CommentsState.Payload(details)
3939
} catch (e: Exception) {
40+
e.printStackTrace()
4041
_commentsState.value = CommentsState.Error
4142
}
4243
}

app/src/main/res/layout/fragment_viewer.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
/>
2626

2727
<com.google.android.material.appbar.AppBarLayout
28+
android:id="@+id/appBar"
2829
android:layout_width="match_parent"
2930
android:layout_height="wrap_content"
3031
android:animateLayoutChanges="true"

app/src/main/res/values-ru/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<string name="category_92">Техно</string>
3333

3434

35-
<string name="abouttext">"Photosight Gallery - это неофициальное приложение для быстрого и удобного доступа к крупнейшему в мире архиву высокохудожественных фоторабот профессиональных фотографов (преимущественно из стран СНГ) photosight.ru
35+
<string name="abouttext">"Photosight Gallery - это неофициальное приложение для быстрого и удобного доступа к крупнейшему в мире архиву высокохудожественных фоторабот профессиональных фотографов (преимущественно из стран СНГ) sight.photo
3636

3737
Пожелания и багрепорты принимаются на email:
3838
deviantstudio.software@gmail.com

app/src/main/res/values-uk/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<string name="dislikes">Невподоби</string>
5555
<string name="retry">Повторити</string>
5656
<string name="views">Перегляди</string>
57-
<string name="abouttext">"Photosight Gallery - це неофіційний застосунок для швидкого та зручного доступу до великого архіву високохудожніх світлин професійних фотографів (переважно москалів) photosight.ru
57+
<string name="abouttext">"Photosight Gallery - це неофіційний застосунок для швидкого та зручного доступу до великого архіву високохудожніх світлин професійних фотографів (переважно москалів) sight.photo
5858
Побажання та звіти про помилки приймаються на deviantstudio.software@gmail.com
5959

6060
Change Log:

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
<string name="thin_font" translatable="false">sans-serif-light</string>
4646
<string name="light_font" translatable="false">sans-serif</string>
4747

48-
<string name="abouttext">"Photosight.ru is a photographic community of talented photographers mostly from Europe. You can find there daily updated archive of creative artistic photos or share your own.
49-
Photosight Gallery is an easy way to browse photos from photosight.ru on your Android device.
48+
<string name="abouttext">"sight.photo is a photographic community of talented photographers mostly from Europe. You can find there daily updated archive of creative artistic photos or share your own.
49+
Photosight Gallery is an easy way to browse photos from https://sight.photo on your Android device.
5050

5151
Please e-mail bugreports:
5252
deviantstudio.software@gmail.com
@@ -70,7 +70,7 @@ Change Log:
7070
<string name="photo_author">"&lt;AUTHOR&gt;"</string>
7171
<string name="likes">Likes</string>
7272
<string name="dislikes">Dislikes</string>
73-
<string name="copyright" translatable="false">© 1997-2020 Deviant Studio</string>
73+
<string name="copyright" translatable="false">© 1997-2022 Deviant Studio</string>
7474
<string name="about_title_" translatable="false">"PHOTOSIGHT GALLERY "</string>
7575
<string name="retry">Retry</string>
7676
<string name="views">Views</string>

parser/src/main/kotlin/ds/photosight/parser/Requests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class CategoriesRequest : JsoupRequest<List<PhotoCategory>>() {
6565

6666
class PhotoDetailsRequest(photoId: Int) : JsoupRequest<PhotoDetails>() {
6767

68-
private val dateFormat = DateTimeFormatter.ofPattern("d MMMM yyyy, HH:mm:ss")
68+
private val dateFormat = DateTimeFormatter.ofPattern("d MMMM yyyy, HH:mm:ss", Locale.US)
6969

7070
override fun invoke(): PhotoDetails {
7171
val doc = getDocument()

parser/src/test/kotlin/ds/photosight/parser/PhotosightParserTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class PhotosightParserTest {
7373

7474
@Test
7575
fun `comments showcase`() {
76-
PhotoDetailsRequest(5358008)()
76+
PhotoDetailsRequest(7249211)()
7777
.also { println(it) }
7878
}
7979

0 commit comments

Comments
 (0)