Skip to content

Commit 58f36fd

Browse files
committed
feat: improve design
1 parent 9454cd7 commit 58f36fd

File tree

21 files changed

+231
-167
lines changed

21 files changed

+231
-167
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,11 @@
2727
<activity
2828
android:name=".ui.view.MainActivity"
2929
android:screenOrientation="portrait"
30-
android:theme="@style/Theme.Sapio"
31-
android:windowSoftInputMode="adjustResize"
32-
android:exported="true">
33-
</activity>
34-
<activity
35-
android:name=".ui.view.PreferencesActivity"
3630
android:theme="@style/Theme.Sapio.NoActionBar"
37-
android:screenOrientation="portrait"
31+
android:windowSoftInputMode="adjustResize"
3832
android:exported="true">
3933
</activity>
34+
4035
<activity
4136
android:name=".ui.view.EvaluationsActivity"
4237
android:theme="@style/Theme.Sapio.NoActionBar"

app/src/main/java/com/klee/sapio/ui/view/AboutActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class AboutActivity : AppCompatActivity() {
1414

1515
companion object {
1616
const val RATING_RULES = "https://github.com/jonathanklee/Sapio?tab=readme-ov-file#rating"
17+
const val GITHUB_URL = "https://github.com/jonathanklee/Sapio"
1718
}
1819

1920
override fun onCreate(savedInstanceState: Bundle?) {

app/src/main/java/com/klee/sapio/ui/view/MainActivity.kt

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
package com.klee.sapio.ui.view
22

3-
import android.content.Intent
4-
import android.net.Uri
53
import android.os.Bundle
6-
import android.view.Menu
7-
import android.view.MenuInflater
8-
import android.view.MenuItem
94
import android.view.ViewGroup
105
import androidx.appcompat.app.AppCompatActivity
116
import androidx.core.view.ViewCompat
@@ -40,6 +35,7 @@ class MainActivity : AppCompatActivity() {
4035
R.id.feed -> displayFragment(FeedFragment())
4136
R.id.search -> displayFragment(SearchFragment())
4237
R.id.contribute -> displayFragment(ContributeFragment())
38+
R.id.options -> displayFragment(PreferencesFragment())
4339
}
4440
return@setOnItemSelectedListener true
4541
}
@@ -66,30 +62,4 @@ class MainActivity : AppCompatActivity() {
6662
WindowInsetsCompat.CONSUMED
6763
}
6864
}
69-
70-
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
71-
val inflater: MenuInflater = menuInflater
72-
inflater.inflate(R.menu.menu, menu)
73-
return true
74-
}
75-
76-
override fun onOptionsItemSelected(item: MenuItem): Boolean {
77-
return when (item.itemId) {
78-
R.id.settings -> {
79-
val intent = Intent(this@MainActivity, PreferencesActivity::class.java)
80-
startActivity(intent)
81-
true
82-
}
83-
R.id.about -> {
84-
val intent = Intent(this@MainActivity, AboutActivity::class.java)
85-
startActivity(intent)
86-
true
87-
}
88-
R.id.donate -> {
89-
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(DONATE_URL)))
90-
true
91-
}
92-
else -> super.onOptionsItemSelected(item)
93-
}
94-
}
9565
}

app/src/main/java/com/klee/sapio/ui/view/PreferencesActivity.kt

Lines changed: 0 additions & 25 deletions
This file was deleted.

app/src/main/java/com/klee/sapio/ui/view/PreferencesFragment.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.klee.sapio.ui.view
22

3+
import android.content.Intent
4+
import android.net.Uri
35
import android.os.Bundle
46
import android.view.View
57
import androidx.core.view.ViewCompat
68
import androidx.core.view.WindowInsetsCompat
79
import androidx.core.view.updatePadding
10+
import androidx.preference.Preference
811
import androidx.preference.PreferenceFragmentCompat
912
import com.klee.sapio.R
1013

@@ -30,5 +33,29 @@ class PreferencesFragment : PreferenceFragmentCompat() {
3033

3134
WindowInsetsCompat.CONSUMED
3235
}
36+
37+
setupPreferenceClickListeners()
38+
}
39+
40+
private fun setupPreferenceClickListeners() {
41+
findPreference<Preference>("github_star_preference")?.setOnPreferenceClickListener {
42+
val githubUrl = getString(R.string.github_url)
43+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(githubUrl))
44+
startActivity(intent)
45+
true
46+
}
47+
48+
findPreference<Preference>("about_preference")?.setOnPreferenceClickListener {
49+
val intent = Intent(requireContext(), AboutActivity::class.java)
50+
startActivity(intent)
51+
true
52+
}
53+
54+
findPreference<Preference>("donate_preference")?.setOnPreferenceClickListener {
55+
val donateUrl = "https://ko-fi.com/jnthnkl"
56+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(donateUrl))
57+
startActivity(intent)
58+
true
59+
}
3360
}
3461
}

app/src/main/java/com/klee/sapio/ui/view/SearchFragment.kt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class SearchFragment : Fragment() {
6161
onTextChanged(editable, coroutineScope)
6262
}
6363

64+
setupClearButton()
6465
setSearchIconsColor()
6566

6667
return mBinding.root
@@ -102,6 +103,16 @@ class SearchFragment : Fragment() {
102103
}
103104
}
104105

106+
private fun setupClearButton() {
107+
mBinding.editTextSearch.addTextChangedListener { text ->
108+
mBinding.clearSearch.visibility = if (text?.isNotEmpty() == true) View.VISIBLE else View.GONE
109+
}
110+
111+
mBinding.clearSearch.setOnClickListener {
112+
mBinding.editTextSearch.text?.clear()
113+
}
114+
}
115+
105116
private fun setSearchIconsColor() {
106117
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
107118
mBinding.searchIcon.setColorFilter(
@@ -133,17 +144,15 @@ class SearchFragment : Fragment() {
133144
private fun showResults(visible: Boolean) {
134145
if (visible) {
135146
mBinding.recyclerView.visibility = View.VISIBLE
136-
mBinding.searchIconBig.visibility = View.INVISIBLE
137-
mBinding.searchText.visibility = View.INVISIBLE
147+
mBinding.emptyState.visibility = View.GONE
138148
} else {
139149
mBinding.recyclerView.visibility = View.INVISIBLE
140-
mBinding.searchIconBig.visibility = View.VISIBLE
141-
mBinding.searchText.visibility = View.VISIBLE
150+
mBinding.emptyState.visibility = View.VISIBLE
142151
}
143152
}
144153

145154
private fun showKeyboard() {
146-
mHandler.postDelayed({
155+
mBinding.editTextSearch.post {
147156
mBinding.editTextSearch.requestFocus()
148157

149158
val inputMethodManager =
@@ -154,6 +163,6 @@ class SearchFragment : Fragment() {
154163
mBinding.editTextSearch,
155164
InputMethodManager.SHOW_IMPLICIT
156165
)
157-
}, KEYBOARD_DELAY_MS)
166+
}
158167
}
159168
}

app/src/main/java/com/klee/sapio/ui/viewmodel/AppEvaluationsViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import com.klee.sapio.domain.FetchAppMicrogRiskyEvaluationUseCase
1111
import com.klee.sapio.domain.FetchAppMicrogSecureEvaluationUseCase
1212
import com.klee.sapio.domain.FetchIconUrlUseCase
1313
import dagger.hilt.android.lifecycle.HiltViewModel
14-
import kotlinx.coroutines.Dispatchers
1514
import kotlinx.coroutines.CoroutineDispatcher
15+
import kotlinx.coroutines.Dispatchers
1616
import kotlinx.coroutines.launch
1717
import kotlinx.coroutines.withContext
1818
import javax.inject.Inject
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="#000000"
7+
android:alpha="0.8">
8+
<path
9+
android:fillColor="#FFFFFFFF"
10+
android:pathData="M19.14,12.94C19.18,12.64 19.2,12.33 19.2,12.02C19.2,11.71 19.18,11.39 19.13,11.09L21.17,9.51C21.35,9.37 21.4,9.1 21.29,8.9L19.39,5.58C19.27,5.36 19.03,5.3 18.8,5.38L16.41,6.34C15.9,5.95 15.37,5.62 14.77,5.38L14.47,3.1C14.44,2.86 14.23,2.68 13.98,2.68H10.18C9.93,2.68 9.72,2.86 9.68,3.11L9.38,5.39C8.78,5.64 8.25,5.96 7.74,6.35L5.35,5.39C5.11,5.29 4.87,5.37 4.75,5.59L2.85,8.91C2.73,9.12 2.79,9.38 2.97,9.52L5.01,11.1C4.96,11.4 4.94,11.71 4.94,12.02C4.94,12.33 4.96,12.64 5.01,12.94L2.97,14.52C2.79,14.66 2.74,14.93 2.85,15.13L4.75,18.45C4.87,18.67 5.11,18.73 5.35,18.65L7.74,17.69C8.25,18.08 8.78,18.41 9.38,18.65L9.68,20.93C9.72,21.18 9.93,21.36 10.18,21.36H13.98C14.23,21.36 14.44,21.18 14.48,20.93L14.78,18.65C15.38,18.4 15.91,18.08 16.42,17.69L18.81,18.65C19.04,18.74 19.28,18.66 19.4,18.44L21.3,15.12C21.42,14.91 21.37,14.65 21.19,14.51L19.14,12.94ZM12.08,15.5C10.15,15.5 8.58,13.93 8.58,12C8.58,10.07 10.15,8.5 12.08,8.5C14.01,8.5 15.58,10.07 15.58,12C15.58,13.93 14.01,15.5 12.08,15.5Z"/>
11+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="?attr/colorOnSurfaceVariant">
7+
<path
8+
android:fillColor="#FFFFFFFF"
9+
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12 19,6.41Z"/>
10+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="?attr/colorOnSurface">
7+
<path
8+
android:fillColor="#FFFFFFFF"
9+
android:pathData="M19.14,12.94C19.18,12.64 19.2,12.33 19.2,12.02C19.2,11.71 19.18,11.39 19.13,11.09L21.17,9.51C21.35,9.37 21.4,9.1 21.29,8.9L19.39,5.58C19.27,5.36 19.03,5.3 18.8,5.38L16.41,6.34C15.9,5.95 15.37,5.62 14.77,5.38L14.47,3.1C14.44,2.86 14.23,2.68 13.98,2.68H10.18C9.93,2.68 9.72,2.86 9.68,3.11L9.38,5.39C8.78,5.64 8.25,5.96 7.74,6.35L5.35,5.39C5.11,5.29 4.87,5.37 4.75,5.59L2.85,8.91C2.73,9.12 2.79,9.38 2.97,9.52L5.01,11.1C4.96,11.4 4.94,11.71 4.94,12.02C4.94,12.33 4.96,12.64 5.01,12.94L2.97,14.52C2.79,14.66 2.74,14.93 2.85,15.13L4.75,18.45C4.87,18.67 5.11,18.73 5.35,18.65L7.74,17.69C8.25,18.08 8.78,18.41 9.38,18.65L9.68,20.93C9.72,21.18 9.93,21.36 10.18,21.36H13.98C14.23,21.36 14.44,21.18 14.48,20.93L14.78,18.65C15.38,18.4 15.91,18.08 16.42,17.69L18.81,18.65C19.04,18.74 19.28,18.66 19.4,18.44L21.3,15.12C21.42,14.91 21.37,14.65 21.19,14.51L19.14,12.94ZM12.08,15.5C10.15,15.5 8.58,13.93 8.58,12C8.58,10.07 10.15,8.5 12.08,8.5C14.01,8.5 15.58,10.07 15.58,12C15.58,13.93 14.01,15.5 12.08,15.5Z"/>
10+
</vector>

0 commit comments

Comments
 (0)