package net.osdn.gokigen.pkremote.preference.sony;
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 SonyPreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener
+public class SonyPreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener
{
private final String TAG = toString();
+ private AppCompatActivity context = null;
private SharedPreferences preferences = null;
private CameraPowerOffSony powerOffController = null;
private LogCatViewer logCatViewer = null;
cameraApiListViewer = new SonyCameraApiListViewer(changeScene);
cameraApiListViewer.prepare();
+
+ this.context = context;
}
catch (Exception e)
{
Map<String, ?> items = preferences.getAll();
SharedPreferences.Editor editor = preferences.edit();
- if (!items.containsKey(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA)) {
+ if (!items.containsKey(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA))
+ {
editor.putBoolean(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true);
}
- if (!items.containsKey(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW)) {
+ if (!items.containsKey(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW))
+ {
editor.putBoolean(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true);
}
- if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD)) {
+ if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD))
+ {
editor.putString(IPreferencePropertyAccessor.CONNECTION_METHOD, IPreferencePropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
}
- if (!items.containsKey(IPreferencePropertyAccessor.GET_SMALL_PICTURE_AS_VGA)) {
+ 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.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.USE_SMARTPHONE_TRANSFER_MODE:
+ value = preferences.getBoolean(key, false);
+ Log.v(TAG, " " + key + " , " + value);
+ break;
+
default:
String strValue = preferences.getString(key, "");
setListPreference(key, key, strValue);
});
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);
findPreference("sony_api_list").setOnPreferenceClickListener(cameraApiListViewer);
}
catch (Exception e)
setBooleanPreference(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, defaultValue);
setBooleanPreference(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, defaultValue);
setBooleanPreference(IPreferencePropertyAccessor.GET_SMALL_PICTURE_AS_VGA, IPreferencePropertyAccessor.GET_SMALL_PICTURE_AS_VGA, false);
+ setBooleanPreference(IPreferencePropertyAccessor.USE_SMARTPHONE_TRANSFER_MODE, IPreferencePropertyAccessor.USE_SMARTPHONE_TRANSFER_MODE, 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);
+ }
}