Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
7e6cc4e8
Commit
7e6cc4e8
authored
Jan 20, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine EditTextPreference layout
parent
4f3c7dd8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
7 deletions
+61
-7
plugin/src/main/res/layout/preference_dialog_edittext.xml
plugin/src/main/res/layout/preference_dialog_edittext.xml
+40
-0
plugin/src/main/scala/be/mygod/preference/EditTextPreference.scala
...c/main/scala/be/mygod/preference/EditTextPreference.scala
+12
-0
plugin/src/main/scala/be/mygod/preference/EditTextPreferenceDialogFragment.scala
...e/mygod/preference/EditTextPreferenceDialogFragment.scala
+9
-7
No files found.
plugin/src/main/res/layout/preference_dialog_edittext.xml
0 → 100644
View file @
7e6cc4e8
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_marginTop=
"48dp"
android:layout_marginBottom=
"48dp"
android:overScrollMode=
"ifContentScrolls"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingStart=
"?attr/dialogPreferredPadding"
android:paddingEnd=
"?attr/dialogPreferredPadding"
android:orientation=
"vertical"
>
<TextView
android:id=
"@android:id/message"
style=
"@style/TextAppearance.AppCompat.Subhead"
android:layout_marginBottom=
"48dp"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:textColor=
"?android:attr/textColorSecondary"
/>
<EditText
android:id=
"@android:id/edit"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
</ScrollView>
plugin/src/main/scala/be/mygod/preference/EditTextPreference.scala
View file @
7e6cc4e8
...
@@ -25,6 +25,9 @@ import android.support.v7.preference.{EditTextPreference => Parent}
...
@@ -25,6 +25,9 @@ import android.support.v7.preference.{EditTextPreference => Parent}
import
android.support.v7.widget.AppCompatEditText
import
android.support.v7.widget.AppCompatEditText
import
android.text.InputType
import
android.text.InputType
import
android.util.AttributeSet
import
android.util.AttributeSet
import
android.view.ViewGroup
import
android.widget.FrameLayout
import
com.github.shadowsocks.plugin.R
/**
/**
* Fixed EditTextPreference + SummaryPreference with password support!
* Fixed EditTextPreference + SummaryPreference with password support!
...
@@ -35,6 +38,15 @@ class EditTextPreference(context: Context, attrs: AttributeSet = null) extends P
...
@@ -35,6 +38,15 @@ class EditTextPreference(context: Context, attrs: AttributeSet = null) extends P
val
editText
=
new
AppCompatEditText
(
context
,
attrs
)
val
editText
=
new
AppCompatEditText
(
context
,
attrs
)
editText
.
setId
(
android
.
R
.
id
.
edit
)
editText
.
setId
(
android
.
R
.
id
.
edit
)
{
val
arr
=
context
.
obtainStyledAttributes
(
Array
(
R
.
attr
.
dialogPreferredPadding
))
val
margin
=
arr
.
getDimensionPixelOffset
(
0
,
0
)
arr
.
recycle
()
val
params
=
new
FrameLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
params
.
setMargins
(
margin
,
0
,
margin
,
0
)
editText
.
setLayoutParams
(
params
)
}
override
def
createDialog
()
=
new
EditTextPreferenceDialogFragment
()
override
def
createDialog
()
=
new
EditTextPreferenceDialogFragment
()
override
protected
def
getSummaryValue
:
String
=
{
override
protected
def
getSummaryValue
:
String
=
{
...
...
plugin/src/main/scala/be/mygod/preference/EditTextPreferenceDialogFragment.scala
View file @
7e6cc4e8
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
package
be.mygod.preference
package
be.mygod.preference
import
android.content.Context
import
android.support.v14.preference.PreferenceDialogFragment
import
android.support.v14.preference.PreferenceDialogFragment
import
android.support.v7.widget.AppCompatEditText
import
android.support.v7.widget.AppCompatEditText
import
android.view.
{
View
,
ViewGroup
}
import
android.view.
{
View
,
ViewGroup
}
...
@@ -29,17 +28,20 @@ class EditTextPreferenceDialogFragment extends PreferenceDialogFragment {
...
@@ -29,17 +28,20 @@ class EditTextPreferenceDialogFragment extends PreferenceDialogFragment {
private
lazy
val
preference
=
getPreference
.
asInstanceOf
[
EditTextPreference
]
private
lazy
val
preference
=
getPreference
.
asInstanceOf
[
EditTextPreference
]
protected
lazy
val
editText
:
AppCompatEditText
=
preference
.
editText
protected
lazy
val
editText
:
AppCompatEditText
=
preference
.
editText
override
protected
def
onCreateDialogView
(
context
:
Context
)
:
AppCompatEditText
=
{
val
parent
=
editText
.
getParent
.
asInstanceOf
[
ViewGroup
]
if
(
parent
!=
null
)
parent
.
removeView
(
editText
)
editText
}
override
protected
def
onBindDialogView
(
view
:
View
)
{
override
protected
def
onBindDialogView
(
view
:
View
)
{
super
.
onBindDialogView
(
view
)
super
.
onBindDialogView
(
view
)
editText
.
setText
(
preference
.
getText
)
editText
.
setText
(
preference
.
getText
)
val
text
=
editText
.
getText
val
text
=
editText
.
getText
if
(
text
!=
null
)
editText
.
setSelection
(
0
,
text
.
length
)
if
(
text
!=
null
)
editText
.
setSelection
(
0
,
text
.
length
)
val
oldParent
=
editText
.
getParent
.
asInstanceOf
[
ViewGroup
]
if
(
oldParent
eq
view
)
return
if
(
oldParent
!=
null
)
oldParent
.
removeView
(
editText
)
val
oldEdit
=
view
.
findViewById
(
android
.
R
.
id
.
edit
)
if
(
oldEdit
==
null
)
return
val
container
=
oldEdit
.
getParent
.
asInstanceOf
[
ViewGroup
]
if
(
container
==
null
)
return
container
.
removeView
(
oldEdit
)
container
.
addView
(
editText
,
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
}
}
override
protected
def
needInputMethod
=
true
override
protected
def
needInputMethod
=
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment