Skip to content

Commit

Permalink
Merge pull request #31 from reskimulud/dev
Browse files Browse the repository at this point in the history
Merge from Dev to Main branch
  • Loading branch information
reskimulud committed May 5, 2022
2 parents e60003b + c57b56e commit 6eaba9d
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@

**Mankgram** has a *simple interface and is easy to use*, you can send pictures either from the camera directly or take pictures from the gallery. There is also a feature to change the display mode to dark to make the user comfortable and of course it will save battery because it doesn't display a lot of light colors.

**Mankgram** are available in the form of a *list* and *map view* in displaying stories. To embed a location, we can tick **share location** when uploading a new story. In map view mode, we can change the map **type** and **style** as we like.

This application is an application that was made as an assignment for submission in the [Belajar Fundamental Aplikasi Android Intermediate](https://dicoding.com/academies/352) class at [Dicoding](https://dicoding.com) learning platform, and it is also related to the [Bangkit Academy 2022](https://g.co/bangkit) activity that I participated in.

## Screenshoot:
## Screenshot:

<table border="1" align="center">
<tr>
Expand All @@ -36,6 +38,12 @@ This application is an application that was made as an assignment for submission
<td><img src="https://raw.githubusercontent.com/reskimulud/reskimulud/main/assets_for_project/mankgram/Screenshot_2022-04-12-16-37-52-69.png" width="240px" /></td>
</tr>

<tr>
<td><img src="https://raw.githubusercontent.com/reskimulud/reskimulud/main/assets_for_project/mankgram/Screenshot_2022-05-05-11-23-50-46.png" width="240px" /></td>
<td><img src="https://raw.githubusercontent.com/reskimulud/reskimulud/main/assets_for_project/mankgram/Screenshot_2022-05-05-11-23-57-08.png" width="240px" /></td>
<td><img src="https://raw.githubusercontent.com/reskimulud/reskimulud/main/assets_for_project/mankgram/Screenshot_2022-05-05-11-24-11-05.png" width="240px" /></td>
</tr>

</table>

## License
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class StoryRemoteMediator(
val responseData = response?.listStory as List<StoryModel>
val endOfPaginationReached = responseData.isEmpty()

Log.e("StoryRemoteMediator", "inserting: $response")
Log.i("StoryRemoteMediator", "inserting: $response")

userStoryDatabase.withTransaction {
if (loadType == LoadType.REFRESH) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.os.Bundle
import android.view.WindowInsets
import android.view.WindowManager
import androidx.activity.viewModels
import com.mankart.mankgram.R
import com.mankart.mankgram.databinding.ActivityOnBoardingBinding
import com.mankart.mankgram.ui.authentication.AuthenticationActivity
import com.mankart.mankgram.ui.mainmenu.setting.SettingViewModel
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/java/com/mankart/mankgram/ui/mainmenu/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.mankart.mankgram.ui.mainmenu

import android.Manifest
import android.animation.ObjectAnimator
import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.widget.Toast
import com.google.android.material.bottomnavigation.BottomNavigationView
Expand All @@ -14,6 +16,7 @@ import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.preferencesDataStore
import androidx.navigation.findNavController
import androidx.navigation.ui.setupWithNavController
import androidx.recyclerview.widget.RecyclerView
import com.mankart.mankgram.R
import com.mankart.mankgram.utils.clearDirectory
import com.mankart.mankgram.databinding.ActivityMainBinding
Expand All @@ -23,6 +26,7 @@ val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "se
class MainActivity : AppCompatActivity() {

private lateinit var binding: ActivityMainBinding
private var hideNavView = false

override fun onRequestPermissionsResult(
requestCode: Int,
Expand Down Expand Up @@ -62,11 +66,40 @@ class MainActivity : AppCompatActivity() {
)
}

val rvStory = findViewById<RecyclerView>(R.id.rv_story)
if (rvStory != null) {
hideShowBottomNavigation(rvStory)
}

supportActionBar?.hide()
val navController = findNavController(R.id.nav_host_fragment_activity_main)
navView.setupWithNavController(navController)
}

private fun hideShowBottomNavigation(rvStory: RecyclerView) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
rvStory.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
val height = (binding.navView.height + 32).toFloat()

if (!hideNavView && scrollY > oldScrollY) {
hideNavView = true
ObjectAnimator.ofFloat(binding.navView, "translationY", 0f, height).apply {
duration = 200
start()
}
}

if (hideNavView && scrollY < oldScrollY) {
hideNavView = false
ObjectAnimator.ofFloat(binding.navView, "translationY", height, 0f).apply {
duration = 200
start()
}
}
}
}
}

override fun onDestroy() {
super.onDestroy()
clearDirectory(application)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import androidx.transition.TransitionInflater
import com.bumptech.glide.Glide
import com.mankart.mankgram.R
import com.mankart.mankgram.databinding.FragmentDetailImageBinding

class DetailImageFragment : DialogFragment() {
Expand Down Expand Up @@ -43,5 +42,7 @@ class DetailImageFragment : DialogFragment() {

sharedElementEnterTransition = animation
sharedElementReturnTransition = animation

binding.root.setOnClickListener { dismiss() }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.mankart.mankgram.ui.mainmenu.home

import android.animation.ObjectAnimator
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.*
Expand All @@ -21,6 +23,7 @@ class HomeFragment : Fragment() {
private val homeViewModel: HomeViewModel by activityViewModels { factory }
private var _binding: FragmentHomeBinding? = null
private lateinit var listStoryAdapter: ListStoryAdapter
private var hideNavView = false

// This property is only valid between onCreateView and
// onDestroyView.
Expand Down Expand Up @@ -51,12 +54,43 @@ class HomeFragment : Fragment() {

factory = ViewModelFactory.getInstance(requireActivity())

binding.refreshLayout.isRefreshing = true
binding.refreshLayout.setOnRefreshListener {
listStoryAdapter.refresh()
}
fetchUserStories()

initObserve()

val navView = requireActivity().findViewById<View>(R.id.nav_view)
if (navView != null) {
hideShowBottomNavigation(navView)
}

}

private fun hideShowBottomNavigation(navView: View) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
binding.rvStory.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
val height = (navView.height + 32).toFloat()

if (!hideNavView && scrollY > oldScrollY) {
hideNavView = true
ObjectAnimator.ofFloat(navView, "translationY", 0f, height).apply {
duration = 200
start()
}
}

if (hideNavView && scrollY < oldScrollY) {
hideNavView = false
ObjectAnimator.ofFloat(navView, "translationY", height, 0f).apply {
duration = 200
start()
}
}
}
}
}

private fun fetchUserStories() {
Expand Down Expand Up @@ -92,10 +126,6 @@ class HomeFragment : Fragment() {
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}

override fun onDestroy() {
super.onDestroy()
listStoryAdapter.submitData(lifecycle, PagingData.empty())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class SettingFragment : Fragment() {

binding.btnLogout.setOnClickListener {
authenticationViewModel.logout()
settingViewModel.saveIsFirstTime(false)
startActivity(Intent(activity, AuthenticationActivity::class.java))
activity?.finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.transition.TransitionManager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import com.bumptech.glide.Glide
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.mankart.mankgram.R
Expand All @@ -29,20 +30,29 @@ class DialogDetailStoryFragment : BottomSheetDialogFragment() {
super.onViewCreated(view, savedInstanceState)

val bundle = DialogDetailStoryFragmentArgs.fromBundle(arguments as Bundle)
binding.include.storyName.text = bundle.name
binding.include.storyDescription.text = bundle.description

Glide.with(requireActivity())
.load(bundle.image)
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.placeholder_image)
.into(binding.include.storyImage)
binding.include.apply {
storyName.text = bundle.name
storyDescription.text = bundle.description

var isExpanded = false
Glide.with(requireActivity())
.load(bundle.image)
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.placeholder_image)
.into(storyImage)

binding.include.tvDetail.setOnClickListener {
TransitionManager.beginDelayedTransition(binding.root as ViewGroup)
binding.include.apply {
storyImage.setOnClickListener {
val toDetailImageFragment =
DialogDetailStoryFragmentDirections.actionDialogDetailStoryFragmentToDetailImageFragment2(
bundle.image
)
findNavController().navigate(toDetailImageFragment)
}

var isExpanded = false

tvDetail.setOnClickListener {
TransitionManager.beginDelayedTransition(binding.root as ViewGroup)
when (isExpanded) {
true -> {
storyDescription.visibility = View.GONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.os.Looper
import java.util.concurrent.Executor
import java.util.concurrent.Executors

// Kode ini nantinya akan saya gunakan kembali untuk membuat threading
class AppExecutors {
val diskIO: Executor = Executors.newSingleThreadExecutor()
val networkIO: Executor = Executors.newFixedThreadPool(3)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_detail_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@tools:sample/avatars"/>

</androidx.constraintlayout.widget.ConstraintLayout>
13 changes: 13 additions & 0 deletions app/src/main/res/navigation/map_option_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,18 @@
android:name="image"
app:argType="string"
app:nullable="true" />
<action
android:id="@+id/action_dialogDetailStoryFragment_to_detailImageFragment2"
app:destination="@id/detailImageFragment2" />
</dialog>
<dialog
android:id="@+id/detailImageFragment2"
android:name="com.mankart.mankgram.ui.mainmenu.home.DetailImageFragment"
android:label="fragment_detail_image"
tools:layout="@layout/fragment_detail_image" >
<argument
android:name="image"
app:argType="string"
app:nullable="true" />
</dialog>
</navigation>

0 comments on commit 6eaba9d

Please sign in to comment.