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
2291d680
Commit
2291d680
authored
May 16, 2023
by
Kazuyuki Hida
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
規約同意画面をActivityベースに変更。ログインからの処理でも規約同意画面が表示されるようにした。
parent
98e7bd4c
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
345 additions
and
225 deletions
+345
-225
ABVJE_Launcher_Android/AndroidManifest.xml
+4
-0
ABVJE_UI_Android/res/layout/ac_agreement_to_terms.xml
+41
-2
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
+71
-32
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/helper/AgreementToTermsHelper.java
+0
-188
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/helper/LogoutHelper.java
+2
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/AgreementToTermsActivity.java
+207
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/AgreementToTermsActivityDialog.java
+4
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/LoginActivity.java
+16
-3
No files found.
ABVJE_Launcher_Android/AndroidManifest.xml
View file @
2291d680
...
@@ -256,5 +256,8 @@
...
@@ -256,5 +256,8 @@
android:theme=
"@style/AppTheme"
android:theme=
"@style/AppTheme"
android:configChanges=
"keyboardHidden|orientation|screenSize"
>
android:configChanges=
"keyboardHidden|orientation|screenSize"
>
</activity>
</activity>
<activity
android:name=
"jp.agentec.abook.abv.ui.home.activity.AgreementToTermsActivity"
android:theme=
"@android:style/Theme.NoTitleBar.Fullscreen"
/>
<activity
android:name=
"jp.agentec.abook.abv.ui.home.activity.AgreementToTermsActivityDialog"
android:theme=
"@style/Theme.MyTheme.ModalDialog"
/>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
ABVJE_UI_Android/res/layout/
dlg
_agreement_to_terms.xml
→
ABVJE_UI_Android/res/layout/
ac
_agreement_to_terms.xml
View file @
2291d680
...
@@ -8,11 +8,50 @@
...
@@ -8,11 +8,50 @@
android:background=
"@color/basic_white1"
android:background=
"@color/basic_white1"
>
>
<!-- ヘッダ -->
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/list_first_color"
>
<TextView
android:id=
"@+id/disagreeButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentStart=
"true"
android:layout_centerVertical=
"true"
android:text=
"@string/disagree"
android:textColor=
"@color/dialog_text_color"
android:padding=
"16dp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerInParent=
"true"
android:text=
"@string/terms_of_service"
android:textColor=
"@color/dialog_text_color"
android:padding=
"16dp"
/>
<TextView
android:id=
"@+id/agreeButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
android:text=
"@string/agree"
android:textColor=
"@color/dialog_text_color"
android:padding=
"16dp"
tools:ignore=
"RelativeOverlap"
/>
</RelativeLayout>
<!-- 規約 -->
<!-- 規約 -->
<ScrollView
<ScrollView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"
match_parent
"
android:layout_height=
"
0dp
"
tools:ignore=
"UselessParent
"
>
android:layout_weight=
"1
"
>
<LinearLayout
<LinearLayout
android:orientation=
"vertical"
android:orientation=
"vertical"
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
View file @
2291d680
...
@@ -49,9 +49,10 @@ import jp.agentec.abook.abv.ui.common.constant.ErrorMessage;
...
@@ -49,9 +49,10 @@ 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.constant.NaviConsts
;
import
jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog
;
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.ABVViewUnbindHelper
;
import
jp.agentec.abook.abv.ui.common.helper.
AgreementToTerms
Helper
;
import
jp.agentec.abook.abv.ui.common.helper.
Logout
Helper
;
import
jp.agentec.abook.abv.ui.common.util.ABVToastUtil
;
import
jp.agentec.abook.abv.ui.common.util.ABVToastUtil
;
import
jp.agentec.abook.abv.ui.common.util.AlertDialogUtil
;
import
jp.agentec.abook.abv.ui.common.util.AlertDialogUtil
;
import
jp.agentec.abook.abv.ui.home.activity.AgreementToTermsActivity
;
import
jp.agentec.abook.abv.ui.home.activity.LoginActivity
;
import
jp.agentec.abook.abv.ui.home.activity.LoginActivity
;
import
jp.agentec.abook.abv.ui.home.activity.OperationListActivity
;
import
jp.agentec.abook.abv.ui.home.activity.OperationListActivity
;
import
jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper
;
import
jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper
;
...
@@ -62,6 +63,10 @@ import jp.agentec.adf.util.StringUtil;
...
@@ -62,6 +63,10 @@ import jp.agentec.adf.util.StringUtil;
public
abstract
class
ABVNoAuthenticatedActivity
extends
ABVActivity
{
public
abstract
class
ABVNoAuthenticatedActivity
extends
ABVActivity
{
private
static
final
String
TAG
=
"ABVNoAuthenticatedActivity"
;
private
static
final
String
TAG
=
"ABVNoAuthenticatedActivity"
;
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
Context
mContext
=
ABVNoAuthenticatedActivity
.
this
;
@Override
@Override
...
@@ -85,10 +90,32 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
...
@@ -85,10 +90,32 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
*
*
* @param loginId
* @param loginId
*/
*/
protected
void
showMainActivity
(
String
loginId
)
{
protected
void
showMainActivity
(
String
loginId
)
{
confirmResult
=
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT_FROM_LOGIN
,
isNormalSize
(),
null
);
switch
(
confirmResult
)
{
case
DISABLE:
case
EMPTY:
case
AGREED:
// 規約同意画面が開かれなかったら、改めて初期化
doShowMainActivity
();
break
;
case
FAILED:
confirmResult
=
AgreementToTermsActivity
.
Result
.
AGREED
;
doShowMainActivity
();
break
;
case
CONFIRM:
// onActivityResultを待つ
break
;
}
}
protected
void
doShowMainActivity
()
{
startActivity
(
new
Intent
().
setClassName
(
getApplicationContext
().
getPackageName
(),
getMainActivityClassName
()).
setFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
),
NaviConsts
.
Right
);
startActivity
(
new
Intent
().
setClassName
(
getApplicationContext
().
getPackageName
(),
getMainActivityClassName
()).
setFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
),
NaviConsts
.
Right
);
if
(!(
this
instanceof
LoginActivity
))
{
finish
();
finish
();
}
LoginActivity
.
finishPendingActivity
();
Intent
intent
=
new
Intent
();
Intent
intent
=
new
Intent
();
getApplicationContext
().
sendBroadcast
(
intent
);
getApplicationContext
().
sendBroadcast
(
intent
);
}
}
...
@@ -371,28 +398,54 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
...
@@ -371,28 +398,54 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
}
}
protected
void
moveToHome
()
{
protected
void
moveToHome
()
{
AgreementToTermsHelper
.
clearVersion
(
this
);
// 必要に応じて、規約同意画面を表示
AgreementToTermsHelper
.
confirmAgreement
(
this
,
isNormalSize
(),
agreementListener
);
AgreementToTermsActivity
.
clearVersion
(
this
);
// for debug!
confirmResult
=
AgreementToTermsActivity
.
confirmAgreement
(
this
,
REQUEST_AGREEMENT
,
isNormalSize
(),
null
);
switch
(
confirmResult
)
{
case
DISABLE:
case
EMPTY:
case
AGREED:
// 規約同意画面が開かれなかったら、改めて初期化
doMoveToHome
();
break
;
case
FAILED:
confirmResult
=
AgreementToTermsActivity
.
Result
.
AGREED
;
doMoveToHome
();
break
;
case
CONFIRM:
// onActivityResultを待つ
break
;
}
}
private
final
AgreementToTermsHelper
.
AgreementListener
agreementListener
=
new
AgreementToTermsHelper
.
AgreementListener
()
{
@Override
public
void
onDisabled
()
{
onAgreed
();
}
}
@Override
@Override
public
void
onEmpty
()
{
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
onAgreed
();
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
requestCode
==
REQUEST_AGREEMENT
)
{
if
(
resultCode
==
RESULT_OK
)
{
// 同意したら初期化
confirmResult
=
AgreementToTermsActivity
.
Result
.
AGREED
;
doMoveToHome
();
}
else
{
// 規約に同意しなかったので、ログアウト
LogoutHelper
.
logout
(
this
);
}
}
}
@Override
if
(
requestCode
==
REQUEST_AGREEMENT_FROM_LOGIN
)
{
public
void
onFailed
()
{
if
(
resultCode
==
RESULT_OK
)
{
onAgreed
();
// 同意したら初期化
confirmResult
=
AgreementToTermsActivity
.
Result
.
AGREED
;
doShowMainActivity
();
}
else
{
// 規約に同意しなかったので、ログアウト
LogoutHelper
.
logout
(
this
);
}
}
}
}
@Override
private
void
doMoveToHome
()
{
public
void
onAgreed
()
{
Bundle
extras
=
getIntent
().
getExtras
();
Bundle
extras
=
getIntent
().
getExtras
();
Intent
intent
=
new
Intent
();
Intent
intent
=
new
Intent
();
if
(
extras
!=
null
&&
!
StringUtil
.
isNullOrEmpty
(
extras
.
getString
(
AppDefType
.
PushMessageKey
.
data
)))
{
if
(
extras
!=
null
&&
!
StringUtil
.
isNullOrEmpty
(
extras
.
getString
(
AppDefType
.
PushMessageKey
.
data
)))
{
...
@@ -428,26 +481,12 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
...
@@ -428,26 +481,12 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
}
}
}
}
startActivity
(
intent
);
startActivity
(
intent
);
if
(!
(
this
instanceof
LoginActivity
))
{
finish
();
finish
();
}
}
LoginActivity
.
finishPendingActivity
();
@Override
public
void
onDisagreed
()
{
Intent
intent
=
new
Intent
();
intent
.
setClassName
(
getApplicationContext
().
getPackageName
(),
LoginActivity
.
class
.
getName
()).
setFlags
(
Intent
.
FLAG_ACTIVITY_NO_HISTORY
);
startActivity
(
intent
);
finish
();
}
}
@Override
public
void
onError
(
Exception
e
)
{
Intent
intent
=
new
Intent
();
intent
.
setClassName
(
getApplicationContext
().
getPackageName
(),
LoginActivity
.
class
.
getName
()).
setFlags
(
Intent
.
FLAG_ACTIVITY_NO_HISTORY
);
startActivity
(
intent
);
finish
();
}
};
/**
/**
* カスタムURL対応
* カスタムURL対応
* @param uri
* @param uri
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/helper/AgreementToTermsHelper.java
deleted
100644 → 0
View file @
98e7bd4c
package
jp
.
agentec
.
abook
.
abv
.
ui
.
common
.
helper
;
import
android.app.AlertDialog
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.view.Display
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.TextView
;
import
androidx.annotation.Nullable
;
import
jp.agentec.abook.abv.bl.acms.client.json.AgreementToTermsJSON
;
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
;
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.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.dialog.ABookAlertDialog
;
import
jp.agentec.abook.abv.ui.common.util.AlertDialogUtil
;
public
class
AgreementToTermsHelper
{
private
static
final
String
TAG
=
"AgreementToTermsHelper"
;
public
interface
AgreementListener
{
void
onDisabled
();
void
onEmpty
();
void
onFailed
();
void
onAgreed
();
void
onDisagreed
();
void
onError
(
Exception
e
);
}
/**
* 同意規約情報を読み込んで、バージョンが異なっていたら、ダイアログを表示
* バージョンが同じだったら何もしない
*/
public
static
void
confirmAgreement
(
final
ABVActivity
context
,
final
boolean
isNomalSize
,
@Nullable
final
AgreementListener
listener
)
{
if
(!
ABVDataCache
.
getInstance
().
serviceOption
.
isUsableAgreementToTerms
())
{
// 規約同意オプションが無効な場合、表示しない
if
(
listener
!=
null
)
{
listener
.
onDisabled
();
}
return
;
}
final
AgreementToTermsJSON
termsJSON
;
try
{
context
.
showProgressPopup
();
AgreementToTermsLogic
logic
=
AbstractLogic
.
getLogic
(
AgreementToTermsLogic
.
class
);
termsJSON
=
logic
.
getTerms
();
if
(
termsJSON
.
getTerms
().
isEmpty
()
||
termsJSON
.
getTermsVersion
().
isEmpty
())
{
// 規約内容やバージョンが空の場合は表示しない
if
(
listener
!=
null
)
{
listener
.
onEmpty
();
}
return
;
}
if
(
getLatestVersion
(
context
).
equals
(
termsJSON
.
getTermsVersion
()))
{
// 規約のバージョンが、すでに同意しているものと同じときは表示しない
if
(
listener
!=
null
)
{
listener
.
onAgreed
();
}
return
;
}
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
if
(
listener
!=
null
)
{
// 取得に失敗した場合
listener
.
onFailed
();
}
return
;
}
finally
{
context
.
closeProgressPopup
();
}
try
{
// ダイアログ表示
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
context
,
R
.
style
.
Theme_MyDialog
);
builder
.
setTitle
(
R
.
string
.
terms_of_service
);
LayoutInflater
inflater
=
context
.
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
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
setLatestVersion
(
context
,
termsJSON
.
getTermsVersion
());
agree
(
context
,
termsJSON
.
getTermsVersion
(),
isNomalSize
,
listener
);
}
});
builder
.
setNegativeButton
(
R
.
string
.
disagree
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
disagree
(
context
,
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
)
{
if
(
listener
!=
null
)
{
// ダイアログ表示でエラーが出た場合
listener
.
onError
(
e
);
}
}
}
// 同意する
private
static
void
agree
(
final
ABVActivity
context
,
String
currentVersion
,
final
boolean
isNomalSize
,
final
AgreementListener
listener
)
{
try
{
// 同意したことをCMSに送信
AgreementToTermsLogic
logic
=
AbstractLogic
.
getLogic
(
AgreementToTermsLogic
.
class
);
logic
.
agreeTerms
(
currentVersion
);
// 同意したバージョンを保存して閉じる
setLatestVersion
(
context
,
currentVersion
);
if
(
listener
!=
null
)
{
listener
.
onAgreed
();
}
}
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
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
if
(
e
instanceof
NetworkDisconnectedException
)
{
confirmAgreement
(
context
,
isNomalSize
,
listener
);
}
}
});
dialog
.
show
();
}
}
// 同意しない
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
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
if
(
listener
!=
null
)
{
listener
.
onDisagreed
();
}
}
});
dialog
.
setNegativeButton
(
R
.
string
.
cancel
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
confirmAgreement
(
context
,
isNomalSize
,
listener
);
}
});
dialog
.
show
();
}
private
static
String
getLatestVersion
(
Context
context
)
{
return
PreferenceUtil
.
getUserPref
(
context
,
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
,
""
);
}
private
static
void
setLatestVersion
(
Context
context
,
String
version
)
{
PreferenceUtil
.
putUserPref
(
context
,
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
,
version
);
}
public
static
void
clearVersion
(
Context
context
)
{
PreferenceUtil
.
removeUserPref
(
context
,
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
);
}
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/helper/LogoutHelper.java
View file @
2291d680
...
@@ -34,7 +34,9 @@ public class LogoutHelper {
...
@@ -34,7 +34,9 @@ public class LogoutHelper {
}
}
// 新着更新が実行されている場合停止
// 新着更新が実行されている場合停止
if
(
activity
instanceof
ABookSettingActivity
)
{
((
ABookSettingActivity
)
activity
).
stopContentRefresher
();
((
ABookSettingActivity
)
activity
).
stopContentRefresher
();
}
SharedPreferences
sharedPreferences
=
activity
.
getSharedPreferences
(
AppDefType
.
PrefName
.
USER_PREFERENCE
,
Context
.
MODE_PRIVATE
);
SharedPreferences
sharedPreferences
=
activity
.
getSharedPreferences
(
AppDefType
.
PrefName
.
USER_PREFERENCE
,
Context
.
MODE_PRIVATE
);
sharedPreferences
.
edit
().
remove
(
AppDefType
.
UserPrefKey
.
GUEST_LOGIN
).
apply
();
sharedPreferences
.
edit
().
remove
(
AppDefType
.
UserPrefKey
.
GUEST_LOGIN
).
apply
();
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/AgreementToTermsActivity.java
0 → 100644
View file @
2291d680
package
jp
.
agentec
.
abook
.
abv
.
ui
.
home
.
activity
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.view.KeyEvent
;
import
android.view.View
;
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.constant.ABookKeys
;
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.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
{
private
static
final
String
TAG
=
"AgreementToTermsActivity"
;
private
String
currentVersion
=
""
;
public
enum
Result
{
DISABLE
,
// 規約同意オプションが無効だった
EMPTY
,
// 規約情報が空だった
AGREED
,
// 同意済みだった
FAILED
,
// 規約情報の読み込みに失敗した
CONFIRM
// 規約同意画面を表示した
}
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
ac_agreement_to_terms
);
TextView
versionText
=
findViewById
(
R
.
id
.
textVersion
);
TextView
termsText
=
findViewById
(
R
.
id
.
textTerms
);
Intent
intent
=
getIntent
();
if
(
intent
!=
null
)
{
currentVersion
=
intent
.
getStringExtra
(
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
);
versionText
.
setText
(
currentVersion
);
termsText
.
setText
(
intent
.
getStringExtra
(
ABookKeys
.
AGREEMENT_TO_TERMS
));
}
setResult
(
RESULT_CANCELED
);
findViewById
(
R
.
id
.
disagreeButton
).
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
disagree
();
}
});
findViewById
(
R
.
id
.
agreeButton
).
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
agree
();
}
});
}
@Override
public
void
onBackPressed
()
{
disagree
();
}
@Override
public
boolean
onKeyUp
(
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
)
{
disagree
();
return
true
;
}
else
{
return
super
.
onKeyUp
(
keyCode
,
event
);
}
}
// 同意する
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
);
}
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
);
}
/**
* 同意規約情報を読み込んで、バージョンが異なっていたら、Activityを表示
* バージョンが同じだったら何もしない
* 呼び出し側は、onActivityResultで、resultCode が RESULT_OK なら同意した、
* RESULT_CANCELEDなら同意しなかったと判断する
*
* @param context 呼び出し元アクティビティ
* @param requestCode startActivityForResultで使用するリクエスト・コード
* @param isNormalSize 端末サイズ指定(スマホならtrue)
* @param onFailed 規約情報の取得に失敗したときの処理
*/
public
static
Result
confirmAgreement
(
ABVActivity
context
,
int
requestCode
,
boolean
isNormalSize
,
@Nullable
final
Runnable
onFailed
)
{
if
(!
ABVDataCache
.
getInstance
().
serviceOption
.
isUsableAgreementToTerms
())
{
// 規約同意オプションが無効な場合、何もしない
return
Result
.
DISABLE
;
}
try
{
context
.
showProgressPopup
();
AgreementToTermsLogic
logic
=
AbstractLogic
.
getLogic
(
AgreementToTermsLogic
.
class
);
AgreementToTermsJSON
json
=
logic
.
getTerms
();
if
(
json
.
getTerms
().
isEmpty
()
||
json
.
getTermsVersion
().
isEmpty
())
{
// 規約内容やバージョンが空の場合は何もしない
return
Result
.
EMPTY
;
}
if
(
getLatestVersion
(
context
).
equals
(
json
.
getTermsVersion
()))
{
// 規約のバージョンが、すでに同意しているものと同じときは何もしない
return
Result
.
AGREED
;
}
// ダイアログ表示
Intent
intent
=
new
Intent
(
context
,
isNormalSize
?
AgreementToTermsActivity
.
class
:
AgreementToTermsActivityDialog
.
class
);
intent
.
putExtra
(
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
,
json
.
getTermsVersion
());
intent
.
putExtra
(
ABookKeys
.
AGREEMENT_TO_TERMS
,
json
.
getTerms
());
context
.
startActivityForResult
(
intent
,
requestCode
);
return
Result
.
CONFIRM
;
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
if
(
onFailed
!=
null
)
{
failed
(
context
,
onFailed
);
}
return
Result
.
FAILED
;
}
finally
{
context
.
closeProgressPopup
();
}
}
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
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
// ログイン直後の場合失敗したら、ログアウトする仕様なので、それをonFailedを通して実行
onFailed
.
run
();
}
});
dialog
.
show
();
}
private
static
String
getLatestVersion
(
Context
context
)
{
return
PreferenceUtil
.
getUserPref
(
context
,
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
,
""
);
}
private
static
void
setLatestVersion
(
Context
context
,
String
version
)
{
PreferenceUtil
.
putUserPref
(
context
,
ABookKeys
.
AGREEMENT_TO_TERMS_VERSION
,
version
);
}
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
();
}
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/AgreementToTermsActivityDialog.java
0 → 100644
View file @
2291d680
package
jp
.
agentec
.
abook
.
abv
.
ui
.
home
.
activity
;
public
class
AgreementToTermsActivityDialog
extends
AgreementToTermsActivity
{
}
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/LoginActivity.java
View file @
2291d680
...
@@ -21,6 +21,9 @@ import android.widget.ImageButton;
...
@@ -21,6 +21,9 @@ import android.widget.ImageButton;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
java.util.ArrayList
;
import
java.util.List
;
import
jp.agentec.abook.abv.bl.acms.client.json.CmsUrlJSON
;
import
jp.agentec.abook.abv.bl.acms.client.json.CmsUrlJSON
;
import
jp.agentec.abook.abv.bl.acms.type.DeleteDataType
;
import
jp.agentec.abook.abv.bl.acms.type.DeleteDataType
;
import
jp.agentec.abook.abv.bl.acms.type.LoginMode
;
import
jp.agentec.abook.abv.bl.acms.type.LoginMode
;
...
@@ -98,8 +101,7 @@ public class LoginActivity extends ABVLoginActivity {
...
@@ -98,8 +101,7 @@ public class LoginActivity extends ABVLoginActivity {
private
InputMethodManager
imm
;
private
InputMethodManager
imm
;
// private CheckBox chexBoxAgree;
private
static
List
<
LoginActivity
>
pendingActivityList
=
new
ArrayList
<>();
// private static String termsOfUseUrl = ABVEnvironment.getInstance().agreeToTermsOfUseUrl;
@Override
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
public
void
onCreate
(
Bundle
savedInstanceState
)
{
...
@@ -288,7 +290,18 @@ public class LoginActivity extends ABVLoginActivity {
...
@@ -288,7 +290,18 @@ public class LoginActivity extends ABVLoginActivity {
@Override
@Override
public
void
onPause
()
{
public
void
onPause
()
{
super
.
onPause
();
super
.
onPause
();
finish
();
pendingActivityList
.
add
(
this
);
}
public
static
void
finishPendingActivity
()
{
while
(
pendingActivityList
.
size
()
>
0
)
{
LoginActivity
activity
=
pendingActivityList
.
remove
(
pendingActivityList
.
size
()
-
1
);
activity
.
finish
();
}
}
public
static
void
clearPendingActivity
()
{
pendingActivityList
.
clear
();
}
}
@Override
@Override
...
...
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