2 * ***************************************************************
4 * Copyright 2015 Samsung Electronics All Rights Reserved.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 * ****************************************************************
23 package org.iotivity.service.easysetup;
25 import android.app.Activity;
26 import android.app.AlertDialog;
27 import android.content.DialogInterface;
28 import android.content.Intent;
29 import android.content.SharedPreferences;
30 import android.net.ConnectivityManager;
31 import android.net.NetworkInfo;
32 import android.net.UrlQuerySanitizer;
33 import android.net.wifi.WifiConfiguration;
34 import android.net.wifi.WifiManager;
35 import android.os.Bundle;
36 import android.os.Handler;
37 import android.os.Message;
38 import android.preference.PreferenceManager;
39 import android.util.Log;
40 import android.view.View;
41 import android.view.View.OnClickListener;
42 import android.webkit.WebView;
43 import android.webkit.WebViewClient;
44 import android.widget.Button;
45 import android.widget.EditText;
46 import android.widget.LinearLayout;
47 import android.widget.ProgressBar;
48 import android.widget.RadioButton;
49 import android.widget.RelativeLayout;
50 import android.widget.TextView;
51 import android.widget.Toast;
53 import org.iotivity.base.ModeType;
54 import org.iotivity.base.OcException;
55 import org.iotivity.base.OcPlatform;
56 import org.iotivity.base.OcProvisioning;
57 import org.iotivity.base.PlatformConfig;
58 import org.iotivity.base.QualityOfService;
59 import org.iotivity.base.ServiceType;
62 import java.io.FileNotFoundException;
63 import java.io.FileOutputStream;
64 import java.io.IOException;
65 import java.io.InputStream;
66 import java.io.OutputStream;
69 public class LoginActivity extends Activity {
70 private static final String TAG = "Easysetup Login: ";
73 private WebView mWebView = null;
76 protected void onCreate(Bundle savedInstanceState) {
77 super.onCreate(savedInstanceState);
78 setContentView(R.layout.activity_login);
80 /* For Samsung account authentifaction */
81 mWebView = (WebView) findViewById(R.id.webView);
82 mWebView.setVisibility(View.VISIBLE);
83 mWebView.setInitialScale(200);
84 mWebView.getSettings().setJavaScriptEnabled(true);
85 //mWebView.getSettings().setSupportZoom(true);
86 mWebView.getSettings().setBuiltInZoomControls(true);
87 mWebView.setWebViewClient(new WebViewClientClass());
89 mWebView.loadUrl("https://account.samsung.com/account/check.do?actionID=StartAP&serviceID=85o501t021&countryCode=KR&languageCode=ko&serviceChannel=PC_APP");
93 public void onDestroy() {
97 private class WebViewClientClass extends WebViewClient {
100 public void onPageFinished(WebView view, String url) {
101 Log.e(TAG, "called!!! url=" + url);
103 if(url.contains("https://account.samsung.com/account/hybridCommonClosed.do")){
105 mWebView.setVisibility(View.INVISIBLE);
108 UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
109 sanitizer.setAllowUnregisteredParamaters(true);
110 sanitizer.parseUrl(url);
112 String mAuthCode = null;
113 mAuthCode = sanitizer.getValue("code");
115 Intent intent = getIntent();
116 intent.putExtra("authCode", mAuthCode);
117 intent.putExtra("authProvider", "samsung");
119 setResult(RESULT_OK, intent);