Skip to content

Commit 70848a1

Browse files
committed
redesigning some activities and dialogs
1 parent c892145 commit 70848a1

File tree

11 files changed

+201
-135
lines changed

11 files changed

+201
-135
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ android {
6464
}
6565

6666
dependencies {
67-
implementation 'com.github.SimpleMobileTools:Simple-Commons:387fbe81cc'
67+
implementation 'com.github.SimpleMobileTools:Simple-Commons:1123a20745'
6868
implementation 'com.github.tibbi:AndroidPdfViewer:da57ff410e'
6969
implementation 'com.github.Stericson:RootTools:df729dcb13'
7070
implementation 'com.github.Stericson:RootShell:1.6'

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/DecompressActivity.kt

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ package com.simplemobiletools.filemanager.pro.activities
33
import android.annotation.SuppressLint
44
import android.net.Uri
55
import android.os.Bundle
6-
import android.view.Menu
7-
import android.view.MenuItem
86
import com.simplemobiletools.commons.dialogs.FilePickerDialog
97
import com.simplemobiletools.commons.extensions.*
8+
import com.simplemobiletools.commons.helpers.NavigationIcon
109
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
1110
import com.simplemobiletools.commons.helpers.isOreoPlus
1211
import com.simplemobiletools.filemanager.pro.R
@@ -26,18 +25,44 @@ class DecompressActivity : SimpleActivity() {
2625
override fun onCreate(savedInstanceState: Bundle?) {
2726
super.onCreate(savedInstanceState)
2827
setContentView(R.layout.activity_decompress)
28+
setupOptionsMenu()
29+
2930
uri = intent.data
3031
if (uri == null) {
3132
toast(R.string.unknown_error_occurred)
3233
return
3334
}
3435

3536
val realPath = getRealPathFromURI(uri!!)
36-
title = realPath?.getFilenameFromPath() ?: Uri.decode(uri.toString().getFilenameFromPath())
37+
decompress_toolbar.title = realPath?.getFilenameFromPath() ?: Uri.decode(uri.toString().getFilenameFromPath())
3738
fillAllListItems(uri!!)
3839
updateCurrentPath("")
3940
}
4041

42+
override fun onResume() {
43+
super.onResume()
44+
setupToolbar(decompress_toolbar, NavigationIcon.Arrow)
45+
}
46+
47+
private fun setupOptionsMenu() {
48+
decompress_toolbar.setOnMenuItemClickListener { menuItem ->
49+
when (menuItem.itemId) {
50+
R.id.decompress -> decompressFiles()
51+
else -> return@setOnMenuItemClickListener false
52+
}
53+
return@setOnMenuItemClickListener true
54+
}
55+
}
56+
57+
override fun onBackPressed() {
58+
if (currentPath.isEmpty()) {
59+
super.onBackPressed()
60+
} else {
61+
val newPath = if (currentPath.contains("/")) currentPath.getParentPath() else ""
62+
updateCurrentPath(newPath)
63+
}
64+
}
65+
4166
private fun updateCurrentPath(path: String) {
4267
currentPath = path
4368
try {
@@ -54,29 +79,6 @@ class DecompressActivity : SimpleActivity() {
5479
}
5580
}
5681

57-
override fun onCreateOptionsMenu(menu: Menu): Boolean {
58-
menuInflater.inflate(R.menu.menu_decompress, menu)
59-
updateMenuItemColors(menu)
60-
return true
61-
}
62-
63-
override fun onOptionsItemSelected(item: MenuItem): Boolean {
64-
when (item.itemId) {
65-
R.id.decompress -> decompressFiles()
66-
}
67-
68-
return true
69-
}
70-
71-
override fun onBackPressed() {
72-
if (currentPath.isEmpty()) {
73-
super.onBackPressed()
74-
} else {
75-
val newPath = if (currentPath.contains("/")) currentPath.getParentPath() else ""
76-
updateCurrentPath(newPath)
77-
}
78-
}
79-
8082
private fun decompressFiles() {
8183
val defaultFolder = getRealPathFromURI(uri!!) ?: internalStoragePath
8284
FilePickerDialog(this, defaultFolder, false, config.showHidden, true, true, showFavoritesButton = true) { destination ->

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/ReadTextActivity.kt

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import android.net.Uri
77
import android.os.Bundle
88
import android.print.PrintAttributes
99
import android.print.PrintManager
10-
import android.view.Menu
11-
import android.view.MenuItem
1210
import android.view.inputmethod.EditorInfo
1311
import android.webkit.WebResourceRequest
1412
import android.webkit.WebView
@@ -47,6 +45,8 @@ class ReadTextActivity : SimpleActivity() {
4745
override fun onCreate(savedInstanceState: Bundle?) {
4846
super.onCreate(savedInstanceState)
4947
setContentView(R.layout.activity_read_text)
48+
setupOptionsMenu()
49+
5050
searchQueryET = findViewById(R.id.search_query)
5151
searchPrevBtn = findViewById(R.id.search_previous)
5252
searchNextBtn = findViewById(R.id.search_next)
@@ -70,7 +70,7 @@ class ReadTextActivity : SimpleActivity() {
7070

7171
val filename = getFilenameFromUri(uri)
7272
if (filename.isNotEmpty()) {
73-
title = Uri.decode(filename)
73+
read_text_toolbar.title = Uri.decode(filename)
7474
}
7575

7676
read_text_view.onGlobalLayout {
@@ -82,21 +82,9 @@ class ReadTextActivity : SimpleActivity() {
8282
setupSearchButtons()
8383
}
8484

85-
override fun onCreateOptionsMenu(menu: Menu): Boolean {
86-
menuInflater.inflate(R.menu.menu_editor, menu)
87-
updateMenuItemColors(menu)
88-
return true
89-
}
90-
91-
override fun onOptionsItemSelected(item: MenuItem): Boolean {
92-
when (item.itemId) {
93-
R.id.menu_search -> openSearch()
94-
R.id.menu_save -> saveText()
95-
R.id.menu_open_with -> openPath(intent.dataString!!, true)
96-
R.id.menu_print -> printText()
97-
else -> return super.onOptionsItemSelected(item)
98-
}
99-
return true
85+
override fun onResume() {
86+
super.onResume()
87+
setupToolbar(read_text_toolbar, NavigationIcon.Arrow)
10088
}
10189

10290
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
@@ -131,6 +119,19 @@ class ReadTextActivity : SimpleActivity() {
131119
}
132120
}
133121

122+
private fun setupOptionsMenu() {
123+
read_text_toolbar.setOnMenuItemClickListener { menuItem ->
124+
when (menuItem.itemId) {
125+
R.id.menu_search -> openSearch()
126+
R.id.menu_save -> saveText()
127+
R.id.menu_open_with -> openPath(intent.dataString!!, true)
128+
R.id.menu_print -> printText()
129+
else -> return@setOnMenuItemClickListener false
130+
}
131+
return@setOnMenuItemClickListener true
132+
}
133+
}
134+
134135
private fun openSearch() {
135136
isSearchActive = true
136137
search_wrapper.beVisible()

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/SaveAsActivity.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import android.net.Uri
55
import android.os.Bundle
66
import com.simplemobiletools.commons.dialogs.FilePickerDialog
77
import com.simplemobiletools.commons.extensions.*
8+
import com.simplemobiletools.commons.helpers.NavigationIcon
89
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
910
import com.simplemobiletools.filemanager.pro.R
1011
import com.simplemobiletools.filemanager.pro.extensions.config
12+
import kotlinx.android.synthetic.main.activity_save_as.*
1113
import java.io.File
1214

1315
class SaveAsActivity : SimpleActivity() {
@@ -54,4 +56,9 @@ class SaveAsActivity : SimpleActivity() {
5456
finish()
5557
}
5658
}
59+
60+
override fun onResume() {
61+
super.onResume()
62+
setupToolbar(activity_save_as_toolbar, NavigationIcon.Arrow)
63+
}
5764
}

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/CompressAsDialog.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
1919
var realPath = path.getParentPath()
2020

2121
view.apply {
22-
file_name.setText(baseFilename)
22+
filename_value.setText(baseFilename)
2323

24-
file_path.text = activity.humanizePath(realPath)
25-
file_path.setOnClickListener {
24+
folder.setText(activity.humanizePath(realPath))
25+
folder.setOnClickListener {
2626
FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden, true, true, showFavoritesButton = true) {
27-
file_path.text = activity.humanizePath(it)
27+
folder.setText(activity.humanizePath(it))
2828
realPath = it
2929
}
3030
}
@@ -35,9 +35,9 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
3535
.setNegativeButton(R.string.cancel, null)
3636
.apply {
3737
activity.setupDialogStuff(view, this, R.string.compress_as) { alertDialog ->
38-
alertDialog.showKeyboard(view.file_name)
38+
alertDialog.showKeyboard(view.filename_value)
3939
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
40-
val name = view.file_name.value
40+
val name = view.filename_value.value
4141
when {
4242
name.isEmpty() -> activity.toast(R.string.empty_name)
4343
name.isAValidFilename() -> {

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/CreateNewItemDialog.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
2020
.setNegativeButton(R.string.cancel, null)
2121
.apply {
2222
activity.setupDialogStuff(view, this, R.string.create_new) { alertDialog ->
23-
alertDialog.showKeyboard(view.item_name)
23+
alertDialog.showKeyboard(view.item_title)
2424
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
25-
val name = view.item_name.value
25+
val name = view.item_title.value
2626
if (name.isEmpty()) {
2727
activity.toast(R.string.empty_name)
2828
} else if (name.isAValidFilename()) {
Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4-
android:id="@+id/decompress_wrapper"
4+
android:id="@+id/decompress_coordinator"
55
android:layout_width="match_parent"
6-
android:layout_height="wrap_content">
6+
android:layout_height="match_parent">
77

8-
<com.simplemobiletools.commons.views.MyRecyclerView
9-
android:id="@+id/decompress_list"
8+
<com.google.android.material.appbar.AppBarLayout
9+
android:id="@+id/decompress_app_bar_layout"
1010
android:layout_width="match_parent"
11-
android:layout_height="match_parent"
12-
android:clipToPadding="false"
13-
android:paddingTop="@dimen/small_margin"
14-
android:scrollbars="none"
15-
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
11+
android:layout_height="wrap_content">
1612

17-
</RelativeLayout>
13+
<com.google.android.material.appbar.MaterialToolbar
14+
android:id="@+id/decompress_toolbar"
15+
android:layout_width="match_parent"
16+
android:layout_height="?attr/actionBarSize"
17+
android:background="@color/color_primary"
18+
app:menu="@menu/menu_decompress"
19+
app:title="@string/decompress"
20+
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
21+
22+
</com.google.android.material.appbar.AppBarLayout>
23+
24+
<RelativeLayout
25+
android:id="@+id/decompress_wrapper"
26+
android:layout_width="match_parent"
27+
android:layout_height="wrap_content"
28+
app:layout_behavior="@string/appbar_scrolling_view_behavior">
29+
30+
<com.simplemobiletools.commons.views.MyRecyclerView
31+
android:id="@+id/decompress_list"
32+
android:layout_width="match_parent"
33+
android:layout_height="match_parent"
34+
android:clipToPadding="false"
35+
android:paddingTop="@dimen/small_margin"
36+
android:scrollbars="none"
37+
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
38+
39+
</RelativeLayout>
40+
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,54 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:id="@+id/read_text_wrapper"
2+
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:id="@+id/read_text_coordinator"
45
android:layout_width="match_parent"
5-
android:layout_height="wrap_content"
6-
android:orientation="vertical">
6+
android:layout_height="match_parent">
77

8-
<include
9-
android:id="@+id/search_wrapper"
10-
layout="@layout/search_bar" />
8+
<com.google.android.material.appbar.AppBarLayout
9+
android:id="@+id/read_text_app_bar_layout"
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content">
12+
13+
<com.google.android.material.appbar.MaterialToolbar
14+
android:id="@+id/read_text_toolbar"
15+
android:layout_width="match_parent"
16+
android:layout_height="?attr/actionBarSize"
17+
android:background="@color/color_primary"
18+
app:menu="@menu/menu_editor"
19+
app:title="@string/file_editor"
20+
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
21+
22+
</com.google.android.material.appbar.AppBarLayout>
1123

12-
<ScrollView
13-
android:id="@+id/read_text_holder"
24+
<LinearLayout
25+
android:id="@+id/read_text_wrapper"
1426
android:layout_width="match_parent"
15-
android:layout_height="match_parent"
16-
android:fillViewport="true">
27+
android:layout_height="wrap_content"
28+
android:orientation="vertical"
29+
app:layout_behavior="@string/appbar_scrolling_view_behavior">
1730

18-
<com.simplemobiletools.filemanager.pro.views.GestureEditText
19-
android:id="@+id/read_text_view"
31+
<include
32+
android:id="@+id/search_wrapper"
33+
layout="@layout/search_bar" />
34+
35+
<ScrollView
36+
android:id="@+id/read_text_holder"
2037
android:layout_width="match_parent"
21-
android:layout_height="wrap_content"
22-
android:background="@null"
23-
android:gravity="top"
24-
android:inputType="textMultiLine|textNoSuggestions"
25-
android:padding="@dimen/medium_margin"
26-
android:textCursorDrawable="@null"
27-
android:textSize="@dimen/smaller_text_size" />
28-
29-
</ScrollView>
30-
</LinearLayout>
38+
android:layout_height="match_parent"
39+
android:fillViewport="true">
40+
41+
<com.simplemobiletools.filemanager.pro.views.GestureEditText
42+
android:id="@+id/read_text_view"
43+
android:layout_width="match_parent"
44+
android:layout_height="wrap_content"
45+
android:background="@null"
46+
android:gravity="top"
47+
android:inputType="textMultiLine|textNoSuggestions"
48+
android:padding="@dimen/medium_margin"
49+
android:textCursorDrawable="@null"
50+
android:textSize="@dimen/smaller_text_size" />
51+
52+
</ScrollView>
53+
</LinearLayout>
54+
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:id="@+id/activity_save_as_holder"
2+
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:id="@+id/activity_save_as_coordinator"
45
android:layout_width="match_parent"
56
android:layout_height="match_parent">
67

7-
</RelativeLayout>
8+
<com.google.android.material.appbar.AppBarLayout
9+
android:id="@+id/activity_save_as_app_bar_layout"
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content">
12+
13+
<com.google.android.material.appbar.MaterialToolbar
14+
android:id="@+id/activity_save_as_toolbar"
15+
android:layout_width="match_parent"
16+
android:layout_height="?attr/actionBarSize"
17+
android:background="@color/color_primary"
18+
app:title="@string/save_as"
19+
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
20+
21+
</com.google.android.material.appbar.AppBarLayout>
22+
23+
<RelativeLayout
24+
android:id="@+id/activity_save_as_holder"
25+
android:layout_width="match_parent"
26+
android:layout_height="match_parent"
27+
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
28+
29+
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 commit comments

Comments
 (0)