Developer

MAF Setting Screen

The MAF Setting Screen component provides extensions to the Android standard preferences. Native preference controls can only handle string and Boolean values. MAF controls extend the native preferences by adding float, long, and integer datatype handling, and skinnability functionality.

Dependencies and Project Setup

The MAF Setting Screen control is a complex reusable control, which means it builds on top of simple controls, such as the MAF Dialog and MAF Edit Text. The required MAF Android libraries include:
  • com.sap.mobile.maf.ui.android/MAFSettingScreen
  • com.sap.mobile.maf.ui.android/MAFUIComponents
  • com.sap.mobile.maf.tools.android/MAFLogger

Supported Types in MAF Setting Screens

MAF Setting Screen controls are an extension of android.preference.DialogPreference. MAF adds skinnability functionality to the native controls and stores input values in SharedPreferences based on the component type. MAF also supports string and Boolean types but with skinnability functions. These are the Setting Screen components:
  • com.sap.maf.uicontrols.settingscreen.MAFFloatPreference – shows a dialog with an input field. You can only enter numbers and the . (dot) character. Stores the input value as a float in SharedPreferences.
  • com.sap.maf.uicontrols.settingscreen.MAFIntegerPreference – shows a dialog with an input field. You can only enter numbers. Stores the input value as an integer in SharedPreferences.
  • com.sap.maf.uicontrols.settingscreen.MAFLongPreference – shows a dialog with an input field. You can only enter numbers. Stores the input value as an integer in SharedPreferences.
  • com.sap.maf.uicontrols.settingscreen.MAFStringPreference – shows a dialog with an input field. You can enter any characters. Stores the input value as a string in SharedPreferences.
  • com.sap.maf.uicontrols.settingscreen.MAFBooleanPreference – shows an item in the preference list with a label and a check box. Stores the state of the check box in SharedPreferences as a Boolean value (selected = true, unselected = false).
  • com.sap.maf.uicontrols.settingscreen.MAFListPreference – shows a dialog with a choice list, and stores the selected item in SharedPreferences.
  • com.sap.maf.uicontrols.settingscreen.MAFSecurePreference – shows a dialog with an input field, and stores the input text in the DataVault if the user is registered and connected. If the DataVault is unavailable, the input text is disabled.

Usage of MAF Setting Screen

Use the MAF Setting Screen components in the standard Android preference XML file. This is an example of a preference XML file that uses all Setting Screen components:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:sap="http://sap.com/" >
	
	
	<PreferenceCategory android:title = "Sample Preferences">
	
		<com.sap.maf.uicontrols.settingscreen.MAFIntegerPreference
			android:key = "TestIntegerPref"
			android:title = "Test Integer Preferences"
			android:defaultValue = "100"					
		/>
		
		
		<com.sap.maf.uicontrols.settingscreen.MAFFloatPreference
			android:key = "TestFloatPref"
			android:title = "Test Float Preferences"
			android:defaultValue = "1.2"			
		/>
		
		
		<com.sap.maf.uicontrols.settingscreen.MAFLongPreference
			android:key = "TestLongPref"
			android:title = "Test Long Preferences"
			android:defaultValue = "123456"			
		/>
		
		<com.sap.maf.uicontrols.settingscreen.MAFStringPreference
			android:key = "TestStringPref"
			android:title = "Test String Preferences"
			android:defaultValue = "test"
		/>
		
			
		<com.sap.maf.uicontrols.settingscreen.MAFPreference
			android:key = "TestSimplePref"
			android:title = "Test Simple Preferences"								
		/> 
		
		<com.sap.maf.uicontrols.settingscreen.MAFListPreference
			android:key = "TestListPref"
			android:title = "Test List Preferences"
			android:entries = "@array/listpref"
			android:entryValues="@array/listprefvalues"									
		/>
				
	</PreferenceCategory>
	
	<PreferenceCategory android:title = "Sample Preferences Section2">
	
	<com.sap.maf.uicontrols.settingscreen.MAFBooleanPreference
			android:key = "TestBoolPref"
			android:title = "Test Boolean Preferences"
			android:defaultValue = "false"
		/>

	    </PreferenceCategory>
</PreferenceScreen>
To use the native Android preference activity programmatically, enter: 
public class SamplePreferenceActivity extends PreferenceActivity {
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.preferences);		
	}
	
	
}

Skinning of MAF Setting Screen

The MAF Setting Screen is built from basic skinnable components:, therefore you can skin them via the basic components.
  • The preference screen uses the Window target type background color attribute.
  • The dialog-based preferences use the Dialog target type attributes.
  • The input fields use the TextBox target type attributes.
  • The Boolean preference uses the CheckBox target type attributes.