OSDN Git Service

SDK更新に対応。
authorMRSa <mrsa@myad.jp>
Sun, 23 Apr 2023 12:44:34 +0000 (21:44 +0900)
committerMRSa <mrsa@myad.jp>
Sun, 23 Apr 2023 12:44:34 +0000 (21:44 +0900)
16 files changed:
.idea/compiler.xml
.idea/deploymentTargetDropDown.xml [new file with mode: 0644]
.idea/gradle.xml
.idea/kotlinc.xml [new file with mode: 0644]
.idea/misc.xml
app/build.gradle
app/src/main/AndroidManifest.xml
app/src/main/java/net/osdn/gokigen/pkremote/MainActivity.java [deleted file]
app/src/main/java/net/osdn/gokigen/pkremote/MainActivity.kt [new file with mode: 0644]
app/src/main/res/values-ja/strings.xml
app/src/main/res/values/colors.xml
app/src/main/res/values/strings.xml
app/src/main/res/values/themes.xml [new file with mode: 0644]
build.gradle
gradle.properties
gradle/wrapper/gradle-wrapper.properties

index fb7f4a8..b589d56 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="CompilerConfiguration">
-    <bytecodeTargetLevel target="11" />
+    <bytecodeTargetLevel target="17" />
   </component>
 </project>
\ No newline at end of file
diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
new file mode 100644 (file)
index 0000000..6b217bd
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="deploymentTargetDropDown">
+    <runningDeviceTargetSelectedWithDropDown>
+      <Target>
+        <type value="RUNNING_DEVICE_TARGET" />
+        <deviceKey>
+          <Key>
+            <type value="SERIAL_NUMBER" />
+            <value value="3e50111c1220" />
+          </Key>
+        </deviceKey>
+      </Target>
+    </runningDeviceTargetSelectedWithDropDown>
+    <timeTargetWasSelectedWithDropDown value="2023-04-23T11:32:00.727128Z" />
+  </component>
+</project>
\ No newline at end of file
index 4404972..93512f7 100644 (file)
@@ -8,13 +8,13 @@
         <option name="testRunner" value="GRADLE" />
         <option name="distributionType" value="DEFAULT_WRAPPED" />
         <option name="externalProjectPath" value="$PROJECT_DIR$" />
+        <option name="gradleJvm" value="Embedded JDK" />
         <option name="modules">
           <set>
             <option value="$PROJECT_DIR$" />
             <option value="$PROJECT_DIR$/app" />
           </set>
         </option>
-        <option name="resolveModulePerSourceSet" value="false" />
       </GradleProjectSettings>
     </option>
   </component>
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644 (file)
index 0000000..69e8615
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="KotlinJpsPluginSettings">
+    <option name="version" value="1.8.20" />
+  </component>
+</project>
\ No newline at end of file
index b9d1ffe..8aec3db 100644 (file)
@@ -74,7 +74,7 @@
       <textMaps />
     </LinkMapSettings>
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/classes" />
   </component>
   <component name="ProjectType">
index d211dd5..8520951 100644 (file)
@@ -2,13 +2,14 @@ apply plugin: 'com.android.application'
 apply plugin: 'kotlin-android'
 
 android {
-    compileSdkVersion 32
+    compileSdkVersion 33
     defaultConfig {
         applicationId "net.osdn.gokigen.pkremote"
         minSdkVersion 14
-        targetSdkVersion 32
-        versionCode 10802
-        versionName "1.8.2"
+        targetSdkVersion 33
+        versionCode 10803
+        versionName "1.8.3"
+        multiDexEnabled true
     }
     buildTypes {
         release {
@@ -16,21 +17,30 @@ android {
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
     }
+    compileOptions {
+        //sourceCompatibility JavaVersion.VERSION_1_8
+        //targetCompatibility JavaVersion.VERSION_1_8
+        sourceCompatibility JavaVersion.VERSION_17
+        targetCompatibility JavaVersion.VERSION_17
+    }
+    namespace 'net.osdn.gokigen.pkremote'
 }
 
 dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar'])
-    implementation 'androidx.appcompat:appcompat:1.4.1'
-    implementation 'androidx.exifinterface:exifinterface:1.3.3'
+    implementation 'androidx.appcompat:appcompat:1.6.1'
+    implementation 'androidx.exifinterface:exifinterface:1.3.6'
     implementation 'androidx.preference:preference-ktx:1.2.0'
-    implementation 'com.google.android.material:material:1.5.0'
-    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
+    implementation 'com.google.android.material:material:1.8.0'
+    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
     implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
+    //implementation "androidx.core:core-splashscreen:1.0.1"
 
     api files('libs/olycamerakit.jar')
-    implementation "androidx.core:core-ktx:1.7.0"
-    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
+    implementation "androidx.core:core-ktx:1.10.0"
+    //implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
 }
 repositories {
+    google()
     mavenCentral()
 }
index a3401c1..0e8b572 100644 (file)
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:dist="http://schemas.android.com/apk/distribution"
-    package="net.osdn.gokigen.pkremote">
+    xmlns:dist="http://schemas.android.com/apk/distribution">
 
     <dist:module dist:instant="true" />
 
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/MainActivity.java b/app/src/main/java/net/osdn/gokigen/pkremote/MainActivity.java
deleted file mode 100644 (file)
index 45b99b7..0000000
+++ /dev/null
@@ -1,443 +0,0 @@
-package net.osdn.gokigen.pkremote;
-
-import android.Manifest;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.os.Bundle;
-
-import androidx.annotation.NonNull;
-
-import com.google.android.material.bottomnavigation.BottomNavigationView;
-
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.ActionBar;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.app.ActivityCompat;
-import androidx.core.content.ContextCompat;
-import androidx.preference.PreferenceManager;
-
-import android.os.Vibrator;
-import android.util.Log;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.WindowManager;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ImageButton;
-import android.widget.Spinner;
-import android.widget.TextView;
-
-import net.osdn.gokigen.pkremote.camera.CameraInterfaceProvider;
-import net.osdn.gokigen.pkremote.camera.interfaces.IInterfaceProvider;
-import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection;
-import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
-import net.osdn.gokigen.pkremote.scene.CameraSceneUpdater;
-
-/**
- *
- *
- */
-public class MainActivity extends AppCompatActivity implements View.OnClickListener, IInformationReceiver, ICardSlotSelector, AdapterView.OnItemSelectedListener
-{
-    private final String TAG = toString();
-    private IInterfaceProvider interfaceProvider = null;
-    private CameraSceneUpdater scenceUpdater = null;
-
-    private ImageButton mImageConnectButton = null;
-    private ImageButton mReloadButton = null;
-    private Spinner mCardSlotSelection = null;
-    private ICardSlotSelectionReceiver slotSelectionReceiver = null;
-    //private TextView mTextMessage = null;
-
-    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
-            = new BottomNavigationView.OnNavigationItemSelectedListener() {
-
-        @Override
-        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
-            switch (item.getItemId()) {
-                case R.id.navigation_photo_library:
-                    scenceUpdater.changeScenceToImageList();
-                    return (true);
-                case R.id.navigation_calendar:
-                    scenceUpdater.changeSceneToCalendar();
-                    return (true);
-                case R.id.navigation_auto_transfer:
-                    scenceUpdater.changeSceneToAutoTransfer();
-                    return (true);
-                case R.id.navigation_settings:
-                    scenceUpdater.changeSceneToConfiguration();
-                    return (true);
-            }
-            return (false);
-        }
-    };
-
-    /**
-     *
-     *
-     */
-    @Override
-    public void onBackPressed()
-    {
-        //Log.v(TAG, "onBackPressed()");
-        super.onBackPressed();
-        runOnUiThread(new Runnable() {
-            @Override
-            public void run()
-            {
-                if (scenceUpdater != null)
-                {
-                    scenceUpdater.updateBottomNavigationMenu();
-                }
-            }
-        });
-    }
-
-    /**
-     *
-     *
-     */
-    @Override
-    protected void onCreate(Bundle savedInstanceState)
-    {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_main);
-        try
-        {
-            ActionBar bar = getSupportActionBar();
-            if (bar != null)
-            {
-                // タイトルバーは表示しない
-                bar.hide();
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
-
-        //mTextMessage = findViewById(R.id.message);
-        mImageConnectButton = findViewById(R.id.button_wifi_connect);
-        mReloadButton = findViewById(R.id.button_reload);
-        mCardSlotSelection = findViewById(R.id.card_slot_selection);
-
-        BottomNavigationView navigation = findViewById(R.id.navigation);
-        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
-
-        // パーミッション群のオプトイン
-        final int REQUEST_NEED_PERMISSIONS = 1010;
-
-        if ((ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) ||
-                (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) ||
-                (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_MEDIA_LOCATION) != PackageManager.PERMISSION_GRANTED) ||
-                (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_NETWORK_STATE) != PackageManager.PERMISSION_GRANTED) ||
-                (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED) ||
-                (ContextCompat.checkSelfPermission(this, Manifest.permission.VIBRATE) != PackageManager.PERMISSION_GRANTED) ||
-                (ContextCompat.checkSelfPermission(this, Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED)) {
-            ActivityCompat.requestPermissions(this,
-                    new String[]{
-                            Manifest.permission.WRITE_EXTERNAL_STORAGE,
-                            Manifest.permission.READ_EXTERNAL_STORAGE,
-                            Manifest.permission.ACCESS_MEDIA_LOCATION,
-                            Manifest.permission.ACCESS_NETWORK_STATE,
-                            Manifest.permission.ACCESS_WIFI_STATE,
-                            Manifest.permission.VIBRATE,
-                            Manifest.permission.INTERNET,
-                    },
-                    REQUEST_NEED_PERMISSIONS);
-        }
-        initializeClass();
-        prepareClass();
-        onReadyClass();
-    }
-
-    /**
-     * パーミッション設定が終わった後...
-     */
-    @Override
-    public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults)
-    {
-        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
-        prepareClass();
-        onReadyClass();
-    }
-
-    /**
-     *
-     */
-    @Override
-    protected void onPause()
-    {
-        super.onPause();
-        try
-        {
-            ICameraConnection connection = interfaceProvider.getCameraConnection();
-            if (connection != null)
-            {
-                connection.stopWatchWifiStatus(this);
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * クラスの初期化 (instantiate)
-     */
-    private void initializeClass()
-    {
-        try
-        {
-            scenceUpdater = CameraSceneUpdater.newInstance(this);
-            interfaceProvider = CameraInterfaceProvider.newInstance(this, scenceUpdater, this, this);
-            scenceUpdater.changeFirstFragment(interfaceProvider);
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * 本クラスの準備
-     */
-    private void prepareClass()
-    {
-        try
-        {
-            mImageConnectButton.setOnClickListener(this);
-            mReloadButton.setOnClickListener(this);
-            setupCardSlotSelection(interfaceProvider.getCammeraConnectionMethod() == ICameraConnection.CameraConnectionMethod.PANASONIC);
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    private void setupCardSlotSelection(boolean isEnabled)
-    {
-        try
-        {
-            if (mCardSlotSelection == null)
-            {
-                mCardSlotSelection = findViewById(R.id.card_slot_selection);
-            }
-            if (isEnabled)
-            {
-                // 接続モードが Panasonic の時だけ、SD Card 選択を出せるようにする
-                mCardSlotSelection.setVisibility(View.VISIBLE);
-                ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.sd_card_slot, android.R.layout.simple_spinner_item);
-                adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
-                mCardSlotSelection.setAdapter(adapter);
-                mCardSlotSelection.setOnItemSelectedListener(this);
-            }
-            else
-            {
-                mCardSlotSelection.setVisibility(View.GONE);
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-
-
-    /**
-     * 初期化終了時の処理 (カメラへの自動接続)
-     */
-    private void onReadyClass()
-    {
-        try
-        {
-            // カメラに自動接続するかどうか確認
-            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
-            boolean isAutoConnectCamera = preferences.getBoolean(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true);
-            Log.v(TAG, "isAutoConnectCamera() : " + isAutoConnectCamera);
-
-            // カメラに接続する
-            if (isAutoConnectCamera)
-            {
-                // 自動接続の指示があったとき
-                scenceUpdater.changeCameraConnection();
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    @Override
-    public void onClick(View v)
-    {
-        try
-        {
-            int id = v.getId();
-            switch (id)
-            {
-                case R.id.button_wifi_connect:
-                    // カメラとの接続を行う
-                    scenceUpdater.changeCameraConnection();
-                    vibrate();
-                    break;
-
-                case R.id.button_reload:
-                    // 画像一覧情報をリロードする
-                    scenceUpdater.reloadRemoteImageContents();
-                    vibrate();
-                    break;
-
-                default:
-                    break;
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     *
-     *
-     */
-    private void vibrate()
-    {
-        try {
-            Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
-            if (vibrator != null)
-            {
-                vibrator.vibrate(50);
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-
-    @Override
-    public void updateMessage(final String message, final boolean isBold, final boolean isColor,  final int color)
-    {
-        try {
-            final TextView messageArea = findViewById(R.id.message);
-            runOnUiThread(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        if ((messageArea != null) && (message != null))
-                        {
-                            messageArea.setText(message);
-                            if (isBold)
-                            {
-                                messageArea.setTypeface(Typeface.DEFAULT_BOLD);
-                            }
-                            if (isColor)
-                            {
-                                messageArea.setTextColor(color);
-                            }
-                            else
-                            {
-                                messageArea.setTextColor(Color.DKGRAY);
-                            }
-                            messageArea.invalidate();
-                        }
-                    }
-                    catch (Exception e)
-                    {
-                        e.printStackTrace();
-                    }
-                }
-            });
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    @Override
-    public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
-    {
-        try
-        {
-            String item = (String) parent.getItemAtPosition(position);
-            Log.v(TAG, " onItemSelected : " +  item);
-            if ((slotSelectionReceiver != null)&&(item != null))
-            {
-                slotSelectionReceiver.slotSelected(item);
-            }
-            // vibrate();
-            // scenceUpdater.reloadRemoteImageContents();
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    @Override
-    public void onNothingSelected(AdapterView<?> parent)
-    {
-        // 何もしない
-    }
-
-    @Override
-    public void setupSlotSelector(final boolean isEnable, @Nullable ICardSlotSelectionReceiver slotSelectionReceiver)
-    {
-        try
-        {
-            Log.v(TAG, "  ------- setupSlotSelector " + isEnable);
-            this.slotSelectionReceiver = slotSelectionReceiver;
-            runOnUiThread(new Runnable() {
-                @Override
-                public void run()
-                {
-                    setupCardSlotSelection(isEnable);
-                }
-            });
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    @Override
-    public void selectSlot(@NonNull String slotId)
-    {
-        try
-        {
-            Log.v(TAG, " selectSlot : " + slotId);
-
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    @Override
-    public void changedCardSlot(@NonNull String slotId)
-    {
-        try
-        {
-            Log.v(TAG, " changedCardSlot : " + slotId);
-            scenceUpdater.reloadRemoteImageContents();
-            vibrate();
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-}
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/MainActivity.kt b/app/src/main/java/net/osdn/gokigen/pkremote/MainActivity.kt
new file mode 100644 (file)
index 0000000..11b1e79
--- /dev/null
@@ -0,0 +1,466 @@
+package net.osdn.gokigen.pkremote
+
+import android.Manifest
+import android.content.pm.PackageManager
+import android.graphics.Color
+import android.graphics.Typeface
+import android.os.Build
+import android.os.Bundle
+import android.os.VibrationEffect
+import android.os.Vibrator
+import android.os.VibratorManager
+import android.util.Log
+import android.view.View
+import android.view.WindowManager
+import android.widget.AdapterView
+import android.widget.ArrayAdapter
+import android.widget.ImageButton
+import android.widget.Spinner
+import android.widget.TextView
+import android.widget.Toast
+import androidx.appcompat.app.AppCompatActivity
+import androidx.core.app.ActivityCompat
+import androidx.core.content.ContextCompat
+import androidx.preference.PreferenceManager
+import com.google.android.material.navigation.NavigationBarView
+import net.osdn.gokigen.pkremote.camera.CameraInterfaceProvider
+import net.osdn.gokigen.pkremote.camera.interfaces.IInterfaceProvider
+import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection
+import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusReceiver
+import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor
+import net.osdn.gokigen.pkremote.scene.CameraSceneUpdater
+
+/**
+ *
+ *
+ */
+class MainActivity : AppCompatActivity(),
+    View.OnClickListener,
+    IInformationReceiver,
+    ICardSlotSelector,
+    AdapterView.OnItemSelectedListener
+{
+    private var interfaceProvider: IInterfaceProvider? = null
+    private var scenceUpdater: CameraSceneUpdater? = null
+    private var mImageConnectButton: ImageButton? = null
+    private var mReloadButton: ImageButton? = null
+    private var mCardSlotSelection: Spinner? = null
+    private var slotSelectionReceiver: ICardSlotSelectionReceiver? = null
+
+    private val mOnNavigationItemSelectedListener =
+        NavigationBarView.OnItemSelectedListener { item ->
+        //BottomNavigationView.OnNavigationItemSelectedListener { item ->
+            when (item.itemId) {
+                R.id.navigation_photo_library -> {
+                    scenceUpdater?.changeScenceToImageList()
+                    return@OnItemSelectedListener true
+                }
+
+                R.id.navigation_calendar -> {
+                    scenceUpdater?.changeSceneToCalendar()
+                    return@OnItemSelectedListener true
+                }
+
+                R.id.navigation_auto_transfer -> {
+                    scenceUpdater?.changeSceneToAutoTransfer()
+                    return@OnItemSelectedListener true
+                }
+
+                R.id.navigation_settings -> {
+                    scenceUpdater?.changeSceneToConfiguration()
+                    return@OnItemSelectedListener true
+                }
+            }
+            false
+        }
+
+    /**
+     *
+     *
+     */
+    override fun onBackPressed()
+    {
+        //Log.v(TAG, "onBackPressed()");
+        super.onBackPressed()
+        runOnUiThread { scenceUpdater?.updateBottomNavigationMenu() }
+    }
+
+    /**
+     *
+     *
+     */
+    override fun onCreate(savedInstanceState: Bundle?)
+    {
+        ///////// SHOW SPLASH SCREEN /////////
+        //installSplashScreen()
+        Log.v(TAG, " ----- onCreate() -----")
+
+        super.onCreate(savedInstanceState)
+        setContentView(R.layout.activity_main)
+
+        supportActionBar?.hide()
+        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
+
+        try
+        {
+            mImageConnectButton = findViewById(R.id.button_wifi_connect)
+            mReloadButton = findViewById(R.id.button_reload)
+            mCardSlotSelection = findViewById(R.id.card_slot_selection)
+            //val navigation = findViewById<BottomNavigationView>(R.id.navigation)
+            //navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
+            val navigation = findViewById<NavigationBarView>(R.id.navigation)
+            navigation.setOnItemSelectedListener(mOnNavigationItemSelectedListener)
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+
+        try
+        {
+            initializeClass()
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+
+        if (allPermissionsGranted())
+        {
+            Log.v(TAG, "allPermissionsGranted() : true")
+            prepareClass()
+            onReadyClass()
+        }
+        else
+        {
+            Log.v(TAG, "====== REQUEST PERMISSIONS ======")
+            ActivityCompat.requestPermissions(this, REQUIRED_PERMISSIONS, REQUEST_CODE_PERMISSIONS)
+        }
+    }
+
+    private fun allPermissionsGranted() = REQUIRED_PERMISSIONS.all {
+        ContextCompat.checkSelfPermission(baseContext, it) == PackageManager.PERMISSION_GRANTED
+    }
+
+    /**
+     * パーミッション設定が終わった後...
+     */
+    override fun onRequestPermissionsResult(
+        requestCode: Int,
+        permissions: Array<String>,
+        grantResults: IntArray
+    ) {
+        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
+        Log.v(TAG, "------------------------- onRequestPermissionsResult() ")
+        if (requestCode == REQUEST_CODE_PERMISSIONS)
+        {
+            if (allPermissionsGranted())
+            {
+                prepareClass()
+                onReadyClass()
+            }
+            else
+            {
+                Log.v(TAG, "----- onRequestPermissionsResult() : false")
+                Toast.makeText(this, getString(R.string.permission_not_granted), Toast.LENGTH_SHORT).show()
+                //Snackbar.make(main_layout,"Permissions not granted by the user.", Snackbar.LENGTH_SHORT).show()
+                finish()
+            }
+        }
+    }
+
+    /**
+     *
+     */
+    override fun onPause()
+    {
+        super.onPause()
+        try
+        {
+            val connection = interfaceProvider?.cameraConnection
+            connection?.stopWatchWifiStatus(this)
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    /**
+     * クラスの初期化 (instantiate)
+     */
+    private fun initializeClass()
+    {
+        try
+        {
+            scenceUpdater = CameraSceneUpdater.newInstance(this)
+            if (scenceUpdater != null)
+            {
+                val scene : ICameraStatusReceiver = scenceUpdater as CameraSceneUpdater
+                interfaceProvider = CameraInterfaceProvider.newInstance(this, scene, this, this)
+                val provider = interfaceProvider as IInterfaceProvider
+                scenceUpdater?.changeFirstFragment(provider)
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    /**
+     * 本クラスの準備
+     */
+    private fun prepareClass()
+    {
+        try
+        {
+            Log.v(TAG, "prepareClass()")
+            mImageConnectButton?.setOnClickListener(this)
+            mReloadButton?.setOnClickListener(this)
+            setupCardSlotSelection(interfaceProvider?.cammeraConnectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    private fun setupCardSlotSelection(isEnabled: Boolean)
+    {
+        try
+        {
+            if (mCardSlotSelection == null)
+            {
+                mCardSlotSelection = findViewById(R.id.card_slot_selection)
+            }
+            if (isEnabled)
+            {
+                // 接続モードが Panasonic の時だけ、SD Card 選択を出せるようにする
+                mCardSlotSelection?.visibility = View.VISIBLE
+                val adapter = ArrayAdapter.createFromResource(
+                    this,
+                    R.array.sd_card_slot,
+                    android.R.layout.simple_spinner_item
+                )
+                adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
+                mCardSlotSelection?.adapter = adapter
+                mCardSlotSelection?.onItemSelectedListener = this
+            }
+            else
+            {
+                mCardSlotSelection?.visibility = View.GONE
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    /**
+     * 初期化終了時の処理 (カメラへの自動接続)
+     */
+    private fun onReadyClass()
+    {
+        try
+        {
+            // カメラに自動接続するかどうか確認
+            val preferences = PreferenceManager.getDefaultSharedPreferences(this)
+            val isAutoConnectCamera =
+                preferences.getBoolean(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true)
+            Log.v(TAG, "isAutoConnectCamera() : $isAutoConnectCamera")
+
+            // カメラに接続する
+            if (isAutoConnectCamera)
+            {
+                // 自動接続の指示があったとき
+                scenceUpdater?.changeCameraConnection()
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    override fun onClick(v: View)
+    {
+        try
+        {
+            when (v.id)
+            {
+                R.id.button_wifi_connect -> {
+                    // カメラとの接続を行う
+                    scenceUpdater?.changeCameraConnection()
+                    vibrate()
+                }
+
+                R.id.button_reload -> {
+                    // 画像一覧情報をリロードする
+                    scenceUpdater?.reloadRemoteImageContents()
+                    vibrate()
+                }
+
+                else -> {}
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    /**
+     *
+     *
+     */
+    private fun vibrate()
+    {
+        try
+        {
+            // バイブレータをつかまえる
+            val vibrator  = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
+            {
+                val vibratorManager =  this.getSystemService(VIBRATOR_MANAGER_SERVICE) as VibratorManager
+                vibratorManager.defaultVibrator
+            }
+            else
+            {
+                @Suppress("DEPRECATION")
+                getSystemService(VIBRATOR_SERVICE) as Vibrator
+            }
+            if (!vibrator.hasVibrator())
+            {
+                // バイブレータが搭載されていないとき...
+                Log.v(TAG, " not have Vibrator...")
+                return
+            }
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
+            {
+                vibrator.vibrate(VibrationEffect.createOneShot(50, VibrationEffect.DEFAULT_AMPLITUDE))
+            }
+            else
+            {
+                @Suppress("DEPRECATION")
+                vibrator.vibrate(50)
+            }
+         }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    override fun updateMessage(message: String, isBold: Boolean, isColor: Boolean, color: Int)
+    {
+        try
+        {
+            val messageArea = findViewById<TextView>(R.id.message)
+            runOnUiThread {
+                try
+                {
+                    messageArea.text = message
+                    if (isBold) {
+                        messageArea.typeface = Typeface.DEFAULT_BOLD
+                    }
+                    if (isColor) {
+                        messageArea.setTextColor(color)
+                    } else {
+                        messageArea.setTextColor(Color.DKGRAY)
+                    }
+                    messageArea.invalidate()
+                }
+                catch (e: Exception)
+                {
+                    e.printStackTrace()
+                }
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long)
+    {
+        try
+        {
+            val item = parent.getItemAtPosition(position) as String
+            slotSelectionReceiver?.slotSelected(item)
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    override fun onNothingSelected(parent: AdapterView<*>?)
+    {
+        // 何もしない
+    }
+
+    override fun setupSlotSelector(
+        isEnable: Boolean,
+        slotSelectionReceiver: ICardSlotSelectionReceiver?
+    )
+    {
+        try
+        {
+            Log.v(TAG, "  ------- setupSlotSelector $isEnable")
+            this.slotSelectionReceiver = slotSelectionReceiver
+            runOnUiThread { setupCardSlotSelection(isEnable) }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    override fun selectSlot(slotId: String)
+    {
+        try
+        {
+            Log.v(TAG, " selectSlot : $slotId")
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    override fun changedCardSlot(slotId: String)
+    {
+        try
+        {
+            Log.v(TAG, " changedCardSlot : $slotId")
+            scenceUpdater?.reloadRemoteImageContents()
+            vibrate()
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    companion object
+    {
+        private val TAG = MainActivity::class.java.simpleName
+
+        private const val REQUEST_CODE_PERMISSIONS = 10
+        //const val REQUEST_CODE_MEDIA_EDIT = 12
+        //const val REQUEST_CODE_OPEN_DOCUMENT_TREE = 20
+
+        private val REQUIRED_PERMISSIONS = arrayOf(
+            Manifest.permission.INTERNET,
+            Manifest.permission.VIBRATE,
+            Manifest.permission.WRITE_EXTERNAL_STORAGE,
+            Manifest.permission.READ_EXTERNAL_STORAGE,
+            Manifest.permission.ACCESS_MEDIA_LOCATION,
+            Manifest.permission.ACCESS_NETWORK_STATE,
+            Manifest.permission.ACCESS_WIFI_STATE,
+            //Manifest.permission.CHANGE_WIFI_MULTICAST_STATE,
+        )
+    }
+}
index e0931e3..854c30d 100644 (file)
@@ -15,7 +15,7 @@
     <string name="title_settings">設定</string>
     <string name="title_photo_library">画像</string>
     <string name="title_auto_transfer">自動転送</string>
-
+    <string name="permission_not_granted">ユーザの許可が得られませんでしたので終了します。</string>
 
     <string name="dialog_title_confirmation">確認</string>
     <string name="dialog_positive_execute">OK</string>
index a521896..57d8356 100644 (file)
@@ -2,8 +2,12 @@
 <resources>
     <color name="colorPrimary">#008577</color>
     <color name="colorPrimaryDark">#00574B</color>
-    <color name="colorAccent">#D81B60</color>
+    <color name="colorAccent">#03DAC5</color>
+    <color name="colorAccentDark">#FF018786</color>
+    <color name="background_color">#FF000000</color>
     <color name="background_dark">#555555</color>
     <color name="background_translucent_white">#88FFFFFF</color>
     <color name="background_translucent_dark">#AA555555</color>
+    <color name="black">#FF000000</color>
+    <color name="white">#FFFFFFFF</color>
 </resources>
index 0dd75af..e6f6218 100644 (file)
@@ -15,7 +15,7 @@
     <string name="title_settings">Settings</string>
     <string name="title_photo_library">Photo Library</string>
     <string name="title_auto_transfer">Auto Transfer</string>
-
+    <string name="permission_not_granted">Permissions not granted by the user.</string>
 
     <string name="dialog_title_confirmation">Confirmation</string>
     <string name="dialog_positive_execute">OK</string>
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
new file mode 100644 (file)
index 0000000..9e01213
--- /dev/null
@@ -0,0 +1,25 @@
+<resources>
+    <!-- Base application theme. -->
+    <style name="Theme.Aohina" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
+        <!-- Primary brand color. -->
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryVariant">@color/colorPrimaryDark</item>
+        <item name="colorOnPrimary">@color/white</item>
+        <!-- Secondary brand color. -->
+        <item name="colorSecondary">@color/colorAccent</item>
+        <item name="colorSecondaryVariant">@color/colorAccentDark</item>
+        <item name="colorOnSecondary">@color/black</item>
+        <!-- Status bar color. -->
+        <!-- <item name="android:statusBarColor">?attr/colorPrimaryVariant</item> -->
+        <!-- Customize your theme here. -->
+    </style>
+<!--
+    <style name="Theme.A01Splash" parent="Theme.SplashScreen">
+        <item name="windowSplashScreenBackground">@color/colorAccentDark</item>
+        <item name="windowSplashScreenIconBackgroundColor">@color/colorAccentDark</item>
+        <item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
+        <item name="windowSplashScreenAnimationDuration">300</item>
+        <item name="postSplashScreenTheme">@style/Theme.Aohina</item>
+    </style>
+-->
+</resources>
index 51a96fc..8776286 100644 (file)
@@ -1,13 +1,14 @@
 // Top-level build file where you can add configuration options common to all sub-projects/modules.
 
 buildscript {
-    ext.kotlin_version = '1.6.10'
+    ext.kotlin_version = '1.8.20'
     repositories {
+        gradlePluginPortal()
         google()
         mavenCentral()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:7.1.0'
+        classpath 'com.android.tools.build:gradle:8.0.0'
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
 
         // NOTE: Do not place your application dependencies here; they belong
index 199d16e..d194175 100644 (file)
@@ -6,7 +6,7 @@
 # http://www.gradle.org/docs/current/userguide/build_environment.html
 # Specifies the JVM arguments used for the daemon process.
 # The setting is particularly useful for tweaking memory settings.
-org.gradle.jvmargs=-Xmx1536m
+org.gradle.jvmargs=-Xmx8192m
 # When configured, Gradle will run in incubating parallel mode.
 # This option should only be used with decoupled projects. More details, visit
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
@@ -17,4 +17,7 @@ org.gradle.jvmargs=-Xmx1536m
 android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
+android.defaults.buildfeatures.buildconfig=true
+android.nonTransitiveRClass=false
+android.nonFinalResIds=false
 
index 34c2003..4161756 100644 (file)
@@ -1,6 +1,6 @@
-#Tue Dec 29 19:08:31 JST 2020
+#Tue Mar 21 11:03:30 JST 2023
 distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
 distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
+zipStoreBase=GRADLE_USER_HOME