1 |
package com.caddi.android.caddipictureupload.util; |
2 |
|
3 |
import android.text.method.PasswordTransformationMethod; |
4 |
import android.view.View; |
5 |
|
6 |
/** |
7 |
* |
8 |
*/ |
9 |
public class MyTransformation extends PasswordTransformationMethod { |
10 |
|
11 |
@Override |
12 |
public CharSequence getTransformation(CharSequence source, View view) { |
13 |
return new PasswordCharSequence(source); |
14 |
} |
15 |
|
16 |
private class PasswordCharSequence implements CharSequence { |
17 |
private CharSequence mSource; |
18 |
public PasswordCharSequence(CharSequence source) { |
19 |
mSource = source; // Store char sequence |
20 |
} |
21 |
public char charAt(int index) { |
22 |
//This is the check which makes sure the last character is shown |
23 |
if(index != mSource.length()-1) |
24 |
return '•'; |
25 |
else |
26 |
return mSource.charAt(index); |
27 |
} |
28 |
public int length() { |
29 |
return mSource.length(); // Return default |
30 |
} |
31 |
public CharSequence subSequence(int start, int end) { |
32 |
return mSource.subSequence(start, end); // Return default |
33 |
} |
34 |
} |
35 |
} |