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
e67f928b
Commit
e67f928b
authored
Apr 14, 2022
by
onuma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文字列修正。URL修正。文言取得をContentsLogicクラスへ移動。
parent
85d821f7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
61 deletions
+101
-61
ABVJE_BL/src/jp/agentec/abook/abv/bl/logic/ContentLogic.java
+50
-0
ABVJE_Res_Default_Android/res/values-ja/strings.xml
+1
-0
ABVJE_Res_Default_Android/res/values-ko/strings.xml
+2
-0
ABVJE_Res_Default_Android/res/values/strings.xml
+1
-0
ABVJE_UI_Android/res/layout/ac_login.xml
+1
-1
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/LoginActivity.java
+46
-60
No files found.
ABVJE_BL/src/jp/agentec/abook/abv/bl/logic/ContentLogic.java
View file @
e67f928b
package
jp
.
agentec
.
abook
.
abv
.
bl
.
logic
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Iterator
;
...
...
@@ -30,7 +35,11 @@ import jp.agentec.abook.abv.bl.dto.ContentDto;
import
jp.agentec.abook.abv.bl.dto.ContentPageDto
;
import
jp.agentec.abook.abv.bl.dto.ContentTagDto
;
import
jp.agentec.abook.abv.bl.dto.comparator.ContentPageDtoComparator
;
import
jp.agentec.adf.net.http.HttpParameterObject
;
import
jp.agentec.adf.net.http.HttpRequestSender
;
import
jp.agentec.adf.net.http.HttpResponse
;
import
jp.agentec.adf.util.FileUtil
;
import
jp.agentec.adf.util.NumericUtil
;
import
jp.agentec.adf.util.StringUtil
;
/**
...
...
@@ -512,4 +521,45 @@ public class ContentLogic extends AbstractLogic {
}
return
new
ContentJSON
(
text
);
}
/**
* 利用規約の詳細文を取得する
* @param url 取得しに行くURL
* @return 取得した文字列(失敗したらnullが返る)
*/
public
String
getTermsOfServiceText
(
String
url
,
String
laungage
)
{
HttpResponse
response
=
new
HttpResponse
();
HttpURLConnection
conn
=
null
;
try
{
URL
requestUrl
=
new
URL
(
url
+
"?language="
+
laungage
);
conn
=
HttpRequestSender
.
openConnection
(
"GET"
,
requestUrl
,
"UTF-8"
,
null
,
null
,
5000
);
Logger
.
i
(
TAG
,
"responseCode : "
+
conn
.
getResponseCode
());
response
.
httpResponseCode
=
conn
.
getResponseCode
();
if
(
response
.
httpResponseCode
!=
200
)
{
return
null
;
}
response
.
httpResponseMessage
=
conn
.
getResponseMessage
();
response
.
contentLength
=
NumericUtil
.
parseLong
(
conn
.
getHeaderField
(
"Content-Length"
),
0
);
InputStream
inputStream
=
conn
.
getInputStream
();
BufferedReader
bufferReader
=
new
BufferedReader
(
new
InputStreamReader
(
conn
.
getInputStream
(),
"UTF-8"
));
String
resultJson
=
new
String
();
String
str
;
while
(
null
!=
(
str
=
bufferReader
.
readLine
()
)
)
{
resultJson
=
resultJson
+
str
;
}
bufferReader
.
close
();
Logger
.
d
(
TAG
,
"response JSON : "
+
resultJson
);
return
resultJson
;
}
catch
(
IOException
e
)
{
Logger
.
e
(
e
.
getMessage
());
}
catch
(
NumberFormatException
e
)
{
Logger
.
e
(
e
.
getMessage
());
}
finally
{
if
(
conn
!=
null
)
{
conn
.
disconnect
();
}
}
return
null
;
}
}
ABVJE_Res_Default_Android/res/values-ja/strings.xml
View file @
e67f928b
...
...
@@ -1511,4 +1511,5 @@
<string
name=
"btn_print"
>
PDF
</string>
<string
name=
"msg_agree_to_terms_of_use"
>
利用規約に同意する
</string>
<string
name=
"clickable_detail_button"
>
(詳細)
</string>
<string
name=
"err_gert_term_of_use_text"
>
利用規約の取得に失敗しました。ネットワークの接続状態を確認してください。
</string>
</resources>
ABVJE_Res_Default_Android/res/values-ko/strings.xml
View file @
e67f928b
...
...
@@ -1516,4 +1516,5 @@
<string
name=
"btn_print"
>
PDF
</string>
<string
name=
"msg_agree_to_terms_of_use"
>
이용약관에 동의함
</string>
<string
name=
"clickable_detail_button"
>
(상세)
</string>
<string
name=
"err_gert_term_of_use_text"
>
이용약관을 얻지 못했습니다. 네트워크 연결 상태를 확인해주세요.
</string>
</resources>
\ No newline at end of file
ABVJE_Res_Default_Android/res/values/strings.xml
View file @
e67f928b
...
...
@@ -1512,4 +1512,5 @@
<string
name=
"btn_print"
>
PDF
</string>
<string
name=
"msg_agree_to_terms_of_use"
>
I agree to the terms of use
</string>
<string
name=
"clickable_detail_button"
>
(detail)
</string>
<string
name=
"err_gert_term_of_use_text"
>
Failed to get the terms of use. Check the network connection status.
</string>
</resources>
ABVJE_UI_Android/res/layout/ac_login.xml
View file @
e67f928b
...
...
@@ -84,7 +84,7 @@
android:layout_gravity=
"center"
/>
<TextView
android:id=
"@+id/te
xtView6
"
android:id=
"@+id/te
rms_of_use_text
"
android:layout_width=
"match_parent"
android:layout_height=
"46dp"
android:layout_gravity=
"left"
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/LoginActivity.java
View file @
e67f928b
...
...
@@ -57,6 +57,7 @@ import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import
jp.agentec.abook.abv.bl.dto.PasswordLockInfoDto
;
import
jp.agentec.abook.abv.bl.logic.AbstractLogic
;
import
jp.agentec.abook.abv.bl.logic.CommunicationLogic
;
import
jp.agentec.abook.abv.bl.logic.ContentLogic
;
import
jp.agentec.abook.abv.bl.logic.ContractLogic
;
import
jp.agentec.abook.abv.bl.logic.OperationLogic
;
import
jp.agentec.abook.abv.bl.logic.UserAuthenticateLogic
;
...
...
@@ -112,9 +113,10 @@ public class LoginActivity extends ABVLoginActivity {
private
Button
btnLoginOff
;
private
Button
btnLoginOn
;
private
Button
btnDetail
;
private
CheckBox
chexBoxAgree
;
private
String
detail_t
ext
=
""
;
private
static
String
agreement
Url
=
ABVEnvironment
.
getInstance
().
agree_to_terms_of_use_url
;
private
String
termsOfUseT
ext
=
""
;
private
static
String
termsOfUse
Url
=
ABVEnvironment
.
getInstance
().
agree_to_terms_of_use_url
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -170,7 +172,7 @@ public class LoginActivity extends ABVLoginActivity {
}
});
//
ログインボタン(最初はGONEにして見せない)
//
活性化したログインボタン。
btnLoginOn
=
findViewById
(
R
.
id
.
btn_login_on
);
btnLoginOn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
...
...
@@ -178,6 +180,7 @@ public class LoginActivity extends ABVLoginActivity {
tryLogin
();
}
});
// 非活性化したログインボタン
btnLoginOff
=
findViewById
(
R
.
id
.
btn_login_off
);
btnLoginOff
.
setVisibility
(
View
.
VISIBLE
);
...
...
@@ -205,6 +208,16 @@ public class LoginActivity extends ABVLoginActivity {
}
});
// agreementUrl が 空の場合は、チェックボックスなどを消す
if
(
StringUtil
.
isNullOrEmpty
(
termsOfUseUrl
))
{
chexBoxAgree
.
setVisibility
(
View
.
GONE
);
findViewById
(
R
.
id
.
terms_of_use_text
).
setVisibility
(
View
.
GONE
);
findViewById
(
R
.
id
.
detail
).
setVisibility
(
View
.
GONE
);
// ログインボタン
btnLoginOff
.
setVisibility
(
View
.
GONE
);
btnLoginOn
.
setVisibility
(
View
.
VISIBLE
);
}
//androidバジョン6以上からMAC idではなくandroid固有numberを取得ため、ダイアログで表示
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
23
)
{
mBtnDeviceInfo
.
setVisibility
(
View
.
VISIBLE
);
...
...
@@ -245,39 +258,51 @@ public class LoginActivity extends ABVLoginActivity {
}
// 詳細ボタン
Button
btnDetail
=
findViewById
(
R
.
id
.
detail
);
btnDetail
=
findViewById
(
R
.
id
.
detail
);
btnDetail
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
btnDetail
.
setEnabled
(
false
);
// 非活性化(連打防止)
// ネットワーク接続チェック
if
(!
ABVEnvironment
.
getInstance
().
networkAdapter
.
isNetworkConnected
())
{
AlertDialogUtil
.
showAlertDialog
(
LoginActivity
.
this
,
getString
(
R
.
string
.
error
),
getString
(
R
.
string
.
err_gert_term_of_use_text
),
true
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
btnDetail
.
setEnabled
(
true
);
// 活性化
}
});
return
;
}
CommonExecutor
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
// CMSより文言を取得し、ダイアログで表示する。
detail_text
=
getAgreementText
();
ContentLogic
logic
=
AbstractLogic
.
getLogic
(
ContentLogic
.
class
);
String
language
=
Locale
.
getDefault
().
getLanguage
();
termsOfUseText
=
logic
.
getTermsOfServiceText
(
termsOfUseUrl
,
language
);
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
final
ABookAlertDialog
messageDialog
=
AlertDialogUtil
.
createAlertDialog
(
LoginActivity
.
this
,
R
.
string
.
error
);
if
(
detail_t
ext
!=
null
)
{
JSONObject
detail_json
=
new
JSONObject
(
detail_t
ext
);
String
messageText
=
getString
(
R
.
string
.
err_gert_term_of_use_text
);
if
(
termsOfUseT
ext
!=
null
)
{
JSONObject
detail_json
=
new
JSONObject
(
termsOfUseT
ext
);
Locale
locale
=
Locale
.
getDefault
();
if
(
locale
.
getLanguage
().
equals
(
"ja"
))
{
message
Dialog
.
setMessage
(
detail_json
.
getString
(
"ja"
)
);
message
Text
=
detail_json
.
getString
(
"ja"
);
}
else
if
(
locale
.
getLanguage
().
equals
(
"ko"
))
{
message
Dialog
.
setMessage
(
detail_json
.
getString
(
"ko"
)
);
message
Text
=
detail_json
.
getString
(
"ko"
);
}
else
{
message
Dialog
.
setMessage
(
detail_json
.
getString
(
"en"
)
);
message
Text
=
detail_json
.
getString
(
"en"
);
}
}
else
{
messageDialog
.
setMessage
(
R
.
string
.
NETWORK
);
}
messageDialog
.
setPositiveButton
(
R
.
string
.
clos
e
,
new
DialogInterface
.
OnClickListener
()
{
AlertDialogUtil
.
showAlertDialog
(
LoginActivity
.
this
,
getString
(
R
.
string
.
error
),
messageText
,
tru
e
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
btnDetail
.
setEnabled
(
true
);
// 活性化
}
});
messageDialog
.
show
();
}
});
}
...
...
@@ -286,48 +311,6 @@ public class LoginActivity extends ABVLoginActivity {
});
}
/**
* 利用規約の詳細文を取得する
* @return 取得した文字列(失敗したらnullが返る)
*/
private
String
getAgreementText
()
{
HttpResponse
response
=
new
HttpResponse
();
HttpURLConnection
conn
=
null
;
try
{
java
.
net
.
URL
url
=
new
URL
(
agreementUrl
);
Logger
.
d
(
TAG
,
"url="
+
url
);
conn
=
HttpRequestSender
.
openConnection
(
"GET"
,
url
,
"UTF-8"
,
null
,
null
,
5000
);
Logger
.
i
(
TAG
,
"responseCode : "
+
conn
.
getResponseCode
());
response
.
httpResponseCode
=
conn
.
getResponseCode
();
if
(
response
.
httpResponseCode
!=
200
)
{
return
null
;
}
response
.
httpResponseMessage
=
conn
.
getResponseMessage
();
response
.
contentLength
=
NumericUtil
.
parseLong
(
conn
.
getHeaderField
(
"Content-Length"
),
0
);
InputStream
inputStream
=
conn
.
getInputStream
();
BufferedReader
bufferReader
=
new
BufferedReader
(
new
InputStreamReader
(
conn
.
getInputStream
(),
"UTF-8"
));
String
resultJson
=
new
String
();
String
str
;
while
(
null
!=
(
str
=
bufferReader
.
readLine
()
)
)
{
resultJson
=
resultJson
+
str
;
}
bufferReader
.
close
();
Logger
.
i
(
TAG
,
"response JSON : "
+
resultJson
);
return
resultJson
;
}
catch
(
IOException
e
)
{
Logger
.
e
(
e
.
getMessage
());
}
catch
(
NumberFormatException
e
)
{
Logger
.
e
(
e
.
getMessage
());
}
finally
{
if
(
conn
!=
null
)
{
conn
.
disconnect
();
}
}
return
null
;
}
@Override
public
void
onResume
()
{
Logger
.
i
(
TAG
,
"onResume"
);
...
...
@@ -495,9 +478,12 @@ public class LoginActivity extends ABVLoginActivity {
return
false
;
}
}
if
(!
chexBoxAgree
.
isChecked
())
{
handleErrorMessageToast
(
ErrorCode
.
E132
);
return
false
;
if
(!
StringUtil
.
isNullOrEmpty
(
termsOfUseUrl
))
{
if
(!
chexBoxAgree
.
isChecked
())
{
handleErrorMessageToast
(
ErrorCode
.
E132
);
return
false
;
}
}
return
true
;
}
...
...
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