Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26634] Android Hyperloop: How to add android.view.WindowManager in hyperloop?

GitHub Issuen/a
TypeStory
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2018-12-14T21:42:09.000+0000
Affected Version/sRelease 7.5.0
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterRiduanul Islam
AssigneeGary Mathews
Created2018-12-06T13:31:25.000+0000
Updated2018-12-14T21:42:09.000+0000

Description

Hello! How to add WindowManager in hyperloop. Right now I have added as var WindowManager = require('android.view.WindowManager'); but it's not working, Cannot read property 'SOFT_INPUT_STATE_ALWAYS_HIDDEN'
function doClick(e) {
	// alert($.label.text);

}
var WindowManager = require('android.view.WindowManager');
var Activity = require('android.app.Activity');
var LinearLayout = require('android.widget.LinearLayout');
var RelativeLayout = require('android.widget.RelativeLayout');
var Gravity = require('android.view.Gravity');
var NumberPicker = require('android.widget.NumberPicker');
var AlertDialog = require('android.app.AlertDialog');
var Builder = require('android.app.AlertDialog.Builder');
var LayoutParams = require('android.widget.LinearLayout.LayoutParams');
var ViewGroupLayoutParams = require('android.view.ViewGroup.LayoutParams');
var View = require('android.view.View');
var Color = require('android.graphics.Color');
var Dialog = require('android.app.Dialog');
var OnValueChangeListener = require('android.widget.NumberPicker.OnValueChangeListener');
var OnClickListener = require('android.view.View.OnClickListener');
var DialogOnClickListener = require('android.content.DialogInterface.OnClickListener');
var TextView = require('android.widget.TextView');

var activity = new Activity(Ti.Android.currentActivity);
var layout = new LinearLayout(activity);
var alertDialog = new AlertDialog(activity);
var builder = new Builder(new Activity(Titanium.App.Android.getTopActivity()));
var text1 = new TextView(activity);
var mainParams = new LayoutParams(ViewGroupLayoutParams.WRAP_CONTENT,
		ViewGroupLayoutParams.WRAP_CONTENT, Gravity.CENTER);

layout.setLayoutParams(mainParams);
layout.setBackgroundColor(Color.BLACK);
layout.setPadding(30, 30, 30, 30);

text1.setTextColor(Color.WHITE);
//text1.setTextSize(TypedValue.COMPLEX_UNIT_PX, 50);

layout.addView(text1);

builder.setView(layout);

var newDialog = builder.create();
newDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
newDialog.show();


$.index.open();
Error:
[ERROR] :  HyperloopProxy: (main) [337,999] Unable to find matching constructor for class: android.app.AlertDialog, args: [com.am.HyperloopaarActivity@bc4d4e2]
[ERROR] :  TiExceptionHandler: (main) [109,1108] /alloy/controllers/index.js:75
[ERROR] :  TiExceptionHandler: newDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN),
[ERROR] :  TiExceptionHandler:                                                                   ^
[ERROR] :  TiExceptionHandler: TypeError: Cannot read property 'SOFT_INPUT_STATE_ALWAYS_HIDDEN' of undefined
[ERROR] :  TiExceptionHandler:     at new Controller (/alloy/controllers/index.js:75:67)
[ERROR] :  TiExceptionHandler:     at Object.exports.createController (/alloy.js:339:9)
[ERROR] :  TiExceptionHandler:     at /app.js:59:7
[ERROR] :  TiExceptionHandler:     at Module._runScript (ti:/module.js:613:9)
[ERROR] :  TiExceptionHandler:     at Module.load (ti:/module.js:105:7)
[ERROR] :  TiExceptionHandler:     at Module.loadJavascriptText (ti:/module.js:457:9)
[ERROR] :  TiExceptionHandler:     at Module.loadAsFile (ti:/module.js:512:15)
[ERROR] :  TiExceptionHandler:     at Module.loadAsFileOrDirectory (ti:/module.js:429:20)
[ERROR] :  TiExceptionHandler:     at Module.require (ti:/module.js:256:17)
[ERROR] :  TiExceptionHandler:     at require (ti:/module.js:570:15)
[ERROR] :  TiExceptionHandler:
[ERROR] :  TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
[ERROR] :  TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:180)
[ERROR] :  TiExceptionHandler:     org.appcelerator.kroll.KrollRuntime.runModule(KrollRuntime.java:247)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiLaunchActivity.loadActivityScript(TiLaunchActivity.java:135)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiLaunchActivity.windowCreated(TiLaunchActivity.java:190)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiRootActivity.windowCreated(TiRootActivity.java:185)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:783)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiLaunchActivity.onCreate(TiLaunchActivity.java:176)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiRootActivity.onCreate(TiRootActivity.java:174)
[ERROR] :  TiExceptionHandler:     android.app.Activity.performCreate(Activity.java:7183)
[ERROR] :  V8Exception: Exception occurred at /alloy/controllers/index.js:75: Uncaught TypeError: Cannot read property 'SOFT_INPUT_STATE_ALWAYS_HIDDEN' of undefined

Comments

  1. Gary Mathews 2018-12-11

    [~aislam] There is an issue with Hyperloop and inner classes on Android. I suggest this as a workaround for the time being:
       newDialog.getWindow().setSoftInputMode(3);
       
    The constant is from https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#SOFT_INPUT_STATE_ALWAYS_HIDDEN

JSON Source