From f246bca4b8aeb4d8a72cab97e0f5b654741d4838 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 28 Jul 2022 12:40:44 +0200 Subject: [PATCH] updating the remaining activity styles --- .../pro/activities/SetWallpaperActivity.kt | 47 ++-- .../pro/activities/SettingsActivity.kt | 6 - .../pro/activities/VideoPlayerActivity.kt | 52 +++- .../pro/activities/ViewPagerActivity.kt | 2 + .../pro/activities/WidgetConfigureActivity.kt | 8 + .../res/layout/activity_set_wallpaper.xml | 44 +++- .../main/res/layout/activity_video_player.xml | 35 ++- .../res/layout/activity_widget_config.xml | 247 ++++++++++-------- 8 files changed, 264 insertions(+), 177 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt index 018c7d8fd..9a36ee237 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt @@ -6,11 +6,10 @@ import android.content.Intent import android.graphics.Bitmap import android.net.Uri import android.os.Bundle -import android.view.Menu -import android.view.MenuItem import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.checkAppSideloading import com.simplemobiletools.commons.extensions.toast +import com.simplemobiletools.commons.helpers.NavigationIcon import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.isNougatPlus import com.simplemobiletools.commons.models.RadioItem @@ -40,6 +39,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete return } + setupOptionsMenu() if (intent.data == null) { val pickIntent = Intent(applicationContext, MainActivity::class.java) pickIntent.action = Intent.ACTION_PICK @@ -51,19 +51,31 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete handleImage(intent) } - override fun onCreateOptionsMenu(menu: Menu): Boolean { - menuInflater.inflate(R.menu.menu_set_wallpaper, menu) - updateMenuItemColors(menu) - return true + override fun onResume() { + super.onResume() + setupToolbar(set_wallpaper_toolbar, NavigationIcon.Arrow) } - override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { - R.id.save -> confirmWallpaper() - R.id.allow_changing_aspect_ratio -> crop_image_view.clearAspectRatio() - else -> return super.onOptionsItemSelected(item) + override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { + if (requestCode == PICK_IMAGE) { + if (resultCode == Activity.RESULT_OK && resultData != null) { + handleImage(resultData) + } else { + finish() + } + } + super.onActivityResult(requestCode, resultCode, resultData) + } + + private fun setupOptionsMenu() { + set_wallpaper_toolbar.setOnMenuItemClickListener { menuItem -> + when (menuItem.itemId) { + R.id.save -> confirmWallpaper() + R.id.allow_changing_aspect_ratio -> crop_image_view.clearAspectRatio() + else -> return@setOnMenuItemClickListener false + } + return@setOnMenuItemClickListener true } - return true } private fun handleImage(intent: Intent) { @@ -158,15 +170,4 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete toast("${getString(R.string.image_editing_failed)}: ${result.error.message}") } } - - override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { - if (requestCode == PICK_IMAGE) { - if (resultCode == Activity.RESULT_OK && resultData != null) { - handleImage(resultData) - } else { - finish() - } - } - super.onActivityResult(requestCode, resultCode, resultData) - } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt index 81c933dba..a195c1955 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt @@ -4,7 +4,6 @@ import android.app.Activity import android.content.Intent import android.os.Bundle import android.text.TextUtils -import android.view.Menu import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.simplemobiletools.commons.dialogs.* @@ -128,11 +127,6 @@ class SettingsActivity : SimpleActivity() { } } - 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 == PICK_IMPORT_SOURCE_INTENT && resultCode == Activity.RESULT_OK && resultData != null && resultData.data != null) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt index 61c4f2684..65cac3e4e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt @@ -13,6 +13,7 @@ import android.os.Bundle import android.os.Handler import android.util.DisplayMetrics import android.view.* +import android.widget.RelativeLayout import android.widget.SeekBar import com.google.android.exoplayer2.* import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory @@ -58,8 +59,13 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen private var mIgnoreCloseDown = false public override fun onCreate(savedInstanceState: Bundle?) { + useDynamicTheme = false + showTransparentTop = true + showTransparentNavigation = true + super.onCreate(savedInstanceState) setContentView(R.layout.activity_video_player) + setupOptionsMenu() setupOrientation() checkNotchSupport() initPlayer() @@ -105,19 +111,27 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen } } - override fun onCreateOptionsMenu(menu: Menu): Boolean { - menuInflater.inflate(R.menu.menu_video_player, menu) - return true - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { - R.id.menu_change_orientation -> changeOrientation() - R.id.menu_open_with -> openPath(mUri!!.toString(), true) - R.id.menu_share -> shareMediumPath(mUri!!.toString()) - else -> return super.onOptionsItemSelected(item) + private fun setupOptionsMenu() { + (video_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight + video_toolbar.apply { + setTitleTextColor(Color.WHITE) + overflowIcon = resources.getColoredDrawableWithColor(R.drawable.ic_three_dots_vector, Color.WHITE) + navigationIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, Color.WHITE) + } + + video_toolbar.setOnMenuItemClickListener { menuItem -> + when (menuItem.itemId) { + R.id.menu_change_orientation -> changeOrientation() + R.id.menu_open_with -> openPath(mUri!!.toString(), true) + R.id.menu_share -> shareMediumPath(mUri!!.toString()) + else -> return@setOnMenuItemClickListener false + } + return@setOnMenuItemClickListener true + } + + video_toolbar.setNavigationOnClickListener { + finish() } - return true } override fun onConfigurationChanged(newConfig: Configuration) { @@ -127,6 +141,12 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen video_surface_frame.onGlobalLayout { video_surface_frame.controller.resetState() } + + if (!portrait && navigationBarRight && navigationBarWidth > 0) { + video_toolbar.setPadding(0, 0, navigationBarWidth, 0) + } else { + video_toolbar.setPadding(0, 0, 0, 0) + } } private fun setupOrientation() { @@ -141,7 +161,7 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen private fun initPlayer() { mUri = intent.data ?: return - supportActionBar?.title = getFilenameFromUri(mUri!!) + video_toolbar.title = getFilenameFromUri(mUri!!) initTimeHolder() showSystemUI(true) @@ -459,6 +479,12 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen arrayOf(video_prev_file, video_next_file, video_curr_time, video_duration).forEach { it.isClickable = !mIsFullscreen } + + video_appbar.animate().alpha(newAlpha).withStartAction { + video_appbar.beVisible() + }.withEndAction { + video_appbar.beVisibleIf(newAlpha == 1f) + }.start() } private fun initTimeHolder() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 32c73a356..d089e91ee 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -836,6 +836,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View if (!portrait && navigationBarRight && navigationBarWidth > 0) { medium_viewer_toolbar.setPadding(0, 0, navigationBarWidth, 0) + } else { + medium_viewer_toolbar.setPadding(0, 0, 0, 0) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt index 734c1241c..38cd63ad7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.pro.activities import android.app.Activity import android.appwidget.AppWidgetManager import android.content.Intent +import android.content.res.ColorStateList import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.os.Bundle @@ -69,6 +70,11 @@ class WidgetConfigureActivity : SimpleActivity() { } } + override fun onResume() { + super.onResume() + setupToolbar(config_toolbar) + } + private fun initVariables() { mBgColor = config.widgetBgColor mBgAlpha = Color.alpha(mBgColor) / 255f @@ -126,11 +132,13 @@ class WidgetConfigureActivity : SimpleActivity() { mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha) config_image_holder.background.applyColorFilter(mBgColor) config_bg_color.setFillWithStroke(mBgColor, mBgColor) + config_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor()) } private fun updateTextColor() { config_folder_name.setTextColor(mTextColor) config_text_color.setFillWithStroke(mTextColor, mTextColor) + config_save.setTextColor(getProperPrimaryColor().getContrastColor()) } private fun pickBackgroundColor() { diff --git a/app/src/main/res/layout/activity_set_wallpaper.xml b/app/src/main/res/layout/activity_set_wallpaper.xml index 7acb21c69..6ea9b43d7 100644 --- a/app/src/main/res/layout/activity_set_wallpaper.xml +++ b/app/src/main/res/layout/activity_set_wallpaper.xml @@ -1,20 +1,42 @@ - - + + + + + + + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + - + + + + diff --git a/app/src/main/res/layout/activity_video_player.xml b/app/src/main/res/layout/activity_video_player.xml index 8c50ca199..ebb1ed5db 100644 --- a/app/src/main/res/layout/activity_video_player.xml +++ b/app/src/main/res/layout/activity_video_player.xml @@ -1,6 +1,6 @@ - + android:layout_centerInParent="true" /> @@ -23,19 +23,19 @@ android:id="@+id/video_volume_controller" android:layout_width="@dimen/media_side_slider_width" android:layout_height="match_parent" - android:layout_alignParentEnd="true"/> + android:layout_alignParentEnd="true" /> + android:layout_height="match_parent" /> + android:contentDescription="@null" /> + tools:ignore="UnknownIdInLayout" /> - + + android:textSize="@dimen/extra_big_text_size" /> + + + + + diff --git a/app/src/main/res/layout/activity_widget_config.xml b/app/src/main/res/layout/activity_widget_config.xml index 8f6005e77..d674ade88 100644 --- a/app/src/main/res/layout/activity_widget_config.xml +++ b/app/src/main/res/layout/activity_widget_config.xml @@ -1,136 +1,153 @@ - + android:layout_height="match_parent"> + + + + + + + android:layout_centerHorizontal="true" + android:layout_margin="@dimen/activity_margin" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + android:paddingBottom="@dimen/activity_margin"> - + android:background="?attr/selectableItemBackground"> + + + + + + + + - + + + + + + + + + + + + + + + + + +