WIP visor de imagenes
This commit is contained in:
parent
2256b1e57f
commit
72acdf1f10
22
.idea/navEditor.xml
generated
22
.idea/navEditor.xml
generated
@ -159,6 +159,28 @@
|
|||||||
</LayoutPositions>
|
</LayoutPositions>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry key="picture_viewer_navigation.xml">
|
||||||
|
<value>
|
||||||
|
<LayoutPositions>
|
||||||
|
<option name="myPositions">
|
||||||
|
<map>
|
||||||
|
<entry key="pictureViewerMainFragment">
|
||||||
|
<value>
|
||||||
|
<LayoutPositions>
|
||||||
|
<option name="myPosition">
|
||||||
|
<Point>
|
||||||
|
<option name="x" value="40" />
|
||||||
|
<option name="y" value="40" />
|
||||||
|
</Point>
|
||||||
|
</option>
|
||||||
|
</LayoutPositions>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</LayoutPositions>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
<entry key="profile_navigation.xml">
|
<entry key="profile_navigation.xml">
|
||||||
<value>
|
<value>
|
||||||
<LayoutPositions>
|
<LayoutPositions>
|
||||||
|
|||||||
@ -108,4 +108,8 @@ dependencies {
|
|||||||
annotationProcessor "androidx.room:room-compiler:$room_version"
|
annotationProcessor "androidx.room:room-compiler:$room_version"
|
||||||
kapt("androidx.room:room-compiler:$room_version")
|
kapt("androidx.room:room-compiler:$room_version")
|
||||||
implementation "androidx.room:room-ktx:2.5.2"
|
implementation "androidx.room:room-ktx:2.5.2"
|
||||||
|
|
||||||
|
implementation "androidx.preference:preference-ktx:1.2.1"
|
||||||
|
|
||||||
|
implementation 'com.github.MikeOrtiz:TouchImageView:3.5'
|
||||||
}
|
}
|
||||||
@ -33,6 +33,7 @@
|
|||||||
<activity android:name=".posting.PostViewerActivity" android:theme="@style/Theme.Isolaatti"/>
|
<activity android:name=".posting.PostViewerActivity" android:theme="@style/Theme.Isolaatti"/>
|
||||||
<activity android:name=".drafts.ui.DraftsActivity" android:theme="@style/Theme.Isolaatti"/>
|
<activity android:name=".drafts.ui.DraftsActivity" android:theme="@style/Theme.Isolaatti"/>
|
||||||
<activity android:name=".about.AboutActivity" android:theme="@style/Theme.Isolaatti"/>
|
<activity android:name=".about.AboutActivity" android:theme="@style/Theme.Isolaatti"/>
|
||||||
|
<activity android:name=".picture_viewer.ui.PictureViewerActivity" android:theme="@style/Theme.Isolaatti"/>
|
||||||
</application>
|
</application>
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
@ -13,5 +13,9 @@ class AboutActivity : AppCompatActivity() {
|
|||||||
binding = ActivityAboutBinding.inflate(layoutInflater)
|
binding = ActivityAboutBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
|
binding.toolbar.setNavigationOnClickListener {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,6 +23,7 @@ import com.isolaatti.common.ErrorMessageViewModel
|
|||||||
import com.isolaatti.databinding.FragmentFeedBinding
|
import com.isolaatti.databinding.FragmentFeedBinding
|
||||||
import com.isolaatti.drafts.ui.DraftsActivity
|
import com.isolaatti.drafts.ui.DraftsActivity
|
||||||
import com.isolaatti.home.presentation.FeedViewModel
|
import com.isolaatti.home.presentation.FeedViewModel
|
||||||
|
import com.isolaatti.picture_viewer.ui.PictureViewerActivity
|
||||||
import com.isolaatti.posting.PostViewerActivity
|
import com.isolaatti.posting.PostViewerActivity
|
||||||
import com.isolaatti.posting.comments.presentation.BottomSheetPostComments
|
import com.isolaatti.posting.comments.presentation.BottomSheetPostComments
|
||||||
import com.isolaatti.posting.common.domain.OnUserInteractedWithPostCallback
|
import com.isolaatti.posting.common.domain.OnUserInteractedWithPostCallback
|
||||||
@ -163,6 +164,9 @@ class FeedFragment : Fragment(), OnUserInteractedWithPostCallback {
|
|||||||
val textViewEmail: TextView? = header?.findViewById(R.id.textViewEmail)
|
val textViewEmail: TextView? = header?.findViewById(R.id.textViewEmail)
|
||||||
|
|
||||||
Picasso.get().load(UrlGen.userProfileImage(it.id)).into(image)
|
Picasso.get().load(UrlGen.userProfileImage(it.id)).into(image)
|
||||||
|
image?.setOnClickListener {_ ->
|
||||||
|
PictureViewerActivity.startActivityWithUrls(requireContext(), arrayOf(UrlGen.userProfileImageFullQuality(it.id)))
|
||||||
|
}
|
||||||
|
|
||||||
textViewName?.text = it.name
|
textViewName?.text = it.name
|
||||||
textViewEmail?.text = it.email
|
textViewEmail?.text = it.email
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.isolaatti.picture_viewer.domain
|
||||||
|
|
||||||
|
class Picture {
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package com.isolaatti.picture_viewer.presentation
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
|
import com.isolaatti.picture_viewer.ui.PictureViewerImageWrapperFragment
|
||||||
|
|
||||||
|
class PictureViewerViewPagerAdapter(fragment: Fragment, private val images: Array<String>) : FragmentStateAdapter(fragment) {
|
||||||
|
override fun getItemCount(): Int {
|
||||||
|
return images.size
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createFragment(position: Int): Fragment {
|
||||||
|
return PictureViewerImageWrapperFragment.getInstance(images[position])
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package com.isolaatti.picture_viewer.ui
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import com.isolaatti.databinding.ActivityPictureViewerBinding
|
||||||
|
import com.isolaatti.picture_viewer.presentation.PictureViewerViewPagerAdapter
|
||||||
|
|
||||||
|
class PictureViewerActivity : AppCompatActivity() {
|
||||||
|
private lateinit var binding: ActivityPictureViewerBinding
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
binding = ActivityPictureViewerBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
|
setContentView(binding.root)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val EXTRA_URLS = "urls"
|
||||||
|
const val EXTRA_PROFILE_ID = "profileId"
|
||||||
|
|
||||||
|
fun startActivityWithUrls(context: Context, urls: Array<String>) {
|
||||||
|
val intent = Intent(context, PictureViewerActivity::class.java)
|
||||||
|
intent.putExtra(EXTRA_URLS, urls)
|
||||||
|
context.startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
package com.isolaatti.picture_viewer.ui
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import com.isolaatti.databinding.FragmentTouchImageViewWrapperBinding
|
||||||
|
import com.ortiz.touchview.OnTouchImageViewListener
|
||||||
|
import com.squareup.picasso.Picasso
|
||||||
|
import java.lang.NullPointerException
|
||||||
|
|
||||||
|
class PictureViewerImageWrapperFragment : Fragment() {
|
||||||
|
|
||||||
|
private lateinit var binding: FragmentTouchImageViewWrapperBinding
|
||||||
|
private var url: String? = null
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
|
binding = FragmentTouchImageViewWrapperBinding.inflate(inflater)
|
||||||
|
|
||||||
|
url = arguments?.getString(ARGUMENT_URL)
|
||||||
|
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
parentFragment?.let {
|
||||||
|
|
||||||
|
binding.touchImageView.setOnTouchImageViewListener(object: OnTouchImageViewListener {
|
||||||
|
override fun onMove() {
|
||||||
|
(it as PictureViewerMainFragment).enableViewPagerUserInput(!binding.touchImageView.isZoomed)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
url?.let {
|
||||||
|
Picasso.get().load(it).into(binding.touchImageView)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val ARGUMENT_URL = "url"
|
||||||
|
fun getInstance(url: String): PictureViewerImageWrapperFragment {
|
||||||
|
val fragment = PictureViewerImageWrapperFragment()
|
||||||
|
fragment.arguments = Bundle().apply {
|
||||||
|
putString(ARGUMENT_URL, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
package com.isolaatti.picture_viewer.ui
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import com.isolaatti.databinding.FragmentMainPictureViewerBinding
|
||||||
|
import com.isolaatti.picture_viewer.presentation.PictureViewerViewPagerAdapter
|
||||||
|
|
||||||
|
class PictureViewerMainFragment : Fragment() {
|
||||||
|
|
||||||
|
private lateinit var binding: FragmentMainPictureViewerBinding
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
|
binding = FragmentMainPictureViewerBinding.inflate(inflater)
|
||||||
|
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
val url = requireActivity().intent.extras?.getStringArray(PictureViewerActivity.EXTRA_URLS)
|
||||||
|
|
||||||
|
url?.let {
|
||||||
|
val adapter = PictureViewerViewPagerAdapter(this, it)
|
||||||
|
binding.viewpager.adapter = adapter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun enableViewPagerUserInput(enabled: Boolean) {
|
||||||
|
binding.viewpager.isUserInputEnabled = enabled
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,26 +1,12 @@
|
|||||||
package com.isolaatti.settings.ui
|
package com.isolaatti.settings.ui
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import android.view.View
|
import com.isolaatti.R
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import com.isolaatti.databinding.FragmentSettingsBinding
|
|
||||||
|
|
||||||
class SettingsFragment : Fragment() {
|
class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
lateinit var viewBinding: FragmentSettingsBinding
|
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
inflater: LayoutInflater,
|
setPreferencesFromResource(R.xml.preferences, rootKey)
|
||||||
container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View? {
|
|
||||||
viewBinding = FragmentSettingsBinding.inflate(inflater)
|
|
||||||
|
|
||||||
viewBinding.topAppBar.setNavigationOnClickListener {
|
|
||||||
requireActivity().onBackPressed()
|
|
||||||
}
|
|
||||||
|
|
||||||
return viewBinding.root
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,5 +4,6 @@ import com.isolaatti.connectivity.RetrofitClient.Companion.BASE_URL
|
|||||||
|
|
||||||
object UrlGen {
|
object UrlGen {
|
||||||
fun userProfileImage(userId: Int) = "${BASE_URL}images/profile_image/of_user/$userId?mode=small"
|
fun userProfileImage(userId: Int) = "${BASE_URL}images/profile_image/of_user/$userId?mode=small"
|
||||||
|
fun userProfileImageFullQuality(userId: Int) = "${BASE_URL}images/profile_image/of_user/$userId?mode=original"
|
||||||
fun imageUrl(imageId: String) = "${BASE_URL}images/image/${imageId}"
|
fun imageUrl(imageId: String) = "${BASE_URL}images/image/${imageId}"
|
||||||
}
|
}
|
||||||
@ -4,10 +4,12 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appBarLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:title="@string/about"
|
app:title="@string/about"
|
||||||
|
|||||||
14
app/src/main/res/layout/activity_picture_viewer.xml
Normal file
14
app/src/main/res/layout/activity_picture_viewer.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<androidx.fragment.app.FragmentContainerView
|
||||||
|
android:id="@+id/fragmentContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||||
|
app:defaultNavHost="true"
|
||||||
|
app:navGraph="@navigation/picture_viewer_navigation"/>
|
||||||
|
</FrameLayout>
|
||||||
10
app/src/main/res/layout/fragment_main_picture_viewer.xml
Normal file
10
app/src/main/res/layout/fragment_main_picture_viewer.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
|
android:id="@+id/viewpager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/black"/>
|
||||||
|
</FrameLayout>
|
||||||
@ -1,33 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
|
||||||
android:id="@+id/topAppBar_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
|
||||||
android:id="@+id/topAppBar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
app:title="@string/settings"
|
|
||||||
app:navigationIcon="@drawable/baseline_arrow_back_24"/>
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/account"
|
|
||||||
android:textAlignment="textStart"
|
|
||||||
style="@style/Widget.MaterialComponents.Button.TextButton"/>
|
|
||||||
</LinearLayout>
|
|
||||||
</ScrollView>
|
|
||||||
</LinearLayout>
|
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<com.ortiz.touchview.TouchImageView
|
||||||
|
android:id="@+id/touchImageView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/black"/>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
11
app/src/main/res/navigation/picture_viewer_navigation.xml
Normal file
11
app/src/main/res/navigation/picture_viewer_navigation.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/picture_viewer_navigation"
|
||||||
|
app:startDestination="@id/pictureViewerMainFragment">
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/pictureViewerMainFragment"
|
||||||
|
android:name="com.isolaatti.picture_viewer.ui.PictureViewerMainFragment"
|
||||||
|
android:label="PictureViewerMainFragment" />
|
||||||
|
</navigation>
|
||||||
@ -5,4 +5,5 @@
|
|||||||
<color name="surface">@color/design_default_color_background</color>
|
<color name="surface">@color/design_default_color_background</color>
|
||||||
<color name="on_surface">#000000</color>
|
<color name="on_surface">#000000</color>
|
||||||
<color name="danger">#BA0606</color>
|
<color name="danger">#BA0606</color>
|
||||||
|
<color name="black">#000000</color>
|
||||||
</resources>
|
</resources>
|
||||||
4
app/src/main/res/xml/preferences.xml
Normal file
4
app/src/main/res/xml/preferences.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
@ -10,6 +10,7 @@ dependencyResolutionManagement {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rootProject.name = "Isolaatti"
|
rootProject.name = "Isolaatti"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user