import net.osdn.gokigen.a01d.camera.olympus.IOlympusDisplayInjector;
import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
import net.osdn.gokigen.a01d.camera.olympus.cameraproperty.OlyCameraPropertyListFragment;
+import net.osdn.gokigen.a01d.camera.olympus.myolycameraprops.LoadSaveCameraProperties;
+import net.osdn.gokigen.a01d.camera.olympus.myolycameraprops.LoadSaveMyCameraPropertyDialog;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.OlympusInterfaceProvider;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ICameraStatusReceiver;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
+import net.osdn.gokigen.a01d.liveview.IFavoriteSettingDialogKicker;
import net.osdn.gokigen.a01d.liveview.IStatusViewDrawer;
import net.osdn.gokigen.a01d.liveview.LiveViewFragment;
import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.myolycameraprops;
+
+interface ILoadSaveCameraProperties
+{
+ static final int MAX_STORE_PROPERTIES = 256; // お気に入り設定の最大記憶数...
+ static final String TITLE_KEY = "CameraPropTitleKey";
+ static final String DATE_KEY = "CameraPropDateTime";
+
+ void loadCameraSettings(final String id, final String dataName);
+ void saveCameraSettings(final String id, final String dataName);
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.myolycameraprops;
+
+interface ILoadSaveMyCameraPropertyDialogDismiss
+{
+ void doDismissWithPropertyLoad(String id, String name);
+ void doDismissWithPropertySave(String id, String name);
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.myolycameraprops;
+
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.support.v4.app.ListFragment;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ListView;
+
+import net.osdn.gokigen.a01d.R;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+public class LoadMyCameraPropertyFragment extends ListFragment implements ListView.OnItemClickListener
+{
+ private final String TAG = toString();
+ private ILoadSaveMyCameraPropertyDialogDismiss dialogDismiss = null;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+ return (inflater.inflate(R.layout.list_camera_properties, container, false));
+ }
+
+ public void setDismissInterface(ILoadSaveMyCameraPropertyDialogDismiss dismiss)
+ {
+ this.dialogDismiss = dismiss;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState)
+ {
+ super.onActivityCreated(savedInstanceState);
+
+ List<MyCameraPropertySetItems> listItems = new ArrayList<>();
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+ for (int index = 1; index <= LoadSaveCameraProperties.MAX_STORE_PROPERTIES; index++)
+ {
+ String idHeader = String.format(Locale.ENGLISH, "%03d", index);
+ String prefDate = preferences.getString(idHeader + LoadSaveCameraProperties.DATE_KEY, "");
+ if (prefDate.length() <= 0)
+ {
+ //listItems.add(new MyCameraPropertySetItems(0, idHeader, "", ""));
+ break;
+ }
+ String prefTitle = preferences.getString(idHeader + LoadSaveCameraProperties.TITLE_KEY, "");
+ listItems.add(new MyCameraPropertySetItems(0, idHeader, prefTitle, prefDate));
+ }
+
+ //String prefDate = preferences.getString(LoadSaveCameraProperties.DATE_KEY, "");
+ //listItems.add(new MyCameraPropertySetItems(0, "000", getString(R.string.auto_save_props), prefDate));
+
+ MyCameraPropertyLoadArrayAdapter adapter = new MyCameraPropertyLoadArrayAdapter(getActivity(), R.layout.column_load, listItems);
+ setListAdapter(adapter);
+
+ getListView().setOnItemClickListener(this);
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> adapterView, View view, int position, long l)
+ {
+ final MyCameraPropertySetItems item = (MyCameraPropertySetItems) getListAdapter().getItem(position);
+ Log.v(TAG, "onItemClick() : " + position + " [" + item.getItemId() + "] " + item.getItemName() + " (" + item.getItemInfo() + ") " + item.getIconResource() + " ");
+
+ // アイテムを選択して終わらせる
+ if (dialogDismiss != null)
+ {
+ dialogDismiss.doDismissWithPropertyLoad(item.getItemId(), item.getItemName());
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.myolycameraprops;
+
+import android.app.Activity;
+import android.app.ProgressDialog;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.widget.Toast;
+
+import net.osdn.gokigen.a01d.R;
+import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraProperty;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
+
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * カメラプロパティを一括でバックアップしたり、リストアしたりするクラス
+ *
+ */
+public class LoadSaveCameraProperties implements ILoadSaveCameraProperties
+{
+ private final String TAG = toString();
+
+ private final Activity parent;
+ private final IOlyCameraConnection cameraConnection;
+ private final IOlyCameraPropertyProvider propertyProvider;
+
+ public LoadSaveCameraProperties(Activity context, IOlympusInterfaceProvider interfaceProvider)
+ {
+ this.parent = context;
+ this.cameraConnection = interfaceProvider.getOlyCameraConnection();
+ this.propertyProvider = interfaceProvider.getCameraPropertyProvider();
+ }
+
+ /**
+ * カメラの現在の設定を本体から読みだして記憶する
+ *
+ */
+ @Override
+ public void saveCameraSettings(final String idHeader, final String dataName)
+ {
+ Log.v(TAG, "saveCameraSettings() : START [" + idHeader + "], dataName: " + dataName);
+
+ // カメラから設定を一括で読みだして、Preferenceに記録する
+ if (cameraConnection.getConnectionStatus() == IOlyCameraConnection.CameraConnectionStatus.CONNECTED)
+ {
+ //
+ // BUSYダイアログを表示する
+ //
+ final ProgressDialog busyDialog = new ProgressDialog(parent);
+ busyDialog.setMessage(parent.getString(R.string.dialog_start_save_property_message));
+ busyDialog.setTitle(parent.getString(R.string.dialog_start_save_property_title));
+ busyDialog.setIndeterminate(false);
+ busyDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+ busyDialog.show();
+
+ try
+ {
+ Thread thread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ final boolean toast = saveCameraSettingsImpl(idHeader, dataName);
+ busyDialog.dismiss();
+
+ parent.runOnUiThread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ // Toast で保存したよのメッセージを表示
+ if (toast)
+ {
+ String storedMessage = parent.getString(R.string.saved_my_props) + dataName;
+ Toast.makeText(parent, storedMessage, Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+
+ }
+ });
+ thread.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ Log.v(TAG, "PROPERTY STORED : " + idHeader + " " + dataName);
+ }
+ }
+
+ /**
+ * Preferenceにあるカメラの設定をカメラに登録する
+ * (注: Read Onlyなパラメータを登録しようとするとエラーになるので注意)
+ */
+ @Override
+ public void loadCameraSettings(final String idHeader, final String dataName)
+ {
+ Log.v(TAG, "loadCameraSettings() : START [" + idHeader + "], dataName: " + dataName);
+ if (cameraConnection.getConnectionStatus() == IOlyCameraConnection.CameraConnectionStatus.CONNECTED)
+ {
+ //Log.v(TAG, "PROPERTY RESTORE ENTER : (" + id + ") " + name);
+
+ //
+ // BUSYダイアログを表示する
+ //
+ final ProgressDialog busyDialog = new ProgressDialog(parent);
+ busyDialog.setMessage(parent.getString(R.string.dialog_start_load_property_message));
+ busyDialog.setTitle(parent.getString(R.string.dialog_start_load_property_title));
+ busyDialog.setIndeterminate(false);
+ busyDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+ busyDialog.show();
+
+ try
+ {
+ Thread thread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ final boolean toast = loadCameraSettingsSequential(idHeader);
+ busyDialog.dismiss();
+
+ parent.runOnUiThread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ // Toast で展開したよのメッセージを表示
+ if (toast)
+ {
+ String restoredMessage = parent.getString(R.string.restored_my_props) + dataName;
+ Toast.makeText(parent, restoredMessage, Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+ }
+ });
+ thread.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ //Log.v(TAG, "PROPERTY RESTORE EXIT : (" + id + ") " + name);
+ }
+ }
+
+ /**
+ * カメラのプロパティを1つづつ個別設定
+ *
+ */
+ private boolean saveCameraSettingsImpl(String idHeader, String dataName)
+ {
+ boolean ret = false;
+ Map<String, String> values = null;
+ try
+ {
+ values = propertyProvider.getCameraPropertyValues(propertyProvider.getCameraPropertyNames());
+ if (values != null)
+ {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ SharedPreferences.Editor editor = preferences.edit();
+ for (String key : values.keySet())
+ {
+ editor.putString(idHeader + key, values.get(key));
+ //Log.v(TAG, "storeCameraSettings(): " + idHeader + key + " , " + values.get(key));
+ }
+ DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
+ editor.putString(idHeader + DATE_KEY, dateFormat.format(new Date()));
+ editor.putString(idHeader + TITLE_KEY, dataName);
+ //editor.commit();
+ editor.apply();
+
+ ret = true;
+ Log.v(TAG, "storeCameraSettings() COMMITED : " + idHeader + " [" + dataName + "]");
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ ret = false;
+ }
+ return (ret);
+ //Log.v(TAG, "CameraPropertyBackupRestore::storeCameraSettings() : " + idHeader);
+ }
+
+ /**
+ * カメラのプロパティを1つづつ個別設定
+ *
+ */
+ private boolean loadCameraSettingsSequential(String idHeader)
+ {
+ boolean ret = false;
+ int setCount = 0;
+ // Restores my settings.
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ if (cameraConnection.getConnectionStatus() == IOlyCameraConnection.CameraConnectionStatus.CONNECTED)
+ {
+ String takeModeValue = preferences.getString(idHeader + IOlyCameraProperty.TAKE_MODE, null);
+ try
+ {
+ // TAKEMODE だけは先行して設定する(設定できないカメラプロパティもあるので...)
+ if (takeModeValue != null)
+ {
+ propertyProvider.setCameraPropertyValue(IOlyCameraProperty.TAKE_MODE, takeModeValue);
+ Log.v(TAG, "loadCameraSettings() TAKEMODE : " + takeModeValue);
+ setCount++;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ Log.v(TAG, "loadCameraSettings() : loadCameraSettingsSequential() fail...");
+ }
+
+ Set<String> names = propertyProvider.getCameraPropertyNames();
+ for (String name : names)
+ {
+ String value = preferences.getString(idHeader + name, null);
+ if (value != null)
+ {
+ if (propertyProvider.canSetCameraProperty(name))
+ {
+ // Read Onlyのプロパティを除外して登録
+ try
+ {
+ // カメラプロパティを個別登録(全パラメータを一括登録すると何か落ちている
+ Log.v(TAG, "loadCameraSettingsSequential(): " + value);
+ propertyProvider.setCameraPropertyValue(name, value);
+ setCount++;
+ //Thread.sleep(5); // 処理落ちしている?かもしれないので必要なら止める
+ ret = true;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ ret = false;
+ }
+ }
+ }
+ }
+ Log.v(TAG, "loadCameraSettingsSequential() : END [" + idHeader + "]" + " " + setCount);
+ }
+ return (ret);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.myolycameraprops;
+
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTabHost;
+import android.support.v4.view.ViewPager;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TabHost;
+
+import net.osdn.gokigen.a01d.R;
+
+
+public class LoadSaveMyCameraPropertyDialog extends DialogFragment implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener, ILoadSaveMyCameraPropertyDialogDismiss
+{
+ private final String TAG = toString();
+ private ILoadSaveCameraProperties propertyOperations = null;
+ private FragmentTabHost tabHost = null;
+ private ViewPager viewPager = null;
+
+ public void setPropertyOperationsHolder(ILoadSaveCameraProperties holder)
+ {
+ propertyOperations = holder;
+ }
+
+ /**/
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+ try
+ {
+ View view = inflater.inflate(R.layout.dialog_my_camera_properties, container);
+ tabHost = (FragmentTabHost) view.findViewById(R.id.tabHost01);
+ tabHost.setup(getActivity(), getChildFragmentManager());
+ tabHost.addTab(tabHost.newTabSpec("Load").setIndicator(getString(R.string.title_tab_title_load)), Fragment.class, null);
+ tabHost.addTab(tabHost.newTabSpec("Save").setIndicator(getString(R.string.title_tab_title_save)), Fragment.class, null);
+
+ tabHost.setOnTabChangedListener(this);
+
+ LoadSaveMyCameraPropertyPagerAdapter adapter = new LoadSaveMyCameraPropertyPagerAdapter(getChildFragmentManager(), this);
+ adapter.setTitles(new String[]{getString(R.string.title_tab_title_load), getString(R.string.title_tab_title_save)});
+
+ viewPager = (ViewPager) view.findViewById(R.id.pager);
+ viewPager.setAdapter(adapter);
+ //viewPager.setOnPageChangeListener(this);
+ viewPager.addOnPageChangeListener(this);
+
+ getDialog().setTitle(getString(R.string.title_my_settings));
+ return (view);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+
+ }
+
+ @Override
+ public void onTabChanged(String tabId)
+ {
+ Log.v(TAG, "CHANGED TAB : " + tabId);
+
+ int i = tabHost.getCurrentTab();
+ viewPager.setCurrentItem(i);
+ }
+
+ @Override
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+
+ }
+
+ @Override
+ public void onPageSelected(int position)
+ {
+ Log.v(TAG, "CHANGED PAGER : " + position);
+ tabHost.setCurrentTab(position);
+
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int state)
+ {
+
+ }
+
+ @Override
+ public void doDismissWithPropertyLoad(final String id, final String name)
+ {
+ dismiss();
+ if (propertyOperations != null)
+ {
+ propertyOperations.loadCameraSettings(id, name);
+ }
+ }
+
+ @Override
+ public void doDismissWithPropertySave(final String id, final String name)
+ {
+ dismiss();
+ if (propertyOperations != null)
+ {
+ propertyOperations.saveCameraSettings(id, name);
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.myolycameraprops;
+
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.util.Log;
+
+class LoadSaveMyCameraPropertyPagerAdapter extends FragmentPagerAdapter
+{
+ private final String TAG = toString();
+ private final ILoadSaveMyCameraPropertyDialogDismiss dismissInterface;
+
+ private String[] titles = null;
+ private LoadMyCameraPropertyFragment loadFragment = null;
+ private SaveMyCameraPropertyFragment saveFragment = null;
+
+ LoadSaveMyCameraPropertyPagerAdapter(FragmentManager fm, ILoadSaveMyCameraPropertyDialogDismiss dismissInterface)
+ {
+ super(fm);
+ this.dismissInterface = dismissInterface;
+ }
+
+ private void initialize()
+ {
+ loadFragment = null;
+ loadFragment = new LoadMyCameraPropertyFragment();
+ loadFragment.setDismissInterface(dismissInterface);
+
+ saveFragment = null;
+ saveFragment = new SaveMyCameraPropertyFragment();
+ saveFragment.setDismissInterface(dismissInterface);
+ }
+
+ @Override
+ public Fragment getItem(int position)
+ {
+ Log.v(TAG, "getItem :" + position);
+ if ((loadFragment == null)||(saveFragment == null))
+ {
+ initialize();
+ }
+ Fragment returnFragment;
+ if (position == 0)
+ {
+ // loadFragment
+ returnFragment = loadFragment;
+ }
+ else //
+ {
+ // saveFragment
+ returnFragment = saveFragment;
+ }
+ return (returnFragment);
+ }
+
+ @Override
+ public int getCount()
+ {
+ return 2;
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position)
+ {
+ return titles[position];
+ }
+
+ void setTitles(String[] titles)
+ {
+ this.titles = titles;
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.myolycameraprops;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+import java.util.List;
+
+class MyCameraPropertyLoadArrayAdapter extends ArrayAdapter<MyCameraPropertySetItems>
+{
+ private LayoutInflater inflater = null;
+ private final int textViewResourceId;
+ private List<MyCameraPropertySetItems> listItems = null;
+
+ MyCameraPropertyLoadArrayAdapter(Context context, int resource, List<MyCameraPropertySetItems> objects)
+ {
+ super(context, resource, objects);
+ textViewResourceId = resource;
+ listItems = objects;
+
+ inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+ /**
+ *
+ */
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent)
+ {
+ View view;
+ if(convertView != null)
+ {
+ view = convertView;
+ }
+ else
+ {
+ view = inflater.inflate(textViewResourceId, parent, false);
+ }
+ MyCameraPropertySetItems item = listItems.get(position);
+ try
+ {
+ TextView idView = (TextView) view.findViewWithTag("id");
+ idView.setText(item.getItemId());
+
+ TextView titleView = (TextView)view.findViewWithTag("title");
+ titleView.setText(item.getItemName());
+
+ TextView infoView = (TextView) view.findViewWithTag("info");
+ infoView.setText(item.getItemInfo());
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (view);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.myolycameraprops;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import net.osdn.gokigen.a01d.R;
+
+import java.util.List;
+
+class MyCameraPropertySetArrayAdapter extends ArrayAdapter<MyCameraPropertySetItems>
+{
+ private final String TAG = toString();
+ private final Context context;
+ private LayoutInflater inflater = null;
+ private final int textViewResourceId;
+ private List<MyCameraPropertySetItems> listItems = null;
+ private final ILoadSaveMyCameraPropertyDialogDismiss dialogDismiss;
+
+
+ MyCameraPropertySetArrayAdapter(Context context, int resource, List<MyCameraPropertySetItems> objects, ILoadSaveMyCameraPropertyDialogDismiss dialogDismiss)
+ {
+ super(context, resource, objects);
+ this.context = context;
+ textViewResourceId = resource;
+ listItems = objects;
+ this.dialogDismiss = dialogDismiss;
+
+ inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+ /**
+ *
+ */
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent)
+ {
+ View view;
+ if(convertView != null)
+ {
+ view = convertView;
+ }
+ else
+ {
+ view = inflater.inflate(textViewResourceId, parent, false);
+ }
+ try
+ {
+ final MyCameraPropertySetItems item = listItems.get(position);
+
+ TextView idView = (TextView) view.findViewWithTag("id");
+ idView.setText(item.getItemId());
+
+ final EditText titleView = (EditText)view.findViewWithTag("title");
+ titleView.setText(item.getItemName());
+
+ TextView infoView = (TextView) view.findViewWithTag("info");
+ infoView.setText(item.getItemInfo());
+
+ Button button = (Button) view.findViewWithTag("button");
+ button.setOnClickListener(new Button.OnClickListener()
+ {
+ @Override
+ public void onClick(View view)
+ {
+
+ String idHeader = item.getItemId();
+ String title = titleView.getText().toString();
+ String itemInfo = item.getItemInfo();
+
+ Log.v(TAG, "CLICKED : " + idHeader + " " + title + " (" + item.getItemName() + " " + itemInfo + ")" );
+ if (dialogDismiss != null)
+ {
+ dialogDismiss.doDismissWithPropertySave(idHeader, title);
+ }
+ Log.v(TAG, "PROPERTY STORED : " + idHeader + " " + title);
+
+ // Toastで保管したことを通知する
+ String restoredMessage = context.getString(R.string.saved_my_props) + title;
+ Toast.makeText(context, restoredMessage, Toast.LENGTH_SHORT).show();
+
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (view);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.myolycameraprops;
+
+class MyCameraPropertySetItems
+{
+ private final String itemId;
+ private String itemName = "";
+ private String itemInfo = "";
+ private int iconResource = 0;
+
+ MyCameraPropertySetItems(int iconResource, String itemId, String itemName, String itemInfo)
+ {
+ this.iconResource = iconResource;
+ this.itemId = itemId;
+ this.itemName = itemName;
+ this.itemInfo = itemInfo;
+ }
+
+ String getItemId()
+ {
+ return itemId;
+ }
+
+ String getItemName()
+ {
+ return itemName;
+ }
+
+ String getItemInfo()
+ {
+ return itemInfo;
+ }
+
+ int getIconResource()
+ {
+ return iconResource;
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.myolycameraprops;
+
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.support.v4.app.ListFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import net.osdn.gokigen.a01d.R;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+public class SaveMyCameraPropertyFragment extends ListFragment
+{
+ private ILoadSaveMyCameraPropertyDialogDismiss dialogDismiss = null;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+ return (inflater.inflate(R.layout.list_camera_properties, container, false));
+ }
+
+ public void setDismissInterface(ILoadSaveMyCameraPropertyDialogDismiss dismiss)
+ {
+ this.dialogDismiss = dismiss;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState)
+ {
+ super.onActivityCreated(savedInstanceState);
+
+ List<MyCameraPropertySetItems> listItems = new ArrayList<>();
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+ for (int index = 1; index <= LoadSaveCameraProperties.MAX_STORE_PROPERTIES; index++)
+ {
+ String idHeader = String.format(Locale.ENGLISH, "%03d", index);
+ String prefDate = preferences.getString(idHeader + LoadSaveCameraProperties.DATE_KEY, "");
+ if (prefDate.length() <= 0)
+ {
+ listItems.add(new MyCameraPropertySetItems(0, idHeader, "", ""));
+ break;
+ }
+ String prefTitle = preferences.getString(idHeader + LoadSaveCameraProperties.TITLE_KEY, "");
+ listItems.add(new MyCameraPropertySetItems(0, idHeader, prefTitle, prefDate));
+ }
+ MyCameraPropertySetArrayAdapter adapter = new MyCameraPropertySetArrayAdapter(getActivity(), R.layout.column_save, listItems, dialogDismiss);
+ setListAdapter(adapter);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.liveview;
+
+/**
+ * Created by MRSa on 2017/09/09.
+ */
+
+public interface IFavoriteSettingDialogKicker
+{
+ void showFavoriteSettingDialog();
+}
import net.osdn.gokigen.a01d.camera.olympus.operation.ICaptureControl;
import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraInformation;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraProperty;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
private final ICaptureControl captureControl;
private final IOlyCameraPropertyProvider propertyProvider;
private final ICameraInformation cameraInformation;
+ private final IOlyCameraConnection cameraConnection;
+ private final IFavoriteSettingDialogKicker dialogKicker;
- LiveViewClickTouchListener(Context context, ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IOlympusInterfaceProvider interfaceProvider)
+ LiveViewClickTouchListener(Context context, ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IOlympusInterfaceProvider interfaceProvider, IFavoriteSettingDialogKicker dialogKicker)
{
this.context = context;
this.statusNotify = imageStatusNotify;
this.captureControl = interfaceProvider.getCaptureControl();
this.propertyProvider = interfaceProvider.getCameraPropertyProvider();
this.cameraInformation = interfaceProvider.getCameraInformation();
+ this.cameraConnection = interfaceProvider.getOlyCameraConnection();
+ this.dialogKicker = dialogKicker;
}
/**
statusViewDrawer.updateLiveViewScale(true);
break;
+ case R.id.show_favorite_settings_button:
+ // お気に入り設定のダイアログを表示する
+ showFavoriteDialog();
+ break;
+
default:
Log.v(TAG, "onClick() : " + id);
break;
}
/**
+ * お気に入り設定ダイアログの表示
+ *
+ */
+ private void showFavoriteDialog()
+ {
+ Log.v(TAG, "showFavoriteDialog()");
+ try
+ {
+ if (cameraConnection.getConnectionStatus() == IOlyCameraConnection.CameraConnectionStatus.CONNECTED)
+ {
+ // お気に入り設定のダイアログを表示する
+ dialogKicker.showFavoriteSettingDialog();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
* オブジェクトをタッチする処理
*
*/
import net.osdn.gokigen.a01d.R;
import net.osdn.gokigen.a01d.camera.olympus.IOlympusDisplayInjector;
import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.olympus.myolycameraprops.LoadSaveCameraProperties;
+import net.osdn.gokigen.a01d.camera.olympus.myolycameraprops.LoadSaveMyCameraPropertyDialog;
import net.osdn.gokigen.a01d.camera.olympus.operation.ICaptureControl;
import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
import net.osdn.gokigen.a01d.camera.olympus.operation.IZoomLensControl;
* 撮影用ライブビュー画面
*
*/
-public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFocusingModeNotify
+public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFocusingModeNotify, IFavoriteSettingDialogKicker
{
private final String TAG = this.toString();
private static final int COMMAND_MY_PROPERTY = 0x00000100;
}
if (onClickTouchListener == null)
{
- onClickTouchListener = new LiveViewClickTouchListener(this.getContext(), imageView, this, changeScene, interfaceProvider);
+ onClickTouchListener = new LiveViewClickTouchListener(this.getContext(), imageView, this, changeScene, interfaceProvider, this);
}
imageView.setOnClickListener(onClickTouchListener);
imageView.setOnTouchListener(onClickTouchListener);
view.findViewById(R.id.show_preference_button).setOnClickListener(onClickTouchListener);
view.findViewById(R.id.camera_property_settings_button).setOnClickListener(onClickTouchListener);
view.findViewById(R.id.shutter_button).setOnClickListener(onClickTouchListener);
+ view.findViewById(R.id.show_favorite_settings_button).setOnClickListener(onClickTouchListener);
manualFocus = view.findViewById(R.id.focusing_button);
if (manualFocus != null)
statusArea = view.findViewById(R.id.informationMessageTextView);
focalLengthArea = view.findViewById(R.id.focal_length_with_digital_zoom_view);
+
}
catch (Exception e)
{
}
}
+ @Override
+ public void showFavoriteSettingDialog()
+ {
+ Log.v(TAG, "showFavoriteSettingDialog()");
+ LoadSaveMyCameraPropertyDialog dialog = new LoadSaveMyCameraPropertyDialog();
+ dialog.setTargetFragment(this, COMMAND_MY_PROPERTY);
+ dialog.setPropertyOperationsHolder(new LoadSaveCameraProperties(getActivity(), interfaceProvider));
+ dialog.show(getFragmentManager(), "my_dialog");
+ }
+
private void runOnUiThread(Runnable action)
{
Activity activity = getActivity();
--- /dev/null
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M17,3L7,3c-1.1,0 -1.99,0.9 -1.99,2L5,21l7,-3 7,3L19,5c0,-1.1 -0.9,-2 -2,-2zM17,18l-5,-2.18L7,18L7,5h10v13z"/>
+</vector>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal"
+ >
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="26dp"
+ android:layout_height="wrap_content"
+ android:textStyle="normal"
+ android:textSize="6pt"
+ android:clickable="false"
+ android:focusable="false"
+ android:tag="id"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="80dp"
+ android:layout_height="wrap_content"
+ android:textSize="4pt"
+ android:clickable="false"
+ android:focusable="false"
+ android:tag="info"
+ />
+
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textStyle="normal"
+ android:textSize="9pt"
+ android:clickable="false"
+ android:focusable="false"
+ android:tag="title"
+ />
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal"
+ >
+ <TextView
+ android:layout_width="0px"
+ android:layout_height="0px"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="5pt"
+ android:tag="id"
+ />
+ <Button xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:tag="button"
+ android:text="@string/save_props"
+ />
+ <EditText xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="88dp"
+ android:layout_height="wrap_content"
+ android:hint="@string/hint_save_props"
+ android:textSize="8pt"
+ android:tag="title"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="4pt"
+ android:tag="info"
+ />
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+android:layout_height="match_parent"
+android:layout_width="match_parent"
+android:orientation="vertical"
+ >
+<android.support.v4.app.FragmentTabHost
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/tabHost01"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+</android.support.v4.app.FragmentTabHost>
+
+<android.support.v4.view.ViewPager
+ android:id="@+id/pager"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"/>
+</LinearLayout>
android:layout_toRightOf="@id/connect_disconnect_button"
android:layout_toEndOf="@id/connect_disconnect_button"
android:clickable="true"
- android:gravity="start"
+ android:gravity="start|center"
android:text="@string/information"
android:textColor="@color/background_translucent_dark"
- android:textSize="9pt" />
+ android:textSize="8pt" />
<ImageButton
android:id="@+id/camera_property_settings_button"
android:src="@drawable/ic_build_black_24dp"
android:visibility="visible" />
-
<ImageButton
- android:id="@+id/show_hide_grid_button"
+ android:id="@+id/show_favorite_settings_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:layout_alignTop="@id/show_preference_button"
android:layout_toLeftOf="@id/camera_property_settings_button"
android:layout_toStartOf="@id/camera_property_settings_button"
+ android:contentDescription="@string/button"
+ android:src="@drawable/ic_bookmark_border_black_24dp"
+ android:visibility="visible" />
+
+ <ImageButton
+ android:id="@+id/show_hide_grid_button"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:clickable="true"
+ android:gravity="center"
+ android:scaleType="fitCenter"
+ android:layout_alignTop="@id/show_preference_button"
+ android:layout_toLeftOf="@id/show_favorite_settings_button"
+ android:layout_toStartOf="@id/show_favorite_settings_button"
android:contentDescription="@string/grid"
android:src="@drawable/ic_grid_on_black_24dp"
android:visibility="visible" />
-
</RelativeLayout>
</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="vertical"
+ >
+ <ListView
+ android:id="@id/android:list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scrollbars="vertical"
+ android:scrollbarFadeDuration="1000000"/>
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal"
+ >
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="26dp"
+ android:layout_height="wrap_content"
+ android:textStyle="normal"
+ android:textSize="6pt"
+ android:clickable="false"
+ android:focusable="false"
+ android:tag="id"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="80dp"
+ android:layout_height="wrap_content"
+ android:textSize="4pt"
+ android:clickable="false"
+ android:focusable="false"
+ android:tag="info"
+ />
+
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textStyle="normal"
+ android:textSize="9pt"
+ android:clickable="false"
+ android:focusable="false"
+ android:tag="title"
+ />
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal"
+ >
+ <TextView
+ android:layout_width="0px"
+ android:layout_height="0px"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="5pt"
+ android:tag="id"
+ />
+ <Button xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:tag="button"
+ android:text="@string/save_props"
+ />
+ <EditText xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="88dp"
+ android:layout_height="wrap_content"
+ android:hint="@string/hint_save_props"
+ android:textSize="8pt"
+ android:tag="title"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="4pt"
+ android:tag="info"
+ />
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+android:layout_height="match_parent"
+android:layout_width="match_parent"
+android:orientation="vertical"
+ >
+<android.support.v4.app.FragmentTabHost
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/tabHost01"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+</android.support.v4.app.FragmentTabHost>
+
+<android.support.v4.view.ViewPager
+ android:id="@+id/pager"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"/>
+</LinearLayout>
android:layout_height="match_parent"
android:clickable="true"
android:gravity="center"
- android:scaleType="fitCenter"
+ android:scaleType="fitEnd"
android:contentDescription="@string/button"
android:src="@drawable/btn_manual_focus"
android:visibility="visible"
android:layout_toRightOf="@id/connect_disconnect_button"
android:layout_toEndOf="@id/connect_disconnect_button"
android:clickable="true"
- android:gravity="start"
+ android:gravity="start|center"
android:text="@string/information"
android:textColor="@color/background_translucent_dark"
- android:textSize="9pt" />
+ android:textSize="6pt" />
<ImageButton
android:id="@+id/camera_property_settings_button"
android:visibility="visible" />
<ImageButton
- android:id="@+id/show_hide_grid_button"
+ android:id="@+id/show_favorite_settings_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:layout_alignTop="@id/show_preference_button"
android:layout_toLeftOf="@id/camera_property_settings_button"
android:layout_toStartOf="@id/camera_property_settings_button"
+ android:contentDescription="@string/button"
+ android:src="@drawable/ic_bookmark_border_black_24dp"
+ android:visibility="visible" />
+
+ <ImageButton
+ android:id="@+id/show_hide_grid_button"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:clickable="true"
+ android:gravity="center"
+ android:scaleType="fitCenter"
+ android:layout_alignTop="@id/show_preference_button"
+ android:layout_toLeftOf="@id/show_favorite_settings_button"
+ android:layout_toStartOf="@id/show_favorite_settings_button"
android:contentDescription="@string/grid"
android:src="@drawable/ic_grid_on_black_24dp"
android:visibility="visible" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="vertical"
+ >
+ <ListView
+ android:id="@id/android:list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scrollbars="vertical"
+ android:scrollbarFadeDuration="1000000"/>
+</LinearLayout>
<string name="live_view_scale_default">LV : ???</string>
<string name="focal_length_with_digital_zoom_view_default"> </string>
+ <string name="save_props">保存</string>
+ <string name="hint_save_props">ラベル</string>
+ <string name="saved_my_props">設定を保存しました。 : </string>
+
+ <string name="auto_save_props">(自動保存)</string>
+ <string name="title_tab_title_load">設定反映</string>
+ <string name="title_tab_title_save">設定保存</string>
+ <string name="title_my_settings">お気に入りカメラ設定</string>
</resources>
<string name="live_view_scale_default">LV : ???</string>
<string name="focal_length_with_digital_zoom_view_default"> </string>
+ <string name="save_props">Save</string>
+ <string name="hint_save_props">Label</string>
+ <string name="saved_my_props">Saved Property : </string>
+ <string name="auto_save_props">(Auto Save)</string>
+ <string name="title_tab_title_load">Load</string>
+ <string name="title_tab_title_save">Save</string>
+ <string name="title_my_settings">Favorite Camera Properties</string>
+
<string name="connect_start">start</string>
<string name="connect_check_wifi">check WIFI</string>
<string name="connect_connect">connecting</string>
<string name="fatal_cannot_use_camera">The CameraKit SDK can not work because the running mode of camera is UNKNOWN. So please long press the power button of camera more than 8 seconds. (This is the camera reset operation.) After that turn on the camera power again.</string>
<string name="camera_reset_required">The camera reset operation is required.</string>
<string name="camera_disconnected">Disconnected</string>
+
+ <string name="dialog_start_save_property_message">Please Wait</string>
+ <string name="dialog_start_save_property_title">Storing Properties…</string>
+ <string name="dialog_start_load_property_message">Please Wait</string>
+ <string name="dialog_start_load_property_title">Setting Properties…</string>
+ <string name="restored_my_props">Restored Property : </string>
+
</resources>