Commit 7917561a by Kazuyuki Hida

Merge branch 'features/1.4.500_53088_agreement_to_terms' into 'features/1.4.500'

規約同意画面を追加

See merge request !316
parents 17000bea f732d5a6
......@@ -15,6 +15,7 @@ import java.util.Observer;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsBooleanResultJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsCommonJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsMessageJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AgreementToTermsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ApertureMasterDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AppLatestVersionJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ArchiveDetailJSON;
......@@ -54,6 +55,7 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.AbstractAcmsLoginParameter
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsContentParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AddMemberGroupParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AgreementToTermsParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AppStoreNewLoginParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.ArchiveDetailRequestParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.ArchiveRequestParameters;
......@@ -1112,6 +1114,36 @@ public class AcmsClient implements AcmsClientResponseListener {
return new TermsOfUseJson(response.httpResponseBody);
}
/**
* 規約情報の取得
*
* @param sid セッションID
* @return
* @throws AcmsException CMSがエラーを返した時の例外
* @throws NetworkDisconnectedException ネットワークエラー
*/
public AgreementToTermsJSON getTerms(String sid) throws AcmsException, NetworkDisconnectedException {
HttpResponse response = send(AcmsApis.ApiGetTerms, new AcmsParameters(sid));
AgreementToTermsJSON json = new AgreementToTermsJSON(response.httpResponseBody);
return json;
}
/**
* 規約に同意したことをCMSに通達
*
* @param params パラメータ
* @return 標準的なレスポンス
* @throws AcmsException CMSがエラーを返した時の例外
* @throws NetworkDisconnectedException ネットワークエラー
*/
public AcmsCommonJSON agreeTerms(AgreementToTermsParameters params) throws AcmsException, NetworkDisconnectedException {
HttpResponse response = send(AcmsApis.ApiAgreeTerms, params);
AcmsCommonJSON json = new AcmsCommonJSON(response.httpResponseBody);
return json;
}
/**********************************************************************************************/
/** 以下、共用メソッド---------------------------------------------------------------------- **/
/**********************************************************************************************/
......
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONException;
import org.json.adf.JSONObject;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
/**
* 規約同意のAPIで使うレスポンス
*/
public class AgreementToTermsJSON extends AcmsCommonJSON {
private static final String TERMS_VERSION = "termsVersion";
private static final String TERMS = "terms";
private String termsVersion;
private String terms;
public AgreementToTermsJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException, JSONException {
super.parse(json);
termsVersion = json.has(TERMS_VERSION) ? json.getString(TERMS_VERSION) : "";
terms = json.has(TERMS) ? json.getString(TERMS) : "";
}
/**
* @return 規約のバージョン
*/
public String getTermsVersion() {
return termsVersion;
}
/**
* @return 規約の内容
*/
public String getTerms() {
return terms;
}
}
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject;
/**
* 規約同意時に使用するパラメータ
*/
public class AgreementToTermsParameters extends HttpParameterObject {
private final String sid;
private final String termsVersion;
/**
* @param sid セッションID
* @param termsVersion 同意した規約のバージョン
*/
public AgreementToTermsParameters(String sid, String termsVersion) {
super();
this.sid = sid;
this.termsVersion = termsVersion;
}
/**
* @return セッションID
*/
public String getSid() {
return sid;
}
/**
* @return 同意した規約のバージョン
*/
public String getTermsVersion() {
return termsVersion;
}
}
......@@ -177,6 +177,10 @@ public class AcmsApis {
public static final String ApigetArchive = "archive";
public static final String ApigetCollaboration = "collaboration";
// 規約同意
public static final String ApiGetTerms = "getTerms";
public static final String ApiAgreeTerms = "agreeTerms";
public static final class UserCmds {
public static final String inviteUsers = "3";
public static final String getMyInfo = "9";
......
......@@ -180,5 +180,10 @@ public interface ServiceOption {
* 利用しない:N(通常)、利用する:Y
*/
int AlcoholCheckerHw = 202;
/**
* 規約同意
*/
int agrementToTerms = 203;
}
}
\ No newline at end of file
......@@ -246,6 +246,9 @@ public class ABookKeys {
public static final String TASK_DEVICE_TYPE = "deviceType"; // CMSのインターフェースのパラメータ:devicetype
public static final String TASK_QUESTION_ID = "qid"; // CMSのインターフェースのパラメータ:qid
public static final String AGREEMENT_TO_TERMS_VERSION = "termsVersion";
public static final String AGREEMENT_TO_TERMS = "terms";
public static final String JSON_NAME = "jsonName";
public static final String JSON_DATA = "jsonData";
public static final String PUSH_MESSAGE_ID = "pushMessageId";
......
......@@ -352,6 +352,13 @@ public class ABVDataCache {
}
/**
* @return 規約同意オプションがYならtrue
*/
public boolean isUsableAgreementToTerms() {
return isServiceOptionEnable(ServiceOptionId.agrementToTerms);
}
/**
* @version 1.2.300
* サービスオプション(ユーザパスワードソルト付加)返す
* @return true:利用する, false:利用しない
......
package jp.agentec.abook.abv.bl.logic;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsCommonJSON;
import jp.agentec.abook.abv.bl.acms.client.json.AgreementToTermsJSON;
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.NetworkDisconnectedException;
/**
* 規約同意の入出力
*/
public class AgreementToTermsLogic extends AbstractLogic {
private static final String TAG = "AgreementToTermsLogic";
/**
* 規約情報の取得
*
* @return 規約情報
* @throws AcmsException CMSがエラーを返したという例外
* @throws NetworkDisconnectedException ネットワークエラー
*/
public AgreementToTermsJSON getTerms() throws AcmsException, NetworkDisconnectedException {
String sid = cache.getMemberInfo().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 {
String sid = cache.getMemberInfo().sid;
return AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).agreeTerms(new AgreementToTermsParameters(sid, termsVersion));
}
}
......@@ -1548,4 +1548,9 @@
<string name="msg_ble_connect_success">%1$sと接続になりました。%1$sを操作してください。</string>
<string name="select_spp_device_title">シリアル通信機器選択</string>
<string name="msg_get_device_token_fail">プッシュ通知サービスに必要なデバイストークンの取得に失敗しました。\nGooglePlayServiceアプリがインストールされているか確認してください。</string>
<string name="terms_of_service">利用規約</string>
<string name="failed_to_get_terms_of_service">利用規約の取得に失敗しました。</string>
<string name="logout_by_disagree">ログアウトされ、ログイン画面に遷移します。よろしいでしょうか?</string>
<string name="failed_to_send_agreement">利用規約同意情報をサーバへ送信失敗しました。\nもう一度、同意ボタンをタップしてください。</string>
</resources>
......@@ -1545,4 +1545,9 @@
<string name="pairing_search_scan">주사</string>
<string name="pairing_search_stop">멈추다</string>
<string name="msg_get_device_token_fail">알림 서비스에 필요한 단말기 토큰을 취득하지 못했습니다. \nGooglePlayService가 인스톨 되어있는지 확인해 주세요.</string>
<string name="terms_of_service">이용규약</string>
<string name="failed_to_get_terms_of_service">이용규약 정보 취득에 실패하였습니다.</string>
<string name="logout_by_disagree">로그 아웃되어 로그인 화면으로 이동합니다. 실행 하시겠습니까?</string>
<string name="failed_to_send_agreement">이용 규약 동의 정보를 서버에 전송 실패하였습니다. 다시 한번 동의 버튼을 눌러주세요.</string>
</resources>
\ No newline at end of file
......@@ -1548,4 +1548,9 @@
<string name="msg_ble_connect_success">It is now connected to the %1$s.Operate the %1$s.</string>
<string name="select_spp_device_title">Serial communication device selection</string>
<string name="msg_get_device_token_fail">Failed to acquire the device token required for the push notification service. \nCheck if the GooglePlayService app is installed.</string>
<string name="terms_of_service">Terms of Service</string>
<string name="failed_to_get_terms_of_service">Failed to get the terms of service information.</string>
<string name="logout_by_disagree">Log out and transition to the login screen. Are you okay?</string>
<string name="failed_to_send_agreement">Failed to send information about agreeing to the Terms of Service to the server. Please tap \"Agree\" again.</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/basic_white1"
>
<!-- 規約 -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
tools:ignore="UselessParent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
>
<TextView
android:id="@+id/textVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:textColor="@color/dialog_text_color"
android:textSize="16sp"
android:lineSpacingMultiplier="1.2"
/>
<TextView
android:id="@+id/textTerms"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/dialog_text_color"
android:textSize="18sp"
android:lineSpacingMultiplier="1.2"
/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#ff999999"
android:padding="8dp"
>
<Button
android:id="@+id/agreeButton"
style="@style/ButtonABookDark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/agree"/>
<Button
android:id="@+id/disagreeButton"
style="@style/ButtonABookDark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/disagree" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
package jp.agentec.abook.abv.ui.common.activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.app.DownloadManager.Request;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
......@@ -23,18 +20,12 @@ import android.widget.ImageView;
import android.widget.Toast;
import java.io.File;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
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.parameters.AppLastVersionParameters;
import jp.agentec.abook.abv.bl.acms.type.AcmsApis;
import jp.agentec.abook.abv.bl.acms.type.AuthLevel;
import jp.agentec.abook.abv.bl.acms.type.LoginMode;
import jp.agentec.abook.abv.bl.acms.type.ServiceOption.ServiceOptionId;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Callback;
import jp.agentec.abook.abv.bl.common.CommonExecutor;
......@@ -58,6 +49,8 @@ import jp.agentec.abook.abv.ui.common.constant.ErrorMessage;
import jp.agentec.abook.abv.ui.common.constant.NaviConsts;
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.AgreementToTermsHelper;
import jp.agentec.abook.abv.ui.common.helper.LogoutHelper;
import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.home.activity.LoginActivity;
......@@ -65,13 +58,12 @@ import jp.agentec.abook.abv.ui.home.activity.OperationListActivity;
import jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.FileUtil;
import jp.agentec.adf.util.StringUtil;
public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
private static final String TAG = "ABVNoAuthenticatedActivity";
private Context mContext = ABVNoAuthenticatedActivity.this;
private final Context mContext = ABVNoAuthenticatedActivity.this;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -94,8 +86,59 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
*
* @param loginId
*/
protected void showMainActivity(String loginId) {
AgreementToTermsHelper.AgreementListener listener = new AgreementToTermsHelper.AgreementListener() {
@Override
public void onDisabled() {
onAgreed();
}
@Override
public void onEmpty() {
onAgreed();
}
@Override
public void onAgreed() {
// 規約同意画面が開かれなかったら、次に進む
doShowMainActivity();
}
@Override
public void onConfirmed(boolean isAgreed) {
if (isAgreed) {
// 同意したら初期化
doShowMainActivity();
} else {
// 規約に同意しなかったので、ログアウト
LogoutHelper.logout(ABVNoAuthenticatedActivity.this);
}
}
@Override
public void onError(Exception e) {
logoutAlert(R.string.C_E_SYSTEM_0001);
}
@Override
public void onFailed(Exception e) {
// 読み込みに失敗したらログアウト
logoutAlert(R.string.failed_to_get_terms_of_service);
}
private void logoutAlert(int messageRes) {
AlertDialogUtil.showAlertDialog(ABVNoAuthenticatedActivity.this, R.string.app_name, messageRes, true, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
LogoutHelper.logout(ABVNoAuthenticatedActivity.this);
}
});
}
};
AgreementToTermsHelper.confirmAgreement(this, isNormalSize(), listener);
}
protected void doShowMainActivity() {
startActivity(new Intent().setClassName(getApplicationContext().getPackageName(), getMainActivityClassName()).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP), NaviConsts.Right);
finish();
Intent intent = new Intent();
......@@ -322,8 +365,6 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
}
}
/**
* 1日1回のバージョンチェックを行う
* @return true チェックを行う false 行わない
......@@ -380,7 +421,59 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
}
protected void moveToHome() {
try {
// カスタムURI起動の場合は、規約同意は無視
final Uri data = getIntent().getData();
if (data != null && data.getScheme() != null && data.getScheme().equals(getString(R.string.scheme_url))) {
doMoveToHome();
return;
}
// 必要に応じて、規約同意画面を表示
AgreementToTermsHelper.AgreementListener listener = new AgreementToTermsHelper.AgreementListener() {
@Override
public void onDisabled() {
onAgreed();
}
@Override
public void onEmpty() {
onAgreed();
}
@Override
public void onAgreed() {
// 規約同意画面が開かれなかったら、次に進む
doMoveToHome();
}
@Override
public void onConfirmed(boolean isAgreed) {
if (isAgreed) {
// 同意したら初期化
doMoveToHome();
} else {
// 規約に同意しなかったので、ログアウト
LogoutHelper.logout(ABVNoAuthenticatedActivity.this);
}
}
@Override
public void onError(Exception e) {
// 失敗しても、次に進む
Logger.e(TAG, e);
doMoveToHome();
}
@Override
public void onFailed(Exception e) {
// 読み込みに失敗しても、次に進む
Logger.e(TAG, e);
doMoveToHome();
}
};
AgreementToTermsHelper.confirmAgreement(this, isNormalSize(), listener);
}
private void doMoveToHome() {
Bundle extras = getIntent().getExtras();
Intent intent = new Intent();
if (extras != null && !StringUtil.isNullOrEmpty(extras.getString(AppDefType.PushMessageKey.data))) {
......@@ -417,13 +510,6 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
}
startActivity(intent);
finish();
} catch (Exception e) {
Logger.e("ABVException Login", e);
Intent intent = new Intent();
intent.setClassName(getApplicationContext().getPackageName(), LoginActivity.class.getName()).setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
finish();
}
}
/**
......
package jp.agentec.abook.abv.ui.common.helper;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.widget.Toast;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.UserAuthenticateLogic;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
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.LoginActivity;
/**
* ログアウトする時に使用するヘルパークラス
* 複数個所で、ログアウトする契機があるので、まとめた。
*/
public class LogoutHelper {
/**
* ログアウトして、ログイン画面に遷移する
*
* @param activity 呼び出し元アクティビティ
*/
public static void logout(Activity activity) {
try {
// modify by Jang 2013.06.20
UserAuthenticateLogic user = AbstractLogic.getLogic(UserAuthenticateLogic.class);
// ログイン情報がある場合のみログアウト処理を行う
if (user.getMemberInfo() != null) {
user.signoutUser();
// Widgetへ通知
Intent intent = new Intent();
activity.sendBroadcast(intent);
}
} catch (Exception e) {
Logger.w("signoutUser failed at callLoginActivity", e);
ABVToastUtil.showMakeText(activity, R.string.ERROR, Toast.LENGTH_SHORT);
}
// 新着更新が実行されている場合停止
if (activity instanceof ABookSettingActivity) {
((ABookSettingActivity)activity).stopContentRefresher();
}
SharedPreferences sharedPreferences = activity.getSharedPreferences(AppDefType.PrefName.USER_PREFERENCE, Context.MODE_PRIVATE);
sharedPreferences.edit().remove(AppDefType.UserPrefKey.GUEST_LOGIN).apply();
Intent intent = new Intent(activity, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
activity.startActivity(intent);
activity.finish();
}
}
......@@ -96,6 +96,10 @@ public class AlertDialogUtil {
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) {
ABookAlertDialog alertDialog = createAlertDialog(context, R.string.delete);
alertDialog.setMessage(deleteMessage);
......
......@@ -56,6 +56,7 @@ import jp.agentec.abook.abv.launcher.android.R;
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.dialog.ABookAlertDialog;
import jp.agentec.abook.abv.ui.common.helper.LogoutHelper;
import jp.agentec.abook.abv.ui.common.helper.ProgressDialogHelper;
import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
......@@ -176,43 +177,13 @@ public class ABookSettingFragment extends PreferenceFragment {
logoutAkert.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.confirm), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
logout();
LogoutHelper.logout(getActivity());
}
});
logoutAkert.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), (DialogInterface.OnClickListener) null);
showAlertDialog(logoutAkert);
}
private void logout() {
try {
// modify by Jang 2013.06.20
UserAuthenticateLogic user = AbstractLogic.getLogic(UserAuthenticateLogic.class);
// ログイン情報がある場合のみログアウト処理を行う
if (user.getMemberInfo() != null) {
user.signoutUser();
// Widgetへ通知
Intent intent = new Intent();
getActivity().sendBroadcast(intent);
}
} catch (Exception e) {
Logger.w("signoutUser failed at callLoginActivity", e);
ABVToastUtil.showMakeText(getActivity(), R.string.ERROR, Toast.LENGTH_SHORT);
}
// 新着更新が実行されている場合停止
((ABookSettingActivity)getActivity()).stopContentRefresher();
SharedPreferences sharedPreferences = getActivity().getSharedPreferences(AppDefType.PrefName.USER_PREFERENCE, Context.MODE_PRIVATE);
sharedPreferences.edit().remove(AppDefType.UserPrefKey.GUEST_LOGIN).commit();
Intent intent = new Intent(getActivity(), LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
getActivity().finish();
}
private void setLogInfoSetting() {
PreferenceGroup logInfo = (PreferenceGroup) findPreference(LOG_INFO);
// ログExport
......
......@@ -86,7 +86,7 @@ is_check_invalid_passward_limit=true
repeat_default=true
#Setting Info(設定画面のABookについての設定情報)
version_name=1.4.413
version_name=1.4.500
release_date=2023/04/25
copy_right=2016 AGENTEC Co.,Ltd. All rights reserved.
hope_page=http://www.agentec.jp
......
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