Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
7371d7a2
Commit
7371d7a2
authored
May 18, 2023
by
Kazuyuki Hida
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
レビューの指摘事項(非同期通信除く)を修正
parent
f6cc3315
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
53 deletions
+71
-53
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
+4
-6
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/AgreementToTermsActivity.java
+67
-47
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
View file @
7371d7a2
...
...
@@ -65,9 +65,8 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
private
static
final
int
REQUEST_AGREEMENT
=
120391
;
// ユニークで適当な値
private
static
final
int
REQUEST_AGREEMENT_FROM_LOGIN
=
120392
;
// ユニークで適当な値
private
AgreementToTermsActivity
.
Result
confirmResult
;
private
Context
mContext
=
ABVNoAuthenticatedActivity
.
this
;
private
final
Context
mContext
=
ABVNoAuthenticatedActivity
.
this
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -92,7 +91,7 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
*/
protected
void
showMainActivity
(
String
loginId
)
{
confirmResult
=
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT_FROM_LOGIN
,
isNormalSize
(),
new
Runnable
()
{
AgreementToTermsActivity
.
Result
confirmResult
=
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT_FROM_LOGIN
,
isNormalSize
(),
new
Runnable
()
{
@Override
public
void
run
()
{
LogoutHelper
.
logout
(
ABVNoAuthenticatedActivity
.
this
);
...
...
@@ -408,7 +407,8 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
return
;
}
// 必要に応じて、規約同意画面を表示
confirmResult
=
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT
,
isNormalSize
(),
null
);
AgreementToTermsActivity
.
clearVersion
(
this
);
// for debug!
AgreementToTermsActivity
.
Result
confirmResult
=
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT
,
isNormalSize
(),
null
);
switch
(
confirmResult
)
{
case
DISABLE:
case
EMPTY:
...
...
@@ -433,7 +433,6 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
if
(
requestCode
==
REQUEST_AGREEMENT
)
{
if
(
resultCode
==
RESULT_OK
)
{
// 同意したら初期化
confirmResult
=
AgreementToTermsActivity
.
Result
.
AGREED
;
doMoveToHome
();
}
else
{
// 規約に同意しなかったので、ログアウト
...
...
@@ -444,7 +443,6 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
if
(
requestCode
==
REQUEST_AGREEMENT_FROM_LOGIN
)
{
if
(
resultCode
==
RESULT_OK
)
{
// 同意したら初期化
confirmResult
=
AgreementToTermsActivity
.
Result
.
AGREED
;
doShowMainActivity
();
}
else
{
// 規約に同意しなかったので、ログアウト
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/AgreementToTermsActivity.java
View file @
7371d7a2
...
...
@@ -12,6 +12,7 @@ import androidx.annotation.NonNull;
import
androidx.annotation.Nullable
;
import
jp.agentec.abook.abv.bl.acms.client.json.AgreementToTermsJSON
;
import
jp.agentec.abook.abv.bl.common.CommonExecutor
;
import
jp.agentec.abook.abv.bl.common.constant.ABookKeys
;
import
jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
...
...
@@ -22,7 +23,6 @@ import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import
jp.agentec.abook.abv.launcher.android.R
;
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.dialog.ABookAlertDialog
;
import
jp.agentec.abook.abv.ui.common.util.AlertDialogUtil
;
public
class
AgreementToTermsActivity
extends
ABVUIActivity
{
...
...
@@ -85,48 +85,58 @@ public class AgreementToTermsActivity extends ABVUIActivity {
// 同意する
private
void
agree
()
{
try
{
// 同意したことをCMSに送信
AgreementToTermsLogic
logic
=
AbstractLogic
.
getLogic
(
AgreementToTermsLogic
.
class
);
logic
.
agreeTerms
(
currentVersion
);
// 同意したバージョンを保存して閉じる
setLatestVersion
(
AgreementToTermsActivity
.
this
,
currentVersion
);
setResult
(
RESULT_OK
);
finish
();
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
// 失敗したらアラート表示
ABookAlertDialog
dialog
=
AlertDialogUtil
.
createAlertDialog
(
this
,
R
.
string
.
app_name
);
if
(
e
instanceof
NetworkDisconnectedException
)
{
dialog
.
setMessage
(
R
.
string
.
msg_network_offline
);
}
else
{
dialog
.
setMessage
(
R
.
string
.
failed_to_send_agreement
);
showProgressPopup
();
CommonExecutor
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
// 同意したことをCMSに送信
AgreementToTermsLogic
logic
=
AbstractLogic
.
getLogic
(
AgreementToTermsLogic
.
class
);
logic
.
agreeTerms
(
currentVersion
);
// 同意したバージョンを保存して閉じる
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
setLatestVersion
(
AgreementToTermsActivity
.
this
,
currentVersion
);
setResult
(
RESULT_OK
);
finish
();
}
});
}
catch
(
final
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
// 失敗したらアラート表示
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
int
messageId
;
if
(
e
instanceof
NetworkDisconnectedException
)
{
messageId
=
R
.
string
.
msg_network_offline
;
}
else
{
messageId
=
R
.
string
.
failed_to_send_agreement
;
}
AlertDialogUtil
.
showAlertDialog
(
AgreementToTermsActivity
.
this
,
R
.
string
.
app_name
,
messageId
,
true
,
null
);
}
});
}
finally
{
closeProgressPopup
();
}
}
dialog
.
setPositiveButton
(
R
.
string
.
close
,
null
);
showAlertDialog
(
dialog
);
}
});
}
// 同意しない
private
void
disagree
()
{
// 確認ダイアログ
ABookAlertDialog
dialog
=
AlertDialogUtil
.
createAlertDialog
(
this
,
R
.
string
.
app_name
);
dialog
.
setMessage
(
R
.
string
.
logout_by_disagree
);
dialog
.
setPositiveButton
(
R
.
string
.
ok
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
// ログアウトしてよし
setResult
(
RESULT_CANCELED
);
finish
();
}
});
dialog
.
setNegativeButton
(
R
.
string
.
cancel
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
// アラートを閉じるだけ
}
});
showAlertDialog
(
dialog
);
AlertDialogUtil
.
showAlertDialog
(
this
,
R
.
string
.
app_name
,
R
.
string
.
logout_by_disagree
,
false
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
// ログアウトしてよし
setResult
(
RESULT_CANCELED
);
finish
();
}
}
);
}
/**
...
...
@@ -140,7 +150,7 @@ public class AgreementToTermsActivity extends ABVUIActivity {
* @param isNormalSize 端末サイズ指定(スマホならtrue)
* @param onFailed 規約情報の取得に失敗したときの処理
*/
public
static
Result
confirmAgreement
(
ABVActivity
context
,
int
requestCode
,
boolean
isNormalSize
,
@Nullable
final
Runnable
onFailed
)
{
public
static
Result
confirmAgreement
(
final
ABVActivity
context
,
int
requestCode
,
boolean
isNormalSize
,
@Nullable
final
Runnable
onFailed
)
{
if
(!
ABVDataCache
.
getInstance
().
serviceOption
.
isUsableAgreementToTerms
())
{
// 規約同意オプションが無効な場合、何もしない
return
Result
.
DISABLE
;
...
...
@@ -148,7 +158,6 @@ public class AgreementToTermsActivity extends ABVUIActivity {
try
{
context
.
showProgressPopup
();
AgreementToTermsLogic
logic
=
AbstractLogic
.
getLogic
(
AgreementToTermsLogic
.
class
);
AgreementToTermsJSON
json
=
logic
.
getTerms
();
if
(
json
.
getTerms
().
isEmpty
()
||
json
.
getTermsVersion
().
isEmpty
())
{
...
...
@@ -176,23 +185,38 @@ public class AgreementToTermsActivity extends ABVUIActivity {
}
}
/**
* 規約内容の読み込みに失敗したときは、それを伝えるアラートを出してから、失敗時の処理を行う
*
* @param context アラートを生成するためのコンテキスト
* @param onFailed 失敗時の処理
*/
private
static
void
failed
(
Context
context
,
@NonNull
final
Runnable
onFailed
)
{
ABookAlertDialog
dialog
=
AlertDialogUtil
.
createAlertDialog
(
context
,
R
.
string
.
app_name
);
dialog
.
setMessage
(
R
.
string
.
failed_to_get_terms_of_service
);
dialog
.
setPositiveButton
(
R
.
string
.
close
,
new
DialogInterface
.
OnClickListener
()
{
AlertDialogUtil
.
showAlertDialog
(
context
,
R
.
string
.
app_name
,
R
.
string
.
failed_to_get_terms_of_service
,
true
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
// ログイン直後の場合失敗したら、ログアウトする仕様なので、それをonFailedを通して実行
onFailed
.
run
();
}
});
dialog
.
show
();
}
/**
* 直近の同意した規約のバージョンを返すメソッド
*
* @param context SharedPreferenceにアクセスするためのコンテキスト
* @return バージョン文字列
*/
private
static
String
getLatestVersion
(
Context
context
)
{
return
PreferenceUtil
.
getUserPref
(
context
,
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
,
""
);
}
/**
* 直近の同意した規約のバージョンを保存するメソッド
*
* @param context SharedPreferenceにアクセスするためのコンテキスト
* @param version バージョン文字列
*/
private
static
void
setLatestVersion
(
Context
context
,
String
version
)
{
PreferenceUtil
.
putUserPref
(
context
,
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
,
version
);
}
...
...
@@ -200,8 +224,4 @@ public class AgreementToTermsActivity extends ABVUIActivity {
public
static
void
clearVersion
(
Context
context
)
{
PreferenceUtil
.
removeUserPref
(
context
,
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
);
}
public
static
boolean
isFirstAgreement
(
Context
context
)
{
return
PreferenceUtil
.
getUserPref
(
context
,
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
,
""
).
isEmpty
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment