package net.osdn.gokigen.pkremote.preference.nikon;
import android.content.Context;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
+import android.provider.Settings;
import android.util.Log;
import java.util.Map;
import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
import net.osdn.gokigen.pkremote.scene.IChangeScene;
+import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.DEBUG_INFO;
+import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.EXIT_APPLICATION;
+import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.WIFI_SETTINGS;
+
/**
*
*
*/
-public class NikonPreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener
+public class NikonPreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener
{
private final String TAG = toString();
+ private AppCompatActivity context = null;
private SharedPreferences preferences = null;
private PtpIpCameraPowerOff powerOffController = null;
private LogCatViewer logCatViewer = null;
logCatViewer = new LogCatViewer(changeScene);
logCatViewer.prepare();
+
+ this.context = context;
}
catch (Exception e)
{
if (!items.containsKey(IPreferencePropertyAccessor.NIKON_CAMERA_IP_ADDRESS)) {
editor.putString(IPreferencePropertyAccessor.NIKON_CAMERA_IP_ADDRESS, IPreferencePropertyAccessor.NIKON_CAMERA_IP_ADDRESS_DEFAULT_VALUE);
}
+ if (!items.containsKey(IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT)) {
+ editor.putString(IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT, IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT_DEFAULT_VALUE);
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.NIKON_USE_SCREENNAIL_AS_SMALL)) {
+ editor.putBoolean(IPreferencePropertyAccessor.NIKON_USE_SCREENNAIL_AS_SMALL, false);
+ }
if (!items.containsKey(IPreferencePropertyAccessor.BLE_WIFI_ON)) {
editor.putBoolean(IPreferencePropertyAccessor.BLE_WIFI_ON, false);
}
+ if (!items.containsKey(IPreferencePropertyAccessor.GET_SMALL_PICTURE_AS_VGA))
+ {
+ editor.putBoolean(IPreferencePropertyAccessor.GET_SMALL_PICTURE_AS_VGA, false);
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.USE_SMARTPHONE_TRANSFER_MODE))
+ {
+ editor.putBoolean(IPreferencePropertyAccessor.USE_SMARTPHONE_TRANSFER_MODE, false);
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT))
+ {
+ editor.putString(IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT, IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE);
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.USE_OSC_THETA_V21))
+ {
+ editor.putBoolean(IPreferencePropertyAccessor.USE_OSC_THETA_V21, false);
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.PIXPRO_HOST_IP))
+ {
+ editor.putString(IPreferencePropertyAccessor.PIXPRO_HOST_IP, IPreferencePropertyAccessor.PIXPRO_HOST_IP_DEFAULT_VALUE);
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT))
+ {
+ editor.putString(IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT, IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT_DEFAULT_VALUE);
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.PIXPRO_GET_PICS_LIST_TIMEOUT))
+ {
+ editor.putString(IPreferencePropertyAccessor.PIXPRO_GET_PICS_LIST_TIMEOUT, IPreferencePropertyAccessor.PIXPRO_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE);
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.THUMBNAIL_IMAGE_CACHE_SIZE))
+ {
+ editor.putString(IPreferencePropertyAccessor.THUMBNAIL_IMAGE_CACHE_SIZE, IPreferencePropertyAccessor.THUMBNAIL_IMAGE_CACHE_SIZE_DEFAULT_VALUE);
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.CANON_HOST_IP)) {
+ editor.putString(IPreferencePropertyAccessor.CANON_HOST_IP, IPreferencePropertyAccessor.CANON_HOST_IP_DEFAULT_VALUE);
+ }
+ if (!items.containsKey(IPreferencePropertyAccessor.CANON_CONNECTION_SEQUENCE)) {
+ editor.putString(IPreferencePropertyAccessor.CANON_CONNECTION_SEQUENCE, IPreferencePropertyAccessor.CANON_CONNECTION_SEQUENCE_DEFAULT_VALUE);
+ }
editor.apply();
}
catch (Exception e)
Log.v(TAG, " " + key + " , " + value);
break;
+ case IPreferencePropertyAccessor.NIKON_USE_SCREENNAIL_AS_SMALL:
+ value = preferences.getBoolean(key, false);
+ Log.v(TAG, " " + key + " , " + value);
+ break;
+
case IPreferencePropertyAccessor.BLE_WIFI_ON:
value = preferences.getBoolean(key, false);
Log.v(TAG, " " + key + " , " + value);
});
connectionMethod.setSummary(connectionMethod.getValue() + " ");
- findPreference("exit_application").setOnPreferenceClickListener(powerOffController);
- findPreference("debug_info").setOnPreferenceClickListener(logCatViewer);
+ findPreference(EXIT_APPLICATION).setOnPreferenceClickListener(powerOffController);
+ findPreference(DEBUG_INFO).setOnPreferenceClickListener(logCatViewer);
+ findPreference(WIFI_SETTINGS).setOnPreferenceClickListener(this);
}
catch (Exception e)
{
// Preferenceの画面に反映させる
setBooleanPreference(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true);
setBooleanPreference(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true);
-
+ setBooleanPreference(IPreferencePropertyAccessor.NIKON_USE_SCREENNAIL_AS_SMALL, IPreferencePropertyAccessor.NIKON_USE_SCREENNAIL_AS_SMALL, false);
setBooleanPreference(IPreferencePropertyAccessor.BLE_WIFI_ON, IPreferencePropertyAccessor.BLE_WIFI_ON, false);
}
catch (Exception e)
}
}
+ @Override
+ public boolean onPreferenceClick(Preference preference)
+ {
+ try
+ {
+ String preferenceKey = preference.getKey();
+ if (preferenceKey.contains(WIFI_SETTINGS))
+ {
+ // Wifi 設定画面を表示する
+ Log.v(TAG, " onPreferenceClick : " + preferenceKey);
+ if (context != null)
+ {
+ context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
+ }
+ }
+ return (true);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (false);
+ }
}