Commit 90398862 by Kim Jinsung

Merge branch 'features/1.3.200' of gitlab.agentec.jp:abook_android/abook_check…

Merge branch 'features/1.3.200' of gitlab.agentec.jp:abook_android/abook_check into features/1.3.200
parents ea86dd32 f077265b
......@@ -114,13 +114,6 @@ android {
abiFilters "x86_64", ""
}
}
// 容量が大きいため、コメントアウト
// x86_armv7 {
// ndk {
// abiFilters "x86", "armeabi-v7a", ""
// }
// }
} else {
armv7 {
versionCode defaultConfig.versionCode
......@@ -128,6 +121,7 @@ android {
abiFilters "armeabi-v7a", ""
}
}
armv8 {
versionCode defaultConfig.versionCode + 1
ndk {
......
......@@ -6,7 +6,7 @@ buildscript {
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
compileSdkVersion 29
buildToolsVersion '28.0.3'
defaultConfig {
......
......@@ -26,7 +26,7 @@ dependencies {
}
android {
compileSdkVersion 26
compileSdkVersion 29
buildToolsVersion '28.0.3'
defaultConfig {
......
......@@ -131,7 +131,7 @@ public class ThetaHelper {
* @param ssid アクセスポイント
* @return 接続パスワード
*/
private String getPassword(String ssid) {
public String getPassword(String ssid) {
String password = ssid.replace("THETA","");
password = password.replace(".OSC","");
return password.substring(2);
......@@ -247,48 +247,14 @@ public class ThetaHelper {
* THETAカメラWi-Fiと非接続
*/
public void disConnectThetaCameraWifi(WifiManager wifiManager) {
Logger.d(TAG,"disConnectThetaCameraWifi");
//既存接続中のネットワーク切断
WifiInfo wifi_inf = wifiManager.getConnectionInfo();
if (wifi_inf.getNetworkId() != -1 ) {
wifiManager.disableNetwork(wifi_inf.getNetworkId());
wifiManager.disconnect();
}
//通常Wi-Fi再接続処理
// boolean disconnect = true;
// for (WifiConfiguration configuration : wifiManager.getConfiguredNetworks()) {
// if (wifi_inf.getNetworkId() == configuration.networkId) {
// String packageName = mContext.getPackageName();
// int result = configuration.toString().indexOf(packageName);
// if (result != -1) {
// disconnect = false;
// break;
// }
// }
// }
// if (disconnect) {
// //一番近くにあるの通常Wi-Fiに接続
// List<ScanResult> results = wifiManager.getScanResults();
// int level = 0;
// int networkId = -1;
// for (WifiConfiguration configuration : wifiManager.getConfiguredNetworks()) {
// int index = configuration.SSID.indexOf(ABookValues.THETA_MODEL_NAME_THETA);
// if (index != -1) {
// continue;
// }
// for (ScanResult scanResult : results) {
// if (configuration.SSID.indexOf(scanResult.SSID) != -1) {
// if (level == 0 || WifiManager.compareSignalLevel(level, scanResult.level) < 0) {
// level = scanResult.level;
// networkId = configuration.networkId;
// }
// break;
// }
// }
// }
// if (networkId != -1) {
// wifiManager.enableNetwork(networkId, true);
// }
// }
wifiManager.disconnect();
}
......
......@@ -25,7 +25,23 @@ public class PreferenceUtil {
public static boolean get(Context context, String key, boolean def) {
return getPref(context).getBoolean(key, def);
}
/**
* SharedPreference から、指定のキーで値をとりだす。String[]
* @param context
* @param key キー
* @return String[] 、データがなければnull
*/
public static String[] get(Context context , String key) {
SharedPreferences prefs = getUserPreference(context);
String result = prefs.getString(key,"");
if (result.length() > 0) {
return result.split(",");
}
return null;
}
public static boolean contains(Context context, String key) {
return getPref(context).contains(key);
}
......@@ -41,6 +57,26 @@ public class PreferenceUtil {
public static void put(Context context, String key, String val) {
getEditor(context).putString(key, val).commit();
}
/**
* SharedPreference に String[] で値を保存します。
* @param context
* @param key キー
* @param vals 保存する値 String[]
*/
public static void put(Context context, String key, String[] vals) {
StringBuffer buffer = new StringBuffer();
String stringItem;
for(String val : vals){
buffer.append(val + ",");
};
String buf = buffer.toString();
stringItem = buf.substring(0, buf.length() - 1);
SharedPreferences prefs = getUserPreference(context);
Editor editor = prefs.edit();
editor.putString(key, stringItem).commit();
}
public static void clear(Context context) {
getEditor(context).clear().commit();
......
......@@ -3,74 +3,43 @@ package jp.agentec.abook.abv.ui.common.activity;
import jp.agentec.abook.abv.bl.acms.type.DownloadStatusType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.exception.ABVException;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
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.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.OperationDao;
import jp.agentec.abook.abv.bl.download.ContentDownloader;
import jp.agentec.abook.abv.bl.download.ContentFileExtractor;
import jp.agentec.abook.abv.bl.download.ContentZipDownloadNotification;
import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.FixPushMessageDto;
import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.bl.dto.PushMessageDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.PushMessageLogic;
import jp.agentec.abook.abv.cl.environment.DeviceInfo;
import jp.agentec.abook.abv.cl.helper.ContentMarkingFileHelper;
import jp.agentec.abook.abv.cl.util.AndroidStringUtil;
import jp.agentec.abook.abv.launcher.android.ABVApplication;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.constant.ErrorCode;
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.helper.ProgressDialogHelper;
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.KeyboardUtils;
import jp.agentec.abook.abv.ui.common.util.LogUtil;
import jp.agentec.abook.abv.ui.common.util.PatternStringUtil;
import jp.agentec.abook.abv.ui.home.activity.ABookSettingActivity;
import jp.agentec.abook.abv.ui.home.adapter.FixPushMessageAdapter;
import jp.agentec.abook.abv.ui.home.adapter.OperationSelectAdapter;
import jp.agentec.abook.abv.ui.home.adapter.PushMessageListAdapter;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.viewer.activity.DeviceImageListActivity;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
public abstract class ABVUIActivity extends ABVAuthenticatedActivity {
private final static String TAG = "ABVUIActivity";
......
......@@ -26,6 +26,7 @@ public interface AppDefType {
String DISPLAY_MARKING = "displayMarking";
String APP_VERSIONUP_PROCESSING = "appVersionProcessingFlag";
String ERROR_SEND_ENABLE = "errorSendEnable";
String THETA_SSID_STRING = "THETA_SSID";
}
interface UserPrefKey {
......
......@@ -9,10 +9,16 @@ import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.net.Uri;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiNetworkSpecifier;
import android.os.Build;
import android.os.Bundle;
import android.provider.BaseColumns;
import android.provider.MediaStore;
......@@ -31,6 +37,7 @@ import com.theta.helper.ThetaHelper;
import com.theta.network.ThetaDeviceInfo;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
......@@ -42,6 +49,7 @@ import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.constant.ABookValues;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.cl.environment.DeviceInfo;
import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVUIActivity;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
......@@ -101,6 +109,10 @@ public class DeviceImageListActivity extends ABVUIActivity {
private SceneSendHelper mSceneSendHelper = new SceneSendHelper(this);
private WifiManager mWifiManager;
private List<String> savedThetaList_ = new ArrayList<>();
private boolean isStartCamera_ = false; // THETAとの接続開始フラグ
private ConnectivityManager.NetworkCallback networkCallback_ = null; // ネットワーク状態更新時のコールバック
@Override
public void onCreate(Bundle savedInstanceState) {
Logger.i(TAG, "onCreate");
......@@ -221,6 +233,17 @@ public class DeviceImageListActivity extends ABVUIActivity {
displayGalleryGridView();
}
mIsOnResume = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// Android10の場合は、コールバック登録解除で、THETAとの接続が切れる
if (networkCallback_ != null && isStartCamera_) {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm != null) {
cm.unregisterNetworkCallback(networkCallback_);
isStartCamera_ = false;
}
}
}
}
//端末の戻るボタン禁止
......@@ -508,6 +531,7 @@ public class DeviceImageListActivity extends ABVUIActivity {
registerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Logger.v(TAG,"registerButton.onClick");
buttonDoubleTapControl(registerButton);
if (deviceWifiEnable()) {
wifiScanStart();
......@@ -561,6 +585,7 @@ public class DeviceImageListActivity extends ABVUIActivity {
* ブロードキャスト リスナーを登録し、Wifiスキャンを開始する。
*/
private void wifiScanStart() {
Logger.v(TAG,"wifiScanStart");
showProgressPopup();
registerReceiver(wifiReceiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
mWifiManager.startScan();
......@@ -571,35 +596,88 @@ public class DeviceImageListActivity extends ABVUIActivity {
* @param ssid アクセスポイント
* @param networkId 接続可能なネットワークID
*/
private void connectThetaWifi(String ssid, int networkId) {
private void connectThetaWifi(final String ssid, int networkId) {
Logger.i(TAG,"connectThetaWifi ssid=%s, networdId=%s, Build.VERSION_CODE=%s", ssid, networkId, Build.VERSION.SDK_INT);
showProgressPopup(getString(R.string.msg_wifi_connecting));
if (networkId == -1) {
networkId = mThetaHelper.saveThetaCameraWifi(ssid);
if (networkId == -1) {
Logger.e(TAG, "saveThetaCameraWifi networkId -1");
closeProgressPopup();
showSimpleAlertDialog(getString(R.string.msg_fail_connect_theta_wifi));
return;
}
}
boolean isSuccess = mThetaHelper.connectThetaCameraWifi(networkId);
if (isSuccess) {
handler.postDelayed(new Runnable() {
@Override
public void run() {
new DeviceInfoTask(DeviceImageListActivity.this).execute();
}
}, GET_THETA_CAMERA_INFO_DELAY);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
WifiNetworkSpecifier.Builder builder = new WifiNetworkSpecifier.Builder();
builder.setSsid(ssid);
String pass = mThetaHelper.getPassword(ssid);
builder.setWpa2Passphrase(pass);
WifiNetworkSpecifier wifiNetworkSpecifier = builder.build();
NetworkRequest.Builder networkRequestBuilder = new NetworkRequest.Builder();
networkRequestBuilder.addTransportType(NetworkCapabilities.TRANSPORT_WIFI);
networkRequestBuilder.setNetworkSpecifier(wifiNetworkSpecifier);
NetworkRequest networkRequest = networkRequestBuilder.build();
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm != null) {
networkCallback_ = new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
super.onAvailable(network);
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm != null) {
// 接続したら保存
addThetaSSID(ssid);
PreferenceUtil.put(getApplicationContext(), AppDefType.DefPrefKey.THETA_SSID_STRING, savedThetaList_.toArray(new String[savedThetaList_.size()]));
cm.bindProcessToNetwork(network);
handler.postDelayed(new Runnable() {
@Override
public void run() {
new DeviceInfoTask(DeviceImageListActivity.this).execute();
}
}, GET_THETA_CAMERA_INFO_DELAY);
}
}
@Override
public void onLost(Network network) {
super.onLost(network);
closeProgressPopup();
}
@Override
public void onUnavailable() {
super.onUnavailable();
closeProgressPopup();
}
};
cm.requestNetwork(networkRequest, networkCallback_);
}
} else {
Logger.e(TAG, "connectThetaCameraWifi fail");
closeProgressPopup();
AlertDialogUtil.showAlertDialog(this, R.string.app_name, R.string.msg_fail_connect_theta_wifi, true, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
wifiScanStart();
if (networkId == -1) {
networkId = mThetaHelper.saveThetaCameraWifi(ssid);
if (networkId == -1) {
Logger.e(TAG, "saveThetaCameraWifi networkId -1");
closeProgressPopup();
showSimpleAlertDialog(getString(R.string.msg_fail_connect_theta_wifi));
return;
}
});
}
boolean isSuccess = mThetaHelper.connectThetaCameraWifi(networkId);
if (isSuccess) {
handler.postDelayed(new Runnable() {
@Override
public void run() {
new DeviceInfoTask(DeviceImageListActivity.this).execute();
}
}, GET_THETA_CAMERA_INFO_DELAY);
} else {
Logger.e(TAG, "connectThetaCameraWifi fail");
closeProgressPopup();
AlertDialogUtil.showAlertDialog(this, R.string.app_name, R.string.msg_fail_connect_theta_wifi, true, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Logger.i(TAG, "---AlertDialogUtil.onClick");
wifiScanStart();
}
});
}
}
}
......@@ -641,6 +719,7 @@ public class DeviceImageListActivity extends ABVUIActivity {
Intent intent = new Intent();
intent.setClassName(getPackageName(), ThetaCameraActivity.class.getName());
startActivity(intent);
isStartCamera_ = true;
} else {
AlertDialogUtil.showAlertDialog(this, R.string.app_name, R.string.msg_fail_connect_theta_wifi, true, new DialogInterface.OnClickListener() {
@Override
......@@ -681,23 +760,36 @@ public class DeviceImageListActivity extends ABVUIActivity {
ThetaDeviceInfo deviceInfo = new ThetaDeviceInfo();
if (index != -1) {
int networkId = -1;
for (WifiConfiguration configuration : mWifiManager.getConfiguredNetworks()) {
// Android4.2以降よりダブルクォーテーションが付いてくるので除去
String configurationSSID = configuration.SSID.replace("\"", "");
if (configurationSSID.equals(scanSSID)) {
if (configuration.status == WifiConfiguration.Status.CURRENT) {
isConnected = true;
} else {
networkId = configuration.networkId;
deviceInfo.setSSID(configurationSSID);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
deviceInfo.setSSID(scanSSID);
String[] ssid = PreferenceUtil.get(getApplicationContext(), AppDefType.DefPrefKey.THETA_SSID_STRING);
if (ssid != null) {
savedThetaList_ = new ArrayList<>(Arrays.asList(ssid));
if (findThetaSSID(scanSSID)) {
networkId = 0; // -1 だと未登録になるので
deviceInfo.setSSID(scanSSID);
deviceInfo.setNetworkId(networkId);
}
}
} else {
for (WifiConfiguration configuration : mWifiManager.getConfiguredNetworks()) {
// Android4.2以降よりダブルクォーテーションが付いてくるので除去
String configurationSSID = configuration.SSID.replace("\"", "");
if (configurationSSID.equals(scanSSID)) {
if (configuration.status == WifiConfiguration.Status.CURRENT) {
isConnected = true;
} else {
networkId = configuration.networkId;
deviceInfo.setSSID(configurationSSID);
deviceInfo.setNetworkId(networkId);
}
break;
}
}
if (isConnected) {
break;
}
}
if (isConnected) {
break;
}
if (networkId == -1) { //保存されてない
deviceInfo.setSSID(scanSSID);
scanWifiList.add(deviceInfo);
......@@ -707,11 +799,12 @@ public class DeviceImageListActivity extends ABVUIActivity {
}
}
}
//THETA接続状態の場合、カメラ画面へ遷移
if (isConnected) {
//THETA接続状態の場合、カメラ画面へ遷移
changeProgressPopup(getString(R.string.msg_wifi_connecting));
new DeviceInfoTask(DeviceImageListActivity.this).execute();
} else { //カメラ選択画面再描画
} else {
//カメラ選択画面再描画
WifiThetaConnectAdapter savedAdapter = (WifiThetaConnectAdapter) savedListView.getAdapter();
savedAdapter.setListItem(scanSavedWifiList);
savedAdapter.notifyDataSetChanged();
......@@ -719,7 +812,32 @@ public class DeviceImageListActivity extends ABVUIActivity {
notSaveAdapter.setListItem(scanWifiList);
notSaveAdapter.notifyDataSetChanged();
}
closeProgressPopup();
}
/**
* savedThetaList_ に新しい ssidを追加する
* @param ssid
* @return ssidの追加された、あたらしいsavedThetaList_
*/
private List<String> addThetaSSID(String ssid) {
if (!findThetaSSID(ssid)) {
savedThetaList_.add(ssid);
}
return savedThetaList_;
}
/**
* savedThetaList_ に、すでにssidが存在するか?
* @param ssid
* @return 存在するならtrue
*/
private boolean findThetaSSID(String ssid) {
for (String id : savedThetaList_) {
if (id.equals(ssid)) {
return true;
}
}
return false;
}
}
......@@ -11,6 +11,7 @@ import android.os.Bundle;
import com.theta.helper.ThetaHelper;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVUIActivity;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
......@@ -89,6 +90,7 @@ public class ThetaActivity extends ABVUIActivity {
* Wi-Fiが接続状態かチェックする。
*/
protected void closeThetaCameraActivity() {
Logger.i(TAG,"closeThetaCameraActivity");
showProgressPopup();
//現在接続状態なのかチェック
registerReceiver(wifiReceiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
......
......@@ -54,6 +54,7 @@ public class ThetaCameraActivity extends ThetaActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
Logger.i(TAG,"onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.ac_theta_camera);
mLiveView = findViewById(R.id.live_view);
......@@ -232,6 +233,7 @@ public class ThetaCameraActivity extends ThetaActivity {
* @param fileId ファイルID
*/
public void shootTaskFinish(final String fileId) {
Logger.i(TAG,"shootTaskFinish : " + fileId);
handler.post(new Runnable() {
@Override
public void run() {
......
......@@ -40,6 +40,7 @@ public class ThetaImageListActivity extends ThetaActivity {
private boolean isSelected = false;
@Override
public void onCreate(Bundle savedInstanceState) {
Logger.i(TAG, "--- onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.ac_theta_image_list);
mImageListView = findViewById(R.id.lv_theta_image);
......
......@@ -40,7 +40,7 @@ public class ThetaImagePreviewActivity extends ThetaActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Logger.d(TAG, "onCreate");
Logger.i(TAG, "onCreate");
setContentView(R.layout.ac_theta_image_preview);
isSavedSuccess = false;
// 戻るボタン
......
......@@ -35,7 +35,7 @@ public class ActionZoomLayout extends RelativeLayout {
@Override
protected void dispatchDraw(Canvas canvas) {
canvas.save(Canvas.ALL_SAVE_FLAG);
canvas.save();
canvas.concat(imgMatrix);
super.dispatchDraw(canvas);
canvas.restore();
......
......@@ -179,7 +179,7 @@ public class ZoomRelativeLayout extends RelativeLayout {
@Override
protected void dispatchDraw(Canvas canvas) {
canvas.save(Canvas.ALL_SAVE_FLAG);
canvas.save();
if (!isOperationPdf) {
canvas.concat(imgMatrix);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment