Commit 409f5a6e by Kazuyuki Hida

レビューの指摘により、下記を修正。

* コメントを追加した。
* LoginActivityの動作を元に戻した。
parent 80247a91
...@@ -1114,12 +1114,28 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -1114,12 +1114,28 @@ public class AcmsClient implements AcmsClientResponseListener {
return new TermsOfUseJson(response.httpResponseBody); return new TermsOfUseJson(response.httpResponseBody);
} }
/**
* 規約情報の取得
*
* @param sid セッションID
* @return
* @throws AcmsException CMSがエラーを返した時の例外
* @throws NetworkDisconnectedException ネットワークエラー
*/
public AgreementToTermsJSON getTerms(String sid) throws AcmsException, NetworkDisconnectedException { public AgreementToTermsJSON getTerms(String sid) throws AcmsException, NetworkDisconnectedException {
HttpResponse response = send(AcmsApis.ApiGetTerms, new AcmsParameters(sid)); HttpResponse response = send(AcmsApis.ApiGetTerms, new AcmsParameters(sid));
AgreementToTermsJSON json = new AgreementToTermsJSON(response.httpResponseBody); AgreementToTermsJSON json = new AgreementToTermsJSON(response.httpResponseBody);
return json; return json;
} }
/**
* 規約に同意したことをCMSに通達
*
* @param params パラメータ
* @return 標準的なレスポンス
* @throws AcmsException CMSがエラーを返した時の例外
* @throws NetworkDisconnectedException ネットワークエラー
*/
public AcmsCommonJSON agreeTerms(AgreementToTermsParameters params) throws AcmsException, NetworkDisconnectedException { public AcmsCommonJSON agreeTerms(AgreementToTermsParameters params) throws AcmsException, NetworkDisconnectedException {
HttpResponse response = send(AcmsApis.ApiAgreeTerms, params); HttpResponse response = send(AcmsApis.ApiAgreeTerms, params);
AcmsCommonJSON json = new AcmsCommonJSON(response.httpResponseBody); AcmsCommonJSON json = new AcmsCommonJSON(response.httpResponseBody);
......
...@@ -6,6 +6,9 @@ import org.json.adf.JSONObject; ...@@ -6,6 +6,9 @@ import org.json.adf.JSONObject;
import jp.agentec.abook.abv.bl.common.exception.AcmsException; import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException; import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
/**
* 規約同意のAPIで使うレスポンス
*/
public class AgreementToTermsJSON extends AcmsCommonJSON { public class AgreementToTermsJSON extends AcmsCommonJSON {
private static final String TERMS_VERSION = "termsVersion"; private static final String TERMS_VERSION = "termsVersion";
...@@ -25,10 +28,16 @@ public class AgreementToTermsJSON extends AcmsCommonJSON { ...@@ -25,10 +28,16 @@ public class AgreementToTermsJSON extends AcmsCommonJSON {
terms = json.has(TERMS) ? json.getString(TERMS) : ""; terms = json.has(TERMS) ? json.getString(TERMS) : "";
} }
/**
* @return 規約のバージョン
*/
public String getTermsVersion() { public String getTermsVersion() {
return termsVersion; return termsVersion;
} }
/**
* @return 規約の内容
*/
public String getTerms() { public String getTerms() {
return terms; return terms;
} }
......
...@@ -2,20 +2,33 @@ package jp.agentec.abook.abv.bl.acms.client.parameters; ...@@ -2,20 +2,33 @@ package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject; import jp.agentec.adf.net.http.HttpParameterObject;
/**
* 規約同意時に使用するパラメータ
*/
public class AgreementToTermsParameters extends HttpParameterObject { public class AgreementToTermsParameters extends HttpParameterObject {
private final String sid; private final String sid;
private final String termsVersion; private final String termsVersion;
/**
* @param sid セッションID
* @param termsVersion 同意した規約のバージョン
*/
public AgreementToTermsParameters(String sid, String termsVersion) { public AgreementToTermsParameters(String sid, String termsVersion) {
super(); super();
this.sid = sid; this.sid = sid;
this.termsVersion = termsVersion; this.termsVersion = termsVersion;
} }
/**
* @return セッションID
*/
public String getSid() { public String getSid() {
return sid; return sid;
} }
/**
* @return 同意した規約のバージョン
*/
public String getTermsVersion() { public String getTermsVersion() {
return termsVersion; return termsVersion;
} }
......
...@@ -351,6 +351,9 @@ public class ABVDataCache { ...@@ -351,6 +351,9 @@ public class ABVDataCache {
return isServiceOptionEnable(ServiceOptionId.AlcoholCheckerHw); return isServiceOptionEnable(ServiceOptionId.AlcoholCheckerHw);
} }
/**
* @return 規約同意オプションがYならtrue
*/
public boolean isUsableAgreementToTerms() { public boolean isUsableAgreementToTerms() {
return isServiceOptionEnable(ServiceOptionId.agrementToTerms); return isServiceOptionEnable(ServiceOptionId.agrementToTerms);
} }
......
...@@ -7,14 +7,32 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.AgreementToTermsParameters ...@@ -7,14 +7,32 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.AgreementToTermsParameters
import jp.agentec.abook.abv.bl.common.exception.AcmsException; import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException; import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
/**
* 規約同意の入出力
*/
public class AgreementToTermsLogic extends AbstractLogic { public class AgreementToTermsLogic extends AbstractLogic {
private static final String TAG = "AgreementToTermsLogic"; private static final String TAG = "AgreementToTermsLogic";
/**
* 規約情報の取得
*
* @return 規約情報
* @throws AcmsException CMSがエラーを返したという例外
* @throws NetworkDisconnectedException ネットワークエラー
*/
public AgreementToTermsJSON getTerms() throws AcmsException, NetworkDisconnectedException { public AgreementToTermsJSON getTerms() throws AcmsException, NetworkDisconnectedException {
String sid = cache.getMemberInfo().sid; String sid = cache.getMemberInfo().sid;
return AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).getTerms(sid); return AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).getTerms(sid);
} }
/**
* 同意したことをCMSに通達
*
* @param termsVersion バージョン
* @return 標準的なレスポンス情報
* @throws AcmsException CMSがエラーを返したという例外
* @throws NetworkDisconnectedException ネットワークエラー
*/
public AcmsCommonJSON agreeTerms(String termsVersion) throws AcmsException, NetworkDisconnectedException { public AcmsCommonJSON agreeTerms(String termsVersion) throws AcmsException, NetworkDisconnectedException {
String sid = cache.getMemberInfo().sid; String sid = cache.getMemberInfo().sid;
return AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).agreeTerms(new AgreementToTermsParameters(sid, termsVersion)); return AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).agreeTerms(new AgreementToTermsParameters(sid, termsVersion));
......
...@@ -126,7 +126,6 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity { ...@@ -126,7 +126,6 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
if (!(this instanceof LoginActivity)) { if (!(this instanceof LoginActivity)) {
finish(); finish();
} }
LoginActivity.finishPendingActivity();
Intent intent = new Intent(); Intent intent = new Intent();
getApplicationContext().sendBroadcast(intent); getApplicationContext().sendBroadcast(intent);
} }
...@@ -416,7 +415,6 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity { ...@@ -416,7 +415,6 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
return; return;
} }
// 必要に応じて、規約同意画面を表示 // 必要に応じて、規約同意画面を表示
AgreementToTermsActivity.clearVersion(this); // for debug!
AgreementToTermsActivity.PreAgreementListener listener = new AgreementToTermsActivity.PreAgreementListener() { AgreementToTermsActivity.PreAgreementListener listener = new AgreementToTermsActivity.PreAgreementListener() {
@Override @Override
public void onDisabled() { public void onDisabled() {
...@@ -508,7 +506,6 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity { ...@@ -508,7 +506,6 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
if (! (this instanceof LoginActivity)) { if (! (this instanceof LoginActivity)) {
finish(); finish();
} }
LoginActivity.finishPendingActivity();
} }
/** /**
......
...@@ -15,8 +15,17 @@ import jp.agentec.abook.abv.ui.common.util.ABVToastUtil; ...@@ -15,8 +15,17 @@ import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.abook.abv.ui.home.activity.ABookSettingActivity; import jp.agentec.abook.abv.ui.home.activity.ABookSettingActivity;
import jp.agentec.abook.abv.ui.home.activity.LoginActivity; import jp.agentec.abook.abv.ui.home.activity.LoginActivity;
/**
* ログアウトする時に使用するヘルパークラス
* 複数個所で、ログアウトする契機があるので、まとめた。
*/
public class LogoutHelper { public class LogoutHelper {
/**
* ログアウトして、ログイン画面に遷移する
*
* @param activity 呼び出し元アクティビティ
*/
public static void logout(Activity activity) { public static void logout(Activity activity) {
try { try {
// modify by Jang 2013.06.20 // modify by Jang 2013.06.20
......
...@@ -96,6 +96,10 @@ public class AlertDialogUtil { ...@@ -96,6 +96,10 @@ public class AlertDialogUtil {
alertDialog.show(); alertDialog.show();
} }
public static void showAlertDialog(Context context, int title, int message) {
showAlertDialog(context, title, message, true, null);
}
public static ABookAlertDialog deleteContentAlertDialog(Context context, int deleteMessage) { public static ABookAlertDialog deleteContentAlertDialog(Context context, int deleteMessage) {
ABookAlertDialog alertDialog = createAlertDialog(context, R.string.delete); ABookAlertDialog alertDialog = createAlertDialog(context, R.string.delete);
alertDialog.setMessage(deleteMessage); alertDialog.setMessage(deleteMessage);
......
...@@ -22,14 +22,28 @@ import jp.agentec.abook.abv.ui.common.activity.ABVActivity; ...@@ -22,14 +22,28 @@ import jp.agentec.abook.abv.ui.common.activity.ABVActivity;
import jp.agentec.abook.abv.ui.common.activity.ABVUIActivity; import jp.agentec.abook.abv.ui.common.activity.ABVUIActivity;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil; import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
/**
* 規約同意画面
* AgreementToTermsActivity.confirmAgreement()メソッドを実行すると、
* 規約同意画面を表示する必要があるかを判別して、必要な場合のみ表示する。
* 規約に同意したか同意しなかったかは、onActivityResult()でresultCodeがRESULT_OKなら同意、
* RESULT_CANCELEDだったら同意しないと判別する
*/
public class AgreementToTermsActivity extends ABVUIActivity { public class AgreementToTermsActivity extends ABVUIActivity {
private static final String TAG = "AgreementToTermsActivity"; private static final String TAG = "AgreementToTermsActivity";
private String currentVersion = ""; private String currentVersion = "";
/**
* 規約同意画面を表示しなかった(あるいはできなかった)場合の処理を指定するリスナー
*/
public interface PreAgreementListener { public interface PreAgreementListener {
// 規約同意オプションがNoだった
void onDisabled(); void onDisabled();
// 規約内容やバージョンが空だった
void onEmpty(); void onEmpty();
// すでに同意済みだった
void onAgreed(); void onAgreed();
// 規約情報の取得に失敗した
void onFailed(Exception e); void onFailed(Exception e);
} }
...@@ -79,7 +93,9 @@ public class AgreementToTermsActivity extends ABVUIActivity { ...@@ -79,7 +93,9 @@ public class AgreementToTermsActivity extends ABVUIActivity {
} }
} }
// 同意する /**
* 同意するをタップしたときの処理
*/
private void agree() { private void agree() {
showProgressPopup(); showProgressPopup();
CommonExecutor.execute(new Runnable() { CommonExecutor.execute(new Runnable() {
...@@ -110,7 +126,7 @@ public class AgreementToTermsActivity extends ABVUIActivity { ...@@ -110,7 +126,7 @@ public class AgreementToTermsActivity extends ABVUIActivity {
} else { } else {
messageId = R.string.failed_to_send_agreement; messageId = R.string.failed_to_send_agreement;
} }
AlertDialogUtil.showAlertDialog(AgreementToTermsActivity.this, R.string.app_name, messageId, true, null); AlertDialogUtil.showAlertDialog(AgreementToTermsActivity.this, R.string.app_name, messageId);
} }
}); });
} finally { } finally {
...@@ -120,7 +136,9 @@ public class AgreementToTermsActivity extends ABVUIActivity { ...@@ -120,7 +136,9 @@ public class AgreementToTermsActivity extends ABVUIActivity {
}); });
} }
// 同意しない /**
* 同意しないをタップしたときの処理
*/
private void disagree() { private void disagree() {
// 確認ダイアログ // 確認ダイアログ
AlertDialogUtil.showAlertDialog(this, R.string.app_name, R.string.logout_by_disagree, false, AlertDialogUtil.showAlertDialog(this, R.string.app_name, R.string.logout_by_disagree, false,
...@@ -175,11 +193,21 @@ public class AgreementToTermsActivity extends ABVUIActivity { ...@@ -175,11 +193,21 @@ public class AgreementToTermsActivity extends ABVUIActivity {
intent.putExtra(ABookKeys.AGREEMENT_TO_TERMS_VERSION, json.getTermsVersion()); intent.putExtra(ABookKeys.AGREEMENT_TO_TERMS_VERSION, json.getTermsVersion());
intent.putExtra(ABookKeys.AGREEMENT_TO_TERMS, json.getTerms()); intent.putExtra(ABookKeys.AGREEMENT_TO_TERMS, json.getTerms());
context.startActivityForResult(intent, requestCode); context.startActivityForResult(intent, requestCode);
} catch (Exception e) { } catch (final Exception e) {
Logger.e(TAG, e); Logger.e(TAG, e);
listener.onFailed(e); context.runOnUiThread(new Runnable() {
@Override
public void run() {
listener.onFailed(e);
}
});
} finally { } finally {
context.closeProgressPopup(); context.runOnUiThread(new Runnable() {
@Override
public void run() {
context.closeProgressPopup();
}
});
} }
} }
}); });
...@@ -204,13 +232,4 @@ public class AgreementToTermsActivity extends ABVUIActivity { ...@@ -204,13 +232,4 @@ public class AgreementToTermsActivity extends ABVUIActivity {
private static void setLatestVersion(Context context, String version) { private static void setLatestVersion(Context context, String version) {
PreferenceUtil.putUserPref(context, ABookKeys.AGREEMENT_TO_TERMS_VERSION, version); PreferenceUtil.putUserPref(context, ABookKeys.AGREEMENT_TO_TERMS_VERSION, version);
} }
/**
* 規約同意バージョンをクリア(動作確認時に使用するために残しておく)
*
* @param context
*/
public static void clearVersion(Context context) {
PreferenceUtil.removeUserPref(context, ABookKeys.AGREEMENT_TO_TERMS_VERSION);
}
} }
...@@ -38,12 +38,16 @@ app_versioncode=1 ...@@ -38,12 +38,16 @@ app_versioncode=1
# abvEnvironments.xml # abvEnvironments.xml
#cms server #cms server
acms_address=https://chatdev2.agentec.jp/acms #acms_address=https://chatdev2.agentec.jp/acms
download_server_address=https://chatdev2.agentec.jp/acms #download_server_address=https://chatdev2.agentec.jp/acms
acms_address=https://check130.abook.bz/acms
download_server_address=https://check130.abook.bz/acms
#syncview server #syncview server
websocket_server_http_url=https://check130.agentec.jp/v1 #websocket_server_http_url=https://check130.agentec.jp/v1
websocket_server_ws_url=wss://check130.agentec.jp/v1 #websocket_server_ws_url=wss://check130.agentec.jp/v1
websocket_server_http_url=https://check130.abook.bz:10443/v1
websocket_server_ws_url=wss://check130.abook.bz:10443/v1
#WebSocket debug出力 #WebSocket debug出力
websocket_debug=false websocket_debug=false
......
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