List of usage examples for android.widget Switch setChecked
@Override public void setChecked(boolean checked)
From source file:support.plus.reportit.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Default config if (savedInstanceState != null) { // Restore value of members from saved state userName = savedInstanceState.getString(userName); userBossName = savedInstanceState.getString(userBossName); } else {/*from ww w . j a v a 2 s.c o m*/ // Probably initialize members with default values for a new instance } super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Toolbar toolbar = (Toolbar) findViewById(R.id.settings_toolbar); setSupportActionBar(toolbar); toolbar.setTitle(R.string.app_name); toolbar.setNavigationIcon(R.drawable.ic_back); final TextView TextuserName = (TextView) findViewById(R.id.userName); final TextView TextuserBossName = (TextView) findViewById(R.id.userBossName); final EditText inuserName = (EditText) findViewById(R.id.inuserName); final EditText inuserBossName = (EditText) findViewById(R.id.inuserBossName); final Switch sNoti = (Switch) findViewById(R.id.sNoti); final Button btimePick = (Button) findViewById(R.id.btimePick); final Button bSave = (Button) findViewById(R.id.bSave); final Switch sfingerprint_activ = (Switch) findViewById(R.id.sfingerprint_activ); final Button bsetpassword = (Button) findViewById(R.id.bsetpassword); final Switch sdarkTheme = (Switch) findViewById(R.id.sdarkTheme); final Button bchooseRingtone = (Button) findViewById(R.id.bringtonePick); final SharedPreferences pref3 = getSharedPreferences("Theme", Context.MODE_PRIVATE); Boolean themeDark = pref3.getBoolean("darkTheme", false); if (themeDark == true) { sdarkTheme.setChecked(true); } else { sdarkTheme.setChecked(false); } sdarkTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { final SharedPreferences pref3 = getSharedPreferences("Theme", Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref3.edit(); editor.putBoolean("darkTheme", true); editor.commit(); getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); // Now recreate for it to take effect // startActivity(getIntent()); recreate(); } else { SharedPreferences.Editor editor = pref3.edit(); editor.putBoolean("darkTheme", false); editor.commit(); getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_AUTO); // Now recreate for it to take effect // startActivity(getIntent()); recreate(); } } }); /* SECURITY SETTINGS */ final SharedPreferences pref1 = getSharedPreferences("Fingerprint", Context.MODE_PRIVATE); Boolean fingerprintSet = pref1.getBoolean("fingerprintSet", false); if (fingerprintSet == true) { sfingerprint_activ.setChecked(true); bsetpassword.setVisibility(View.VISIBLE); } else { sfingerprint_activ.setChecked(false); bsetpassword.setVisibility(View.GONE); } sfingerprint_activ.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { SharedPreferences.Editor editor = pref1.edit(); editor.putBoolean("fingerprintSet", true); editor.commit(); bsetpassword.setVisibility(View.VISIBLE); } else { SharedPreferences.Editor editor = pref1.edit(); editor.putBoolean("fingerprintSet", false); editor.commit(); bsetpassword.setVisibility(View.GONE); } } }); bsetpassword.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new MaterialDialog.Builder(SettingsActivity.this).title(R.string.set_password) .content(R.string.set_password_desc) .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD) .inputRange(1, 10) .input(getString(R.string.password), "", new MaterialDialog.InputCallback() { @Override public void onInput(MaterialDialog dialog, CharSequence input) { String name = String.valueOf(input); SharedPreferences pref1 = getSharedPreferences("Fingerprint", Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref1.edit(); editor.putString("passwordSet", name); editor.commit(); return; } }).positiveText(R.string.set_password).negativeText(R.string.cancel).cancelable(false) .show(); } }); /* END SECURITY SETTINGS */ /* NOTIFICATION SETTINGS */ btimePick.setVisibility(View.GONE); sNoti.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { btimePick.setVisibility(View.VISIBLE); bchooseRingtone.setVisibility(View.VISIBLE); } else { btimePick.setVisibility(View.GONE); bchooseRingtone.setVisibility(View.GONE); } } }); final SharedPreferences pref4 = getApplicationContext().getSharedPreferences("userNotification", MODE_PRIVATE); Boolean notificationSet = pref4.getBoolean("alarmSet", false); if (notificationSet == true) { sNoti.setChecked(true); btimePick.setVisibility(View.VISIBLE); bchooseRingtone.setVisibility(View.VISIBLE); } else { sNoti.setChecked(false); btimePick.setVisibility(View.GONE); bchooseRingtone.setVisibility(View.GONE); } sNoti.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { SharedPreferences.Editor editor = pref4.edit(); editor.putBoolean("alarmSet", true); editor.commit(); btimePick.setVisibility(View.VISIBLE); bchooseRingtone.setVisibility(View.VISIBLE); } else { SharedPreferences.Editor editor = pref4.edit(); editor.putBoolean("alarmSet", false); editor.commit(); btimePick.setVisibility(View.GONE); bchooseRingtone.setVisibility(View.GONE); } } }); bchooseRingtone.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, R.string.choose_ringtone); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null); startActivityForResult(intent, 5); } }); btimePick.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogFragment newFragment = new TimePickerFragment(); newFragment.show(getSupportFragmentManager(), "timePicker"); } }); /* END NOTIFICATION SETTINGS */ /* SAVE SETTINGS */ bSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String saveworkplace = "Student"; String saveuserBossName = "Boss"; saveworkplace = inuserName.getText().toString(); saveuserBossName = inuserBossName.getText().toString(); TextuserName.setText(getString(R.string.firm_name) + String.valueOf(saveworkplace)); TextuserBossName.setText(getString(R.string.instructor_name) + String.valueOf(saveuserBossName)); final SharedPreferences pref2 = getApplicationContext().getSharedPreferences("userData", MODE_APPEND); SharedPreferences.Editor editor = pref2.edit(); editor.putString("userName", saveworkplace); editor.putString("userBoss", saveuserBossName); editor.putBoolean("data_saved", true); editor.commit(); Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), "Data saved. Restart the app to see changes.", Snackbar.LENGTH_LONG); snackbar.show(); // finish(); startActivity(getIntent()); } }); final SharedPreferences pref2 = getApplicationContext().getSharedPreferences("userData", MODE_APPEND); if (pref2.getBoolean("data_saved", true)) { String TextuserNameString = pref2.getString("userName", ""); String TextuserBossNameString = pref2.getString("userBoss", ""); TextuserName.setText(getString(R.string.firm_name) + String.valueOf(TextuserNameString)); TextuserBossName.setText(getString(R.string.instructor_name) + String.valueOf(TextuserBossNameString)); inuserName.setVisibility(View.GONE); inuserBossName.setVisibility(View.GONE); bSave.setVisibility(View.GONE); } else { Toast toast = Toast.makeText(this, "No data saved", Toast.LENGTH_SHORT); toast.show(); } /* END SAVE SETTINGS */ }
From source file:com.synox.android.ui.fragment.ShareFileFragment.java
/** * Updates in the UI the section about public share with the information in the current * public share bound to mFile, if any//from w w w . j a va 2 s .c o m */ private void updatePublicShareSection() { if (mPublicShare != null && ShareType.PUBLIC_LINK.equals(mPublicShare.getShareType())) { /// public share bound -> expand section Switch shareViaLinkSwitch = getShareViaLinkSwitch(); if (!shareViaLinkSwitch.isChecked()) { // set null listener before setChecked() to prevent infinite loop of calls shareViaLinkSwitch.setOnCheckedChangeListener(null); shareViaLinkSwitch.setChecked(true); shareViaLinkSwitch.setOnCheckedChangeListener(mOnShareViaLinkSwitchCheckedChangeListener); } getExpirationDateSection().setVisibility(View.VISIBLE); getPasswordSection().setVisibility(View.VISIBLE); // GetLink button AppCompatButton getLinkButton = getGetLinkButton(); getLinkButton.setVisibility(View.VISIBLE); getLinkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //GetLink from the server and show ShareLinkToDialog ((FileActivity) getActivity()).getFileOperationsHelper().getFileWithLink(mFile); } }); /// update state of expiration date switch and message depending on expiration date Switch expirationDateSwitch = getExpirationDateSwitch(); // set null listener before setChecked() to prevent infinite loop of calls expirationDateSwitch.setOnCheckedChangeListener(null); long expirationDate = mPublicShare.getExpirationDate(); if (expirationDate > 0) { if (!expirationDateSwitch.isChecked()) { expirationDateSwitch.toggle(); } String formattedDate = SimpleDateFormat.getDateInstance().format(new Date(expirationDate)); getExpirationDateValue().setText(formattedDate); } else { if (expirationDateSwitch.isChecked()) { expirationDateSwitch.toggle(); } getExpirationDateValue().setText(R.string.empty); } // recover listener expirationDateSwitch.setOnCheckedChangeListener(mOnExpirationDateInteractionListener); /// update state of password switch and message depending on password protection Switch passwordSwitch = getPasswordSwitch(); // set null listener before setChecked() to prevent infinite loop of calls passwordSwitch.setOnCheckedChangeListener(null); if (mPublicShare.isPasswordProtected()) { if (!passwordSwitch.isChecked()) { passwordSwitch.toggle(); } getPasswordValue().setVisibility(View.VISIBLE); } else { if (passwordSwitch.isChecked()) { passwordSwitch.toggle(); } getPasswordValue().setVisibility(View.INVISIBLE); } // recover listener passwordSwitch.setOnCheckedChangeListener(mOnPasswordInteractionListener); } else { /// no public share -> collapse section Switch shareViaLinkSwitch = getShareViaLinkSwitch(); if (shareViaLinkSwitch.isChecked()) { shareViaLinkSwitch.setOnCheckedChangeListener(null); getShareViaLinkSwitch().setChecked(false); shareViaLinkSwitch.setOnCheckedChangeListener(mOnShareViaLinkSwitchCheckedChangeListener); } getExpirationDateSection().setVisibility(View.GONE); getPasswordSection().setVisibility(View.GONE); getGetLinkButton().setVisibility(View.GONE); } }
From source file:com.adamas.client.android.MainActivity.java
private void processConnectDisconnectKey() { if (_connected) { DisconnectOpenvpnTask task = new DisconnectOpenvpnTask(); task.execute();/*from ww w. j a va 2 s . c o m*/ } else { if (_selectedAdamasConnector != null) { _connectedAdamasConnector = _selectedAdamasConnector; // Request permission to use the API Intent i = mService.prepare(getApplicationContext()); if (i != null) { startActivityForResult(i, VPNSERVICE_PERMISSION); } else { onActivityResult(VPNSERVICE_PERMISSION, Activity.RESULT_OK, null); } } else { Switch mySwitch = (Switch) _menuItemStartStop.getActionView() .findViewById(R.id.switchForStartStopConnector); mySwitch.setChecked(_connected); if (_connectorfragment != null) { if (_connectorfragment.getConnectorCount() == 0) { toast(getResources().getString(R.string.toast_add_a_connector), ToastType.warning); } else { toast(getResources().getString(R.string.toast_select_a_connector), ToastType.warning); } } } } }
From source file:fm.krui.kruifm.StreamActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.stream_layout); // Instantiate class members prefManager = new PreferenceManager(this); favTrackManager = new FavoriteTrackManager(this); stationTag = getIntent().getIntExtra(KEY_STATION_TAG, -1); // Set ActionBar Title ActionBar actionBar = getActionBar(); actionBar.setTitle(getString(R.string.listen_sidebar)); actionBar.setSubtitle(getActivitySubtitle(getIntent())); // FIXME: Move these to PreferenceManager after expanding its scope for cleaner code trackPrefs = this.getSharedPreferences(StreamService.PREFS_NAME, 0); // Instantiate broadcast receiver broadcastReceiver = new BroadcastReceiver() { @Override/*from w w w . j a v a 2 s .c o m*/ public void onReceive(Context context, Intent intent) { processBroadcastCommand(intent); } }; // Retrieve player state to determine how to build this activity boolean playerState = prefManager.getPlayerState(); // If audio is playing in StreamService, we don't want to rebuffer, and we want to restore the UI state from the cache. if (playerState) { restoreUIState(); } // If audio is NOT playing, buffer and treat this launch like a clean startup. else { // Determine the URL we need to use to stream based on the station tag and quality preferences streamUrl = getStreamUrl(stationTag); Log.v(TAG, "streamUrl is now set to: " + streamUrl); // Perform initial configuration of audio server changeUrl(stationTag); // Begin buffering the audio startAudio((ImageView) this.findViewById(R.id.play_audio_imageview)); } // Build play button listener final ImageView playButton = (ImageView) this.findViewById(R.id.play_audio_imageview); playButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { handleAudio(playButton); } }); // Build volume seek bar listener // ** DISABLED FOR NOW -- This might be completely thrown out. ** /*final SeekBar volumeSeekBar = (SeekBar)this.findViewById(R.id.volume_seekbar); volumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { // When seek bar progress is changed, change the audio of the media player appropriately. @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // Send new volume via intent? Will this be slow? } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); */ // Build settings button listener and apply it to settings icon and submit button View.OnClickListener flipListener = new View.OnClickListener() { @Override public void onClick(View v) { // Card flip animation which toggles between stream controls and settings views flipCard(); } }; final ImageView settingsButton = (ImageView) this.findViewById(R.id.stream_settings_imageview); final Button saveSettingsButton = (Button) this.findViewById(R.id.set_stream_settings_button); settingsButton.setOnClickListener(flipListener); saveSettingsButton.setOnClickListener(flipListener); // Build favorite button listener final ImageView favoriteButton = (ImageView) this.findViewById(R.id.stream_favorite_imageview); favoriteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (trackIsFavorite) { favoriteButton.setImageResource(R.drawable.star_unfilled_white); trackIsFavorite = false; removeTrackFromFavorites(); } else { favoriteButton.setImageResource(R.drawable.star_filled_white); trackIsFavorite = true; addTrackToFavorites(); } } }); // Build settings switches final Switch streamQualitySwitch = (Switch) this.findViewById(R.id.stream_quality_switch); final Switch albumArtSwitch = (Switch) this.findViewById(R.id.stream_album_art_switch); // Set initial state of switches albumArtSwitch.setChecked(prefManager.getAlbumArtDownloadPreference()); if (prefManager.getStreamQuality() == prefManager.HIGH_QUALITY) { streamQualitySwitch.setChecked(true); } else { streamQualitySwitch.setChecked(false); } // Assign listeners to switches streamQualitySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { prefManager.setStreamQuality(prefManager.HIGH_QUALITY); Log.v(TAG, "Stream quality setting is now: " + prefManager.getStreamQuality()); } else { prefManager.setStreamQuality(prefManager.LOW_QUALITY); Log.v(TAG, "Stream quality setting is now: " + prefManager.getStreamQuality()); } changeUrl(stationSpinnerPosition); } }); albumArtSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { prefManager.setAlbumArtDownloadPreference(true); Log.v(TAG, "Album Art Download setting is now " + prefManager.getAlbumArtDownloadPreference()); } else { prefManager.setAlbumArtDownloadPreference(false); Log.v(TAG, "Album Art Download setting is now " + prefManager.getAlbumArtDownloadPreference()); } } }); // ***** Old onCreate function starts here! // Initialize screen lock/wake receiver IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); BroadcastReceiver screenReceiver = new ScreenReceiver(); // Attach it to this activity this.getApplicationContext().registerReceiver(screenReceiver, filter); }
From source file:dynamite.zafroshops.app.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); EXTRA_ID = getApplicationContext().getPackageName() + ".id"; titles = new CharSequence[] { getString(R.string.title_section1), getString(R.string.title_section2), getString(R.string.title_section5) }; mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); NewZopOpenings = new ArrayList(); NewZopServices = new ArrayList(); depth = 1;/* w w w . j a v a 2 s . c om*/ locationToggleDefault = true; // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); SharedPreferences preferences = getPreferences(0); final SharedPreferences.Editor editor = preferences.edit(); Switch locationToggle = (Switch) findViewById(R.id.location_toggle); locationToggle.setChecked(preferences.getBoolean(StorageKeys.LOCATION_TOGGLE_KEY, locationToggleDefault)); locationToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { editor.putBoolean(StorageKeys.LOCATION_TOGGLE_KEY, b); editor.commit(); if (b) { getLocation(true); getAddress(true); } } }); if (!preferences.contains(StorageKeys.COUNTRY_KEY)) { editor.putString(StorageKeys.COUNTRY_KEY, ""); editor.commit(); } try { // Create the Mobile Service Client instance, using the provided // Mobile Service URL and key MobileClient = new MobileServiceClient(getString(R.string.azure_site), getString(R.string.azure_mobile_service_app_key), this); } catch (MalformedURLException ignored) { } NotificationsManager.handleNotifications(this, getString(R.string.google_api_name), PushHandler.class); registerWithNotificationHubs(); googleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(LocationServices.API).build(); Bundle bundle = getIntent().getExtras(); if (bundle != null && bundle.containsKey(EXTRA_ID)) { nextMenu(ZopItemFragment.newInstance(bundle.getString(EXTRA_ID)), false, 100); } // setup ads adView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build(); adView.loadAd(adRequest); Interstitial = new InterstitialAd(this); Interstitial.setAdUnitId(getString(R.string.ads_interstitial_unit_id)); Interstitial.setAdListener(new AdListener() { @Override public void onAdClosed() { requestNewInterstitial(); } }); requestNewInterstitial(); // setup in app package if (!getResources().getBoolean(R.bool.debug)) { inAppHelper = new IabHelper(this, getString(R.string.inappkey)); inAppHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (!result.isSuccess()) { return; } if (inAppHelper == null) { return; } inAppHelper.queryInventoryAsync(gotInventoryListener); } }); } DataVersion = 0; Versions = new Hashtable<>(); Counts = new Hashtable<>(); setDataVersion(); openHelpDialog(null); }
From source file:org.jak_linux.dns66.main.StartFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_start, container, false); Switch switchOnBoot = (Switch) rootView.findViewById(R.id.switch_onboot); ImageView view = (ImageView) rootView.findViewById(R.id.start_button); view.setOnLongClickListener(new View.OnLongClickListener() { @Override/*from www . j a v a 2 s .c om*/ public boolean onLongClick(View v) { if (AdVpnService.vpnStatus != AdVpnService.VPN_STATUS_STOPPED) { Log.i(TAG, "Attempting to disconnect"); Intent intent = new Intent(getActivity(), AdVpnService.class); intent.putExtra("COMMAND", org.jak_linux.dns66.vpn.Command.STOP.ordinal()); getActivity().startService(intent); } else { checkHostsFilesAndStartService(); } return true; } }); updateStatus(rootView, AdVpnService.vpnStatus); switchOnBoot.setChecked(MainActivity.config.autoStart); switchOnBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { MainActivity.config.autoStart = isChecked; FileHelper.writeSettings(getContext(), MainActivity.config); } }); return rootView; }
From source file:com.adamas.client.android.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); _menuItemStartStop = menu.findItem(R.id.action_start_stop_vpn); final Switch mySwitch = (Switch) _menuItemStartStop.getActionView() .findViewById(R.id.switchForStartStopConnector); if (_checked != null) { mySwitch.setChecked(_checked.booleanValue()); _checked = null;//from w w w. ja va2 s. c om } else { mySwitch.setChecked(_connected); } if (_connecting.get() || _disconnecting.get()) { _menuItemStartStop.getActionView().findViewById(R.id.switchForStartStopConnector) .setVisibility(View.GONE); _menuItemStartStop.getActionView().findViewById(R.id.progressBarConnecting).setVisibility(View.VISIBLE); } //attach a listener to check for changes in state mySwitch.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (_runProcessConnectDisconnectKey) { if (isChecked) { processConnectDisconnectKey(); } else { processConnectDisconnectKey(); } } else { _runProcessConnectDisconnectKey = true; } } }); return true; }
From source file:com.urbantamil.projmadurai.CustomWebViewClient.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.book_detail, container, false); final View book_use_pdf = rootView.findViewById(R.id.book_use_pdf); setHasOptionsMenu(true);/*from w ww .j a v a 2 s . c om*/ // book-use-PDF is not featured for the app book_use_pdf.setVisibility(View.INVISIBLE); if (getArguments().containsKey(ARG_ITEM_OPEN)) { m_open_book = getArguments().getBoolean(ARG_ITEM_OPEN); Log.d(TAG, "ARG_ITEM_OPEN was requested as " + m_open_book); } // Show the dummy content as text in a TextView. if (mItem != null) { ((TextView) rootView.findViewById(R.id.book_detail)).setText(mItem.getTitle()); ((TextView) rootView.findViewById(R.id.book_author)).setText(mItem.getAuthor()); ((CheckBox) rootView.findViewById(R.id.book_use_pdf)).setChecked(true); ((TextView) rootView.findViewById(R.id.book_genre)).setText(mItem.getGenre()); final Switch sw = (Switch) rootView.findViewById(R.id.book_bookmark); if (Build.VERSION.SDK_INT >= 14) { sw.setTextOn(getResources().getString(R.string.mark)); sw.setTextOff(getResources().getString(R.string.clear)); } //load current state of bookmarking for the book boolean isBookMarked = false; try { MaduraiBookmark mgr = MaduraiBookmark.getManager(getActivity()); if (mgr != null) { isBookMarked = mgr.findBook(mItem) >= 0; } } catch (Exception e) { //pass } if (Build.VERSION.SDK_INT >= 14) { sw.setChecked(isBookMarked); } sw.postInvalidate(); sw.setOnClickListener(m_bookmarkListener); final Button btn = (Button) rootView.findViewById(R.id.book_open_browser); mWebView = (ObservableWebView) rootView.findViewById(R.id.book_webView); final ObservableWebView wv = (ObservableWebView) rootView.findViewById(R.id.book_webView); wv.getSettings().setJavaScriptEnabled(true); fontSize = wv.getSettings().getDefaultFontSize(); wv.setKeepScreenOn(true); wv.setWebViewClient(new CustomWebViewClient(btn)); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url = MaduraiOrg.getFullUrlAssetsHTML(mItem.getUrl_html().next()); //update book : on recent list MaduraiRecentBook.getManager(getActivity()).add(mItem); wv.setVisibility(View.VISIBLE); wv.invalidate(); wv.loadUrl(url); btn.setEnabled(false); btn.setText(R.string.projmad_please_wait); } }); wv.setOnScrollChangedCallback(new ObservableWebView.OnScrollChangedCallback() { public void onScroll(int l, int t) { //Do stuff Log.d(TAG, "We Scrolled by " + l + " and t = " + t); } }); if (m_open_book) { Log.d(TAG, "Book requested to be opened"); // delayed open book wv.setVisibility(View.VISIBLE); wv.invalidate(); String url = MaduraiOrg.getFullUrlAssetsHTML(mItem.getUrl_html().next()); wv.loadUrl(url); } else { Log.d(TAG, "Book requested cannot be opened"); } } else { Log.d(TAG, "mItem - cannot be loaded - some error occured on dispatch"); } return rootView; }
From source file:com.androguide.honamicontrol.kernel.cpucontrol.CPUActivity.java
private void handleGovernors() { String currentGovernor = ""; if (Helpers.doesFileExist(GOVERNOR)) currentGovernor = CPUHelper.readOneLineNotRoot(GOVERNOR); String currentGovernor2 = ""; if (Helpers.doesFileExist(GOVERNOR2)) currentGovernor2 = CPUHelper.readOneLineNotRoot(GOVERNOR2); else// www .j a v a 2 s. c om currentGovernor2 = bootPrefs.getString("CORE1_GOVERNOR", "NaN"); String currentGovernor3 = ""; if (Helpers.doesFileExist(GOVERNOR3)) currentGovernor3 = CPUHelper.readOneLineNotRoot(GOVERNOR3); else currentGovernor3 = bootPrefs.getString("CORE2_GOVERNOR", "NaN"); String currentGovernor4 = ""; if (Helpers.doesFileExist(GOVERNOR4)) currentGovernor4 = CPUHelper.readOneLineNotRoot(GOVERNOR4); else currentGovernor4 = bootPrefs.getString("CORE3_GOVERNOR", "NaN"); /** CPU Governor for all cores */ String[] availableGovernorsGeneral = CPUHelper.readOneLineNotRoot(GOVERNORS_LIST).split(" "); ArrayAdapter<CharSequence> governorAdapterGeneral = new ArrayAdapter<CharSequence>(this, R.layout.spinner_row); governorAdapterGeneral.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); for (String availableGovernor : availableGovernorsGeneral) { governorAdapterGeneral.add(availableGovernor); } mGeneralGovernor.setAdapter(governorAdapterGeneral); mGeneralGovernor.setSelection(Arrays.asList(availableGovernorsGeneral).indexOf(currentGovernor)); mGeneralGovernor.setOnItemSelectedListener(new GeneralGovListener()); /** CPU Governor for core 0 */ String[] availableGovernors = CPUHelper.readOneLineNotRoot(GOVERNORS_LIST).split(" "); ArrayAdapter<CharSequence> governorAdapter = new ArrayAdapter<CharSequence>(this, R.layout.spinner_row); governorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); for (String availableGovernor : availableGovernors) { governorAdapter.add(availableGovernor); } mGovernor.setAdapter(governorAdapter); mGovernor.setSelection(Arrays.asList(availableGovernors).indexOf(currentGovernor)); mGovernor.setOnItemSelectedListener(new GovListener()); /** CPU Governor for core 1 */ ArrayAdapter<CharSequence> governorAdapter2 = new ArrayAdapter<CharSequence>(this, R.layout.spinner_row); governorAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); for (String anAvailableGovernors2 : availableGovernors) { governorAdapter2.add(anAvailableGovernors2); } mGovernor2.setAdapter(governorAdapter2); mGovernor2.setSelection(Arrays.asList(availableGovernors).indexOf(currentGovernor2)); mGovernor2.setOnItemSelectedListener(new GovListener2()); /** CPU Governor for core 2 */ ArrayAdapter<CharSequence> governorAdapter3 = new ArrayAdapter<CharSequence>(this, R.layout.spinner_row); governorAdapter3.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); for (String anAvailableGovernors3 : availableGovernors) { governorAdapter3.add(anAvailableGovernors3); } mGovernor3.setAdapter(governorAdapter3); mGovernor3.setSelection(Arrays.asList(availableGovernors).indexOf(currentGovernor3)); mGovernor3.setOnItemSelectedListener(new GovListener3()); /** CPU Governor for core 3 */ ArrayAdapter<CharSequence> governorAdapter4 = new ArrayAdapter<CharSequence>(this, R.layout.spinner_row); governorAdapter4.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); for (String anAvailableGovernors4 : availableGovernors) { governorAdapter4.add(anAvailableGovernors4); } mGovernor4.setAdapter(governorAdapter4); mGovernor4.setSelection(Arrays.asList(availableGovernors).indexOf(currentGovernor4)); mGovernor4.setOnItemSelectedListener(new GovListener4()); /** CPU Boost */ if (Helpers.doesFileExist(KRAIT_BOOST)) { Switch cpuBoostSwitch = (Switch) findViewById(R.id.krait_boost_switch); String cpuBoostState = CPUHelper.readOneLineNotRoot(KRAIT_BOOST); if (cpuBoostState.equals("Y")) cpuBoostSwitch.setChecked(true); else cpuBoostSwitch.setChecked(false); cpuBoostSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) Helpers.CMDProcessorWrapper.runSuCommand("busybox echo Y > " + KRAIT_BOOST); else Helpers.CMDProcessorWrapper.runSuCommand("busybox echo N > " + KRAIT_BOOST); } }); } else { findViewById(R.id.card_krait_boost).setVisibility(View.GONE); } /** CPU Informations */ String pvs = "NaN"; String table = "NaN"; TextView pvsBinning = (TextView) findViewById(R.id.pvs_bin); TextView pvsSpeed = (TextView) findViewById(R.id.pvs_speed); if (Helpers.doesFileExist(PVS_BINNING)) { String rawTableName = CPUHelper.readOneLineNotRoot(PVS_BINNING); rawTableName = rawTableName.replaceAll("[\\D]", ""); table = rawTableName; String[] params = rawTableName.split(""); if (rawTableName.length() == 3) pvs = params[2]; } pvsBinning.setText(getString(R.string.pvs_binning) + " " + pvs); pvsSpeed.setText(getString(R.string.freq_table) + " " + table); }
From source file:com.adamas.client.android.MainActivity.java
@Override public boolean handleMessage(Message msg) { if (_menuItemStartStop == null) { return true; }// w ww.j ava 2 s .c o m if (msg.what == MSG_UPDATE_VPN_STATE) { String state = (String) msg.obj; int code = msg.arg1; if (code == VpnStatus.CONNECTED || code == VpnStatus.NOT_CONNECTED) { _menuItemStartStop.getActionView().findViewById(R.id.switchForStartStopConnector) .setVisibility(View.VISIBLE); _menuItemStartStop.getActionView().findViewById(R.id.progressBarConnecting) .setVisibility(View.GONE); Switch myswitch = (Switch) _menuItemStartStop.getActionView() .findViewById(R.id.switchForStartStopConnector); if (code == VpnStatus.CONNECTED && !myswitch.isChecked()) { _runProcessConnectDisconnectKey = false; myswitch.setChecked(true); } else if (code == VpnStatus.NOT_CONNECTED && myswitch.isChecked()) { _runProcessConnectDisconnectKey = false; myswitch.setChecked(false); } if (code == VpnStatus.CONNECTED) { toast(getResources().getString(R.string.vpn_is_connected), ToastType.info); if (connectClicked) { connectClicked = false; showHomeUrl(); } } else { toast(getResources().getString(R.string.vpn_is_not_connected), ToastType.error); } if (_connectorfragment != null) { _connectorfragment.vpnAdaptorNotifyDataSetChanged(); } } else if (code == VpnStatus.CONNECTING || code == VpnStatus.DISCONNECTING) { _menuItemStartStop.getActionView().findViewById(R.id.switchForStartStopConnector) .setVisibility(View.GONE); _menuItemStartStop.getActionView().findViewById(R.id.progressBarConnecting) .setVisibility(View.VISIBLE); } else { //TODO impossible to get here _menuItemStartStop.getActionView().findViewById(R.id.switchForStartStopConnector) .setVisibility(View.VISIBLE); _menuItemStartStop.getActionView().findViewById(R.id.progressBarConnecting) .setVisibility(View.GONE); toast(getResources().getString(R.string.vpn_is_not_connected), ToastType.error); if (_connectorfragment != null) { _connectorfragment.vpnAdaptorNotifyDataSetChanged(); } } } changeHomeImage(); return true; }