Back to project page NativeClient-Android.
The source code is released under:
Apache License
If you think the Android project NativeClient-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* Copyright (c) Microsoft// www . ja v a 2s. com All Rights Reserved Apache 2.0 License Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. */ package com.microsoft.aad.taskapplication; import android.app.Activity; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.Switch; import android.widget.TextView; import com.microsoft.aad.taskapplication.helpers.Constants; /** * Settings page to try broker by options */ public class SettingsActivity extends Activity { private CheckBox checkboxAskBroker, checkboxCheckBroker; private Switch fullScreenSwitch; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); loadSettings(); checkboxAskBroker = (CheckBox) findViewById(R.id.askInstall); checkboxCheckBroker = (CheckBox) findViewById(R.id.useBroker); Button save = (Button) findViewById(R.id.settingsSave); save.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TextView textView = (TextView)findViewById(R.id.authority); Constants.AUTHORITY_URL = textView.getText().toString(); textView = (TextView)findViewById(R.id.resource); Constants.RESOURCE_ID = textView.getText().toString(); textView = (TextView)findViewById(R.id.clientId); Constants.CLIENT_ID = textView.getText().toString(); textView = (TextView)findViewById(R.id.extraQueryParameters); Constants.EXTRA_QP = textView.getText().toString(); textView = (TextView)findViewById(R.id.redirectUri); Constants.REDIRECT_URL = textView.getText().toString(); textView = (TextView)findViewById(R.id.serviceUrl); Constants.SERVICE_URL = textView.getText().toString(); textView = (TextView)findViewById(R.id.serviceUrl); textView.setText(Constants.SERVICE_URL); fullScreenSwitch = (Switch)findViewById(R.id.fullScreen); Constants.FULL_SCREEN = fullScreenSwitch.isChecked(); //checkboxes saveSettings(Constants.KEY_NAME_ASK_BROKER_INSTALL, checkboxAskBroker.isChecked()); saveSettings(Constants.KEY_NAME_CHECK_BROKER, checkboxCheckBroker.isChecked()); finish(); } }); SharedPreferences prefs = SettingsActivity.this.getSharedPreferences( Constants.SHARED_PREFERENCE_NAME, Activity.MODE_PRIVATE); boolean stateAskBrokerInstall = prefs.getBoolean( Constants.KEY_NAME_ASK_BROKER_INSTALL, false); checkboxAskBroker.setChecked(stateAskBrokerInstall); boolean stateCheckBroker = prefs.getBoolean( Constants.KEY_NAME_CHECK_BROKER, false); checkboxCheckBroker.setChecked(stateCheckBroker); } private void loadSettings() { TextView textView = (TextView)findViewById(R.id.authority); textView.setText(Constants.AUTHORITY_URL); textView = (TextView)findViewById(R.id.resource); textView.setText(Constants.RESOURCE_ID); textView = (TextView)findViewById(R.id.clientId); textView.setText(Constants.CLIENT_ID); textView = (TextView)findViewById(R.id.extraQueryParameters); textView.setText(Constants.EXTRA_QP); textView = (TextView)findViewById(R.id.redirectUri); textView.setText(Constants.REDIRECT_URL); textView = (TextView)findViewById(R.id.serviceUrl); textView.setText(Constants.SERVICE_URL); fullScreenSwitch = (Switch)findViewById(R.id.fullScreen); fullScreenSwitch.setChecked(Constants.FULL_SCREEN); } private void saveSettings(String key, boolean value) { SharedPreferences prefs = SettingsActivity.this.getSharedPreferences( Constants.SHARED_PREFERENCE_NAME, Activity.MODE_PRIVATE); Editor prefsEditor = prefs.edit(); prefsEditor.putBoolean(key, value); prefsEditor.commit(); } }