Skip to content

Commit

Permalink
Improved dashboard UI/UX
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjoongcho committed Oct 29, 2023
1 parent 8440d1b commit 438b23f
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 92 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
applicationId "me.blog.korn123.easydiary"
minSdkVersion 19
targetSdkVersion versions.compileSdk
versionCode 303
versionName '1.4.303.202310160'
versionCode 304
versionName '1.4.304.202311xx0'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package me.blog.korn123.easydiary.activities

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View
import com.zhpan.bannerview.constants.PageStyle
import me.blog.korn123.commons.utils.FontUtils
import me.blog.korn123.easydiary.R
import me.blog.korn123.easydiary.databinding.ActivityDashboardBinding
import me.blog.korn123.easydiary.extensions.*
import me.blog.korn123.easydiary.fragments.*
import me.blog.korn123.easydiary.fragments.PhotoHighlightFragment.Companion.PAGE_MARGIN
import me.blog.korn123.easydiary.fragments.PhotoHighlightFragment.Companion.PAGE_STYLE
import me.blog.korn123.easydiary.fragments.PhotoHighlightFragment.Companion.REVEAL_WIDTH
import me.blog.korn123.easydiary.helper.TransitionHelper

/**
* Created by CHO HANJOONG on 2017-03-16.
Expand All @@ -22,6 +27,7 @@ class DashboardActivity : EasyDiaryActivity() {
*
***************************************************************************************************/
private lateinit var mBinding: ActivityDashboardBinding
private lateinit var mDailySymbolFragment: DailySymbolFragment


/***************************************************************************************************
Expand All @@ -41,8 +47,17 @@ class DashboardActivity : EasyDiaryActivity() {
setDisplayHomeAsUpEnabled(true)
}


mDailySymbolFragment = DailySymbolFragment()
mBinding.close.setOnClickListener { view ->
view.postDelayed({
TransitionHelper.finishActivityWithTransition(this)
}, 300)

}

supportFragmentManager.beginTransaction().run {
// PhotoHighlight
// 01. PhotoHighlight
replace(R.id.photoHighlight, PhotoHighlightFragment().apply {
arguments = Bundle().apply {
putInt(PAGE_STYLE, PageStyle.MULTI_PAGE_SCALE)
Expand All @@ -55,121 +70,147 @@ class DashboardActivity : EasyDiaryActivity() {
}
})

// DDay
// replace(R.id.dDay, DDayFragment())
// 02. DDay
replace(R.id.dDay, DDayFragment())

// DashBoardSummary
replace(R.id.summary, DashBoardSummaryFragment())

// Daily Symbol
replace(R.id.dashboard_daily_symbol, DailySymbolFragment())
// 03. TODO
replace(R.id.fragment_diary_todo, DiaryFragment().apply {
arguments = Bundle().apply {
putString(DiaryFragment.MODE_FLAG, DiaryFragment.MODE_TASK_TODO)
}
})

// Commit
commit()
}
// 04. DONE
replace(R.id.fragment_diary_done, DiaryFragment().apply {
arguments = Bundle().apply {
putString(DiaryFragment.MODE_FLAG, DiaryFragment.MODE_TASK_DONE)
}
})

mBinding.run {
getDashboardCardWidth(0.9F).also {
lifetime.layoutParams.width = it
lastMonth.layoutParams.width = it
lastWeek.layoutParams.width = it
}
// 05. Future Diary
replace(R.id.fragment_diary_future, DiaryFragment().apply {
arguments = Bundle().apply {
putString(DiaryFragment.MODE_FLAG, DiaryFragment.MODE_FUTURE)
}
})

getDashboardCardWidth(0.95F).also {
statistics1.layoutParams.width = it
statistics2.layoutParams.width = it
statistics3.layoutParams.width = it
statistics4.layoutParams.width = it
statistics5.layoutParams.width = it
if (isLandScape()) {
val height = getDefaultDisplay().y - statusBarHeight() - actionBarHeight()
statistics1.layoutParams.height = height
statistics2.layoutParams.height = height
statistics3.layoutParams.height = height
statistics4.layoutParams.height = height
statistics5.layoutParams.height = height
// 06. Diary Previous 100
replace(R.id.fragment_diary_previous100, DiaryFragment().apply {
arguments = Bundle().apply {
putString(DiaryFragment.MODE_FLAG, DiaryFragment.MODE_PREVIOUS_100)
}
}
}
})

supportFragmentManager.beginTransaction().run {
// 07. DashBoardSummary
replace(R.id.summary, DashBoardSummaryFragment())

// 08. Daily Symbol
replace(R.id.dashboard_daily_symbol, mDailySymbolFragment)

// 09. DashBoardRank-Lifetime
replace(R.id.lifetime, DashBoardRankFragment().apply {
val args = Bundle()
args.putString(DashBoardRankFragment.MODE_FLAG, DashBoardRankFragment.MODE_LIFETIME)
args.putString(
DashBoardRankFragment.MODE_FLAG,
DashBoardRankFragment.MODE_LIFETIME
)
arguments = args
})
commit()
}

supportFragmentManager.beginTransaction().run {
// 10. DashBoardRank-LastMonth
replace(R.id.lastMonth, DashBoardRankFragment().apply {
val args = Bundle()
args.putString(DashBoardRankFragment.MODE_FLAG, DashBoardRankFragment.MODE_LAST_MONTH)
args.putString(
DashBoardRankFragment.MODE_FLAG,
DashBoardRankFragment.MODE_LAST_MONTH
)
arguments = args
})
commit()
}

supportFragmentManager.beginTransaction().run {
// 11. DashBoardRank-LastWeek
replace(R.id.lastWeek, DashBoardRankFragment().apply {
val args = Bundle()
args.putString(DashBoardRankFragment.MODE_FLAG, DashBoardRankFragment.MODE_LAST_WEEK)
args.putString(
DashBoardRankFragment.MODE_FLAG,
DashBoardRankFragment.MODE_LAST_WEEK
)
arguments = args
})
commit()
}

val chartTitle = getString(R.string.statistics_creation_time)
supportFragmentManager.beginTransaction().run {
// 12. Statistics-Creation Time
val chartTitle = getString(R.string.statistics_creation_time)
replace(R.id.statistics1, WritingBarChartFragment().apply {
val args = Bundle()
args.putString(WritingBarChartFragment.CHART_TITLE, chartTitle)
arguments = args
})
commit()
}

val symbolAllTitle = getString(R.string.statistics_symbol_all)
supportFragmentManager.beginTransaction().run {
// 13. Statistics-Symbol All
val symbolAllTitle = getString(R.string.statistics_symbol_all)
replace(R.id.statistics2, SymbolBarChartFragment().apply {
val args = Bundle()
args.putString(WritingBarChartFragment.CHART_TITLE, symbolAllTitle)
arguments = args
})
commit()
}

val symbolTopTenTitle = getString(R.string.statistics_symbol_top_ten)
supportFragmentManager.beginTransaction().run {
// 14. Statistics-Symbol TopTen
val symbolTopTenTitle = getString(R.string.statistics_symbol_top_ten)
replace(R.id.statistics3, SymbolHorizontalBarChartFragment().apply {
val args = Bundle()
args.putString(WritingBarChartFragment.CHART_TITLE, symbolTopTenTitle)
arguments = args
})
commit()
}

if (config.enableDebugOptionVisibleChartWeight) {
mBinding.statistics4.visibility = View.VISIBLE
supportFragmentManager.beginTransaction().run {
// 15. Chart Weight
if (config.enableDebugOptionVisibleChartWeight) {
mBinding.statistics4.visibility = View.VISIBLE
replace(R.id.statistics4, WeightLineChartFragment().apply {
val args = Bundle()
args.putString(WritingBarChartFragment.CHART_TITLE, "Weight")
arguments = args
})
commit()
}
}

if (config.enableDebugOptionVisibleChartStock) {
mBinding.statistics5.visibility = View.VISIBLE
supportFragmentManager.beginTransaction().run {
// 16. Chart Stock
if (config.enableDebugOptionVisibleChartStock) {
mBinding.statistics5.visibility = View.VISIBLE
replace(R.id.statistics5, StockLineChartFragment().apply {
val args = Bundle()
args.putString(WritingBarChartFragment.CHART_TITLE, "Stock")
arguments = args
})
commit()
}
// Commit
commit()
}

mBinding.run {
getDashboardCardWidth(0.9F).also {
lifetime.layoutParams.width = it
lastMonth.layoutParams.width = it
lastWeek.layoutParams.width = it
}

getDashboardCardWidth(0.95F).also {
statistics1.layoutParams.width = it
statistics2.layoutParams.width = it
statistics3.layoutParams.width = it
statistics4.layoutParams.width = it
statistics5.layoutParams.width = it
if (isLandScape()) {
val height = getDefaultDisplay().y - statusBarHeight() - actionBarHeight()
statistics1.layoutParams.height = height
statistics2.layoutParams.height = height
statistics3.layoutParams.height = height
statistics4.layoutParams.height = height
statistics5.layoutParams.height = height
}
}

insertDiaryButton.post { insertDiaryButton.visibility = View.VISIBLE }
insertDiaryButton.setOnClickListener {
val createDiary = Intent(this@DashboardActivity, DiaryWritingActivity::class.java)
TransitionHelper.startActivityWithTransition(this@DashboardActivity, createDiary)
}
}

Expand Down Expand Up @@ -205,9 +246,49 @@ class DashboardActivity : EasyDiaryActivity() {
// }
// }

override fun onResume() {
super.onResume()
mBinding.run {
layoutProgressContainer.visibility = View.VISIBLE
progress.visibility = View.VISIBLE
// root.setBackgroundColor(getDashboardBackgroundColor())
// requireActivity().updateTextColors(root)
// requireActivity().updateAppViews(root)
// FontUtils.setFontsTypeface(requireContext(), null, root, true)
}

Handler(Looper.getMainLooper()).postDelayed({
mBinding.run {
// Diary Update
mDailySymbolFragment.updateDailySymbol()

// FIXME:
// This is workaround.
// For pages that are invisible but have already been loaded, it will not be updated.
mDailySymbolFragment.mCalendarFragment.refreshViewOnlyCurrentPage()

Handler(Looper.getMainLooper()).postDelayed({
layoutProgressContainer.visibility = View.GONE
progress.visibility = View.GONE
}, 300)
}
}, 300)
}


/***************************************************************************************************
* etc functions
*
***************************************************************************************************/
fun showProgressContainer() {
mBinding.layoutProgressContainer.visibility = View.VISIBLE
mBinding.progress.visibility = View.VISIBLE
}

fun hideProgressContainer() {
Handler(Looper.getMainLooper()).postDelayed({
mBinding.layoutProgressContainer.visibility = View.GONE
mBinding.progress.visibility = View.GONE
}, 300)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,16 @@ class DiaryMainActivity : ToolbarControlBaseActivity<FastScrollObservableRecycle
}
R.id.microphone -> showSpeechDialog()
R.id.openDashboard -> {
DashboardDialogFragment().apply {
show(
supportFragmentManager,
"DashboardDialog"
)
}
// DashboardDialogFragment().apply {
// show(
// supportFragmentManager,
// "DashboardDialog"
// )
// }
TransitionHelper.startActivityWithTransition(
this@DiaryMainActivity,
Intent(this@DiaryMainActivity, DashboardActivity::class.java)
)
}
R.id.popupMenu -> openCustomOptionMenu()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package me.blog.korn123.easydiary.adapters

import android.app.Activity
import android.graphics.Color
import android.os.Handler
import android.os.Looper
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
Expand Down
Loading

0 comments on commit 438b23f

Please sign in to comment.