diff --git a/jni/main_code.cpp b/jni/main_code.cpp index 82139f3..9d70758 100755 --- a/jni/main_code.cpp +++ b/jni/main_code.cpp @@ -541,14 +541,23 @@ void TAndroidApplication::InnerInit() Renderer->SetMatrixHeight(800); } - Renderer->PushPerspectiveProjectionMatrix(pi/6, Renderer->GetMatrixWidth() / Renderer->GetMatrixHeight(), 1.f, 400.f); + Renderer->SetPerspectiveProjectionMatrix(pi/6, Renderer->GetMatrixWidth() / Renderer->GetMatrixHeight(), 1.f, 400.f); GetConsole() << "Inner init end!\n"; m2.unlock(); } +void TAndroidApplication::InnerReinitGLResources() +{ + if (Renderer->GetScreenWidth() < Renderer->GetScreenHeight()) + { + Renderer->SetMatrixWidth(480); + Renderer->SetMatrixHeight(800); + } + Renderer->SetPerspectiveProjectionMatrix(pi/6, Renderer->GetMatrixWidth() / Renderer->GetMatrixHeight(), 1.f, 400.f); +} void TAndroidApplication::InnerDeinit() { diff --git a/jni/main_code.h b/jni/main_code.h index 899195b..9e65a9c 100755 --- a/jni/main_code.h +++ b/jni/main_code.h @@ -13,12 +13,12 @@ #include #include #include -#endif - -//#ifdef TARGET_WIN32 -//#define NOMINMAX 1 -//#include -//#undef NOMINMAX +#endif + +//#ifdef TARGET_WIN32 +//#define NOMINMAX 1 +//#include +//#undef NOMINMAX //#endif #include "boost/shared_ptr.hpp" @@ -62,6 +62,7 @@ public: TAndroidApplication(); virtual void InnerInit(); + void InnerReinitGLResources() override; virtual void InnerDeinit(); diff --git a/proj.android-studio/app/build.gradle b/proj.android-studio/app/build.gradle index 68332a8..221162a 100755 --- a/proj.android-studio/app/build.gradle +++ b/proj.android-studio/app/build.gradle @@ -19,6 +19,7 @@ apply plugin: 'kotlin-android' android { compileSdkVersion 28 + buildToolsVersion "28.0.3" defaultConfig { applicationId "fishrungames.mountainwallpaper" diff --git a/proj.android-studio/app/src/main/AndroidManifest.xml b/proj.android-studio/app/src/main/AndroidManifest.xml index 06c84e0..4ee1d06 100755 --- a/proj.android-studio/app/src/main/AndroidManifest.xml +++ b/proj.android-studio/app/src/main/AndroidManifest.xml @@ -49,7 +49,8 @@ + android:launchMode="singleTop" + android:theme="@style/Theme.AppCompat"> diff --git a/proj.android-studio/app/src/main/java/fishrungames/mountainwallpaper/MountainWallpaper.kt b/proj.android-studio/app/src/main/java/fishrungames/mountainwallpaper/MountainWallpaper.kt index 847500a..836b0c0 100755 --- a/proj.android-studio/app/src/main/java/fishrungames/mountainwallpaper/MountainWallpaper.kt +++ b/proj.android-studio/app/src/main/java/fishrungames/mountainwallpaper/MountainWallpaper.kt @@ -24,6 +24,9 @@ import android.view.GestureDetector import android.view.MotionEvent import android.view.SurfaceHolder import fishrungames.salmonengineandroid.EngineWrapper +import android.content.SharedPreferences + + class MountainWallpaper : GLWallpaperService(), SharedPreferences.OnSharedPreferenceChangeListener { @@ -54,6 +57,10 @@ class MountainWallpaper : GLWallpaperService(), SharedPreferences.OnSharedPrefer apkFilePath = appInfo!!.sourceDir EngineWrapper.SetupApkFilePath(apkFilePath) + + val prefs = PreferenceManager.getDefaultSharedPreferences(this) + JniWrapper.SetTimeOfDayPref(Integer.parseInt(prefs.getString("Timeofday", "0")!!)) + JniWrapper.SetSnowPref(prefs.getBoolean("Snow", false)) } override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { diff --git a/proj.android-studio/app/src/main/java/fishrungames/mountainwallpaper/WallpaperPreferences.kt b/proj.android-studio/app/src/main/java/fishrungames/mountainwallpaper/WallpaperPreferences.kt index ef21221..eb3b0a4 100755 --- a/proj.android-studio/app/src/main/java/fishrungames/mountainwallpaper/WallpaperPreferences.kt +++ b/proj.android-studio/app/src/main/java/fishrungames/mountainwallpaper/WallpaperPreferences.kt @@ -18,11 +18,28 @@ package fishrungames.mountainwallpaper import android.os.Bundle import android.support.v4.app.FragmentActivity +import android.app.WallpaperManager +import android.view.View +import android.widget.Button +import android.content.Intent +import android.content.ComponentName class WallpaperPreferences : FragmentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.pref_activity) + val buttonSetWallpaper = findViewById(R.id.button_setWallpaper) as Button + + buttonSetWallpaper.setOnClickListener(object : View.OnClickListener{ + override fun onClick(arg0: View) { + + val component = ComponentName(packageName, "$packageName.MountainWallpaper") + intent = Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER) + intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, component) + startActivity(intent) + + } + }) } } diff --git a/proj.android-studio/app/src/main/res/layout/pref_activity.xml b/proj.android-studio/app/src/main/res/layout/pref_activity.xml index d050e6e..fa2b455 100755 --- a/proj.android-studio/app/src/main/res/layout/pref_activity.xml +++ b/proj.android-studio/app/src/main/res/layout/pref_activity.xml @@ -1,29 +1,34 @@ - + android:layout_height="fill_parent" + android:layout_margin="20dp" + android:orientation="vertical"> - + android:src="@drawable/icon" /> - + android:background="#ff0000" /> + +