From afc737b3a50f4fe5473f267bc52720ca35008104 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 8 Jan 2023 17:03:26 +0100 Subject: [PATCH] start rewriting the top menu to a search bar --- app/build.gradle | 2 +- .../calendar/pro/activities/MainActivity.kt | 34 +- .../pro/adapters/MyYearPagerAdapter.kt | 4 +- .../pro/fragments/DayFragmentsHolder.kt | 5 - .../pro/fragments/EventListFragment.kt | 5 - .../pro/fragments/MonthDayFragmentsHolder.kt | 5 - .../pro/fragments/MonthFragmentsHolder.kt | 5 - .../pro/fragments/MyFragmentHolder.kt | 2 - .../pro/fragments/WeekFragmentsHolder.kt | 28 +- .../calendar/pro/fragments/YearFragment.kt | 49 +- .../pro/fragments/YearFragmentsHolder.kt | 30 +- .../calendar/pro/helpers/Formatter.kt | 2 + .../calendar/pro/views/WeeklyViewGrid.kt | 2 +- .../main/res/layout-land/fragment_year.xml | 559 +++++++++--------- app/src/main/res/layout/activity_main.xml | 22 +- app/src/main/res/layout/fragment_month.xml | 3 +- .../main/res/layout/fragment_month_widget.xml | 2 +- app/src/main/res/layout/fragment_week.xml | 50 +- .../main/res/layout/fragment_week_holder.xml | 27 + app/src/main/res/layout/fragment_year.xml | 541 ++++++++--------- app/src/main/res/layout/top_navigation.xml | 6 +- .../res/layout/weekly_view_hour_textview.xml | 4 +- app/src/main/res/menu/menu_main.xml | 6 - 23 files changed, 719 insertions(+), 674 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0cb5bb5e7..712b72851 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -70,7 +70,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:71f9297e2e' + implementation 'com.github.SimpleMobileTools:Simple-Commons:a064515a00' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt index 1cfdb9754..e78dde0e7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt @@ -90,6 +90,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { appLaunched(BuildConfig.APPLICATION_ID) setupOptionsMenu() refreshMenuItems() + updateMaterialActivityViews(main_coordinator, main_holder, useTransparentNavigation = false, useTopSearchMenu = true) checkWhatsNewDialog() calendar_fab.beVisibleIf(config.storedView != YEARLY_VIEW && config.storedView != WEEKLY_VIEW) @@ -182,6 +183,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { } } + updateStatusbarColor(getProperBackgroundColor()) + main_menu.updateColors() storeStateVariables() updateWidgets() updateTextColors(calendar_coordinator) @@ -196,16 +199,15 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { checkSwipeRefreshAvailability() checkShortcuts() - setupToolbar(main_toolbar, searchMenuItem = mSearchMenuItem) if (!mIsSearchOpen) { refreshMenuItems() } setupQuickFilter() - main_toolbar.setNavigationOnClickListener { + /*main_toolbar.setNavigationOnClickListener { onBackPressed() - } + }*/ if (config.caldavSync) { updateCalDAVEvents() @@ -231,7 +233,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { } shouldGoToTodayBeVisible = currentFragments.lastOrNull()?.shouldGoToTodayBeVisible() ?: false - main_toolbar.menu.apply { + main_menu.getToolbar().menu.apply { goToTodayButton = findItem(R.id.go_to_today) findItem(R.id.print).isVisible = config.storedView != MONTHLY_DAILY_VIEW findItem(R.id.filter).isVisible = mShouldFilterBeVisible @@ -243,8 +245,10 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { } private fun setupOptionsMenu() { - setupSearch(main_toolbar.menu) - main_toolbar.setOnMenuItemClickListener { menuItem -> + main_menu.getToolbar().inflateMenu(R.menu.menu_main) + main_menu.toggleHideOnScroll(false) + main_menu.setupMenu() + main_menu.getToolbar().setOnMenuItemClickListener { menuItem -> if (fab_extended_overlay.isVisible()) { hideExtendedFab() } @@ -539,17 +543,12 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { currentFragments.last().printView() } - private fun resetActionBarTitle() { - main_toolbar.title = getString(R.string.app_launcher_name) - main_toolbar.subtitle = "" + fun resetActionBarTitle() { + main_menu.updateHintText(getString(R.string.search)) } fun updateTitle(text: String) { - main_toolbar.title = text - } - - fun updateSubtitle(text: String) { - main_toolbar.subtitle = text + main_menu.updateHintText(text) } private fun showFilterDialog() { @@ -948,7 +947,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { fragment.arguments = bundle supportFragmentManager.beginTransaction().add(R.id.fragments_holder, fragment).commitNow() - main_toolbar.navigationIcon = null + //main_toolbar.navigationIcon = null } private fun fixDayCode(dayCode: String? = null): String? = when { @@ -1043,18 +1042,17 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { toggleGoToTodayVisibility(currentFragments.last().shouldGoToTodayBeVisible()) currentFragments.last().apply { refreshEvents() - updateActionBarTitle() } calendar_fab.beGoneIf(currentFragments.size == 1 && config.storedView == YEARLY_VIEW) if (currentFragments.size > 1) { showBackNavigationArrow() } else { - main_toolbar.navigationIcon = null + //main_toolbar.navigationIcon = null } } private fun showBackNavigationArrow() { - main_toolbar.navigationIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, getProperStatusBarColor().getContrastColor()) + //main_toolbar.navigationIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, getProperStatusBarColor().getContrastColor()) } private fun refreshViewPager() { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/MyYearPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/MyYearPagerAdapter.kt index f57fc7d9f..750d8f8c3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/MyYearPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/MyYearPagerAdapter.kt @@ -7,8 +7,9 @@ import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter import com.simplemobiletools.calendar.pro.fragments.YearFragment import com.simplemobiletools.calendar.pro.helpers.YEAR_LABEL +import com.simplemobiletools.calendar.pro.interfaces.NavigationListener -class MyYearPagerAdapter(fm: FragmentManager, val mYears: List) : FragmentStatePagerAdapter(fm) { +class MyYearPagerAdapter(fm: FragmentManager, val mYears: List, private val mListener: NavigationListener) : FragmentStatePagerAdapter(fm) { private val mFragments = SparseArray() override fun getCount() = mYears.size @@ -20,6 +21,7 @@ class MyYearPagerAdapter(fm: FragmentManager, val mYears: List) : FragmentS val fragment = YearFragment() fragment.arguments = bundle + fragment.listener = mListener mFragments.put(position, fragment) return fragment diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/DayFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/DayFragmentsHolder.kt index a57ba9c0a..5e366b91b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/DayFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/DayFragmentsHolder.kt @@ -74,7 +74,6 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener { }) currentItem = defaultDailyPage } - updateActionBarTitle() } private fun getDays(code: String): List { @@ -134,10 +133,6 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener { override fun shouldGoToTodayBeVisible() = currentDayCode != todayDayCode - override fun updateActionBarTitle() { - (activity as MainActivity).updateTitle(getString(R.string.app_launcher_name)) - } - override fun getNewEventDayCode() = currentDayCode override fun printView() { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/EventListFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/EventListFragment.kt index 4f0f4c16b..fd542912a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/EventListFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/EventListFragment.kt @@ -62,7 +62,6 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener { } use24HourFormat = requireContext().config.use24HourFormat - updateActionBarTitle() return mView } @@ -230,10 +229,6 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener { override fun shouldGoToTodayBeVisible() = hasBeenScrolled - override fun updateActionBarTitle() { - (activity as? MainActivity)?.updateTitle(getString(R.string.app_launcher_name)) - } - override fun getNewEventDayCode() = Formatter.getTodayCode() override fun printView() { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthDayFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthDayFragmentsHolder.kt index fd3314c71..e996aca15 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthDayFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthDayFragmentsHolder.kt @@ -72,7 +72,6 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener { }) currentItem = defaultMonthlyPage } - updateActionBarTitle() } private fun getMonths(code: String): List { @@ -133,10 +132,6 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener { override fun shouldGoToTodayBeVisible() = currentDayCode.getMonthCode() != todayDayCode.getMonthCode() - override fun updateActionBarTitle() { - (activity as? MainActivity)?.updateTitle(getString(R.string.app_launcher_name)) - } - override fun getNewEventDayCode() = (viewPager?.adapter as? MyMonthDayPagerAdapter)?.getNewEventDayCode(viewPager?.currentItem ?: 0) ?: if (shouldGoToTodayBeVisible()) { currentDayCode diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthFragmentsHolder.kt index 2e546c055..b378b4e92 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthFragmentsHolder.kt @@ -72,7 +72,6 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener { }) currentItem = defaultMonthlyPage } - updateActionBarTitle() } private fun getMonths(code: String): List { @@ -133,10 +132,6 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener { override fun shouldGoToTodayBeVisible() = currentDayCode.getMonthCode() != todayDayCode.getMonthCode() - override fun updateActionBarTitle() { - (activity as? MainActivity)?.updateTitle(getString(R.string.app_launcher_name)) - } - override fun getNewEventDayCode() = if (shouldGoToTodayBeVisible()) currentDayCode else todayDayCode override fun printView() { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MyFragmentHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MyFragmentHolder.kt index 12c707f6a..914b75799 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MyFragmentHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MyFragmentHolder.kt @@ -14,8 +14,6 @@ abstract class MyFragmentHolder : Fragment() { abstract fun shouldGoToTodayBeVisible(): Boolean - abstract fun updateActionBarTitle() - abstract fun getNewEventDayCode(): String abstract fun printView() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt index 551e161f6..21f9d8372 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt @@ -48,8 +48,11 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener { } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + val textColor = requireContext().getProperTextColor() weekHolder = inflater.inflate(R.layout.fragment_week_holder, container, false) as ViewGroup weekHolder!!.background = ColorDrawable(requireContext().getProperBackgroundColor()) + weekHolder!!.week_view_month_label.setTextColor(textColor) + weekHolder!!.week_view_week_number.setTextColor(textColor) val itemHeight = requireContext().getWeeklyViewItemHeight().toInt() weekHolder!!.week_view_hours_holder.setPadding(0, 0, 0, itemHeight) @@ -88,7 +91,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener { } } - updateActionBarTitle() + setupWeeklyActionbarTitle(currentWeekTS) } private fun setupWeeklyViewPager() { @@ -131,7 +134,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener { weekHolder!!.week_view_hours_holder.removeAllViews() val hourDateTime = DateTime().withDate(2000, 1, 1).withTime(0, 0, 0, 0) for (i in 1..23) { - val formattedHours = Formatter.getHours(requireContext(), hourDateTime.withHourOfDay(i)) + val formattedHours = Formatter.getTime(requireContext(), hourDateTime.withHourOfDay(i)) (layoutInflater.inflate(R.layout.weekly_view_hour_textview, null, false) as TextView).apply { text = formattedHours setTextColor(textColor) @@ -155,19 +158,10 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener { private fun setupWeeklyActionbarTitle(timestamp: Long) { val startDateTime = Formatter.getDateTimeFromTS(timestamp) - val endDateTime = Formatter.getDateTimeFromTS(timestamp + WEEK_SECONDS) - val startMonthName = Formatter.getMonthName(requireContext(), startDateTime.monthOfYear) - if (startDateTime.monthOfYear == endDateTime.monthOfYear) { - var newTitle = startMonthName - if (startDateTime.year != DateTime().year) { - newTitle += " - ${startDateTime.year}" - } - (activity as MainActivity).updateTitle(newTitle) - } else { - val endMonthName = Formatter.getMonthName(requireContext(), endDateTime.monthOfYear) - (activity as MainActivity).updateTitle("$startMonthName - $endMonthName") - } - (activity as MainActivity).updateSubtitle("${getString(R.string.week)} ${startDateTime.plusDays(3).weekOfWeekyear}") + val month = Formatter.getShortMonthName(requireContext(), startDateTime.monthOfYear) + weekHolder!!.week_view_month_label.text = month + val weekNumber = startDateTime.plusDays(3).weekOfWeekyear + weekHolder!!.week_view_week_number.text = "${getString(R.string.week_number_short)} $weekNumber" } override fun goToToday() { @@ -243,10 +237,6 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener { override fun shouldGoToTodayBeVisible() = currentWeekTS != thisWeekTS - override fun updateActionBarTitle() { - setupWeeklyActionbarTitle(currentWeekTS) - } - override fun getNewEventDayCode(): String { val currentTS = System.currentTimeMillis() / 1000 return if (currentTS > currentWeekTS && currentTS < currentWeekTS + WEEK_SECONDS) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragment.kt index fb73259b0..79bff328c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragment.kt @@ -14,13 +14,16 @@ import com.simplemobiletools.calendar.pro.extensions.getViewBitmap import com.simplemobiletools.calendar.pro.extensions.printBitmap import com.simplemobiletools.calendar.pro.helpers.YEAR_LABEL import com.simplemobiletools.calendar.pro.helpers.YearlyCalendarImpl +import com.simplemobiletools.calendar.pro.interfaces.NavigationListener import com.simplemobiletools.calendar.pro.interfaces.YearlyCalendar import com.simplemobiletools.calendar.pro.models.DayYearly import com.simplemobiletools.calendar.pro.views.SmallMonthView +import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.getProperPrimaryColor import com.simplemobiletools.commons.extensions.getProperTextColor import com.simplemobiletools.commons.extensions.updateTextColors import kotlinx.android.synthetic.main.fragment_year.view.* +import kotlinx.android.synthetic.main.top_navigation.view.* import org.joda.time.DateTime class YearFragment : Fragment(), YearlyCalendar { @@ -30,13 +33,16 @@ class YearFragment : Fragment(), YearlyCalendar { private var lastHash = 0 private var mCalendar: YearlyCalendarImpl? = null + var listener: NavigationListener? = null + lateinit var mView: View override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { mView = inflater.inflate(R.layout.fragment_year, container, false) mYear = requireArguments().getInt(YEAR_LABEL) - requireContext().updateTextColors(mView.calendar_holder) + requireContext().updateTextColors(mView.calendar_wrapper) setupMonths() + setupButtons() mCalendar = YearlyCalendarImpl(this, requireContext(), mYear) return mView @@ -94,6 +100,40 @@ class YearFragment : Fragment(), YearlyCalendar { } } + private fun setupButtons() { + val textColor = requireContext().getProperTextColor() + mView.top_left_arrow.apply { + applyColorFilter(textColor) + background = null + setOnClickListener { + listener?.goLeft() + } + + val pointerLeft = requireContext().getDrawable(R.drawable.ic_chevron_left_vector) + pointerLeft?.isAutoMirrored = true + setImageDrawable(pointerLeft) + } + + mView.top_right_arrow.apply { + applyColorFilter(textColor) + background = null + setOnClickListener { + listener?.goRight() + } + + val pointerRight = requireContext().getDrawable(R.drawable.ic_chevron_right_vector) + pointerRight?.isAutoMirrored = true + setImageDrawable(pointerRight) + } + + mView.top_value.apply { + setTextColor(requireContext().getProperTextColor()) + setOnClickListener { + (activity as MainActivity).showGoToDateDialog() + } + } + } + private fun markCurrentMonth(now: DateTime) { if (now.year == mYear) { val monthLabel = mView.findViewById(resources.getIdentifier("month_${now.monthOfYear}_label", "id", requireContext().packageName)) @@ -105,8 +145,9 @@ class YearFragment : Fragment(), YearlyCalendar { } override fun updateYearlyCalendar(events: SparseArray>, hashCode: Int) { - if (!isAdded) + if (!isAdded) { return + } if (hashCode == lastHash) { return @@ -117,6 +158,8 @@ class YearFragment : Fragment(), YearlyCalendar { val monthView = mView.findViewById(resources.getIdentifier("month_$i", "id", requireContext().packageName)) monthView.setEvents(events.get(i)) } + + mView.top_value.text = mYear.toString() } fun printCurrentView() { @@ -124,7 +167,7 @@ class YearFragment : Fragment(), YearlyCalendar { setupMonths() toggleSmallMonthPrintModes() - requireContext().printBitmap(mView.calendar_holder.getViewBitmap()) + requireContext().printBitmap(mView.calendar_wrapper.getViewBitmap()) isPrintVersion = false setupMonths() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragmentsHolder.kt index 21b9f58b6..0faf54e80 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragmentsHolder.kt @@ -14,13 +14,14 @@ import com.simplemobiletools.calendar.pro.adapters.MyYearPagerAdapter import com.simplemobiletools.calendar.pro.helpers.Formatter import com.simplemobiletools.calendar.pro.helpers.YEARLY_VIEW import com.simplemobiletools.calendar.pro.helpers.YEAR_TO_OPEN +import com.simplemobiletools.calendar.pro.interfaces.NavigationListener import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.views.MyViewPager import kotlinx.android.synthetic.main.fragment_years_holder.view.* import org.joda.time.DateTime import kotlin.text.toInt -class YearFragmentsHolder : MyFragmentHolder() { +class YearFragmentsHolder : MyFragmentHolder(), NavigationListener { private val PREFILLED_YEARS = 61 private var viewPager: MyViewPager? = null @@ -49,17 +50,15 @@ class YearFragmentsHolder : MyFragmentHolder() { private fun setupFragment() { val years = getYears(currentYear) - val yearlyAdapter = MyYearPagerAdapter(requireActivity().supportFragmentManager, years) + val yearlyAdapter = MyYearPagerAdapter(requireActivity().supportFragmentManager, years, this) defaultYearlyPage = years.size / 2 viewPager?.apply { adapter = yearlyAdapter addOnPageChangeListener(object : ViewPager.OnPageChangeListener { - override fun onPageScrollStateChanged(state: Int) { - } + override fun onPageScrollStateChanged(state: Int) {} - override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { - } + override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {} override fun onPageSelected(position: Int) { currentYear = years[position] @@ -68,15 +67,10 @@ class YearFragmentsHolder : MyFragmentHolder() { (activity as? MainActivity)?.toggleGoToTodayVisibility(shouldGoToTodayBeVisible) isGoToTodayVisible = shouldGoToTodayBeVisible } - - if (position < years.size) { - (activity as? MainActivity)?.updateTitle("${getString(R.string.app_launcher_name)} - ${years[position]}") - } } }) currentItem = defaultYearlyPage } - updateActionBarTitle() } private fun getYears(targetYear: Int): List { @@ -85,6 +79,16 @@ class YearFragmentsHolder : MyFragmentHolder() { return years } + override fun goLeft() { + viewPager!!.currentItem = viewPager!!.currentItem - 1 + } + + override fun goRight() { + viewPager!!.currentItem = viewPager!!.currentItem + 1 + } + + override fun goToDateTime(dateTime: DateTime) {} + override fun goToToday() { currentYear = todayYear setupFragment() @@ -122,10 +126,6 @@ class YearFragmentsHolder : MyFragmentHolder() { override fun shouldGoToTodayBeVisible() = currentYear != todayYear - override fun updateActionBarTitle() { - (activity as? MainActivity)?.updateTitle("${getString(R.string.app_launcher_name)} - $currentYear") - } - override fun getNewEventDayCode() = Formatter.getTodayCode() override fun printView() { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Formatter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Formatter.kt index 50e12f4a3..9958dbe66 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Formatter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Formatter.kt @@ -115,6 +115,8 @@ object Formatter { // use manually translated month names, as DateFormat and Joda have issues with a lot of languages fun getMonthName(context: Context, id: Int) = context.resources.getStringArray(R.array.months)[id - 1] + fun getShortMonthName(context: Context, id: Int) = context.resources.getStringArray(R.array.months_short)[id - 1] + fun getHourPattern(context: Context) = if (context.config.use24HourFormat) PATTERN_HOURS_24 else PATTERN_HOURS_12 fun getTimePattern(context: Context) = if (context.config.use24HourFormat) PATTERN_TIME_24 else PATTERN_TIME_12 diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/WeeklyViewGrid.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/WeeklyViewGrid.kt index 6146e02df..f3c7d8c64 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/WeeklyViewGrid.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/WeeklyViewGrid.kt @@ -24,7 +24,7 @@ class WeeklyViewGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie super.onDraw(canvas) val rowHeight = context.getWeeklyViewItemHeight() for (i in 0 until ROWS_CNT) { - val y = rowHeight * i.toFloat() + val y = rowHeight * i.toFloat() - i / 2 canvas.drawLine(0f, y, width.toFloat(), y, paint) } diff --git a/app/src/main/res/layout-land/fragment_year.xml b/app/src/main/res/layout-land/fragment_year.xml index d337ff05e..cd42461fc 100644 --- a/app/src/main/res/layout-land/fragment_year.xml +++ b/app/src/main/res/layout-land/fragment_year.xml @@ -1,325 +1,334 @@ - + android:layout_height="match_parent"> - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + android:layout_marginEnd="@dimen/yearly_padding_full" + android:layout_weight="1"> - - + - + - + - - - + android:layout_marginStart="@dimen/yearly_padding_half" + android:layout_marginEnd="@dimen/yearly_padding_half" + android:layout_weight="1"> - + - + - + - + android:layout_marginStart="@dimen/yearly_padding_full" + android:layout_weight="1"> - + - + - + - + android:layout_marginEnd="@dimen/yearly_padding_full" + android:layout_weight="1"> - + - + - + + - + + + android:layout_marginStart="@dimen/yearly_padding_half" + android:layout_marginEnd="@dimen/yearly_padding_half" + android:layout_weight="1"> - - + - + - + - - - + android:layout_marginStart="@dimen/yearly_padding_full" + android:layout_weight="1"> - + - + - + - + android:layout_marginEnd="@dimen/yearly_padding_full" + android:layout_weight="1"> - + - + - + - + android:layout_marginStart="@dimen/yearly_padding_half" + android:layout_marginEnd="@dimen/yearly_padding_half" + android:layout_weight="1"> - + - + - + + - + + + android:layout_marginStart="@dimen/yearly_padding_full" + android:layout_weight="1"> - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 6c779a0de..cb2f2829c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -5,29 +5,21 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - + android:layout_height="wrap_content" /> + android:layout_marginTop="?attr/actionBarSize" + android:fillViewport="true" + android:scrollbars="none"> diff --git a/app/src/main/res/layout/fragment_month.xml b/app/src/main/res/layout/fragment_month.xml index c2db1c7ab..59950bc63 100644 --- a/app/src/main/res/layout/fragment_month.xml +++ b/app/src/main/res/layout/fragment_month.xml @@ -2,8 +2,7 @@ + android:layout_height="match_parent"> diff --git a/app/src/main/res/layout/fragment_month_widget.xml b/app/src/main/res/layout/fragment_month_widget.xml index 2799c821b..cb7c177ff 100644 --- a/app/src/main/res/layout/fragment_month_widget.xml +++ b/app/src/main/res/layout/fragment_month_widget.xml @@ -1,7 +1,7 @@ diff --git a/app/src/main/res/layout/fragment_week.xml b/app/src/main/res/layout/fragment_week.xml index 56f4f5cdf..39bbb692b 100644 --- a/app/src/main/res/layout/fragment_week.xml +++ b/app/src/main/res/layout/fragment_week.xml @@ -4,6 +4,31 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + + + + + + + - - - - - - - - diff --git a/app/src/main/res/layout/fragment_week_holder.xml b/app/src/main/res/layout/fragment_week_holder.xml index 3e932a9da..0645020f5 100644 --- a/app/src/main/res/layout/fragment_week_holder.xml +++ b/app/src/main/res/layout/fragment_week_holder.xml @@ -14,6 +14,33 @@ android:background="@drawable/stroke_bottom_right" android:importantForAccessibility="no" /> + + + + - + android:layout_height="match_parent"> - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:layout_marginEnd="@dimen/yearly_padding_full" + android:layout_weight="1"> - + - + - + - + android:layout_marginStart="@dimen/yearly_padding_half" + android:layout_marginEnd="@dimen/yearly_padding_half" + android:layout_weight="1"> - + - + - + - + android:layout_marginStart="@dimen/yearly_padding_full" + android:layout_weight="1"> - - + - + - + + - + - + android:layout_marginEnd="@dimen/yearly_padding_full" + android:layout_weight="1"> - + - + - + - + android:layout_marginStart="@dimen/yearly_padding_half" + android:layout_marginEnd="@dimen/yearly_padding_half" + android:layout_weight="1"> - + - + - + - + android:layout_marginStart="@dimen/yearly_padding_full" + android:layout_weight="1"> - - + - + - + + - + - + android:layout_marginEnd="@dimen/yearly_padding_full" + android:layout_weight="1"> - + - + - + - + android:layout_marginStart="@dimen/yearly_padding_half" + android:layout_marginEnd="@dimen/yearly_padding_half" + android:layout_weight="1"> - + - + - + - + android:layout_marginStart="@dimen/yearly_padding_full" + android:layout_weight="1"> - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/top_navigation.xml b/app/src/main/res/layout/top_navigation.xml index 4c970a76c..8e270b13b 100644 --- a/app/src/main/res/layout/top_navigation.xml +++ b/app/src/main/res/layout/top_navigation.xml @@ -1,6 +1,7 @@ + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/calendar_wrapper"> + android:textSize="@dimen/month_text_size" + tools:text="January" /> diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index c29c65654..42a930e5a 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -3,12 +3,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:ignore="AppCompatResource"> -