import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.SparseArrayCompat;
+import androidx.fragment.app.FragmentActivity;
+import net.osdn.gokigen.gr2control.R;
import net.osdn.gokigen.gr2control.camera.ICameraStatus;
import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.FujiXReplyMessageReceiver;
import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandPublisher;
class FujiXStatusHolder
{
private final String TAG = toString();
+ private final FragmentActivity activity;
private final IFujiXCommandPublisher publisher;
private static final boolean logcat = true;
private SparseIntArray statusHolder;
private SparseArrayCompat<String> statusNameArray;
- FujiXStatusHolder(@NonNull IFujiXCommandPublisher publisher)
+ FujiXStatusHolder(@NonNull FragmentActivity activity, @NonNull IFujiXCommandPublisher publisher)
{
statusHolder = new SparseIntArray();
statusHolder.clear();
+ this.activity = activity;
this.publisher = publisher;
statusNameArray = new SparseArrayCompat<>();
prepareStatusNameArray();
switch (current)
{
case IFujiXFilmSimulation.FILM_SIMULATION_PROVIA:
- value = "PROVIA";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_PROVIA_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_VELVIA:
- value = "VELVIA";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_VELVIA_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_ASTIA:
- value = "ASTIA";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_ASTIA_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME:
- value = "MONO";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_SEPIA:
- value = "SEPIA";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_SEPIA_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_HI:
- value = "NEG_HI";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_HI_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_STD:
- value = "NEG_STD";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_STD_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_Y_FILTER:
- value = "MONO_Y";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_Y_FILTER_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_R_FILTER:
- value = "MONO_R";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_R_FILTER_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_G_FILTER:
- value = "MONO_G";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_G_FILTER_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_CHROME:
- value = "CLASSIC CHROME";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_CHROME_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_ACROS:
- value = "ACROS";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_ACROS_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_ACROS_Y:
- value = "ACROS_Y";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_ACROS_Y_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_ACROS_R:
- value = "ACROS_R";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_ACROS_R_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_ACROS_G:
- value = "ACROS_G";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_ACROS_G_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_ETERNA:
- value = "ETERNA";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_STR;
break;
case IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_NEGATIVE:
- value = "CLASSIC NEGATIVE";
+ value = IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_NEGATIVE_STR;
+ break;
+ case IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_BLEACH_BYPASS:
+ value = IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_BLEACH_BYPASS_STR;
break;
default:
value = "??? " + current;
value = "? " + current;
break;
}
- logcat(" Image Aspect : " + value);
+ logcat(" Image Aspect : " + value);
}
String iso = "";
try
{
- iso = "" + (0x0000ffff & current);
+ int isoValue = (0x0000ffff & current);
+ if ((0xffff0000 & current) != 0)
+ {
+ iso = "AUTO_" + isoValue;
+ }
+ else if (isoValue > 12800)
+ {
+ iso = "H" + isoValue;
+
+ }
+ else if (isoValue < 200)
+ {
+ iso = "L" + isoValue;
+ }
+ else
+ {
+ iso = "" + isoValue;
+ }
}
catch (Exception e)
{
e.printStackTrace();
}
+ logcat(" ISO SENSITIVITY : " + iso);
notifier.updateIsoSensitivity(iso);
}
{
mode = mode + current;
}
- logcat(" Focus Mode : " + mode);
+ logcat(" Focus Mode : " + mode);
}
private void updateFocusedStatus(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
// アイテム名の一覧を応答する
return (getAvailableStatusNameList());
}
-
if (listKey.matches(ICameraStatus.EFFECT))
{
return (getAvailableEffectItemList());
}
+ if (listKey.matches(ICameraStatus.AE))
+ {
+ return (new ArrayList<>());
+ }
+ if (listKey.matches(ICameraStatus.WHITE_BALANCE))
+ {
+ return (getAvailableResourceArrayItemList(R.array.fuji_x_white_balance));
+ }
+ if (listKey.matches(ICameraStatus.ISO_SENSITIVITY))
+ {
+ return (getAvailableResourceArrayItemList(R.array.fuji_x_iso_sensitivity));
+ }
+ if (listKey.matches(ICameraStatus.FLASH_XV))
+ {
+ return (getAvailableResourceArrayItemList(R.array.fuji_x_flash_control));
+ }
+ if (listKey.matches(ICameraStatus.SELF_TIMER))
+ {
+ return (getAvailableResourceArrayItemList(R.array.fuji_x_timer_control));
+ }
///// 選択可能なステータスの一覧を取得する : でも以下はアイテム名の一覧... /////
+ /*
ArrayList<String> selection = new ArrayList<>();
try
{
{
e.printStackTrace();
}
- return (selection);
+ */
+ return (new ArrayList<>());
}
private List<String> getAvailableEffectItemList()
selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ACROS_G_STR);
selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_STR);
selection.add(IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_NEGATIVE_STR);
+ selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_BLEACH_BYPASS_STR);
return(selection);
}
+ private List<String> getAvailableResourceArrayItemList(int id)
+ {
+ // リソースのの選択肢をリストにして返す
+ ArrayList<String> selection = new ArrayList<>();
+
+ String[] items = activity.getResources().getStringArray(id);
+ for (String item : items)
+ {
+ Log.v(TAG, " SELECTION : " + item);
+ selection.add(item);
+ }
+ return (selection);
+ }
+
private String getCurrentEffectStatus()
{
// EFFECTの現在状態を応答する : FILM Simulationにした
return ("");
}
+ private String getCurrentWhiteBalanceStatus()
+ {
+ // White Balanceの現在状態を取得する
+ try
+ {
+ int value = statusHolder.get(IFujiXCameraProperties.WHITE_BALANCE);
+ String[] items = activity.getResources().getStringArray(R.array.fuji_x_white_balance);
+ String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_white_balance_value);
+ int index = 0;
+ for (String itemValue : itemValues)
+ {
+ int itemValueInt = Integer.parseInt(itemValue);
+ if (itemValueInt == value)
+ {
+ return (items[index]);
+ }
+ index++;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return ("");
+ }
+
+ private String getCurrentIsoSensitivityStatus()
+ {
+ String iso = "";
+ try
+ {
+ int current = statusHolder.get(IFujiXCameraProperties.ISO);
+ int isoValue = (0x0000ffff & current);
+ if ((0xffff0000 & current) != 0)
+ {
+ iso = "AUTO_" + isoValue;
+ }
+ else if (isoValue > 12800)
+ {
+ iso = "H" + isoValue;
+
+ }
+ else if (isoValue < 200)
+ {
+ iso = "L" + isoValue;
+ }
+ else
+ {
+ iso = "" + isoValue;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ logcat(" ISO SENSITIVITY : " + iso);
+ return (iso);
+ }
+
+ private String getCurrentFlashStatus()
+ {
+ String flash = "";
+ try
+ {
+ int current = statusHolder.get(IFujiXCameraProperties.FLASH);
+ String[] items = activity.getResources().getStringArray(R.array.fuji_x_flash_control);
+ String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_flash_control_value);
+ int index = 0;
+ for (String itemValue : itemValues)
+ {
+ int itemValueInt = Integer.parseInt(itemValue, 16);
+ if (itemValueInt == current)
+ {
+ return (items[index]);
+ }
+ index++;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (flash);
+ }
+
+ private String getCurrentSelfTimerStatus()
+ {
+ String selfTimer = "";
+ try
+ {
+ int current = statusHolder.get(IFujiXCameraProperties.SELF_TIMER);
+ String[] items = activity.getResources().getStringArray(R.array.fuji_x_timer_control);
+ String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_timer_control_value);
+ int index = 0;
+ for (String itemValue : itemValues)
+ {
+ int itemValueInt = Integer.parseInt(itemValue, 16);
+ if (itemValueInt == current)
+ {
+ return (items[index]);
+ }
+ index++;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (selfTimer);
+ }
+
private void setEffectItem(String value)
{
try
}
}
+ private void setCurrentWhiteBalanceStatus(String value)
+ {
+ // White Balanceを設定する
+ try
+ {
+ String[] items = activity.getResources().getStringArray(R.array.fuji_x_white_balance);
+ String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_white_balance_value);
+ int index = 0;
+ for (String item : items)
+ {
+ if (item.matches(value))
+ {
+ // 見つかった! この値を設定する
+ String itemValue = itemValues[index];
+ int itemValueInt = Integer.parseInt(itemValue);
+ publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyMessageReceiver(" Set White Balance", true), IFujiXCameraProperties.WHITE_BALANCE, 4, itemValueInt));
+ return;
+ }
+ index++;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private void setCurrentIsoSensitivityStatus(String value)
+ {
+ // ISO感度を設定する
+ try
+ {
+ String[] items = activity.getResources().getStringArray(R.array.fuji_x_iso_sensitivity);
+ String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_iso_sensitivity_value);
+ int index = 0;
+ for (String item : items)
+ {
+ //Log.v(TAG, " ===== ISO : " + value + " " + item + " ===== ");
+ if (item.matches(value))
+ {
+ // 見つかった! この値を設定する
+ String itemValue = itemValues[index];
+ int itemValueInt = (int) Long.parseLong(itemValue,16);
+ logcat(" SET ISO SENSITIVITY : " + value + " " + itemValueInt);
+ publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyMessageReceiver(" Set ISO", true), IFujiXCameraProperties.ISO, 4, itemValueInt));
+ return;
+ }
+ index++;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private void setCurrentFlashStatus(String value)
+ {
+ // ISO感度を設定する
+ try
+ {
+ String[] items = activity.getResources().getStringArray(R.array.fuji_x_flash_control);
+ String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_flash_control_value);
+ int index = 0;
+ for (String item : items)
+ {
+ Log.v(TAG, " ===== FLASH : " + value + " " + item + " ===== ");
+ if (item.matches(value))
+ {
+ // 見つかった! この値を設定する
+ String itemValue = itemValues[index];
+ int itemValueInt = (int) Long.parseLong(itemValue,16);
+ logcat(" SET FLASH : " + value + " " + itemValueInt);
+ publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyMessageReceiver(" Set FLASH", true), IFujiXCameraProperties.FLASH, 4, itemValueInt));
+ return;
+ }
+ index++;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private void setSelfTimerStatus(String value)
+ {
+ // セルフタイマーを設定する
+ try
+ {
+ String[] items = activity.getResources().getStringArray(R.array.fuji_x_timer_control);
+ String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_timer_control_value);
+ int index = 0;
+ for (String item : items)
+ {
+ Log.v(TAG, " ===== SELF-TIMER : " + value + " " + item + " ===== ");
+ if (item.matches(value))
+ {
+ // 見つかった! この値を設定する
+ String itemValue = itemValues[index];
+ int itemValueInt = (int) Long.parseLong(itemValue,16);
+ logcat(" SET SELF-TIMER : " + value + " " + itemValueInt);
+ publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyMessageReceiver(" Set SELF-TIMER", true), IFujiXCameraProperties.SELF_TIMER, 4, itemValueInt));
+ return;
+ }
+ index++;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
String getItemStatus(String key)
{
{
return (getCurrentEffectStatus());
}
+ if (key.matches(ICameraStatus.WHITE_BALANCE))
+ {
+ return (getCurrentWhiteBalanceStatus());
+ }
+ if (key.matches(ICameraStatus.ISO_SENSITIVITY))
+ {
+ return (getCurrentIsoSensitivityStatus());
+ }
+ if (key.matches(ICameraStatus.FLASH_XV))
+ {
+ return (getCurrentFlashStatus());
+ }
+ if (key.matches(ICameraStatus.SELF_TIMER))
+ {
+ return (getCurrentSelfTimerStatus());
+ }
+ if (key.matches(ICameraStatus.TAKE_MODE))
+ {
+ return ("");
+ }
try
{
int strIndex = key.indexOf("x");
{
try
{
- if (logcat)
- {
- Log.v(TAG, "setStatus(" + key + ", " + value + ")");
- }
-
+ logcat(" setStatus(" + key + ", " + value + ")");
if (key.matches(ICameraStatus.EFFECT))
{
setEffectItem(value);
- return;
}
-
- // ここで設定を行う。
+ else if (key.matches(ICameraStatus.WHITE_BALANCE))
+ {
+ setCurrentWhiteBalanceStatus(value);
+ }
+ else if (key.matches(ICameraStatus.ISO_SENSITIVITY))
+ {
+ setCurrentIsoSensitivityStatus(value);
+ }
+ else if (key.matches(ICameraStatus.FLASH_XV))
+ {
+ setCurrentFlashStatus(value);
+ }
+ else if (key.matches(ICameraStatus.SELF_TIMER))
+ {
+ setSelfTimerStatus(value);
+ }
+ // その他の設定...
}
catch (Exception e)
{
}
}
-
private void dumpStatus()
{
try