Advertisement
simwhi

Files

Jan 31st, 2017
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.77 KB | None | 0 0
  1. package com.giderosmobile.android;
  2.  
  3. import java.lang.reflect.Method;
  4.  
  5. import javax.microedition.khronos.egl.EGLConfig;
  6. import javax.microedition.khronos.opengles.GL10;
  7.  
  8. import android.annotation.TargetApi;
  9. import android.app.Activity;
  10. import android.content.Context;
  11. import android.content.Intent;
  12. import android.opengl.GLSurfaceView;
  13. import android.os.Build;
  14. import android.os.Bundle;
  15. import android.os.Handler;
  16. import android.os.Looper;
  17. import android.view.KeyEvent;
  18. import android.view.MotionEvent;
  19. import android.view.View;
  20. import android.view.View.OnTouchListener;
  21. import android.view.Gravity;
  22. import android.graphics.Color;
  23. import android.widget.FrameLayout;
  24. import android.widget.ImageView;
  25. import android.view.inputmethod.BaseInputConnection;
  26. import android.view.inputmethod.EditorInfo;
  27. import android.view.inputmethod.InputConnection;
  28. import android.text.InputType;
  29.  
  30. import com.giderosmobile.android.player.*;
  31. import com.wobblemonkey.speedygram.R;
  32.  
  33. public class SpeedyGramActivity extends Activity implements OnTouchListener
  34. {
  35. static
  36. {
  37. System.loadLibrary("gvfs");
  38. System.loadLibrary("lua");
  39. System.loadLibrary("gideros");
  40. System.loadLibrary("luasocket");
  41. System.loadLibrary("lfs");
  42. System.loadLibrary("lsqlite3");
  43. System.loadLibrary("json");
  44. System.loadLibrary("bitop");
  45. //Line below is a marker for plugin insertion scripts. Do not remove or change
  46. //GIDEROS-STATIC-INIT//
  47. //System.loadLibrary("facebook");
  48. //System.loadLibrary("flurry");
  49. //System.loadLibrary("iab");
  50. System.loadLibrary("ads");
  51. }
  52.  
  53. static private String[] externalClasses = {
  54. //Line below is a marker for plugin insertion scripts. Do not remove or change
  55. //GIDEROS-EXTERNAL-CLASS//
  56. // "com.giderosmobile.android.plugins.facebook.GFacebook",
  57. // "com.giderosmobile.android.plugins.flurry.GFlurry",
  58. // "com.giderosmobile.android.plugins.iab.Iab"
  59. "com.giderosmobile.android.plugins.ads.Ads",
  60. null
  61. };
  62.  
  63. private GLSurfaceView mGLView;
  64.  
  65. private boolean mHasFocus = false;
  66. private boolean mPlaying = false;
  67.  
  68. private static FrameLayout splashLayout;
  69. private static ImageView splash;
  70. private static FrameLayout layout;
  71. private static int hasSplash = -1;
  72.  
  73. @Override
  74. public void onCreate(Bundle savedInstanceState)
  75. {
  76. super.onCreate(savedInstanceState);
  77.  
  78. mGLView = new GiderosGLSurfaceView(this);
  79. setContentView(mGLView);
  80. mGLView.setOnTouchListener(this);
  81.  
  82. boolean showSplash = false;
  83.  
  84. if(showSplash && getResources().getIdentifier("splash", "drawable", getPackageName()) != 0){
  85. layout = (FrameLayout)getWindow().getDecorView();
  86. hasSplash = 11;
  87. //create a layout for animation
  88. splashLayout = new FrameLayout(this);
  89. //parameters for layout
  90. FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
  91. FrameLayout.LayoutParams.MATCH_PARENT ,
  92. FrameLayout.LayoutParams.MATCH_PARENT,
  93. Gravity.CENTER);
  94. splashLayout.setLayoutParams(params);
  95. //set background color
  96. splashLayout.setBackgroundColor(Color.parseColor("#ffffff"));
  97.  
  98. //create image view for animation
  99. splash = new ImageView(this);
  100. //image view parameters
  101. FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams(
  102. FrameLayout.LayoutParams.WRAP_CONTENT,
  103. FrameLayout.LayoutParams.WRAP_CONTENT,
  104. Gravity.CENTER);
  105. splash.setLayoutParams(params2);
  106.  
  107. //scale your image
  108. splash.setScaleType(ImageView.ScaleType.CENTER );
  109.  
  110. //load image source
  111. splash.setBackgroundResource(R.drawable.splash);
  112.  
  113. //add image view to layout
  114. splashLayout.addView(splash);
  115. //add image layout to main layout
  116. layout.addView(splashLayout);
  117. }
  118.  
  119. WeakActivityHolder.set(this);
  120.  
  121. GiderosApplication.onCreate(externalClasses,mGLView);
  122. }
  123.  
  124. int[] id = new int[256];
  125. int[] x = new int[256];
  126. int[] y = new int[256];
  127. float[] pressure = new float[256];
  128.  
  129. @Override
  130. public void onStart()
  131. {
  132. super.onStart();
  133. GiderosApplication.getInstance().onStart();
  134. }
  135.  
  136. @Override
  137. public void onRestart()
  138. {
  139. super.onRestart();
  140. GiderosApplication.getInstance().onRestart();
  141. }
  142.  
  143. @Override
  144. public void onStop()
  145. {
  146. GiderosApplication.getInstance().onStop();
  147. super.onStop();
  148. }
  149.  
  150. @Override
  151. public void onDestroy()
  152. {
  153. GiderosApplication.onDestroy();
  154. super.onDestroy();
  155. }
  156.  
  157. @Override
  158. protected void onPause()
  159. {
  160. if (mPlaying == true)
  161. {
  162. GiderosApplication.getInstance().onPause();
  163. mGLView.onPause();
  164. mPlaying = false;
  165. }
  166.  
  167. super.onPause();
  168. }
  169.  
  170. @Override
  171. protected void onResume()
  172. {
  173. super.onResume();
  174.  
  175. if (mHasFocus == true && mPlaying == false)
  176. {
  177. mGLView.onResume();
  178. GiderosApplication.getInstance().onResume();
  179. mPlaying = true;
  180. }
  181. }
  182.  
  183. @Override
  184. public void onLowMemory()
  185. {
  186. super.onLowMemory();
  187.  
  188. GiderosApplication app = GiderosApplication.getInstance();
  189. if (app != null)
  190. app.onLowMemory();
  191. }
  192.  
  193. @Override
  194. public void onActivityResult(int requestCode, int resultCode, Intent data)
  195. {
  196. super.onActivityResult(requestCode, resultCode, data);
  197. GiderosApplication.getInstance().onActivityResult(requestCode, resultCode, data);
  198. }
  199.  
  200. @TargetApi(Build.VERSION_CODES.KITKAT)
  201. @Override
  202. public void onWindowFocusChanged(boolean hasFocus)
  203. {
  204. super.onWindowFocusChanged(hasFocus);
  205.  
  206. if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
  207. if (hasFocus) {
  208. getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
  209. | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
  210. | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
  211. | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
  212. | View.SYSTEM_UI_FLAG_FULLSCREEN
  213. | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
  214. }
  215. }
  216.  
  217. mHasFocus = hasFocus;
  218.  
  219. if (mHasFocus == true && mPlaying == false)
  220. {
  221. mGLView.onResume();
  222. GiderosApplication.getInstance().onResume();
  223. mPlaying = true;
  224. }
  225. }
  226.  
  227. public boolean onTouch(View v, MotionEvent event)
  228. {
  229. GiderosApplication app = GiderosApplication.getInstance();
  230. if (app == null)
  231. return false;
  232.  
  233. int size = event.getPointerCount();
  234. for (int i = 0; i < size; i++)
  235. {
  236. id[i] = event.getPointerId(i);
  237. x[i] = (int) event.getX(i);
  238. y[i] = (int) event.getY(i);
  239. pressure[i] = (float) event.getPressure(i);
  240. }
  241.  
  242. int actionMasked = event.getActionMasked();
  243. boolean isPointer = (actionMasked == MotionEvent.ACTION_POINTER_DOWN || actionMasked == MotionEvent.ACTION_POINTER_UP);
  244. int actionIndex = isPointer ? event.getActionIndex() : 0;
  245.  
  246. if (actionMasked == MotionEvent.ACTION_DOWN || actionMasked == MotionEvent.ACTION_POINTER_DOWN)
  247. {
  248. app.onTouchesBegin(size, id, x, y, pressure, actionIndex);
  249. } else if (actionMasked == MotionEvent.ACTION_MOVE)
  250. {
  251. app.onTouchesMove(size, id, x, y, pressure);
  252. } else if (actionMasked == MotionEvent.ACTION_UP || actionMasked == MotionEvent.ACTION_POINTER_UP)
  253. {
  254. app.onTouchesEnd(size, id, x, y, pressure, actionIndex);
  255. } else if (actionMasked == MotionEvent.ACTION_CANCEL)
  256. {
  257. app.onTouchesCancel(size, id, x, y, pressure);
  258. }
  259.  
  260. return true;
  261. }
  262.  
  263. @Override
  264. public boolean onKeyDown(int keyCode, KeyEvent event)
  265. {
  266. //GIDEROS-ACTIVTIY-ONKEYDOWN//
  267. GiderosApplication app = GiderosApplication.getInstance();
  268. if (app != null && app.onKeyDown(keyCode, event) == true)
  269. return true;
  270.  
  271. return super.onKeyDown(keyCode, event);
  272. }
  273.  
  274.  
  275. @Override
  276. public boolean onKeyUp(int keyCode, KeyEvent event)
  277. {
  278. //GIDEROS-ACTIVTIY-ONKEYUP//
  279. GiderosApplication app = GiderosApplication.getInstance();
  280. if (app != null && app.onKeyUp(keyCode, event) == true)
  281. return true;
  282.  
  283. return super.onKeyUp(keyCode, event);
  284. }
  285.  
  286.  
  287. @Override
  288. public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
  289. GiderosApplication app = GiderosApplication.getInstance();
  290. if (app != null && app.onKeyMultiple(keyCode, repeatCount, event) == true)
  291. return true;
  292.  
  293. return super.onKeyMultiple(keyCode, repeatCount, event);
  294. }
  295.  
  296. public void onRequestPermissionsResult(int requestCode,
  297. String permissions[], int[] grantResults) {
  298. }
  299.  
  300. //GIDEROS-ACTIVTIY-METHODS//
  301.  
  302. static public void dismisSplash(){
  303. if(hasSplash == -1){
  304. return;
  305. }
  306. else if(hasSplash == 0){
  307. hasSplash = -1;
  308. new Handler(Looper.getMainLooper()).post(new Runnable() {
  309. @Override
  310. public void run() {
  311. splashLayout.setVisibility(View.GONE);
  312. splash.setBackgroundResource(0);
  313. //remove animation view from main layout
  314. layout.removeView(splashLayout);
  315. splashLayout = null;
  316. splash = null;
  317. layout = null;
  318. }
  319. });
  320. }
  321. else if(hasSplash > 0){
  322. hasSplash--;
  323. }
  324. }
  325. }
  326.  
  327. class GiderosGLSurfaceView extends GLSurfaceView
  328. {
  329. public GiderosGLSurfaceView(Context context)
  330. {
  331. super(context);
  332. setEGLContextClientVersion(2);
  333. setEGLConfigChooser(8,8,8,0,16,8);
  334. mRenderer = new GiderosRenderer();
  335. setRenderer(mRenderer);
  336. if (android.os.Build.VERSION.SDK_INT >= 11)
  337. {
  338. try
  339. {
  340. for (Method method : getClass().getMethods())
  341. {
  342. if (method.getName().equals("setPreserveEGLContextOnPause"))
  343. {
  344. method.invoke(this, true);
  345. break;
  346. }
  347. }
  348. }
  349. catch (Exception e)
  350. {
  351. }
  352. }
  353. setFocusable(true);
  354. setFocusableInTouchMode(true);
  355. }
  356.  
  357. @Override
  358. public InputConnection onCreateInputConnection(EditorInfo outAttrs)
  359. {
  360. outAttrs.actionLabel = "";
  361. outAttrs.hintText = "";
  362. outAttrs.initialCapsMode = 0;
  363. outAttrs.initialSelEnd = outAttrs.initialSelStart = -1;
  364. outAttrs.label = "";
  365. outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
  366. outAttrs.inputType = InputType.TYPE_NULL;
  367.  
  368. return new BaseInputConnection(this, false);
  369. }
  370.  
  371. @Override
  372. public boolean onCheckIsTextEditor ()
  373. {
  374. return true;
  375. }
  376.  
  377. GiderosRenderer mRenderer;
  378. }
  379.  
  380. class GiderosRenderer implements GLSurfaceView.Renderer
  381. {
  382. public void onSurfaceCreated(GL10 gl, EGLConfig config)
  383. {
  384. GiderosApplication.getInstance().onSurfaceCreated();
  385. }
  386.  
  387. public void onSurfaceChanged(GL10 gl, int w, int h)
  388. {
  389. GiderosApplication.getInstance().onSurfaceChanged(w, h);
  390. }
  391.  
  392. public void onDrawFrame(GL10 gl)
  393. {
  394. GiderosApplication app = GiderosApplication.getInstance();
  395. if (app != null)
  396. {
  397. //GIDEROS-ACTIVITY-PREDRAW//
  398. app.onDrawFrame();
  399. //GIDEROS-ACTIVITY-POSTDRAW//
  400. SpeedyGramActivity.dismisSplash();
  401. }
  402. }
  403. }
  404.  
  405. <?xml version="1.0" encoding="utf-8"?>
  406. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  407. package="com.wobblemonkey.speedygram">
  408. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  409. <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
  410. <uses-permission android:name="android.permission.INTERNET"/>
  411. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  412. <uses-permission android:name="com.android.vending.BILLING" />
  413. <uses-permission android:name="android.permission.VIBRATE"/>
  414. <!-- TAG:MANIFEST-EXTRA -->
  415. <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
  416. <supports-screens android:largeScreens="true"
  417. android:smallScreens="true"
  418. android:normalScreens="true"
  419. android:xlargeScreens="true"
  420. android:anyDensity="true"/>
  421. <application android:icon="@drawable/icon"
  422. android:label="@string/app_name"
  423. android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
  424. <activity android:label="@string/app_name"
  425. android:name="com.giderosmobile.android.SpeedyGramActivity"
  426. android:launchMode="singleTask"
  427. android:screenOrientation="sensorLandscape"
  428. android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
  429. <intent-filter>
  430. <action android:name="android.intent.action.MAIN" />
  431. <category android:name="android.intent.category.LAUNCHER" />
  432. </intent-filter>
  433. </activity>
  434. <!-- facebook -->
  435. <meta-data android:name="com.facebook.sdk.ApplicationId"
  436. android:value="@string/facebook_app_id"/>
  437. <activity android:name="com.facebook.LoginActivity"
  438. android:theme="@android:style/Theme.Translucent.NoTitleBar"
  439. android:label="@string/app_name" />
  440.  
  441. <meta-data android:name="com.appodeal.framework"
  442. android:value="gideros" />
  443. <activity android:name="com.appodeal.ads.InterstitialActivity"
  444. android:configChanges="orientation|screenSize"
  445. android:theme="@android:style/Theme.Translucent.NoTitleBar" />
  446. <activity android:name="com.appodeal.ads.VideoActivity"
  447. android:configChanges="orientation|screenSize"
  448. android:theme="@android:style/Theme.Translucent.NoTitleBar" />
  449.  
  450. <activity android:name="com.appodeal.ads.LoaderActivity"
  451. android:configChanges="orientation|screenSize"
  452. android:theme="@android:style/Theme.Translucent.NoTitleBar" />
  453.  
  454. <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
  455.  
  456. <activity android:name="com.google.android.gms.ads.AdActivity"
  457. android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
  458. android:theme="@android:style/Theme.Translucent" />
  459.  
  460. <activity android:name="com.chartboost.sdk.CBImpressionActivity" android:excludeFromRecents="true"
  461. android:hardwareAccelerated="true" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
  462. android:configChanges="keyboardHidden|orientation|screenSize" />
  463.  
  464. <activity android:name="com.applovin.adview.AppLovinInterstitialActivity"
  465. android:theme="@android:style/Theme.Translucent" />
  466.  
  467. <activity android:name="com.mopub.mobileads.MoPubActivity"
  468. android:configChanges="keyboardHidden|orientation|screenSize"
  469. android:theme="@android:style/Theme.Translucent" />
  470. <activity android:name="com.mopub.common.MoPubBrowser"
  471. android:configChanges="keyboardHidden|orientation|screenSize" />
  472. <activity android:name="com.mopub.mobileads.MraidActivity"
  473. android:configChanges="keyboardHidden|orientation|screenSize" />
  474. <activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity"
  475. android:configChanges="keyboardHidden|orientation|screenSize" />
  476.  
  477. <activity android:name="org.nexage.sourcekit.mraid.MRAIDBrowser"
  478. android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
  479. android:theme="@android:style/Theme.Translucent" />
  480.  
  481. <activity android:name="com.amazon.device.ads.AdActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
  482.  
  483. <activity android:name="ru.mail.android.mytarget.ads.MyTargetActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
  484.  
  485. <activity android:name="org.nexage.sourcekit.vast.activity.VASTActivity"
  486. android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
  487.  
  488. <activity android:name="org.nexage.sourcekit.vast.activity.VPAIDActivity"
  489. android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
  490.  
  491. <!--suppress AndroidDomInspection -->
  492. <activity android:name="com.appodeal.ads.networks.vpaid.VPAIDActivity"
  493. android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
  494.  
  495. <activity android:name="com.appodeal.ads.networks.SpotXActivity"
  496. android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
  497. <!--suppress AndroidDomInspection -->
  498. <activity android:name="com.facebook.ads.InterstitialAdActivity" android:configChanges="keyboardHidden|orientation|screenSize" />
  499.  
  500. <activity android:name="com.unity3d.ads.android.view.UnityAdsFullscreenActivity"
  501. android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
  502. android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:hardwareAccelerated="true" />
  503. <activity android:name="com.unity3d.ads.android2.view.UnityAdsFullscreenActivity"
  504. android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
  505. android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:hardwareAccelerated="true" />
  506.  
  507.  
  508. <!--suppress AndroidDomInspection -->
  509. <activity android:name="com.jirbo.adcolony.AdColonyOverlay"
  510. android:configChanges="keyboardHidden|orientation|screenSize"
  511. android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
  512. <!--suppress AndroidDomInspection -->
  513. <activity android:name="com.jirbo.adcolony.AdColonyFullscreen"
  514. android:configChanges="keyboardHidden|orientation|screenSize"
  515. android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
  516. <!--suppress AndroidDomInspection -->
  517. <activity android:name="com.jirbo.adcolony.AdColonyBrowser"
  518. android:configChanges="keyboardHidden|orientation|screenSize"
  519. android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
  520. <!--suppress AndroidDomInspection -->
  521. <activity android:name="com.vungle.publisher.FullScreenAdActivity"
  522. android:configChanges="keyboardHidden|orientation|screenSize"
  523. android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
  524. <!--suppress AndroidDomInspection -->
  525. <activity android:name="com.startapp.android.publish.list3d.List3DActivity"
  526. android:theme="@android:style/Theme" />
  527. <!--suppress AndroidDomInspection -->
  528. <activity android:name="com.startapp.android.publish.OverlayActivity"
  529. android:theme="@android:style/Theme.Translucent"
  530. android:configChanges="orientation|keyboardHidden|screenSize" />
  531. <!--suppress AndroidDomInspection -->
  532. <activity android:name="com.startapp.android.publish.FullScreenActivity"
  533. android:theme="@android:style/Theme"
  534. android:configChanges="orientation|keyboardHidden|screenSize" />
  535. <service android:name="com.yandex.metrica.MetricaService" android:enabled="true"
  536. android:exported="true" android:process=":Metrica">
  537. <intent-filter>
  538. <category android:name="android.intent.category.DEFAULT" />
  539. <action android:name="com.yandex.metrica.IMetricaService" />
  540. <data android:scheme="metrica" />
  541. </intent-filter>
  542. <meta-data android:name="metrica:api:level" android:value="44" />
  543. </service>
  544. <receiver android:name="com.yandex.metrica.MetricaEventHandler"
  545. android:enabled="true" android:exported="true">
  546. <intent-filter>
  547. <action android:name="com.android.vending.INSTALL_REFERRER" />
  548. </intent-filter>
  549. </receiver>
  550. <!--suppress AndroidDomInspection -->
  551. <activity android:name="com.yandex.mobile.ads.AdActivity"
  552. android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
  553. <activity android:name="com.inmobi.rendering.InMobiAdActivity"
  554. android:configChanges="keyboardHidden|orientation|keyboard|smallestScreenSize|screenSize"
  555. android:theme="@android:style/Theme.Translucent.NoTitleBar" android:hardwareAccelerated="true" />
  556. <receiver android:name="com.inmobi.commons.core.utilities.uid.ImIdShareBroadCastReceiver"
  557. android:enabled="true" android:exported="true" >
  558. <intent-filter>
  559. <action android:name="com.inmobi.share.id" />
  560. </intent-filter>
  561. </receiver>
  562. <service android:enabled="true" android:name="com.inmobi.signals.activityrecognition.ActivityRecognitionManager" />
  563.  
  564. <!--suppress AndroidDomInspection -->
  565. <activity android:name="com.flurry.android.FlurryFullscreenTakeoverActivity"
  566. android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
  567.  
  568.  
  569. </application>
  570. </manifest>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement