Showing posts with label facebook. Show all posts
Showing posts with label facebook. Show all posts

Saturday, 31 August 2013

Add side menus to an Windows Phone application (similar to the Facebook app)

     It is been a while since my last post, but I have a good reason (on the 20th of July - so tired that the first time I've mistaken the date by one month -  my son Mattia was born and between work and my duties and no sleep there is not much time left for writing on my blog even if I have a lot of posts that I want to do).  
     I will get right to the subject (the title is not one of the best chosen). A few days ago I was talking with my friend Alessandro Scardova about the possibility of implementing side menus inside an Windows Phone application (similar to the ones in the Facebook application). Even if not 100%"Modern UI" design it is a good approach for applications that have multiple options that need to be accessed quickly (also the approach can be applied cross-platform). So I took it as a challange and tried to implement it.
     My initial thought was that I might be able to implement it using an templated panorama or pivot, but after some tests I was not able to get the desired behaviour:


  • when we start the application we will have the selected ViewPort selected
  • swiping left or right we can open/close the side menus
  • also using the buttons on the upper left and on the right corners we can also close and open the side menus
  • the side menus have a width smaller than 480 this way, when opened, we can still see a part of main viewport (including the upper button)
  • when opening the menus the ApplicationBar is not visible
     The solution I have implemented (doesn't use MVVM pattern) it is more a proof of concept on how to implement the functionality. The approach is pretty simple. We have the whole view that we move inside a canvas using manipulations and animations. Initially I thought that I can use only  grid without the canvas and animate the margin of the grid but, as Windows Phone doesn't have ThicknessAnimation, my animations for opening and closing the menus were not very smooth. Also I've tried implementing the swipe behaviour using the Touch.FrameReported event but the results I got were not very good.

     So how does my implementation work:
  • I have a canvas/grid that has a width of 1320 and the height stretches to the whole available height that contains my whole view
  • The view is inserted in a canvas with initial Canvas.Left position set to -420 this way we see the main view port (component)
  • The "stable" positions inside the canvas are:  0: left menu opened, -420: main view and -840:right menu opened
  • When pressing the buttons we will use a resource Storyboard with a  DoubleAnimation to set the the Canvas.Left position inside the canvas to 0,-420 or -840:
  <Canvas.Resources>  
<Storyboard x:Name="moveAnimation">
<DoubleAnimation Duration="0:0:0.2" To="0" Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="LayoutRoot" d:IsOptimized="True" />
</Storyboard>
</Canvas.Resources>

Use the animation to open/close the menus:
  void MoveViewWindow(double left)  
{
_viewMoved = true;
if (left==-420)
ApplicationBar.IsVisible = true;
else
ApplicationBar.IsVisible = false;
((Storyboard)canvas.Resources["moveAnimation"]).SkipToFill();
((DoubleAnimation)((Storyboard)canvas.Resources["moveAnimation"]).Children[0]).To = left;
((Storyboard)canvas.Resources["moveAnimation"]).Begin();
}

  • To implement the swipe I use the ManipulationStarted, ManipulationDelta and ManipulationEnded on the canvas container. On delta we set the Canvas.Left value directly (no need for animations) between a maximum of 0 and a minimum of -840.
  private void canvas_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)  
{
if (e.DeltaManipulation.Translation.X != 0)
Canvas.SetLeft(LayoutRoot, Math.Min(Math.Max(-840, Canvas.GetLeft(LayoutRoot) + e.DeltaManipulation.Translation.X), 0));
}

  • when swiping we also memorize the initial Canvas.Left position. If substracting the final Canvas.Left and the initial one the absolute value is lower then 100 (not a long swipe) we bounce back to the initial position. Otherwise we move to the next position.
  private void canvas_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)  
{
var left = Canvas.GetLeft(LayoutRoot);
if (_viewMoved)
return;
if (Math.Abs(initialPosition - left) < 100)
{
//bouncing back
MoveViewWindow(initialPosition);
return;
}
//change of state
if (initialPosition - left > 0)
{
//slide to the left
if (initialPosition > -420)
MoveViewWindow(-420);
else
MoveViewWindow(-840);
}
else
{
//slide to the right
if (initialPosition< -420)
MoveViewWindow(-420);
else
MoveViewWindow(0);
}
}


  • _viewMoved is used to see if the view was already moved by another event since our manipulation started (like a button was pressed)
   Here are some screenshots from the sample that you can download and play with:

   Hope you will find it useful.

Here is the SOURCE CODE

NAMASTE!

Tuesday, 16 April 2013

3 ways to force the WebBrowser control to logout from Facebook

     Decided to write this post because it took me some time to find the answer. Maybe you already know that if you use OAuth Facebook connect inside your Windows Phone application there is one step where you use the WebBrowser control to let the user authenticate on the Facebook server and authorize your app. The "problem" presents itself when you want to link another user because the WebBrowser control has already memorized the old credentials and will automatically use them. What needs to be done is to logout the old user from the WebBrowser without actually telling the user to go on the web page and click logout. I have found 3 easy ways to do that: the first two will work on both Windows Phone 7.x and Windows Phone 8 and are Facebook specific and the third one will only work on Windows Phone 8 (generic method for OAuth providers). The 3 methods can use the WebBrowser control headless (you don't actually have to show the WebBrowser control to the user and don't even have to have the webbrowser attached to a Page):  

Method 1: described by Rene Schulte in this blog post  
The method constructs the logout Uri using your AppId and a SessionKey that is obtained from the AccessToken you got when the user authenticated.

Get the SessionKey:
  private static string ExtractSessionKeyFromAccessToken(string accessToken)  
{
if (!String.IsNullOrEmpty(accessToken))
{
var parts = accessToken.Split('|');
if (parts.Length > 2)
{
return parts[1];
}
}
return String.Empty;
}

Obtain the logout Uri:
  public Uri GetLogoutUri(FacebookCredentials credentials)  
{
var sessionkey = ExtractSessionKeyFromAccessToken(credentials.AccessToken);
var url = String.Format("http://facebook.com/logout.php?app_key={0}&session_key={1}&next={2}", EndpointData.FacebookAppId, sessionkey, EndpointData.FacebookLogoutCallbackUrl);
return new Uri(url);
}

Make the WebBrowser navigate to the logout Uri:
 Browser.Navigate(FacebookService.GetLogoutUri(EndpointData.Settings.Facebook));  

Method 2:
If for some reason you don't have the Facebook AppId available (my case) you can use the WebBrowser to navigate to the Logout page https://www.facebook.com/logout.php and after the page gets loaded you just execute the script document.forms['logout_form']:
 wb.LoadCompleted += wb_LoadCompleted;  
wb.Navigate(new Uri("https://www.facebook.com/logout.php"));
Once the page gets loaded:
 void wb_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)  
{
wb.LoadCompleted -= wb_LoadCompleted;
if (wb.SaveToString().Contains("logout_form"))
wb.InvokeScript("eval", "document.forms['logout_form'].submit();");
}

Method 3:
This is the easiest one, but will only work on Windows Phone 8: call the new WebBrowser async method ClearCookiesAsync(). This method works for every OAuth provider (Dropbox, Box, Skydrive, Picasa, Flickr, Google Drive... infinite list).

NAMASTE

Thursday, 4 April 2013

Facebook unveils a new home screen for Android devices



It was a big day for Facebook, as Chairman and CEO Mark Zuckerberg, unveiled "Facebook Home," a slick interface for the Android operation system that brings messages, photos and recent stories to the home screen of your Android smartphone.

Smartphone manufacturer HTC also announced the HTC First, the first device to have the Facebook Home interface incorporated into the Android OS. It'll also come pre-loaded with Instagram, which is another popular photo-sharing service owned by Facebook that utilizes a twist of photo filters for cool effects.

The Facebook gurus views the home screen as "the soul of your phone" and offers an alternative with Facebook Home, which does not need to open an app to see all your social media connections.

The ingenuity with Home begins with a virtual button at the bottom of your display that shows your face. A simple swipe up and it shows all your regular apps or you can swipe it away to hide them all.



Then the beauty of the Home interface shines with a feature called "Chat Heads," which allows messages you receive to pop up over any application currently running. A conversation can be held with your Facebook friends on top of – let's say – while using the Internet browser. The chats can be dragged around the screen and when you're done, just tap and they're gone.



Another unique feature of the Home overlay is that some of this social media interaction can go on while the phone is still locked by using called Cover Feed. This feature will allow a steady stream of photos, likes, comments and status updates from your newsfeed.

The new features will be available on April 12 on the HTC First, a 4G LTE device that will come in red, baby blue, white and black. It'll be available exclusively from AT&T for $99.99 and is now available for pre-order.

Several other Android smartphone with the latest version of the Facebook and Messenger apps will also be Home friendly. They include the HTC One, One X, One X Plus, Samsung Galaxy S3, Note 2 and the S4 when it is launched. Android tablets will come on board later, but there is not indication of when Home will play with iOS devices.

Facebook sees their new Home interface as a way to flip the smartphone home-screen experience from being designed around apps to being designed around people.

We'll have to wait and see if their latest creation gets any "Likes" from its one billion users.

Visit us on Facebook | Follow on Twitter | Send an email

Friday, 29 March 2013

Is a smartphone the next milestone for social media giant Facebook?

The big question is whether Facebook, the king of social media, will unveil a smartphone during an April 4 shindig? Will it also be powered by Android, the king of mobile operating systems.

The invitations have been sent out and all eyes are on Facebook's headquarters in Menlo Park, Calif., where attendees will find 1 Hacker Way and get inside by 10 a.m. PST to see Facebook's "New Home on Android" announcement.

From the day Facebook was founded in 2004, they have reached one milestone after another, such as adding photo uploading in 2005, launching music listening applications in 2011 and taking the big, big step of going public in the fall of 2012.

A lot of fans must have been thrilled with their growth, as Facebook reached one billion users in September. That a lot of updates, photos albums, music apps, messages, likes and just overall spending a bunch of time on Facebook.

If a Facebook-branded smartphone does come true, I wonder how Facebook will make it unique from all the other iPhones, Androids, Windows 8 and BlackBerry devices.

I imagine the smartphone market is pretty saturated now, because everyone I know already has a mobile phone of some flavor, whether smartphone or feature phone. Then we have those contract things that make us pretty loyal to one particular carrier for a couple of years.

But who is to say there is not room in the market for a Facebook device, or to speculate further, a HTC device running Android that been tweaked by the Facebook team.

So I say bring it on. We'll be checking our Facebook pages for new friends and updates while watching to see if the social media giant can deliver something really special, whether it's a phone or something else.

Visit us on Facebook | Follow on Twitter | Video: Parade of Smartphones

Wednesday, 30 January 2013

BlackBerry comes out swinging with Z10 and Q10 smartphones



The new BlackBerry Z10 and BlackBerry Q10 smartphones were officially announced today as the company's first smartphones powered by QNX technology, which has also been used in the BlackBerry PlayBook tablet, as well as in the auto and health care industry.

The BlackBerry Z10 is the touchscreen device with a textured surface, a slight curve on the back and a 4.2-inch display. It also has a 1.5 gigahertz dual-core processor, 2 gigabytes of RAM and 16 GB of internal storage, with an expandable memory slot and micro HDMI out port. Near Field Communication, or NFC, is included to support the emerging mobile payments technology.

The BlackBerry Q10 comes with a physical QWERTY, Bold-style keyboard that has been so popular with BlackBerry fans over the years. It has the same specifications as the Z10, along with a glass-weave cover that is pitched as being stronger than plastic.

Both devices will come in white and black and have a removable battery.

BlackBerry fans will find many new features, such as the BlackBerry Hub and BlackBerry Balance. The latter allows users to balance their work and personal information.

There are 70,000 applications available, including popular apps like Skype, and Amazon Kindle. In the social media arena, Facebook, Twitter, Foursquare and LinkedIn are on board.

The new BlackBerry 10 devices will be available in the U.S. on AT&T, Sprint, Verizon Wireless and T-Mobile. In statements released by AT&T and Verizon, plans to offer the BlackBerry Z10 are in place and fans can sign up to "be among the first to know when it arrives." Sprint has released plans to carry the BlackBerry Q10 later this year..

According to BlackBerry, there are around 650 carriers that are considered to be partners in the launch of the BlackBerry 10 platform.

Bell and Rogers Communications, who are both Canadian communications and media companies, announced plans to offer the new BlackBerry Z10, Rogers will offer the device on February 5 at $149.99 with select three-year plans. Bell is taking pre-orders and also will launch on Bell Mobility on February 5. Virgin Mobile Canada is also planning a February 5 launch of the BlackBerry Z10.

The carriers in the United Kingdom should see availability before everyone else, with devices ready for purchase tomorrow on all their carriers, such as O2, Vodafone, Phones 4u, BT, 3UK and the Carphone Warehouse. EE, a digital communications company in the UK, will launch the BlackBerry Z10 for £49.99 ($67.82 US) on a £41 ($55.52 US) per month on a 24 month package. Pricing for the U.S. debut of the new phones have not been set and will likely come from the individual carriers. According to BlackBerry, the Z10 will available around March.

In other surprise announcements, Research In Motion, or RIM, will be re-branded as BlackBerry. The company says it will adopt the name of its revolutionary BlackBerry smartphone to coincide with the launch of its new mobile computing platform. The company’s website, www.rim.com, has changed to www.blackberry.com

"From today on, we are BlackBerry everywhere in the world, " said BlackBerry President and CEO Thorsten Heins.

Heins also announced Alicia Keys as the new Global Creative Director. Keys is pitched by BlackBerry as a 14-time Grammy Award winning singer, songwriter and entrepreneur.

Heins said Keys is an original BlackBerry power user who believes in the product and will lead an array of business initiatives to drive engagement and perception of the brand.

Keys is expected to work closely with developers, carriers and entertainers to enhance the BlackBerry 10 platform.

Visit us on Facebook | Follow on Twitter | Send an email | View Photo Galleries

Click to become a LifeFlicksTech member

Thursday, 4 October 2012

Facebook gets a 'Like' from one billion users; offers 'thanks' to us all

Facebook reaches one billion users
Facebook's announcement of reaching one billion users each month was the biggest "like" of their existence.

This was big enough for CEO Mark Zuckerberg to sign his name at the top of the news release. He wanted to give a big "thank you for giving me and my little team the honor of serving you."

I say "well done" to Zuckerberg for having the vision and innovation to make Facebook what it is today. But the toughest part is probably still yet to come, as Facebook is now a public company and expectations are even higher when you're dealing with financial performance.

This kind of growth is not bad for a company that has only been around since 2004. One of their competitors, Linkedin, officially launched a year earlier in May 2003 and they've only managed to attract around 175 million users.

Another competitor in the social media space, MySpace, also launched in 2003 and I hear they're trying to make a comeback after being acquired by Specific Media in June 2011. Twitter — another social media outfit that I like a lot — unveiled their sign in 2006 in the city with the Golden Gate Bridge. Around six years later, I've seen published numbers of 90 to 175 million registered users who say what they want to say in 140 characters or less. If you're looking at total Twitter accounts, the number is estimated to be even higher at around 500 million.

The youngest of the social media bunch — Google+ — is probably the closest challenger to Facebook with around 250 million users since 2011. According to Facebook, they hit 100 million users in August 2008, which is four years after they started up. If you grab a calculator and start pecking around, Google+'s growth rate is on the fast track, but not likely to catch up with Facebook no time soon.

This kind of success makes you wonder what is it about Facebook that causes us to sign on the first thing in the morning, check out mobile devices throughout the day and switch to a new window on the desktop computer when the boss is not looking. Then we run straight home after work home and get on the home computer to check Facebook again and again until after midnight. One billion people just can't get enough of Facebook.

Facebook released a few demographics along with the bragging rights to "one billion users" that give a little insight into what a typical Facebook users might look like.

The typical age was around 26 in the early years and has progressively gotten younger along the way. All of you Facebook buffs have given out 1.13 trillion "likes' since Facebook added the feature in February 2009. The "like button" was acquired from Facebook's acquisition of social networking site FriendFeed during that same year.

When the ability to upload a photo into Facebook was added in the fall of 2006, we all thought that was just grand and have since uploaded around 265 million photos of people, places and things from Brazil, India, Indonesia, Mexico, the United States and other countries.

So Facebook is certainly on its way to being a fairy tale of a company, if it can figure out the Wall Street part and make enough money to gather 'likes" from investors. Since the initial public offering, or IPO, on May 18 when the stock closed at $38.23, it hasn't seen that kind of a price since and remains down about 40 percent for the year.

But despite the stock woes, having one billion users is quite impressive and Facebook's Zuckerberg says it is simply "the things that connect us."

Although I've been hanging out on Google+ more with all the tech fanatics that seem to gather there, I guess I'll go check my Facebook page now.

Visit us on Facebook | Follow on Twitter | Send an email | View Photo Galleries

Monday, 24 September 2012

iPhone 5 replaces my longtime buddy, the iPhone 3G

iPhone 5 and iPhone 3G
I joined the five million or more customers buying the iPhone 5 over the weekend. My longtime buddy since 2008, the iPhone 3G, has found a nice spot on the shelf. May it rest in peace as it gathers dust.

My 3G would no longer power off and I couldn't do a reset. The battery was about shot and the back panel was cracked. It would mysteriously make phone calls on its own accord to the person you last had a conversation with. The list of odd behavior goes on and on.

It was time for an upgrade a few years ago, but I was determined to hold out as each new iPhone model was unveiled. I skipped the iPhone 3GS because it looked just like my 3G. I skipped the iPhone 4 because of the antenna flap. Then I skipped the 4S because it looked just the 4.

So the iPhone 5, although it's similar in design to the 4S, got my nod for having a larger 4-inch display, being thinner and lighter, while also being a lot faster with the A6 processor, compared with the 412mHz processor in my 3G. Throw in the eight megapixel iSight camera and the 4G LTE service and I'm the kid in the candy store.

The other determining factor is that the iPhone 5 was just a good deal for me. I paid the exact same amount of $199 for the 3G when it was released in 2008 as I did iPhone 5. But the 3G had eight megabytes of memory and the iPhone 5has 16MB. Apple began offering twice the capacity for the same price with the iPhone 3GS in June 2009 with 16GB model for just $199 and they also unveiled a new 32GB model for $299.

Now, it's great to check Twitter and Facebook with the built-in social networks integration while also exploring all the 200 new features in iOS 6. With the increased speed of the iPhone 5, most apps or Web pages now open between a walk from the couch to the refrigerator.

I did splurge on a protective case, but might not need a screen protector, thanks to the "fingerprint-resistant oleophobic coating" on the iPhone 5's display, which also combines the screen and touch sensors layer into one piece for a thinner profile. But I shouldn't be cheap and will probably purchase a screen protector when more choices are available the store shelves for the iPhone 5.

The big fuss about the smaller Lightning connector to replace the longtime 30-pin connector has not bothered me at all. I think we'll see the benefit of this change when the new accessories start to hit the market, such as docks and other devices. I also wouldn't be surprised if the logic behind moving the headphone port to the bottom also makes sense later. I have a hunch the audio port will be utilized in the new products when the iPhone 5 is docked.

I did experience the "rattle inside" that early buyers have been discussing in the Apple Support Communities' forum. But a trip to the Apple Store and the Genius Bar solved the problem. I'm rattle free now.

The Passbook app also needed some tweaking, as it wouldn't connect to the iTunes store. But after a bit of research, I discovered some steps that also got me on my way with the Target and Walgreens discounts apps in Passbook. The participating retailers worth a download will vary by your location and I imagine more will be added soon.

The Apple support forums are full of other concerns and issues about the iPhone 5, but they seem to vary from device to device and not all customers have the same experience. If you're researching a problem, the support forums would be a good place to start before heading back to the retailer. There might a trend among concerns and issues that Apple will need to address.

I think I made a good choice and I'm a happy camper so far.

Visit us on Facebook | Follow on Twitter | Send an email | View Photo Galleries

Click to become a LifeFlicksTech member

Sunday, 20 May 2012

Facebook arrives on Wall Street looking for a 'Like'


Now that we know Facebook has a market value of $104 billion, the next sixty-four thousand question for some of us will be should I buy stock.

If you can answer that question successful, in several years you could be very rich. Or you could be the Facebook fan who lost their shirt.

If you're thinking about it, maybe a closer look at this fairy-tale company will help sway your mind. There is a lot behind the simple "Like" button and your updates.

Facebook has been around since 2004, when it was founded by current CEO Mark Zuckerberg, along with a few other Harvard University technology wizards.

Who would have known that Zuckerberg, now a newlywed as of Saturday, would grow Facebook into one of the world's top social networking websites, which has around 11 offices in the United States, with main digs being in Menlo Park Calif., and 18 or more offices scattered around the globe.

You'll probably be surprised to find out, that according to Facebook's website, 80% of monthly users are outside of the U.S. and Canada. So maybe that's why they need almost twice as many international offices as they have U.S. offices and felt compelled to make Facebook available in more than 70 languages.

So if Zuckerberg wanted to brag, he could go on for hours about how he started in a dormitory room and now runs a company worth a lot of billions. But according to Zuckerberg, he just simply wants to "make the world more open and connected."

But there is another sixty-four thousand question looming that has to do with whether Facebook can be montetized going forward to satisfy the investors appetite for profits. Now Facebook will have face the heat when monthly, quarterly and annual financial reports come around.

I imagine, like all other Internet-based companies, Facebook will rely on advertising and maybe – are your ready – user fees at some point. The latter is my thinking only, but with the emerging trend of paying for digital content, I wouldn't put it out of the question.

If Facebook ask us to reach for our wallets at some point, I imagine some of the 901 million fans would scatter to other social networks or suddenly decide that updating your status for all to see is not as crucial as it once was.

I don't update my own timeline enough, but I like what others are doing with their updates, the 300 million photos that are uploaded daily and other social aspects of their lives. It's very entertaining.

Facebook is likely to continue to grow by snapping up innovative companies like Instagram, a photo-sharing service and most recently, Karma, which is built around notification of important events and instant gifts.

At this point, I'm bullish on Facebook, with is easy for me to say, since I'm not an investor or shareholder and passed on any of the 180,000,000 shares of stock that Facebook was offering. But they had a decent opening day on Friday and finished slightly up at $38.23 rather than down from their initial offering price of $38.

Everyone will be watching what happens today, the rest of this week, and the months and years ahead.

The pressure is on for Facebook.