Thursday, March 31, 2016

Android Implementing searching

Android provides either a search Dialog that appears on top of the activity window or a search widget that one can insert in the layout. Both search dialog and search widget can deliver the user’s search query to a specific activity in the application. Some of the features readily available in the search dialog and widget include Voice search, Search suggestions and recent queries, search suggestions that matches actual result in the application data. 

Search dialog UI appears on top of the activity upon activating it. this component can also deliver search suggestions. 
Search widget is an instance of SearchView that can be placed anywhere in the app layout. 

When user executes a search from the search dialog or search widget, the system creates an Intent and stores the user query in it. The system then starts the activity that application has declared to handle the searches and delivers the Intent. Below are the items required to set up application as assisted search. 

A searchable configuration: An XML file that configures some settings for the search dialog or widget. It includes settings for features such as voice search, search suggestion and hint text for the search box. 

A searchable Activity : The Activity that receives search query. Searches the data and displays the search results. 

A search interface, provided by either 
- The search dialog -> Search dialog is hidden by default, and it appears when calling onSearchRequested. 
- A SearchView widget -> allows to put a search view anywhere in the activity. 

For creating search configuration, app needs to have searchable.xml under res/xml folder. Below is the XML for searchable configuration

?xml version="1.0" encoding="utf-8"?
searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_label"
android:hint="@string/search_hint" 
/searchable

label is the only required attribute, which should be attribute name. The label is shown only when user activate the searchable suggestions. 

A searchable Activity can be created by declaring searchable activity in the manifest file. After doing this, whenever user searches within a dialog or search widget, the system starts the application searchable activity and delivers the search query in an Intnet with ACTION_SEARCH. The intent has Query extra using which the data can be retrieved. Below is how we can declare the activity as a searchable one

application ... 
activity android:name=".SearchableActivity" 
intent-filter
action android:name="android.intent.action.SEARCH"
/intent-filter
meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"
/activity
...
/application


references:

What is firebase?

This is a service to provide apps backend including data storage, user authentication, static hosting etc.


Firebase stores the data in JSON format and synchronises the data between apps in multiple platforms.
Based on the volume of users in the app, it automatically scales up. Data is transferred over a secure SSL connection with a 2048 bit certificate. Database access and validation is controlled at a granular level using flexible security language. All of the data security logic is centralized in one place making it easy to update and verify.

A firebase app will remain responsive regardless of network latency or internet connectivity. All writes to firebase will trigger local events immediately, before any data has been written to the server. Once connectivity is re-established, the client will receive any changes missed, synchronizing to the current server state.

Firebase abstracts the authentication functionality. The firebase has built in functionality for authenticating users with email, password, Facebook, twitter. Also can authenticate with the existing backend with the authentication tokens.


firebase can deploy the web apps in seconds with production grade static asset hosting. This provides features such as rolling back to the previous version within very less time. Every app gets the firebaseapp.com domain and paid app gets the custom domain. and paid apps can deploy to a custom domain.

references:
https://www.firebase.com/

Android Custom Compound Views

The intention is to create a compound view which actually displays a background image with 2 buttons 

This is accomplished by writing a class and subclassing it with Layout class and loading the layout xml with layout inflator.
like below. 


public class WeatherView extends LinearLayout {
    private View mValue;
    private ImageView mImage;
    
    public WeatherView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setOrientation(LinearLayout.HORIZONTAL);
        setGravity(Gravity.CENTER_VERTICAL);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.weather_view_layout, this, true);
    }
    
    public WeatherView(Context context) {
        this(context, null);
    }
    
}

The complete files with layout XML, layout subclass and Activity layout xml can be downloaded from https://drive.google.com/file/d/0B0ZgwdHsnw1baTBuNngtdGk5Rnc/view?usp=sharing


references

Wednesday, March 30, 2016

Angular JS Two way data binding

In this step, application will control the order in which the items are listed. Dynamic ordering is implemented by creating new model property, wiring it with the repeater, and letting the data binging magic do the rest of the work. 

w.r.to UI, application now also displays a drop down box which lets the user control the order in which the items are listed. 

template looks like the below 

Search : input ng-model=“query”
Sort By: 
select ng-model=“orderProp”
option value=“name” Alphabetical /option
option value=“age” Newest /option
select 

ul class=“phones” 
li ng-repeat=“phone in phones| filter:query | orderBy:orderProp”
span {{phone.name}} /span
span {{phone.snippet}} /span

/li
/ul

Angular creates data binding between the select element and the orderProp model. orderProp is then used as input for orderBy filter. 

below is how the controller looks like 

var phonecatApp = angular.module(‘phonecatApp’,[]);

phonecatApp.controller = (‘phoneListControl’, function($scope)
{
$scope.phones = [
{‘name’ : ‘Nexus S’, ‘snippet’ : ‘Fast got furious’ , ‘age’ : 1},
{‘name’ : ‘MOto S’, ‘snippet’ : ‘Fast got furious Moto’ , ‘age’ : 2},
{‘name’ : ‘Droid S’, ‘snippet’ : ‘Fast got furious Droid’ , ‘age’ : 3},

];
$scope.orderProp = ‘age’;
}

Notice that when the app is loaded in the browser, "Newest" is selected in the drop down menu. This is because we set orderProp to 'age' in the controller. So the binding works in the direction from our model to the UI. Now if you select "Alphabetically" in the drop down menu, the model will be updated as well and the phones will be reordered. That is the data-binding doing its job in the opposite direction — from the UI to the model.

References:

Tuesday, March 29, 2016

iOS App with Swift crashes due to Certificate issue


Below was what the crash report indicated. 

[deny-mmap] mapped file has no team identifier and is not a platform binary: /private/var/mobile/Containers/Bundle/Application/B7B2BE25-BEE1-4DD0-B6BD-2BF4E4932862/TestApp.app/Frameworks/libswiftCore.dylib

 We found origins that caused this issue, related to a missing attribute in “Subject” field InHouse Certificates :
    It was
Subject: UID=269J2W3P2L, CN=iPhone Distribution: Company Name, O=Company Name, C=FR
    And now we can find a OU field in new certificates :
    

Subject: UID=269J2W3P2L, CN=iPhone Distribution: Company Name, OU=269J2W3P2L, O=Company Name, C=FR

The OU, which stands for organizational unit should be mandatorily present in the certificate it appears.

references:
https://www.airsignapp.com/ios-apps-using-swift-crash-when-signed-with-inhouse-certificate/

JavaPNS bug with 2KB payload

Starting iOS 8.0, Apple supports 2048 bytes of payload. Inorder to utilize it, application side we don’t need to make any changes, however, from the server side, if using JavaPNS library, we will have to update it to the latest versions 2.2 or 2.3 which claims to have raised that bar. However, in experience, it appeared that it is plagued by the Issue which gives exception like below 


Looking at the github source code, it appeared that the application still hardcodes the payload size to 256 and this can be found in the code PushNotificationPayload.java. 
Just changed that to 2048 and recompiled using the below, gave the latest code base and good to go to push lengthier messages! 

javac -cp .:bcprov-jdk15-146.jar:log4j-1.2.15.jar javapns/*.java javapns/communication/*.java javapns/communication/exceptions/*.java javapns/devices/*.java javapns/devices/implementations/basic/*.java  javapns/devices/exceptions/*.java javapns/feedback/*.java  javapns/notification/*.java javapns/notification/exceptions/*.java javapns/notification/management/*.java javapns/notification/transmission/*.java javapns/test/*.java

references

Angular JS - filtering repeaters

This section intended to showcase the full text search capability. In this example, the team made the controller untouched. 
the view is changed like this below 

div class=“container-fluid“
div class=“row”
div class=“col-md2”
Search : input ng-model=query
/div
div class=“col-md-0”
ul class=“phones”
li ng-repeat=“phone in phones | filter:query”
{{phone.name}}
p {{phone.snippet}}

The change here was that we added a standard input tag and also an angular filter function to process the input for the ng-repeat directive. 

Below are the items it tries to demonstrate by this

Data Binding: When the page loads, the Angular binds the name of the input field to a variable of same name in the data model and keeps both in sync

In this code, the data that user types into the input box is immediately available as filter input in the list repeater. When changes to the data model cause the repeater’s input to change, the repeater efficiently updates the DOM to reflect the current state of the model. 

Use of filter filter. The filter function uses the query value to create a new array that contains only those records that matches the query.  ngRepeat automatically updates the view in response to the changing number of phones returned by the filter filter. The process is completely transparent to the developer. 


references: