Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
531
Issue boards
Milestones
Wiki
Code
Merge requests
13
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
4aab43a7
Commit
4aab43a7
authored
3 years ago
by
Nicolas Pomepuy
Browse files
Options
Downloads
Patches
Plain Diff
Improve the settings search by filling the string substitution in the summary
parent
438a02b5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Pipeline
#88538
passed with stage
in 2 minutes and 37 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
application/vlc-android/src/org/videolan/vlc/gui/preferences/search/PreferenceParser.kt
+29
-3
29 additions, 3 deletions
...g/videolan/vlc/gui/preferences/search/PreferenceParser.kt
with
29 additions
and
3 deletions
application/vlc-android/src/org/videolan/vlc/gui/preferences/search/PreferenceParser.kt
+
29
−
3
View file @
4aab43a7
...
...
@@ -28,8 +28,11 @@ import android.content.Context
import
android.content.ContextWrapper
import
android.content.res.XmlResourceParser
import
android.os.Parcelable
import
android.util.Log
import
kotlinx.android.parcel.Parcelize
import
org.videolan.tools.Settings
import
org.videolan.tools.wrap
import
org.videolan.vlc.BuildConfig
import
org.videolan.vlc.R
object
PreferenceParser
{
...
...
@@ -61,11 +64,24 @@ object PreferenceParser {
categoryEng
=
getValue
(
englishContext
,
parser
,
namespace
,
"title"
)
}
if
(
element
!=
"PreferenceCategory"
&&
element
!=
"Preference"
)
{
val
key
=
getValue
(
context
,
parser
,
namespace
,
"key"
)
val
title
=
getValue
(
context
,
parser
,
namespace
,
"title"
)
val
summary
=
getValue
(
context
,
parser
,
namespace
,
"summary"
)
val
titleEng
=
getValue
(
englishContext
,
parser
,
namespace
,
"title"
)
val
summaryEng
=
getValue
(
englishContext
,
parser
,
namespace
,
"summary"
)
val
key
=
getValue
(
context
,
parser
,
namespace
,
"key"
)
var
summary
=
getValue
(
context
,
parser
,
namespace
,
"summary"
)
var
summaryEng
=
getValue
(
englishContext
,
parser
,
namespace
,
"summary"
)
if
(
summary
.
contains
(
"%s"
)
&&
element
==
"ListPreference"
)
{
//get the current value for the string substitution
try
{
val
defaultValue
=
getValue
(
context
,
parser
,
namespace
,
"defaultValue"
)
val
rawValue
=
Settings
.
getInstance
(
context
).
getString
(
key
,
defaultValue
)
?:
""
val
entriesId
=
parser
.
getAttributeResourceValue
(
namespace
,
"entries"
,
-
1
)
val
entryValuesId
=
parser
.
getAttributeResourceValue
(
namespace
,
"entryValues"
,
-
1
)
val
index
=
context
.
resources
.
getStringArray
(
entryValuesId
).
indexOf
(
rawValue
)
summary
=
summary
.
replace
(
"%s"
,
context
.
resources
.
getStringArray
(
entriesId
)[
index
])
summaryEng
=
summaryEng
.
replace
(
"%s"
,
englishContext
.
resources
.
getStringArray
(
entriesId
)[
index
])
}
catch
(
e
:
Exception
)
{
}
}
if
(
key
.
isNotBlank
())
result
.
add
(
PreferenceItem
(
key
,
id
,
title
,
summary
,
titleEng
,
summaryEng
,
category
,
categoryEng
))
}
}
...
...
@@ -86,6 +102,16 @@ object PreferenceParser {
}
return
""
}
private
fun
getSummary
(
context
:
Context
,
parser
:
XmlResourceParser
,
namespace
:
String
,
node
:
String
,
defaultValue
:
String
,
key
:
String
):
String
{
val
value
=
getValue
(
context
,
parser
,
namespace
,
node
)
if
(
value
.
contains
(
"%s"
))
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
this
::
class
.
java
.
simpleName
,
"Found string replacement for $key"
)
return
if
(
value
.
contains
(
"%s"
))
value
.
replace
(
"%s"
,
Settings
.
getInstance
(
context
).
getString
(
key
,
defaultValue
)
?:
""
)
else
value
}
}
@Parcelize
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment