shield android key code problem - Shield Q&A

hi there,
when I develop on shield, I found the key code of dpad and left stick is same.
For example,
when i output the log of keyCode using the following code snippet:
public boolean onKeyDown(int keyCode, KeyEvent event)
{
Logger.LogOut( "onKeyDown " + keyCode + event);
}
I found that the key codes of dpad and left stick are exactly the same, they are:
21 KEYCODE_DPAD_LEFT
20 KEYCODE_DPAD_DOWN
22 KEYCODE_DPAD_RIGHT
19 KEYCODE_DPAD_UP
Is it designed that way?
Does it means they are the same key, if not how can we differentiate the dpad and left stick?
In addition, is the right stick can only be used as a mouse device? As, I the onKeyDown() function will not be called if I shake the right stick. Can I use it as right stick? If yes, how can I do.
THX.
here is the relevent logs:
onKeyDown 21KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_LEFT, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3633502, downTime=3633502, deviceId=5, source=0x1000010 }
onKeyDown 20KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_DOWN, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3711266, downTime=3711266, deviceId=5, source=0x1000010 }
onKeyDown 22KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_RIGHT, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3734280, downTime=3734280, deviceId=5, source=0x1000010 }
onKeyDown 19KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_UP, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3749236, downTime=3749236, deviceId=5, source=0x1000010 }

yijin said:
hi there,
when I develop on shield, I found the key code of dpad and left stick is same.
For example,
when i output the log of keyCode using the following code snippet:
public boolean onKeyDown(int keyCode, KeyEvent event)
{
Logger.LogOut( "onKeyDown " + keyCode + event);
}
I found that the key codes of dpad and left stick are exactly the same, they are:
21 KEYCODE_DPAD_LEFT
20 KEYCODE_DPAD_DOWN
22 KEYCODE_DPAD_RIGHT
19 KEYCODE_DPAD_UP
Is it designed that way?
Does it means they are the same key, if not how can we differentiate the dpad and left stick?
In addition, is the right stick can only be used as a mouse device? As, I the onKeyDown() function will not be called if I shake the right stick. Can I use it as right stick? If yes, how can I do.
THX.
here is the relevent logs:
onKeyDown 21KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_LEFT, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3633502, downTime=3633502, deviceId=5, source=0x1000010 }
onKeyDown 20KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_DOWN, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3711266, downTime=3711266, deviceId=5, source=0x1000010 }
onKeyDown 22KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_RIGHT, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3734280, downTime=3734280, deviceId=5, source=0x1000010 }
onKeyDown 19KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_UP, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3749236, downTime=3749236, deviceId=5, source=0x1000010 }
Click to expand...
Click to collapse
BLOODY FRICKIN HELL MAN!!!!!!!!
QUESTIONS go in the Question and Answer section, it is there for a reason dammit! UGG!

yijin said:
hi there,
when I develop on shield, I found the key code of dpad and left stick is same.
For example,
when i output the log of keyCode using the following code snippet:
public boolean onKeyDown(int keyCode, KeyEvent event)
{
Logger.LogOut( "onKeyDown " + keyCode + event);
}
I found that the key codes of dpad and left stick are exactly the same, they are:
21 KEYCODE_DPAD_LEFT
20 KEYCODE_DPAD_DOWN
22 KEYCODE_DPAD_RIGHT
19 KEYCODE_DPAD_UP
Is it designed that way?
Does it means they are the same key, if not how can we differentiate the dpad and left stick?
In addition, is the right stick can only be used as a mouse device? As, I the onKeyDown() function will not be called if I shake the right stick. Can I use it as right stick? If yes, how can I do.
THX.
here is the relevent logs:
onKeyDown 21KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_LEFT, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3633502, downTime=3633502, deviceId=5, source=0x1000010 }
onKeyDown 20KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_DOWN, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3711266, downTime=3711266, deviceId=5, source=0x1000010 }
onKeyDown 22KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_RIGHT, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3734280, downTime=3734280, deviceId=5, source=0x1000010 }
onKeyDown 19KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_UP, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3749236, downTime=3749236, deviceId=5, source=0x1000010 }
Click to expand...
Click to collapse
You need to capture MotionEvents too. Otherwise, they fall back to KeyEvents.

Related

Shield android stick keycode problem

hi there,
when I develop on shield, I found the key code of dpad and left stick is same.
For example,
when i output the log of keyCode using the following code snippet:
public boolean onKeyDown(int keyCode, KeyEvent event)
{
Logger.LogOut( "onKeyDown " + keyCode + event);
}
I found that the key codes of dpad and left stick are exactly the same, they are:
21 KEYCODE_DPAD_LEFT
20 KEYCODE_DPAD_DOWN
22 KEYCODE_DPAD_RIGHT
19 KEYCODE_DPAD_UP
Is it designed that way?
Does it means they are the same key, if not how can we differentiate the dpad and left stick?
In addition, is the right stick can only be used as a mouse device? As, I the onKeyDown() function will not be called if I shake the right stick. Can I use it as right stick? If yes, how can I do.
THX.
here is the relevent logs:
onKeyDown 21KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_LEFT, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3633502, downTime=3633502, deviceId=5, source=0x1000010 }
onKeyDown 20KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_DOWN, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3711266, downTime=3711266, deviceId=5, source=0x1000010 }
onKeyDown 22KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_RIGHT, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3734280, downTime=3734280, deviceId=5, source=0x1000010 }
onKeyDown 19KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DPAD_UP, scanCode=0, metaState=0, flags=0x400, repeatCount=0, eventTime=3749236, downTime=3749236, deviceId=5, source=0x1000010 }
You want motion events for an axis, not keycode.
Sent from my One using XDA Premium HD app

[Q] Android Getting Sound Levels

Hello there
I'm a newbie in programming and I wanna build a sound recording application.
I have this code which is recording sound and puts a timestamp :
Code:
package com.tsop.tsp_recorder;
import android.R.layout;
import android.app.Activity;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.os.Bundle;
import android.os.Environment;
import android.view.ViewGroup;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.MarginLayoutParams;
import android.content.Context;
import android.util.Log;
import android.media.MediaRecorder;
import android.media.MediaPlayer;
import java.io.IOException;
import java.util.Calendar;
public class MainActivity extends Activity
{
private static final String LOG_TAG = "AudioRecordTest";
private static String mFileName = null;
private RecordButton mRecordButton = null;
private MediaRecorder mRecorder = null;
private PlayButton mPlayButton = null;
private MediaPlayer mPlayer = null;
private void onRecord(boolean start) {
if (start) {
startRecording();
} else {
stopRecording();
}
}
private void onPlay(boolean start) {
if (start) {
startPlaying();
} else {
stopPlaying();
}
}
private void startPlaying() {
mPlayer = new MediaPlayer();
try {
mPlayer.setDataSource(mFileName);
mPlayer.prepare();
mPlayer.start();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
}
private void stopPlaying() {
mPlayer.release();
mPlayer = null;
}
private void startRecording() {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
}
private void stopRecording() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}
class RecordButton extends Button {
boolean mStartRecording = true;
OnClickListener clicker = new OnClickListener() {
public void onClick(View v) {
onRecord(mStartRecording);
if (mStartRecording) {
setText("Stop recording");
} else {
setText("Start recording");
}
mStartRecording = !mStartRecording;
}
};
public RecordButton(Context ctx) {
super(ctx);
setText("Start recording");
setOnClickListener(clicker);
}
}
class PlayButton extends Button {
boolean mStartPlaying = true;
OnClickListener clicker = new OnClickListener() {
public void onClick(View v) {
onPlay(mStartPlaying);
if (mStartPlaying) {
setText("Stop playing");
} else {
setText("Start playing");
}
mStartPlaying = !mStartPlaying;
}
};
public PlayButton(Context ctx) {
super(ctx);
setText("Start playing");
setOnClickListener(clicker);
}
}
public MainActivity() {
theDate date = new theDate();
String sDate = date.curDate();
String sTime = date.curTime();
mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
mFileName += "/TSP_Recordings/Date_"+sDate+"_Time_"+sTime+".3gp";
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
LinearLayout ll = new LinearLayout(this);
mRecordButton = new RecordButton(this);
ll.addView(mRecordButton,
new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
0));
mPlayButton = new PlayButton(this);
ll.addView(mPlayButton,
new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
0));
setContentView(ll);
}
@Override
public void onPause() {
super.onPause();
if (mRecorder != null) {
mRecorder.release();
mRecorder = null;
}
if (mPlayer != null) {
mPlayer.release();
mPlayer = null;
}
}
}
package com.tsop.tsp_recorder;
import java.util.Calendar;
public class theDate {
static Calendar c = Calendar.getInstance();
public static String curDate() {
int month = c.get(Calendar.MONTH) + 1;
String sDate = c.get(Calendar.DAY_OF_MONTH) + "-"
+ month
+ "-" + c.get(Calendar.YEAR);
return sDate;
}
public static String curTime() {
String sTime = c.get(Calendar.HOUR_OF_DAY)
+ "-" + c.get(Calendar.MINUTE) + "-"
+ c.get(Calendar.SECOND);
return sTime;
}
public static long duration() {
long dur = c.getTimeInMillis();
return dur;
}
}
I need to change it and make it messure the sound levels.I'll use the getMaxAmplitude method,but this method returns only the last result,before it was called.I think I should use a loop,but the start method is capturing and encoding continuously.
How can I get the current amplitude,for example in a period of 1 second,on my recording?
Thanks
I've edited my code into this :
Code:
package com.tsop.tsp_recorder;
import android.R.layout;
import android.app.Activity;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.os.Bundle;
import android.os.Environment;
import android.view.ViewGroup;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.MarginLayoutParams;
import android.content.Context;
import android.util.Log;
import android.media.MediaRecorder;
import android.media.MediaPlayer;
import java.io.IOException;
import java.util.Calendar;
public class MainActivity extends Activity
{
private static final String LOG_TAG = "AudioRecordTest";
private static String mFileName = null;
private RecordButton mRecordButton = null;
private MediaRecorder mRecorder = null;
private PlayButton mPlayButton = null;
private MediaPlayer mPlayer = null;
public int currentAmplitude;
private void onRecord(boolean start) {
if (start) {
startRecording();
} else {
stopRecording();
}
}
private void onPlay(boolean start) {
if (start) {
startPlaying();
} else {
stopPlaying();
}
}
private void startPlaying() {
mPlayer = new MediaPlayer();
try {
mPlayer.setDataSource(mFileName);
mPlayer.prepare();
mPlayer.start();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
}
private void stopPlaying() {
mPlayer.release();
mPlayer = null;
}
private void startRecording() {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
getAmplitude();
}
private void stopRecording() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}
public double getAmplitude() {
if (mRecorder != null) {
currentAmplitude = mRecorder.getMaxAmplitude();
return currentAmplitude;
}
else
return 0;
}
class RecordButton extends Button {
boolean mStartRecording = true;
OnClickListener clicker = new OnClickListener() {
public void onClick(View v) {
onRecord(mStartRecording);
if (mStartRecording) {
setText("Stop recording");
} else {
setText("Start recording");
}
mStartRecording = !mStartRecording;
}
};
public RecordButton(Context ctx) {
super(ctx);
setText("Start recording");
setOnClickListener(clicker);
}
}
class PlayButton extends Button {
boolean mStartPlaying = true;
OnClickListener clicker = new OnClickListener() {
public void onClick(View v) {
onPlay(mStartPlaying);
if (mStartPlaying) {
setText("Stop playing");
} else {
setText("Start playing");
}
mStartPlaying = !mStartPlaying;
}
};
public PlayButton(Context ctx) {
super(ctx);
setText("Start playing");
setOnClickListener(clicker);
}
}
public MainActivity() {
theDate date = new theDate();
String sDate = date.curDate();
String sTime = date.curTime();
mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
mFileName += "/TSP_Recordings/Date_"+sDate+"_Time_"+sTime+".3gp";
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
LinearLayout ll = new LinearLayout(this);
mRecordButton = new RecordButton(this);
ll.addView(mRecordButton,
new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
0));
mPlayButton = new PlayButton(this);
ll.addView(mPlayButton,
new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
0));
TextView tv = new TextView(this);
ll.addView(tv,
new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
0));
tv.setText(Integer.toString(currentAmplitude));
setContentView(ll);
}
@Override
public void onPause() {
super.onPause();
if (mRecorder != null) {
mRecorder.release();
mRecorder = null;
}
if (mPlayer != null) {
mPlayer.release();
mPlayer = null;
}
}
}
But my result is 0 everytime.Any ideas?

One smali code but 2 different in Java source

hi everyone
i'm very noob in android because i'm a Java EE developer.
ok i have one apk file that i want to change the source code in to JAVA.
i decompiled the apk file in two ways:
first, i used apktool ,dex2jar, jd-ui and then i got this java code :
Code:
package com.sunglab.bigbanghd;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.*;
//import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageButton;
public class MainActivity
extends Activity
implements SensorEventListener
{
public static final int Amazon = 1;
public static final int Google = 0;
public static boolean IsthatPlaying = true;
public static final int Samsung = 3;
public static final int Tstore = 2;
public static MediaPlayer mPlayer;
public static int store = WallpaperSettings.store;
public int MusicNumber = 0;
Handler handler;
Intent intent;
GL2JNIView.Renderer mRenderer;
private GL2JNIView mView;
Sensor m_ot_sensor;
SensorManager m_sensor_manager;
ImageButton menu_Button;
public void abc(int paramInt)
{
switch (paramInt)
{
}
do
{
do
{
do
{
do
{
do
{
return;
Log.e("else", "Playing 0");
mPlayer.reset();
mPlayer = MediaPlayer.create(this, 2131034112);
mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
{
public void onCompletion(MediaPlayer paramAnonymousMediaPlayer)
{
if (MainActivity.mPlayer.isPlaying()) {
Log.e("else", "finish but playing");
}
for (;;)
{
MainActivity localMainActivity = MainActivity.this;
localMainActivity.MusicNumber = (1 + localMainActivity.MusicNumber);
if (MainActivity.this.MusicNumber == 5) {
MainActivity.this.MusicNumber = 0;
}
MainActivity.this.abc(MainActivity.this.MusicNumber);
return;
Log.e("else", "finish");
}
}
});
} while (!IsthatPlaying);
mPlayer.start();
return;
Log.e("else", "Playing 1");
mPlayer.reset();
mPlayer = MediaPlayer.create(this, 2131034113);
mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
{
public void onCompletion(MediaPlayer paramAnonymousMediaPlayer)
{
if (MainActivity.mPlayer.isPlaying()) {
Log.e("else", "finish but playing");
}
for (;;)
{
MainActivity localMainActivity = MainActivity.this;
localMainActivity.MusicNumber = (1 + localMainActivity.MusicNumber);
if (MainActivity.this.MusicNumber == 5) {
MainActivity.this.MusicNumber = 0;
}
MainActivity.this.abc(MainActivity.this.MusicNumber);
return;
Log.e("else", "finish");
}
}
});
} while (!IsthatPlaying);
mPlayer.start();
return;
Log.e("else", "Playing 2");
mPlayer.reset();
mPlayer = MediaPlayer.create(this, 2131034114);
mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
{
public void onCompletion(MediaPlayer paramAnonymousMediaPlayer)
{
if (MainActivity.mPlayer.isPlaying()) {
Log.e("else", "finish but playing");
}
for (;;)
{
MainActivity localMainActivity = MainActivity.this;
localMainActivity.MusicNumber = (1 + localMainActivity.MusicNumber);
if (MainActivity.this.MusicNumber == 5) {
MainActivity.this.MusicNumber = 0;
}
MainActivity.this.abc(MainActivity.this.MusicNumber);
return;
Log.e("else", "finish");
}
}
});
} while (!IsthatPlaying);
mPlayer.start();
return;
Log.e("else", "Playing 3");
mPlayer.reset();
mPlayer = MediaPlayer.create(this, 2131034115);
mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
{
public void onCompletion(MediaPlayer paramAnonymousMediaPlayer)
{
if (MainActivity.mPlayer.isPlaying()) {
Log.e("else", "finish but playing");
}
for (;;)
{
MainActivity localMainActivity = MainActivity.this;
localMainActivity.MusicNumber = (1 + localMainActivity.MusicNumber);
if (MainActivity.this.MusicNumber == 5) {
MainActivity.this.MusicNumber = 0;
}
MainActivity.this.abc(MainActivity.this.MusicNumber);
return;
Log.e("else", "finish");
}
}
});
} while (!IsthatPlaying);
mPlayer.start();
return;
Log.e("else", "Playing 4");
mPlayer.reset();
mPlayer = MediaPlayer.create(this, 2131034116);
mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
{
public void onCompletion(MediaPlayer paramAnonymousMediaPlayer)
{
if (MainActivity.mPlayer.isPlaying()) {
Log.e("else", "finish but playing");
}
for (;;)
{
MainActivity localMainActivity = MainActivity.this;
localMainActivity.MusicNumber = (1 + localMainActivity.MusicNumber);
if (MainActivity.this.MusicNumber == 5) {
MainActivity.this.MusicNumber = 0;
}
MainActivity.this.abc(MainActivity.this.MusicNumber);
return;
Log.e("else", "finish");
}
}
});
} while (!IsthatPlaying);
mPlayer.start();
}
public void onAccuracyChanged(Sensor paramSensor, int paramInt)
{
Log.e("Sensor working", "Good ratated2s");
}
public void onBackPressed()
{
Log.e("omg", "Back key");
AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
localBuilder.setIcon(2130837507);
if ((store == 2) || (store == 3)) {
localBuilder.setTitle("이 앱을 종료 하시겠습니까?");
}
for (;;)
{
localBuilder.setCancelable(false);
if ((store != 2) && (store != 3)) {
localBuilder.setPositiveButton("More Apps", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
{
switch (MainActivity.store)
{
}
for (;;)
{
MainActivity.this.startActivity(MainActivity.this.intent);
return;
MainActivity.this.intent = new Intent("android.intent.action.VIEW", Uri.parse("xxxx"));
continue;
MainActivity.this.intent = new Intent("android.intent.action.VIEW", Uri.parse("xxx"));
}
}
});
}
localBuilder.setNeutralButton("Cancel", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
{
paramAnonymousDialogInterface.cancel();
}
});
localBuilder.setNegativeButton("Exit", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
{
MainActivity.this.finish();
}
});
localBuilder.show();
return;
localBuilder.setTitle("Do you need More SungLab Apps ?");
}
}
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
Log.e("gg", "onCreate");
this.m_sensor_manager = ((SensorManager)getSystemService("sensor"));
this.m_ot_sensor = this.m_sensor_manager.getDefaultSensor(3);
this.mView = new GL2JNIView(getApplication());
setContentView(this.mView);
SharedPreferences localSharedPreferences = getSharedPreferences("wallpaperSet", 0);
int i = localSharedPreferences.getInt("THICK", 5);
int j = localSharedPreferences.getInt("TAIL", 7);
int k = localSharedPreferences.getInt("NUMBER", 5999);
int m = localSharedPreferences.getInt("COLORS", 0);
if (Boolean.valueOf(localSharedPreferences.getBoolean("MUSIC", true)).booleanValue()) {}
for (IsthatPlaying = true;; IsthatPlaying = false)
{
GL2JNIView.Renderer.number = k + 1;
GL2JNIView.Renderer.tail = 0.99F - (0.2F - 0.02F * j);
GL2JNIView.Renderer.thick = 1.0F + 0.4F * i;
GL2JNIView.Renderer.colors = m;
addContentView(((LayoutInflater)getSystemService("layout_inflater")).inflate(2130903040, null), new ViewGroup.LayoutParams(-1, -1));
getWindow().setFlags(128, 128);
mPlayer = MediaPlayer.create(this, 2131034112);
if (!IsthatPlaying) {
mPlayer.pause();
}
mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
{
public void onCompletion(MediaPlayer paramAnonymousMediaPlayer)
{
if (MainActivity.mPlayer.isPlaying()) {
Log.e("else", "finish but playing");
}
for (;;)
{
MainActivity localMainActivity = MainActivity.this;
localMainActivity.MusicNumber = (1 + localMainActivity.MusicNumber);
if (MainActivity.this.MusicNumber == 5) {
MainActivity.this.MusicNumber = 0;
}
MainActivity.this.abc(MainActivity.this.MusicNumber);
return;
Log.e("else", "finish");
}
}
});
this.menu_Button = ((ImageButton)findViewById(2131296256));
this.menu_Button.setOnClickListener(new View.OnClickListener()
{
public void onClick(View paramAnonymousView)
{
MainActivity.this.startActivity(new Intent(MainActivity.this, WallpaperSettings.class));
}
});
return;
}
}
protected void onDestroy()
{
super.onDestroy();
this.mView = null;
if (mPlayer.isPlaying()) {
mPlayer.stop();
}
mPlayer.release();
mPlayer = null;
Log.e("omg", "Destroy");
}
public void onHomePressed()
{
Log.e("omg", "Home key");
}
protected void onPause()
{
super.onPause();
this.mView.onPause();
if (IsthatPlaying) {
mPlayer.pause();
}
this.m_sensor_manager.unregisterListener(this);
Log.e("omg", "onPause");
}
protected void onResume()
{
super.onResume();
this.mView.onResume();
Log.e("omg", "onResume");
if (Boolean.valueOf(getSharedPreferences("wallpaperSet", 0).getBoolean("MUSIC", true)).booleanValue())
{
IsthatPlaying = true;
if (!IsthatPlaying) {
break label82;
}
mPlayer.start();
}
for (;;)
{
this.m_sensor_manager.registerListener(this, this.m_ot_sensor, 2);
return;
IsthatPlaying = false;
break;
label82:
mPlayer.pause();
}
}
public void onSensorChanged(SensorEvent paramSensorEvent)
{
if (paramSensorEvent.sensor.getType() == 3)
{
if ((int)paramSensorEvent.values[2] > 45) {
GL2JNIView.Renderer.DefinallyROTATION = -90;
}
}
else {
return;
}
if ((int)paramSensorEvent.values[2] < -45)
{
GL2JNIView.Renderer.DefinallyROTATION = 90;
return;
}
GL2JNIView.Renderer.DefinallyROTATION = 0;
}
public boolean onTouchEvent(MotionEvent paramMotionEvent)
{
int i = paramMotionEvent.getPointerCount();
int j = 0;
if (j >= i) {
switch (paramMotionEvent.getAction())
{
}
}
for (;;)
{
return true;
GL2JNIView.TouchMoveNumber(paramMotionEvent.getX(j), paramMotionEvent.getY(j), j, paramMotionEvent.getPointerCount());
j++;
break;
GL2JNIView.TouchUpNumber();
continue;
GL2JNIView.TouchDownNumber();
continue;
GL2JNIView.TouchDownNumber();
}
}
}
/* Location: C:\jd-gui-windows-1.4.0\classes_dex2jar.jar!\com\sunglab\bigbanghd\MainActivity.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
and the second way i used backSmali tool and jd-ui , i got this JAVA code:
Code:
/**
* Generated by smali2java 1.0.0.558
* Copyright (C) 2013 Hensence.com
*/
package com.sunglab.bigbanghd;
import android.app.Activity;
import android.hardware.SensorEventListener;
import android.media.MediaPlayer;
import android.os.Handler;
import android.content.Intent;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.widget.ImageButton;
import android.util.Log;
import android.content.Context;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.app.Application;
import android.view.View;
import android.content.SharedPreferences;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.Window;
import android.hardware.SensorEvent;
import android.view.MotionEvent;
public class MainActivity extends Activity implements SensorEventListener {
public static final int Amazon = 0x1;
public static final int Google = 0x0;
public int MusicNumber;
public static final int Samsung = 0x3;
public static final int Tstore = 0x2;
Handler handler;
Intent intent;
public static MediaPlayer mPlayer;
GL2JNIView.Renderer mRenderer;
private GL2JNIView mView;
Sensor m_ot_sensor;
SensorManager m_sensor_manager;
ImageButton menu_Button;
public static int store = WallpaperSettings.store;
public static boolean IsthatPlaying = 0x1;
public void onCreate(Bundle p1) {
super.onCreate(p1);
Log.e("gg", "onCreate");
m_sensor_manager = (SensorManager)getSystemService("sensor");
m_ot_sensor = m_sensor_manager.getDefaultSensor(0x3);
mView = new GL2JNIView(getApplication());
setContentView(mView);
SharedPreferences "preferences" = getSharedPreferences("wallpaperSet", 0x0);
int "thickness" = "preferences".getInt("THICK", 0x5);
int "tails" = "preferences".getInt("TAIL", 0x7);
int "particleNumber" = "preferences".getInt("NUMBER", 0x176f);
int "colors" = "preferences".getInt("COLORS", 0x0);
Boolean "music" = Boolean.valueOf("preferences".getBoolean("MUSIC", true));
if("music".booleanValue()) {
IsthatPlaying = 0x1;
} else {
IsthatPlaying = 0x0;
}
GL2JNIView.Renderer.number = ("particleNumber" + 0x1);
GL2JNIView.Renderer.tail = (0x3f7d70a4 # 0.99f - (0x3e4ccccd # 0.2f - ((float)"tails" * 0x3ca3d70a # 0.02f)));
GL2JNIView.Renderer.thick = (0.0f + ((float)"thickness" * 0x3ecccccd # 0.4f));
GL2JNIView.Renderer.colors = "colors";
LayoutInflater "vi" = (LayoutInflater)getSystemService("layout_inflater");
View "v" = "vi".inflate(0x0, 0x0);
addContentView("v", new ViewGroup.LayoutParams(-0x1, -0x1));
getWindow().setFlags(0x80, 0x80);
mPlayer = MediaPlayer.create(this, 0x0);
if(!IsthatPlaying) {
mPlayer.pause();
}
mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener(this) {
1(MainActivity p1) {
}
public void onCompletion(MediaPlayer p1) {
if(MainActivity.mPlayer.isPlaying()) {
Log.e("else", "finish but playing");
} else {
Log.e("else", "finish");
}
MusicNumber = (MusicNumber + 0x1);
if(MusicNumber == 0x5) {
MusicNumber = 0x0;
}
abc(MusicNumber);
}
});
menu_Button = (ImageButton)findViewById(0x0);
menu_Button.setOnClickListener(new View.OnClickListener(this) {
2(MainActivity p1) {
}
public void onClick(View p1) {
startActivity(new Intent(this$0, WallpaperSettings.class));
}
});
}
public void abc(int p1) {
switch(p1) {
case 0:
{
Log.e("else", "Playing 0");
mPlayer.reset();
mPlayer = MediaPlayer.create(this, 0x0);
mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener(this) {
3(MainActivity p1) {
}
public void onCompletion(MediaPlayer p1) {
if(MainActivity.mPlayer.isPlaying()) {
Log.e("else", "finish but playing");
} else {
Log.e("else", "finish");
}
MusicNumber = (MusicNumber + 0x1);
if(MusicNumber == 0x5) {
MusicNumber = 0x0;
}
abc(MusicNumber);
}
});
if(IsthatPlaying) {
mPlayer.start();
}
return;
}
case 1:
{
Log.e("else", "Playing 1");
mPlayer.reset();
mPlayer = MediaPlayer.create(this, 0x7f050001);
mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener(this) {
4(MainActivity p1) {
}
public void onCompletion(MediaPlayer p1) {
if(MainActivity.mPlayer.isPlaying()) {
Log.e("else", "finish but playing");
} else {
Log.e("else", "finish");
}
MusicNumber = (MusicNumber + 0x1);
if(MusicNumber == 0x5) {
MusicNumber = 0x0;
}
abc(MusicNumber);
}
});
if(IsthatPlaying) {
mPlayer.start();
}
return;
}
case 2:
{
Log.e("else", "Playing 2");
mPlayer.reset();
mPlayer = MediaPlayer.create(this, 0x7f050002);
mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener(this) {
5(MainActivity p1) {
}
public void onCompletion(MediaPlayer p1) {
if(MainActivity.mPlayer.isPlaying()) {
Log.e("else", "finish but playing");
} else {
Log.e("else", "finish");
}
MusicNumber = (MusicNumber + 0x1);
if(MusicNumber == 0x5) {
MusicNumber = 0x0;
}
abc(MusicNumber);
}
});
if(IsthatPlaying) {
mPlayer.start();
}
return;
}
case 3:
{
Log.e("else", "Playing 3");
mPlayer.reset();
mPlayer = MediaPlayer.create(this, 0x7f050003);
mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener(this) {
6(MainActivity p1) {
}
public void onCompletion(MediaPlayer p1) {
if(MainActivity.mPlayer.isPlaying()) {
Log.e("else", "finish but playing");
} else {
Log.e("else", "finish");
}
MusicNumber = (MusicNumber + 0x1);
if(MusicNumber == 0x5) {
MusicNumber = 0x0;
}
abc(MusicNumber);
}
});
if(IsthatPlaying) {
mPlayer.start();
}
return;
}
case 4:
{
Log.e("else", "Playing 4");
mPlayer.reset();
mPlayer = MediaPlayer.create(this, 0x7f050004);
mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener(this) {
7(MainActivity p1) {
}
public void onCompletion(MediaPlayer p1) {
if(MainActivity.mPlayer.isPlaying()) {
Log.e("else", "finish but playing");
} else {
Log.e("else", "finish");
}
MusicNumber = (MusicNumber + 0x1);
if(MusicNumber == 0x5) {
MusicNumber = 0x0;
}
abc(MusicNumber);
}
});
if(IsthatPlaying) {
mPlayer.start();
break;
}
}
}
}
protected void onPause() {
super.onPause();
mView.onPause();
if(IsthatPlaying) {
mPlayer.pause();
}
m_sensor_manager.unregisterListener(this);
Log.e("omg", "onPause");
}
protected void onResume() {
super.onResume();
mView.onResume();
Log.e("omg", "onResume");
SharedPreferences "preferences" = getSharedPreferences("wallpaperSet", 0x0);
Boolean "music" = Boolean.valueOf("preferences".getBoolean("MUSIC", true));
if("music".booleanValue()) {
IsthatPlaying = 0x1;
} else {
IsthatPlaying = 0x0;
}
if(IsthatPlaying) {
mPlayer.start();
} else {
mPlayer.pause();
}
m_sensor_manager.registerListener(this, m_ot_sensor, 0x2);
}
public void onSensorChanged(SensorEvent p1) {
if(p1.sensor.getType() == 0x3) {
if((int)p1.values[0x2] > 0x2d) {
GL2JNIView.Renderer.DefinallyROTATION = -0x5a;
return;
}
if((int)p1.values[0x2] < -0x2d) {
GL2JNIView.Renderer.DefinallyROTATION = 0x5a;
return;
}
GL2JNIView.Renderer.DefinallyROTATION = 0x0;
}
}
public void onAccuracyChanged(Sensor p1, int p2) {
Log.e("Sensor working", "Good ratated2s");
}
protected void onDestroy() {
super.onDestroy();
mView = 0x0;
if(mPlayer.isPlaying()) {
mPlayer.stop();
}
mPlayer.release();
mPlayer = 0x0;
Log.e("omg", "Destroy");
}
public void onBackPressed() {
Log.e("omg", "Back key");
AlertDialog.Builder "d" = new AlertDialog.Builder(this);
"d".setIcon(0x7f020003);
if((store == 0x2) || (store == 0x3)) {
"d".setTitle("\uc774 \uc571\uc744 \uc885\ub8cc \ud558\uc2dc\uaca0\uc2b5\ub2c8\uae4c?");
} else {
"d".setTitle("Do you need More SungLab Apps ?");
}
"d".setCancelable(false);
if((store != 0x2) && (store != 0x3)) {
"d".setPositiveButton("More Apps", new DialogInterface.OnClickListener(this) {
8(MainActivity p1) {
}
public void onClick(DialogInterface p1, int p2) {
switch(MainActivity.store) {
case 0:
{
new Intent("android.intent.action.VIEW", Uri.parse("xx"));
intent = localIntent1;
break;
}
case 1:
{
new Intent("android.intent.action.VIEW", Uri.parse("xxxx"));
intent = localIntent2;
break;
}
}
startActivity(intent);
}
});
}
"d".setNeutralButton("Cancel", new DialogInterface.OnClickListener(this) {
9(MainActivity p1) {
}
public void onClick(DialogInterface p1, int p2) {
p1.cancel();
}
});
"d".setNegativeButton("Exit", new DialogInterface.OnClickListener(this) {
10(MainActivity p1) {
}
public void onClick(DialogInterface p1, int p2) {
finish();
}
});
"d".show();
}
public void onHomePressed() {
Log.e("omg", "Home key");
}
public boolean onTouchEvent(MotionEvent p1) {
int "pointerCount" = p1.getPointerCount();
for(int "i" = 0x0; "i" >= "pointerCount"; "i" = "i" + 0x1) {
}
GL2JNIView.TouchMoveNumber(p1.getX("i"), p1.getY("i"), "i", p1.getPointerCount());
switch(p1.getAction()) {
case 1:
{
GL2JNIView.TouchUpNumber();
break;
}
case 0:
{
GL2JNIView.TouchDownNumber();
break;
}
case 5:
{
GL2JNIView.TouchDownNumber();
break;
}
case 2:
case 3:
case 4:
{
return true;
}
}
}
}
now i have a question why both of java codes are not the same?? for example, in the first one, we have some (do while) loops but in the second way we don't have them???
and as you can see, in the first one some lines seem wrong (in abc() method or it has written for( ;; ) ).
And also in the second one, in abc() method, we have switch case but in the first one we don't have it.
i want to edit some lines and codes but it seems the original decompiled code doesn't work.

Web Development Question: Scroll List with bezel

Hello,
I try to create anew Web Application for the GS2 using the Tizen SDK (Version : 2.4.0_Rev5 Build id : 20151223-1448).
In the main page I create a list element, to which I then add new button elements via code.
I'm using the template TAUList. Unfortunately, the scrolling using the bezel is only scrolling through the items in the list, which are initially in the list. All later added items can be scrolled only by using the touch screen. Can someone tell me, what I'm doing wring here?
Is there something,which I have to re-init, after I have altered the list?
Thanks for any hints.
HTML:
( function () {
window.addEventListener( 'tizenhwkey', function( ev ) {
if( ev.keyName === "back" ) {
var page = document.getElementsByClassName( 'ui-page-active' )[0],
pageid = page ? page.id : "";
if( pageid === "main" ) {
try {
tizen.application.getCurrentApplication().exit();
} catch (ignore) {
}
} else {
window.history.back();
}
}
} );
} () );
var XML_ADDRESS = "them? cmd=jsonlist2 room=Wohnzimmer STATE&XHR=1",
XML_METHOD = "GET";
var devListArray;
var xmlhttp;
function getFhemData(){
var objDevs = document.getElementById('devList');
var i;
xmlhttp = new XMLHttpRequest();
xmlhttp.open(XML_METHOD, XML_ADDRESS, true);
xmlhttp.overrideMimeType("application/json");
xmlhttp.setRequestHeader("Authorization", "Basic " + btoa("xxxxx" + ":" + "xxxxxxxx"));
xmlhttp.send();
xmlhttp.onreadystatechange = function() {
var JSONCode = JSON && JSON.parse(xmlhttp.responseText);
devListArray = JSONCode.Results;
var dli;
for (i = 0; i < devListArray.length; i++) {
dli = createDevice(devListArray[i]);
objDevs.appendChild(dli);
}
xmlhttp = null;
};
}
function createDevice(dev) {
var li = document.createElement('li');
li.setAttribute('class','li-has-toggle');
var la = document.createElement('label');
la.innerHTML =dev.Name;
var divInp = document.createElement('div');
divInp.setAttribute('class','ui-toggleswitch');
var inp = document.createElement('input');
inp.setAttribute('type','checkbox');
var state = dev.Internals;
if(state.STATE ==='on'){
inp.setAttribute('checked');
}
inp.setAttribute('class','ui-switch-input');
inp.setAttribute('value','test2');
var divInpBut = document.createElement('div');
divInpBut.setAttribute('class','ui-switch-button');
divInp.appendChild(inp);
divInp.appendChild(divInpBut);
la.appendChild(divInp);
li.appendChild(la);
return li;
}
function init() {
getFhemData();
}
window.onload = function() {
init();
};
The Page:
HTML:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,user-scalable=no">
<title>Circular UI</title>
<link rel="stylesheet" href="lib/tau/wearable/theme/default/tau.min.css">
<link rel="stylesheet" media="all and (-tizen-geometric-shape: circle)" href="lib/tau/wearable/theme/default/tau.circle.min.css">
<!-- load theme file for your application -->
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="ui-page ui-page-active" id="main">
<header class="ui-header">
<h2 class="ui-title">TAU List</h2>
</header>
<div class="ui-content">
<ul class="ui-listview" id="devList">
<li>List1</li>
<li>List2</li>
</ul>
</div>
</div>
<script type="text/javascript" src="lib/tau/wearable/js/tau.min.js"></script>
<script type="text/javascript" src="js/circle-helper.js"></script>
<script src="app.js"></script>
<script src="lowBatteryCheck.js"></script>
</body>
</html>
hi, I have the same problem :/
did you find an soloution?
Hi,
the CircleHelper.js must be adapted. After adding new items in list, call destroy on your list in listHelper[], and then call again tau.helper.SnapListStyle.create() on the list.
I don't know if there is a cleaner why as of now.
Could the problem be "devListArray.length;" related? Limiting the new items to show up...
Not sure about this.
I just came across the same problem, solution is like @jamesst20 said destroying/re-creating the SnapListStyle items in circle-helper.js
In case anyone still looking for a solution, change circle-helper.js to
Code:
/*global tau */
/*jslint unparam: true */
(function (tau) {
var page,
list,
listHelper = [],
snapList = [],
i, len;
function createSnapListStyle(page) {
if (tau.support.shape.circle) {
list = page.querySelectorAll(".ui-listview");
if (list) {
if (page.id !== "pageMarqueeList" && page.id !== "pageTestVirtualList" && page.id !== "pageAnimation") {
len = list.length;
for (i = 0; i < len; i++) {
listHelper[i] = tau.helper.SnapListStyle.create(list[i]);
}
len = listHelper.length;
if (len) {
for (i = 0; i < len; i++) {
snapList[i] = listHelper[i].getSnapList();
}
}
}
}
}
}
function destroySnapListStyle() {
len = listHelper.length;
if (len) {
for (i = 0; i < len; i++) {
listHelper[i].destroy();
}
listHelper = [];
}
}
document.addEventListener("pagebeforeshow", function (e) {
page = e.target;
createSnapListStyle(page);
});
document.addEventListener("pagebeforehide", function (e) {
destroySnapListStyle();
});
document.addEventListener("onsnaplistitemschanged", function (e) {
destroySnapListStyle();
page = e.target;
createSnapListStyle(page);
}, false);
}(tau));
Than call
Code:
document.dispatchEvent(new CustomEvent("onsnaplistitemschanged"));
whenever your list items changed.

How to prevent opening status bar menu in android on Api 31

I could prevent opening the status bar in < API 31 , but in API 31 doesn't work
some codes are deprecated in this version like :
Code:
val closeIntent = Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
I used this code to prevent opening the status bar drawer :
JavaScript:
// To keep track of activity's window focus
var currentFocus = false
// To keep track of activity's foreground/background status
var isPaused = false
lateinit var collapseNotificationHandler: Handler
fun collapseNow() {
collapseNotificationHandler = Handler()
if (!currentFocus && !isPaused) {
collapseNotificationHandler.postDelayed(object : Runnable {
override fun run() {
// Use reflection to trigger a method from 'StatusBarManager'
val statusBarService = getSystemService("statusbar")
var statusBarManager: Class<*>? = null
try {
statusBarManager = Class.forName("android.app.StatusBarManager")
} catch (e: ClassNotFoundException) {
e.printStackTrace()
}
var collapseStatusBar: Method? = null
try {
// Prior to API 17, the method to call is 'collapse()'
// API 17 onwards, the method to call is `collapsePanels()`
collapseStatusBar = if (Build.VERSION.SDK_INT > 16) {
statusBarManager!!.getMethod("collapsePanels")
} else {
statusBarManager!!.getMethod("collapse")
}
} catch (e: NoSuchMethodException) {
e.printStackTrace()
}
if (collapseStatusBar != null) {
collapseStatusBar.setAccessible(true)
}
try {
if (collapseStatusBar != null) {
collapseStatusBar.invoke(statusBarService)
}
} catch (e: IllegalArgumentException) {
e.printStackTrace()
} catch (e: IllegalAccessException) {
e.printStackTrace()
} catch (e: InvocationTargetException) {
e.printStackTrace()
}
// Check if the window focus has been returned
// If it hasn't been returned, post this Runnable again
// Currently, the delay is 100 ms. You can change this
// value to suit your needs.
if (!currentFocus && !isPaused) {
collapseNotificationHandler.postDelayed(this, 100L)
}
}
}, 300L)
}
}
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
currentFocus = hasFocus;
if (!hasFocus) {
collapseNow()
}
}
I review all of google developers docs for this problem but unfortunately google codes are deprecated and don't have a clear document for that
HI, i have the same issue, you found anything to solve this problem?
danielsantb said:
HI, i have the same issue, you found anything to solve this problem?
Click to expand...
Click to collapse
I used Device Manager for controlling status Bar but it's not true way, but I solved my problem with this method

Categories

Resources