Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-android
Commits
e2bb2595
Commit
e2bb2595
authored
12 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
#15495: Fix SeekBar dragable in audio Preferences
parent
5e0b947b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/com/savoirfairelinux/sflphone/client/PrefManagementFragment.java
+93
-78
93 additions, 78 deletions
...oirfairelinux/sflphone/client/PrefManagementFragment.java
with
93 additions
and
78 deletions
src/com/savoirfairelinux/sflphone/client/PrefManagementFragment.java
+
93
−
78
View file @
e2bb2595
...
...
@@ -33,6 +33,7 @@ package com.savoirfairelinux.sflphone.client;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.res.TypedArray
;
import
android.graphics.Typeface
;
import
android.preference.EditTextPreference
;
import
android.preference.ListPreference
;
...
...
@@ -45,11 +46,9 @@ import android.util.Log;
import
android.util.AttributeSet
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ArrayAdapter
;
import
android.widget.ListView
;
import
android.widget.LinearLayout
;
import
android.widget.SeekBar
;
import
android.widget.SeekBar.OnSeekBarChangeListener
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
com.savoirfairelinux.sflphone.R
;
...
...
@@ -130,110 +129,126 @@ public class PrefManagementFragment extends PreferenceFragment
public
class
SeekBarPreference
extends
Preference
implements
OnSeekBarChangeListener
{
public
int
MAXIMUM
=
100
;
public
int
INTERVAL
=
5
;
private
float
oldValue
=
25
;
private
TextView
Indicator
;
private
SeekBar
seekbar
;
private
int
progress
;
private
int
max
=
100
;
private
TextView
summary
;
private
boolean
discard
;
public
SeekBarPreference
(
Context
context
)
public
SeekBarPreference
(
Context
context
)
{
super
(
context
);
super
(
context
);
}
public
SeekBarPreference
(
Context
context
,
AttributeSet
attrs
)
public
SeekBarPreference
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
super
(
context
,
attrs
);
}
public
SeekBarPreference
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
public
SeekBarPreference
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
{
super
(
context
,
attrs
,
defStyle
);
super
(
context
,
attrs
,
defStyle
);
}
@Override
protected
View
onCreateView
(
ViewGroup
parent
)
protected
View
onCreateView
(
ViewGroup
p
)
{
float
scale
=
getContext
().
getResources
().
getDisplayMetrics
().
density
;
RelativeLayout
layout
=
new
RelativeLayout
(
getContext
());
RelativeLayout
.
LayoutParams
textParams
=
new
RelativeLayout
.
LayoutParams
(
RelativeLayout
.
LayoutParams
.
WRAP_CONTENT
,
RelativeLayout
.
LayoutParams
.
WRAP_CONTENT
);
RelativeLayout
.
LayoutParams
sbarParams
=
new
RelativeLayout
.
LayoutParams
(
Math
.
round
(
scale
*
160
),
RelativeLayout
.
LayoutParams
.
WRAP_CONTENT
);
RelativeLayout
.
LayoutParams
indParams
=
new
RelativeLayout
.
LayoutParams
(
RelativeLayout
.
LayoutParams
.
WRAP_CONTENT
,
RelativeLayout
.
LayoutParams
.
WRAP_CONTENT
);
TextView
preferenceText
=
new
TextView
(
getContext
());
preferenceText
.
setId
(
0
);
preferenceText
.
setText
(
getTitle
());
preferenceText
.
setTextSize
(
18
);
preferenceText
.
setTypeface
(
Typeface
.
SANS_SERIF
,
Typeface
.
BOLD
);
SeekBar
sbar
=
new
SeekBar
(
getContext
());
sbar
.
setId
(
1
);
sbar
.
setMax
(
MAXIMUM
);
sbar
.
setProgress
((
int
)
this
.
oldValue
);
sbar
.
setOnSeekBarChangeListener
(
this
);
this
.
Indicator
=
new
TextView
(
getContext
());
this
.
Indicator
.
setTextSize
(
12
);
this
.
Indicator
.
setTypeface
(
Typeface
.
MONOSPACE
,
Typeface
.
ITALIC
);
this
.
Indicator
.
setText
(
""
+
sbar
.
getProgress
());
textParams
.
addRule
(
RelativeLayout
.
ALIGN_PARENT_LEFT
);
sbarParams
.
addRule
(
RelativeLayout
.
RIGHT_OF
,
preferenceText
.
getId
());
indParams
.
setMargins
(
Math
.
round
(
20
*
scale
),
0
,
0
,
0
);
indParams
.
addRule
(
RelativeLayout
.
RIGHT_OF
,
sbar
.
getId
());
preferenceText
.
setLayoutParams
(
textParams
);
sbar
.
setLayoutParams
(
sbarParams
);
this
.
Indicator
.
setLayoutParams
(
indParams
);
layout
.
addView
(
preferenceText
);
layout
.
addView
(
this
.
Indicator
);
layout
.
addView
(
sbar
);
layout
.
setId
(
android
.
R
.
id
.
widget_frame
);
final
Context
ctx
=
getContext
();
// final Tools T = new Tools( ctx );
LinearLayout
layout
=
new
LinearLayout
(
ctx
);
layout
.
setId
(
android
.
R
.
id
.
widget_frame
);
layout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
// T.setPadding( layout, 15, 10, 15, 10 );
TextView
title
=
new
TextView
(
ctx
);
int
textColor
=
title
.
getCurrentTextColor
();
title
.
setId
(
android
.
R
.
id
.
title
);
title
.
setSingleLine
();
title
.
setTextAppearance
(
ctx
,
android
.
R
.
style
.
TextAppearance_Large
);
title
.
setTextColor
(
textColor
);
layout
.
addView
(
title
);
seekbar
=
new
SeekBar
(
ctx
);
seekbar
.
setId
(
android
.
R
.
id
.
progress
);
seekbar
.
setMax
(
max
);
seekbar
.
setOnSeekBarChangeListener
(
this
);
layout
.
addView
(
seekbar
);
summary
=
new
TextView
(
ctx
);
summary
.
setId
(
android
.
R
.
id
.
summary
);
summary
.
setSingleLine
();
summary
.
setTextAppearance
(
ctx
,
android
.
R
.
style
.
TextAppearance_Small
);
summary
.
setTextColor
(
textColor
);
layout
.
addView
(
summary
);
return
layout
;
}
@Override
p
ublic
void
onProgressChanged
(
SeekBar
seekBar
,
int
progress
,
boolean
fromUser
)
p
rotected
void
onBindView
(
View
view
)
{
progress
=
Math
.
round
(((
float
)
progress
)/
INTERVAL
)
*
INTERVAL
;
super
.
onBindView
(
view
);
if
(
seekbar
!=
null
)
seekbar
.
setProgress
(
progress
);
}
if
(!
callChangeListener
(
progress
))
{
seekBar
.
setProgress
((
int
)
this
.
oldValue
);
return
;
public
void
setProgress
(
int
pcnt
)
{
if
(
progress
!=
pcnt
)
{
persistInt
(
progress
=
pcnt
);
notifyDependencyChange
(
shouldDisableDependents
()
);
notifyChanged
();
}
}
seekBar
.
setProgress
(
progress
);
this
.
oldValue
=
progress
;
this
.
Indicator
.
setText
(
""
+
progress
);
updatePreference
(
progress
);
public
int
getProgress
()
{
return
progress
;
}
public
void
setMax
(
int
max
)
{
this
.
max
=
max
;
if
(
seekbar
!=
null
)
seekbar
.
setMax
(
max
);
}
notifyChanged
();
private
SeekBar
getSeekBar
()
{
return
seekbar
;
}
@Override
p
ublic
void
onStartTrackingTouch
(
SeekBar
seekBar
)
{
p
rotected
Object
onGetDefaultValue
(
TypedArray
a
,
int
index
)
{
return
a
.
getInt
(
index
,
progress
);
}
@Override
p
ublic
void
onS
topTrackingTouch
(
SeekBar
seekBar
)
{
p
rotected
void
onS
etInitialValue
(
boolean
restoreValue
,
Object
defaultValue
)
{
setProgress
(
restoreValue
?
getPersistedInt
(
progress
)
:
(
Integer
)
defaultValue
);
}
private
void
updatePreference
(
int
newValue
)
{
// SharedPreference.Editor editor = getEditor();
// editor.putInt(getKey(), newValue);
// editor.commit();
@Override
public
boolean
shouldDisableDependents
()
{
return
progress
==
0
||
super
.
shouldDisableDependents
();
}
public
void
onProgressChanged
(
SeekBar
seekBar
,
int
progress
,
boolean
fromUser
)
{
discard
=
!
callChangeListener
(
progress
);
}
public
void
onStartTrackingTouch
(
SeekBar
seekBar
)
{
discard
=
false
;
}
public
void
onStopTrackingTouch
(
SeekBar
seekBar
)
{
if
(
discard
)
seekBar
.
setProgress
(
progress
);
else
{
setProgress
(
seekBar
.
getProgress
()
);
OnPreferenceChangeListener
listener
=
getOnPreferenceChangeListener
();
//if (listener instanceof AbstractSeekBarListener)
//// setSummary( ((AbstractSeekBarListener)listener).toSummary( seekBar.getProgress() ) );
}
}
}
}
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