Revision 378fe36a src/com/rackspace/cloud/android/PithosLoginActivity.java
b/src/com/rackspace/cloud/android/PithosLoginActivity.java | ||
---|---|---|
1 | 1 |
package com.rackspace.cloud.android; |
2 | 2 |
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 | 3 |
import java.net.URLDecoder; |
4 |
import java.util.ArrayList; |
|
5 |
import java.util.Arrays; |
|
8 | 6 |
import java.util.HashMap; |
9 | 7 |
import java.util.Map; |
10 | 8 |
import java.util.StringTokenizer; |
11 | 9 |
|
12 | 10 |
import org.apache.http.impl.cookie.BasicClientCookie; |
13 | 11 |
|
12 |
import com.rackspace.cloud.files.api.client.ContainerObjectManager; |
|
13 |
import com.rackspace.cloud.servers.api.client.CloudServersException; |
|
14 |
|
|
14 | 15 |
import android.app.AlertDialog; |
15 | 16 |
import android.content.DialogInterface; |
16 | 17 |
import android.content.Intent; |
17 | 18 |
import android.net.http.SslError; |
19 |
import android.os.AsyncTask; |
|
18 | 20 |
import android.os.Build; |
19 | 21 |
import android.os.Bundle; |
20 | 22 |
import android.text.method.PasswordTransformationMethod; |
... | ... | |
33 | 35 |
import android.widget.LinearLayout.LayoutParams; |
34 | 36 |
import android.widget.TextView; |
35 | 37 |
|
36 |
|
|
37 |
public class PithosLoginActivity extends CloudActivity{ |
|
38 |
String loginUrl=null; |
|
38 |
public class PithosLoginActivity extends CloudActivity { |
|
39 |
String loginUrl = null; |
|
39 | 40 |
String auth = null; |
40 |
|
|
41 |
|
|
41 | 42 |
public void onCreate(Bundle savedInstanceState) { |
42 |
super.onCreate(savedInstanceState);
|
|
43 |
trackPageView(GoogleAnalytics.PAGE_PROVIDERS);
|
|
44 |
Log.i("LOGIN","START");
|
|
45 |
|
|
46 |
setContentView(R.layout.login);
|
|
47 |
CookieSyncManager.createInstance(this);
|
|
43 |
super.onCreate(savedInstanceState);
|
|
44 |
trackPageView(GoogleAnalytics.PAGE_PROVIDERS);
|
|
45 |
Log.i("LOGIN", "START");
|
|
46 |
|
|
47 |
setContentView(R.layout.login);
|
|
48 |
CookieSyncManager.createInstance(this);
|
|
48 | 49 |
CookieSyncManager.getInstance().startSync(); |
49 | 50 |
CookieSyncManager.getInstance().sync(); |
50 |
//String loginUrl ="https://plus.pithos.grnet.gr/im/login/";//invitation?code=3219662435709009446"); |
|
51 |
// String loginUrl |
|
52 |
// ="https://plus.pithos.grnet.gr/im/login/";//invitation?code=3219662435709009446"); |
|
51 | 53 |
/* |
52 |
CookieManager.getInstance().setCookie(loginUrl, "_pithos2_a='';expires=Mon, 17 Oct 2010 10:47:11 UTC;"); |
|
53 |
CookieManager.getInstance().removeExpiredCookie(); |
|
54 |
CookieManager.getInstance().removeSessionCookie();*/ |
|
54 |
* CookieManager.getInstance().setCookie(loginUrl, |
|
55 |
* "_pithos2_a='';expires=Mon, 17 Oct 2010 10:47:11 UTC;"); |
|
56 |
* CookieManager.getInstance().removeExpiredCookie(); |
|
57 |
* CookieManager.getInstance().removeSessionCookie(); |
|
58 |
*/ |
|
55 | 59 |
CookieManager.getInstance().removeAllCookie(); |
56 |
final WebView webview = (WebView) findViewById(R.id.browser);//new WebView(this); |
|
57 |
|
|
58 |
loginUrl = getIntent().getExtras().getString("login"); |
|
59 |
auth = getIntent().getExtras().getString("auth"); |
|
60 |
webview.requestFocus(View.FOCUS_DOWN); |
|
61 |
webview.setOnTouchListener(new View.OnTouchListener() { |
|
62 |
@Override |
|
63 |
public boolean onTouch(View v, MotionEvent event) { |
|
64 |
switch (event.getAction()) { |
|
65 |
case MotionEvent.ACTION_DOWN: |
|
66 |
case MotionEvent.ACTION_UP: |
|
67 |
if (!v.hasFocus()) { |
|
68 |
v.requestFocus(); |
|
69 |
} |
|
70 |
break; |
|
71 |
} |
|
72 |
return false; |
|
73 |
} |
|
74 |
}); |
|
75 |
doLogin(webview); |
|
76 |
|
|
77 |
|
|
78 |
} |
|
60 |
final WebView webview = (WebView) findViewById(R.id.browser);// new |
|
61 |
// WebView(this); |
|
62 |
|
|
63 |
loginUrl = getIntent().getExtras().getString("login"); |
|
64 |
auth = getIntent().getExtras().getString("auth"); |
|
65 |
webview.requestFocus(View.FOCUS_DOWN); |
|
66 |
|
|
67 |
webview.setOnTouchListener(new View.OnTouchListener() { |
|
68 |
@Override |
|
69 |
public boolean onTouch(View v, MotionEvent event) { |
|
70 |
switch (event.getAction()) { |
|
71 |
case MotionEvent.ACTION_DOWN: |
|
72 |
case MotionEvent.ACTION_UP: |
|
73 |
if (!v.hasFocus()) { |
|
74 |
v.requestFocus(); |
|
75 |
} |
|
76 |
break; |
|
77 |
} |
|
78 |
return false; |
|
79 |
} |
|
80 |
}); |
|
81 |
doLogin(webview); |
|
82 |
|
|
83 |
} |
|
84 |
|
|
79 | 85 |
/* |
80 |
protected void onSaveInstanceState(Bundle outState) { |
|
81 |
super.onSaveInstanceState(outState);
|
|
82 |
//outState.putBoolean("isHidden", isHidden);
|
|
83 |
}*/
|
|
84 |
|
|
85 |
private void doLogin(final WebView webview){ |
|
86 |
|
|
86 |
* protected void onSaveInstanceState(Bundle outState) {
|
|
87 |
* super.onSaveInstanceState(outState); //outState.putBoolean("isHidden",
|
|
88 |
* isHidden); }
|
|
89 |
*/
|
|
90 |
|
|
91 |
private void doLogin(final WebView webview) {
|
|
92 |
|
|
87 | 93 |
webview.getSettings().setJavaScriptEnabled(true); |
88 | 94 |
// webview.setHttpAuthUsernamePassword("vho.grnet.gr", "VHO login", |
89 | 95 |
// "ebs-koutsoub", "mwJBdgbtv"); |
90 |
|
|
96 |
|
|
91 | 97 |
webview.clearCache(true); |
92 | 98 |
webview.clearFormData(); |
93 | 99 |
webview.clearHistory(); |
94 |
|
|
95 |
|
|
96 |
webview.getSettings().setBuiltInZoomControls(true); |
|
97 |
//webview.getSettings().setDefaultZoom(ZoomDensity.); |
|
98 |
//if(Build.VERSION.SDK_INT!=7) |
|
99 |
//webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS); |
|
100 |
|
|
100 |
|
|
101 |
// webview.getSettings().setBuiltInZoomControls(true); |
|
102 |
webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL); |
|
103 |
// if(Build.VERSION.SDK_INT!=7) |
|
104 |
// webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS); |
|
105 |
|
|
101 | 106 |
webview.setWebViewClient(new WebViewClient() { |
102 |
|
|
103 |
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error){ |
|
104 |
handler.proceed(); |
|
105 |
} |
|
106 |
|
|
107 |
@Override public boolean shouldOverrideUrlLoading(WebView view, |
|
108 |
String url) { |
|
109 |
view.loadUrl(url); return true; |
|
110 |
} |
|
111 |
|
|
107 |
|
|
108 |
public void onReceivedSslError(WebView view, |
|
109 |
SslErrorHandler handler, SslError error) { |
|
110 |
handler.proceed(); |
|
111 |
} |
|
112 |
|
|
112 | 113 |
@Override |
114 |
public boolean shouldOverrideUrlLoading(WebView view, String url) { |
|
115 |
view.loadUrl(url); |
|
116 |
return true; |
|
117 |
} |
|
113 | 118 |
|
119 |
@Override |
|
114 | 120 |
public void onPageFinished(WebView view, String url) { |
115 | 121 |
super.onPageFinished(view, url); |
116 |
|
|
122 |
|
|
117 | 123 |
CookieSyncManager.getInstance().sync(); |
118 |
|
|
124 |
|
|
119 | 125 |
String cookie = CookieManager.getInstance().getCookie(url); |
120 |
if(cookie!=null) |
|
121 |
Log.i("LOGIN COOKIE",url+" c: "+cookie +" "+cookie.contains("_pithos2_a")); |
|
122 |
/*if(url.indexOf('?')!=-1){ |
|
123 |
String q = url.substring(url.indexOf('?'),url.length()); |
|
124 |
Log.i("LOGIN COOKIE",url+" c: "+q); |
|
125 |
Map<String,String> params = getQueryMap(q); |
|
126 |
String token = params.get("token"); |
|
127 |
String user = params.get("user"); |
|
128 |
if(token!=null&&user!=null) |
|
129 |
exit(user,token); |
|
130 |
|
|
131 |
}*/ |
|
132 |
if(null!=cookie && cookie.contains("_pithos2_a")){ |
|
133 |
StringTokenizer str1 = new StringTokenizer(cookie,";"); |
|
134 |
while(str1.hasMoreTokens()){ |
|
126 |
if (cookie != null) |
|
127 |
Log.i("LOGIN COOKIE", |
|
128 |
url + " c: " + cookie + " " |
|
129 |
+ cookie.contains("_pithos2_a")); |
|
130 |
/* |
|
131 |
* if(url.indexOf('?')!=-1){ String q = |
|
132 |
* url.substring(url.indexOf('?'),url.length()); |
|
133 |
* Log.i("LOGIN COOKIE",url+" c: "+q); Map<String,String> params |
|
134 |
* = getQueryMap(q); String token = params.get("token"); String |
|
135 |
* user = params.get("user"); if(token!=null&&user!=null) |
|
136 |
* exit(user,token); |
|
137 |
* |
|
138 |
* } |
|
139 |
*/ |
|
140 |
if (null != cookie && cookie.contains("_pithos2_a")) { |
|
141 |
StringTokenizer str1 = new StringTokenizer(cookie, ";"); |
|
142 |
while (str1.hasMoreTokens()) { |
|
135 | 143 |
String cc = str1.nextToken(); |
136 |
Log.i("LOGIN","token:"+cc);
|
|
137 |
if(cc.trim().startsWith("_pithos2_a")){
|
|
138 |
Log.i("LOGIN COOKIE INSIDE",url+" c: "+cc);
|
|
144 |
Log.i("LOGIN", "token:" + cc);
|
|
145 |
if (cc.trim().startsWith("_pithos2_a")) {
|
|
146 |
Log.i("LOGIN COOKIE INSIDE", url + " c: " + cc);
|
|
139 | 147 |
try { |
140 |
String value = URLDecoder.decode(parseRawCookie(cc).getValue()); |
|
141 |
StringTokenizer str = new StringTokenizer(value,"|"); |
|
142 |
if(str.countTokens()==2){ |
|
148 |
String value = URLDecoder |
|
149 |
.decode(parseRawCookie(cc).getValue()); |
|
150 |
StringTokenizer str = new StringTokenizer( |
|
151 |
value, "|"); |
|
152 |
if (str.countTokens() == 2) { |
|
143 | 153 |
String u = str.nextToken(); |
144 | 154 |
String t = str.nextToken(); |
145 |
Log.i("value",value); |
|
146 |
Log.i("s1",u); |
|
147 |
Log.i("s2",t); |
|
148 |
exit(u,t); |
|
155 |
if (u.startsWith("\"")) |
|
156 |
u = u.substring(1, u.length()); |
|
157 |
if (t.endsWith("\"")) |
|
158 |
t = t.substring(0, t.length() - 1); |
|
159 |
Log.i("value", value); |
|
160 |
Log.i("s1", u); |
|
161 |
Log.i("s2", t); |
|
162 |
exit(u, t); |
|
149 | 163 |
return; |
150 | 164 |
} |
151 |
|
|
152 |
//exit(s[0], s[1]); |
|
165 |
|
|
166 |
// exit(s[0], s[1]);
|
|
153 | 167 |
} catch (Exception e) { |
154 | 168 |
// TODO Auto-generated catch block |
155 | 169 |
e.printStackTrace(); |
156 | 170 |
} |
157 | 171 |
} |
158 | 172 |
} |
159 |
|
|
173 |
|
|
160 | 174 |
} |
161 | 175 |
} |
162 | 176 |
|
... | ... | |
166 | 180 |
String[] up = view.getHttpAuthUsernamePassword(host, realm); |
167 | 181 |
if (up != null && up.length == 2) { |
168 | 182 |
handler.proceed(up[0], up[1]); |
169 |
|
|
183 |
|
|
170 | 184 |
} else { |
171 |
final AlertDialog.Builder alert = new AlertDialog.Builder(PithosLoginActivity.this); |
|
172 |
alert.setTitle("Pithos Login"); |
|
173 |
//View lv = findViewById(R.layout.dialoglogin); |
|
174 |
//alert.setView(lv); |
|
175 |
final EditText input = new EditText(PithosLoginActivity.this);//(EditText) lv.findViewById(R.id.username); |
|
176 |
final EditText pass = new EditText(PithosLoginActivity.this);//(EditText) lv.findViewById(R.id.password); |
|
177 |
pass.setTransformationMethod(new PasswordTransformationMethod()); |
|
178 |
LinearLayout layout = new LinearLayout(PithosLoginActivity.this); |
|
179 |
layout.setOrientation(LinearLayout.VERTICAL); |
|
180 |
LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); |
|
181 |
layout.setLayoutParams(params); |
|
182 |
input.setLayoutParams(params); |
|
183 |
pass.setLayoutParams(params); |
|
184 |
TextView username = new TextView(PithosLoginActivity.this); |
|
185 |
username.setText("Username:"); |
|
186 |
|
|
187 |
TextView password = new TextView(PithosLoginActivity.this); |
|
188 |
password.setText("Password:"); |
|
189 |
layout.addView(username); |
|
190 |
layout.addView(input); |
|
191 |
layout.addView(password); |
|
192 |
layout.addView(pass); |
|
193 |
alert.setView(layout); |
|
194 |
|
|
195 |
alert.setPositiveButton("Login", new DialogInterface.OnClickListener() { |
|
196 |
public void onClick(DialogInterface dialog, int whichButton) { |
|
197 |
String uvalue = input.getText().toString().trim(); |
|
198 |
String pvalue = pass.getText().toString().trim(); |
|
199 |
handler.proceed(uvalue, pvalue); |
|
200 |
} |
|
201 |
}); |
|
202 |
|
|
203 |
alert.setNegativeButton("Cancel", |
|
204 |
new DialogInterface.OnClickListener() { |
|
205 |
public void onClick(DialogInterface dialog, int whichButton) { |
|
206 |
dialog.cancel(); |
|
207 |
} |
|
208 |
}); |
|
209 |
alert.show(); |
|
210 |
} |
|
185 |
final AlertDialog.Builder alert = new AlertDialog.Builder( |
|
186 |
PithosLoginActivity.this); |
|
187 |
alert.setTitle("Pithos Login"); |
|
188 |
// View lv = findViewById(R.layout.dialoglogin); |
|
189 |
// alert.setView(lv); |
|
190 |
final EditText input = new EditText( |
|
191 |
PithosLoginActivity.this);// (EditText) |
|
192 |
// lv.findViewById(R.id.username); |
|
193 |
final EditText pass = new EditText(PithosLoginActivity.this);// (EditText) |
|
194 |
// lv.findViewById(R.id.password); |
|
195 |
pass.setTransformationMethod(new PasswordTransformationMethod()); |
|
196 |
LinearLayout layout = new LinearLayout( |
|
197 |
PithosLoginActivity.this); |
|
198 |
layout.setOrientation(LinearLayout.VERTICAL); |
|
199 |
LayoutParams params = new LayoutParams( |
|
200 |
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); |
|
201 |
layout.setLayoutParams(params); |
|
202 |
input.setLayoutParams(params); |
|
203 |
pass.setLayoutParams(params); |
|
204 |
TextView username = new TextView(PithosLoginActivity.this); |
|
205 |
username.setText("Username:"); |
|
206 |
|
|
207 |
TextView password = new TextView(PithosLoginActivity.this); |
|
208 |
password.setText("Password:"); |
|
209 |
layout.addView(username); |
|
210 |
layout.addView(input); |
|
211 |
layout.addView(password); |
|
212 |
layout.addView(pass); |
|
213 |
alert.setView(layout); |
|
214 |
|
|
215 |
alert.setPositiveButton("Login", |
|
216 |
new DialogInterface.OnClickListener() { |
|
217 |
public void onClick(DialogInterface dialog, |
|
218 |
int whichButton) { |
|
219 |
String uvalue = input.getText().toString() |
|
220 |
.trim(); |
|
221 |
String pvalue = pass.getText().toString() |
|
222 |
.trim(); |
|
223 |
handler.proceed(uvalue, pvalue); |
|
224 |
} |
|
225 |
}); |
|
226 |
|
|
227 |
alert.setNegativeButton("Cancel", |
|
228 |
new DialogInterface.OnClickListener() { |
|
229 |
public void onClick(DialogInterface dialog, |
|
230 |
int whichButton) { |
|
231 |
dialog.cancel(); |
|
232 |
} |
|
233 |
}); |
|
234 |
alert.show(); |
|
211 | 235 |
} |
236 |
} |
|
212 | 237 |
|
213 |
|
|
214 | 238 |
}); |
215 |
Log.i("LOGIN","LOADING:"+loginUrl);
|
|
216 |
//setContentView(webview); |
|
239 |
Log.i("LOGIN", "LOADING:" + loginUrl);
|
|
240 |
// setContentView(webview);
|
|
217 | 241 |
webview.clearSslPreferences(); |
218 |
//webview.loadUrl("https://pithos.dev.grnet.gr/im/login/invitation?code=6879429392467020041"); |
|
219 |
|
|
220 |
|
|
221 |
webview.loadUrl(loginUrl);//invitation?code=3219662435709009446"); |
|
222 |
|
|
223 |
//webview.loadUrl("http://www.google.gr"); |
|
242 |
// webview.loadUrl("https://pithos.dev.grnet.gr/im/login/invitation?code=6879429392467020041"); |
|
243 |
|
|
244 |
webview.loadUrl(loginUrl);// invitation?code=3219662435709009446"); |
|
245 |
|
|
246 |
// webview.loadUrl("http://www.google.gr"); |
|
224 | 247 |
} |
225 |
|
|
248 |
|
|
226 | 249 |
public static Map<String, String> getQueryMap(String query) { |
227 | 250 |
String[] params = query.split("&"); |
228 | 251 |
Map<String, String> map = new HashMap<String, String>(); |
229 | 252 |
for (String param : params) { |
230 | 253 |
String name = param.split("=")[0]; |
231 | 254 |
String value = param.split("=")[1]; |
232 |
if(param.endsWith("==")) |
|
233 |
value=value+"==";
|
|
234 |
else if(param.endsWith("=")) |
|
235 |
value=value+"=";
|
|
236 |
|
|
237 |
Log.d("DD",name +" "+value);
|
|
255 |
if (param.endsWith("=="))
|
|
256 |
value = value + "==";
|
|
257 |
else if (param.endsWith("="))
|
|
258 |
value = value + "=";
|
|
259 |
|
|
260 |
Log.d("DD", name + " " + value);
|
|
238 | 261 |
map.put(name, value); |
239 | 262 |
} |
240 | 263 |
return map; |
241 | 264 |
} |
242 |
void exit(String username,String token){ |
|
243 |
Log.i("LOGINA",username+" "+token); |
|
265 |
|
|
266 |
void exit(final String username, final String token) { |
|
267 |
Log.d("LOGINA", username + " " + token); |
|
244 | 268 |
Intent result = new Intent(); |
245 | 269 |
Bundle b = new Bundle(); |
246 | 270 |
b.putString("username", username); |
... | ... | |
248 | 272 |
b.putString("server", auth); |
249 | 273 |
result.putExtra("accountInfo", b); |
250 | 274 |
setResult(RESULT_OK, result); |
275 |
PithosLoginActivity.this.finish(); |
|
276 |
} |
|
277 |
|
|
278 |
public void returnToCaller(Bundle b) { |
|
279 |
Intent result = new Intent(); |
|
280 |
result.putExtra("accountInfo", b); |
|
281 |
setResult(RESULT_OK, result); |
|
251 | 282 |
finish(); |
252 | 283 |
} |
253 |
|
|
254 |
|
|
284 |
|
|
255 | 285 |
BasicClientCookie parseRawCookie(String rawCookie) throws Exception { |
256 |
String[] rawCookieParams = rawCookie.split(";");
|
|
286 |
String[] rawCookieParams = rawCookie.split(";");
|
|
257 | 287 |
|
258 |
String[] rawCookieNameAndValue = rawCookieParams[0].split("=");
|
|
259 |
if (rawCookieNameAndValue.length != 2) {
|
|
260 |
throw new Exception("Invalid cookie: missing name and value.");
|
|
261 |
}
|
|
288 |
String[] rawCookieNameAndValue = rawCookieParams[0].split("=");
|
|
289 |
if (rawCookieNameAndValue.length != 2) {
|
|
290 |
throw new Exception("Invalid cookie: missing name and value.");
|
|
291 |
}
|
|
262 | 292 |
|
263 |
String cookieName = rawCookieNameAndValue[0].trim(); |
|
264 |
String cookieValue = rawCookieNameAndValue[1].trim(); |
|
265 |
BasicClientCookie cookie = new BasicClientCookie(cookieName, cookieValue); |
|
266 |
for (int i = 1; i < rawCookieParams.length; i++) { |
|
267 |
String rawCookieParamNameAndValue[] = rawCookieParams[i].trim().split("="); |
|
293 |
String cookieName = rawCookieNameAndValue[0].trim(); |
|
294 |
String cookieValue = rawCookieNameAndValue[1].trim(); |
|
295 |
BasicClientCookie cookie = new BasicClientCookie(cookieName, |
|
296 |
cookieValue); |
|
297 |
for (int i = 1; i < rawCookieParams.length; i++) { |
|
298 |
String rawCookieParamNameAndValue[] = rawCookieParams[i].trim() |
|
299 |
.split("="); |
|
268 | 300 |
|
269 |
String paramName = rawCookieParamNameAndValue[0].trim();
|
|
301 |
String paramName = rawCookieParamNameAndValue[0].trim();
|
|
270 | 302 |
|
271 |
if (paramName.equalsIgnoreCase("secure")) { |
|
272 |
cookie.setSecure(true); |
|
273 |
} else { |
|
274 |
if (rawCookieParamNameAndValue.length != 2) { |
|
275 |
throw new Exception("Invalid cookie: attribute not a flag or missing value."); |
|
276 |
} |
|
303 |
if (paramName.equalsIgnoreCase("secure")) { |
|
304 |
cookie.setSecure(true); |
|
305 |
} else { |
|
306 |
if (rawCookieParamNameAndValue.length != 2) { |
|
307 |
throw new Exception( |
|
308 |
"Invalid cookie: attribute not a flag or missing value."); |
|
309 |
} |
|
277 | 310 |
|
278 |
String paramValue = rawCookieParamNameAndValue[1].trim();
|
|
311 |
String paramValue = rawCookieParamNameAndValue[1].trim();
|
|
279 | 312 |
|
280 |
|
|
281 |
} |
|
282 |
} |
|
313 |
} |
|
314 |
} |
|
283 | 315 |
|
284 |
return cookie;
|
|
316 |
return cookie;
|
|
285 | 317 |
} |
286 |
|
|
318 |
|
|
287 | 319 |
private String lastHtml; |
288 |
|
|
320 |
|
|
289 | 321 |
public void setLastHtml(String lastHtml) { |
290 | 322 |
this.lastHtml = lastHtml; |
291 | 323 |
} |
292 |
|
|
324 |
|
|
293 | 325 |
public String getLastHtml() { |
294 | 326 |
return lastHtml; |
295 | 327 |
} |
296 |
class MyJavaScriptInterface { |
|
297 |
|
|
298 |
public void showHTML(String html) { |
|
299 |
setLastHtml(html); |
|
300 |
|
|
301 |
} } |
|
302 |
|
|
303 |
private String getHtmlValue(String substring, String html){ String |
|
304 |
result=null; boolean found = false; found = html.contains(substring); if |
|
305 |
(found) { int indx = html.indexOf(substring); StringBuffer res = new |
|
306 |
StringBuffer(); for (int i = indx + substring.length(); i < html |
|
307 |
.length(); i++) { char c = html.charAt(i); if (c == '<') break; |
|
308 |
res.append(c); } |
|
309 |
|
|
310 |
result = res.toString(); result = result.trim(); |
|
311 |
|
|
312 |
} return result; } |
|
313 |
|
|
328 |
|
|
329 |
class MyJavaScriptInterface { |
|
330 |
|
|
331 |
public void showHTML(String html) { |
|
332 |
setLastHtml(html); |
|
333 |
|
|
334 |
} |
|
335 |
} |
|
336 |
|
|
337 |
private String getHtmlValue(String substring, String html) { |
|
338 |
String result = null; |
|
339 |
boolean found = false; |
|
340 |
found = html.contains(substring); |
|
341 |
if (found) { |
|
342 |
int indx = html.indexOf(substring); |
|
343 |
StringBuffer res = new StringBuffer(); |
|
344 |
for (int i = indx + substring.length(); i < html.length(); i++) { |
|
345 |
char c = html.charAt(i); |
|
346 |
if (c == '<') |
|
347 |
break; |
|
348 |
res.append(c); |
|
349 |
} |
|
350 |
|
|
351 |
result = res.toString(); |
|
352 |
result = result.trim(); |
|
353 |
|
|
354 |
} |
|
355 |
return result; |
|
356 |
} |
|
357 |
|
|
314 | 358 |
} |
Also available in: Unified diff