Handle configuration change through Build Gradle

As we know our Activities are currently blocked in Portrait mode only,
and we are planning to unblock or authorise other screen configs later , as we
expect to implement more features in coming month we should expect moreActivities as well , 
some of them may stay in Portrait mode and some others indefault mode , 
so It will be hard to manage screenOrientation for Activities within manifest one by one, so I move screen orientation config
from manifest to Gradle , as below:

Step 1:

For all Activities currently configured in single mode portrait in stead of 
we just replace it by:  

For example in manifest we have:


android:theme="@style/theme_app_no_action_bar" />

Step 2:

Then in our defaultConfig in build gradle file we add:

{ manifestPlaceholders = [ screenOrientation:"portrait", configChanges:"orientation"] } 

defaultConfig {
applicationId "org.xxx.yyy.zzz"
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionName project.versionName

//Manage Screen orientation for all Activities
//By default all set to "unspecified" ,
//exceptional cases should be set in manifest.

manifestPlaceholders = [screenOrientation:"portrait",configChanges:"orientation"]

So if we decide to remove lock and authorizing all Activities fro support all orientations, we jus set the default value in Gradle like that:

manifestPlaceholders = [screenOrientation:"unspecified", configChanges:"orientation"]

This way we get control of all Activities from gradle ,  notice it's still possible to declare orientation for individual Activities by classic way (hardcoded)



 © Xosrov 2016