Cordova 微信分享插件 (iOS, WP, Android)

先上 GitHub 链接 https://github.com/vilic/cordova-plugin-wechat

因为词焙需要, 然后现成的没有好用并且平台覆盖全面的, 于是就参考已有的自己写了个.

没有具体去看最低支持到 Cordova 多少, 但 3.x 应该问题不大. PhoneGap 估计也差不多.

支持三大系统, 除了安卓外, 基本不用额外配置, cordova plugin add com.wordsbaking.cordova.wechat –variable APP_ID=[你的AppID] 之后相关配置 (包括 URL Scheme) 都弄好了.

分享的内容只支持文本, 图片和链接. 以后空了再增加其他支持.

安卓需要额外修改一下 plugin.xml, 具体的参见 GitHub 上的说明.

iOS Web Application Directly Using Online URI

Will Apple App Store approve web apps that directly using online URL and resources?

Yes.

When I submitted my app to Apple App Store, I was worrying about a rule that forbidding downloading code in any way or form. And as a web app that downloads its main code only after installation, it does seem to violate this rule. But luckily, it’s finally approved.

Apple App Store http://itunes.apple.com/app/id843170841
See also the Windows Phone version http://www.windowsphone.com/s?appid=a3e70b25-b048-4bef-996f-cc2b30a6eda2

And congrats to myself that WordsBaking is scheduled to be FEATURED in Windows Phone Store (China) tomorrow. 😉

Disable Scroll Bouncing Effect of WebBrowser Control on Windows Phone 8

Just another story happens when developing WordsBaking.

First, the basis. If you don’t have any element in your web page that requires overflow style being auto or scroll, “-ms-touch-action: none;” under “html” selector should work well . Actually it works all the time in Internet Explorer, but in a WebBrowser control, if there’s something like a list for which you may need that style, the solution becomes tricky.

I spent tons of hours and tried tons of ways hoping figure out a solution, and luckily, found one.

That is the good news, but the bad news is, this solution doesn’t seem to be elegant (though it works perfectly so far).

The first thing that I found might be useful is that this bouncing effect happens only when your finger touches the elements that already have their contents at the top/bottom or both. So, the first solution I thought might work was to add a pointerdown (MSPointerDown) event listener on the element, and determine whether its content has reached the top or bottom. Unfortunately, it doesn’t work well.

Later I read about an article shows a solution on suppressing scrolling and zooming in WP7 WebBrowser control, I can’t say that it works (on WP8), but it helps.

Combining these two parts (and this is why I think it’s not elegant enough), here’s the solution:

C# Part

private void mainBrowser_Loaded(object sender, RoutedEventArgs e) {
    // here we are using a library named Linq to Visual Tree.
    // http://www.scottlogic.com/blog/2010/03/04/linq-to-visual-tree.html
    var border = mainBrowser.Descendants().Last() as Border;
    border.ManipulationDelta += border_ManipulationDelta;
    border.ManipulationCompleted += border_ManipulationCompleted;
}

void border_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) {
    mainBrowser.InvokeScript("onmanipulationcompleted");
}

void border_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) {
    var status = mainBrowser.InvokeScript("onmanipulationdelta") as string;
    if (status == "top" || status == "both") {
        if (e.DeltaManipulation.Translation.Y > 0) {
            e.Handled = true;
        }
    }
    if (status == "bottom" || status == "both") {
        if (e.DeltaManipulation.Translation.Y < 0) {
            e.Handled = true;
        }
    }
}

JavaScript Part

window.manipulationTarget = null;

window.onmanipulationdelta = function () {
    if (!window.manipulationTarget) {
        return '';
    }

    var target = window.manipulationTarget;

    var top = target.scrollTop == 0;
    var bottom = target.scrollTop + target.clientHeight == target.scrollHeight;

    return top ? bottom ? 'both' : 'top': bottom ? 'bottom' : '';
};

window.onmanipulationcompleted = function () {
    window.manipulationTarget = null;
};

// and you'll need to make calls to every elements
// with overflow auto or scroll with this:
function preventBouncing(ele) {
    // using jQuery.
    ele.on('MSPointerDown pointerdown', function (e) {
        window.manipulationTarget = this;
    });
}

And good luck fellows~

HowTo: Add Facebook Account on a China Country Variant Lumia

Before we start, there’s something you may need to know:
1. It has to be Windows Phone 8.
2. Twitter account can’t be added this way.
3. When come to flashing ROM, I refer the WCDMA model (for China Unicom).

And the technique here is simple, though not very easy to be done. We’ll need to add the Facebook account somewhere else first, backup the settings and then restore it on the China Country Variant Windows Phone.

I was lucky because I got a Hong Kong CV Lumia 920, so I simply restored the backup data on my new Lumia 1020 and the Facebook account showed up. However for other people who don’t have an older Windows Phone runing WP8, they won’t be able to add that account at the first place. Luckily, we get Vietnam CV Lumias sharing the same models (you can check the RM-xxx code to see if that really matches) as Lumias for Mainland of China. So we can flash the Vietnam ROM and then get Facebook account added.

Actually if you are cool with that Vietnam ROM, you can just get off the bus here and enjoy the social network, or you may want to flash back ROM for China as what I would do.

Some photos here by Lumia 1020.

NOKIA Pro Camera – Auto mode:

WP_20130820_18_37_05_Pro WP_20130820_19_26_27_Pro WP_20130817_18_30_22_Pro

NOKIA Pro Camera – ISO 100 / 0.8 seconds:

WP_20130819_21_02_20_Pro

And a bonus by Lumia 920 (Edited by Fireworks CS6).

1020-small

吐槽下Windows 8, 及其周边

个人来讲, 虽然算不上fan, 还是比较喜欢微软的. 当然因为环境原因, 我也是用着Windows长大的, 最爱的自然是Windows 7.

我是个 “外貌党”. 对外观有特别多的要求, 比如只穿蓝/白两色的衣服/鞋子, 最多能忍受下浅灰色, 但也必须只能是出现在边角. 就连同是蓝色的, 我也常常穿上后发现色调不搭, 比如一个蓝色偏紫, 一个偏绿, 又换下来…

所以即使Linux再好(当然对于我的使用习惯和范围来讲, 它也不是最佳选择), 我也不可能用Linux… UI一项就直接把它刷下去了. 但Windows 7却非常漂亮. 尤其喜欢Aero特效. 如果实在要挑一点美中不足的, 就是Start键的颜色不会随主题颜色变化而变化, 有时候显得有点不协调.

但美的标准显然不止一个, 微软拥有, 至少曾经拥有非常棒的UI设计师, 如果说Aero作为华丽的美征服了我, 那Metro则是因为其简约的美让我着迷.

在第一代WP的尾声, 11年夏天的时候, 入手了我的第一台WP手机, Omnia 7(不过无力吐槽后盖, 为什么要偏棕色!). 当然, 蓝色主题没的说. 再后来, Lumia 800出现, 于是今年年初狠下心购入一台黑色800. 花了两倍于当时买O7的价钱… 但还是爱不释手. 为什么不买蓝色? 因为那个蓝色的色调太飘, 跟我的衣服配不上… (眼睛不那么bitch要死啊…)

所以Windows 7和Windows Phone 7.5, 在我看来是微软在UI上的巅峰作品, 同在这个巅峰上的还有诸如Office 2010, Visual Studio 2010.

当然众所周知的, Windows 8来了, 随之而来的还有Office 2013, Visual Studio 2012, 以及Windows Phone 8. 功能上来讲, Office, VS以及WP应该都算是稳步提升, 特别是Visual Studio 2012的JavaScript智能提示相当做得相当出色. 前面我也提到, 我非常喜欢Metro UI, 但…

Windows 8你能不能抓住当年WP Metro UI的精髓啊!!! 精髓不止是方格子好吧!!!

虽然在Windows 8正式发布后我没有使用过(因为换回Windows 7了), 但之前的Developer Preview, Customer Preview, 以及RTM版本我都是一路用过来的, 也用了比较长的时间. 老实说在我这个没有触屏的笔记本上我没有感觉到多大的便利, 也是长期使用桌面. 可惜的是, 我很常用的开始菜单没有了, 开始菜单上的Jump List自然也就没了(当然任务栏上还有). 那些入门级用户不用开始菜单不代表我们这些相对老练的用户不用好吧微软!!! 当然多数功能还是可以在开始屏幕实现, 但我就想启动个程序, 全屏换过去换过来别不别扭啊!!! 总体来讲, 我觉得易用性下降了.

接下来要吐槽Windows 8的UI了, 去其精华取其糟粕非Windows 8莫属啊! 当年看到微软Tellme的宣传片, 那个平板上的UI多舒服啊! 干嘛要被Windows 8整成这样啊!!! 拿那么多颜色来干嘛啊!!! 眼睛不花啊!!! 我只想要蓝色的Tile啊, 蓝色的啊!!! 而且自带的软件Tile颜色也花花绿绿的啊, 是干什么啊这是!!! 你们UI设计师干嘛去了啊!!! 退一万步说, 即使要弄多点颜色请搭配合理好不啊!!! 全是些奇葩的颜色啊!!! 你妹Tile的背景色还是带渐变的啊!!! Metro你搞神马渐变啊!!! 开始屏幕背景一个二个丑到爆啊!!! 不能给个纯黑的选项啊!!! 给个纯黑的要死啊!!!

另外桌面UI做了调整跟Metro统一, 这个我不反对啊, 关键是能不能稍微用点心, 做得好看点和谐点啊!!! 那个进度条就是个三流水准的设计师做得啊!!! 好多Aero风格的图标一个没换啊!!! 花得了多少时间啊!!!

我是打算坚守在Windows 7上再熬一段时间了,,, 最多装个双系统,,, 为了Windows Phone 8开发. 但是啊!!! Visual Studio 2012那么爽能不能出个2010风格的皮肤啊!!! 虽然2012不丑, 但是跟我的Windows 7不怎么搭啊!!! Office到还将就, 毕竟2010我也够用了.

顺便Windows Phone 8… 开始屏幕可以添加更小的Tile, 这个我觉得挺好的, 但配色能不能不要那么奇葩啊!!! 不过还好没有Windows 8乱. 至少多数Tile还能是同一个颜色. 不过WP7.5那个XBox的绿色Tile颜色多么和谐啊!!! WP8你干嘛要换成那种屎绿色啊!!! 真心觉得8系列都喜欢用屎色啊… 另外WP7开始屏幕右边的黑边很有感觉, WP8没了, 不过这个还算可以理解…

不过还是因为大爱Metro, 虽然Windows 8不准备升, WP8还是准备入的, 淘宝上预定了Lumia 920… 不过能不能出个小点的啊!!! 800那个大小多舒服啊!!! 或者4.0我也能够忍受啊,,, 一下就来个4.5让我情何以堪啊, 还180+g的重量啊!!! 不过看在其他还不错的份上我就忍了…

希望Windows 9团队里能重新出现优秀的UI设计师… 至少要考虑到我们这些有强迫症的人啊… 顺便我强迫症也不是很强迫好嘛…

现在好纠结好纠结, 强迫症的一方面要让我用最新的系统, 一方面要让我用最漂亮的UI,,, 哎… 不过UI最终还是胜了.

吐槽完了.