利用規約に同意する。ログイン画面修正と、ダイアログ表示。
Showing
... | @@ -14,11 +14,23 @@ import android.view.animation.Animation; | ... | @@ -14,11 +14,23 @@ import android.view.animation.Animation; |
import android.view.animation.Animation.AnimationListener; | import android.view.animation.Animation.AnimationListener; | ||
import android.view.animation.TranslateAnimation; | import android.view.animation.TranslateAnimation; | ||
import android.view.inputmethod.InputMethodManager; | import android.view.inputmethod.InputMethodManager; | ||
import android.widget.Button; | |||
import android.widget.CheckBox; | |||
import android.widget.EditText; | import android.widget.EditText; | ||
import android.widget.ImageButton; | import android.widget.ImageButton; | ||
import android.widget.TextView; | import android.widget.TextView; | ||
import android.widget.Toast; | import android.widget.Toast; | ||
import org.json.adf.JSONObject; | |||
import java.io.BufferedReader; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.io.InputStreamReader; | |||
import java.net.HttpURLConnection; | |||
import java.net.URL; | |||
import java.util.Locale; | |||
import jp.agentec.abook.abv.bl.acms.client.json.CmsUrlJSON; | import jp.agentec.abook.abv.bl.acms.client.json.CmsUrlJSON; | ||
import jp.agentec.abook.abv.bl.acms.type.DeleteDataType; | import jp.agentec.abook.abv.bl.acms.type.DeleteDataType; | ||
import jp.agentec.abook.abv.bl.acms.type.LoginMode; | import jp.agentec.abook.abv.bl.acms.type.LoginMode; | ||
... | @@ -53,12 +65,16 @@ import jp.agentec.abook.abv.cl.environment.DeviceInfo; | ... | @@ -53,12 +65,16 @@ import jp.agentec.abook.abv.cl.environment.DeviceInfo; |
import jp.agentec.abook.abv.cl.util.PreferenceUtil; | import jp.agentec.abook.abv.cl.util.PreferenceUtil; | ||
import jp.agentec.abook.abv.launcher.android.R; | import jp.agentec.abook.abv.launcher.android.R; | ||
import jp.agentec.abook.abv.ui.common.activity.ABVLoginActivity; | import jp.agentec.abook.abv.ui.common.activity.ABVLoginActivity; | ||
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType; | |||
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.UserPrefKey; | import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.UserPrefKey; | ||
import jp.agentec.abook.abv.ui.common.constant.ErrorCode; | import jp.agentec.abook.abv.ui.common.constant.ErrorCode; | ||
import jp.agentec.abook.abv.ui.common.constant.ErrorMessage; | import jp.agentec.abook.abv.ui.common.constant.ErrorMessage; | ||
import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog; | import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog; | ||
import jp.agentec.abook.abv.ui.common.helper.ABVViewUnbindHelper; | import jp.agentec.abook.abv.ui.common.helper.ABVViewUnbindHelper; | ||
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil; | import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil; | ||
import jp.agentec.adf.net.http.HttpRequestSender; | |||
import jp.agentec.adf.net.http.HttpResponse; | |||
import jp.agentec.adf.util.NumericUtil; | |||
import jp.agentec.adf.util.StringUtil; | import jp.agentec.adf.util.StringUtil; | ||
/** | /** | ||
... | @@ -94,6 +110,12 @@ public class LoginActivity extends ABVLoginActivity { | ... | @@ -94,6 +110,12 @@ public class LoginActivity extends ABVLoginActivity { |
private InputMethodManager imm; | private InputMethodManager imm; | ||
private Button btnLoginOff; | |||
private Button btnLoginOn; | |||
private CheckBox chexBoxAgree; | |||
private String detail_text = ""; | |||
|
|||
private static String agreementUrl = ABVEnvironment.getInstance().agree_to_terms_of_use_url; | |||
@Override | @Override | ||
public void onCreate(Bundle savedInstanceState) { | public void onCreate(Bundle savedInstanceState) { | ||
Logger.i(TAG, "onCreate"); | Logger.i(TAG, "onCreate"); | ||
... | @@ -148,12 +170,40 @@ public class LoginActivity extends ABVLoginActivity { | ... | @@ -148,12 +170,40 @@ public class LoginActivity extends ABVLoginActivity { |
} | } | ||
}); | }); | ||
findViewById(R.id.btn_login).setOnClickListener(new View.OnClickListener() { | // ログインボタン(最初はGONEにして見せない) | ||
btnLoginOn = findViewById(R.id.btn_login_on); | |||
btnLoginOn.setOnClickListener(new View.OnClickListener() { | |||
@Override | @Override | ||
public void onClick(View v) { | public void onClick(View v) { | ||
tryLogin(); | tryLogin(); | ||
} | } | ||
}); | }); | ||
btnLoginOff = findViewById(R.id.btn_login_off); | |||
btnLoginOff.setVisibility(View.VISIBLE); | |||
// チェックボックス | |||
chexBoxAgree = findViewById(R.id.check_box_agree); | |||
// 初期化(状態は保存しておく。ログアウトした後に使う) | |||
boolean agree = PreferenceUtil.getUserPref(LoginActivity.this, AppDefType.PrefName.AGREE_STATUS, false); | |||
if (agree) { | |||
btnLoginOn.setVisibility(View.VISIBLE); | |||
btnLoginOff.setVisibility(View.GONE); | |||
chexBoxAgree.setChecked(true); | |||
} | |||
chexBoxAgree.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
if (chexBoxAgree.isChecked()) { | |||
btnLoginOn.setVisibility(View.VISIBLE); | |||
btnLoginOff.setVisibility(View.GONE); | |||
PreferenceUtil.putUserPref(LoginActivity.this, AppDefType.PrefName.AGREE_STATUS, true); | |||
} else { | |||
btnLoginOn.setVisibility(View.GONE); | |||
btnLoginOff.setVisibility(View.VISIBLE); | |||
PreferenceUtil.putUserPref(LoginActivity.this, AppDefType.PrefName.AGREE_STATUS, false); | |||
} | |||
} | |||
}); | |||
//androidバジョン6以上からMAC idではなくandroid固有numberを取得ため、ダイアログで表示 | //androidバジョン6以上からMAC idではなくandroid固有numberを取得ため、ダイアログで表示 | ||
if (android.os.Build.VERSION.SDK_INT >= 23) { | if (android.os.Build.VERSION.SDK_INT >= 23) { | ||
... | @@ -193,6 +243,89 @@ public class LoginActivity extends ABVLoginActivity { | ... | @@ -193,6 +243,89 @@ public class LoginActivity extends ABVLoginActivity { |
ErrorMessage.showErrorMessageDialog(this, R.string.app_name, ErrorCode.L110); | ErrorMessage.showErrorMessageDialog(this, R.string.app_name, ErrorCode.L110); | ||
} | } | ||
} | } | ||
// 詳細ボタン | |||
Button btnDetail = findViewById(R.id.detail); | |||
btnDetail.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
CommonExecutor.execute(new Runnable() { | |||
@Override | |||
public void run() { | |||
// CMSより文言を取得し、ダイアログで表示する。 | |||
detail_text = getAgreementText(); | |||
runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
final ABookAlertDialog messageDialog = AlertDialogUtil.createAlertDialog(LoginActivity.this, R.string.error); | |||
if (detail_text != null) { | |||
JSONObject detail_json = new JSONObject(detail_text); | |||
Locale locale = Locale.getDefault(); | |||
if (locale.getLanguage().equals("ja")) { | |||
messageDialog.setMessage(detail_json.getString("ja")); | |||
} else if (locale.getLanguage().equals("ko")) { | |||
messageDialog.setMessage(detail_json.getString("ko")); | |||
} else { | |||
messageDialog.setMessage(detail_json.getString("en")); | |||
} | |||
} else { | |||
messageDialog.setMessage(R.string.NETWORK); | |||
} | |||
messageDialog.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() { | |||
@Override | |||
public void onClick(DialogInterface dialog, int which) { | |||
dialog.dismiss(); | |||
} | |||
}); | |||
messageDialog.show(); | |||
} | |||
}); | |||
} | |||
}); | |||
} | |||
}); | |||
} | |||
/** | |||
* 利用規約の詳細文を取得する | |||
* @return 取得した文字列(失敗したらnullが返る) | |||
*/ | |||
private String getAgreementText() { | |||
HttpResponse response = new HttpResponse(); | |||
HttpURLConnection conn = null; | |||
try { | |||
java.net.URL url = new URL(agreementUrl); | |||
Logger.d(TAG, "url=" + url); | |||
conn = HttpRequestSender.openConnection("GET", url, "UTF-8", null, null, 5000); | |||
Logger.i(TAG,"responseCode : " + conn.getResponseCode()); | |||
response.httpResponseCode = conn.getResponseCode(); | |||
if (response.httpResponseCode != 200) { | |||
return null; | |||
} | |||
response.httpResponseMessage = conn.getResponseMessage(); | |||
response.contentLength = NumericUtil.parseLong(conn.getHeaderField("Content-Length"), 0); | |||
InputStream inputStream = conn.getInputStream(); | |||
BufferedReader bufferReader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8")); | |||
String resultJson = new String(); | |||
String str; | |||
while ( null != ( str = bufferReader.readLine() ) ) { | |||
resultJson = resultJson + str; | |||
} | |||
bufferReader.close(); | |||
Logger.i(TAG,"response JSON : " + resultJson); | |||
return resultJson; | |||
} catch (IOException e) { | |||
Logger.e(e.getMessage()); | |||
} catch (NumberFormatException e) { | |||
Logger.e(e.getMessage()); | |||
} finally { | |||
if (conn != null) { | |||
conn.disconnect(); | |||
} | |||
} | |||
return null; | |||
} | } | ||
@Override | @Override | ||
... | @@ -362,6 +495,10 @@ public class LoginActivity extends ABVLoginActivity { | ... | @@ -362,6 +495,10 @@ public class LoginActivity extends ABVLoginActivity { |
return false; | return false; | ||
} | } | ||
} | } | ||
if (!chexBoxAgree.isChecked()) { | |||
handleErrorMessageToast(ErrorCode.E132); | |||
return false; | |||
} | |||
return true; | return true; | ||
} | } | ||
... | ... |