]> Pileus Git - ~andy/freeotp/blob - src/org/fedorahosted/freeotp/AddTokenSecretTextWatcher.java
Relicense to Apache 2.0
[~andy/freeotp] / src / org / fedorahosted / freeotp / AddTokenSecretTextWatcher.java
1 /*
2  * FreeOTP
3  *
4  * Authors: Nathaniel McCallum <npmccallum@redhat.com>
5  *
6  * Copyright (C) 2013  Nathaniel McCallum, Red Hat
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 package org.fedorahosted.freeotp;
22
23 import android.app.AlertDialog;
24 import android.text.Editable;
25
26 public class AddTokenSecretTextWatcher extends AddTokenTextWatcher {
27         public AddTokenSecretTextWatcher(AlertDialog dialog) {
28                 super(dialog);
29         }
30
31         @Override
32         public void afterTextChanged(Editable s) {
33                 super.afterTextChanged(s);
34
35                 if (s.length() == 0)
36                         return;
37
38                 boolean haveData = false;
39                 for (int i = s.length() - 1; i >= 0; i--) {
40                         char c = s.charAt(i);
41                         if (c != '=')
42                                 haveData = true;
43                         else if (haveData)
44                                 s.delete(i, i + 1);
45                 }
46         }
47 }