├── .gitignore
├── Readme.md
├── app
├── .gitignore
├── CMakeLists.txt
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ ├── canary.wav
│ ├── image.png
│ ├── orchestral.ogg
│ └── sansation.ttf
│ ├── cpp
│ └── main.cpp
│ ├── java
│ └── de
│ │ └── flatspotsoftware
│ │ └── testapp
│ │ ├── CPPCallIns.java
│ │ ├── CPPCallbacks.java
│ │ └── activity
│ │ └── TestNativeActivity.java
│ └── res
│ ├── drawable-hdpi
│ └── sfml_logo.png
│ ├── drawable-ldpi
│ └── sfml_logo.png
│ ├── drawable-mdpi
│ └── sfml_logo.png
│ ├── drawable-xhdpi
│ └── sfml_logo.png
│ ├── drawable-xxhdpi
│ └── sfml_logo.png
│ ├── layout
│ └── overlay_layout.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | .idea/
11 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | # SFML-AndroidStudio-Template
2 |
3 | WIP. Android Studio, with the Gradle and CMake build system, template for a Native (and/or Hybrid) App with SFML
4 |
5 | ## Prerequisites
6 |
7 | Brain.exe
8 |
9 | Install Android Studio (2.3.3 +)
10 |
11 | At the first startup of Android Studio install the SDK and NDK in Android Studio.
12 | I recommend doing it directly in android studio so your sdk and ndk directories are set correctly
13 |
14 | Build SFML for android (use libc++_shared, change the build.gradle file in the template for full c++11 support!),
15 | have a look at the SFML wiki there is a tutorial.
16 |
17 | For Building SFML with libc++ android-ndk-r12b is required. Afterwards you can use the latest and greatest from android-studio
18 |
19 | **If however, you build SFML from git, you can also build with latest android-ndk**
20 |
21 | ## How to use
22 |
23 | Clone this git, rename the folder and then just open it in android studio (2.3+)
24 |
25 | FIX YOUR PATHS AND ABI FILTERS
26 |
27 | Now you can simply run the application!
28 |
29 | ## Todo
30 |
31 | - **CleanUp Paths and abiFilters**
32 | - Support linking of debug libs
33 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html
3 |
4 | # Sets the minimum version of CMake required to build the native library.
5 |
6 | cmake_minimum_required(VERSION 3.4.1)
7 |
8 | # Creates and names a library, sets it as either STATIC
9 | # or SHARED, and provides the relative paths to its source code.
10 | # You can define multiple libraries, and CMake builds them for you.
11 | # Gradle automatically packages shared libraries with your APK.
12 |
13 | # Export ANativeActivity_onCreate(),
14 | # Refer to: https://github.com/android-ndk/ndk/issues/381.
15 | set(CMAKE_SHARED_LINKER_FLAGS
16 | "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
17 |
18 | include_directories(${SFML_INCLUDE_DIR})
19 | link_directories("${SFML_LIBRARY_DIR}${ANDROID_ABI}/")
20 | link_directories("${SFML_EXT_LIBRARY_DIR}${ANDROID_ABI}/")
21 |
22 | message(STATUS "SFML include dir: ${SFML_INCLUDE_DIR}")
23 | message(STATUS "SFML lib dir: ${SFML_LIBRARY_DIR}${ANDROID_ABI}/")
24 | message(STATUS "SFML extlib dir: ${SFML_EXT_LIBRARY_DIR}${ANDROID_ABI}/")
25 | message(STATUS "ABI ${ANDROID_ABI}")
26 |
27 | add_library( # Sets the name of the library.
28 | native-lib
29 |
30 | # Sets the library as a shared library.
31 | SHARED
32 |
33 | # Provides a relative path to your source file(s).
34 | src/main/cpp/main.cpp
35 | )
36 |
37 | # Searches for a specified prebuilt library and stores the path as a
38 | # variable. Because CMake includes system libraries in the search path by
39 | # default, you only need to specify the name of the public NDK library
40 | # you want to add. CMake verifies that the library exists before
41 | # completing its build.
42 |
43 |
44 | # Specifies libraries CMake should link to your target library. You
45 | # can link multiple libraries, such as libraries you define in this
46 | # build script, prebuilt third-party libraries, or system libraries.
47 |
48 | target_link_libraries( # Specifies the target library.
49 | native-lib
50 |
51 | # Links the target library to the log library
52 | # included in the NDK.
53 |
54 | log
55 | android
56 | EGL
57 | GLESv1_CM
58 |
59 | sfml-system
60 |
61 | openal
62 |
63 | sfml-window
64 | sfml-audio
65 | sfml-graphics
66 | sfml-network
67 | sfml-activity
68 | -Wl,--whole-archive sfml-main -Wl,--no-whole-archive
69 | )
70 |
71 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | def ndkDir = System.getenv("ANDROID_NDK")
4 | def propertiesFile = project.rootProject.file('local.properties')
5 | if (propertiesFile.exists()) {
6 | Properties properties = new Properties()
7 | properties.load(propertiesFile.newDataInputStream())
8 | ndkDir = properties.getProperty('ndk.dir')
9 | }
10 |
11 | android {
12 | compileSdkVersion 25
13 | buildToolsVersion "25.0.3"
14 | defaultConfig {
15 | applicationId "sfml.com.sfml_example"
16 | //Replace this with your real package name (e.g. com.StudioName.GameName)
17 | minSdkVersion 19
18 | targetSdkVersion 25
19 | versionCode 1
20 | versionName "1.0"
21 | externalNativeBuild {
22 | cmake {
23 | cppFlags "-std=c++14 -frtti -fexceptions"
24 | arguments "-DANDROID_TOOLCHAIN=clang",
25 | "-DANDROID_STL=c++_shared",
26 | "-DSFML_INCLUDE_DIR=${ndkDir}/sources/sfml/include",
27 | "-DSFML_LIBRARY_DIR=${ndkDir}/sources/sfml/lib/",
28 | "-DSFML_EXT_LIBRARY_DIR=${ndkDir}/sources/sfml/extlibs/lib/"
29 | abiFilters 'armeabi-v7a'
30 | // multiple ABIs are supported
31 | // but you have to compile SFML for every ABI you want to support
32 | // abiFilters 'armeabi-v7a', 'armeabi'
33 | }
34 | }
35 | }
36 |
37 | buildTypes {
38 | debug {
39 | minifyEnabled false
40 | jniDebuggable true
41 | debuggable true
42 | }
43 | release {
44 | minifyEnabled false
45 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
46 | }
47 | }
48 | externalNativeBuild {
49 | cmake {
50 | path "CMakeLists.txt"
51 | }
52 | }
53 | sourceSets {
54 | main {
55 | // let gradle pack the shared library into apk
56 | jniLibs.srcDirs = ["${ndkDir}/sources/sfml/lib", "${ndkDir}/sources/sfml/extlibs/lib/"]
57 | }
58 | }
59 |
60 | }
61 |
62 | dependencies {
63 | compile fileTree(dir: 'libs', include: ['*.jar'])
64 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
65 | exclude group: 'com.android.support', module: 'support-annotations'
66 | })
67 | compile 'com.android.support:appcompat-v7:25.3.1'
68 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
69 | compile 'com.android.support:support-v4:25.3.1'
70 | testCompile 'junit:junit:4.12'
71 | }
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/alex/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
14 |
15 |
16 |
21 |
22 |
24 |
25 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/assets/canary.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/assets/canary.wav
--------------------------------------------------------------------------------
/app/src/main/assets/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/assets/image.png
--------------------------------------------------------------------------------
/app/src/main/assets/orchestral.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/assets/orchestral.ogg
--------------------------------------------------------------------------------
/app/src/main/assets/sansation.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/assets/sansation.ttf
--------------------------------------------------------------------------------
/app/src/main/cpp/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | // Do we want to showcase direct JNI/NDK interaction?
8 | // Undefine this to get real cross-platform code.
9 | #define USE_JNI
10 |
11 | #if defined(USE_JNI)
12 | // These headers are only needed for direct NDK/JDK interaction
13 | #include
14 | #include
15 |
16 | // Since we want to get the native activity from SFML, we'll have to use an
17 | // extra header here:
18 | #include
19 |
20 | #include
21 |
22 | #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-activity", __VA_ARGS__))
23 | #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "native-activity", __VA_ARGS__))
24 |
25 | // NDK/JNI sub example - call Java code from native code
26 | int vibrate(sf::Time duration)
27 | {
28 | // First we'll need the native activity handle
29 | ANativeActivity *activity = sf::getNativeActivity();
30 |
31 | // Retrieve the JVM and JNI environment
32 | JavaVM* vm = activity->vm;
33 | JNIEnv* env = activity->env;
34 |
35 | // First, attach this thread to the main thread
36 | JavaVMAttachArgs attachargs;
37 | attachargs.version = JNI_VERSION_1_6;
38 | attachargs.name = "NativeThread";
39 | attachargs.group = NULL;
40 | jint res = vm->AttachCurrentThread(&env, &attachargs);
41 |
42 | if (res == JNI_ERR)
43 | return EXIT_FAILURE;
44 |
45 | // Retrieve class information
46 | jclass natact = env->FindClass("android/app/NativeActivity");
47 | jclass context = env->FindClass("android/content/Context");
48 |
49 | // Get the value of a constant
50 | jfieldID fid = env->GetStaticFieldID(context, "VIBRATOR_SERVICE", "Ljava/lang/String;");
51 | jobject svcstr = env->GetStaticObjectField(context, fid);
52 |
53 | // Get the method 'getSystemService' and call it
54 | jmethodID getss = env->GetMethodID(natact, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;");
55 | jobject vib_obj = env->CallObjectMethod(activity->clazz, getss, svcstr);
56 |
57 | // Get the object's class and retrieve the member name
58 | jclass vib_cls = env->GetObjectClass(vib_obj);
59 | jmethodID vibrate = env->GetMethodID(vib_cls, "vibrate", "(J)V");
60 |
61 | // Determine the timeframe
62 | jlong length = duration.asMilliseconds();
63 |
64 | // Bzzz!
65 | env->CallVoidMethod(vib_obj, vibrate, length);
66 |
67 | // Free references
68 | env->DeleteLocalRef(vib_obj);
69 | env->DeleteLocalRef(vib_cls);
70 | env->DeleteLocalRef(svcstr);
71 | env->DeleteLocalRef(context);
72 | env->DeleteLocalRef(natact);
73 |
74 | // Detach thread again
75 | vm->DetachCurrentThread();
76 |
77 | return EXIT_SUCCESS;
78 | }
79 |
80 | int testCall(std::string arg)
81 | {
82 |
83 | // First we'll need the native activity handle
84 | ANativeActivity *activity = sf::getNativeActivity();
85 |
86 | // Retrieve the JVM and JNI environment
87 | JavaVM* vm = activity->vm;
88 | JNIEnv* env = activity->env;
89 |
90 | // First, attach this thread to the main thread
91 | JavaVMAttachArgs attachargs;
92 | attachargs.version = JNI_VERSION_1_6;
93 | attachargs.name = "main";
94 | attachargs.group = NULL;
95 | jint res = vm->AttachCurrentThread(&env, &attachargs);
96 |
97 | if (res == JNI_ERR)
98 | return EXIT_FAILURE;
99 |
100 | jclass apiclass = env->GetObjectClass(activity->clazz);
101 |
102 | if (apiclass != nullptr)
103 | {
104 | jmethodID methodID = env->GetMethodID(apiclass, "testCall", "(Ljava/lang/String;)V");
105 |
106 | jstring jstr123 = env->NewStringUTF(arg.c_str());
107 |
108 | env->CallVoidMethod(activity->clazz, methodID, jstr123);
109 |
110 | // Free references
111 | env->DeleteLocalRef(jstr123);
112 | } else {
113 | LOGW("NOPE!");
114 | }
115 |
116 | vm->DetachCurrentThread();
117 |
118 |
119 | return EXIT_SUCCESS;
120 | }
121 |
122 | extern "C"
123 | {
124 | JNIEXPORT jstring JNICALL
125 | Java_de_flatspotsoftware_testapp_CPPCallIns_testCall(JNIEnv *env, jobject thiz, jstring arg) {
126 | std::string str = std::string(env->GetStringUTFChars(arg, JNI_FALSE));
127 | str.append(str);
128 | return env->NewStringUTF(str.c_str());
129 | }
130 | };
131 | #endif
132 |
133 | // This is the actual Android example. You don't have to write any platform
134 | // specific code, unless you want to use things not directly exposed.
135 | // ('vibrate()' in this example; undefine 'USE_JNI' above to disable it)
136 | int main(int argc, char *argv[])
137 | {
138 | sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "");
139 |
140 | sf::Texture texture;
141 | if(!texture.loadFromFile("image.png"))
142 | return EXIT_FAILURE;
143 |
144 | sf::Sprite image(texture);
145 | image.setPosition(0, 0);
146 | image.setOrigin(texture.getSize().x/2, texture.getSize().y/2);
147 |
148 | sf::Music music;
149 | if(!music.openFromFile("canary.wav"))
150 | return EXIT_FAILURE;
151 |
152 | music.play();
153 |
154 | sf::View view = window.getDefaultView();
155 |
156 | bool focus = true;
157 |
158 | while (window.isOpen())
159 | {
160 | sf::Event event;
161 |
162 | while (window.pollEvent(event))
163 | {
164 | switch (event.type)
165 | {
166 | case sf::Event::Closed:
167 | window.close();
168 | break;
169 | case sf::Event::Resized:
170 | view.setSize(event.size.width, event.size.height);
171 | view.setCenter(event.size.width/2, event.size.height/2);
172 | window.setView(view);
173 | break;
174 | case sf::Event::TouchBegan:
175 | if (event.touch.finger == 0)
176 | {
177 | image.setPosition(event.touch.x, event.touch.y);
178 | #if defined(USE_JNI)
179 | vibrate(sf::milliseconds(100));
180 |
181 | testCall("dkjfhjskdhfjskdhgkjdfhgjkdfhgdfjkgdfhkjgjkdfghkjldf");
182 |
183 | #endif
184 | }
185 | break;
186 | case sf::Event::LostFocus:
187 |
188 | focus = false; //don't draw, if the window is not shown
189 | LOGI("LOST FOCUS!");
190 |
191 | break;
192 |
193 | case sf::Event::GainedFocus:
194 |
195 | focus = true; //draw if the window is shown
196 | LOGI("GAINED FOCUS!");
197 | break;
198 |
199 |
200 | case sf::Event::MouseEntered: // mouse entered event is called on activity resume
201 |
202 | LOGI("MOUSE ENTERED!");
203 |
204 | window.create(sf::VideoMode::getDesktopMode(), ""); //recreating the window circumvents a nasty sfml-bug where on activityResume the egl_surface is not valid anymore
205 |
206 | testCall("MouseDidEnter");
207 |
208 |
209 | break;
210 | }
211 | }
212 |
213 | if (focus)
214 | {
215 | window.clear(sf::Color::White);
216 | window.draw(image);
217 | window.display();
218 | }
219 | }
220 |
221 | return 0;
222 | }
223 |
--------------------------------------------------------------------------------
/app/src/main/java/de/flatspotsoftware/testapp/CPPCallIns.java:
--------------------------------------------------------------------------------
1 | package de.flatspotsoftware.testapp;
2 |
3 | /**
4 | * Created by Alia5 on 8/30/2017.
5 | */
6 |
7 | public class CPPCallIns {
8 |
9 | static {
10 | System.loadLibrary("native-lib");
11 | }
12 |
13 | private static CPPCallIns callIns = null;
14 |
15 | private CPPCallIns()
16 | {}
17 |
18 | public static CPPCallIns getInstance()
19 | {
20 | if (callIns == null)
21 | callIns = new CPPCallIns();
22 |
23 | return callIns;
24 | }
25 |
26 | public native String testCall(String arg);
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/de/flatspotsoftware/testapp/CPPCallbacks.java:
--------------------------------------------------------------------------------
1 | package de.flatspotsoftware.testapp;
2 |
3 | /**
4 | * Created by Alia5 on 8/30/2017.
5 | */
6 |
7 | public interface CPPCallbacks {
8 |
9 | void testCall(String arg);
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/de/flatspotsoftware/testapp/activity/TestNativeActivity.java:
--------------------------------------------------------------------------------
1 | package de.flatspotsoftware.testapp.activity;
2 |
3 | import android.app.AlertDialog;
4 | import android.app.NativeActivity;
5 | import android.content.res.Configuration;
6 | import android.os.Bundle;
7 | import android.os.Handler;
8 | import android.support.v4.widget.PopupWindowCompat;
9 | import android.util.Log;
10 | import android.view.Gravity;
11 | import android.view.LayoutInflater;
12 | import android.view.MotionEvent;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.view.Window;
16 | import android.view.WindowManager;
17 | import android.widget.LinearLayout;
18 | import android.widget.PopupWindow;
19 | import android.widget.TextView;
20 | import android.widget.Toast;
21 |
22 | import de.flatspotsoftware.testapp.CPPCallIns;
23 | import de.flatspotsoftware.testapp.CPPCallbacks;
24 | import sfml.com.sfml_example.R;
25 |
26 | /**
27 | * Created by Alia5 on 8/30/2017.
28 | */
29 |
30 | public class TestNativeActivity extends NativeActivity implements CPPCallbacks {
31 |
32 |
33 | /* Immersive sticky mode doesn't work properly with SFML... so we just write the stick part up ourselves....
34 | Additionally we can now hide the nav-bar...
35 | */
36 | Handler stickyHandler = new Handler();
37 |
38 | Runnable stickRunnable = new Runnable() {
39 | @Override
40 | public void run() {
41 | getWindow().getDecorView()
42 | .setSystemUiVisibility(
43 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
44 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
45 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
46 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
47 | | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
48 | | View.SYSTEM_UI_FLAG_IMMERSIVE);
49 |
50 | stickyHandler.postDelayed(this, 3000);
51 | }
52 | };
53 |
54 |
55 | private View androidOverlayView;
56 |
57 |
58 | @Override
59 | public void onConfigurationChanged(Configuration newConfig) {
60 | super.onConfigurationChanged(newConfig);
61 | }
62 |
63 | @Override
64 | protected void onCreate(Bundle savedInstanceState) {
65 | Log.d("TEST", "Hello from JAVA!!!");
66 | super.onCreate(savedInstanceState);
67 |
68 | showOverlay();
69 | }
70 |
71 | @Override
72 | protected void onResume() {
73 | super.onResume();
74 | Log.d("onResume", "onResume");
75 | stickyHandler.post(stickRunnable);
76 | }
77 |
78 | @Override
79 | protected void onDestroy() {
80 | super.onDestroy();
81 | stickyHandler.removeCallbacks(stickRunnable);
82 | }
83 |
84 | @Override
85 | public void testCall(String arg) {
86 | System.out.print(arg);
87 |
88 | if (arg.equals("MouseDidEnter"))
89 | {
90 |
91 | Log.d("Java_ACtivity", "onResumeCalled");
92 |
93 | return;
94 | }
95 |
96 | Log.wtf("INTERFASCE!!!",arg);
97 |
98 | runOnUiThread(new Runnable() {
99 | @Override
100 | public void run() {
101 | AlertDialog.Builder builder = new AlertDialog.Builder(TestNativeActivity.this);
102 |
103 | builder.setMessage(CPPCallIns.getInstance().testCall("abc"));
104 |
105 | builder.create().show();
106 | }
107 | });
108 |
109 | }
110 |
111 | //ideally you would run this from a callback from native code... but for demo purposes
112 | void showOverlay()
113 | {
114 | new Handler().postDelayed(new Runnable() {
115 | @Override
116 | public void run() {
117 | TestNativeActivity.this.runOnUiThread(new Runnable() {
118 | @Override
119 | public void run() {
120 |
121 | final PopupWindow _popupWindow;
122 |
123 | LayoutInflater layoutInflater
124 | = (LayoutInflater)getBaseContext()
125 | .getSystemService(LAYOUT_INFLATER_SERVICE);
126 | View popupView = layoutInflater.inflate(R.layout.overlay_layout, null);
127 | popupView.findViewById(R.id.testButton).setOnClickListener(new View.OnClickListener() {
128 | @Override
129 | public void onClick(View v) {
130 | Toast.makeText(TestNativeActivity.this, "click!", Toast.LENGTH_SHORT).show();
131 | }
132 | });
133 | _popupWindow = new PopupWindow(
134 | popupView,
135 | WindowManager.LayoutParams.MATCH_PARENT,
136 | WindowManager.LayoutParams.MATCH_PARENT);
137 |
138 |
139 | _popupWindow.setTouchable(false); //if false, touch events go through, else, the overlay is getting touch events
140 |
141 |
142 | LinearLayout mainLayout = new LinearLayout(TestNativeActivity.this);
143 | ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
144 | params.setMargins(0, 0, 0, 0);
145 | TestNativeActivity.this.setContentView(mainLayout, params);
146 |
147 | // Show our UI over NativeActivity window
148 | _popupWindow.showAtLocation(mainLayout, Gravity.TOP | Gravity.START, 0, 0);
149 | _popupWindow.update();
150 |
151 |
152 | }});
153 | }
154 | }, 2000);
155 | }
156 |
157 | }
158 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/sfml_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/res/drawable-hdpi/sfml_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldpi/sfml_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/res/drawable-ldpi/sfml_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/sfml_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/res/drawable-mdpi/sfml_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/sfml_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/res/drawable-xhdpi/sfml_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/sfml_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/res/drawable-xxhdpi/sfml_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/overlay_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
12 |
13 |
14 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | SFML
4 |
5 |
6 | Hello blank fragment
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
25 | task wrapper(type: Wrapper){
26 | gradleVersion = '3.3'
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alia5/SFML_AndroidStudio/f87e16e114f63cb046ae35124d4e2313d6cf879d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Aug 29 21:20:16 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
--------------------------------------------------------------------------------