Skip to content

Commit 0b05f31

Browse files
committed
updating commons with some new theming
1 parent 9dafec1 commit 0b05f31

16 files changed

+331
-326
lines changed

app/build.gradle

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

6767
dependencies {
68-
implementation 'com.github.SimpleMobileTools:Simple-Commons:15387bc4a3'
68+
implementation 'com.github.SimpleMobileTools:Simple-Commons:0f166c0688'
6969

7070
kapt 'androidx.room:room-compiler:2.4.2'
7171
implementation 'androidx.room:room-runtime:2.4.2'

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
android:name=".activities.MainActivity"
3232
android:exported="false" />
3333

34-
3534
<activity
3635
android:name=".activities.ManageClipboardItemsActivity"
3736
android:exported="false"

app/src/main/kotlin/com/simplemobiletools/keyboard/activities/MainActivity.kt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import android.graphics.drawable.LayerDrawable
55
import android.graphics.drawable.RippleDrawable
66
import android.os.Bundle
77
import android.provider.Settings
8-
import android.view.Menu
9-
import android.view.MenuItem
108
import android.view.inputmethod.InputMethodManager
119
import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
1210
import com.simplemobiletools.commons.extensions.*
@@ -20,6 +18,7 @@ class MainActivity : SimpleActivity() {
2018
override fun onCreate(savedInstanceState: Bundle?) {
2119
super.onCreate(savedInstanceState)
2220
setContentView(R.layout.activity_main)
21+
setupOptionsMenu()
2322
appLaunched(BuildConfig.APPLICATION_ID)
2423
change_keyboard_holder.setOnClickListener {
2524
(getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager).showInputMethodPicker()
@@ -28,6 +27,7 @@ class MainActivity : SimpleActivity() {
2827

2928
override fun onResume() {
3029
super.onResume()
30+
setupToolbar(main_toolbar)
3131
if (!isKeyboardEnabled()) {
3232
ConfirmationAdvancedDialog(this, messageId = R.string.redirection_note, positive = R.string.ok, negative = 0) { success ->
3333
if (success) {
@@ -41,24 +41,24 @@ class MainActivity : SimpleActivity() {
4141
}
4242
}
4343

44-
updateTextColors(main_holder)
44+
updateTextColors(main_nested_scrollview)
4545
updateChangeKeyboardColor()
46-
main_holder.setBackgroundColor(getProperBackgroundColor())
4746
}
4847

49-
override fun onCreateOptionsMenu(menu: Menu): Boolean {
50-
menuInflater.inflate(R.menu.menu_main, menu)
51-
updateMenuItemColors(menu)
52-
return true
53-
}
54-
55-
override fun onOptionsItemSelected(item: MenuItem): Boolean {
56-
when (item.itemId) {
57-
R.id.settings -> launchSettings()
58-
R.id.about -> launchAbout()
59-
else -> return super.onOptionsItemSelected(item)
48+
private fun setupOptionsMenu() {
49+
main_toolbar.setOnMenuItemClickListener { menuItem ->
50+
when (menuItem.itemId) {
51+
R.id.settings -> {
52+
launchSettings()
53+
true
54+
}
55+
R.id.about -> {
56+
launchAbout()
57+
true
58+
}
59+
else -> false
60+
}
6061
}
61-
return true
6262
}
6363

6464
private fun launchSettings() {

app/src/main/kotlin/com/simplemobiletools/keyboard/activities/ManageClipboardItemsActivity.kt

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@ import android.app.Activity
44
import android.content.ActivityNotFoundException
55
import android.content.Intent
66
import android.os.Bundle
7-
import android.view.Menu
8-
import android.view.MenuItem
97
import android.widget.Toast
108
import com.google.gson.Gson
119
import com.google.gson.reflect.TypeToken
1210
import com.simplemobiletools.commons.dialogs.FilePickerDialog
1311
import com.simplemobiletools.commons.extensions.*
14-
import com.simplemobiletools.commons.helpers.PERMISSION_READ_STORAGE
15-
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
16-
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
17-
import com.simplemobiletools.commons.helpers.isQPlus
12+
import com.simplemobiletools.commons.helpers.*
1813
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
1914
import com.simplemobiletools.keyboard.R
2015
import com.simplemobiletools.keyboard.adapters.ClipsActivityAdapter
@@ -36,6 +31,7 @@ class ManageClipboardItemsActivity : SimpleActivity(), RefreshRecyclerViewListen
3631
override fun onCreate(savedInstanceState: Bundle?) {
3732
super.onCreate(savedInstanceState)
3833
setContentView(R.layout.activity_manage_clipboard_items)
34+
setupOptionsMenu()
3935
updateTextColors(clipboard_items_wrapper)
4036
updateClips()
4137

@@ -49,21 +45,9 @@ class ManageClipboardItemsActivity : SimpleActivity(), RefreshRecyclerViewListen
4945
}
5046
}
5147

52-
override fun onCreateOptionsMenu(menu: Menu): Boolean {
53-
menuInflater.inflate(R.menu.menu_manage_clipboard_items, menu)
54-
updateMenuItemColors(menu)
55-
return super.onCreateOptionsMenu(menu)
56-
}
57-
58-
override fun onOptionsItemSelected(item: MenuItem): Boolean {
59-
when (item.itemId) {
60-
R.id.add_clipboard_item -> addOrEditClip()
61-
R.id.export_clips -> exportClips()
62-
R.id.import_clips -> importClips()
63-
else -> return super.onOptionsItemSelected(item)
64-
}
65-
66-
return true
48+
override fun onResume() {
49+
super.onResume()
50+
setupToolbar(clipboard_toolbar, NavigationIcon.Arrow)
6751
}
6852

6953
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
@@ -77,6 +61,27 @@ class ManageClipboardItemsActivity : SimpleActivity(), RefreshRecyclerViewListen
7761
}
7862
}
7963

64+
65+
private fun setupOptionsMenu() {
66+
clipboard_toolbar.setOnMenuItemClickListener { menuItem ->
67+
when (menuItem.itemId) {
68+
R.id.add_clipboard_item -> {
69+
addOrEditClip()
70+
true
71+
}
72+
R.id.export_clips -> {
73+
exportClips()
74+
true
75+
}
76+
R.id.import_clips -> {
77+
importClips()
78+
true
79+
}
80+
else -> false
81+
}
82+
}
83+
}
84+
8085
override fun refreshItems() {
8186
updateClips()
8287
}

app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package com.simplemobiletools.keyboard.activities
22

33
import android.content.Intent
44
import android.os.Bundle
5-
import android.view.Menu
65
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
76
import com.simplemobiletools.commons.extensions.*
7+
import com.simplemobiletools.commons.helpers.NavigationIcon
88
import com.simplemobiletools.commons.models.RadioItem
99
import com.simplemobiletools.keyboard.R
1010
import com.simplemobiletools.keyboard.extensions.config
@@ -22,6 +22,7 @@ class SettingsActivity : SimpleActivity() {
2222

2323
override fun onResume() {
2424
super.onResume()
25+
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
2526

2627
setupPurchaseThankYou()
2728
setupCustomizeColors()
@@ -31,7 +32,7 @@ class SettingsActivity : SimpleActivity() {
3132
setupShowPopupOnKeypress()
3233
setupKeyboardLanguage()
3334

34-
updateTextColors(settings_scrollview)
35+
updateTextColors(settings_nested_scrollview)
3536

3637
arrayOf(settings_color_customization_label, settings_general_settings_label).forEach {
3738
it.setTextColor(getProperPrimaryColor())
@@ -42,11 +43,6 @@ class SettingsActivity : SimpleActivity() {
4243
}
4344
}
4445

45-
override fun onCreateOptionsMenu(menu: Menu): Boolean {
46-
updateMenuItemColors(menu)
47-
return super.onCreateOptionsMenu(menu)
48-
}
49-
5046
private fun setupPurchaseThankYou() {
5147
settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled())
5248

app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/AddOrEditClipDialog.kt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
package com.simplemobiletools.keyboard.dialogs
22

33
import androidx.appcompat.app.AlertDialog
4-
import androidx.appcompat.widget.AppCompatEditText
54
import com.simplemobiletools.commons.activities.BaseSimpleActivity
65
import com.simplemobiletools.commons.extensions.*
76
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
87
import com.simplemobiletools.keyboard.R
98
import com.simplemobiletools.keyboard.helpers.ClipsHelper
109
import com.simplemobiletools.keyboard.models.Clip
10+
import kotlinx.android.synthetic.main.dialog_add_or_edit_clip.view.*
1111

1212
class AddOrEditClipDialog(val activity: BaseSimpleActivity, val originalClip: Clip?, val callback: () -> Unit) {
1313
init {
14-
val layoutId = if (activity.baseConfig.isUsingSystemTheme) {
15-
R.layout.dialog_add_or_edit_clip_material
16-
} else {
17-
R.layout.dialog_add_or_edit_clip
18-
}
19-
20-
val view = activity.layoutInflater.inflate(layoutId, null).apply {
14+
val view = activity.layoutInflater.inflate(R.layout.dialog_add_or_edit_clip, null).apply {
2115
if (originalClip != null) {
22-
findViewById<AppCompatEditText>(R.id.add_clip_value).setText(originalClip.value)
16+
add_clip_value.setText(originalClip.value)
2317
}
2418
}
2519

@@ -28,9 +22,9 @@ class AddOrEditClipDialog(val activity: BaseSimpleActivity, val originalClip: Cl
2822
.setNegativeButton(R.string.cancel, null)
2923
.apply {
3024
activity.setupDialogStuff(view, this) { alertDialog ->
31-
alertDialog.showKeyboard(view.findViewById(R.id.add_clip_value))
25+
alertDialog.showKeyboard(view.add_clip_value)
3226
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
33-
val clipValue = view.findViewById<AppCompatEditText>(R.id.add_clip_value).value
27+
val clipValue = view.add_clip_value.value
3428
if (clipValue.isEmpty()) {
3529
activity.toast(R.string.value_cannot_be_empty)
3630
return@setOnClickListener

app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/ExportClipsDialog.kt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.simplemobiletools.keyboard.dialogs
22

33
import androidx.appcompat.app.AlertDialog
4-
import androidx.appcompat.widget.AppCompatEditText
54
import com.simplemobiletools.commons.activities.BaseSimpleActivity
65
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
76
import com.simplemobiletools.commons.dialogs.FilePickerDialog
@@ -11,8 +10,7 @@ import com.simplemobiletools.keyboard.extensions.config
1110
import kotlinx.android.synthetic.main.dialog_export_clips.view.*
1211

1312
class ExportClipsDialog(
14-
val activity: BaseSimpleActivity, path: String, val hidePath: Boolean,
15-
callback: (path: String, filename: String) -> Unit
13+
val activity: BaseSimpleActivity, path: String, val hidePath: Boolean, callback: (path: String, filename: String) -> Unit
1614
) {
1715
init {
1816
var folder = if (path.isNotEmpty() && activity.getDoesFilePathExist(path)) {
@@ -21,14 +19,8 @@ class ExportClipsDialog(
2119
activity.internalStoragePath
2220
}
2321

24-
val layoutId = if (activity.baseConfig.isUsingSystemTheme) {
25-
R.layout.dialog_export_clips_material
26-
} else {
27-
R.layout.dialog_export_clips
28-
}
29-
30-
val view = activity.layoutInflater.inflate(layoutId, null).apply {
31-
findViewById<AppCompatEditText>(R.id.export_clips_filename).setText("${activity.getString(R.string.app_launcher_name)}_${activity.getCurrentFormattedDateTime()}")
22+
val view = activity.layoutInflater.inflate(R.layout.dialog_export_clips, null).apply {
23+
export_clips_filename.setText("${activity.getString(R.string.app_launcher_name)}_${activity.getCurrentFormattedDateTime()}")
3224

3325
if (hidePath) {
3426
export_clips_path_label.beGone()
@@ -49,9 +41,9 @@ class ExportClipsDialog(
4941
.setNegativeButton(R.string.cancel, null)
5042
.apply {
5143
activity.setupDialogStuff(view, this, R.string.export_clipboard_items) { alertDialog ->
52-
alertDialog.showKeyboard(view.findViewById(R.id.export_clips_filename))
44+
alertDialog.showKeyboard(view.export_clips_filename)
5345
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
54-
val filename = view.findViewById<AppCompatEditText>(R.id.export_clips_filename).value
46+
val filename = view.export_clips_filename.value
5547
if (filename.isEmpty()) {
5648
activity.toast(R.string.filename_cannot_be_empty)
5749
return@setOnClickListener
Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,61 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:id="@+id/main_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/main_coordinator"
45
android:layout_width="match_parent"
56
android:layout_height="match_parent">
67

7-
<RelativeLayout
8-
android:id="@+id/change_keyboard_holder"
9-
android:layout_width="wrap_content"
10-
android:layout_height="wrap_content"
11-
android:layout_margin="@dimen/big_margin">
8+
<com.google.android.material.appbar.AppBarLayout
9+
android:id="@+id/main_app_bar_layout"
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content">
1212

13-
<android.widget.TextView
14-
android:id="@+id/change_keyboard"
15-
style="@style/ColoredButtonStyle"
16-
android:layout_width="wrap_content"
17-
android:layout_height="wrap_content"
18-
android:text="@string/change_keyboard" />
13+
<com.google.android.material.appbar.MaterialToolbar
14+
android:id="@+id/main_toolbar"
15+
android:layout_width="match_parent"
16+
android:layout_height="?attr/actionBarSize"
17+
android:background="@color/color_primary"
18+
app:menu="@menu/menu_main"
19+
app:title="@string/app_launcher_name"
20+
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
1921

20-
</RelativeLayout>
22+
</com.google.android.material.appbar.AppBarLayout>
2123

22-
<com.simplemobiletools.commons.views.MyEditText
23-
android:id="@+id/text_edittext"
24+
<androidx.core.widget.NestedScrollView
25+
android:id="@+id/main_nested_scrollview"
2426
android:layout_width="match_parent"
25-
android:layout_height="wrap_content"
26-
android:layout_below="@+id/change_keyboard_holder"
27-
android:layout_margin="@dimen/activity_margin" />
27+
android:layout_height="match_parent"
28+
android:fillViewport="true"
29+
android:scrollbars="none"
30+
app:layout_behavior="@string/appbar_scrolling_view_behavior">
31+
32+
<RelativeLayout
33+
android:id="@+id/change_keyboard_wrapper"
34+
android:layout_width="match_parent"
35+
android:layout_height="wrap_content">
36+
37+
<RelativeLayout
38+
android:id="@+id/change_keyboard_holder"
39+
android:layout_width="wrap_content"
40+
android:layout_height="wrap_content"
41+
android:layout_margin="@dimen/normal_margin">
42+
43+
<android.widget.TextView
44+
android:id="@+id/change_keyboard"
45+
style="@style/ColoredButtonStyle"
46+
android:layout_width="wrap_content"
47+
android:layout_height="wrap_content"
48+
android:text="@string/change_keyboard" />
49+
50+
</RelativeLayout>
51+
52+
<com.simplemobiletools.commons.views.MyEditText
53+
android:id="@+id/text_edittext"
54+
android:layout_width="match_parent"
55+
android:layout_height="wrap_content"
56+
android:layout_below="@+id/change_keyboard_holder"
57+
android:layout_margin="@dimen/activity_margin" />
2858

29-
</RelativeLayout>
59+
</RelativeLayout>
60+
</androidx.core.widget.NestedScrollView>
61+
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 commit comments

Comments
 (0)