TV OUT port for our ROMS - FIND SOLUTION and GET YOUR DONATE - HTC Wildfire S

Hi,
I bought MHL cable and RCA cable for connect my phone to TV ( play games on big screen and internet etc) . Today my RCA cable arrived MHL still on the way.
For few peoples who dont know diffrence between two cables. RCA connects on 3.5mm , MHL on mini-usb and MHL have hardware for TV out but rca doesnt.
I tried RCA but didnt work cus there is no TV-OUT option in our roms.
So is there anyway port TV-OUT option (app etc) from other roms?
I will try MHL too when it arrives.
EDIT: If you find a solution for TVOUT you can get DONATE from me [/SIZE]

I had the same question.
Sent from my HTC_A510c using XDA App

junxracr said:
I had the same question.
Sent from my HTC_A510c using XDA App
Click to expand...
Click to collapse
I Think is not posible because the jack of the wildfire dont have video signal, so even if you had the software you cannot

maybe the mhl one will work. tell us the result when you receive it

mud_f1 said:
I Think is not posible because the jack of the wildfire dont have video signal, so even if you had the software you cannot
Click to expand...
Click to collapse
We've already got a whole thread about peoples opinions on this matter. Please guys, only weigh in if you have REAL experience as this is something we all want to know for sure.

Oh sorry i didnt know that.

I will try mhl too when i get it but still ,any rom maker can try to port TV-OUT option from other phones or ROMS ?

Can any rom maker check this thread please.
http://forum.xda-developers.com/showthread.php?t=674041
There is few people trying to port tv out apk to hero.

Bump

There is 3 file i found, copied but looks didnt worked. I tried to install tvout apk but got an error " Application not installed".
system/app/TVOUT.apk
system/app/TVOUT.odex
system/lib/libTVOUT.so
I found new post here : http://forum.xda-developers.com/showthread.php?t=750043
They are talking about services.jar file and kernel.
If can someone help me please post here. And where the hell is services.jar file. Thanks.
Originally Posted by adrynalyne View Post
Does anyone here know which part of the framework also controls TV-OUT? Its not just the apk.
Turns out that there are kernel drivers necessary - there's a framebuffer TVOut driver as well as a USB projector gadget driver. These are built into the CM6 kernel (the one packaged in the nightly builds, not the cm-kernel tree) and obviously the latest RUU from HTC.
Not only that, at least under CM6, there's both fb0 and fb1 display devices present (/dev/display/). I'm assuming the fb1 display is for TV Out.
This leads me to believe that it is most definitely a non-kernel matter, which should help focus efforts (unless you have a vanilla AOSP kernel, in which case it will require kernel driver porting).
logcat/the kernel still doesn't recognize the USB device when I plug in the cable, and I'm not sure what to do at this point.
Click to expand...
Click to collapse

anyone know where is services.jar file in our phone??

/system/framework
Sent from my HTC_A510c using Tapatalk

Codes from our wildfire s
services.jar\classes.dex\com\android\server\TVOUTCableObserver.class
Any clue ???
Code:
public class TVOUTCableObserver
{
private Context mContext;
private BroadcastReceiver receiver = new BroadcastReceiver()
{
private final int TVOUT_BIT = 256;
private int oldState;
public void onReceive(Context paramContext, Intent paramIntent)
{
int i = paramIntent.getIntExtra("state", 0);
paramIntent.getStringExtra("name");
paramIntent.getIntExtra("microphone", 0);
int j = i & 0x100;
if (j != this.oldState)
{
if (j <= 0)
break label73;
TVOUTCableObserver.this.log("plug");
ActivityManagerNative.broadcastStickyIntent(new Intent("android.intent.action.CABLE_PLUG"), null);
}
while (true)
{
this.oldState = j;
return;
label73: TVOUTCableObserver.this.log("unplug");
ActivityManagerNative.broadcastStickyIntent(new Intent("android.intent.action.CABLE_UNPLUG"), null);
}
}
};
public TVOUTCableObserver(Context paramContext)
{
this.mContext = paramContext;
}
private void log(String paramString)
{
}
public void start()
{
IntentFilter localIntentFilter = new IntentFilter("android.intent.action.HEADSET_PLUG");
this.mContext.registerReceiver(this.receiver, localIntentFilter);
}
public void stop()
{
this.mContext.unregisterReceiver(this.receiver);
}
}

And this is from Galaxy S
services.jar\classes.dex\com\android\server\TvOutService.class
There is no TVOUTCableObserver.class.
So is it posibble to delete our TVOUTCableObserver.class and replace TvOutService.class from galaxy s?
Code:
package com.android.server;
import android.app.ActivityManagerNative;
import android.app.Notification;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.hardware.TvOut;
import android.os.Handler;
import android.os.ITvOutService;
import android.os.ITvOutService.Stub;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.provider.Settings.System;
import android.util.Log;
import android.view.IRotationWatcher.Stub;
import android.view.IWindowManager;
import android.view.IWindowManager.Stub;
import android.widget.TextView;
public class TvOutService extends ITvOutService.Stub
{
static final int DEFAULT_TVSTATUS = 0;
static final int DEFAULT_TVSYSTEM = 2;
private static int HDMI_SUBTITLE_HEIGHT = 0;
static final int HDMI_SUBTITLE_MAX_HEIGHT = 304;
static final int HDMI_SUBTITLE_MAX_WIDTH = 1856;
private static int HDMI_SUBTITLE_WIDTH = 0;
public static final String LOCALE_CHANGE_ACTION = "android.intent.action.locale.changed";
private static final boolean LOG = 1;
private static final String TAG = "TvOut-Observer";
static final int TVSTATUS_OFF = 0;
static final int TVSTATUS_ON = 1;
static final int TVSYSTEM_NTSC = 1;
static final int TVSYSTEM_PAL = 2;
private static boolean mIsScreenOff;
private static boolean mIsTvWaitResume;
private static boolean mTvCableConnected;
private static boolean mTvSuspend;
private static int sRotation = 0;
private static IWindowManager sWindowManager;
private Bitmap bitmap_subtitle = null;
private Canvas canvas_subtile = null;
private Context mContext;
Handler mHandler;
private Notification mHeadsetNotification;
final Object mLock = new Object();
private boolean mPlaySounds;
private int mPrevFontSize = 0;
private String mPrevSubtitle = "";
private final BroadcastReceiver mReceiver = new BroadcastReceiver()
{
public void onReceive(Context paramContext, Intent paramIntent)
{
String str = paramIntent.getAction();
Log.i("TvOut-Observer", "ACTION " + str);
Log.i("TvOut-Observer", " tvOutSetImageString BroadcastReceiver broadcast received");
if ("android.intent.action.locale.changed".equals(str))
{
Log.i("TvOut-Observer", " tvOutSetImageString BroadcastReceiver broadcast received");
TvOutService.this.tvOutSetImageString();
}
if ("android.intent.action.SCREEN_OFF".equals(str))
{
Log.i("TvOut-Observer", "ACTION_SCREEN_OFF");
TvOutService.access$602(true);
TvOutService.this.updateTVoutOnScreenOnOff();
}
while (true)
{
return;
if (!("android.intent.action.SCREEN_ON".equals(str)))
continue;
Log.i("TvOut-Observer", "ACTION_SCREEN_ON ");
TvOutService.access$602(false);
TvOutService.this.updateTVoutOnScreenOnOff();
}
}
};
private int mTvStatus;
private int mTvSystem = -1;
private PowerManager.WakeLock mWakeLock = null;
private TvOut tvout;
static
{
mTvCableConnected = false;
mTvSuspend = false;
mIsTvWaitResume = false;
HDMI_SUBTITLE_WIDTH = 0;
HDMI_SUBTITLE_HEIGHT = 0;
mIsScreenOff = false;
}
public TvOutService(Context paramContext)
{
Log.e("TvOut-Observer", "TVOU_DEBUG TvOutService");
this.mContext = paramContext;
this.mPlaySounds = SystemProperties.get("persist.service.mount.playsnd", "1").equals("1");
init();
sWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
if (sWindowManager != null);
try
{
sRotation = sWindowManager.watchRotation(new IRotationWatcher.Stub()
{
public void onRotationChanged(int paramInt)
{
TvOutService.onRotationChanged(paramInt);
}
});
return;
}
catch (RemoteException localRemoteException)
{
}
}
public static void onRotationChanged(int paramInt)
{
ITvOutService localITvOutService = ITvOutService.Stub.asInterface(ServiceManager.getService("tvoutservice"));
if (localITvOutService == null)
Log.e("TvOut-Observer", " setTvoutOrientation TvOutService Not running");
while (true)
{
return;
if (sRotation == paramInt)
continue;
sRotation = paramInt;
try
{
Log.i("TvOut-Observer", "setTvoutOrientation rotation = " + paramInt);
localITvOutService.SetOrientation(paramInt);
}
catch (RemoteException localRemoteException)
{
Log.e("TvOut-Observer", "setTvoutOrientation ", localRemoteException);
}
}
}
private void stayAwake(boolean paramBoolean)
{
if (this.mWakeLock != null)
if ((paramBoolean) && (!(this.mWakeLock.isHeld())))
{
Log.e("TvOut-Observer", "stayAwake Accuring the lock SCREEN_ON_DEBUG");
this.mWakeLock.acquire();
}
while (true)
{
return;
if ((paramBoolean) || (!(this.mWakeLock.isHeld())))
continue;
Log.e("TvOut-Observer", "stayAwake relesing the lock SCREEN_ON_DEBUG");
this.mWakeLock.release();
continue;
Log.e("TvOut-Observer", "stayAwake mWakeLock is null SCREEN_ON_DEBUG");
}
}
private int textSizeForSubtitle()
{
switch (HDMI_SUBTITLE_HEIGHT)
{
default:
case 120:
case 144:
case 180:
case 270:
}
for (int i = 37; ; i = 37)
while (true)
{
Log.e("TvOut-Observer", "textSizeForSubtitle subtitletextsize = " + i);
return i;
i = 16;
continue;
i = 20;
continue;
i = 25;
}
}
private void tvOutSetImageString()
{
String str = this.mContext.getString(17040351);
Log.i("TvOut-Observer", "tvOutSetImageString " + str);
this.tvout.TvOutSetImageString(str);
}
private void updatescreensize()
{
Log.e("TvOut-Observer", "updatescreensize");
}
private void updatetvstatus()
{
Log.e("TvOut-Observer", "updatetvstatus");
if (this.mTvStatus == 0)
{
Log.i("TvOut-Observer", "updatetvstatus tvstatus off mTvCableConnected : " + mTvCableConnected);
if ((this.tvout.isEnabled()) || (isSuspended()))
{
Intent localIntent3 = new Intent("android.intent.action.TVOUT_PLUG");
localIntent3.addFlags(1073741824);
localIntent3.putExtra("state", 0);
localIntent3.putExtra("name", "h2w");
localIntent3.putExtra("microphone", 0);
ActivityManagerNative.broadcastStickyIntent(localIntent3, null);
Log.i("TvOut-Observer", "ACTION_TVOUT_PLUG : disable");
Intent localIntent4 = new Intent("android.intent.action.HEADSET_PLUG");
localIntent4.addFlags(1073741824);
localIntent4.putExtra("state", 1);
localIntent4.putExtra("name", "h2w");
localIntent4.putExtra("microphone", 0);
ActivityManagerNative.broadcastStickyIntent(localIntent4, null);
Log.i("TvOut-Observer", "ACTION_HEADSET_PLUG : enable");
DisableTvOut();
setTvoutCableConnected(0);
}
}
while (true)
{
return;
if (this.mTvStatus == 1)
{
Log.i("TvOut-Observer", "updatetvstatus tvstatus on mTvCableConnected : " + mTvCableConnected);
if ((this.tvout.isEnabled()) || (mTvCableConnected != true))
continue;
Log.i("TvOut-Observer", "updatetvstatus enable tvout mTvCableConnected : " + mTvCableConnected);
Intent localIntent1 = new Intent("android.intent.action.HEADSET_PLUG");
localIntent1.addFlags(1073741824);
localIntent1.putExtra("state", 0);
localIntent1.putExtra("name", "h2w");
localIntent1.putExtra("microphone", 0);
ActivityManagerNative.broadcastStickyIntent(localIntent1, null);
Log.i("TvOut-Observer", "ACTION_HEADSET_PLUG : disable");
Intent localIntent2 = new Intent("android.intent.action.TVOUT_PLUG");
localIntent2.addFlags(1073741824);
localIntent2.putExtra("state", 1);
localIntent2.putExtra("name", "h2w");
localIntent2.putExtra("microphone", 0);
ActivityManagerNative.broadcastStickyIntent(localIntent2, null);
Log.i("TvOut-Observer", "ACTION_TVOUT_PLUG : enable");
EnableTvOut();
setTvoutCableConnected(1);
}
Log.e("TvOut-Observer", "updatetvsystem system shuldnot come here... error in tvout status values");
}
}
private void updatetvsystem()
{
Log.e("TvOut-Observer", "updatetvsystem");
this.tvout.SetTvSystem(this.mTvSystem);
}
public void CableConnected(boolean paramBoolean)
{
Log.e("TvOut-Observer", "CableConnected : " + paramBoolean);
mTvCableConnected = paramBoolean;
if (paramBoolean == true)
{
setTvoutCableConnected(1);
label40: if ((this.mTvStatus != 0) && (mTvCableConnected))
break label94;
Log.i("TvOut-Observer", "CableConnected tvstatus off mTvCableConnected : " + mTvCableConnected);
DisableTvOut();
}
while (true)
{
return;
setTvoutCableConnected(0);
break label40:
label94: if (this.mTvStatus != 1)
continue;
Log.i("TvOut-Observer", "CableConnected tvstatus on mTvCableConnected : " + mTvCableConnected);
if ((!(this.tvout.isEnabled())) && (mTvCableConnected == true))
{
Log.i("TvOut-Observer", "CableConnected enable tvout mTvCableConnected : " + mTvCableConnected);
if (!(mIsScreenOff))
EnableTvOut();
Log.i("TvOut-Observer", "CableConnected enable tvout mIsScreenOff : " + mIsScreenOff);
}
Log.e("TvOut-Observer", "updatetvsystem system shuldnot come here... error in tvout status values");
}
}
public void DisableTvOut()
{
Log.e("TvOut-Observer", "DisableTvOut");
this.tvout.DisableTvOut();
stayAwake(false);
mTvSuspend = false;
mIsTvWaitResume = false;
}
public void DisableTvOutForce()
{
Log.e("TvOut-Observer", "DisableTvOut");
Intent localIntent1 = new Intent("android.intent.action.TVOUT_PLUG");
localIntent1.addFlags(1073741824);
localIntent1.putExtra("state", 0);
localIntent1.putExtra("name", "h2w");
localIntent1.putExtra("microphone", 0);
ActivityManagerNative.broadcastStickyIntent(localIntent1, null);
Log.i("TvOut-Observer", "ACTION_TVOUT_PLUG : disable");
Intent localIntent2 = new Intent("android.intent.action.HEADSET_PLUG");
localIntent2.addFlags(1073741824);
localIntent2.putExtra("state", 1);
localIntent2.putExtra("name", "h2w");
localIntent2.putExtra("microphone", 0);
ActivityManagerNative.broadcastStickyIntent(localIntent2, null);
Log.i("TvOut-Observer", "ACTION_HEADSET_PLUG : enable");
this.tvout.DisableTvOut();
stayAwake(false);
mTvSuspend = false;
mIsTvWaitResume = false;
}
public void EnableTvOut()
{
Log.i("TvOut-Observer", "EnableTvOut");
tvOutSetImageString();
this.tvout.SetOrientation(sRotation);
if (this.tvout.isEnabled())
DisableTvOut();
if ((mTvCableConnected != true) || (this.mTvStatus != 1))
return;
this.tvout.EnableTvOut();
stayAwake(true);
}
public void EnableTvOutForce()
{
Log.e("TvOut-Observer", "EnableTvOut");
Intent localIntent1 = new Intent("android.intent.action.HEADSET_PLUG");
localIntent1.addFlags(1073741824);
localIntent1.putExtra("state", 0);
localIntent1.putExtra("name", "h2w");
localIntent1.putExtra("microphone", 0);
ActivityManagerNative.broadcastStickyIntent(localIntent1, null);
Log.i("TvOut-Observer", "ACTION_HEADSET_PLUG : disable");
Intent localIntent2 = new Intent("android.intent.action.TVOUT_PLUG");
localIntent2.addFlags(1073741824);
localIntent2.putExtra("state", 1);
localIntent2.putExtra("name", "h2w");
localIntent2.putExtra("microphone", 0);
ActivityManagerNative.broadcastStickyIntent(localIntent2, null);
Log.i("TvOut-Observer", "ACTION_TVOUT_PLUG : enable");
this.tvout.SetOrientation(sRotation);
this.tvout.EnableTvOut();
stayAwake(true);
}
public void SetCableStatus(boolean paramBoolean)
{
Log.i("TvOut-Observer", "SetCableStatus : " + paramBoolean);
mTvCableConnected = paramBoolean;
}
public void SetOrientation(int paramInt)
{
Log.e("TvOut-Observer", "SetOrientation");
this.tvout.SetOrientation(paramInt);
}
public void TvOutResume()
{
Log.e("TvOut-Observer", "TvOutResume");
if (mTvSuspend == true)
if ((!(this.tvout.isEnabled())) || (isTvoutCableConnected()))
{
Log.e("TvOut-Observer", "Call Tvout resume");
this.tvout.SetOrientation(sRotation);
this.tvout.TvOutResume(3);
mTvSuspend = false;
mIsTvWaitResume = true;
}
while (true)
{
return;
Log.e("TvOut-Observer", "tvout.isEnabled()" + this.tvout.isEnabled());
continue;
Log.e("TvOut-Observer", "mTvSuspend " + mTvSuspend);
}
}
public void TvOutSetImage(int paramInt)
{
Log.e("TvOut-Observer", "TvOutSetImage");
if (!(this.tvout.isEnabled()))
return;
}
public void TvOutSuspend(String paramString)
{
if ((!(this.tvout.isEnabled())) && (!(this.tvout.isSuspended())))
return;
TvOutSuspendAnalog(paramString);
}
public void TvOutSuspendAnalog(String paramString)
{
Log.e("TvOut-Observer", "TvOutSuspend");
if (isTvoutCableConnected())
if ((!(mTvSuspend)) || (mIsTvWaitResume == true))
{
Log.e("TvOut-Observer", "Call Suspend");
this.tvout.TvOutSuspend(this.mContext, paramString);
mTvSuspend = true;
mIsTvWaitResume = false;
}
while (true)
{
return;
Log.e("TvOut-Observer", "mTvSuspend" + mTvSuspend + " mIsTvWaitResume" + mIsTvWaitResume);
continue;
Log.e("TvOut-Observer", "isTvoutCableConnected()" + isTvoutCableConnected());
}
}
public boolean TvoutSubtitleIsEnable()
{
Log.e("TvOut-Observer", "isHDMISubtitleOn");
return this.tvout.TvoutSubtitleIsEnable();
}
public boolean TvoutSubtitlePostString(String paramString, int paramInt)
{
Log.e("TvOut-Observer", "TvoutSubtitlePostString string = " + paramString + " fontsize : " + paramInt);
int i = 0;
textSizeForSubtitle();
if ((this.mPrevSubtitle.equals(paramString)) && (this.mPrevFontSize == paramInt));
for (int i1 = 0; ; i1 = 1)
{
TextView localTextView;
Bitmap localBitmap;
while (true)
{
return i1;
localTextView = new TextView(this.mContext);
localTextView.setDrawingCacheQuality(524288);
localTextView.setGravity(17);
localTextView.setTextSize((float)(0.8D * paramInt));
localTextView.layout(0, 0, HDMI_SUBTITLE_WIDTH, HDMI_SUBTITLE_HEIGHT);
localTextView.setDrawingCacheBackgroundColor(-16777216);
localTextView.setText(paramString);
localTextView.setDrawingCacheEnabled(true);
localTextView.invalidate();
localTextView.buildDrawingCache();
localBitmap = localTextView.getDrawingCache();
if (localBitmap != null)
break;
Log.e("TvOut-Observer", "TvoutHDMIPostSubtitle bitmap is null ");
i1 = 0;
}
int j = localTextView.getLineCount();
int k = localTextView.getLineHeight();
int l = HDMI_SUBTITLE_HEIGHT - (j * k);
if (l > 0)
i = l / 2 - (k / 2);
Log.e("TvOut-Observer", "subttle y : " + i);
this.bitmap_subtitle.eraseColor(-16777216);
this.canvas_subtile.drawBitmap(localBitmap, 0, i, null);
this.tvout.TvoutSubtitlePostBitmap(this.bitmap_subtitle, -16777216);
localTextView.setDrawingCacheEnabled(false);
this.mPrevSubtitle = paramString;
this.mPrevFontSize = paramInt;
}
}
public boolean TvoutSubtitleSetStatus(int paramInt)
{
Log.e("TvOut-Observer", "TvoutSubtitleSetStatus :" + paramInt);
if (paramInt > 0)
{
if ((!(isEnabled())) || (isSuspended()) || (TvoutSubtitleIsEnable()))
break label135;
HDMI_SUBTITLE_WIDTH = this.tvout.TvoutSubtitleGetWidth();
HDMI_SUBTITLE_HEIGHT = this.tvout.TvoutSubtitleGetHeight();
this.bitmap_subtitle = Bitmap.createBitmap(HDMI_SUBTITLE_WIDTH, HDMI_SUBTITLE_HEIGHT, Bitmap.Config.RGB_565);
this.bitmap_subtitle.eraseColor(-16777216);
this.canvas_subtile = new Canvas(this.bitmap_subtitle);
}
label135: for (boolean bool = this.tvout.TvoutSubtitleSetStatus(1); ; bool = false)
while (true)
{
return bool;
bool = this.tvout.TvoutSubtitleSetStatus(0);
}
}
public String getIntent()
{
return "android.intent.action.locale.changed";
}
void init()
{
Log.e("TvOut-Observer", "TVOUT_DEBUG_VIVEK_ANALOG1");
this.tvout = new TvOut();
this.mHandler = new Handler();
this.mTvStatus = 0;
SettingsObserver localSettingsObserver = new SettingsObserver(this.mHandler);
Settings.System.putInt(this.mContext.getContentResolver(), "tv_out", 0);
localSettingsObserver.observe();
Log.e("TvOut-Observer", "TVOUT_DEBUG_VIVEK_ANALOG2");
IntentFilter localIntentFilter = new IntentFilter();
localIntentFilter.addAction("android.intent.action.locale.changed");
localIntentFilter.addAction("android.intent.action.SCREEN_OFF");
localIntentFilter.addAction("android.intent.action.SCREEN_ON");
this.mContext.registerReceiver(this.mReceiver, localIntentFilter);
setWakeMode(this.mContext, 6);
Log.e("TvOut-Observer", "TVOUT_DEBUG_VIVEK_ANALOG3");
}
public boolean isEnabled()
{
Log.e("TvOut-Observer", "isEnabled");
return this.tvout.isEnabled();
}
public boolean isSuspended()
{
Log.e("TvOut-Observer", "isSuspended");
return this.tvout.isSuspended();
}
public boolean isTvoutCableConnected()
{
Log.e("TvOut-Observer", "isTvoutCableConnected");
return this.tvout.isTvoutCableConnected();
}
public void setTvoutCableConnected(int paramInt)
{
Log.e("TvOut-Observer", "setTvoutCableConnected");
this.tvout.setTvoutCableConnected(paramInt);
}
public void setWakeMode(Context paramContext, int paramInt)
{
int i = 0;
if (this.mWakeLock != null)
{
if (this.mWakeLock.isHeld())
{
i = 1;
this.mWakeLock.release();
}
this.mWakeLock = null;
}
Log.e("TvOut-Observer", "setWakeMode is called SCREEN_ON_DEBUG");
this.mWakeLock = ((PowerManager)paramContext.getSystemService("power")).newWakeLock(0x20000000 | paramInt, "TvOut-Observer");
Log.e("TvOut-Observer", "setWakeMode setting the mode SCREEN_ON_DEBUG mode : " + paramInt);
if (this.mWakeLock == null)
Log.e("TvOut-Observer", "setWakeMode mWakeLock is null SCREEN_ON_DEBUG");
this.mWakeLock.setReferenceCounted(false);
if (i == 0)
return;
this.mWakeLock.acquire();
}
void updateTVoutOnScreenOnOff()
{
if (mIsScreenOff == true)
{
Log.i("TvOut-Observer", "updateTVoutOnScreenOnOff tvstatus off mTvCableConnected : " + mTvCableConnected);
if ((this.mTvStatus == 1) && (mTvCableConnected == true) && (this.tvout.isEnabled()))
DisableTvOut();
}
while (true)
{
return;
if (this.mTvStatus != 1)
continue;
Log.i("TvOut-Observer", "updateTVoutOnScreenOnOff tvstatus on mTvCableConnected : " + mTvCableConnected);
if ((this.tvout.isEnabled()) || (mTvCableConnected != true))
continue;
Log.i("TvOut-Observer", "CableConnected enable tvout mTvCableConnected : " + mTvCableConnected);
if (!(mIsScreenOff))
EnableTvOut();
Log.i("TvOut-Observer", "updateTVoutOnScreenOnOff enable tvout mIsScreenOff : " + mIsScreenOff);
}
}
class SettingsObserver extends ContentObserver
{
SettingsObserver(Handler paramHandler)
{
super(paramHandler);
}
void observe()
{
Log.e("TvOut-Observer", "observe");
ContentResolver localContentResolver = TvOutService.this.mContext.getContentResolver();
localContentResolver.registerContentObserver(Settings.System.getUriFor("tv_system"), false, this);
localContentResolver.registerContentObserver(Settings.System.getUriFor("tv_out"), false, this);
update();
}
public void onChange(boolean paramBoolean)
{
Log.e("TvOut-Observer", "onChange");
update();
}
public void update()
{
Log.e("TvOut-Observer", "update");
ContentResolver localContentResolver = TvOutService.this.mContext.getContentResolver();
int i = 0;
int j = 0;
synchronized (TvOutService.this.mLock)
{
int k = Integer.parseInt(Settings.System.getString(TvOutService.this.mContext.getContentResolver(), "tv_system"));
if (TvOutService.this.mTvSystem != k)
{
TvOutService.access$102(TvOutService.this, k);
i = 1;
}
int l = Settings.System.getInt(localContentResolver, "tv_out", 0);
if (TvOutService.this.mTvStatus != l)
{
TvOutService.access$202(TvOutService.this, l);
j = 1;
}
if (i != 0)
TvOutService.this.updatetvsystem();
if (j != 0)
TvOutService.this.updatetvstatus();
return;
}
}
}
}

I will make this thread more interesting.
If you find a solution for TVOUT you can get DONATE from me

Another link
Galaxy Player 4.0, 5.0
HDMI Capable
http://forum.xda-developers.com/showthread.php?t=1406174&page=3
Looks its not that hard for real developer.
Any help?

I changed services.jar. Added few tv out files from galaxy s.
But still didnt find a solution for install TVOUT.apk
Tried recovery zip and other force to install apk programs. I dont know whats wrong about TVOUT.apk file.
Any develepor can check TVOUT.apk please?

Have you tried copying and pasting the TVOUT files to /system/app?

MrTaco505 said:
Have you tried copying and pasting the TVOUT files to /system/app?
Click to expand...
Click to collapse
Yes i did. same error. and cant see shortcut on menu or anywhere.

Related

[Q] How to read store.vol file Windows phone 7

Hello!
I have file store.vol copy from Windows phone device(HTC HD7). I use EDB API to read it.
My problem: I could not open store.vol file. ERROR_BAD_FORMAT.
How can I open this file.
Thanks!!!
My code:
Code:
#include "stdafx.h"
#include "Winphone7_Lib.h"
#include "clsReadEDB.h"
#include <iosfwd>
#define EDB
extern "C"
{
#include <windbase_edb.h>
}
// clsReadEDB
IMPLEMENT_DYNAMIC(clsReadEDB, CWnd)
clsReadEDB::clsReadEDB()
{
}
void clsReadEDB::readFile(char* path)
{
CEGUID guid;
CEVOLUMEOPTIONS cevo = {0};
cevo.wVersion = 1;
CEOIDINFOEX oidInfo = {0};
wchar_t buff[250];
HANDLE hSes, hBD, hBDS;
BOOL rez;
rez = CeMountDBVolEx(&guid, L"store.vol", &cevo,OPEN_EXISTING);
if (rez == FALSE) {
}
DWORD dw = GetLastError();
hBD = CeFindFirstDatabaseEx(&guid, 0);
if (hBD != INVALID_HANDLE_VALUE)
{
oidInfo.wVersion = CEOIDINFOEX_VERSION;
oidInfo.wObjType = OBJTYPE_DATABASE;
//creare sesiune
hSes = CeCreateSession(&guid);
if (hSes == INVALID_HANDLE_VALUE) {/* error */}
CEOID oidBD = CeFindNextDatabaseEx(hBD, &guid);
while (oidBD != 0)
{
//obtain database information
rez = CeOidGetInfoEx2(&guid, oidBD, &oidInfo);
if (rez != TRUE) {/* error */}
//open database
hBDS = CeOpenDatabaseInSession(hSes, &guid, &oidBD,
oidInfo.infDatabase.szDbaseName, NULL, CEDB_AUTOINCREMENT, NULL);
if (hBDS == INVALID_HANDLE_VALUE) {/* error */}
PCEPROPVAL pInreg = NULL;
PBYTE pBuffInreg = NULL;//memory is allocated by function
WORD wProp;//number of properties
DWORD dwLgInreg;// record lengths
//memory is allocatd by function
CEOID ceoid = CeReadRecordPropsEx(hBDS, CEDB_ALLOWREALLOC, &wProp, NULL,
&(LPBYTE)pBuffInreg, &dwLgInreg, NULL);
int k = 0;
while(ceoid != 0)
{
pInreg = (PCEPROPVAL)pBuffInreg;
//for each field
for (int i = 0; i < wProp; i++)
{
switch(LOWORD(pInreg->propid))
{
case CEVT_LPWSTR:
//process string values
break;
//integers
case CEVT_I2:
case CEVT_I4:
case CEVT_UI2:
case CEVT_UI4:
case CEVT_BLOB:
case CEVT_BOOL:
//process integer values
break;
case CEVT_R8:
//process floating point values
break;
default:
//other types
break;
}
OutputDebugString(buff);
//next field
pInreg++;
}
LocalFree(pBuffInreg);
//next record
ceoid = CeReadRecordPropsEx(hBDS, CEDB_ALLOWREALLOC, &wProp, NULL,
&(LPBYTE)pBuffInreg, &dwLgInreg, NULL);
k++;
}
CloseHandle(hBDS);
//next database
oidBD = CeFindNextDatabaseEx(hBD, &guid);
}
CloseHandle(hBD);
CloseHandle(hSes);
}
CeUnmountDBVol(&guid);
}
clsReadEDB::~clsReadEDB()
{
}

Boolean Replacement

Hey Guys..
I have a problem with my xposed module.
I will a class to boolean false not true if rooted device..
Code:
public static boolean isRooted()
This to return false if rooted device..
Code:
XposedHelpers.findAndHockMethod("com.example.utils.RootCheck", lpparam.classLoader, "isRooted", boolean.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.args[0] = false;
}
});
Xposed say me nosuchmethoderror com.example.utils.RootCheck#isRooted(boolean)..
Can help me..
Thanks
Sorry for my bad English i m a german.
what class is it, is it your own?
are you filtering by package name?
Is not my own class..
From another Application..
This is the class. i have decoded.
I want replace "public static final String" , public static boolean isRooted() to ever false and private static boolean a(String str) to ever false..
can help me?
Code:
public final class RootCheck {
public static final String VALUE_DEVICE_FLAG_SU = "su";
public static final String VALUE_DEVICE_FLAG_SUPER_USER_APK = "superuser.apk";
public static final String VALUE_DEVICE_FLAG_TEST_KEYS = "testkeys";
private RootCheck() {
}
public static boolean isRooted() {
BuildConfig.IS_PROD.booleanValue();
return false;
}
public static Object[] getFlags() {
int i;
int i2;
List arrayList;
Object[] objArr;
int i3 = 1;
String str = Build.TAGS;
if (str == null || !str.contains("test-keys")) {
i = 0;
} else {
i = 1;
}
try {
if (new File("/system/app/Superuser.apk").exists()) {
i2 = 1;
if (!(a("/system/xbin/which su") || a("/system/bin/which su") || a("which su"))) {
i3 = 0;
}
arrayList = new ArrayList();
if (i3 != 0) {
arrayList.add(VALUE_DEVICE_FLAG_SU);
}
if (i2 != 0) {
arrayList.add(VALUE_DEVICE_FLAG_SUPER_USER_APK);
}
if (i != 0) {
arrayList.add(VALUE_DEVICE_FLAG_TEST_KEYS);
}
objArr = new Object[0];
if (arrayList.isEmpty()) {
return arrayList.toArray(objArr);
}
return objArr;
}
} catch (Exception e) {
}
i2 = 0;
i3 = 0;
arrayList = new ArrayList();
if (i3 != 0) {
arrayList.add(VALUE_DEVICE_FLAG_SU);
}
if (i2 != 0) {
arrayList.add(VALUE_DEVICE_FLAG_SUPER_USER_APK);
}
if (i != 0) {
arrayList.add(VALUE_DEVICE_FLAG_TEST_KEYS);
}
objArr = new Object[0];
if (arrayList.isEmpty()) {
return objArr;
}
return arrayList.toArray(objArr);
}
private static boolean a(String str) {
try {
Runtime.getRuntime().exec(str);
return true;
} catch (Exception e) {
return false;
}
}
}
oh wait, isRooted doesn't take any arguments and you're trying to hook isRooted with a boolean argument, which would be a different method
return values are called result here (getResult, setResult.) args is only for arguments
Oh thx
Code:
06-17 22:21:05.373: E/Xposed(30470): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
06-17 22:21:05.373: E/Xposed(30470): at de.bozja.hrh.Hidder$1.beforeHookedMethod(Hidder.java:22)
Error why?
class
Code:
findAndHookMethod("com.example.RootCheck", lpparam.classLoader, "isRooted", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
boolean isRoot = (Boolean) param.getResult(); //Error on this line
if(isRoot == true)
isRoot = false;
param.setResult(isRoot);
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
boolean isRoot = (Boolean) param.getResult();
if(isRoot == true)
isRoot = false;
param.setResult(isRoot);
}
});
beforeHookedMethod is called before the method is executed, so there can't be any result. so it's null
Just setresult to false in beforehooked dont add extra junk
And dont hook method afterhook no need before will do what u need
gitfib said:
oh wait, isRooted doesn't take any arguments and you're trying to hook isRooted with a boolean argument, which would be a different method
return values are called result here (getResult, setResult.) args is only for arguments
Click to expand...
Click to collapse
i am also facing the same issue today when trying to hook some certain method that doesnt take in any argument. And i really didnt get the answer you gave. Could you be more elaborate please?
that was a long time. necrobumping from Google?
I think I meant to use param.setResult instead of param.args[0] to set the return value
gitfib said:
that was a long time. necrobumping from Google?
I think I meant to use param.setResult instead of param.args[0] to set the return value
Click to expand...
Click to collapse
thanks. Will try this too. Couldn't find it on Google
gitfib said:
that was a long time. necrobumping from Google?
I think I meant to use param.setResult instead of param.args[0] to set the return value
Click to expand...
Click to collapse
this is the method i want to hook. I want it to return false
public boolean vpn() {
try {
Iterator it = Collections.list(NetworkInterface.getNetworkInterfaces()).iterator();
String str = "";
do {
if (!it.hasNext()) {
return false;
}
NetworkInterface networkInterface = (NetworkInterface) it.next();
if (networkInterface.isUp()) {
str = networkInterface.getName();
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("IFACE NAME: ");
stringBuilder.append(str);
Log.d("DEBUG", stringBuilder.toString());
if (str.contains("tun") || str.contains("ppp")) {
Toast.makeText(getContext(), "Hello vpn detected", 1).show();
}
} while (!str.contains("pptp"));
Toast.makeText(getContext(), "Hello vpn detected", 1).show();
return true;
} catch (SocketException e) {
e.printStackTrace();
}
}
and this is my kotlin class
package app.devzeus.yesvpn.hook
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XposedHelpers
import de.robv.android.xposed.callbacks.XC_LoadPackage
class hook: IXposedHookLoadPackage {
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
val pakage = "com.eclipse.gamonyapp"
val className = "com.eclipse.gamonyapp.Fragments.OffersFragment"
val method = "vpn"
if (lpparam?.packageName == pakage){
XposedHelpers.findAndHookMethod(className, lpparam.classLoader, method, object: XC_MethodHook(){
override fun beforeHookedMethod(param: MethodHookParam?) {
super.beforeHookedMethod(param)
param?.result = false
}
})
}
}
}
am i doing it wrong? it still doesnt work. The class and method locations are correct
devzeus_ke said:
XposedHelpers.findAndHookMethod(className, lpparam.classLoader, method, object: XC_MethodHook(){
override fun beforeHookedMethod(param: MethodHookParam?) {
super.beforeHookedMethod(param)
param?.result = false
}
Click to expand...
Click to collapse
this should be a separate thread imo
XC_MethodHook | Xposed Framework API
api.xposed.info
in Java there would be no need for the super call and the syntax is .setResult, but I'm not sure in Kotlin
gitfib said:
this should be a separate thread imo
XC_MethodHook | Xposed Framework API
api.xposed.info
in Java there would be no need for the super call and the syntax is .setResult, but I'm not sure in Kotlin
Click to expand...
Click to collapse
about the .setResult(false) the compiler suggests .result = false

Hook contacts data

Hello,
I'm currently working with Xposed and i need to restrict access of contacts to applications installed on smartphone i allready tried some codes but not working anyone can help me?
try {
// final Class<?> cResolver = findClass("android.content.ContentResolver",lpparam.classLoader);
//android.content.ContentProviderClient
final Class<?> cResolver = findClass("android.content.ContentResolver",lpparam.classLoader);
XposedBridge.log("<--------ENTROUUUUUUUUUUUUUU COntentResolver----------->: " + lpparam.packageName);
XposedBridge.hookAllMethods(cResolver, "query", new XC_MethodHook() {
@SuppressLint("DefaultLocale")
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log(" Hooked method: " + param.method);
XposedBridge.log(" uri=" + param.args[0]);
String uri = ((Uri) param.args[0]).toString().toLowerCase();
String[] projection = (param.args[1] instanceof String[] ? (String[]) param.args[1] :null);
if (uri.startsWith("content://com.android.contacts/contacts/name_phone_or_email")) {
} else if (uri.startsWith("content://com.android.contacts/") && !uri.equals("content://com.android.contacts/")) {
XposedBridge.log("JOAAAAAAAAAAAAAAAOOOOOOOOOOOOOOOOOOOO 111111111111111111");
String[] components = uri.replace("content://com.android.", "").split("/");
String methodName = components[0] + "/" + components[1].split("\\?")[0];
if (methodName.equals("contacts/contacts") || methodName.equals("contacts/data") || methodName.equals("contacts/phone_lookup") || methodName.equals("contacts/raw_contacts")){
XposedBridge.log("JOAAAAAAAAAAAAAAAOOOOOOOOOOOOOOOOOOOO 22222222222222");
int urlid = -1;
if ((methodName.equals("contacts/contacts") || methodName.equals("contacts/phone_lookup")) && components.length > 2 && TextUtils.isDigitsOnly(components[2])){
urlid = Integer.parseInt(components[2]);
boolean added = false;
if (projection != null && urlid < 0) {
List<String> listProjection = new ArrayList<String>();
listProjection.addAll(Arrays.asList(projection));
String cid = getIdForUri(uri);
if (cid != null && !listProjection.contains(cid)) {
XposedBridge.log("ENTROUU nesta merda do CID");
added = true;
listProjection.add(cid);
}
param.args[1] = listProjection.toArray(new String[0]);
}
if (added)
XposedBridge.log("ENTROUU nesta merda do added");
param.setObjectExtra("column_added", added);
}
}
}
}
@SuppressLint("DefaultLocale")
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (param.args.length > 1 && param.args[0] instanceof Uri && param.getResult() != null) {
String uri = ((Uri) param.args[0]).toString().toLowerCase();
String[] projection = (param.args[1] instanceof String[] ? (String[]) param.args[1] : null);
String selection = (param.args[2] instanceof String ? (String) param.args[2] : null);
Cursor cursor = (Cursor) param.getResult();
if (uri.startsWith("content://com.android.contacts/")&& !uri.equals("content://com.android.contacts/")) {
// Contacts provider: allow selected contacts
String[] components = uri.replace("content://com.android.", "").split("/");
String methodName = components[0] + "/" + components[1].split("\\?")[0];
if (methodName.equals("contacts/contacts") || methodName.equals("contacts/data") || methodName.equals("contacts/phone_lookup") || methodName.equals("contacts/raw_contacts")) {
int urlid = -1;
if ((methodName.equals("contacts/contacts") || methodName.equals("contacts/phone_lookup")) && components.length > 2 && TextUtils.isDigitsOnly(components[2])){
urlid = Integer.parseInt(components[2]);
}
// Modify column names back
Object column_added = param.getObjectExtra("column_added");
boolean added = (column_added == null ? false : (Boolean) param.getObjectExtra("column_added"));
List<String> listColumn = new ArrayList<String>();
listColumn.addAll(Arrays.asList(cursor.getColumnNames()));
if (added) listColumn.remove(listColumn.size() - 1);
MatrixCursor result = new MatrixCursor(listColumn.toArray(new String[0]));
// Filter rows
String cid = getIdForUri(uri);
int iid = (cid == null ? -1 : cursor.getColumnIndex(cid));
if (iid >= 0 || urlid >= 0)
while (cursor.moveToNext()) {
copyColumns(cursor, result, listColumn.size());
}
else{
XposedBridge.log("ENTROUUUU NO ELSE");
XposedBridge.log("ID missing URI=" + uri + " added=" + added + "/" + cid
+ " columns=" + TextUtils.join(",", cursor.getColumnNames()) + " projection="
+ (projection == null ? "null" : TextUtils.join(",", projection)) + " selection="
+ selection);
}
result.respond(cursor.getExtras());
param.setResult(result);
cursor.close();
}else{
methodName = null;
if (uri.startsWith("content://com.android.contacts/profile"))
methodName = "contacts/profile";
else
methodName = "ContactsProvider2"; // fall-back
if (methodName != null){
// Return empty cursor
MatrixCursor result = new MatrixCursor(cursor.getColumnNames());
result.respond(cursor.getExtras());
XposedBridge.log(cursor.getExtras().toString());
param.setResult(result);
cursor.close();
}
}
}
}
}
});
} catch (Throwable t) {
throw t;
}

Get TextView from method [RESOLVED]

I'm trying to get the TextView of the following method, but everything I have tried returns a null value.
This is the code:
Code:
public final void a(boolean z) {
if (z) {
if (this.W == null) {
this.W = new TextView(getContext());
this.W.setBackgroundResource(android.support.design.widget.b.AnonymousClass7.ay);
this.W.setGravity(17);
LayoutParams marginLayoutParams = new MarginLayoutParams(-2, -2);
marginLayoutParams.bottomMargin = getContext().getResources().getDimensionPixelSize(android.support.design.widget.b.AnonymousClass5.ap);
addView(this.W, marginLayoutParams);
this.h = this.W;
}
this.W.setText(k.e(getContext(), this.a.k).toUpperCase());
this.W.setTextSize(a(getResources()));
this.W.setVisibility(0);
this.t = true;
return;
}
if (this.W != null) {
this.W.setVisibility(8);
}
this.t = false;
}
This is one of the ways in which I have tried to obtain value.
Code:
findAndHookMethod(class, "a", boolean.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(XC_MethodHook.MethodHookParam params) throws Throwable {
super.afterHookedMethod(params);
TextView textView = (TextView) params.thisObject;
if (textView!=null) {
textView.setTextColor(color);
}
}
});
I have also tried the following:
Code:
TextView textView = (TextView) XposedHelpers.getObjectField(p.thisObject, "W");
and
Code:
TextView textView = (TextView] params.args[0];
But nothing is working.
Is it possible to get the TextView? and if it's possible, how to do it?
Problem solved, I had to assign the private variable field as setAccessible(true).

GWD loads watchface.xml this way (java source inside)

This is from the GWD file : C:\Program Files (x86)\GearWatchDesigner\plugins\com.samsung.gwd_1.6.2.201810300802.jar
This is a Java package. When looking inside with a "Java decompiler" (free download), find the loadXml.class and you'll see the following code. Once we analyze this, I think we can kind of figure out the schema.
Code:
package com.samsung.gwd;
import com.samsung.gwd.gef.models.ActionConfig;
import com.samsung.gwd.gef.models.ActionConfigEnum.ACTION_STATE;
import com.samsung.gwd.gef.models.Condition;
import com.samsung.gwd.gef.models.ModelAnimation;
import com.samsung.gwd.gef.models.ModelBackground;
import com.samsung.gwd.gef.models.ModelComponent;
import com.samsung.gwd.gef.models.ModelDigitalclock;
import com.samsung.gwd.gef.models.ModelGroup;
import com.samsung.gwd.gef.models.ModelHand;
import com.samsung.gwd.gef.models.ModelImage;
import com.samsung.gwd.gef.models.ModelIndex;
import com.samsung.gwd.gef.models.ModelRoot;
import com.samsung.gwd.gef.models.ModelText;
import com.samsung.gwd.source.Source;
import com.samsung.gwd.ui.dialog.bitmapfont.BitmapFont;
import com.samsung.gwd.utils.RM;
import com.samsung.gwd.utils.Util;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.log4j.Logger;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import org.xml.sax.SAXException;
public class LoadXml
{
public static final int TIME_ONE_MINUTE = 900;
public static final int TIME_ONE_HOUR = 54000;
public static final double PLATFORM_HOUR_MINUTE_CORRECTION = 0.005D;
Project project;
ModelRoot root;
String path;
Document doc;
String projectDir;
int width;
int height;
public LoadXml(String path, String name, Project project)
{
this.path = path;
File file = new File(path + name);
this.project = project;
this.projectDir = project.getProjectDir();
if (file.isFile())
{
DocumentBuilderFactory docBuildFact = DocumentBuilderFactory.newInstance();
try
{
DocumentBuilder docBuild = docBuildFact.newDocumentBuilder();
this.doc = docBuild.parse(file);
this.doc.getDocumentElement().normalize();
NodeList watchface = this.doc.getElementsByTagName("watchface");
Node watchfaceNode = watchface.item(0);
this.width = Integer.parseInt(((Element)watchfaceNode).getAttribute("width"));
this.height = Integer.parseInt(((Element)watchfaceNode).getAttribute("height"));
NodeList groupsList = this.doc.getElementsByTagName("groups");
for (int i = 0; i < groupsList.getLength(); i++)
{
Node groupsNode = groupsList.item(i);
processGroups((Element)groupsNode);
}
}
catch (ParserConfigurationException e)
{
e.printStackTrace();
}
catch (SAXException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
else
{
Application.LOGGER.error("Loading XML failed : " + path + name);
}
}
void processGroups(Element groupsElmt)
{
if (groupsElmt.getAttribute("type").equals("ambient"))
{
this.project.initLowBitAmbientMode();
this.root = this.project.getAmbientLowRoot();
}
else if (groupsElmt.getAttribute("type").equals("ambient-fullcolor"))
{
this.project.initHighColorAmbientMode();
this.root = this.project.getAmbientHighRoot();
}
else if (groupsElmt.getAttribute("type").equals("current"))
{
this.root = this.project.getModelRoot();
}
else
{
this.root = this.project.getNormalRoot();
}
NodeList groupList = groupsElmt.getElementsByTagName("group");
for (int j = 0; j < groupList.getLength(); j++)
{
Node groupNode = groupList.item(j);
processGroup((Element)groupNode);
}
}
void processGroup(Element groupElm)
{
ModelGroup group = null;
ActionConfig actionConf = null;
String tmpStr = groupElm.getAttribute("x");
if (!groupElm.getAttribute("name").startsWith("__DEFAULT_GROUP")) {
if (!tmpStr.isEmpty())
{
group = new ModelGroup(this.root);
group.setRect(Integer.parseInt(groupElm.getAttribute("x")), Integer.parseInt(groupElm.getAttribute("y")),
Integer.parseInt(groupElm.getAttribute("width")), Integer.parseInt(groupElm.getAttribute("height")));
}
else
{
group = new ModelGroup(this.root);
group.setRect(0, 0, this.width, this.height);
}
}
Point groupLoc;
Point groupLoc;
if (!groupElm.getAttribute("x").isEmpty()) {
groupLoc = new Point(Integer.parseInt(groupElm.getAttribute("x")), Integer.parseInt(groupElm.getAttribute("y")));
} else {
groupLoc = new Point(0, 0);
}
NodeList groupChildList = groupElm.getChildNodes();
for (int i = 0; i < groupChildList.getLength(); i++)
{
Node childNode = groupChildList.item(i);
if ((childNode.getNodeType() == 1) && (childNode.getNodeName().equals("action")))
{
Element childElm = (Element)childNode;
String on_event = childElm.getAttribute("on_event");
if (on_event.equals("tap"))
{
String type = childElm.getAttribute("type");
if (type.equals("launch"))
{
NodeList launchList = childElm.getElementsByTagName("launch");
if (launchList.getLength() != 0)
{
Node launchNode = launchList.item(0);
String appid = ((Element)launchNode).getAttribute("app_id");
if (appid.isEmpty()) {
appid = ((Element)launchNode).getAttribute("preset");
}
if (actionConf != null) {
break;
}
actionConf = new ActionConfig(DeviceSpec.GEAR_S2.getOpenAppTable());
actionConf.setActionState("Open App");
actionConf.setSelectAppId(appid);
}
}
else if (type.equals("image-set-show-next"))
{
if (actionConf != null) {
break;
}
actionConf = new ActionConfig(DeviceSpec.GEAR_S2.getOpenAppTable());
actionConf.setActionState("Change Image");
}
}
}
}
for (int i = 0; i < groupChildList.getLength(); i++)
{
Node childNode = groupChildList.item(i);
if (childNode.getNodeType() == 1)
{
Element childElmnt = (Element)childNode;
if (childNode.getNodeName().equals("part"))
{
ModelComponent model = processPart(childElmnt, group, actionConf);
if (model != null)
{
model.setLocation(model.getLocation().x + groupLoc.x, model.getLocation().y + groupLoc.y);
try
{
if (actionConf == null) {
break;
}
actionConf.setModel(model);
model.setActionConfig(actionConf);
model.setButton(true);
}
catch (Exception e)
{
e.printStackTrace();
if (group == null)
{
this.root.removeChild(model); continue;
}
group.removeChild(model);
continue;
}
}
}
else if (childNode.getNodeName().equals("condition"))
{
ModelComponent model = processCondition(childElmnt, group, 0, 0, null, actionConf);
if (model != null)
{
model.setLocation(model.getLocation().x + groupLoc.x, model.getLocation().y + groupLoc.y);
try
{
if (group == null) {
this.root.addChild(model);
} else {
group.addChild(model);
}
if (actionConf == null) {
break;
}
actionConf.setModel(model);
model.setActionConfig(actionConf);
model.setButton(true);
}
catch (Exception e)
{
e.printStackTrace();
if (group == null) {
this.root.removeChild(model);
} else {
group.removeChild(model);
}
}
}
}
}
}
}
ModelComponent processPart(Element partElmt, ModelGroup group, ActionConfig actionConf)
{
Rectangle partRect = null;
String tmpStr = partElmt.getAttribute("x");
if (!tmpStr.isEmpty()) {
partRect = new Rectangle(Integer.parseInt(tmpStr),
Integer.parseInt(partElmt.getAttribute("y")),
Integer.parseInt(partElmt.getAttribute("width")),
Integer.parseInt(partElmt.getAttribute("height")));
}
String type = partElmt.getAttribute("type");
if (type.equals("image")) {
return processPartImage(partElmt, group, partRect, actionConf);
}
if (type.equals("text")) {
return processPartText(partElmt, group, partRect);
}
if (!type.equals("draw")) {
Application.LOGGER.error("Not supporeted part type : " + type);
}
return null;
}
ModelComponent processPartImage(Element partElmt, ModelGroup group, Rectangle partRect, ActionConfig actionConf)
{
ModelImage obj = null;
boolean isHands = false;
boolean isBackground = false;
boolean isIndex = false;
ModelComponent parent;
ModelComponent parent;
if (group != null) {
parent = group;
} else {
parent = this.root;
}
NodeList partAttrList = null;
Node partAttrNode = null;
Element partAttrElmnt = null;
Element metaElmnt = null;
partAttrList = partElmt.getElementsByTagName("metadata");
if (partAttrList.getLength() != 0)
{
for (int i = 0; i < partAttrList.getLength(); i++)
{
partAttrNode = partAttrList.item(i);
metaElmnt = (Element)partAttrNode;
String tmpStr = metaElmnt.getAttribute("type");
if (tmpStr.equals("hands")) {
isHands = true;
} else if (tmpStr.equals("background")) {
isBackground = true;
} else if (tmpStr.equals("index")) {
isIndex = true;
}
}
}
else
{
partAttrList = partElmt.getElementsByTagName("rotation");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
if ((partAttrElmnt.getAttribute("source").equals("hour0-23.minute")) ||
(partAttrElmnt.getAttribute("source").equals("minute"))) {
isHands = true;
}
}
}
partAttrList = partElmt.getElementsByTagName("image-set");
if ((partAttrList.getLength() == 0) || ((actionConf != null) && (actionConf.getActionState() == ActionConfigEnum.ACTION_STATE.CHANGE_IMAGE)))
{
String baseName = null;
if ((actionConf != null) && (actionConf.getActionState() == ActionConfigEnum.ACTION_STATE.CHANGE_IMAGE))
{
String projResDir = new String(this.project.getProjectDir() + BuildConfig.PATH_XML);
partAttrList = partElmt.getElementsByTagName("image-set");
if (partAttrList.getLength() != 0)
{
int changeNum = 0;
NodeList imageSetChildList = partAttrList.item(0).getChildNodes();
for (int nodeIndex = 0; nodeIndex < imageSetChildList.getLength(); nodeIndex++)
{
Node imageSetChildNode = imageSetChildList.item(nodeIndex);
if (imageSetChildNode.getNodeType() == 1) {
if (imageSetChildNode.getNodeName().equals("image"))
{
Element imageElmnt = (Element)imageSetChildNode;
if (nodeIndex == 0)
{
baseName = imageElmnt.getTextContent();
}
else
{
if ((imageElmnt.getTextContent() == "") || (imageElmnt.getTextContent().compareTo(baseName) == 0))
{
actionConf.setChangeImage(null, changeNum, null);
}
else
{
String str_des = new String(imageElmnt.getTextContent());
if (System.getProperty("os.name").contains("Windows")) {
while (str_des.contains("/")) {
str_des = str_des.replace("/", File.separator);
}
}
actionConf.setChangeImage(RM.getImage(projResDir + str_des),
changeNum, projResDir + str_des);
}
changeNum++;
}
}
}
}
}
Rectangle tempRect = new Rectangle(partRect);
if (isHands) {
obj = new ModelHand(parent, this.path, baseName);
} else if (isBackground) {
obj = new ModelBackground(parent, this.path, baseName);
} else {
obj = new ModelImage(parent, this.path, baseName);
}
obj.setRect(tempRect);
}
else
{
partAttrList = partElmt.getElementsByTagName("image");
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
NodeList partAttrChildList = partAttrNode.getChildNodes();
Rectangle tempRect = new Rectangle(partRect);
if (partAttrChildList.getLength() == 1)
{
if (isHands)
{
obj = new ModelHand(parent, this.path, partAttrElmnt.getTextContent());
obj.setRect(tempRect);
}
else if (isBackground)
{
obj = new ModelBackground(parent, this.path, partAttrElmnt.getTextContent());
obj.setRect(tempRect);
}
else if (isIndex)
{
String tmpStr = metaElmnt.getAttribute("image");
if (!tmpStr.isEmpty())
{
obj = new ModelIndex(parent, this.path, tmpStr);
obj.setRect(tempRect);
((ModelIndex)obj).setOriginalRect(new Rectangle(Integer.parseInt(metaElmnt.getAttribute("x")),
Integer.parseInt(metaElmnt.getAttribute("y")),
Integer.parseInt(metaElmnt.getAttribute("width")),
Integer.parseInt(metaElmnt.getAttribute("height"))));
}
else
{
obj = new ModelIndex(parent, this.path, partAttrElmnt.getTextContent());
obj.setRect(tempRect);
}
tmpStr = metaElmnt.getAttribute("range");
if (tmpStr.isEmpty()) {
return null;
}
((ModelIndex)obj).setRange(0.0D, Integer.parseInt(tmpStr));
tmpStr = metaElmnt.getAttribute("number");
((ModelIndex)obj).setNumber(Integer.parseInt(tmpStr));
((ModelIndex)obj).apply();
((ModelIndex)obj).setRect(tempRect);
}
else
{
obj = new ModelImage(parent, this.path, partAttrElmnt.getTextContent());
obj.setRect(tempRect);
}
}
else {
Application.LOGGER.error("LoadXml : Implement me - image condition, length=" + partAttrChildList.getLength());
}
}
if (obj != null)
{
partAttrList = partElmt.getElementsByTagName("color");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
String tmpStr = partAttrElmnt.getAttribute("a");
if (!tmpStr.isEmpty())
{
tmpStr = partAttrElmnt.getAttribute("r");
if (!tmpStr.isEmpty())
{
obj.setFilterEnable(true);
float[] hsl = Color.RGBtoHSB(Integer.parseInt(partAttrElmnt.getAttribute("r")),
Integer.parseInt(partAttrElmnt.getAttribute("g")),
Integer.parseInt(partAttrElmnt.getAttribute("b")), null);
obj.setHue((int)(hsl[0] * 360.0F - 180.0F));
obj.setSaturation((int)(hsl[1] * 200.0F - 100.0F));
obj.setLightness((int)(hsl[2] * 200.0F - 100.0F));
obj.setAlpha(Integer.parseInt(partAttrElmnt.getAttribute("a")));
}
else
{
obj.setAlpha(Integer.parseInt(partAttrElmnt.getAttribute("a")));
}
}
}
partAttrList = partElmt.getElementsByTagName("rotation");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
String source = partAttrElmnt.getAttribute("source");
if (!source.isEmpty())
{
if (isHands)
{
ModelHand hand = (ModelHand)obj;
hand.setSource(Source.findById(source));
if (!partElmt.getAttribute("x").isEmpty())
{
hand.setPivot(Integer.parseInt(partAttrElmnt.getAttribute("center_x")) +
Integer.parseInt(partElmt.getAttribute("x")),
Integer.parseInt(partAttrElmnt.getAttribute("center_y")) +
Integer.parseInt(partElmt.getAttribute("y")));
hand.setStartAngle(Double.parseDouble(partAttrElmnt.getAttribute("start_angle")));
hand.setEndAngle(Double.parseDouble(partAttrElmnt.getAttribute("end_angle")));
hand.setStartValue(Double.parseDouble(partAttrElmnt.getAttribute("start_value")));
hand.setEndValue(Double.parseDouble(partAttrElmnt.getAttribute("end_value")));
}
else
{
if (group == null) {
hand.setPivot(Integer.parseInt(partAttrElmnt.getAttribute("center_x")),
Integer.parseInt(partAttrElmnt.getAttribute("center_y")));
}
hand.setStartAngle(Double.parseDouble(partAttrElmnt.getAttribute("start_angle")));
hand.setEndAngle(Double.parseDouble(partAttrElmnt.getAttribute("end_angle")));
hand.setStartValue(Double.parseDouble(partAttrElmnt.getAttribute("start_value")));
hand.setEndValue(Double.parseDouble(partAttrElmnt.getAttribute("end_value")));
}
if (partAttrElmnt.getAttribute("animation").equals("tick"))
{
hand.setTensionFrame(Integer.parseInt(partAttrElmnt.getAttribute("tick_frame")) / 2);
hand.setTensionAngle(Double.parseDouble(partAttrElmnt.getAttribute("tick_angle")));
hand.setTension((int)(hand.getTensionAngle() * 100.0D / 6.0D));
hand.setTensionEnabled(true);
}
if (source.equals("hour0-11.minute"))
{
hand.setSource(Source.findById("hour0-23.minute"));
if (hand.getStartAngle() < hand.getEndAngle()) {
hand.setEndAngle(hand.getEndAngle() + 360.0D);
} else {
hand.setEndAngle(hand.getEndAngle() - 360.0D);
}
}
}
}
else if (!partAttrElmnt.getAttribute("angle").isEmpty()) {
if (Util.checkExprTag(partAttrElmnt.getAttribute("angle"))) {
obj.setAngle(Util.removeExprTag(partAttrElmnt.getAttribute("angle")));
} else {
obj.setAngle(Double.parseDouble(partAttrElmnt.getAttribute("angle")));
}
}
}
}
}
else
{
partAttrList = partElmt.getElementsByTagName("image-set");
if (partAttrList.getLength() != 0)
{
ModelAnimation ani = new ModelAnimation(parent);
int frameNum = 0;
ani.setRect(partRect);
NodeList imageSetChildList = partAttrList.item(0).getChildNodes();
for (int nodeIndex = 0; nodeIndex < imageSetChildList.getLength(); nodeIndex++)
{
Node imageSetChildNode = imageSetChildList.item(nodeIndex);
if (imageSetChildNode.getNodeType() == 1)
{
if (imageSetChildNode.getNodeName().equals("image"))
{
Element imageElmnt = (Element)imageSetChildNode;
ModelImage frameItem = new ModelImage(ani, this.path, imageElmnt.getTextContent());
frameItem.setRect(0, 0, partRect.width, partRect.height);
frameItem.setId("Frame " + (nodeIndex + 1));
frameItem.getCondition().deleteAll();
frameItem.getCondition().addItem(frameNum, frameNum + 1);
}
frameNum++;
}
}
partAttrList = partElmt.getElementsByTagName("color");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
String tmpStr = partAttrElmnt.getAttribute("a");
if (!tmpStr.isEmpty()) {
ani.setAlpha(Integer.parseInt(partAttrElmnt.getAttribute("a")));
}
}
partAttrList = partElmt.getElementsByTagName("rotation");
if (partAttrList.getLength() != 0)
{
partAttrElmnt = (Element)partAttrList.item(0);
if (!partAttrElmnt.getAttribute("angle").isEmpty()) {
if (Util.checkExprTag(partAttrElmnt.getAttribute("angle"))) {
ani.setAngle(Util.removeExprTag(partAttrElmnt.getAttribute("angle")));
} else {
ani.setAngle(Double.parseDouble(partAttrElmnt.getAttribute("angle")));
}
}
}
return ani;
}
}
return obj;
}
Con't
Code:
ModelComponent processPartText(Element partElmt, ModelGroup group, Rectangle partRect)
{
String tmpStr = null;
boolean isDigitalclock = false;
NodeList partAttrList = null;
Node partAttrNode = null;
Element partAttrElmnt = null;
partAttrList = partElmt.getElementsByTagName("metadata");
if (partAttrList.getLength() != 0) {
for (int i = 0; i < partAttrList.getLength(); i++)
{
partAttrNode = partAttrList.item(i);
partAttrElmnt = (Element)partAttrNode;
tmpStr = partAttrElmnt.getAttribute("type");
if (tmpStr.equals("digitalclock")) {
isDigitalclock = true;
}
}
}
Rectangle tempRect = new Rectangle(partRect);
if (group != null)
{
tempRect.x += group.getRect().x;
tempRect.y += group.getRect().y;
}
ModelComponent parent;
ModelComponent parent;
if (group != null) {
parent = group;
} else {
parent = this.root;
}
ModelText mText;
ModelText mText;
if (isDigitalclock) {
mText = new ModelDigitalclock(parent);
} else {
mText = new ModelText(parent);
}
mText.setRect(partRect);
partAttrList = partElmt.getElementsByTagName("style");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
tmpStr = partAttrElmnt.getAttribute("typeface");
if (!tmpStr.isEmpty()) {
mText.setFontName(tmpStr);
}
tmpStr = partAttrElmnt.getAttribute("size");
mText.setFont(mText.getFontName(), Integer.parseInt(tmpStr));
tmpStr = partAttrElmnt.getAttribute("style");
if (!tmpStr.isEmpty())
{
if (tmpStr.equals("Bold")) {
mText.setFontStyle(1);
}
mText.setFontStyle(mText.getFontStyle());
}
tmpStr = partAttrElmnt.getAttribute("filename");
if (!tmpStr.isEmpty())
{
mText.setFontName(tmpStr);
mText.setCustomFont(tmpStr, mText.getFontSize());
}
}
partAttrList = partElmt.getElementsByTagName("color");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
tmpStr = partAttrElmnt.getAttribute("r");
if (!tmpStr.isEmpty())
{
mText.setColor(RM.getColor(Integer.parseInt(partAttrElmnt.getAttribute("r")),
Integer.parseInt(partAttrElmnt.getAttribute("g")),
Integer.parseInt(partAttrElmnt.getAttribute("b"))));
mText.setAlpha(Integer.parseInt(partAttrElmnt.getAttribute("a")));
}
else
{
tmpStr = partAttrElmnt.getAttribute("a");
if (!tmpStr.isEmpty()) {
mText.setAlpha(Integer.parseInt(partAttrElmnt.getAttribute("a")));
}
}
}
partAttrList = partElmt.getElementsByTagName("icu-skeleton");
int j;
Locale[] pcLocales;
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
mText.setText(partAttrElmnt.getTextContent());
String strLocales = partAttrElmnt.getAttribute("locale");
if (!strLocales.isEmpty())
{
String[] tokens = strLocales.split(";");
List<Locale> locales = new ArrayList();
String[] arrayOfString1;
j = (arrayOfString1 = tokens).length;
for (int i = 0; i < j; i++)
{
String token = arrayOfString1[i];
pcLocales = Locale.getAvailableLocales();
for (int i = 0; i < pcLocales.length; i++)
{
String str = pcLocales[i].getLanguage() + "_" + pcLocales[i].getCountry();
if (token.equals(str))
{
locales.add(pcLocales[i]);
break;
}
}
}
mText.setLocale(locales);
}
}
partAttrList = partElmt.getElementsByTagName("text");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
String strAlign = partAttrElmnt.getAttribute("align");
if (!strAlign.isEmpty()) {
if (strAlign.equals("left")) {
mText.setAlignment(16384);
} else if (strAlign.equals("right")) {
mText.setAlignment(131072);
} else {
mText.setAlignment(16777216);
}
}
String strLocales = partAttrElmnt.getAttribute("locale");
if (!strLocales.isEmpty())
{
String[] tokens = strLocales.split(";");
List<Locale> locales = new ArrayList();
int k = (pcLocales = tokens).length;
for (j = 0; j < k; j++)
{
Object token = pcLocales[j];
Locale[] pcLocales = Locale.getAvailableLocales();
for (int i = 0; i < pcLocales.length; i++)
{
String str = pcLocales[i].getLanguage() + "_" + pcLocales[i].getCountry();
if (((String)token).equals(str))
{
locales.add(pcLocales[i]);
break;
}
}
}
mText.setLocale(locales);
}
if (partAttrElmnt.getElementsByTagName("format").getLength() != 0)
{
String front = null;String source = null;String back = null;
NodeList textChildList = partAttrElmnt.getChildNodes();
for (int i = 0; i < 2; i++)
{
Node textChildNode = textChildList.item(0);
if (textChildNode.getNodeType() == 1)
{
Element textChildElmnt = (Element)textChildNode;
if (textChildElmnt.getTagName().equals("format")) {
break;
}
textChildList = textChildElmnt.getChildNodes();
}
}
boolean isFormatProcessed = false;
for (int i = 0; i < textChildList.getLength(); i++)
{
Node textChildNode = textChildList.item(i);
if (textChildNode.getNodeType() == 1)
{
Element textChildElmnt = (Element)textChildNode;
if (textChildElmnt.getTagName().equals("format"))
{
source = textChildElmnt.getAttribute("source");
isFormatProcessed = true;
}
}
else if (textChildNode.getNodeType() == 3)
{
Text textChildElmnt = (Text)textChildNode;
tmpStr = textChildElmnt.getTextContent();
if (!tmpStr.isEmpty()) {
if (!isFormatProcessed) {
front = tmpStr;
} else {
back = tmpStr;
}
}
}
}
Application.LOGGER.info(String.format("contents = %s, %s, %s", new Object[] { front, source, back }));
mText.setSource(Source.findById(source));
mText.setFormat(front, back);
}
else
{
tmpStr = partAttrElmnt.getTextContent();
Application.LOGGER.info("contents = " + tmpStr);
if ((!isDigitalclock) &&
(!tmpStr.isEmpty())) {
mText.setText(tmpStr);
}
}
}
partAttrList = partElmt.getElementsByTagName("font");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
tmpStr = partAttrElmnt.getAttribute("filename");
if (!tmpStr.isEmpty()) {
mText.setCustomFont(partAttrElmnt.getAttribute("filename"), Integer.parseInt(partAttrElmnt.getAttribute("size")));
}
tmpStr = partAttrElmnt.getAttribute("family");
if (!tmpStr.isEmpty())
{
NodeList bitmapFontsList = this.doc.getElementsByTagName("bitmap-fonts");
if (bitmapFontsList.getLength() != 0)
{
Node bitmapFontsNode = bitmapFontsList.item(0);
NodeList bitmapFontList = bitmapFontsNode.getChildNodes();
for (int item = 0; item < bitmapFontList.getLength(); item++)
{
Node bitmapFontNode = bitmapFontList.item(item);
if (bitmapFontNode.getNodeType() == 1)
{
Element fontElmt = (Element)bitmapFontNode;
String fontName = fontElmt.getAttribute("name");
if (fontName.equals(tmpStr))
{
processBitmapFonts((Element)bitmapFontNode, mText);
break;
}
}
}
}
}
tmpStr = partAttrElmnt.getAttribute("slant");
if ((!tmpStr.isEmpty()) &&
(tmpStr.equals("italic"))) {
mText.addFontStyle(2);
}
tmpStr = partAttrElmnt.getAttribute("weight");
if ((!tmpStr.isEmpty()) &&
(tmpStr.equals("bold"))) {
mText.addFontStyle(1);
}
}
partAttrList = partElmt.getElementsByTagName("rotation");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
String source = partAttrElmnt.getAttribute("source");
if (!source.isEmpty()) {
mText.setSource(Source.findById(source));
} else if (!partAttrElmnt.getAttribute("angle").isEmpty()) {
if (Util.checkExprTag(partAttrElmnt.getAttribute("angle"))) {
mText.setAngle(Util.removeExprTag(partAttrElmnt.getAttribute("angle")));
} else {
mText.setAngle(Double.parseDouble(partAttrElmnt.getAttribute("angle")));
}
}
}
partAttrList = partElmt.getElementsByTagName("underline");
if (partAttrList.getLength() != 0) {
mText.addFontStyle(4);
}
partAttrList = partElmt.getElementsByTagName("strike-through");
if (partAttrList.getLength() != 0) {
mText.addFontStyle(8);
}
mText.setFontStyle(mText.getFontStyle());
return mText;
}
ModelComponent processCondition(Element conditionElmt, ModelGroup group, int start, int end, ModelComponent _obj, ActionConfig actionConf)
{
ModelComponent conditionObj = _obj;
int depth = 0;
int startValue = 0;
String source = conditionElmt.getAttribute("source");
if (source.equals("battery.percent"))
{
NodeList conditionChildList = conditionElmt.getChildNodes();
for (int i = 0; i < conditionChildList.getLength(); i++)
{
Node conditionChildNode = conditionChildList.item(i);
if (conditionChildNode.getNodeType() == 1)
{
Element conditionChildElmnt = (Element)conditionChildNode;
if (conditionChildNode.getNodeName().equals("compare"))
{
String compareValue = conditionChildElmnt.getAttribute("lt");
if (compareValue.isEmpty()) {
compareValue = conditionChildElmnt.getAttribute("le");
}
int value = Integer.parseInt(compareValue);
ModelComponent obj = processCompareBattery(conditionChildElmnt, group, start + startValue, value, conditionObj, actionConf);
if ((obj != null) && (conditionObj == null)) {
conditionObj = obj;
} else {
startValue = value;
}
}
else
{
conditionChildNode.getNodeName().equals("default");
}
}
}
}
else if (source.equals("pedometer.stepPercent"))
{
NodeList conditionChildList = conditionElmt.getChildNodes();
for (int i = 0; i < conditionChildList.getLength(); i++)
{
Node conditionChildNode = conditionChildList.item(i);
if (conditionChildNode.getNodeType() == 1)
{
Element conditionChildElmnt = (Element)conditionChildNode;
if (conditionChildNode.getNodeName().equals("compare"))
{
String compareValue = conditionChildElmnt.getAttribute("lt");
if (compareValue.isEmpty()) {
compareValue = conditionChildElmnt.getAttribute("le");
}
if (!compareValue.isEmpty())
{
int value = Integer.parseInt(compareValue);
ModelComponent obj = processComparePedometer(conditionChildElmnt, group, start + startValue, value, conditionObj, actionConf);
if ((obj != null) && (conditionObj == null)) {
conditionObj = obj;
} else {
startValue = value;
}
}
}
else
{
conditionChildNode.getNodeName().equals("default");
}
}
}
}
else
{
if (source.equals("hour0-23.minute"))
{
depth = 1;
}
else if (source.equals("second.millisecond"))
{
depth = 2;
startValue = start;
}
NodeList conditionChildList = conditionElmt.getChildNodes();
for (int i = 0; i < conditionChildList.getLength(); i++)
{
Node conditionChildNode = conditionChildList.item(i);
if (conditionChildNode.getNodeType() == 1)
{
Element conditionChildElmnt = (Element)conditionChildNode;
if (conditionChildNode.getNodeName().equals("compare"))
{
String compareValue = conditionChildElmnt.getAttribute("lt");
if (!compareValue.isEmpty()) {
if (depth == 1)
{
int value = (int)Math.round((Double.parseDouble(compareValue) + 0.005D) * 54000.0D);
if (value % 900 != 0) {
value = (int)Math.round(Double.parseDouble(compareValue) * 54000.0D);
}
ModelComponent obj = processCompareTimeline(conditionChildElmnt, group, start + startValue, value, conditionObj, actionConf);
if ((obj != null) && (conditionObj == null)) {
conditionObj = obj;
} else {
startValue = value;
}
}
else
{
int value = (int)Math.round(Double.parseDouble(compareValue) * 15.0D) + start;
ModelComponent obj = processCompareTimeline(conditionChildElmnt, group, startValue, value, conditionObj, actionConf);
if ((obj != null) && (conditionObj == null)) {
conditionObj = obj;
} else {
startValue = value;
}
}
}
}
else if ((conditionChildNode.getNodeName().equals("default")) &&
(depth == 2))
{
ModelComponent obj = processCompareTimeline(conditionChildElmnt, group, startValue, end, conditionObj, actionConf);
if ((obj != null) && (conditionObj == null)) {
conditionObj = obj;
} else {
startValue = end;
}
}
}
}
}
return conditionObj;
}
ModelComponent processCompareTimeline(Element compareElmt, ModelGroup group, int start, int end, ModelComponent _obj, ActionConfig actionConf)
{
ModelComponent conditionObj = _obj;
int startValue = start;
int endValue = end;
NodeList compareChildList = compareElmt.getChildNodes();
if (compareChildList.getLength() == 0) {
return null;
}
for (int i = 0; i < compareChildList.getLength(); i++)
{
Node compareChildNode = compareChildList.item(i);
if (compareChildNode.getNodeType() == 1)
{
Element compareChildElmnt = (Element)compareChildNode;
if (compareChildNode.getNodeName().equals("part"))
{
ModelComponent obj = processPart(compareChildElmnt, group, actionConf);
if (obj != null)
{
endValue = end;
if (_obj == null)
{
conditionObj = obj;
conditionObj.getCondition().deleteAll();
conditionObj.getCondition().addItem(startValue, endValue);
}
else
{
conditionObj.getCondition().addItem(startValue, endValue);
}
}
else
{
startValue = end;
}
return obj;
}
if (compareChildNode.getNodeName().equals("condition"))
{
ModelComponent obj = processCondition(compareChildElmnt, group, endValue - 900, endValue, conditionObj, actionConf);
return obj;
}
}
}
return null;
}
ModelComponent processCompareBattery(Element compareElmt, ModelGroup group, int start, int end, ModelComponent _obj, ActionConfig actionConf)
{
ModelComponent conditionObj = _obj;
int startValue = start;
int endValue = end;
NodeList compareChildList = compareElmt.getChildNodes();
if (compareChildList.getLength() == 0) {
return null;
}
for (int i = 0; i < compareChildList.getLength(); i++)
{
Node compareChildNode = compareChildList.item(i);
if (compareChildNode.getNodeType() == 1)
{
Element compareChildElmnt = (Element)compareChildNode;
if (compareChildNode.getNodeName().equals("part"))
{
ModelComponent obj = processPart(compareChildElmnt, group, actionConf);
if (obj != null)
{
endValue = end;
if (conditionObj == null)
{
conditionObj = obj;
conditionObj.getCondition().setSource("battery");
conditionObj.getCondition().deleteAll();
conditionObj.getCondition().addItem(startValue, endValue);
}
else
{
conditionObj.getCondition().addItem(startValue, endValue);
}
}
else
{
startValue = end;
}
return conditionObj;
}
}
}
return null;
}
void processBitmapFonts(Element bitmapElmt, ModelText txt)
{
NodeList bitmapChildList = bitmapElmt.getChildNodes();
if (bitmapChildList.getLength() == 0) {
return;
}
txt.loadBitmapFont(bitmapElmt.getAttribute("name"));
for (int item = 0; item < bitmapChildList.getLength(); item++)
{
Node bitmapChildNode = bitmapChildList.item(item);
if (bitmapChildNode.getNodeType() == 1)
{
Element bitmapChildElmnt = (Element)bitmapChildNode;
if (bitmapChildNode.getNodeName().equals("character"))
{
String name = bitmapChildElmnt.getAttribute("name");
txt.getBitmapFont().setCharacter(name,
RM.getImage(this.projectDir + BuildConfig.PATH_CUSTOM_FONT + name + '/' + bitmapChildElmnt.getAttribute("filepath")));
}
}
}
}
ModelComponent processComparePedometer(Element compareElmt, ModelGroup group, int start, int end, ModelComponent _obj, ActionConfig actionConf)
{
ModelComponent conditionObj = _obj;
int startValue = start;
int endValue = end;
NodeList compareChildList = compareElmt.getChildNodes();
if (compareChildList.getLength() == 0) {
return null;
}
for (int i = 0; i < compareChildList.getLength(); i++)
{
Node compareChildNode = compareChildList.item(i);
if (compareChildNode.getNodeType() == 1)
{
Element compareChildElmnt = (Element)compareChildNode;
if (compareChildNode.getNodeName().equals("part"))
{
ModelComponent obj = processPart(compareChildElmnt, group, actionConf);
if (obj != null)
{
endValue = end;
if (conditionObj == null)
{
conditionObj = obj;
conditionObj.getCondition().setSource("workout");
conditionObj.getCondition().deleteAll();
conditionObj.getCondition().addItem(startValue, endValue);
}
else
{
conditionObj.getCondition().addItem(startValue, endValue);
}
}
else
{
startValue = end;
}
return conditionObj;
}
}
}
return null;
}
public int getWidth()
{
return this.width;
}
public int getHeight()
{
return this.height;
}
}
Why such complicated? just download the gwd file and convert to tpk file to upload to your smartwatch. I can teach you how to do if you interest to know it. Ping me at [email protected]
Zeuserx said:
This is from the GWD file : C:\Program Files (x86)\GearWatchDesigner\plugins\com.samsung.gwd_1.6.2.201810300802.jar
This is a Java package. When looking inside with a "Java decompiler" (free download), find the loadXml.class and you'll see the following code. Once we analyze this, I think we can kind of figure out the schema.
Code:
package com.samsung.gwd;
import com.samsung.gwd.gef.models.ActionConfig;
import com.samsung.gwd.gef.models.ActionConfigEnum.ACTION_STATE;
import com.samsung.gwd.gef.models.Condition;
import com.samsung.gwd.gef.models.ModelAnimation;
import com.samsung.gwd.gef.models.ModelBackground;
import com.samsung.gwd.gef.models.ModelComponent;
import com.samsung.gwd.gef.models.ModelDigitalclock;
import com.samsung.gwd.gef.models.ModelGroup;
import com.samsung.gwd.gef.models.ModelHand;
import com.samsung.gwd.gef.models.ModelImage;
import com.samsung.gwd.gef.models.ModelIndex;
import com.samsung.gwd.gef.models.ModelRoot;
import com.samsung.gwd.gef.models.ModelText;
import com.samsung.gwd.source.Source;
import com.samsung.gwd.ui.dialog.bitmapfont.BitmapFont;
import com.samsung.gwd.utils.RM;
import com.samsung.gwd.utils.Util;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.log4j.Logger;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import org.xml.sax.SAXException;
public class LoadXml
{
public static final int TIME_ONE_MINUTE = 900;
public static final int TIME_ONE_HOUR = 54000;
public static final double PLATFORM_HOUR_MINUTE_CORRECTION = 0.005D;
Project project;
ModelRoot root;
String path;
Document doc;
String projectDir;
int width;
int height;
public LoadXml(String path, String name, Project project)
{
this.path = path;
File file = new File(path + name);
this.project = project;
this.projectDir = project.getProjectDir();
if (file.isFile())
{
DocumentBuilderFactory docBuildFact = DocumentBuilderFactory.newInstance();
try
{
DocumentBuilder docBuild = docBuildFact.newDocumentBuilder();
this.doc = docBuild.parse(file);
this.doc.getDocumentElement().normalize();
NodeList watchface = this.doc.getElementsByTagName("watchface");
Node watchfaceNode = watchface.item(0);
this.width = Integer.parseInt(((Element)watchfaceNode).getAttribute("width"));
this.height = Integer.parseInt(((Element)watchfaceNode).getAttribute("height"));
NodeList groupsList = this.doc.getElementsByTagName("groups");
for (int i = 0; i < groupsList.getLength(); i++)
{
Node groupsNode = groupsList.item(i);
processGroups((Element)groupsNode);
}
}
catch (ParserConfigurationException e)
{
e.printStackTrace();
}
catch (SAXException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
else
{
Application.LOGGER.error("Loading XML failed : " + path + name);
}
}
void processGroups(Element groupsElmt)
{
if (groupsElmt.getAttribute("type").equals("ambient"))
{
this.project.initLowBitAmbientMode();
this.root = this.project.getAmbientLowRoot();
}
else if (groupsElmt.getAttribute("type").equals("ambient-fullcolor"))
{
this.project.initHighColorAmbientMode();
this.root = this.project.getAmbientHighRoot();
}
else if (groupsElmt.getAttribute("type").equals("current"))
{
this.root = this.project.getModelRoot();
}
else
{
this.root = this.project.getNormalRoot();
}
NodeList groupList = groupsElmt.getElementsByTagName("group");
for (int j = 0; j < groupList.getLength(); j++)
{
Node groupNode = groupList.item(j);
processGroup((Element)groupNode);
}
}
void processGroup(Element groupElm)
{
ModelGroup group = null;
ActionConfig actionConf = null;
String tmpStr = groupElm.getAttribute("x");
if (!groupElm.getAttribute("name").startsWith("__DEFAULT_GROUP")) {
if (!tmpStr.isEmpty())
{
group = new ModelGroup(this.root);
group.setRect(Integer.parseInt(groupElm.getAttribute("x")), Integer.parseInt(groupElm.getAttribute("y")),
Integer.parseInt(groupElm.getAttribute("width")), Integer.parseInt(groupElm.getAttribute("height")));
}
else
{
group = new ModelGroup(this.root);
group.setRect(0, 0, this.width, this.height);
}
}
Point groupLoc;
Point groupLoc;
if (!groupElm.getAttribute("x").isEmpty()) {
groupLoc = new Point(Integer.parseInt(groupElm.getAttribute("x")), Integer.parseInt(groupElm.getAttribute("y")));
} else {
groupLoc = new Point(0, 0);
}
NodeList groupChildList = groupElm.getChildNodes();
for (int i = 0; i < groupChildList.getLength(); i++)
{
Node childNode = groupChildList.item(i);
if ((childNode.getNodeType() == 1) && (childNode.getNodeName().equals("action")))
{
Element childElm = (Element)childNode;
String on_event = childElm.getAttribute("on_event");
if (on_event.equals("tap"))
{
String type = childElm.getAttribute("type");
if (type.equals("launch"))
{
NodeList launchList = childElm.getElementsByTagName("launch");
if (launchList.getLength() != 0)
{
Node launchNode = launchList.item(0);
String appid = ((Element)launchNode).getAttribute("app_id");
if (appid.isEmpty()) {
appid = ((Element)launchNode).getAttribute("preset");
}
if (actionConf != null) {
break;
}
actionConf = new ActionConfig(DeviceSpec.GEAR_S2.getOpenAppTable());
actionConf.setActionState("Open App");
actionConf.setSelectAppId(appid);
}
}
else if (type.equals("image-set-show-next"))
{
if (actionConf != null) {
break;
}
actionConf = new ActionConfig(DeviceSpec.GEAR_S2.getOpenAppTable());
actionConf.setActionState("Change Image");
}
}
}
}
for (int i = 0; i < groupChildList.getLength(); i++)
{
Node childNode = groupChildList.item(i);
if (childNode.getNodeType() == 1)
{
Element childElmnt = (Element)childNode;
if (childNode.getNodeName().equals("part"))
{
ModelComponent model = processPart(childElmnt, group, actionConf);
if (model != null)
{
model.setLocation(model.getLocation().x + groupLoc.x, model.getLocation().y + groupLoc.y);
try
{
if (actionConf == null) {
break;
}
actionConf.setModel(model);
model.setActionConfig(actionConf);
model.setButton(true);
}
catch (Exception e)
{
e.printStackTrace();
if (group == null)
{
this.root.removeChild(model); continue;
}
group.removeChild(model);
continue;
}
}
}
else if (childNode.getNodeName().equals("condition"))
{
ModelComponent model = processCondition(childElmnt, group, 0, 0, null, actionConf);
if (model != null)
{
model.setLocation(model.getLocation().x + groupLoc.x, model.getLocation().y + groupLoc.y);
try
{
if (group == null) {
this.root.addChild(model);
} else {
group.addChild(model);
}
if (actionConf == null) {
break;
}
actionConf.setModel(model);
model.setActionConfig(actionConf);
model.setButton(true);
}
catch (Exception e)
{
e.printStackTrace();
if (group == null) {
this.root.removeChild(model);
} else {
group.removeChild(model);
}
}
}
}
}
}
}
ModelComponent processPart(Element partElmt, ModelGroup group, ActionConfig actionConf)
{
Rectangle partRect = null;
String tmpStr = partElmt.getAttribute("x");
if (!tmpStr.isEmpty()) {
partRect = new Rectangle(Integer.parseInt(tmpStr),
Integer.parseInt(partElmt.getAttribute("y")),
Integer.parseInt(partElmt.getAttribute("width")),
Integer.parseInt(partElmt.getAttribute("height")));
}
String type = partElmt.getAttribute("type");
if (type.equals("image")) {
return processPartImage(partElmt, group, partRect, actionConf);
}
if (type.equals("text")) {
return processPartText(partElmt, group, partRect);
}
if (!type.equals("draw")) {
Application.LOGGER.error("Not supporeted part type : " + type);
}
return null;
}
ModelComponent processPartImage(Element partElmt, ModelGroup group, Rectangle partRect, ActionConfig actionConf)
{
ModelImage obj = null;
boolean isHands = false;
boolean isBackground = false;
boolean isIndex = false;
ModelComponent parent;
ModelComponent parent;
if (group != null) {
parent = group;
} else {
parent = this.root;
}
NodeList partAttrList = null;
Node partAttrNode = null;
Element partAttrElmnt = null;
Element metaElmnt = null;
partAttrList = partElmt.getElementsByTagName("metadata");
if (partAttrList.getLength() != 0)
{
for (int i = 0; i < partAttrList.getLength(); i++)
{
partAttrNode = partAttrList.item(i);
metaElmnt = (Element)partAttrNode;
String tmpStr = metaElmnt.getAttribute("type");
if (tmpStr.equals("hands")) {
isHands = true;
} else if (tmpStr.equals("background")) {
isBackground = true;
} else if (tmpStr.equals("index")) {
isIndex = true;
}
}
}
else
{
partAttrList = partElmt.getElementsByTagName("rotation");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
if ((partAttrElmnt.getAttribute("source").equals("hour0-23.minute")) ||
(partAttrElmnt.getAttribute("source").equals("minute"))) {
isHands = true;
}
}
}
partAttrList = partElmt.getElementsByTagName("image-set");
if ((partAttrList.getLength() == 0) || ((actionConf != null) && (actionConf.getActionState() == ActionConfigEnum.ACTION_STATE.CHANGE_IMAGE)))
{
String baseName = null;
if ((actionConf != null) && (actionConf.getActionState() == ActionConfigEnum.ACTION_STATE.CHANGE_IMAGE))
{
String projResDir = new String(this.project.getProjectDir() + BuildConfig.PATH_XML);
partAttrList = partElmt.getElementsByTagName("image-set");
if (partAttrList.getLength() != 0)
{
int changeNum = 0;
NodeList imageSetChildList = partAttrList.item(0).getChildNodes();
for (int nodeIndex = 0; nodeIndex < imageSetChildList.getLength(); nodeIndex++)
{
Node imageSetChildNode = imageSetChildList.item(nodeIndex);
if (imageSetChildNode.getNodeType() == 1) {
if (imageSetChildNode.getNodeName().equals("image"))
{
Element imageElmnt = (Element)imageSetChildNode;
if (nodeIndex == 0)
{
baseName = imageElmnt.getTextContent();
}
else
{
if ((imageElmnt.getTextContent() == "") || (imageElmnt.getTextContent().compareTo(baseName) == 0))
{
actionConf.setChangeImage(null, changeNum, null);
}
else
{
String str_des = new String(imageElmnt.getTextContent());
if (System.getProperty("os.name").contains("Windows")) {
while (str_des.contains("/")) {
str_des = str_des.replace("/", File.separator);
}
}
actionConf.setChangeImage(RM.getImage(projResDir + str_des),
changeNum, projResDir + str_des);
}
changeNum++;
}
}
}
}
}
Rectangle tempRect = new Rectangle(partRect);
if (isHands) {
obj = new ModelHand(parent, this.path, baseName);
} else if (isBackground) {
obj = new ModelBackground(parent, this.path, baseName);
} else {
obj = new ModelImage(parent, this.path, baseName);
}
obj.setRect(tempRect);
}
else
{
partAttrList = partElmt.getElementsByTagName("image");
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
NodeList partAttrChildList = partAttrNode.getChildNodes();
Rectangle tempRect = new Rectangle(partRect);
if (partAttrChildList.getLength() == 1)
{
if (isHands)
{
obj = new ModelHand(parent, this.path, partAttrElmnt.getTextContent());
obj.setRect(tempRect);
}
else if (isBackground)
{
obj = new ModelBackground(parent, this.path, partAttrElmnt.getTextContent());
obj.setRect(tempRect);
}
else if (isIndex)
{
String tmpStr = metaElmnt.getAttribute("image");
if (!tmpStr.isEmpty())
{
obj = new ModelIndex(parent, this.path, tmpStr);
obj.setRect(tempRect);
((ModelIndex)obj).setOriginalRect(new Rectangle(Integer.parseInt(metaElmnt.getAttribute("x")),
Integer.parseInt(metaElmnt.getAttribute("y")),
Integer.parseInt(metaElmnt.getAttribute("width")),
Integer.parseInt(metaElmnt.getAttribute("height"))));
}
else
{
obj = new ModelIndex(parent, this.path, partAttrElmnt.getTextContent());
obj.setRect(tempRect);
}
tmpStr = metaElmnt.getAttribute("range");
if (tmpStr.isEmpty()) {
return null;
}
((ModelIndex)obj).setRange(0.0D, Integer.parseInt(tmpStr));
tmpStr = metaElmnt.getAttribute("number");
((ModelIndex)obj).setNumber(Integer.parseInt(tmpStr));
((ModelIndex)obj).apply();
((ModelIndex)obj).setRect(tempRect);
}
else
{
obj = new ModelImage(parent, this.path, partAttrElmnt.getTextContent());
obj.setRect(tempRect);
}
}
else {
Application.LOGGER.error("LoadXml : Implement me - image condition, length=" + partAttrChildList.getLength());
}
}
if (obj != null)
{
partAttrList = partElmt.getElementsByTagName("color");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
String tmpStr = partAttrElmnt.getAttribute("a");
if (!tmpStr.isEmpty())
{
tmpStr = partAttrElmnt.getAttribute("r");
if (!tmpStr.isEmpty())
{
obj.setFilterEnable(true);
float[] hsl = Color.RGBtoHSB(Integer.parseInt(partAttrElmnt.getAttribute("r")),
Integer.parseInt(partAttrElmnt.getAttribute("g")),
Integer.parseInt(partAttrElmnt.getAttribute("b")), null);
obj.setHue((int)(hsl[0] * 360.0F - 180.0F));
obj.setSaturation((int)(hsl[1] * 200.0F - 100.0F));
obj.setLightness((int)(hsl[2] * 200.0F - 100.0F));
obj.setAlpha(Integer.parseInt(partAttrElmnt.getAttribute("a")));
}
else
{
obj.setAlpha(Integer.parseInt(partAttrElmnt.getAttribute("a")));
}
}
}
partAttrList = partElmt.getElementsByTagName("rotation");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
String source = partAttrElmnt.getAttribute("source");
if (!source.isEmpty())
{
if (isHands)
{
ModelHand hand = (ModelHand)obj;
hand.setSource(Source.findById(source));
if (!partElmt.getAttribute("x").isEmpty())
{
hand.setPivot(Integer.parseInt(partAttrElmnt.getAttribute("center_x")) +
Integer.parseInt(partElmt.getAttribute("x")),
Integer.parseInt(partAttrElmnt.getAttribute("center_y")) +
Integer.parseInt(partElmt.getAttribute("y")));
hand.setStartAngle(Double.parseDouble(partAttrElmnt.getAttribute("start_angle")));
hand.setEndAngle(Double.parseDouble(partAttrElmnt.getAttribute("end_angle")));
hand.setStartValue(Double.parseDouble(partAttrElmnt.getAttribute("start_value")));
hand.setEndValue(Double.parseDouble(partAttrElmnt.getAttribute("end_value")));
}
else
{
if (group == null) {
hand.setPivot(Integer.parseInt(partAttrElmnt.getAttribute("center_x")),
Integer.parseInt(partAttrElmnt.getAttribute("center_y")));
}
hand.setStartAngle(Double.parseDouble(partAttrElmnt.getAttribute("start_angle")));
hand.setEndAngle(Double.parseDouble(partAttrElmnt.getAttribute("end_angle")));
hand.setStartValue(Double.parseDouble(partAttrElmnt.getAttribute("start_value")));
hand.setEndValue(Double.parseDouble(partAttrElmnt.getAttribute("end_value")));
}
if (partAttrElmnt.getAttribute("animation").equals("tick"))
{
hand.setTensionFrame(Integer.parseInt(partAttrElmnt.getAttribute("tick_frame")) / 2);
hand.setTensionAngle(Double.parseDouble(partAttrElmnt.getAttribute("tick_angle")));
hand.setTension((int)(hand.getTensionAngle() * 100.0D / 6.0D));
hand.setTensionEnabled(true);
}
if (source.equals("hour0-11.minute"))
{
hand.setSource(Source.findById("hour0-23.minute"));
if (hand.getStartAngle() < hand.getEndAngle()) {
hand.setEndAngle(hand.getEndAngle() + 360.0D);
} else {
hand.setEndAngle(hand.getEndAngle() - 360.0D);
}
}
}
}
else if (!partAttrElmnt.getAttribute("angle").isEmpty()) {
if (Util.checkExprTag(partAttrElmnt.getAttribute("angle"))) {
obj.setAngle(Util.removeExprTag(partAttrElmnt.getAttribute("angle")));
} else {
obj.setAngle(Double.parseDouble(partAttrElmnt.getAttribute("angle")));
}
}
}
}
}
else
{
partAttrList = partElmt.getElementsByTagName("image-set");
if (partAttrList.getLength() != 0)
{
ModelAnimation ani = new ModelAnimation(parent);
int frameNum = 0;
ani.setRect(partRect);
NodeList imageSetChildList = partAttrList.item(0).getChildNodes();
for (int nodeIndex = 0; nodeIndex < imageSetChildList.getLength(); nodeIndex++)
{
Node imageSetChildNode = imageSetChildList.item(nodeIndex);
if (imageSetChildNode.getNodeType() == 1)
{
if (imageSetChildNode.getNodeName().equals("image"))
{
Element imageElmnt = (Element)imageSetChildNode;
ModelImage frameItem = new ModelImage(ani, this.path, imageElmnt.getTextContent());
frameItem.setRect(0, 0, partRect.width, partRect.height);
frameItem.setId("Frame " + (nodeIndex + 1));
frameItem.getCondition().deleteAll();
frameItem.getCondition().addItem(frameNum, frameNum + 1);
}
frameNum++;
}
}
partAttrList = partElmt.getElementsByTagName("color");
if (partAttrList.getLength() != 0)
{
partAttrNode = partAttrList.item(0);
partAttrElmnt = (Element)partAttrNode;
String tmpStr = partAttrElmnt.getAttribute("a");
if (!tmpStr.isEmpty()) {
ani.setAlpha(Integer.parseInt(partAttrElmnt.getAttribute("a")));
}
}
partAttrList = partElmt.getElementsByTagName("rotation");
if (partAttrList.getLength() != 0)
{
partAttrElmnt = (Element)partAttrList.item(0);
if (!partAttrElmnt.getAttribute("angle").isEmpty()) {
if (Util.checkExprTag(partAttrElmnt.getAttribute("angle"))) {
ani.setAngle(Util.removeExprTag(partAttrElmnt.getAttribute("angle")));
} else {
ani.setAngle(Double.parseDouble(partAttrElmnt.getAttribute("angle")));
}
}
}
return ani;
}
}
return obj;
}
Click to expand...
Click to collapse

Categories

Resources