Commit d926d9a1 by NGUYEN HOANG SON

implement agrement to terms dialog

parent 6d13a6be
......@@ -180,5 +180,7 @@ public interface ServiceOption {
* 利用しない:N(通常)、利用する:Y
*/
int AlcoholCheckerHw = 202;
int AgrementToTerms = 203;
}
}
\ No newline at end of file
......@@ -375,6 +375,10 @@ public class ABVDataCache {
}
return false;
}
public boolean isAgrementToTerms() {
return isServiceOptionEnable(ServiceOptionId.AgrementToTerms);
}
}
public void setDiffMinFromUTC(String timeZone) {
......
......@@ -11,12 +11,13 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.RequireTermsParameters;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.data.ABVDataCache;
public class AgreementToTermsLogic extends AbstractLogic{
private static final String TAG = "AgreementToTermsLogic";
public boolean isTermsEnabled() {
return false;
return ABVDataCache.getInstance().serviceOption.isAgrementToTerms();
}
public RequireTermsJSON requireTerms() throws IOException, AcmsException, NetworkDisconnectedException {
......
......@@ -30,6 +30,8 @@ import java.util.UUID;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsMessageJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AgreeTermsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.RequireTermsJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AppLastVersionParameters;
import jp.agentec.abook.abv.bl.acms.type.AcmsApis;
import jp.agentec.abook.abv.bl.acms.type.AuthLevel;
......@@ -45,6 +47,7 @@ import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.AgreementToTermsLogic;
import jp.agentec.abook.abv.bl.logic.UserAuthenticateLogic;
import jp.agentec.abook.abv.cl.environment.NetworkAdapter;
import jp.agentec.abook.abv.cl.push.FcmManager;
......@@ -101,6 +104,92 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
Intent intent = new Intent();
getApplicationContext().sendBroadcast(intent);
}
protected void loginDidFinish(String loginId) {
checkTerms(loginId);
}
protected void checkTerms(final String loginId) {
AgreementToTermsLogic termsLogic = AbstractLogic.getLogic(AgreementToTermsLogic.class);
if (!termsLogic.isTermsEnabled()) {
checkTermsDidFinish(loginId);
}
requireTerms(loginId);
}
private void requireTerms(final String loginId) {
showProgressPopup();
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
try {
AgreementToTermsLogic termsLogic = AbstractLogic.getLogic(AgreementToTermsLogic.class);
final RequireTermsJSON json = termsLogic.requireTerms();
if (json != null && json.termsId > 0 && json.termsVersion != null) {
runOnUiThread(new Runnable() {
@Override
public void run() {
closeProgressPopup();
showTerms(json, loginId);
}
});
return;
}
} catch (Exception e) {
ABVToastUtil.showMakeText(mContext, e.getMessage(), Toast.LENGTH_SHORT);
}
closeProgressPopup();
checkTermsDidFinish(loginId);
}
});
}
private void showTerms(final RequireTermsJSON json, final String loginId) {
Logger.d(TAG, "showTerms:%@", json.toString());
ABookAlertDialog messageDialog = AlertDialogUtil.createAlertDialog(mContext, R.string.app_name);
messageDialog.setTitle(json.termsVersion);
messageDialog.setMessage(json.agreement);
messageDialog.setPositiveButton(R.string.confirm, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
agreeTerms(json, loginId);
}
});
messageDialog.setCancelable(false);
messageDialog.setNegativeButton(R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
messageDialog.show();
messageDialog.setMessageViewScrollable(true);
}
private void agreeTerms(final RequireTermsJSON termsJson, final String loginId) {
showProgressPopup();
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
AgreementToTermsLogic termsLogic = AbstractLogic.getLogic(AgreementToTermsLogic.class);
try {
AgreeTermsJSON json = termsLogic.agreeTerms(termsJson.termsId, termsJson.termsVersion);
if (json != null && json.httpStatus == 200) {
closeProgressPopup();
checkTermsDidFinish(loginId);
return;
}
} catch (Exception e) {
ABVToastUtil.showMakeText(mContext, e.getMessage(), Toast.LENGTH_SHORT);
}
closeProgressPopup();
}
});
}
private void checkTermsDidFinish(String loginId) {
showMainActivity(loginId);
}
// ログインなしの場合専用
protected void noAuthenticatedLogin(final boolean isGuestLogin, final String urlPath) {
......
......@@ -5,6 +5,7 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.text.method.ScrollingMovementMethod;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
......@@ -77,4 +78,20 @@ public class ABookAlertDialog extends AlertDialog {
setView(listView);
listView.setOnItemClickListener(l);
}
public void setMessageViewScrollable(boolean enabled) {
if (messageView == null) {
return;
}
TextView textView = (TextView) messageView.findViewById(R.id.main_text);
if (textView == null) {
return;
}
if (enabled) {
textView.setVerticalScrollBarEnabled(true);
textView.setMovementMethod(new ScrollingMovementMethod());
} else {
//default none scroll
}
}
}
......@@ -630,7 +630,7 @@ public class LoginActivity extends ABVLoginActivity {
if (changePasswordType == RequirePasswordChangeType.NONE) {
// パスワード変更が必要ない場合、メイン画面表示
showMainActivity(mLoginId);
loginDidFinish(mLoginId);
} else {
// パスワード変更が必要な場合、アラート表示
showChangePasswordDialog(changePasswordType);
......@@ -670,7 +670,7 @@ public class LoginActivity extends ABVLoginActivity {
public void onClick(DialogInterface dialog, int whichButton) {
if (rpccType == RequirePasswordChangeType.NEWLOGIN_REMINDER || rpccType == RequirePasswordChangeType.REMINDER) {
// 催促の場合、キャンセルが押されたらメイン画面表示
showMainActivity(mLoginId);
loginDidFinish(mLoginId);
}
}
});
......
......@@ -85,7 +85,7 @@ public class LoginPasswordChangeActivity extends ABVNoAuthenticatedActivity {
public void onClick(View v) {
if (mType == 1 || mType == 2) {
// 催促
showMainActivity(mLoginId);
loginDidFinish(mLoginId);
finish();
} else {
finishActivity();
......@@ -176,7 +176,7 @@ public class LoginPasswordChangeActivity extends ABVNoAuthenticatedActivity {
ABVToastUtil.showMakeText(LoginPasswordChangeActivity.this, getString(R.string.change_password_ok), Toast.LENGTH_LONG);
showMainActivity(mLoginId);
loginDidFinish(mLoginId);
finish();
} catch (NetworkDisconnectedException e) {
Logger.e("NetworkDisconnectedException", e);
......
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