Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
keyboard
LatinIME
Commits
88df3d92
Commit
88df3d92
authored
12 years ago
by
Tadashi G. Takaoka
Browse files
Options
Downloads
Patches
Plain Diff
SeekBarDialog supports neutral and dismiss listener
Change-Id: I652fd1a383ef4074c04d03a37ebc779d229474e6
parent
95e3008d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
java/src/com/android/inputmethod/latin/SeekBarDialog.java
+29
-7
29 additions, 7 deletions
java/src/com/android/inputmethod/latin/SeekBarDialog.java
java/src/com/android/inputmethod/latin/SettingsFragment.java
+18
-4
18 additions, 4 deletions
java/src/com/android/inputmethod/latin/SettingsFragment.java
with
47 additions
and
11 deletions
java/src/com/android/inputmethod/latin/SeekBarDialog.java
+
29
−
7
View file @
88df3d92
...
@@ -30,6 +30,8 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
...
@@ -30,6 +30,8 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
public
interface
Listener
{
public
interface
Listener
{
public
void
onPositiveButtonClick
(
final
SeekBarDialog
dialog
);
public
void
onPositiveButtonClick
(
final
SeekBarDialog
dialog
);
public
void
onNegativeButtonClick
(
final
SeekBarDialog
dialog
);
public
void
onNegativeButtonClick
(
final
SeekBarDialog
dialog
);
public
void
onNeutralButtonClick
(
final
SeekBarDialog
dialog
);
public
void
onDismiss
(
final
SeekBarDialog
dialog
);
public
void
onProgressChanged
(
final
SeekBarDialog
dialog
);
public
void
onProgressChanged
(
final
SeekBarDialog
dialog
);
public
void
onStartTrackingTouch
(
final
SeekBarDialog
dialog
);
public
void
onStartTrackingTouch
(
final
SeekBarDialog
dialog
);
public
void
onStopTrackingTouch
(
final
SeekBarDialog
dialog
);
public
void
onStopTrackingTouch
(
final
SeekBarDialog
dialog
);
...
@@ -39,7 +41,11 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
...
@@ -39,7 +41,11 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
@Override
@Override
public
void
onPositiveButtonClick
(
final
SeekBarDialog
dialog
)
{}
public
void
onPositiveButtonClick
(
final
SeekBarDialog
dialog
)
{}
@Override
@Override
public
void
onNegativeButtonClick
(
final
SeekBarDialog
dialog
)
{
dialog
.
dismiss
();
}
public
void
onNegativeButtonClick
(
final
SeekBarDialog
dialog
)
{}
@Override
public
void
onNeutralButtonClick
(
final
SeekBarDialog
dialog
)
{}
@Override
public
void
onDismiss
(
final
SeekBarDialog
dialog
)
{}
@Override
@Override
public
void
onProgressChanged
(
final
SeekBarDialog
dialog
)
{}
public
void
onProgressChanged
(
final
SeekBarDialog
dialog
)
{}
@Override
@Override
...
@@ -63,6 +69,9 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
...
@@ -63,6 +69,9 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
dialogBuilder
.
setView
(
builder
.
mView
);
dialogBuilder
.
setView
(
builder
.
mView
);
dialogBuilder
.
setPositiveButton
(
android
.
R
.
string
.
ok
,
this
);
dialogBuilder
.
setPositiveButton
(
android
.
R
.
string
.
ok
,
this
);
dialogBuilder
.
setNegativeButton
(
android
.
R
.
string
.
cancel
,
this
);
dialogBuilder
.
setNegativeButton
(
android
.
R
.
string
.
cancel
,
this
);
if
(
builder
.
mNeutralButtonTextResId
!=
0
)
{
dialogBuilder
.
setNeutralButton
(
builder
.
mNeutralButtonTextResId
,
this
);
}
mDialog
=
dialogBuilder
.
create
();
mDialog
=
dialogBuilder
.
create
();
mListener
=
(
builder
.
mListener
==
null
)
?
EMPTY_ADAPTER
:
builder
.
mListener
;
mListener
=
(
builder
.
mListener
==
null
)
?
EMPTY_ADAPTER
:
builder
.
mListener
;
mValueView
=
(
TextView
)
builder
.
mView
.
findViewById
(
R
.
id
.
seek_bar_dialog_value
);
mValueView
=
(
TextView
)
builder
.
mView
.
findViewById
(
R
.
id
.
seek_bar_dialog_value
);
...
@@ -101,15 +110,21 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
...
@@ -101,15 +110,21 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
}
}
@Override
@Override
public
void
onClick
(
final
DialogInterface
dialog
,
int
which
)
{
public
void
onClick
(
final
DialogInterface
dialog
,
final
int
which
)
{
if
(
which
==
DialogInterface
.
BUTTON_POSITIVE
)
{
switch
(
which
)
{
case
DialogInterface
.
BUTTON_POSITIVE
:
mListener
.
onPositiveButtonClick
(
this
);
mListener
.
onPositiveButtonClick
(
this
);
return
;
break
;
}
case
DialogInterface
.
BUTTON_NEGATIVE
:
if
(
which
==
DialogInterface
.
BUTTON_NEGATIVE
)
{
mListener
.
onNegativeButtonClick
(
this
);
mListener
.
onNegativeButtonClick
(
this
);
break
;
case
DialogInterface
.
BUTTON_NEUTRAL
:
mListener
.
onNeutralButtonClick
(
this
);
break
;
default
:
return
;
return
;
}
}
mListener
.
onDismiss
(
this
);
}
}
@Override
@Override
...
@@ -135,6 +150,7 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
...
@@ -135,6 +150,7 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
final
AlertDialog
.
Builder
mDialogBuilder
;
final
AlertDialog
.
Builder
mDialogBuilder
;
final
View
mView
;
final
View
mView
;
int
mNeutralButtonTextResId
;
int
mMaxValue
;
int
mMaxValue
;
int
mValueFormatResId
;
int
mValueFormatResId
;
int
mValue
;
int
mValue
;
...
@@ -150,8 +166,14 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
...
@@ -150,8 +166,14 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
return
this
;
return
this
;
}
}
public
Builder
setNeutralButtonText
(
final
int
resId
)
{
mNeutralButtonTextResId
=
resId
;
return
this
;
}
public
Builder
setMaxValue
(
final
int
max
)
{
public
Builder
setMaxValue
(
final
int
max
)
{
mMaxValue
=
max
;
mMaxValue
=
max
;
mValue
=
Math
.
min
(
mValue
,
max
);
return
this
;
return
this
;
}
}
...
@@ -161,7 +183,7 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
...
@@ -161,7 +183,7 @@ public final class SeekBarDialog implements DialogInterface.OnClickListener,
}
}
public
Builder
setValue
(
final
int
value
)
{
public
Builder
setValue
(
final
int
value
)
{
mValue
=
value
;
mValue
=
Math
.
min
(
value
,
mMaxValue
)
;
return
this
;
return
this
;
}
}
...
...
This diff is collapsed.
Click to expand it.
java/src/com/android/inputmethod/latin/SettingsFragment.java
+
18
−
4
View file @
88df3d92
...
@@ -308,10 +308,17 @@ public final class SettingsFragment extends InputMethodSettingsFragment
...
@@ -308,10 +308,17 @@ public final class SettingsFragment extends InputMethodSettingsFragment
final
Context
context
=
getActivity
();
final
Context
context
=
getActivity
();
final
PreferenceScreen
settingsPref
=
mKeypressVibrationDurationSettingsPref
;
final
PreferenceScreen
settingsPref
=
mKeypressVibrationDurationSettingsPref
;
final
SeekBarDialog
.
Listener
listener
=
new
SeekBarDialog
.
Adapter
()
{
final
SeekBarDialog
.
Listener
listener
=
new
SeekBarDialog
.
Adapter
()
{
private
void
writePreference
(
final
SharedPreferences
sp
,
final
int
value
)
{
sp
.
edit
().
putInt
(
Settings
.
PREF_VIBRATION_DURATION_SETTINGS
,
value
).
apply
();
}
@Override
@Override
public
void
onPositiveButtonClick
(
final
SeekBarDialog
dialog
)
{
public
void
onPositiveButtonClick
(
final
SeekBarDialog
dialog
)
{
final
int
ms
=
dialog
.
getValue
();
writePreference
(
sp
,
dialog
.
getValue
());
sp
.
edit
().
putInt
(
Settings
.
PREF_VIBRATION_DURATION_SETTINGS
,
ms
).
apply
();
}
@Override
public
void
onDismiss
(
final
SeekBarDialog
dialog
)
{
if
(
settingsPref
!=
null
)
{
if
(
settingsPref
!=
null
)
{
settingsPref
.
setSummary
(
dialog
.
getValueText
());
settingsPref
.
setSummary
(
dialog
.
getValueText
());
}
}
...
@@ -348,10 +355,17 @@ public final class SettingsFragment extends InputMethodSettingsFragment
...
@@ -348,10 +355,17 @@ public final class SettingsFragment extends InputMethodSettingsFragment
final
AudioManager
am
=
(
AudioManager
)
context
.
getSystemService
(
Context
.
AUDIO_SERVICE
);
final
AudioManager
am
=
(
AudioManager
)
context
.
getSystemService
(
Context
.
AUDIO_SERVICE
);
final
PreferenceScreen
settingsPref
=
mKeypressSoundVolumeSettingsPref
;
final
PreferenceScreen
settingsPref
=
mKeypressSoundVolumeSettingsPref
;
final
SeekBarDialog
.
Listener
listener
=
new
SeekBarDialog
.
Adapter
()
{
final
SeekBarDialog
.
Listener
listener
=
new
SeekBarDialog
.
Adapter
()
{
private
void
writePreference
(
final
SharedPreferences
sp
,
final
float
value
)
{
sp
.
edit
().
putFloat
(
Settings
.
PREF_KEYPRESS_SOUND_VOLUME
,
value
).
apply
();
}
@Override
@Override
public
void
onPositiveButtonClick
(
final
SeekBarDialog
dialog
)
{
public
void
onPositiveButtonClick
(
final
SeekBarDialog
dialog
)
{
final
float
volume
=
dialog
.
getValue
()
/
PERCENT_FLOAT
;
writePreference
(
sp
,
dialog
.
getValue
()
/
PERCENT_FLOAT
);
sp
.
edit
().
putFloat
(
Settings
.
PREF_KEYPRESS_SOUND_VOLUME
,
volume
).
apply
();
}
@Override
public
void
onDismiss
(
final
SeekBarDialog
dialog
)
{
if
(
settingsPref
!=
null
)
{
if
(
settingsPref
!=
null
)
{
settingsPref
.
setSummary
(
dialog
.
getValueText
());
settingsPref
.
setSummary
(
dialog
.
getValueText
());
}
}
...
...
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