Skip to content

Commit

Permalink
[refactor]: use material button instead of complex layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse205 authored Dec 24, 2023
1 parent 9e3e55a commit 42508a9
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 314 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.f0x1d.logfox.databinding.SheetRecordingBinding
import com.f0x1d.logfox.extensions.asUri
import com.f0x1d.logfox.extensions.context.shareFileIntent
import com.f0x1d.logfox.extensions.toLocaleString
import com.f0x1d.logfox.extensions.views.replaceAccessibilityDelegateClassNameWithButton
import com.f0x1d.logfox.ui.dialog.base.BaseViewModelBottomSheet
import com.f0x1d.logfox.viewmodel.recordings.RecordingViewModel
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -49,22 +48,18 @@ class RecordingBottomSheet: BaseViewModelBottomSheet<RecordingViewModel, SheetRe

binding.timeText.text = logRecording.dateAndTime.toLocaleString()

binding.viewLayout.replaceAccessibilityDelegateClassNameWithButton()
binding.viewLayout.setOnClickListener {
binding.viewButton.setOnClickListener {
findNavController().navigate(NavGraphDirections.actionGlobalLogsFragment(
File(logRecording.file).asUri(requireContext())
))
}
binding.exportLayout.replaceAccessibilityDelegateClassNameWithButton()
binding.exportLayout.setOnClickListener {
binding.exportButton.setOnClickListener {
logExportLauncher.launch("${viewModel.dateTimeFormatter.formatForExport(logRecording.dateAndTime)}.log")
}
binding.shareLayout.replaceAccessibilityDelegateClassNameWithButton()
binding.shareLayout.setOnClickListener {
binding.shareButton.setOnClickListener {
requireContext().shareFileIntent(File(logRecording.file))
}
binding.zipLayout.replaceAccessibilityDelegateClassNameWithButton()
binding.zipLayout.setOnClickListener {
binding.zipButton.setOnClickListener {
zipLogLauncher.launch("${viewModel.dateTimeFormatter.formatForExport(logRecording.dateAndTime)}.log")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.f0x1d.logfox.databinding.ActivityCrashDetailsBinding
import com.f0x1d.logfox.extensions.context.copyText
import com.f0x1d.logfox.extensions.context.shareIntent
import com.f0x1d.logfox.extensions.showAreYouSureDeleteDialog
import com.f0x1d.logfox.extensions.views.replaceAccessibilityDelegateClassNameWithButton
import com.f0x1d.logfox.extensions.views.widgets.loadIcon
import com.f0x1d.logfox.extensions.views.widgets.setClickListenerOn
import com.f0x1d.logfox.extensions.views.widgets.setupBackButtonForNavController
Expand Down Expand Up @@ -53,10 +52,6 @@ class CrashDetailsFragment: BaseViewModelFragment<CrashDetailsViewModel, Activit

binding.toolbar.setupBackButtonForNavController()

binding.copyLayout.replaceAccessibilityDelegateClassNameWithButton()
binding.shareLayout.replaceAccessibilityDelegateClassNameWithButton()
binding.zipLayout.replaceAccessibilityDelegateClassNameWithButton()

viewModel.crash.observe(viewLifecycleOwner) {
setupFor(it ?: return@observe)
}
Expand Down Expand Up @@ -94,16 +89,16 @@ class CrashDetailsFragment: BaseViewModelFragment<CrashDetailsViewModel, Activit
binding.appName.text = appCrash.appName ?: getString(R.string.unknown)
binding.appPackage.text = appCrash.packageName

binding.copyLayout.setOnClickListener {
binding.copyButton.setOnClickListener {
requireContext().copyText(crashLog ?: "")
snackbar(R.string.text_copied)
}

binding.shareLayout.setOnClickListener {
binding.shareButton.setOnClickListener {
requireContext().shareIntent(crashLog ?: "")
}

binding.zipLayout.setOnClickListener {
binding.zipButton.setOnClickListener {
zipCrashLauncher.launch("crash-${appCrash.packageName.replace(".", "-")}-${viewModel.dateTimeFormatter.formatForExport(appCrash.dateAndTime)}.zip")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ class FontsInterceptor(context: Context): Interceptor {
R.id.clear_search_button to boldSansTypeface,
R.id.log_levels_button to boldSansTypeface,
R.id.time_text to boldSansTypeface,
R.id.copy_text to boldSansTypeface,
R.id.share_text to boldSansTypeface,
R.id.zip_text to boldSansTypeface,
R.id.export_text to boldSansTypeface,
R.id.view_text to boldSansTypeface,
R.id.including_button to boldSansTypeface
)

Expand Down
139 changes: 22 additions & 117 deletions app/src/main/res/layout/activity_crash_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,137 +92,42 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/copy_layout"
<Button
style="@style/LogFoxBigButtonStyle"
android:id="@+id/copy_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:text="@android:string/copy"
app:icon="@drawable/ic_copy"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/share_layout"
app:layout_constraintEnd_toStartOf="@id/share_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:contentDescription="@android:string/copy">

<ImageView
android:id="@+id/copy_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_copy"
app:tint="?colorPrimary"
android:layout_marginTop="15dp"
app:layout_constraintBottom_toTopOf="@id/copy_text"
app:layout_constraintEnd_toEndOf="@id/copy_text"
app:layout_constraintStart_toStartOf="@id/copy_text"
app:layout_constraintTop_toTopOf="parent"
android:importantForAccessibility="no" />

<TextView
android:id="@+id/copy_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:includeFontPadding="false"
android:maxLines="1"
android:text="@android:string/copy"
android:textColor="?colorPrimary"
android:textSize="14sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/copy_image" />
</androidx.constraintlayout.widget.ConstraintLayout>
app:layout_constraintTop_toTopOf="parent" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/share_layout"
<Button
style="@style/LogFoxBigButtonStyle"
android:id="@+id/share_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:text="@string/share"
app:icon="@drawable/ic_share"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/zip_layout"
app:layout_constraintStart_toEndOf="@id/copy_layout"
app:layout_constraintTop_toTopOf="parent"
android:contentDescription="@string/share">

<ImageView
android:id="@+id/share_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_share"
app:tint="?colorPrimary"
android:layout_marginTop="15dp"
app:layout_constraintBottom_toTopOf="@id/share_text"
app:layout_constraintEnd_toEndOf="@id/share_text"
app:layout_constraintStart_toStartOf="@id/share_text"
app:layout_constraintTop_toTopOf="parent"
android:importantForAccessibility="no" />

<TextView
android:id="@+id/share_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:includeFontPadding="false"
android:maxLines="1"
android:text="@string/share"
android:textColor="?colorPrimary"
android:textSize="14sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/share_image" />
</androidx.constraintlayout.widget.ConstraintLayout>
app:layout_constraintEnd_toStartOf="@id/zip_button"
app:layout_constraintStart_toEndOf="@id/copy_button"
app:layout_constraintTop_toTopOf="parent" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/zip_layout"
<Button
style="@style/LogFoxBigButtonStyle"
android:id="@+id/zip_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:text="@string/zip"
app:icon="@drawable/ic_archive"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/share_layout"
app:layout_constraintTop_toTopOf="parent"
android:contentDescription="@string/zip">

<ImageView
android:id="@+id/zip_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_archive"
app:tint="?colorPrimary"
android:layout_marginTop="15dp"
app:layout_constraintBottom_toTopOf="@id/zip_text"
app:layout_constraintEnd_toEndOf="@id/zip_text"
app:layout_constraintStart_toStartOf="@id/zip_text"
app:layout_constraintTop_toTopOf="parent"
android:importantForAccessibility="no" />
app:layout_constraintStart_toEndOf="@id/share_button"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/zip_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:includeFontPadding="false"
android:maxLines="1"
android:text="@string/zip"
android:textColor="?colorPrimary"
android:textSize="14sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/zip_image" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

Expand Down
Loading

0 comments on commit 42508a9

Please sign in to comment.