redesigning some activities and dialogs

This commit is contained in:
tibbi 2022-07-23 22:49:12 +02:00
parent c892145536
commit 70848a1840
11 changed files with 201 additions and 135 deletions

View file

@ -64,7 +64,7 @@ android {
}
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:387fbe81cc'
implementation 'com.github.SimpleMobileTools:Simple-Commons:1123a20745'
implementation 'com.github.tibbi:AndroidPdfViewer:da57ff410e'
implementation 'com.github.Stericson:RootTools:df729dcb13'
implementation 'com.github.Stericson:RootShell:1.6'

View file

@ -3,10 +3,9 @@ package com.simplemobiletools.filemanager.pro.activities
import android.annotation.SuppressLint
import android.net.Uri
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isOreoPlus
import com.simplemobiletools.filemanager.pro.R
@ -26,6 +25,8 @@ class DecompressActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_decompress)
setupOptionsMenu()
uri = intent.data
if (uri == null) {
toast(R.string.unknown_error_occurred)
@ -33,11 +34,35 @@ class DecompressActivity : SimpleActivity() {
}
val realPath = getRealPathFromURI(uri!!)
title = realPath?.getFilenameFromPath() ?: Uri.decode(uri.toString().getFilenameFromPath())
decompress_toolbar.title = realPath?.getFilenameFromPath() ?: Uri.decode(uri.toString().getFilenameFromPath())
fillAllListItems(uri!!)
updateCurrentPath("")
}
override fun onResume() {
super.onResume()
setupToolbar(decompress_toolbar, NavigationIcon.Arrow)
}
private fun setupOptionsMenu() {
decompress_toolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.decompress -> decompressFiles()
else -> return@setOnMenuItemClickListener false
}
return@setOnMenuItemClickListener true
}
}
override fun onBackPressed() {
if (currentPath.isEmpty()) {
super.onBackPressed()
} else {
val newPath = if (currentPath.contains("/")) currentPath.getParentPath() else ""
updateCurrentPath(newPath)
}
}
private fun updateCurrentPath(path: String) {
currentPath = path
try {
@ -54,29 +79,6 @@ class DecompressActivity : SimpleActivity() {
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_decompress, menu)
updateMenuItemColors(menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.decompress -> decompressFiles()
}
return true
}
override fun onBackPressed() {
if (currentPath.isEmpty()) {
super.onBackPressed()
} else {
val newPath = if (currentPath.contains("/")) currentPath.getParentPath() else ""
updateCurrentPath(newPath)
}
}
private fun decompressFiles() {
val defaultFolder = getRealPathFromURI(uri!!) ?: internalStoragePath
FilePickerDialog(this, defaultFolder, false, config.showHidden, true, true, showFavoritesButton = true) { destination ->

View file

@ -7,8 +7,6 @@ import android.net.Uri
import android.os.Bundle
import android.print.PrintAttributes
import android.print.PrintManager
import android.view.Menu
import android.view.MenuItem
import android.view.inputmethod.EditorInfo
import android.webkit.WebResourceRequest
import android.webkit.WebView
@ -47,6 +45,8 @@ class ReadTextActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_read_text)
setupOptionsMenu()
searchQueryET = findViewById(R.id.search_query)
searchPrevBtn = findViewById(R.id.search_previous)
searchNextBtn = findViewById(R.id.search_next)
@ -70,7 +70,7 @@ class ReadTextActivity : SimpleActivity() {
val filename = getFilenameFromUri(uri)
if (filename.isNotEmpty()) {
title = Uri.decode(filename)
read_text_toolbar.title = Uri.decode(filename)
}
read_text_view.onGlobalLayout {
@ -82,21 +82,9 @@ class ReadTextActivity : SimpleActivity() {
setupSearchButtons()
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_editor, menu)
updateMenuItemColors(menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_search -> openSearch()
R.id.menu_save -> saveText()
R.id.menu_open_with -> openPath(intent.dataString!!, true)
R.id.menu_print -> printText()
else -> return super.onOptionsItemSelected(item)
}
return true
override fun onResume() {
super.onResume()
setupToolbar(read_text_toolbar, NavigationIcon.Arrow)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
@ -131,6 +119,19 @@ class ReadTextActivity : SimpleActivity() {
}
}
private fun setupOptionsMenu() {
read_text_toolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.menu_search -> openSearch()
R.id.menu_save -> saveText()
R.id.menu_open_with -> openPath(intent.dataString!!, true)
R.id.menu_print -> printText()
else -> return@setOnMenuItemClickListener false
}
return@setOnMenuItemClickListener true
}
}
private fun openSearch() {
isSearchActive = true
search_wrapper.beVisible()

View file

@ -5,9 +5,11 @@ import android.net.Uri
import android.os.Bundle
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.filemanager.pro.R
import com.simplemobiletools.filemanager.pro.extensions.config
import kotlinx.android.synthetic.main.activity_save_as.*
import java.io.File
class SaveAsActivity : SimpleActivity() {
@ -54,4 +56,9 @@ class SaveAsActivity : SimpleActivity() {
finish()
}
}
override fun onResume() {
super.onResume()
setupToolbar(activity_save_as_toolbar, NavigationIcon.Arrow)
}
}

View file

@ -19,12 +19,12 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
var realPath = path.getParentPath()
view.apply {
file_name.setText(baseFilename)
filename_value.setText(baseFilename)
file_path.text = activity.humanizePath(realPath)
file_path.setOnClickListener {
folder.setText(activity.humanizePath(realPath))
folder.setOnClickListener {
FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden, true, true, showFavoritesButton = true) {
file_path.text = activity.humanizePath(it)
folder.setText(activity.humanizePath(it))
realPath = it
}
}
@ -35,9 +35,9 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this, R.string.compress_as) { alertDialog ->
alertDialog.showKeyboard(view.file_name)
alertDialog.showKeyboard(view.filename_value)
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
val name = view.file_name.value
val name = view.filename_value.value
when {
name.isEmpty() -> activity.toast(R.string.empty_name)
name.isAValidFilename() -> {

View file

@ -20,9 +20,9 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this, R.string.create_new) { alertDialog ->
alertDialog.showKeyboard(view.item_name)
alertDialog.showKeyboard(view.item_title)
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
val name = view.item_name.value
val name = view.item_title.value
if (name.isEmpty()) {
activity.toast(R.string.empty_name)
} else if (name.isAValidFilename()) {

View file

@ -1,10 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:id="@+id/decompress_wrapper"
android:id="@+id/decompress_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/decompress_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/decompress_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:menu="@menu/menu_decompress"
app:title="@string/decompress"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:id="@+id/decompress_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/decompress_list"
android:layout_width="match_parent"
@ -15,3 +37,4 @@
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,9 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:id="@+id/read_text_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/read_text_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/read_text_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:menu="@menu/menu_editor"
app:title="@string/file_editor"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:id="@+id/read_text_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<include
android:id="@+id/search_wrapper"
@ -28,3 +51,4 @@
</ScrollView>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,7 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_save_as_holder"
<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/activity_save_as_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/activity_save_as_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/activity_save_as_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:title="@string/save_as"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:id="@+id/activity_save_as_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dialog_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -8,55 +7,36 @@
android:paddingTop="@dimen/medium_margin"
android:paddingEnd="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/file_path_label"
<com.simplemobiletools.commons.views.MyTextInputLayout
android:id="@+id/folder_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/small_margin"
android:layout_marginTop="@dimen/activity_margin"
android:text="@string/path"
android:textSize="@dimen/smaller_text_size" />
android:layout_marginBottom="@dimen/activity_margin"
android:hint="@string/folder">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/file_path"
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/folder"
style="@style/UnclickableEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/file_path_label"
android:paddingStart="@dimen/small_margin"
android:paddingTop="@dimen/small_margin"
android:paddingEnd="@dimen/small_margin"
android:paddingBottom="@dimen/activity_margin"
android:textSize="@dimen/normal_text_size"
tools:text="/storage/emulated/0" />
android:layout_height="wrap_content" />
</com.simplemobiletools.commons.views.MyTextInputLayout>
<com.simplemobiletools.commons.views.MyTextInputLayout
android:id="@+id/file_name_hint"
android:id="@+id/filename_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/file_path"
android:layout_toStartOf="@+id/file_extension"
android:hint="@string/filename">
android:layout_below="@+id/folder_hint"
android:hint="@string/filename_without_zip">
<com.simplemobiletools.commons.views.MyEditText
android:id="@+id/file_name"
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/filename_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/medium_margin"
android:inputType="textCapSentences"
android:singleLine="true"
android:textCursorDrawable="@null"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/bigger_text_size" />
</com.simplemobiletools.commons.views.MyTextInputLayout>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/file_extension"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/file_name_hint"
android:layout_alignParentEnd="true"
android:layout_marginBottom="@dimen/small_margin"
android:text=".zip"
android:textSize="@dimen/normal_text_size"
tools:ignore="HardcodedText" />
</RelativeLayout>

View file

@ -8,15 +8,23 @@
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyEditText
android:id="@+id/item_name"
<com.simplemobiletools.commons.views.MyTextInputLayout
android:id="@+id/item_title_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:hint="@string/title">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapSentences"
android:singleLine="true"
android:textCursorDrawable="@null"
android:textSize="@dimen/normal_text_size" />
android:textSize="@dimen/bigger_text_size" />
</com.simplemobiletools.commons.views.MyTextInputLayout>
<RadioGroup
android:id="@+id/dialog_radio_group"
@ -27,7 +35,6 @@
android:id="@+id/dialog_radio_directory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/medium_margin"
android:checked="true"
android:text="@string/folder" />