-
-
Notifications
You must be signed in to change notification settings - Fork 24
ADFA-1304 | Add Project Info Bottom Sheet #706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5dbd774
feat: add full project info bottom sheet with details and DB migration
jatezzz a2cef41
Merge branch 'stage' into ADFA-1304-project-info-bottom-sheet
jatezzz b850bd1
refactor(project_info): Remove duplicated code, remove unused imports…
jatezzz 0ebcadc
fix(recent_projects): Fix indentation
jatezzz 1be7623
Merge branch 'stage' into ADFA-1304-project-info-bottom-sheet
jatezzz 17314a9
refactor(project-info): enforce I/O safety and simplify InfoRowView u…
jatezzz c2d1f2d
Merge remote-tracking branch 'origin/ADFA-1304-project-info-bottom-sh…
jatezzz 49e2f53
Merge branch 'stage' into ADFA-1304-project-info-bottom-sheet
jatezzz 701f8ed
Merge branch 'stage' into ADFA-1304-project-info-bottom-sheet
jatezzz 212af35
refactor(project-info): Improve the loading time of project information
jatezzz c77e329
Merge branch 'stage' into ADFA-1304-project-info-bottom-sheet
jatezzz 2c17168
Merge remote-tracking branch 'origin/stage' into ADFA-1304-project-in…
jatezzz 58ed8ec
refactor(projects_info): Improve UI/UX for close button
jatezzz 557a5a8
feat: improve Kotlin version detection in project details
jatezzz 55d2af6
Merge branch 'stage' into ADFA-1304-project-info-bottom-sheet
jatezzz b4a1652
refactor: Improve Kotlin detection for project info panel
jatezzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package com.itsaky.androidide.ui | ||
|
|
||
| import android.content.Context | ||
| import android.util.AttributeSet | ||
| import android.view.LayoutInflater | ||
| import android.widget.LinearLayout | ||
| import android.widget.TextView | ||
| import com.itsaky.androidide.R | ||
|
|
||
| /** | ||
| * A custom view that displays a label and a value in a vertical layout. | ||
| * | ||
| * This view is used to show project information items (e.g., in a bottom sheet or details screen) | ||
| * where a descriptive label is paired with a specific value. | ||
| * | ||
| * @constructor Creates a new InfoRowView instance. | ||
| * @param context The context the view is running in, through which it can access the current theme, resources, etc. | ||
| * @param attrs The attributes of the XML tag that is inflating the view. | ||
| */ | ||
| class InfoRowView @JvmOverloads constructor( | ||
| context: Context, | ||
| attrs: AttributeSet? = null | ||
| ) : LinearLayout(context, attrs) { | ||
|
|
||
| private val labelView: TextView | ||
| private val valueView: TextView | ||
|
|
||
| init { | ||
| orientation = VERTICAL | ||
| LayoutInflater.from(context).inflate(R.layout.layout_project_info_item, this, true) | ||
| labelView = findViewById(R.id.label) | ||
| valueView = findViewById(R.id.value) | ||
| } | ||
|
|
||
| /** | ||
| * Sets the text for the label TextView. | ||
| * | ||
| * @param text The string to be displayed as the label. | ||
| */ | ||
| fun setLabel(text: String) { | ||
| labelView.text = text | ||
| } | ||
|
|
||
| /** | ||
| * Sets the text for the value TextView. | ||
| * | ||
| * @param text The string to be displayed as the value. | ||
| */ | ||
| fun setValue(text: String) { | ||
| valueView.text = text | ||
| } | ||
|
|
||
| fun setLabelAndValue(label: String, value: String) { | ||
| setLabel(label) | ||
| setValue(value) | ||
| } | ||
| } |
172 changes: 172 additions & 0 deletions
172
app/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| package com.itsaky.androidide.ui | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import android.widget.Toast | ||
| import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
| import com.itsaky.androidide.databinding.LayoutProjectInfoSheetBinding | ||
| import com.itsaky.androidide.resources.R | ||
| import com.itsaky.androidide.roomData.recentproject.RecentProject | ||
| import com.itsaky.androidide.utils.ProjectDetails | ||
| import com.itsaky.androidide.utils.formatDate | ||
| import com.itsaky.androidide.utils.loadProjectDetails | ||
| import com.itsaky.androidide.utils.viewLifecycleScope | ||
| import com.termux.shared.interact.ShareUtils.copyTextToClipboard | ||
| import kotlinx.coroutines.launch | ||
| import org.appdevforall.codeonthego.layouteditor.ProjectFile | ||
|
|
||
| class ProjectInfoBottomSheet : BottomSheetDialogFragment() { | ||
| companion object { | ||
| fun newInstance(project: ProjectFile, recent: RecentProject?): ProjectInfoBottomSheet { | ||
| val args = Bundle() | ||
| args.putString("name", project.name) | ||
| args.putString("path", project.path) | ||
| args.putString("created", project.createdAt) | ||
| args.putString("modified", project.lastModified) | ||
|
|
||
| args.putString("template", recent?.templateName) | ||
| args.putString("lang", recent?.language) | ||
|
|
||
| val fragment = ProjectInfoBottomSheet() | ||
| fragment.arguments = args | ||
| return fragment | ||
| } | ||
| } | ||
|
|
||
| private var _binding: LayoutProjectInfoSheetBinding? = null | ||
| private val binding get() = _binding!! | ||
|
|
||
| private val pName by lazy { arguments?.getString("name") ?: "" } | ||
| private val pPath by lazy { arguments?.getString("path") ?: "" } | ||
| private val pCreated by lazy { arguments?.getString("created") } | ||
| private val pModified by lazy { arguments?.getString("modified") } | ||
|
|
||
| private val pTemplate by lazy { arguments?.getString("template") } | ||
| private val pLang by lazy { arguments?.getString("lang") } | ||
|
|
||
| override fun onCreateView( | ||
| inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? | ||
| ): View { | ||
| _binding = LayoutProjectInfoSheetBinding.inflate(inflater, container, false) | ||
| return binding.root | ||
| } | ||
|
|
||
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
| super.onViewCreated(view, savedInstanceState) | ||
|
|
||
| bindGeneral() | ||
|
|
||
| setLoadingState(true) | ||
|
|
||
| viewLifecycleScope.launch { | ||
| val details = loadProjectDetails(pPath, requireContext()) | ||
|
|
||
| if (isAdded && _binding != null) { | ||
| bindStructure(details) | ||
| bindBuildSetup(details) | ||
| setLoadingState(false) | ||
| } | ||
| } | ||
|
|
||
| binding.btnClose.setOnClickListener { dismiss() } | ||
| } | ||
|
|
||
| // ----------------------------- | ||
| // GENERAL | ||
| // ----------------------------- | ||
| private fun bindGeneral() { | ||
| val unknown = getString(R.string.unknown) | ||
|
|
||
| binding.infoName.setLabelAndValue( | ||
| getString(R.string.project_info_name), | ||
| pName | ||
| ) | ||
|
|
||
| binding.infoLocation.setLabelAndValue( | ||
| getString(R.string.project_info_path), | ||
| pPath | ||
| ) | ||
| binding.infoLocation.setOnClickListener { copyToClipboard(pPath) } | ||
|
|
||
| binding.infoTemplate.setLabelAndValue( | ||
| getString(R.string.project_info_template), | ||
| pTemplate ?: unknown | ||
| ) | ||
|
|
||
| binding.infoCreatedAt.setLabelAndValue( | ||
| getString(R.string.date_created_label), | ||
| formatDate(pCreated ?: unknown) | ||
| ) | ||
|
|
||
| binding.infoModifiedAt.setLabelAndValue( | ||
| getString(R.string.date_modified_label), | ||
| formatDate(pModified ?: unknown) | ||
| ) | ||
| } | ||
|
|
||
| // ----------------------------- | ||
| // STRUCTURE | ||
| // ----------------------------- | ||
| private fun bindStructure(details: ProjectDetails) { | ||
| binding.infoSize.setLabelAndValue( | ||
| getString(R.string.project_info_size), details.sizeFormatted | ||
| ) | ||
| binding.infoFilesCount.setLabelAndValue( | ||
| getString(R.string.project_info_files_count), details.numberOfFiles.toString() | ||
| ) | ||
| } | ||
|
|
||
| // ----------------------------- | ||
| // BUILD SETUP | ||
| // ----------------------------- | ||
| private fun bindBuildSetup(details: ProjectDetails) { | ||
| val unknown = getString(R.string.unknown) | ||
|
|
||
| binding.infoLanguage.setLabelAndValue( | ||
| getString(R.string.wizard_language), | ||
| pLang ?: unknown | ||
| ) | ||
| binding.infoGradleVersion.setLabelAndValue( | ||
| getString(R.string.project_info_gradle_v), | ||
| details.gradleVersion | ||
| ) | ||
| binding.infoKotlinVersion.setLabelAndValue( | ||
| getString(R.string.project_info_kotlin_v), | ||
| details.kotlinVersion | ||
| ) | ||
| binding.infoJavaVersion.setLabelAndValue( | ||
| getString(R.string.project_info_java_v), | ||
| details.javaVersion | ||
| ) | ||
| } | ||
|
|
||
| private fun setLoadingState(isLoading: Boolean) { | ||
| if (isLoading) { | ||
| binding.progressHeavyData.visibility = View.VISIBLE | ||
| binding.containerHeavyData.visibility = View.GONE | ||
| } else { | ||
| binding.progressHeavyData.visibility = View.GONE | ||
|
|
||
| binding.containerHeavyData.apply { | ||
| alpha = 0f | ||
| visibility = View.VISIBLE | ||
| animate() | ||
| .alpha(1f) | ||
| .setDuration(300) | ||
| .start() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun copyToClipboard(value: String) { | ||
| copyTextToClipboard(context, value) | ||
| Toast.makeText(requireContext(), getString(R.string.copied), Toast.LENGTH_SHORT).show() | ||
| } | ||
|
|
||
| override fun onDestroyView() { | ||
| super.onDestroyView() | ||
| _binding = null | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.