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
7eb4d96d
Commit
7eb4d96d
authored
May 23, 2023
by
Kazuyuki Hida
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
動作するようになったので、いったんコミット
parent
89703410
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
200 additions
and
62 deletions
+200
-62
ABVJE_UI_Android/res/layout/dlg_agreement_to_terms.xml
+23
-1
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
+44
-5
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/helper/AgreementToTermsHelper.java
+133
-56
No files found.
ABVJE_UI_Android/res/layout/dlg_agreement_to_terms.xml
View file @
7eb4d96d
...
...
@@ -41,5 +41,26 @@
/>
</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
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
View file @
7eb4d96d
...
...
@@ -91,7 +91,7 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
* @param loginId
*/
protected
void
showMainActivity
(
String
loginId
)
{
AgreementToTerms
Activity
.
Pre
AgreementListener
listener
=
new
AgreementToTermsHelper
.
AgreementListener
()
{
AgreementToTerms
Helper
.
AgreementListener
listener
=
new
AgreementToTermsHelper
.
AgreementListener
()
{
@Override
public
void
onDisabled
()
{
onAgreed
();
...
...
@@ -109,9 +109,29 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
}
@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
)
{
// 読み込みに失敗したらログアウト
AlertDialogUtil
.
showAlertDialog
(
ABVNoAuthenticatedActivity
.
this
,
R
.
string
.
app_name
,
R
.
string
.
failed_to_get_terms_of_service
,
true
,
new
DialogInterface
.
OnClickListener
()
{
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
);
...
...
@@ -119,7 +139,7 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
});
}
};
AgreementToTerms
Activity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT_FROM_LOGIN
,
isNormalSize
(),
listener
);
AgreementToTerms
Helper
.
confirmAgreement
(
this
,
isNormalSize
(),
listener
);
}
protected
void
doShowMainActivity
()
{
...
...
@@ -414,7 +434,7 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
return
;
}
// 必要に応じて、規約同意画面を表示
AgreementToTerms
Activity
.
PreAgreementListener
listener
=
new
AgreementToTermsActivity
.
Pre
AgreementListener
()
{
AgreementToTerms
Helper
.
AgreementListener
listener
=
new
AgreementToTermsHelper
.
AgreementListener
()
{
@Override
public
void
onDisabled
()
{
onAgreed
();
...
...
@@ -432,13 +452,32 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
}
@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
();
}
};
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT
,
isNormalSize
(),
listener
);
AgreementToTermsHelper
.
clearVersion
(
this
);
AgreementToTermsHelper
.
confirmAgreement
(
this
,
isNormalSize
(),
listener
);
}
@Override
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/helper/AgreementToTermsHelper.java
View file @
7eb4d96d
...
...
@@ -7,12 +7,14 @@ import android.view.Display;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
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
;
...
...
@@ -24,6 +26,7 @@ import jp.agentec.abook.abv.launcher.android.R;
import
jp.agentec.abook.abv.ui.common.activity.ABVActivity
;
import
jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog
;
import
jp.agentec.abook.abv.ui.common.util.AlertDialogUtil
;
import
jp.agentec.abook.abv.ui.home.activity.AgreementToTermsActivity
;
/**
* 規約同意ダイアログを表示するヘルパー
...
...
@@ -60,12 +63,15 @@ public class AgreementToTermsHelper {
return
;
}
final
AgreementToTermsJSON
termsJSON
;
try
{
context
.
showProgressPopup
();
CommonExecutor
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
AgreementToTermsJSON
termsJSON
=
null
;
try
{
AgreementToTermsLogic
logic
=
AbstractLogic
.
getLogic
(
AgreementToTermsLogic
.
class
);
termsJSON
=
logic
.
getTerms
();
if
(
termsJSON
.
getTerms
().
isEmpty
()
||
termsJSON
.
getTermsVersion
().
isEmpty
())
{
if
(
termsJSON
==
null
||
termsJSON
.
getTerms
().
isEmpty
()
||
termsJSON
.
getTermsVersion
().
isEmpty
())
{
// 規約内容やバージョンが空の場合は表示しない
listener
.
onEmpty
();
return
;
...
...
@@ -73,117 +79,188 @@ public class AgreementToTermsHelper {
if
(
getLatestVersion
(
context
).
equals
(
termsJSON
.
getTermsVersion
()))
{
// 規約のバージョンが、すでに同意しているものと同じときは表示しない
listener
.
onAgreed
();
return
;
}
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
// 取得に失敗した場合
listener
.
onFailed
(
e
);
return
;
}
finally
{
assert
termsJSON
!=
null
;
// nullなら onEmpty()に流れているはず
final
AgreementToTermsJSON
termsJSON1
=
termsJSON
;
context
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
context
.
closeProgressPopup
();
// 同意画面表示
showAgreementDialog
(
context
,
termsJSON1
,
isNomalSize
,
listener
);
}
});
}
}
});
}
/**
* 実際にダイアログを表示するメソッド
*
* @param activity 土台になるActivity
* @param termsJSON 規約情報
* @param isNomalSize 画面サイズがスマホならtrue
* @param listener 状態に応じてコールバックを受け取るリスナー
*/
private
static
void
showAgreementDialog
(
final
ABVActivity
activity
,
final
AgreementToTermsJSON
termsJSON
,
final
boolean
isNomalSize
,
@NonNull
final
AgreementListener
listener
)
{
try
{
AlertDialog
dialog
=
makeDialog
(
activity
,
termsJSON
,
isNomalSize
,
listener
);
dialog
.
show
();
if
(!
isNomalSize
)
{
WindowManager
.
LayoutParams
params
=
dialog
.
getWindow
().
getAttributes
();
WindowManager
wm
=
(
WindowManager
)
activity
.
getSystemService
(
Context
.
WINDOW_SERVICE
);
Display
disp
=
wm
.
getDefaultDisplay
();
params
.
width
=
disp
.
getWidth
()
*
4
/
5
;
dialog
.
getWindow
().
setAttributes
(
params
);
}
}
catch
(
Exception
e
)
{
listener
.
onError
(
e
);
}
}
/**
* ダイアログを組み立てるメソッド
*
* @param activity 土台になるActivity
* @param termsJSON 規約情報
* @param isNomalSize 画面サイズがスマホならtrue
* @param listener 状態に応じてコールバックを受け取るリスナー
* @return 規約同意画面になるダイアログ
*/
private
static
AlertDialog
makeDialog
(
final
ABVActivity
activity
,
final
AgreementToTermsJSON
termsJSON
,
final
boolean
isNomalSize
,
@NonNull
final
AgreementListener
listener
)
{
// ダイアログ表示
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
context
,
R
.
style
.
Theme_MyDialog
);
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
activity
,
R
.
style
.
Theme_MyDialog
);
builder
.
setTitle
(
R
.
string
.
terms_of_service
);
LayoutInflater
inflater
=
context
.
getLayoutInflater
();
LayoutInflater
inflater
=
activity
.
getLayoutInflater
();
View
layout
=
inflater
.
inflate
(
R
.
layout
.
dlg_agreement_to_terms
,
null
,
false
);
TextView
versionText
=
layout
.
findViewById
(
R
.
id
.
textVersion
);
TextView
termsText
=
layout
.
findViewById
(
R
.
id
.
textTerms
);
versionText
.
setText
(
termsJSON
.
getTermsVersion
());
termsText
.
setText
(
termsJSON
.
getTerms
());
builder
.
setView
(
layout
);
builder
.
setCancelable
(
false
);
builder
.
setPositiveButton
(
R
.
string
.
agree
,
new
DialogInterface
.
OnClickListener
()
{
final
AlertDialog
dialog
=
builder
.
create
();
layout
.
findViewById
(
R
.
id
.
agreeButton
).
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
setLatestVersion
(
context
,
termsJSON
.
getTermsVersion
());
agree
(
context
,
termsJSON
.
getTermsVersion
(),
isNomalSize
,
listener
);
public
void
onClick
(
View
v
)
{
agree
(
activity
,
dialog
,
termsJSON
.
getTermsVersion
(),
isNomalSize
,
listener
);
}
});
builder
.
setNegativeButton
(
R
.
string
.
disagree
,
new
DialogInterface
.
OnClickListener
()
{
layout
.
findViewById
(
R
.
id
.
disagreeButton
).
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
disagree
(
context
,
isNomalSize
,
listener
);
public
void
onClick
(
View
v
)
{
disagree
(
activity
,
dialog
,
isNomalSize
,
listener
);
}
});
AlertDialog
dialog
=
builder
.
create
();
dialog
.
show
();
if
(!
isNomalSize
)
{
WindowManager
.
LayoutParams
params
=
dialog
.
getWindow
().
getAttributes
();
WindowManager
wm
=
(
WindowManager
)
context
.
getSystemService
(
Context
.
WINDOW_SERVICE
);
Display
disp
=
wm
.
getDefaultDisplay
();
params
.
width
=
disp
.
getWidth
()
*
4
/
5
;
dialog
.
getWindow
().
setAttributes
(
params
);
}
}
catch
(
Exception
e
)
{
listener
.
onError
(
e
);
}
return
dialog
;
}
// 同意する
private
static
void
agree
(
final
ABVActivity
context
,
String
currentVersion
,
final
boolean
isNomalSize
,
final
AgreementListener
listener
)
{
/**
* 同意するをタップしたときの処理
*
* @param activity 土台となるActivity
* @param dialog 規約同意画面のダイアログ
* @param currentVersion 同意する規約のバージョン
* @param isNomalSize 画面サイズがスマホならtrue
* @param listener 状態に応じてコールバックを受け取るリスナー
*/
private
static
void
agree
(
final
ABVActivity
activity
,
final
AlertDialog
dialog
,
final
String
currentVersion
,
final
boolean
isNomalSize
,
final
AgreementListener
listener
)
{
activity
.
showProgressPopup
();
CommonExecutor
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
// 同意したことをCMSに送信
AgreementToTermsLogic
logic
=
AbstractLogic
.
getLogic
(
AgreementToTermsLogic
.
class
);
logic
.
agreeTerms
(
currentVersion
);
// 同意したバージョンを保存して閉じる
setLatestVersion
(
context
,
currentVersion
);
if
(
listener
!=
null
)
{
listener
.
onAgreed
();
activity
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
setLatestVersion
(
activity
,
currentVersion
);
dialog
.
dismiss
();
listener
.
onConfirmed
(
true
);
}
});
}
catch
(
final
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
// 失敗したらアラート表示
ABookAlertDialog
dialog
=
AlertDialogUtil
.
createAlertDialog
(
context
,
R
.
string
.
app_name
);
if
(
e
instanceof
NetworkDisconnectedException
)
{
dialog
.
setMessage
(
R
.
string
.
msg_network_offline
);
}
else
{
dialog
.
setMessage
(
R
.
string
.
failed_to_send_agreement
);
}
dialog
.
setPositiveButton
(
R
.
string
.
close
,
new
DialogInterface
.
OnClickListener
()
{
activity
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
public
void
run
()
{
int
messageId
;
if
(
e
instanceof
NetworkDisconnectedException
)
{
confirmAgreement
(
context
,
isNomalSize
,
listener
);
messageId
=
R
.
string
.
msg_network_offline
;
}
else
{
messageId
=
R
.
string
.
failed_to_send_agreement
;
}
AlertDialogUtil
.
showAlertDialog
(
activity
,
R
.
string
.
app_name
,
messageId
);
}
});
dialog
.
show
();
}
finally
{
activity
.
closeProgressPopup
();
}
}
});
}
// 同意しない
private
static
void
disagree
(
final
ABVActivity
context
,
final
boolean
isNomalSize
,
final
AgreementListener
listener
)
{
// 確認ダイアログ
ABookAlertDialog
dialog
=
AlertDialogUtil
.
createAlertDialog
(
context
,
R
.
string
.
app_name
);
dialog
.
setMessage
(
R
.
string
.
logout_by_disagree
);
dialog
.
setPositiveButton
(
R
.
string
.
ok
,
new
DialogInterface
.
OnClickListener
()
{
/**
* 同意しないをタップしたときの処理
*
* @param activity 土台となるActivity
* @param dialog 規約同意画面のダイアログ
* @param isNomalSize 画面サイズがスマホならtrue
* @param listener 状態に応じてコールバックを受け取るリスナー
*/
private
static
void
disagree
(
final
ABVActivity
activity
,
final
AlertDialog
dialog
,
final
boolean
isNomalSize
,
final
AgreementListener
listener
)
{
AlertDialogUtil
.
showAlertDialog
(
activity
,
R
.
string
.
app_name
,
R
.
string
.
logout_by_disagree
,
false
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
if
(
listener
!=
null
)
{
// ログアウトしてよし
listener
.
onConfirmed
(
false
);
dialog
.
dismiss
();
}
}
});
dialog
.
setNegativeButton
(
R
.
string
.
cancel
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
confirmAgreement
(
context
,
isNomalSize
,
listener
);
}
});
dialog
.
show
();
);
}
/**
* 最後に同意した規約のバージョンの取得
*
* @param context コンテクスト
* @return 最後に同意した規約のバージョン
*/
private
static
String
getLatestVersion
(
Context
context
)
{
return
PreferenceUtil
.
getUserPref
(
context
,
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
,
""
);
}
/**
* 最後に同意した規約のバージョンの保存
*
* @param context コンテクスト
* @param version 規約のバージョン
*/
private
static
void
setLatestVersion
(
Context
context
,
String
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
);
}
...
...
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