updating some activity styles

This commit is contained in:
tibbi 2022-07-26 12:05:56 +02:00
parent 6613e75ce7
commit 1fc696e960
13 changed files with 1862 additions and 1789 deletions

View file

@ -15,8 +15,6 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredName
import android.provider.ContactsContract.Data
import android.text.TextUtils
import android.text.method.LinkMovementMethod
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.EditorInfo
@ -65,7 +63,6 @@ class EventActivity : SimpleActivity() {
private var mEventOccurrenceTS = 0L
private var mLastSavePromptTS = 0L
private var mEventCalendarId = STORED_LOCALLY_ONLY
private var mWasActivityInitialized = false
private var mWasContactsPermissionChecked = false
private var mWasCalendarChanged = false
private var mAttendees = ArrayList<Attendee>()
@ -86,6 +83,8 @@ class EventActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_event)
setupOptionsMenu()
refreshMenuItems()
if (checkAppSideloading()) {
return
@ -113,6 +112,11 @@ class EventActivity : SimpleActivity() {
}
}
override fun onResume() {
super.onResume()
setupToolbar(event_toolbar, NavigationIcon.Arrow)
}
private fun gotEvent(savedInstanceState: Bundle?, localEventType: EventType?, event: Event?) {
if (localEventType == null || localEventType.caldavCalendarId != 0) {
config.lastUsedLocalEventTypeId = REGULAR_EVENT_TYPE_ID
@ -129,7 +133,7 @@ class EventActivity : SimpleActivity() {
if (intent.getBooleanExtra(IS_DUPLICATE_INTENT, false)) {
mEvent.id = null
updateActionBarTitle(getString(R.string.new_event))
event_toolbar.title = getString(R.string.new_event)
} else {
cancelNotification(mEvent.id!!)
}
@ -223,30 +227,29 @@ class EventActivity : SimpleActivity() {
updateIconColors()
event_time_zone_image.beVisibleIf(config.allowChangingTimeZones)
event_time_zone.beVisibleIf(config.allowChangingTimeZones)
mWasActivityInitialized = true
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_event, menu)
if (mWasActivityInitialized) {
menu.findItem(R.id.delete).isVisible = mEvent.id != null
menu.findItem(R.id.share).isVisible = mEvent.id != null
menu.findItem(R.id.duplicate).isVisible = mEvent.id != null
private fun refreshMenuItems() {
if (::mEvent.isInitialized) {
event_toolbar.menu.apply {
findItem(R.id.delete).isVisible = mEvent.id != null
findItem(R.id.share).isVisible = mEvent.id != null
findItem(R.id.duplicate).isVisible = mEvent.id != null
}
}
}
updateMenuItemColors(menu, true)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
private fun setupOptionsMenu() {
event_toolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.save -> saveCurrentEvent()
R.id.delete -> deleteEvent()
R.id.duplicate -> duplicateEvent()
R.id.share -> shareEvent()
else -> return super.onOptionsItemSelected(item)
else -> return@setOnMenuItemClickListener false
}
return@setOnMenuItemClickListener true
}
return true
}
private fun getStartEndTimes(): Pair<Long, Long> {
@ -326,7 +329,7 @@ class EventActivity : SimpleActivity() {
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
if (!mWasActivityInitialized) {
if (!::mEvent.isInitialized) {
return
}
@ -435,7 +438,7 @@ class EventActivity : SimpleActivity() {
mOriginalEndTS = realStart + duration
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
updateActionBarTitle(getString(R.string.edit_event))
event_toolbar.title = getString(R.string.edit_event)
mOriginalTimeZone = mEvent.timeZone
if (config.allowChangingTimeZones) {
try {
@ -478,7 +481,7 @@ class EventActivity : SimpleActivity() {
private fun setupNewEvent() {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
event_title.requestFocus()
updateActionBarTitle(getString(R.string.new_event))
event_toolbar.title = getString(R.string.new_event)
if (config.defaultEventTypeId != -1L) {
config.lastUsedCaldavCalendarId = mStoredEventTypes.firstOrNull { it.id == config.defaultEventTypeId }?.caldavCalendarId ?: 0
}
@ -1712,10 +1715,10 @@ class EventActivity : SimpleActivity() {
}
private fun updateActionBarTitle() {
if (mIsNewEvent) {
updateActionBarTitle(getString(R.string.new_event))
event_toolbar.title = if (mIsNewEvent) {
getString(R.string.new_event)
} else {
updateActionBarTitle(getString(R.string.edit_event))
getString(R.string.edit_event)
}
}
}

View file

@ -89,6 +89,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
appLaunched(BuildConfig.APPLICATION_ID)
setupOptionsMenu()
refreshMenuItems()
checkWhatsNewDialog()
calendar_fab.beVisibleIf(config.storedView != YEARLY_VIEW && config.storedView != WEEKLY_VIEW)
@ -169,6 +171,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
val newShouldFilterBeVisible = it.size > 1 || config.displayEventTypes.isEmpty()
if (newShouldFilterBeVisible != mShouldFilterBeVisible) {
mShouldFilterBeVisible = newShouldFilterBeVisible
refreshMenuItems()
}
}
@ -194,8 +197,9 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
checkSwipeRefreshAvailability()
checkShortcuts()
setupToolbar(main_toolbar, searchMenuItem = mSearchMenuItem)
if (!mIsSearchOpen) {
invalidateOptionsMenu()
refreshMenuItems()
}
setupQuickFilter()
@ -214,41 +218,30 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
shouldGoToTodayBeVisible = currentFragments.last().shouldGoToTodayBeVisible()
menu.apply {
private fun refreshMenuItems() {
if (fab_extended_overlay.isVisible()) {
hideExtendedFab()
}
shouldGoToTodayBeVisible = currentFragments.lastOrNull()?.shouldGoToTodayBeVisible() ?: false
main_toolbar.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
findItem(R.id.go_to_today).isVisible = shouldGoToTodayBeVisible && !mIsSearchOpen
findItem(R.id.go_to_date).isVisible = config.storedView != EVENTS_LIST_VIEW
}
setupSearch(menu)
updateMenuItemColors(menu)
return true
}
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
if (fab_extended_overlay.isVisible()) {
hideExtendedFab()
}
menu.apply {
findItem(R.id.refresh_caldav_calendars).isVisible = config.caldavSync
findItem(R.id.filter).isVisible = mShouldFilterBeVisible
}
}
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
private fun setupOptionsMenu() {
setupSearch(main_toolbar.menu)
main_toolbar.setOnMenuItemClickListener { menuItem ->
if (fab_extended_overlay.isVisible()) {
hideExtendedFab()
}
when (item.itemId) {
when (menuItem.itemId) {
R.id.change_view -> showViewDialog()
R.id.go_to_today -> goToToday()
R.id.go_to_date -> showGoToDateDialog()
@ -263,9 +256,10 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
R.id.settings -> launchSettings()
R.id.about -> launchAbout()
android.R.id.home -> onBackPressed()
else -> return super.onOptionsItemSelected(item)
else -> return@setOnMenuItemClickListener false
}
return@setOnMenuItemClickListener true
}
return true
}
override fun onBackPressed() {
@ -336,7 +330,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
search_holder.beVisible()
calendar_fab.beGone()
searchQueryChanged("")
invalidateOptionsMenu()
refreshMenuItems()
return true
}
@ -344,7 +338,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
mIsSearchOpen = false
search_holder.beGone()
calendar_fab.beVisibleIf(currentFragments.last() !is YearFragmentsHolder && currentFragments.last() !is WeekFragmentsHolder)
invalidateOptionsMenu()
refreshMenuItems()
return true
}
})
@ -517,7 +511,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
closeSearch()
updateView(it as Int)
shouldGoToTodayBeVisible = false
invalidateOptionsMenu()
refreshMenuItems()
}
}
@ -534,8 +528,12 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
private fun resetActionBarTitle() {
updateActionBarTitle(getString(R.string.app_launcher_name))
updateActionBarSubtitle("")
main_toolbar.title = getString(R.string.app_launcher_name)
main_toolbar.subtitle = ""
}
fun updateSubtitle(text: String) {
main_toolbar.subtitle = text
}
private fun showFilterDialog() {
@ -549,7 +547,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
fun toggleGoToTodayVisibility(beVisible: Boolean) {
shouldGoToTodayBeVisible = beVisible
if (goToTodayButton?.isVisible != beVisible) {
invalidateOptionsMenu()
refreshMenuItems()
}
}
@ -872,7 +870,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
updateViewPager(dateCode)
if (goToTodayButton?.isVisible == true) {
shouldGoToTodayBeVisible = false
invalidateOptionsMenu()
refreshMenuItems()
}
}

View file

@ -7,7 +7,6 @@ import android.content.Intent
import android.media.AudioManager
import android.media.RingtoneManager
import android.os.Bundle
import android.view.Menu
import android.widget.Toast
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.dialogs.SelectCalendarsDialog
@ -41,6 +40,7 @@ class SettingsActivity : SimpleActivity() {
override fun onResume() {
super.onResume()
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
setupSettingItems()
}
@ -91,7 +91,6 @@ class SettingsActivity : SimpleActivity() {
checkPrimaryColor()
setupExportSettings()
setupImportSettings()
invalidateOptionsMenu()
arrayOf(
settings_color_customization_label,
@ -141,11 +140,6 @@ class SettingsActivity : SimpleActivity() {
config.defaultReminder3 = reminders.getOrElse(2) { REMINDER_OFF }
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
updateMenuItemColors(menu)
return super.onCreateOptionsMenu(menu)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
super.onActivityResult(requestCode, resultCode, resultData)
if (requestCode == GET_RINGTONE_URI && resultCode == RESULT_OK && resultData != null) {
@ -320,7 +314,10 @@ class SettingsActivity : SimpleActivity() {
ensureBackgroundThread {
if (newCalendarIds.isNotEmpty()) {
val existingEventTypeNames = eventsHelper.getEventTypesSync().map { it.getDisplayTitle().lowercase(Locale.getDefault()) } as ArrayList<String>
val existingEventTypeNames = eventsHelper.getEventTypesSync().map {
it.getDisplayTitle().lowercase(Locale.getDefault())
} as ArrayList<String>
getSyncedCalDAVCalendars().forEach {
val calendarTitle = it.getFullTitle()
if (!existingEventTypeNames.contains(calendarTitle.lowercase(Locale.getDefault()))) {

View file

@ -168,7 +168,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
val endMonthName = Formatter.getMonthName(requireContext(), endDateTime.monthOfYear)
(activity as AppCompatActivity).updateActionBarTitle("$startMonthName - $endMonthName")
}
(activity as AppCompatActivity).updateActionBarSubtitle("${getString(R.string.week)} ${startDateTime.plusDays(3).weekOfWeekyear}")
(activity as MainActivity).updateSubtitle("${getString(R.string.week)} ${startDateTime.plusDays(3).weekOfWeekyear}")
}
override fun goToToday() {

View file

@ -1,10 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/event_scrollview"
android:id="@+id/event_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/event_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/event_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:menu="@menu/menu_event"
app:title="@string/app_launcher_name"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
android:id="@+id/event_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:id="@+id/event_holder"
android:layout_width="match_parent"
@ -595,3 +618,4 @@
android:importantForAccessibility="no" />
</RelativeLayout>
</ScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,10 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/calendar_coordinator"
android:id="@+id/main_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/main_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:menu="@menu/menu_main"
app:title="@string/app_launcher_name"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/calendar_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -149,3 +171,4 @@
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,10 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/settings_scrollview"
android:id="@+id/settings_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/settings_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/settings_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:title="@string/settings"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/settings_nested_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="@+id/settings_holder"
android:layout_width="match_parent"
@ -1022,4 +1046,5 @@
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -4,7 +4,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/normal_margin">
android:paddingStart="@dimen/normal_margin"
android:paddingTop="@dimen/small_margin"
android:paddingEnd="@dimen/normal_margin"
android:paddingBottom="@dimen/small_margin">
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/filter_event_type_checkbox"

View file

@ -5,10 +5,10 @@
android:id="@+id/cab_share"
android:icon="@drawable/ic_share_vector"
android:title="@string/share"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
<item
android:id="@+id/cab_delete"
android:icon="@drawable/ic_delete_vector"
android:title="@string/delete"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
</menu>

View file

@ -5,10 +5,10 @@
android:id="@+id/cab_share"
android:icon="@drawable/ic_share_vector"
android:title="@string/share"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
<item
android:id="@+id/cab_delete"
android:icon="@drawable/ic_delete_vector"
android:title="@string/delete"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
</menu>

View file

@ -5,10 +5,10 @@
android:id="@+id/cab_edit"
android:icon="@drawable/ic_edit_vector"
android:title="@string/edit"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
<item
android:id="@+id/cab_delete"
android:icon="@drawable/ic_delete_vector"
android:title="@string/delete"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
</menu>

View file

@ -5,5 +5,5 @@
android:id="@+id/add_event_type"
android:icon="@drawable/ic_plus_vector"
android:title="@string/add_new_type"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
</menu>

View file

@ -6,5 +6,5 @@
android:icon="@drawable/ic_search_vector"
android:title="@string/search"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="collapseActionView|ifRoom" />
app:showAsAction="collapseActionView|always" />
</menu>