Inheritance: java.lang.Object, Parcelable, java.lang.Cloneable
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);


            
            b.WithText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );

            var b2 = new Button(this);
            b2.setText("The other button!");
            ll.addView(b2);

            this.setContentView(sv);
        }
Esempio n. 2
0
        protected override void onCreate(android.os.Bundle arg0)
        {
            base.onCreate(arg0);

            LinearLayout layout = new LinearLayout(this);

            layout.setOrientation(LinearLayout.VERTICAL);
            Button btn = new Button(this);

            btn.setOnClickListener(this);
            btn.setText("threaD");
            layout.addView(btn);

            btn2 = new Button(this);
            btn2.setText("debug");
            btn2.setOnClickListener(new com.koushikdutta.monojavabridge.android.OnClickListener {
                OnClick = v =>
                {
                    Console.WriteLine("Foobar");
                }
            });
            layout.addView(btn2);

            tv = new TextView(this);
            layout.addView(tv);
            setContentView(layout);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            var activity = this;

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);



            b.WithText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );


        }
        // http://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle)
        // protected void onCreate (Bundle savedInstanceState)
        //     protected virtual void onCreate(Bundle savedInstanceState);

        // http://developer.android.com/reference/android/app/ListActivity.html
        // public void onCreate(Bundle savedInstanceState) {
        //1>X:\jsc.svn\examples\java\android\synergy\xcatlog\xcatlog\ApplicationActivity.cs(21,33,21,41): error CS0507: 'xcatlog.Activities.ApplicationActivity.onCreate(android.os.Bundle)': cannot change access modifiers when overriding 'public' inherited member 'com.nolanlawson.logcat.LogcatActivity.onCreate(android.os.Bundle)'
        // 
        public override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            // ok lets do some code review.
            // whats the least ammount of effort to capture a log line and steam it over udp?
            // it seems to start by
            // X:\opensource\github\Catlog\Catlog\src\com\nolanlawson\logcat\LogcatActivity.java
            // then startUpMainLog
            // LogReaderAsyncTask
            // line = reader.readLine()
            //LogcatReaderLoader loader = LogcatReaderLoader.create(LogcatActivity.this, true);
            //         reader = loader.loadReader();
            // import com.nolanlawson.logcat.reader.LogcatReaderLoader;
            // X:\opensource\github\Catlog\Catlog\src\com\nolanlawson\logcat\reader\LogcatReaderLoader.java
            // SingleLogcatReader

            // X:\opensource\github\Catlog\Catlog\src\com\nolanlawson\logcat\reader\SingleLogcatReader.java
            // 	logcatProcess = LogcatHelper.getLogcatProcess(logBuffer);
            //bufferedReader = new BufferedReader(new InputStreamReader(logcatProcess
            //        .getInputStream()), 8192);
            // did we find the magic?

            // X:\opensource\github\Catlog\Catlog\src\com\nolanlawson\logcat\helper\LogcatHelper.java
            // um
            // "logcat", "-v", "time")

            // so.  logging is like the shell example we used to have?





            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150606/adb
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);



            b.WithText(Foo.Bar("hello via .java"));
            b.AtClick(
                v =>
                {
                    b.WithText(Foo.Bar("click!"));
                }
            );



            this.setContentView(sv);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);



            b.WithText("popup");
            b.AtClick(
                v =>
                {
                    XStandOutWindow.closeAll(this, typeof(XWidgetsWindow).ToClass());
                    XStandOutWindow.show(this, typeof(XWidgetsWindow).ToClass(), XStandOutWindow.DEFAULT_ID);

                    this.finish();

                }
            );

            this.setContentView(sv);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);


            var b = new Button(this);
            b.setText("I don't do anything, but I was added dynamically. :)");
            ll.addView(b);


            Action onclick = delegate
            {
                b.setText("onclick");
            };

            b.setText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );

            var b2 = new Button(this);
            b2.setText("The other button!");
            ll.addView(b2);

            this.setContentView(sv);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            Console.WriteLine("HybridGLES3JNIActivity onCreate");

            base.onCreate(savedInstanceState);
            mView = new GLES3JNIView(getApplication());
            setContentView(mView);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            //            Error	1	The expression being assigned to 'TestCharSequenceAsStringAndConst.Activities.ApplicationActivity.uuu' must be constant	y:\jsc.svn\examples\java\Test\TestCharSequenceAsStringAndConst\TestCharSequenceAsStringAndConst\ApplicationActivity.cs	40	32	TestCharSequenceAsStringAndConst
            //Error	3	Argument 1: cannot convert from 'string' to 'java.lang.CharSequence'	y:\jsc.svn\examples\java\Test\TestCharSequenceAsStringAndConst\TestCharSequenceAsStringAndConst\ApplicationActivity.cs	37	31	TestCharSequenceAsStringAndConst

            //Native.IFoo.

            Native.Foo.invoke("hello" + Native.Foo.iss);
        }
        protected override void onCreate(Bundle value)
        {
            this.ApplicationFile = "index.htm";

            base.onCreate(value);

            this.ToNotification("xavalon.net", uri, 0, uri: uri);

        }
        // http://code.google.com/p/modelview-android/
        // "C:\util\android-sdk-windows\platform-tools\aapt.exe"  package -v -f -m -S Y:\opensource\googlecode\modelview-android\res -M "Y:\opensource\googlecode\modelview-android\AndroidManifest.xml" -I "C:\util\android-sdk-windows\platforms\android-16\android.jar" -J Y:\jsc.svn\examples\java\android\ModelViewerActivity\ModelViewerActivity

        //E/AndroidRuntime( 1669): Caused by: java.lang.SecurityException: Permission Denial: killBackgroundProcesses() from pid=1669, uid=10109 requires android.permission.KILL_BACKGROUND_PROCESSES
        //E/AndroidRuntime( 1669):        at android.os.Parcel.readException(Parcel.java:1425)
        //E/AndroidRuntime( 1669):        at android.os.Parcel.readException(Parcel.java:1379)
        //E/AndroidRuntime( 1669):        at android.app.ActivityManagerProxy.killBackgroundProcesses(ActivityManagerNative.java:3174)
        //E/AndroidRuntime( 1669):        at android.app.ActivityManager.killBackgroundProcesses(ActivityManager.java:1645)
        //E/AndroidRuntime( 1669):        at org.jtb.modelview.ui.BrowseActivity$1.run(BrowseActivity.java:42)
        //E/AndroidRuntime( 1669):        at org.jtb.modelview.ui.BrowseActivity.onResume(BrowseActivity.java:39)
        //E/AndroidRuntime( 1669):        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1184)
        //E/AndroidRuntime( 1669):        at android.app.Activity.performResume(Activity.java:5082)
        //E/AndroidRuntime( 1669):        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2565)
        //E/AndroidRuntime( 1669):        ... 12 more
        //W/ActivityManager(  349):   Force finishing activity org.jtb.modelview/.ApplicationActivity
        //W/ActivityManager(  349): Activity pause timeout for ActivityRecord{42130978 org.jtb.modelview/.ApplicationActivity}
        //I/ActivityManager(  349): No longer want com.skype.raider (pid 26479): hidden #16



        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);


            Toast.makeText(
                 this,
                 "http://jsc-solutions.net",
                 Toast.LENGTH_LONG
             ).show();
        }
            //public
            override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);



            StandOutWindow.closeAll(this, typeof(XWidgetsWindow).ToClass());
            StandOutWindow.show(this, typeof(XWidgetsWindow).ToClass(), StandOutWindow.DEFAULT_ID);

            this.finish();
        }
        // ref

        protected override void onCreate(Bundle savedInstanceState)
        {
            Console.WriteLine("LauncherActivity onCreate");
            // and yes we are now running jar/so browser.
            // need /assets and /res too tho
            base.onCreate(savedInstanceState);

            //this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);


        }
        // X:\opensource\ovr_mobile_sdk_0.5.1\VRLib\src\com\oculusvr\vrlib\VrActivity.java
        // com.oculusvr.vrlib
        // ActivityGroup

        // u:\chromium\src\chrome\android\shell\java\src\org\chromium\chrome\shell\ChromeShellActivity.java
        // ActionBarActivity
        // https://developer.android.com/reference/android/support/v4/app/FragmentActivity.html
        // https://developer.android.com/reference/android/support/v7/app/AppCompatActivity.html
        // http://developer.android.com/reference/android/app/ActivityGroup.html


        protected override void onCreate(Bundle savedInstanceState)
        {
            //org.chromium.chrome.shell.TabManager.DEFAULT_URL = "https://explore.xavalon.net";
            org.chromium.chrome.shell.TabManager.DEFAULT_URL = "http://192.168.1.126:27535";
            base.onCreate(savedInstanceState);
            return;

#if xgearvr

            // https://forums.oculus.com/viewtopic.php?f=67&t=22886&p=266775#p266775

            //base.onCreate(savedInstanceState);

            //var sv = new ScrollView(this);
            //var ll = new LinearLayout(this);
            ////ll.setOrientation(LinearLayout.VERTICAL);
            //sv.addView(ll);

            //var b = new Button(this).AttachTo(ll);



            //b.WithText("can we show chrome and vr?");
  

            //this.setContentView(sv);


            android.content.Intent intent = getIntent();

            // we are vr_dual arent we
            Console.WriteLine("invoke HybridOculusVrActivity.OVRJVM ApplicationActivity onCreate logApplicationVrType");
            com.oculusvr.vrlib.VrLib.logApplicationVrType(this);

            var commandString = com.oculusvr.vrlib.VrLib.getCommandStringFromIntent(intent);
            var fromPackageNameString = com.oculusvr.vrlib.VrLib.getPackageStringFromIntent(intent);
            var uriString = com.oculusvr.vrlib.VrLib.getUriStringFromIntent(intent);
            // why are we roundtriping intent details?


            Console.WriteLine("invoke base  HybridOculusVrActivity.OVRJVM ApplicationActivity nativeSetAppInterface "  );

            // https://forums.oculus.com/viewtopic.php?f=67&t=17790
            this.appPtr = HybridOculusVrActivity.OVRJVM.ApplicationActivity.nativeSetAppInterface(
                this,
                fromPackageNameString, commandString, uriString
            );

            Console.WriteLine("invoke base  HybridOculusVrActivity.OVRJVM ApplicationActivity nativeSetAppInterface done");
#endif

        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

            //this.ToFullscreen();

            var v = new RenderingContextView(this);
            var s = new RaySurface(v);

            this.setContentView(v);

            //this.TryHideActionbar(v);

            //this.ShowToast("http://my.jsc-solutions.net");
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);



            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );

            //var b2 = new Button(this);
            //b2.setText("The other button!");
            //ll.addView(b2);

            var ipa = Dns.GetHostAddresses(getLocalIpAddress())[0];

            var port = 8080;

            b.WithText(ipa + ":" + port);

            ClassLibrary1.Class1Shared.CreateServer(
                ipa,
                port,
                x =>
                {
                    //b.WithText(x);
                    android.util.Log.wtf("APKWebServer", x);
                }
            ).Start();

            this.setContentView(sv);
        }
        // http://www.samsung.com/us/support/owners/product/GT-I9250TSGGEN

		protected override void onCreate(Bundle savedInstanceState)
		{
            ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext = this;


			base.onCreate(savedInstanceState);
            
            // USB tether 
            // SAMSUNG Android USB Remote NDIS Network Device

            ((WifiManager)this.getSystemService(Context.WIFI_SERVICE)).createWifiLock(
                WifiManager.WIFI_MODE_FULL_HIGH_PERF,
                "InteractivePortForwarding"
                ).acquire();

			var r = default(global::ScriptCoreLib.Android.Windows.Forms.IAssemblyReferenceToken_Forms);

			var u = new UserControl1();

			u.AttachTo(this);
		}
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);


            var b = new Button(this).AttachTo(ll);

            var uri = new Uri("http://download.jsc-solutions.net/foo/bar.txt?a=1&b=2#frag1/frag2");




            Action<string> w =
                (x) => new Button(this).WithText(x).AttachTo(ll);


            w(
                new
                {
                    uri.OriginalString,
                    uri.Port,
                    uri.Query,
                    uri.PathAndQuery,
                    uri.Fragment,
                    uri.Host
                }.ToString()
            );



            this.setContentView(sv);

            //var foo = new Foo<FooElement>();
            //foo.Invoke(w);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);

            var goo = new foo.Goo();

            //Activator.CreateInstance<

            //var goo = (foo.Goo)Activator.CreateInstance(
            //    typeof(foo.Goo)
            //);

            //E/AndroidRuntime(32112): Caused by: java.lang.RuntimeException
            //E/AndroidRuntime(32112):        at foo.Bar.GetBarString(Bar.java:29)
            //E/AndroidRuntime(32112):        at foo.Goo.GetString(Goo.java:9)
            //E/AndroidRuntime(32112):        at TestJavaNativesOverride.Activities.ApplicationActivity.onCreate(ApplicationActivity.java:69)

            b.WithText(goo.GetString());
            b.AtClick(
                v =>
                {
                    b.setText(
                         new assets::foo.Bar().GetBarString()
                    );
                }
            );


            this.setContentView(sv);



        }
        public override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            __EC2_START_INSTANCE.Handler = new local__EC2_START_INSTANCE
            {
                AtInvoke = delegate
                {
                    Toast.makeText(
                         this,
                         "! __EC2_START_INSTANCE",
                         Toast.LENGTH_LONG
                     ).show();
                }
            };

            Toast.makeText(
                 this,
                 "http://jsc-solutions.net",
                 Toast.LENGTH_LONG
             ).show();
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            {
                var b = new Button(this).AttachTo(ll);
                b.WithText("extras:");
            }

            // http://about-android.blogspot.com/2009/12/passing-data-or-parameter-to-another_02.html

            this.getIntent().With(
                intent =>
                {
                    intent.getExtras().With(
                        e =>
                        {
                            var keys = e.keySet().toArray();
                            foreach (string key in keys)
                            {
                                var b = new Button(this).AttachTo(ll);
                                b.WithText(new { key }.ToString());
                            }

                        }
                    );
                }
            );

            this.setContentView(sv);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            this.ApplicationFile = "Class5.htm";
            this.ApplicationScale = 200;


            this.onpagefinished =
                delegate
                {
                    try
                    {
                        // http://www.aganazzar.com/midi.html
                        // http://www.lastown.com/public/musique/warcraft/list.html
                        // http://gamemusic.wordpress.com/2007/12/09/warcraft-1-orcs-and-humans/



                        if (mediaPlayer != null)
                            mediaPlayer.stop();

                        mediaPlayer = new MediaPlayer();

                        var n = "zak.mp3";

                        if (width < height)
                            n = "Zak McKracken (Main Titles).mid";

                        var assetFileDescritor = this.getAssets().openFd(n);

                        mediaPlayer.reset();

                        mediaPlayer.setDataSource(

                            //"IntroWarII.mp3");

                            assetFileDescritor.getFileDescriptor(),
                            assetFileDescritor.getStartOffset(),
                            assetFileDescritor.getLength()
                            );

                        //add this ? ---------------------------------------
                        //close the descriptor
                        assetFileDescritor.close();
                        //add this ? ---------------------------------------


                        //mediaPlayer.prepare();
                        mediaPlayer.setOnPreparedListener(
                            new _prepared { }
                        );
                        //mediaPlayer.setOnCompletionListener(
                        //    new _OnCompletionListener());

                        //mediaPlayer.setOnErrorListener(
                        //    new _OnErrorListener());


                        mediaPlayer.prepare();
                        mediaPlayer.setLooping(true);

                        //this.ShowLongToast("music: " + n);
                    }
                    catch //(System.Exception e)
                    {
                        //this.ShowLongToast("error " + ((object)e).ToString());

                        //throw;
                    }
                };

            base.onCreate(savedInstanceState);

            
        }
Esempio n. 23
0
        public XWindow(XStandOutWindow xcontext, int id)
            : base(xcontext)
        {
            var context = xcontext;

            context.setTheme(context.getThemeStyle());

            mContext = context;
            //mLayoutInflater = LayoutInflater.from(context);

            this.cls = context.GetType().ToClass();
            this.id = id;
            this.originalParams = context.getParams(id, this);
            this.flags = context.getFlags(id);
            this.touchInfo = new XTouchInfo();
            touchInfo.ratio = (float)originalParams.width / originalParams.height;
            this.data = new Bundle();
            DisplayMetrics metrics = mContext.getResources()
                    .getDisplayMetrics();
            displayWidth = metrics.widthPixels;
            displayHeight = (int)(metrics.heightPixels - 25 * metrics.density);

            // create the window contents
            View content;
            FrameLayout body;


            content = new FrameLayout(context);
            body = (FrameLayout)content;

            addView(content);

            body.setOnTouchListener(new XOnTouchListener
            {

                yield = (View v, MotionEvent @event) =>
                {
                    // pass all touch events to the implementation
                    var consumed = false;

                    // handle move and bring to front
                    consumed = context.onTouchHandleMove(id, this, v, @event)
                            || consumed;

                    // alert implementation
                    consumed = context.onTouchBody(id, this, v, @event)
                            || consumed;

                    return consumed;
                }
            });

            // attach the view corresponding to the id from the
            // implementation
            context.createAndAttachView(id, body);

            // make sure the implementation attached the view
            if (body.getChildCount() == 0)
            {
                throw new System.Exception(
                        "You must attach your view to the given frame in createAndAttachView()");
            }

            //// implement StandOut specific workarounds
            //if (!XUtils.isSet(flags,
            //        XStandOutFlags.FLAG_FIX_COMPATIBILITY_ALL_DISABLE))
            //{
            //    fixCompatibility(body);
            //}
            //// implement StandOut specific additional functionality
            //if (!XUtils.isSet(flags,
            //        XStandOutFlags.FLAG_ADD_FUNCTIONALITY_ALL_DISABLE))
            //{
            //    addFunctionality(body);
            //}

            // attach the existing tag from the frame to the window
            setTag(body.getTag());
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            var activity = this;
            // http://stackoverflow.com/questions/11425020/actionbar-in-a-dialogfragment
            //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest
            //activity.requestWindowFeature(Window.FEATURE_ACTION_BAR);
            //activity.getWindow().setFlags(WindowManager_LayoutParams.FLAG_DIM_BEHIND, WindowManager_LayoutParams.FLAG_DIM_BEHIND);
            //activity.getWindow().setFlags(WindowManager_LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager_LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //var @params = activity.getWindow().getAttributes();
            ////@params.height = WindowManager_LayoutParams.FILL_PARENT;
            ////@params.width = 850; //fixed width
            ////@params.height = 450; //fixed width
            //@params.alpha = 1.0f;
            //@params.dimAmount = 0.5f;
            //activity.getWindow().setAttributes(@params);
            //activity.getWindow().setLayout(850, 850);
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);


            // https://stackoverflow.com/questions/1898886/removing-an-activity-from-the-history-stack

            b.WithText("start secondary");
            b.AtClick(
                v =>
                {
                    foo = "hi";

                    Intent intent = new Intent(this, typeof(SecondaryActivity).ToClass());
                    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    startActivity(intent);
                }
            );

            this.AtPause += delegate { b.setText("AtPause"); };
            this.AtResume += delegate { b.setText("AtResume"); };


            AtPrepareOptions +=
                value =>
                {
                    value.clear();

                    var item1 = value.add(
                         (java.lang.CharSequence)(object)"http://abstractatech.com"
                    );



                    item1.setIcon(android.R.drawable.ic_menu_view);

                    var item2 = value.add(
                        (java.lang.CharSequence)(object)"http://jsc-solutions.net"
                    );

                    //item2.setIcon(android.R.drawable.ic_menu_edit);
                    item2.setIcon(android.R.drawable.ic_menu_view);

                    var i = new Intent(Intent.ACTION_VIEW,
                        android.net.Uri.parse("http://jsc-solutions.net")
                    );

                    // http://vaibhavsarode.wordpress.com/2012/05/14/creating-our-own-activity-launcher-chooser-dialog-android-launcher-selection-dialog/
                    var ic = Intent.createChooser(i, "http://jsc-solutions.net");


                    item2.setIntent(
                        ic
                    );
                };

            AtOption +=
                item =>
                {

                    //b.WithText("menu was clicked!" + (string)(object)item.getTitle());
                    b.WithText("menu was clicked!" + new { item });
                };

            var b2 = new Button(this);
            b2.setText("The other button!");
            ll.addView(b2);

            this.setContentView(sv);



            vConfigurationChanged = e =>
            {
                var orientation = getScreenOrientation();

                var SystemUiVisibility = getWindow().getDecorView().getSystemUiVisibility();

                b2.setText(
                    new
                    {
                        orientation,
                        SystemUiVisibility
                    }.ToString()
                );


                if (orientation == Configuration.ORIENTATION_LANDSCAPE)
                {
                    hideSystemUI();
                }
                else
                {
                    showSystemUI();
                }
            };

            vConfigurationChanged(null);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            // http://www.mkyong.com/android/android-activity-from-one-screen-to-another-screen/

            base.onCreate(savedInstanceState);

            //this.getWindow().getDecorView()
            //this.getWindow().setTitle("secondary " + new { ApplicationActivity.foo});
            //this.getWindow().setTitleColor(0xff0000);

            // Set the IMMERSIVE flag.
            // Set the content to appear under the system bars so that the content
            // doesn't resize when the system bars hide and show.
            getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                    | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);
            this.setContentView(sv);

            var b = new Button(this).AttachTo(ll);



            b.WithText(" secondary " + new { ApplicationActivity.foo });
            b.AtClick(
                v =>
                {
                    this.finish();
                }
            );

            //this.AtPause += delegate
            //{
            //    this.finish();
            //};

            //this.AtWindowFocusChanged += e =>
            //    {
            //        if (!e)
            //            this.finish();


            //    };

            //this.AtUserLeaveHint += delegate { this.finish(); };

            //this.onfo
            //this.onWindowFocusChanged
            //public void onWindowFocusChanged (boolean hasFocus)
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

            //this.ToFullscreen();

            var v = new RenderingContextView(this);

            v.onsurface +=
                gl =>
                {
                    //var __gl = (ScriptCoreLib.Android.__WebGLRenderingContext)(object)gl;

                    Log.wtf("AndroidGLEscherDrosteEffectActivity", "onsurface");

                    var program = gl.createProgram(
                            new EscherDorsteVertexShader(),
                            new EscherDorsteFragmentShader()
                        );

                    gl.bindAttribLocation(program, 0, "position");

                    gl.linkProgram(program);
                    gl.useProgram(program);

                    var uniforms = program.Uniforms(gl);


                    #region loadTexture
                    Func<android.graphics.Bitmap, ScriptCoreLib.JavaScript.WebGL.WebGLTexture> loadTexture = (image) =>
                    {
                        var texture_ = gl.createTexture();

                        gl.enable(gl.TEXTURE_2D);
                        gl.bindTexture(gl.TEXTURE_2D, texture_);

                        //public void texImage2D(uint target, int level, uint internalformat, uint format, uint type, IHTMLCanvas canvas);
                        //public void texImage2D(uint target, int level, uint internalformat, uint format, uint type, IHTMLVideo video);
                        //public void texImage2D(uint target, int level, uint internalformat, uint format, uint type, ImageData pixels);
                        //public void texImage2D(uint target, int level, uint internalformat, int width, int height, int border, uint format, uint type, ArrayBufferView pixels);

                        //public void texImage2D(uint target, int level, uint internalformat, uint format, uint type, IHTMLImage image);
                        //gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);

                        //E/AndroidRuntime( 5131): Caused by: java.lang.IllegalArgumentException: invalid Bitmap format
                        //E/AndroidRuntime( 5131):        at android.opengl.GLUtils.texImage2D(GLUtils.java:127)
                        //E/AndroidRuntime( 5131):        at AndroidGLEscherDrosteEffectActivity.Activities.ApplicationActivity___c__DisplayClass5___c__DisplayClass7._onCreate_b__1(ApplicationActivity___c__DisplayClass5___c__DisplayClass7.java:62)

                        //GLUtils.texImage2D(
                        //    /*target*/ (int)gl.TEXTURE_2D,
                        //    /*level*/ 0,
                        //    /*internalformat*/(int)gl.RGBA,
                        //    image,
                        //    /*type*/  (int)gl.UNSIGNED_BYTE,
                        //    0
                        //);

                        // Load the bitmap into the bound texture.
                        GLUtils.texImage2D((int)gl.TEXTURE_2D, 0, image, 0);


                        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, (int)gl.LINEAR);
                        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (int)gl.LINEAR_MIPMAP_LINEAR);
                        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, (int)gl.REPEAT);
                        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, (int)gl.REPEAT);
                        gl.generateMipmap(gl.TEXTURE_2D);


                        // Recycle the bitmap, since its data has been loaded into OpenGL.
                        image.recycle();


                        return texture_;
                    };
                    #endregion

                    #region openFileFromAssets
                    Func<string, InputStream> openFileFromAssets = (string spath) =>
                    {
                        InputStream value = null;
                        try
                        {
                            value = this.getResources().getAssets().open(spath);
                        }
                        catch
                        {

                        }
                        return value;

                    };
                    #endregion

                    var texture__ = android.graphics.BitmapFactory.decodeStream(
                        openFileFromAssets("assets/AndroidGLEscherDrosteEffectActivity/escher.jpg")
                    );
                    var texture = loadTexture(
                        texture__
                    );

                    gl.uniform1i(gl.getUniformLocation(program, "texture"), 0);

                    gl.enableVertexAttribArray(0);


                    var vertices = gl.createBuffer();
                    gl.bindBuffer(gl.ARRAY_BUFFER, vertices);
                    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
                        -1f, -1f, -1f, 1f, 1f, -1f, 1f, 1f
                    ), gl.STATIC_DRAW);
                    gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);

                    var indices = gl.createBuffer();
                    gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indices);
                    gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(
                        0, 1, 2, 3
                    ), gl.STATIC_DRAW);

                    #region onresize
                    v.onresize +=
                        (width, height) =>
                        {
                            Log.wtf("AndroidGLEscherDrosteEffectActivity", "onresize");

                            gl.viewport(0, 0, width, height);

                            var h = (float)height / (float)width;
                            gl.uniform1f(gl.getUniformLocation(program, "h"), h);
                        };
                    #endregion

                    var parameters_time = 0f;

                    #region onframe
                    var framecount = 0;
                    v.onframe +=
                        delegate
                        {
                            var t = parameters_time / 1000f;

                            if (framecount == 0)
                                Log.wtf("AndroidGLEscherDrosteEffectActivity", "onframe " + ((object)t).ToString());

                            parameters_time += 100;

                            uniforms.t = t;

                            //gl.uniform1f(gl.getUniformLocation(program, "t"), t);
                            gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_SHORT, 0);
                            gl.flush();

                            framecount++;
                        };
                    #endregion

                    Log.wtf("AndroidGLEscherDrosteEffectActivity", "onsurface done");

                };


            this.setContentView(v);

            //this.TryHideActionbar(v);

            this.ShowToast("http://my.jsc-solutions.net");
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            // http://www.mkyong.com/android/android-activity-from-one-screen-to-another-screen/

            base.onCreate(savedInstanceState);
            vCreate(this, savedInstanceState);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);


            var b = new Button(this).AttachTo(ll);


            var ip = getLocalIpAddress();



            b.WithText("server at " + ip);
            b.AtClick(
                v =>
                {
                    var random = new System.Random();

                    // Error 312 (net::ERR_UNSAFE_PORT): Unknown error.
                    var port = random.Next(1024, 32000);

                    var uri = "http://" + ip;

                    uri += ":";
                    uri += ((object)(port)).ToString();

                    b.setText(uri);

                    Toast.makeText(
                          this,
                          "connect to this web server", 
                          Toast.LENGTH_LONG
                      ).show();

                    var ipa = Dns.GetHostAddresses(ip)[0];


                    Action<string> log = x => Log.wtf("ApplicationActivity", x);

                    // jsc does not import generic param, why?
                    //Action<NetworkStream> AtConnection =
                    NetworkStreamAction AtConnection =
                        s =>
                        {

                            //log("AtConnection");

                            var r = new StreamReader(s);

                            var h0 = r.ReadLine();

                            //log("ReadLine done");

                            var m = new MemoryStream();

                            Action<string> WriteLineASCII = (string e) =>
                            {
                                var x = Encoding.ASCII.GetBytes(e + "\r\n");

                                m.Write(x, 0, x.Length);
                            };

                            WriteLineASCII("HTTP/1.1 200 OK");
                            WriteLineASCII("Content-Type:	text/html; charset=utf-8");
                            //WriteLineASCII("Content-Length: " + data.Length);
                            WriteLineASCII("Connection: close");


                            WriteLineASCII("");
                            WriteLineASCII("");
                            WriteLineASCII("<html>");

                            WriteLineASCII("<body><h1 style='color: red;'>Hello world</h2><h3>jsc</h3><pre>" + h0 + "</pre></body>");

                            WriteLineASCII("</html>");

                            log("write done");

                            var oa = m.ToArray();

                            s.Write(oa, 0, oa.Length);

                            s.Flush();
                            s.Close();
                        };

                    //                    AndroidTcpListenerActivity.AndroidActivity 003e create: AndroidTcpListenerActivity.Activities.ApplicationActivity+<>c__DisplayClass8+<>c__DisplayClassb
                    //switch to STA Exception:
                    //System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: The IL Generator cannot be used while there are unclosed exceptions.
                    //   at System.Reflection.Emit.ILGenerator.BakeByteArray()
                    //   at System.Reflection.Emit.MethodBuilder.CreateMethodBodyHelper(ILGenerator il)
                    //   at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
                    //   at System.Reflection.Emit.TypeBuilder.CreateType()

                    new Thread(
                            delegate()
                            {
                                var r = new TcpListener(ipa, port);

                                //try
                                //{
                                r.Start();

                                while (true)
                                {
                                    //log("AcceptTcpClient");
                                    var c = r.AcceptTcpClient();
                                    //log("AcceptTcpClient done, GetStream");

                                    var s = c.GetStream();
                                    //log("AcceptTcpClient done, GetStream done");

                                    new Thread(
                                        delegate()
                                        {
                                            //log("before AtConnection");
                                            AtConnection(s);
                                        }
                                    )
                                    {
                                        IsBackground = true,
                                    }.Start();
                                }

                                //}
                                //catch
                                //{
                                //    log("AcceptTcpClient error!");

                                //    throw;
                                //}


                            }
                        )
                    {
                        IsBackground = true,
                    }.Start();
                }
            );

            var b2 = new Button(this);
            b2.setText("The other button!");
            ll.addView(b2);

            this.setContentView(sv);
        }
Esempio n. 29
0
        // https://forums.oculus.com/viewtopic.php?f=67&t=22886

        //
        // Just as a side note, you can actually run the app on the Note 4 without having a VR Gear.
        // Just change the manifest android:value="vr_only" to android:value="vr_dual" and the message will be gone. You still need to have a valid signature file nevertheless.

        // https://forums.oculus.com/viewtopic.php?f=67&t=17244
        // The way it is designed, you never see a VR image outside of the Gear headset, or a 2D image inside it.
        // When you launch a VR app it just tells you to put on the Gear and doesn't show anything on the screen.
        // Home is a bit of an exception because it does have an out-of-VR store UI as well, but it won't install
        // on current firmware.

        //public com.oculusvr.vrlib.VrActivity ref0;

        //W/JniUtils(10537): enter ovr_GetGlobalClassReference
        //W/JniUtils(10537): com/oculusvr/vrlib/VrLib
        //W/JniUtils(10537): fail ovr_GetGlobalClassReference
        //W/JniUtils(10537): FindClass( com/oculusvr/vrlib/VrLib ) failed

        // jint JNI_OnLoad( JavaVM* vm, void* reserved )
        // X:\opensource\ovr_mobile_sdk_20141111\VRLib\jni\App.cpp
        // ovr_OnLoad( vm );
        // X:\opensource\ovr_mobile_sdk_20141111\VRLib\jni\VrApi\VrApi.cpp
        // X:\opensource\ovr_mobile_sdk_20141111\VRLib\jni\VrApi\JniUtils.cpp
        // VrLibClass = ovr_GetGlobalClassReference( jni, "com/oculusvr/vrlib/VrLib" );

        // i think it crashes because we do not have the things java source linked with us

        //I/DEBUG   (  122):     #05  pc 000a46d0  /data/app-lib/HybridOculusVrActivity.OVRJVM-1/libHybridOculusVrActivity.so (ovr_GetGlobalClassReference(_JNIEnv*, char const*)+112)
        //I/DEBUG   (  122):     #06  pc 00093364  /data/app-lib/HybridOculusVrActivity.OVRJVM-1/libHybridOculusVrActivity.so (ovr_OnLoad+100)
        //I/DEBUG   (  122):     #07  pc 000b9004  /data/app-lib/HybridOculusVrActivity.OVRJVM-1/libHybridOculusVrActivity.so (JNI_OnLoad+48)
        //I/DEBUG   (  122):     #08  pc 00050005  /system/lib/libdvm.so (dvmLoadNativeCode(char const*, Object*, char**)+468)


        // if we were to include AssetsLibrary,
        // how can we force non merge/ script ?


        // VrActivity



        // wo dont yet have the cool dispatcher for arm
        // X:\jsc.svn\core\ScriptCoreLibJava.jni\web\bin\jnistb10\dispatch.c

        // X:\jsc.svn\core\ScriptCoreLibJava.jni\BCLImplementation\ScriptCoreLib\Shared\PlatformInvocationServices.cs
        // could we load any .so on will?

        // X:\opensource\ovr_mobile_sdk_0.5.1\VRLib\jni\Integrations\PureJava\PureJava.cpp

        protected override void onCreate(android.os.Bundle value)
        {
            // E/AndroidRuntime(27462): Caused by: java.lang.SecurityException: Neither user 10249 nor current process has android.permission.WAKE_LOCK.

            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150607

            Console.WriteLine("enter  HybridOculusVrActivity.OVRJVM ApplicationActivity onCreate");
            //getWindow().requestFeature(android.view.Window.FEATURE_NO_TITLE);
            //setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            getWindow().requestFeature(android.view.Window.FEATURE_NO_TITLE);
            getWindow().addFlags(WindowManager_LayoutParams.FLAG_KEEP_SCREEN_ON);
            // https://developer.android.com/reference/android/os/PowerManager.WakeLock.html#release()
            PowerManager powerManager = (PowerManager)getSystemService(POWER_SERVICE);
            var          wakeLock     = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK,
                                                                 "MyWakelockTag");

            wakeLock.acquire();

            Toast.makeText(
                this,
                stringFromJNI() + " can you see it?",
                Toast.LENGTH_LONG
                ).show();

            Console.WriteLine("invoke base  HybridOculusVrActivity.OVRJVM ApplicationActivity onCreate");
            base.onCreate(value);

            ////var ll = new LinearLayout(this);
            ////ll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));


            ////this.setContentView(ll);

            ////var leftSurface = new android.opengl.GLSurfaceView(this, null);
            ////leftSurface.setLayoutParams(new LinearLayout.LayoutParams(1, LinearLayout.LayoutParams.MATCH_PARENT) { weight = 1.0f });
            //////leftSurface.setId();
            //////leftSurface.AttachTo(ll);
            ////ll.addView(leftSurface);
            ////var rightSurface = new android.opengl.GLSurfaceView(this, null);
            ////rightSurface.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT) { weight = 1.0f });
            //////rightSurface.AttachTo(ll);
            ////ll.addView(rightSurface);


            // http://through-the-interface.typepad.com/through_the_interface/2015/01/building-a-gear-vr-app-using-the-oculus-mobile-sdk.html
            //E/AndroidRuntime(13031): android.util.SuperNotCalledException: Activity {HybridOculusVrActivity.OVRJVM/HybridOculusVrActivity.OVRJVM.ApplicationActivity} did not call through to super.onCreate()
            //E/AndroidRuntime(13031):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2150)
            //E/AndroidRuntime(13031):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
            //E/AndroidRuntime(13031):        at android.app.ActivityThread.access$800(ActivityThread.java:135)
            //E/AndroidRuntime(13031):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            //E/AndroidRuntime(13031):        at android.os.Handler.dispatchMessage(Handler.java:102)
            //E/AndroidRuntime(13031):        at android.os.Looper.loop(Looper.java:136)
            //E/AndroidRuntime(13031):        at android.app.ActivityThread.main(ActivityThread.java:5001)

            // why call the base?


            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150504/dae

            //var tv = new TextView(this);
            //tv.setText(stringFromJNI());
            //setContentView(tv);

            //this.ShowToast(
            //    stringFromJNI()
            //    );


            //<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_dual"/>
            //



            // if we do not set it we are going to crash.
            //var appPtr = nativeSetAppInterface(ref0);

            android.content.Intent intent = getIntent();

            // we are vr_dual arent we
            Console.WriteLine("invoke HybridOculusVrActivity.OVRJVM ApplicationActivity onCreate logApplicationVrType");
            com.oculusvr.vrlib.VrLib.logApplicationVrType(this);

            var commandString         = com.oculusvr.vrlib.VrLib.getCommandStringFromIntent(intent);
            var fromPackageNameString = com.oculusvr.vrlib.VrLib.getPackageStringFromIntent(intent);
            var uriString             = com.oculusvr.vrlib.VrLib.getUriStringFromIntent(intent);

            // why are we roundtriping intent details?


            //assembly: X:\jsc.svn\examples\c\android\HybridOculusVrActivity\HybridOculusVrActivity\bin\Debug\HybridOculusVrActivity.dll at
            //type: <>f__AnonymousType0`3, HybridOculusVrActivity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
            //method: ToString
            //type not supported: System.Text.StringBuilder ; consider adding [ScriptAttribute]


            // I/System.Console(11661): invoke base  HybridOculusVrActivity.OVRJVM ApplicationActivity nativeSetAppInterface  fromPackageNameString:
            // empty why?
            Console.WriteLine("invoke base  HybridOculusVrActivity.OVRJVM ApplicationActivity nativeSetAppInterface " +
                              //new
                              //{
                              " fromPackageNameString: " + fromPackageNameString
                              //commandString,
                              //uriString
                              //}
                              );

            // https://forums.oculus.com/viewtopic.php?f=67&t=17790
            this.appPtr = nativeSetAppInterface(this,
                                                fromPackageNameString, commandString, uriString
                                                );

            Console.WriteLine("invoke base  HybridOculusVrActivity.OVRJVM ApplicationActivity nativeSetAppInterface done");



            //nativeResume(appPtr);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            this.ApplicationFile = "index.htm";
            this.ApplicationScale = 150;


            this.onpagefinished =
                delegate
                {
                    try
                    {
                        // http://www.aganazzar.com/midi.html
                        // http://www.lastown.com/public/musique/warcraft/list.html
                        // http://gamemusic.wordpress.com/2007/12/09/warcraft-1-orcs-and-humans/



                        if (mediaPlayer != null)
                            mediaPlayer.stop();

                        mediaPlayer = new MediaPlayer();

                        var music = "Warcraft1_TitleTheme.mid";

                        if (width > height)
                            music = "war-gfx/intro.mid";

                        var  assetFileDescritor = this.getAssets().openFd(music);

                        mediaPlayer.reset();

                        mediaPlayer.setDataSource(

                            //"IntroWarII.mp3");

                            assetFileDescritor.getFileDescriptor(),
                            assetFileDescritor.getStartOffset(),
                            assetFileDescritor.getLength()
                            );

                        //add this ? ---------------------------------------
                        //close the descriptor
                        assetFileDescritor.close();
                        //add this ? ---------------------------------------


                        //mediaPlayer.prepare();
                        mediaPlayer.setOnPreparedListener(
                            new _prepared { }
                        );
                 

                        mediaPlayer.prepare();
                        mediaPlayer.setLooping(true);

                        this.ShowLongToast(new { music }.ToString());
                    }
                    catch (System.Exception e)
                    {
                        this.ShowLongToast("error " + ((object)e).ToString());

                        //throw;
                    }
                };

            base.onCreate(savedInstanceState);

        }
        // "x:\util\android-sdk-windows\platform-tools\adb.exe"  tcpip 5555
        // restarting in TCP mode port: 5555

        // "x:\util\android-sdk-windows\platform-tools\adb.exe" connect 192.168.1.126:5555
        // connected to 192.168.1.126:5555

        // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201505/20150513

        // lets verify this thing . deploy over wifi.

        //C:\Windows\system32> "x:\util\android-sdk-windows\platform-tools\adb.exe" shell netcfg
        //wlan0    UP                               192.168.1.126/24  0x00001043 e8:50:8b:7d:27:7c

        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            //var b = new Button(this).AttachTo(ll);

            //b.WithText("before AtClick");
            //b.AtClick(
            //    v =>
            //    {
            //        b.setText("AtClick");
            //    }
            //);


            this.setContentView(sv);





            // http://www.java2s.com/Tutorial/Java/0490__Security/KeyStoreExample.htm

            //I/System.Console( 5182): 143e:0001 ... { xKeyStoreDefaultType = BKS }
            //I/System.Console( 5182): 143e:0001 { xKeyStore = java.security.KeyStore@274cc17e }
            //I/System.Console( 5182): 143e:0001 load... { keyStoreType = BKS }
            //I/System.Console( 5182): 143e:0001 aliases...


            var xKeyStoreDefaultType = java.security.KeyStore.getDefaultType();

            Console.WriteLine("... " + new { xKeyStoreDefaultType });

            // are we running in GUI or TTY?
            // can we enumerate keystores?

            // ... { xKeyStoreDefaultType = jks }


            Action<string> f = keyStoreType =>
            {
                // jsc should do implicit try catch for closures? while asking for explicit catch for non closures?

                //{ ks = java.security.KeyStore@d3ade7 }
                //{ aliasKey = peer integrity authority for cpu BFEBFBFF000306A9, SerialNumber = 03729f49acf3e79d4cc40da08149433d, SimpleName = peer integrity authority for cpu BFEBFBFF000306A9 }
                //{ aliasKey = peer integrity authority for cpu BFEBFBFF000306C3, SerialNumber = c4761e1ea779bc9546151afce47c7c26, SimpleName = peer integrity authority for cpu BFEBFBFF000306C3 }

                try
                {
                    // http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/sun/security/mscapi/SunMSCAPI.java

                    // https://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html

                    // https://social.msdn.microsoft.com/Forums/expression/en-US/52dca221-1e05-44c1-8c45-9e0d4a807853/java-keystoreload-for-windowsmy-pops-up-insert-smart-card-window?forum=windowssecurity
                    // I removed some personal certificaties at key manager (certmgr.msc) and wala!

                    //Client Authentication (1.3.6.1.5.5.7.3.2)
                    //Secure Email (1.3.6.1.5.5.7.3.4)


                    // https://www.chilkatsoft.com/p/p_280.asp
                    // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\Defaults\Provider\Microsoft Base Smart Card Crypto Provider

                    // http://stackoverflow.com/questions/27692904/how-to-avoid-smart-card-selection-popup-when-accessing-windows-my-using-java

                    // http://stackoverflow.com/questions/4552100/how-to-prevent-popups-when-loading-a-keystore
                    // http://stackoverflow.com/questions/15220976/how-to-obtain-a-users-identity-from-a-smartcard-on-windows-mscapi-with-java

                    KeyStore xKeyStore = KeyStore.getInstance(keyStoreType);
                    Console.WriteLine(new { xKeyStore });
                    Console.WriteLine("load... " + new { keyStoreType });
                    xKeyStore.load(null, null);
                    //Console.WriteLine("load... done");
                    Console.WriteLine("aliases...");
                    java.util.Enumeration en = xKeyStore.aliases();
                    //Console.WriteLine("aliases... done");

                    while (en.hasMoreElements())
                    {
                        var aliasKey = (string)en.nextElement();

                        Console.WriteLine(new { aliasKey });

                        // PCSC?
                        var c509 = xKeyStore.getCertificate(aliasKey) as java.security.cert.X509Certificate;
                        if (c509 != null)
                        {
                            X509Certificate2 crt = new __X509Certificate2 { InternalElement = c509 };

                            //Console.WriteLine(new { crt.Subject, crt.SerialNumber, SimpleName = crt.GetNameInfo(System.Security.Cryptography.X509Certificates.X509NameType.SimpleName, false) });
                            Console.WriteLine(new { aliasKey, crt.SerialNumber, SimpleName = crt.GetNameInfo(System.Security.Cryptography.X509Certificates.X509NameType.SimpleName, false), crt.Issuer });

                        }
                        //if (aliasKey.equals("myKey") ) {
                        //      PrivateKey key = (PrivateKey)ks.getKey(aliasKey, "monPassword".toCharArray());
                        //      Certificate[] chain = ks.getCertificateChain(aliasKey);
                        //}
                    }

                }
                catch (Exception err)
                {
                    Console.WriteLine(new { err.Message, err.StackTrace });

                }
            };

            //hello ubuntu! { AssemblyQualifiedName = java.lang.Object, rt }
            //... { xKeyStoreDefaultType = jks }
            //{ xKeyStore = java.security.KeyStore@9980d5 }
            //load... { keyStoreType = jks }
            //aliases...
            //done


            new Button(this).AttachTo(ll).WithText(xKeyStoreDefaultType).AtClick(
                delegate
                {

                    // on RED there are no entries?
                    // what about ubuntu?
                    f(xKeyStoreDefaultType);
                }
            );
            //I/System.Console( 7167): 1bff:0001 load... { keyStoreType = AndroidKeyStore }
            //I/System.Console( 7167): 1bff:0001 aliases...


            new Button(this).AttachTo(ll).WithText("AndroidKeyStore").AtClick(
               delegate
               {

                   // on RED there are no entries?
                   // what about ubuntu?
                   f("AndroidKeyStore");
               }
           );



        }
Esempio n. 32
0
        protected override void onCreate(android.os.Bundle savedInstanceState)
        {
            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20160102/x360videos
            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20151006
            base.onCreate(savedInstanceState);


            nativeOnCreate(this);

            //setCurrentLanguage(Locale.getDefault().getLanguage());

            // Create the SoundPool
            soundPool           = new SoundPool(3 /* voices */, AudioManager.STREAM_MUSIC, 100);
            soundPoolSoundIds   = new java.util.ArrayList <int>();
            soundPoolSoundNames = new java.util.ArrayList <string>();

            AudioManager audioMgr;

            audioMgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
            var rate = audioMgr.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
            var size = audioMgr.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);

            System.Console.WriteLine("rate = " + rate);
            System.Console.WriteLine("size = " + size);

            // Check preferences
            SharedPreferences prefs = getApplicationContext().getSharedPreferences("oculusvr", MODE_PRIVATE);
            var username            = prefs.getString("username", "guest");

            System.Console.WriteLine("username = "******"action:" + intent.getAction());
            System.Console.WriteLine("type:" + intent.getType());
            System.Console.WriteLine("fromPackageName:" + fromPackageNameString);
            System.Console.WriteLine("command:" + commandString);
            System.Console.WriteLine("uri:" + uriString);

            SurfaceView sv = new SurfaceView(this);

            setContentView(sv);


            #region xCallback
            // X:\jsc.svn\examples\java\android\synergy\OVRVrCubeWorldSurfaceView\OVRVrCubeWorldSurfaceView\ApplicationActivity.cs
            var xCallback = new xCallback
            {
                onsurfaceCreated = holder =>
                {
                    if (appPtr == 0)
                    {
                        return;
                    }

                    nativeSurfaceCreated(appPtr, holder.getSurface());
                    mSurfaceHolder = holder;
                },

                onsurfaceChanged = (SurfaceHolder holder, int format, int width, int height) =>
                {
                    if (appPtr == 0)
                    {
                        return;
                    }

                    nativeSurfaceChanged(appPtr, holder.getSurface());
                    mSurfaceHolder = holder;
                },

                onsurfaceDestroyed = holder =>
                {
                    if (appPtr == 0)
                    {
                        return;
                    }

                    nativeSurfaceDestroyed(appPtr);
                    mSurfaceHolder = holder;
                }
            };
            #endregion

            sv.getHolder().addCallback(xCallback);

            // Force the screen to stay on, rather than letting it dim and shut off
            // while the user is watching a movie.
            //getWindow().addFlags( WindowManager_LayoutParams.FLAG_KEEP_SCREEN_ON );

            //// Force screen brightness to stay at maximum
            //WindowManager.LayoutParams params = getWindow().getAttributes();
            //params.screenBrightness = 1.0f;
            //getWindow().setAttributes( params );

            this.ondispatchTouchEvent += (e) =>
            {
                int   action = e.getAction();
                float x      = e.getRawX();
                float y      = e.getRawY();
                Log.d(TAG, "onTouch dev:" + e.getDeviceId() + " act:" + action + " ind:" + e.getActionIndex() + " @ " + x + "," + y);
                nativeTouch(appPtr, action, x, y);
                return(true);
            };

            this.ondispatchKeyEvent = (e) =>
            {
                bool down;
                int  keyCode  = e.getKeyCode();
                int  deviceId = e.getDeviceId();

                if (e.getAction() == KeyEvent.ACTION_DOWN)
                {
                    down = true;
                }
                else if (e.getAction() == KeyEvent.ACTION_UP)
                {
                    down = false;
                }
                else
                {
                    Log.d(TAG,
                          "source " + e.getSource() + " action "
                          + e.getAction() + " keyCode " + keyCode);

                    return(base.dispatchKeyEvent(e));
                }

                Log.d(TAG, "source " + e.getSource() + " keyCode " + keyCode + " down " + down + " repeatCount " + e.getRepeatCount());

                if (keyCode == KeyEvent.KEYCODE_VOLUME_UP)
                {
                    if (down)
                    {
                        adjustVolume(1);
                    }
                    return(true);
                }

                if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
                {
                    if (down)
                    {
                        adjustVolume(-1);
                    }
                    return(true);
                }


                // Joypads will register as keyboards, but keyboards won't
                // register as position classes
                // || event.getSource() != 16777232)
                // Volume buttons are source 257
                if (e.getSource() == 1281)
                {
                    // do we have one we can test with?

                    //keyCode |= JoyEvent.BUTTON_JOYPAD_FLAG;
                }
                return(buttonEvent(deviceId, keyCode, down, e.getRepeatCount()));
            };
        }
Esempio n. 33
-1
        protected override void onCreate(Bundle arg0)
        {
            base.onCreate(arg0);

            LinearLayout layout = new LinearLayout(this);
            layout.setOrientation(LinearLayout.VERTICAL);

            TextView tv = new TextView(this);
            tv.setText("Hello");
            tv.setTextSize(20);
            layout.addView(tv);

            tv = new TextView(this);
            tv.setText("World!");
            tv.setTextSize(15);
            tv.setTextColor(unchecked((int)0xFF00FFFF));
            layout.addView(tv);

            button = new Button(this);
            button.setText("wtf");
            layout.addView(button);
            button.setOnClickListener(new OnClickListener()
            {
                OnClick = (v) =>
                {
                    Console.WriteLine(toString());
                    button.setText(System.Environment.TickCount.ToString());
                }
            });
            /* 
             * Normally in Java, you'd handle the onClickListener with an inner class.
             * In C# there is no inner class construct.
            button.setOnClickListener(new OnClickListener()
            {
                @Override
                public void onClick()
                {
                }
            });
            */

            setContentView(layout);
        }