Delphi XE7中使用Moto 360

本文详细介绍了如何利用Delphi XE7为Moto360手表设计应用程序,包括自定义视图设计、设备信息配置、蓝牙调试设置等关键步骤,以及提供了一个完整的代码包和示例应用。文章还涵盖了Moto360的屏幕特性、部署挑战和解决方法,旨在帮助开发者高效地为智能手表开发应用。

Hello Moto 360 from Delphi XE7(翻译版)

http://delphi.org/2014/09/hello-moto-360-from-delphi-xe7/

Moto 360

    我真的很喜欢我的Moto 360手表。它看起来很棒,也很为我的Android手机的一种延伸,当然最重要的问题是如何使一个应用程序。仅使用RAD Studio X7,Delphi或C + +来设计app。由于新FireUI多设备设计我可以创建UI的自定义视图做出完美的用户界面设计的微风。这里有一些我制作APP的细节,其次是下载我的样品和自定义视图。

    底线是,它只是工作,这真的不是一个惊喜。最新的Android设备使用ARMv7和NEON指令集。(NEON是一种类似于英特尔平台上的多媒体标准。首先不是每个人都使用这些指令,但一旦他们用了,大家也就都这样做了。)因此,Moto 360也不奇怪。不像一些其他的手表,Moto 360没有微型USB端口。所以你必须使用ADB蓝牙。这需要一些额外的步骤来安装,真是缓慢的部署在。所以我取消了第一个部署缓慢,因为我以为我把某些东西错了。

    首先,Moto 360显示并不完全是圆的。 它的底部有一个平坦的区域。如果你仔细看,你可以看到光线感应器有。不知道这是为什么它不是圆的,或如果有一个设计的原因。在任何情况下,屏幕的分辨率为320 x 290像素每英寸213像素。这意味着在设计的时候你有一个使用面积240 x 218像素。这是我们需要创建一个自定义视图的信息。把下面的代码包中。
1
2
3
4
5
TDeviceinfo . AddDevice(TDeviceinfo . TDeviceClass . Tablet, ViewName,
   // The Moto360 is 320x290 phyiscal and 240x218 logical with 213 PPI
   TSize . Create( 320 , 290 ), TSize . Create( 240 , 218 ),
   TOSVersion . TPlatform . pfAndroid, 213 ,
   True ); // Exclusive

设备CLASS枚举实际上有一个手表类,但在检测类在运行时的代码,它不知道如何检测手表呢。所以它默认为平板电脑。XE7是在Moto 360发布之前发行的,我想象一个更新将解决这个问题。

获取自定义视图显示在IDE的要求是你需要更新在%APPDATA%Roaming \Embarcadero\ BDS\ 15.0 \ mobiledevices.xml参考的新视角。在移动设备元件,添加以下:

1
2
3
4
5
6
7
8
9
10
< MobileDevice >
   < Displayname >Moto360</ Displayname >
   < Name >Moto360</ Name >
   < DevicePlatform >3</ DevicePlatform >
   < FormFactor >2</ FormFactor >
   < Portrait Enabled = "True" Width = "240" Height = "218" Top = "102" Left = "29" StatusbarHeight = "0" StatusBarPos = "0" Artwork = "C:\Users\jim\Documents\Embarcadero\Studio\Projects\HelloMoto360\Moto360.png" />
   < UpsideDown Enabled = "False" Width = "240" Height = "218" Top = "0" Left = "0" StatusbarHeight = "0" StatusBarPos = "0" Artwork = "" />
   < LandscapeLeft Enabled = "False" Width = "240" Height = "218" Top = "0" Left = "0" StatusbarHeight = "0" StatusBarPos = "0" Artwork = "" />
   < LandscapeRight Enabled = "False" Width = "240" Height = "218" Top = "0" Left = "0" StatusbarHeight = "0" StatusBarPos = "0" Artwork = "" />
</ MobileDevice >

    你需要更新路径,作品点到您的系统上的PNG的正确位置。或者你可以只留下空白。这里是什么,它都像当安装在IDE。Hello Moto 360 in the XE7 IDE

    你会注意到设计图面上的红圈。我又看到哪里的角落(因为显示是圆的)。在运行时,你仅仅能看到红色的如果你拿着看吧。我会隐藏在生产运行时。我把文本外框- 1,- 1,设置大小为242 x 242。这样的循环遵循圆而不是屏幕显示区域。 

  1. 让Moto 360显示为目标设备,你首先需要启用蓝牙调试。

     

    1.将侧键按下直到出现设置窗口,向下滑动,点击它。

     

  1. Hold the side button in until Settings appears
  2. Swipe down to About and tap it.
  3. Tap on build number until it tells you that you are a developer.
  4. Swipe back to settings and then tap on Developer options.
  5. Tap on ADB Debugging until it says Enabled.
  6. Tap on Debug over Bluetooth until it says Enabled.
  7. On your paired phone, go into Android Wear settings (gears in the upper right)
  8. Enable Debugging over Bluetooth.
    1. It should show
      • Host: disconnected
      • Target: connected
    2. Target is the watch, Host is your computer.

Then you connect your phone that is connected to the Moto 360 via USB and run the following commands (assuming ADB is on your system path) to connect via Bluetooth. I made a batch file.

 @echo off
 REM optional cleaning up
 adb disconnect localhost:4444
 adb -d forward --remove-all
 REM this is the connection
 adb -d forward tcp:4444 localabstract:/adb-hub
 adb -d connect localhost:4444
 REM these lines are to see if it worked
 echo Here is the forwarded ports . . . .
 adb forward --list
 echo.
 echo Wait a second for it to connect . . . .
 pause
 adb devices

The ADB Devices list should show something like

List of devices attached 
123456abcd device 
localhost:4444 device

Now the Android Wear app on your phone should show

  • Host: connected
  • Target: connected

Be sure that your Moto 360 app uses the unit that defines the Moto 360 device (from your package). This way your app can select it at runtime. If you do all that, you’ll see something similar to this with it running on the Moto 360:

Hello Moto 360 from Delphi XE7

My camera had a hard time focusing on it, but rest assured it looks fabulous! I tried C++ too, and no surprises, it works as well. More experimenting to do, but it is nice to know I have a tool that will take me everywhere I want to go.

If you don’t have a Moto 360, you can setup an Android emulator (AVD) instead. I did that before mine showed up. You need to download the Android 4.4W (API20) SDK Platform and ARM System image.

Android Wear SDK Download

Then create an AVD with the new Emulator.

Android Wear AVD Settings

It actually gives you the rectangle screen with a round bezel. Also it is 320 x 320 (so completely round) and 240 PPI. This means the view I created (since it was exclusive) won’t work on the emulator. You’ll need to create a new custom view for the emulator, but I’ll leave that up to to.

you can download all of my code for the custom view, Bluetooth ADB batch file, and sample apps from Github. (Update: Added a view for Galaxy Gear Live & LG-G) BTW, XE7 adds local Git support, which is another great new featureDownload the trial and check it out.

转载于:https://www.cnblogs.com/HuiLove/p/4518887.html

制作固定大小的Form   固定的Form像一个对话框,何不试试下面的语句   巧用Delphi制作溅射屏幕   精心编写的WINDOWS程序显示启动注意事项,称之为溅射屏幕(splash screen)。利用一点儿小小的内容,即可给程序的显示添加不少色彩   LED数码管仿真显示程序   在电子设备上广泛地使用LED数码管显示数据,在许多应用软件中也经常模拟LED数码管显示数据,使程序画面看起来很有特色   菜单设计   DELPHI中自适应表单的实现   我们知道,屏幕分辨率的设置影响着表单布局,假设你的机器上屏幕分辨率是800*600,而最终要分发应用的机器分辨率为640*480,或1024*768,这样你原先设计的表单在新机器上势必会走样   作非常规程序菜单掌握delphi高级秘籍   大家可能见过诸如金山毒霸,瑞星杀毒,以及五笔输入法等等在系统托盘(即右下角有时间和输入法图标的地方)在的控制菜单,而在正常的任务栏(即屏幕最下方的“开始”按钮的右边的各式各样)中却不出现按钮的程序,即我们常说的在后台运行的程序   用Delphi制作动态菜单   所谓动态菜单是指菜单项随着程序的操作变化而变化。现在,我们用Delphi来实现这一功能,具体步骤如下   工具栏和状态条   为Windows窗口标题栏添加新按钮   对于我们熟悉的标准windows窗口来讲,标题栏上一般包含有3个按钮,即最大化按钮,最小化按钮和关闭按钮。你想不想在Windows的窗口标题栏上添加一个新的自定义按钮   用Delphi4实现风Word97格的工具栏   用过Word97的人对它的工具栏印象很深刻,因为它的风格很“酷”,同样IE4.0的工具栏也有类似的风格,Win98的出现,使这种风格的工具栏得到了推广   如何隐藏和显示Windows的任务条   如果隐藏和显示Windows的任务条?仅仅调用以下的函数就可以.   其他技巧   Delphi利用Windows GDI实现文字倾斜   在Delphi开发环境中,文字的输出效果一般都是头上脚下的"正统"字符,如何输出带有一定倾斜角度的文字以达到特殊的显示效果呢   Delphi之三十六计之界面篇   设置状态栏面板对象的Style为OwnerDraw,并在状态栏对象的DrawPanel事件中书写以下代码   利用COM技术实现外壳扩展的属性页   当用户在资源管理器中调用右键菜单时,会显示一个"属性"菜单项,点击属性菜单项会显示一个属性页,用户可以获得甚至修改文件信息
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值