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
89703410
Commit
89703410
authored
May 22, 2023
by
Kazuyuki Hida
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
別作業に戻るためいったんコミット
parent
409f5a6e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
238 additions
and
3 deletions
+238
-3
ABVJE_UI_Android/res/layout/dlg_agreement_to_terms.xml
+46
-0
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
+2
-3
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/helper/AgreementToTermsHelper.java
+190
-0
No files found.
ABVJE_UI_Android/res/layout/dlg_agreement_to_terms.xml
0 → 100644
View file @
89703410
<?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=
"match_parent"
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>
\ No newline at end of file
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVNoAuthenticatedActivity.java
View file @
89703410
...
@@ -49,6 +49,7 @@ import jp.agentec.abook.abv.ui.common.constant.ErrorMessage;
...
@@ -49,6 +49,7 @@ 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.AgreementToTermsHelper
;
import
jp.agentec.abook.abv.ui.common.helper.LogoutHelper
;
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.ABVToastUtil
;
import
jp.agentec.abook.abv.ui.common.util.AlertDialogUtil
;
import
jp.agentec.abook.abv.ui.common.util.AlertDialogUtil
;
...
@@ -90,7 +91,7 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
...
@@ -90,7 +91,7 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
* @param loginId
* @param loginId
*/
*/
protected
void
showMainActivity
(
String
loginId
)
{
protected
void
showMainActivity
(
String
loginId
)
{
AgreementToTermsActivity
.
PreAgreementListener
listener
=
new
AgreementToTerms
Activity
.
Pre
AgreementListener
()
{
AgreementToTermsActivity
.
PreAgreementListener
listener
=
new
AgreementToTerms
Helper
.
AgreementListener
()
{
@Override
@Override
public
void
onDisabled
()
{
public
void
onDisabled
()
{
onAgreed
();
onAgreed
();
...
@@ -350,8 +351,6 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
...
@@ -350,8 +351,6 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
}
}
}
}
/**
/**
* 1日1回のバージョンチェックを行う
* 1日1回のバージョンチェックを行う
* @return true チェックを行う false 行わない
* @return true チェックを行う false 行わない
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/helper/AgreementToTermsHelper.java
0 → 100644
View file @
89703410
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.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.dialog.ABookAlertDialog
;
import
jp.agentec.abook.abv.ui.common.util.AlertDialogUtil
;
/**
* 規約同意ダイアログを表示するヘルパー
*/
public
class
AgreementToTermsHelper
{
private
static
final
String
TAG
=
"AgreementToTermsHelper"
;
/**
* 規約同意状態に応じて動作するリスナー
*/
public
interface
AgreementListener
{
// 規約同意オプションがNoだった
void
onDisabled
();
// 規約内容やバージョンが空だった
void
onEmpty
();
// 規約情報の取得に失敗した
void
onFailed
(
Exception
e
);
// すでに同意済みだった
void
onAgreed
();
// 同意するまたはしないをタップされた
void
onConfirmed
(
boolean
isAgreed
);
// 規約情報の取得以外でエラーがあった
void
onError
(
Exception
e
);
}
/**
* 同意規約情報を読み込んで、バージョンが異なっていたら、ダイアログを表示
* バージョンが同じだったら何もしない
*/
public
static
void
confirmAgreement
(
final
ABVActivity
context
,
final
boolean
isNomalSize
,
@NonNull
final
AgreementListener
listener
)
{
if
(!
ABVDataCache
.
getInstance
().
serviceOption
.
isUsableAgreementToTerms
())
{
// 規約同意オプションが無効な場合、表示しない
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
())
{
// 規約内容やバージョンが空の場合は表示しない
listener
.
onEmpty
();
return
;
}
if
(
getLatestVersion
(
context
).
equals
(
termsJSON
.
getTermsVersion
()))
{
// 規約のバージョンが、すでに同意しているものと同じときは表示しない
listener
.
onAgreed
();
return
;
}
}
catch
(
Exception
e
)
{
Logger
.
e
(
TAG
,
e
);
// 取得に失敗した場合
listener
.
onFailed
(
e
);
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
)
{
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
.
onConfirmed
(
false
);
}
}
});
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
);
}
}
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