<commit_before>sap.ui.controller("com_mycompany.my_app.controllers.Configuration", {

	app : liberty.getViewer().getApp(),

	switchTheme : function(oEvent){
		var app = this.app,
			_this = this,
			btn = oEvent.getSource();

		app.setLoaderVisible(true, function(){
			var newTheme = btn.getCustomData()[0].getValue('theme');
			if('default' === newTheme){
				newTheme = jQuery.sap.getModulePath('ui5strap') + '/bootstrap-3.1.1-dist/css/bootstrap.min.css';
			}
			if(!_this.activeButton){
				_this.activeButton = _this.getView().byId('defaultThemeButton');
			}
			_this.activeButton.setSelected(false);
			btn.setSelected(true);
			_this.activeButton = btn;
			window.setTimeout(function(){
				jQuery.sap.includeStyleSheet(newTheme, 'bootstrap-css', function(){
					window.setTimeout(function(){
						app.setLoaderVisible(false);
					}, 500);
				}, null);
			}, 500);
		}, 'opaque');
	},

	submitThemeForm : function(oEvent){
		var app = this.app;
		

		var newTheme = this.getView().byId('themeInput').getValue();

		if('' === newTheme){
			return false;
		}

		if(!this.isValidBootstrapTheme(newTheme)){
			//Todo Change to BS Modal

			alert(newTheme + ' is not a valid Bootstrap theme!');

			return false;
		}
		else{
			app.setLoaderVisible(true);
		
			if(this.activeButton){
				this.activeButton.setSelected(false);
			}

			jQuery.sap.includeStyleSheet(newTheme, 'ui5strap-css-0', function(){
				app.setLoaderVisible(false);
			}, null);
		}
	},

	isValidBootstrapTheme : function(themeUrl){
 		return /bootstrap(\.min)?\.css$/.test(themeUrl);
	}
	
});<commit_msg>theme switch fix for android<commit_after>sap.ui.controller("com_mycompany.my_app.controllers.Configuration", {

	app : liberty.getViewer().getApp(),

	switchTheme : function(oEvent){
		var app = this.app,
			_this = this,
			btn = oEvent.getSource();

		app.setLoaderVisible(true, function(){
			var newTheme = btn.getCustomData()[0].getValue('theme');
			if('default' === newTheme){
				newTheme = jQuery.sap.getModulePath('ui5strap') + '/bootstrap-3.1.1-dist/css/bootstrap.min.css';
			}
			if(!_this.activeButton){
				_this.activeButton = _this.getView().byId('defaultThemeButton');
			}
			_this.activeButton.setSelected(false);
			btn.setSelected(true);
			_this.activeButton = btn;

			_this.setTheme(newTheme);
			
		}, 'opaque');
	},

	setTheme : function(newTheme){
		var app = this.app;

		window.setTimeout(function(){
			
			//This is a hack: older browser do not fire the onload event for stylesheets
			//We use window.requestAnimationFrame to find out how old the broser is
			//TODO: Find a better way to securely detect if the browser does support onload on stylesheets
			if(window.requestAnimationFrame){
				jQuery.sap.includeStyleSheet(newTheme, 'bootstrap-css', function(){
					window.setTimeout(function(){
						app.setLoaderVisible(false);
					}, 500);
				}, null);
			}
			else{
				jQuery.sap.includeStyleSheet(newTheme, 'bootstrap-css', function(){}, null);
				window.setTimeout(function(){
					app.setLoaderVisible(false);
				}, 800);
			}

		}, 500);
	},

	submitThemeForm : function(oEvent){
		var app = this.app,
			_this = this;
		

		var newTheme = this.getView().byId('themeInput').getValue();

		if('' === newTheme){
			return false;
		}

		if(!this.isValidBootstrapTheme(newTheme)){
			//Todo Change to BS Modal

			alert(newTheme + ' is not a valid Bootstrap theme!');

			return false;
		}
		else{
			app.setLoaderVisible(true, function(){
			
				if(this.activeButton){
					this.activeButton.setSelected(false);
				}

				_this.setTheme(newTheme);

			}, 'opaque');
		}
	},

	isValidBootstrapTheme : function(themeUrl){
 		return /bootstrap(\.min)?\.css$/.test(themeUrl);
	}
	
});
{'fraction_non_alphanumeric': 0.15585464333781965, 'fraction_numerical': 0.007267833109017497, 'mean_word_length': 3.697850821744627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4881390', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1214, 'n_words': 218}