Skip to content

Commit

Permalink
ui: fix search issue in app info and nw conns screens
Browse files Browse the repository at this point in the history
  • Loading branch information
hussainmohd-a committed Oct 12, 2024
1 parent 6a6b030 commit 69dd5eb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class ConnectionTrackerFragment :
private val connectionTrackerRepository by inject<ConnectionTrackerRepository>()
private val persistentState by inject<PersistentState>()

private var fromWireGuardScreen: Boolean = false
private var fromUniversalFirewallScreen: Boolean = false

companion object {
const val PROTOCOL_FILTER_PREFIX = "P:"
private const val QUERY_TEXT_TIMEOUT: Long = 600
Expand All @@ -80,15 +83,15 @@ class ConnectionTrackerFragment :
initView()
if (arguments != null) {
val query = arguments?.getString(Constants.SEARCH_QUERY) ?: return
val containsUniv = query.contains(UniversalFirewallSettingsActivity.RULES_SEARCH_ID)
val containsWireGuard = query.contains(NetworkLogsActivity.RULES_SEARCH_ID_WIREGUARD)
if (containsUniv) {
fromUniversalFirewallScreen = query.contains(UniversalFirewallSettingsActivity.RULES_SEARCH_ID)
fromWireGuardScreen = query.contains(NetworkLogsActivity.RULES_SEARCH_ID_WIREGUARD)
if (fromUniversalFirewallScreen) {
val rule = query.split(UniversalFirewallSettingsActivity.RULES_SEARCH_ID)[1]
filterCategories.add(rule)
filterType = TopLevelFilter.BLOCKED
viewModel.setFilter(filterQuery, filterCategories, filterType)
hideSearchLayout()
} else if (containsWireGuard) {
} else if (fromWireGuardScreen) {
val rule = query.split(NetworkLogsActivity.RULES_SEARCH_ID_WIREGUARD)[1]
filterQuery = rule
filterType = TopLevelFilter.ALL
Expand Down Expand Up @@ -146,9 +149,14 @@ class ConnectionTrackerFragment :
recyclerAdapter.addLoadStateListener {
if (it.append.endOfPaginationReached) {
if (recyclerAdapter.itemCount < 1) {
b.connectionListLogsDisabledTv.text = getString(R.string.ada_ip_no_connection)
b.connectionListLogsDisabledTv.visibility = View.VISIBLE
b.connectionCardViewTop.visibility = View.GONE
if (fromUniversalFirewallScreen || fromWireGuardScreen) {
b.connectionListLogsDisabledTv.text = getString(R.string.ada_ip_no_connection)
b.connectionListLogsDisabledTv.visibility = View.VISIBLE
b.connectionCardViewTop.visibility = View.GONE
} else {
b.connectionListLogsDisabledTv.visibility = View.GONE
b.connectionCardViewTop.visibility = View.VISIBLE
}
} else {
b.connectionListLogsDisabledTv.visibility = View.GONE
b.connectionCardViewTop.visibility = View.VISIBLE
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/celzero/bravedns/database/AppInfoDAO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface AppInfoDAO {
@Query("select * from AppInfo order by appCategory, uid") fun getAllAppDetails(): List<AppInfo>

@Query(
"select * from AppInfo where isSystemApp = 1 and (appName like :search or uid like :search or packageName like :search) and firewallStatus in (:firewall) and connectionStatus in (:connectionStatus) or isProxyExcluded in (:isProxyExcluded) order by lower(appName)"
"select * from AppInfo where isSystemApp = 1 and (appName like :search or uid like :search or packageName like :search) and (firewallStatus in (:firewall) or isProxyExcluded in (:isProxyExcluded)) and connectionStatus in (:connectionStatus) order by lower(appName)"
)
fun getSystemApps(
search: String,
Expand All @@ -64,7 +64,7 @@ interface AppInfoDAO {
): PagingSource<Int, AppInfo>

@Query(
"select * from AppInfo where isSystemApp = 1 and (appName like :search or uid like :search or packageName like :search) and appCategory in (:filter) and firewallStatus in (:firewall) and connectionStatus in (:connectionStatus) or isProxyExcluded in (:isProxyExcluded) order by lower(appName)"
"select * from AppInfo where isSystemApp = 1 and (appName like :search or uid like :search or packageName like :search) and appCategory in (:filter) and (firewallStatus in (:firewall) or isProxyExcluded in (:isProxyExcluded)) and connectionStatus in (:connectionStatus) order by lower(appName)"
)
fun getSystemApps(
search: String,
Expand All @@ -75,7 +75,7 @@ interface AppInfoDAO {
): PagingSource<Int, AppInfo>

@Query(
"select * from AppInfo where isSystemApp = 0 and (appName like :search or uid like :search or packageName like :search) and firewallStatus in (:firewall) and connectionStatus in (:connectionStatus) or isProxyExcluded in (:isProxyExcluded) order by lower(appName)"
"select * from AppInfo where isSystemApp = 0 and (appName like :search or uid like :search or packageName like :search) and (firewallStatus in (:firewall) or isProxyExcluded in (:isProxyExcluded)) and connectionStatus in (:connectionStatus) order by lower(appName)"
)
fun getInstalledApps(
search: String,
Expand All @@ -85,7 +85,7 @@ interface AppInfoDAO {
): PagingSource<Int, AppInfo>

@Query(
"select * from AppInfo where isSystemApp = 0 and (appName like :search or uid like :search or packageName like :search) and appCategory in (:filter) and firewallStatus in (:firewall) and connectionStatus in (:connectionStatus) or isProxyExcluded in (:isProxyExcluded) order by lower(appName)"
"select * from AppInfo where isSystemApp = 0 and (appName like :search or uid like :search or packageName like :search) and appCategory in (:filter) and (firewallStatus in (:firewall) or isProxyExcluded in (:isProxyExcluded)) and connectionStatus in (:connectionStatus) order by lower(appName)"
)
fun getInstalledApps(
search: String,
Expand All @@ -96,7 +96,7 @@ interface AppInfoDAO {
): PagingSource<Int, AppInfo>

@Query(
"select * from AppInfo where (appName like :search or uid like :search or packageName like :search) and firewallStatus in (:firewall) and connectionStatus in (:connectionStatus) or isProxyExcluded in (:isProxyExcluded) order by lower(appName)"
"select * from AppInfo where (appName like :search or uid like :search or packageName like :search) and (firewallStatus in (:firewall) or isProxyExcluded in (:isProxyExcluded)) and connectionStatus in (:connectionStatus) order by lower(appName)"
)
fun getAppInfos(
search: String,
Expand All @@ -106,7 +106,7 @@ interface AppInfoDAO {
): PagingSource<Int, AppInfo>

@Query(
"select * from AppInfo where (appName like :search or uid like :search or packageName like :search) and appCategory in (:filter) and firewallStatus in (:firewall) and connectionStatus in (:connectionStatus) or isProxyExcluded in (:isProxyExcluded) order by lower(appName)"
"select * from AppInfo where (appName like :search or uid like :search or packageName like :search) and appCategory in (:filter) and (firewallStatus in (:firewall) or isProxyExcluded in (:isProxyExcluded)) and connectionStatus in (:connectionStatus) order by lower(appName)"
)
fun getAppInfos(
search: String,
Expand Down

0 comments on commit 69dd5eb

Please sign in to comment.