Commit e53edaca by sikang

bug fix

parent 6b14a257
package tech.starwin.utils.format_utils; package tech.starwin.utils.format_utils;
import android.app.Activity;
import android.util.Base64; import android.util.Base64;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.EdgeEffect; import android.widget.EdgeEffect;
...@@ -16,31 +18,48 @@ public class StringDecrypt { ...@@ -16,31 +18,48 @@ public class StringDecrypt {
public static final String FLAG = "#-#"; public static final String FLAG = "#-#";
public static String uncodeString(String text) { public static String uncodeString(String text) {
try {
if (text.contains(FLAG)) { if (text.contains(FLAG)) {
String key = text.split(FLAG)[0]; String key = text.split(FLAG)[0];
String value = text.split(FLAG)[1]; String value = text.split(FLAG)[1];
value = new String(Base64.decode(value.getBytes(), Base64.DEFAULT)); value = new String(Base64.decode(value.getBytes(), Base64.DEFAULT));
if (value.startsWith(key)) { if (value.startsWith(key)) {
value.replace(key, ""); value = value.replace(key + "#-#", "");
} }
return value; return value;
} }
} catch (Exception e) {
Log.d("StringDecrypt", text);
}
return text; return text;
} }
public static void uncode(ViewGroup viewGroup) {
Stack stack = new Stack(); public static void encode(Activity activity) {
for (int i = 0; i < viewGroup.getChildCount(); i++) { View rootView = ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
encode((ViewGroup) rootView);
}
public static void encode(ViewGroup viewGroup) {
try {
int count = viewGroup.getChildCount();
for (int i = 0; i < count; i++) {
View view = viewGroup.getChildAt(i); View view = viewGroup.getChildAt(i);
if (view instanceof TextView) { if (view instanceof ViewGroup) {
uncode((TextView) view); encode((ViewGroup) view);
} else if (view instanceof EditText) { } else if (view instanceof TextView) {
uncode((EditText) view); TextView textView = (TextView) view;
} else if (view instanceof ViewGroup) { String text = StringDecrypt.uncodeString(textView.getText().toString());
stack.push(viewGroup); textView.setText(text);
if (textView.getHint() != null) {
String hint = StringDecrypt.uncodeString(textView.getHint().toString());
textView.setHint(hint);
} }
} }
}
} catch (Exception e) {
Log.e("StringDecrypt", "can not update View!");
}
} }
public static void uncode(TextView textView) { public static void uncode(TextView textView) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment