diff --git a/app/src/main/java/com/f0x1d/logfox/extensions/ActivityExtensions.kt b/app/src/main/java/com/f0x1d/logfox/extensions/ActivityExtensions.kt index 8c0f8d71..18b8a5b7 100644 --- a/app/src/main/java/com/f0x1d/logfox/extensions/ActivityExtensions.kt +++ b/app/src/main/java/com/f0x1d/logfox/extensions/ActivityExtensions.kt @@ -4,10 +4,15 @@ import androidx.fragment.app.FragmentActivity import com.f0x1d.logfox.R import com.google.android.material.dialog.MaterialAlertDialogBuilder -fun FragmentActivity.showAreYouSureDialog(okClicked: () -> Unit) { +fun FragmentActivity.showAreYouSureDialog( + title: Int, + message: Int = R.string.are_you_sure, + okClicked: () -> Unit +) { MaterialAlertDialogBuilder(this) .setIcon(R.drawable.ic_dialog_warning) - .setTitle(R.string.are_you_sure) + .setTitle(title) + .setMessage(message) .setPositiveButton(R.string.yes) { dialog, i -> okClicked() } .setNeutralButton(R.string.no, null) .show() diff --git a/app/src/main/java/com/f0x1d/logfox/extensions/FABExtensions.kt b/app/src/main/java/com/f0x1d/logfox/extensions/FABExtensions.kt new file mode 100644 index 00000000..eaad5ae0 --- /dev/null +++ b/app/src/main/java/com/f0x1d/logfox/extensions/FABExtensions.kt @@ -0,0 +1,12 @@ +package com.f0x1d.logfox.extensions + +import androidx.annotation.StringRes +import androidx.appcompat.widget.TooltipCompat +import com.google.android.material.floatingactionbutton.FloatingActionButton + +fun FloatingActionButton.setDescription(@StringRes resId: Int) = setDescription(context.getString(resId)) + +fun FloatingActionButton.setDescription(text: String) { + contentDescription = text + TooltipCompat.setTooltipText(this, text) +} \ No newline at end of file diff --git a/app/src/main/java/com/f0x1d/logfox/extensions/FragmentExtensions.kt b/app/src/main/java/com/f0x1d/logfox/extensions/FragmentExtensions.kt index 18df81c7..fa19383a 100644 --- a/app/src/main/java/com/f0x1d/logfox/extensions/FragmentExtensions.kt +++ b/app/src/main/java/com/f0x1d/logfox/extensions/FragmentExtensions.kt @@ -1,5 +1,10 @@ package com.f0x1d.logfox.extensions import androidx.fragment.app.Fragment +import com.f0x1d.logfox.R -fun Fragment.showAreYouSureDialog(okPressed: () -> Unit) = requireActivity().showAreYouSureDialog(okPressed) \ No newline at end of file +fun Fragment.showAreYouSureDialog( + title: Int, + message: Int = R.string.are_you_sure, + okPressed: () -> Unit +) = requireActivity().showAreYouSureDialog(title, message, okPressed) \ No newline at end of file diff --git a/app/src/main/java/com/f0x1d/logfox/ui/activity/CrashDetailsActivity.kt b/app/src/main/java/com/f0x1d/logfox/ui/activity/CrashDetailsActivity.kt index 0d0e4926..c5900db7 100644 --- a/app/src/main/java/com/f0x1d/logfox/ui/activity/CrashDetailsActivity.kt +++ b/app/src/main/java/com/f0x1d/logfox/ui/activity/CrashDetailsActivity.kt @@ -64,7 +64,7 @@ class CrashDetailsActivity: BaseViewModelActivity(), viewModel.pausedData.observe(viewLifecycleOwner) { paused -> changingState = true - binding.toolbar.menu.findItem(R.id.pause_item).setIcon(if (paused) R.drawable.ic_play else R.drawable.ic_pause) + binding.toolbar.menu.findItem(R.id.pause_item) + .setIcon(if (paused) R.drawable.ic_play else R.drawable.ic_pause) + .setTitle(if (paused) R.string.resume else R.string.pause) if (paused) { binding.scrollFab.show() } else { diff --git a/app/src/main/java/com/f0x1d/logfox/ui/fragment/RecordingsFragment.kt b/app/src/main/java/com/f0x1d/logfox/ui/fragment/RecordingsFragment.kt index 9af5abea..d9c9f62f 100644 --- a/app/src/main/java/com/f0x1d/logfox/ui/fragment/RecordingsFragment.kt +++ b/app/src/main/java/com/f0x1d/logfox/ui/fragment/RecordingsFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.appcompat.widget.TooltipCompat import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager @@ -13,6 +14,7 @@ import com.f0x1d.logfox.database.entity.LogRecording import com.f0x1d.logfox.databinding.FragmentRecordingsBinding import com.f0x1d.logfox.extensions.isHorizontalOrientation import com.f0x1d.logfox.extensions.setClickListenerOn +import com.f0x1d.logfox.extensions.setDescription import com.f0x1d.logfox.extensions.showAreYouSureDialog import com.f0x1d.logfox.extensions.startLoggingService import com.f0x1d.logfox.repository.logging.RecordingState @@ -33,7 +35,7 @@ class RecordingsFragment: BaseViewModelFragment { - binding.recordFab.setImageResource(R.drawable.ic_recording) - binding.recordFab.isEnabled = true - - binding.pauseFab.hide() + viewModel.recordingStateData.observe(viewLifecycleOwner) { state -> + binding.recordFab.apply { + when (state) { + RecordingState.IDLE, RecordingState.SAVING -> { + setImageResource(R.drawable.ic_recording) + setDescription(R.string.record) + isEnabled = state == RecordingState.IDLE + } + + RecordingState.RECORDING, RecordingState.PAUSED -> { + setImageResource(R.drawable.ic_stop) + setDescription(R.string.stop) + isEnabled = true + } } + } - RecordingState.RECORDING -> { - binding.recordFab.setImageResource(R.drawable.ic_stop) - binding.recordFab.isEnabled = true - - binding.pauseFab.setImageResource(R.drawable.ic_pause) - binding.pauseFab.show() - } - - RecordingState.PAUSED -> { - binding.recordFab.setImageResource(R.drawable.ic_stop) - binding.recordFab.isEnabled = true - - binding.pauseFab.setImageResource(R.drawable.ic_play) - binding.pauseFab.show() - } - - RecordingState.SAVING -> { - binding.recordFab.setImageResource(R.drawable.ic_recording) - binding.recordFab.isEnabled = false - - binding.pauseFab.hide() + binding.pauseFab.apply { + when (state) { + RecordingState.IDLE, RecordingState.SAVING -> { + hide() + } + + RecordingState.RECORDING -> { + setImageResource(R.drawable.ic_pause) + setDescription(R.string.pause) + show() + } + + RecordingState.PAUSED -> { + setImageResource(R.drawable.ic_play) + setDescription(R.string.resume) + show() + } } } } diff --git a/app/src/main/java/com/f0x1d/logfox/ui/fragment/crashes/AppCrashesFragment.kt b/app/src/main/java/com/f0x1d/logfox/ui/fragment/crashes/AppCrashesFragment.kt index bde2c403..ede225c8 100644 --- a/app/src/main/java/com/f0x1d/logfox/ui/fragment/crashes/AppCrashesFragment.kt +++ b/app/src/main/java/com/f0x1d/logfox/ui/fragment/crashes/AppCrashesFragment.kt @@ -7,6 +7,7 @@ import android.view.ViewGroup import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.LinearLayoutManager +import com.f0x1d.logfox.R import com.f0x1d.logfox.adapter.CrashesAdapter import com.f0x1d.logfox.databinding.FragmentAppCrashesBinding import com.f0x1d.logfox.extensions.showAreYouSureDialog @@ -27,7 +28,7 @@ class AppCrashesFragment: BaseViewModelFragment @@ -63,7 +63,7 @@ class FiltersFragment: BaseViewModelFragment @@ -35,6 +36,9 @@ android:visibility="gone" android:layout_margin="10dp" app:layout_anchorGravity="bottom|right|end" - android:layout_gravity="end|bottom"/> + android:layout_gravity="end|bottom" + android:contentDescription="@string/scroll_to_bottom" + android:tooltipText="@string/scroll_to_bottom" + tools:targetApi="o" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_recordings.xml b/app/src/main/res/layout/fragment_recordings.xml index 1dc2cc19..7c531a0f 100644 --- a/app/src/main/res/layout/fragment_recordings.xml +++ b/app/src/main/res/layout/fragment_recordings.xml @@ -1,5 +1,6 @@ @@ -36,8 +37,11 @@ android:layout_marginStart="10dp" android:layout_marginEnd="10dp" android:layout_marginBottom="76dp" + android:contentDescription="@string/pause" + android:tooltipText="@string/pause" app:layout_anchorGravity="bottom|right|end" - android:layout_gravity="end|bottom"/> + android:layout_gravity="end|bottom" + tools:targetApi="o" /> + android:layout_gravity="end|bottom" + android:contentDescription="@string/record" + android:tooltipText="@string/record" + tools:targetApi="o" /> \ No newline at end of file diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 854e302b..230ac61f 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -107,4 +107,7 @@ Приложения Вы уверены? Просмотр + Вы действительно хотите удалить это? Вы не сможете отменить это действие. + Вы действительно хотите очистить это? Вы не сможете отменить это действие. + Промотать вниз \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index d13e29c7..1870da7e 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -7,6 +7,7 @@ 已复制 搜索 清除 + 确定要清除吗?清除后无法恢复。 查询 日志状态 记录中 @@ -33,6 +34,7 @@ 录制 录制 删除 + 确定要删除吗?删除后将无法恢复。 继续 更新间隔 毫秒 @@ -108,4 +110,5 @@ 应用 你确定? 查看 + 滚动到底部 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dc581b8f..dfd12273 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -116,4 +116,7 @@ Apps Are you sure? View + Are you sure want to delete it? This action cannot be undone. + Are you sure want to clear it? This action cannot be undone. + Scroll to the bottom \ No newline at end of file