List of usage examples for android.widget RelativeLayout setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:org.wso2.iot.agent.activities.AlreadyRegisteredActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_already_registered); textViewLastSync = (TextView) findViewById(R.id.textViewLastSync); imageViewRefresh = (ImageView) findViewById(R.id.imageViewRefresh); devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); cdmDeviceAdmin = new ComponentName(this, AgentDeviceAdminReceiver.class); context = this; DeviceInfo info = new DeviceInfo(context); Bundle extras = getIntent().getExtras(); if (extras != null) { if (extras.containsKey(getResources().getString(R.string.intent_extra_fresh_reg_flag))) { isFreshRegistration = extras .getBoolean(getResources().getString(R.string.intent_extra_fresh_reg_flag)); }//from ww w . ja v a 2s.c om } String registrationId = Preference.getString(context, Constants.PreferenceFlag.REG_ID); if (registrationId != null && !registrationId.isEmpty()) { regId = registrationId; } else { regId = info.getDeviceId(); } if (isFreshRegistration) { Preference.putBoolean(context, Constants.PreferenceFlag.REGISTERED, true); if (!isDeviceAdminActive()) { startEvents(); } // In FCM, for fresh registrations, the initial FCM notification has been ignored // purposely to avoid calling the server during enrollment flow and causing threading // issues. Therefore after initial enrollment, pending operations is called manually. if (Constants.NOTIFIER_FCM .equals(Preference.getString(context, Constants.PreferenceFlag.NOTIFIER_TYPE))) { MessageProcessor messageProcessor = new MessageProcessor(context); try { if (Preference.getBoolean(context, Constants.PreferenceFlag.REGISTERED)) { messageProcessor.getMessages(); } } catch (AndroidAgentException e) { Log.e(TAG, "Failed to perform operation", e); } } isFreshRegistration = false; } RelativeLayout relativeLayoutSync = (RelativeLayout) findViewById(R.id.layoutSync); relativeLayoutSync.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Preference.getBoolean(context, Constants.PreferenceFlag.REGISTERED) && isDeviceAdminActive()) { syncWithServer(); } } }); RelativeLayout relativeLayoutDeviceInfo = (RelativeLayout) findViewById(R.id.layoutDeviceInfo); relativeLayoutDeviceInfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { loadDeviceInfoActivity(); } }); RelativeLayout relativeLayoutChangePIN = (RelativeLayout) findViewById(R.id.layoutChangePIN); relativeLayoutChangePIN.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { loadPinCodeActivity(); } }); RelativeLayout relativeLayoutRegistration = (RelativeLayout) findViewById(R.id.layoutRegistration); if (Constants.HIDE_UNREGISTER_BUTTON) { relativeLayoutRegistration.setVisibility(View.GONE); } else { relativeLayoutRegistration.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showUnregisterDialog(); } }); } TextView textViewAgentVersion = (TextView) findViewById(R.id.textViewVersion); String versionText = BuildConfig.BUILD_TYPE + " v" + BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ") "; textViewAgentVersion.setText(versionText); if (Build.VERSION.SDK_INT >= 23) { List<String> missingPermissions = new ArrayList<>(); if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { missingPermissions.add(android.Manifest.permission.READ_PHONE_STATE); } if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { missingPermissions.add(android.Manifest.permission.ACCESS_COARSE_LOCATION); } if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { missingPermissions.add(android.Manifest.permission.ACCESS_FINE_LOCATION); } if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { missingPermissions.add(android.Manifest.permission.WRITE_EXTERNAL_STORAGE); } NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); // This is to handle permission obtaining for Android N devices where operations such // as mute that can cause a device to go into "do not disturb" will need additional // permission. Added here as well to support already enrolled devices to optain the // permission without reenrolling. if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M && !devicePolicyManager.isProfileOwnerApp(Constants.AGENT_PACKAGE) && notificationManager != null && !notificationManager.isNotificationPolicyAccessGranted()) { CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context, getResources().getString(R.string.dialog_do_not_distrub_title), getResources().getString(R.string.dialog_do_not_distrub_message), getResources().getString(R.string.ok), doNotDisturbClickListener); } if (missingPermissions.isEmpty()) { NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(Constants.PERMISSION_MISSING, Constants.PERMISSION_MISSING_NOTIFICATION_ID); } else { ActivityCompat.requestPermissions(AlreadyRegisteredActivity.this, missingPermissions.toArray(new String[missingPermissions.size()]), 110); } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { try { int locationSetting = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE); if (locationSetting == 0) { Intent enableLocationIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(enableLocationIntent); Toast.makeText(context, R.string.msg_need_location, Toast.LENGTH_LONG).show(); } } catch (Settings.SettingNotFoundException e) { Log.w(TAG, "Location setting is not available on this device"); } } boolean isRegistered = Preference.getBoolean(context, Constants.PreferenceFlag.REGISTERED); if (isRegistered) { if (CommonUtils.isNetworkAvailable(context)) { String serverIP = Constants.DEFAULT_HOST; String prefIP = Preference.getString(context, Constants.PreferenceFlag.IP); if (prefIP != null) { serverIP = prefIP; } regId = Preference.getString(context, Constants.PreferenceFlag.REG_ID); if (regId != null) { if (serverIP != null && !serverIP.isEmpty()) { ServerConfig utils = new ServerConfig(); utils.setServerIP(serverIP); if (utils.getHostFromPreferences(context) != null && !utils.getHostFromPreferences(context).isEmpty()) { CommonUtils.callSecuredAPI(AlreadyRegisteredActivity.this, utils.getAPIServerURL(context) + Constants.DEVICES_ENDPOINT + regId + Constants.IS_REGISTERED_ENDPOINT, HTTP_METHODS.GET, null, AlreadyRegisteredActivity.this, Constants.IS_REGISTERED_REQUEST_CODE); } else { try { CommonUtils.clearAppData(context); } catch (AndroidAgentException e) { String msg = "Device already dis-enrolled."; Log.e(TAG, msg, e); } loadInitialActivity(); } } else { Log.e(TAG, "There is no valid IP to contact server"); } } } else { if (!Constants.HIDE_ERROR_DIALOG) { CommonDialogUtils.showNetworkUnavailableMessage(AlreadyRegisteredActivity.this); } } } else { loadInitialActivity(); } }
From source file:fm.krui.kruifm.StreamFragment.java
public void startAudio(ImageView playButton) { // FIXME: WHY WHY WHY do I have to call changeUrl BEFORE I can start the audio? The URL is stored in StreamService, right? I don't FUCKING UNDERSTAND THIS! changeUrl(stationTag);/* w w w .j ava2s . c om*/ // Request service to start audio Intent intent = new Intent(getActivity(), StreamService.class); intent.putExtra(StreamService.INTENT_STREAM_URL, streamUrl); intent.setAction(StreamService.ACTION_PLAY); getActivity().startService(intent); isPlaying = true; // Change image of button to pause icon. playButton.setImageResource(R.drawable.pause_icon_white); // Hide the "no audio playing" overlay RelativeLayout noAudioContainer = (RelativeLayout) getActivity() .findViewById(R.id.no_audio_playing_container_relativelayout); RelativeLayout albumArtContainer = (RelativeLayout) getActivity() .findViewById(R.id.stream_album_art_container); noAudioContainer.setVisibility(View.INVISIBLE); albumArtContainer.setVisibility(View.VISIBLE); }
From source file:org.smilec.smile.ui.GeneralActivity.java
private void showResults() { TableLayout tlTotal = (TableLayout) findViewById(R.id.tl_total); tlTotal.setVisibility(View.GONE); TextView tvTotal = (TextView) findViewById(R.id.tv_total); tvTotal.setVisibility(View.GONE); View vTotal = findViewById(R.id.view_separator_total); vTotal.setVisibility(View.GONE); TableLayout.LayoutParams layoutParams = new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 315); ListView lvListStudents = (ListView) GeneralActivity.this.findViewById(R.id.lv_students); lvListStudents.setLayoutParams(layoutParams); lvListStudents.setPadding(5, 0, 0, 0); TextView tvTopTitle = (TextView) GeneralActivity.this.findViewById(R.id.tv_top_scorers); tvTopTitle.setVisibility(View.VISIBLE); // View vSeparatorScore = findViewById(R.id.view_separator_score); // vSeparatorScore.setVisibility(View.VISIBLE); RelativeLayout rlTopScorersContainer = (RelativeLayout) GeneralActivity.this .findViewById(R.id.rl_top_scorers); rlTopScorersContainer.setVisibility(View.VISIBLE); spLimitToSucceed = (Spinner) findViewById(R.id.sp_limit_to_succeed); ArrayAdapter<?> adapterLimit = ArrayAdapter.createFromResource(this, R.array.percent_correct, android.R.layout.simple_spinner_item); adapterLimit.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spLimitToSucceed.setAdapter(adapterLimit); // Initialize the spinner to 70% spLimitToSucceed.setSelection(2);//from w w w . ja va 2s . co m // If the teacher clicks on the spinner to set a different limit to succeed spLimitToSucceed.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { String[] bases = getResources().getStringArray(R.array.percent_correct); if (activeFragment instanceof StudentsFragment) { ((StudentsFragment) activeFragment).updatePercentCorrect(Integer.parseInt(bases[position])); } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); // If the teacher clicks on "Send results" button Button btSendResults = (Button) GeneralActivity.this.findViewById(R.id.bt_send_results); btSendResults.setVisibility(View.VISIBLE); btSendResults.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SendEmailResultsUtil.send(board, ip, GeneralActivity.this); } }); }
From source file:fm.krui.kruifm.StreamActivity.java
public void startAudio(ImageView playButton) { // FIXME: WHY WHY WHY do I have to call changeUrl BEFORE I can start the audio? The URL is stored in StreamService, right? I don't FUCKING UNDERSTAND THIS! changeUrl(stationTag);/* w w w . j a va2s . c om*/ // Request service to start audio Intent intent = new Intent(this, StreamService.class); intent.putExtra(StreamService.INTENT_STREAM_URL, streamUrl); intent.setAction(StreamService.ACTION_PLAY); this.startService(intent); isPlaying = true; // Change image of button to pause icon. playButton.setImageResource(R.drawable.pause_icon_white); // Hide the "no audio playing" overlay RelativeLayout noAudioContainer = (RelativeLayout) this .findViewById(R.id.no_audio_playing_container_relativelayout); RelativeLayout albumArtContainer = (RelativeLayout) this.findViewById(R.id.stream_album_art_container); noAudioContainer.setVisibility(View.INVISIBLE); albumArtContainer.setVisibility(View.VISIBLE); }
From source file:de.enlightened.peris.IntroScreen.java
@Override public final void onResume() { super.onResume(); final PerisApp app = (PerisApp) getApplication(); app.initSession();//from w w w. j a va2 s. c o m app.setActive(false); final RelativeLayout connectingLayout = (RelativeLayout) findViewById(R.id.intro_connecting_layout); connectingLayout.setVisibility(View.GONE); getActionBar().show(); if (this.stealingLink) { this.stealTapatalkLink(this.linkToSteal); return; } if (getString(R.string.server_location).contentEquals("0") && !this.incomingShortcut) { this.refreshList(); } else { this.connectToServer(this.selectedServer); } final TextView tvUpgrade = (TextView) findViewById(R.id.intro_screen_remove_ads); tvUpgrade.setVisibility(View.GONE); }
From source file:com.push.app.HomeActivity.java
/** * Displays the downloaded articles in the list and also populates the slide show * @param recentPosts//from w w w . j av a 2s .co m */ private void displayArticles(final ArticlePost recentPosts) { try { // firstItemView.setVisibility(View.VISIBLE); final ArrayList<Article> mPosts = new ArrayList<>(); mPosts.addAll(recentPosts.getResults()); PostFragmentAdapter.postItems = mPosts; RelativeLayout mainImageHolder = (RelativeLayout) mHomeLayout.findViewById(R.id.mainImageHolder); if (recentPosts.getResults().get(0).getImageUrls().size() > 0) { mainImageHolder.setVisibility(RelativeLayout.VISIBLE); aq.id(firstPostImage).progress(R.id.image_progress).image( recentPosts.getResults().get(0).getImageUrls().get(0), true, true, 0, R.drawable.fallback, null, AQuery.FADE_IN); // Should probably use a canvas here? /*aq.id(firstPostImage).progress(R.id.image_progress).image(recentPosts.getResults().get(0).getImageUrls().get(0), true, true, 0, R.drawable.fallback, new BitmapAjaxCallback() { @Override public void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status) { iv.setVisibility(View.VISIBLE); RelativeLayout parentLayout = (RelativeLayout)iv.getParent(); WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); int imageWidth = dpToPx(bm.getWidth()); int imageHeight = dpToPx(bm.getHeight()); // Here we do the ratio math // Get the new width of the image when in the view float ratio = (float)size.x / (float)imageWidth; // If ratio is less than 1 the original image is larger than the view // Get the new height from the ratio. int newHeight = Math.round(imageHeight * ratio); if (size.x > bm.getWidth()) { size.x = bm.getWidth(); } // If the image is taller than wider, then make it square if (newHeight > size.x) { newHeight = size.x; } if (imageWidth < imageHeight) { //bm = Bitmap.createBitmap(bm, 0, 0, size.x, newHeight); } RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(size.x, newHeight); parentLayout.setLayoutParams(layoutParams); iv.setImageBitmap(bm); } } ); */ } else { mainImageHolder.setVisibility(RelativeLayout.GONE); } firstItemHeadline.setText(recentPosts.getResults().get(0).getHeadline()); firstItemDescription.setText(recentPosts.getResults().get(0).getDescription()); if (recentPosts.getResults().get(0).getAuthor().length() > 0) { firstItemDateandAuthor.setText(DateUtil.setTime( DateUtil.postsDatePublishedFormatter .parse(String.valueOf(recentPosts.getResults().get(0).getPublishDate())).getTime(), true) + " by " + recentPosts.getResults().get(0).getAuthor()); } else { firstItemDateandAuthor.setText(DateUtil.setTime( DateUtil.postsDatePublishedFormatter .parse(String.valueOf(recentPosts.getResults().get(0).getPublishDate())).getTime(), true)); } //remove it from the list recentPosts.getResults().remove(0); PostListAdapter mListAdapter = new PostListAdapter(this, R.layout.list_news_item, recentPosts.getResults()); this.mListView.setAdapter(mListAdapter); mSwipeRefreshLayout.setRefreshing(false); mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (!isSearchOpened) { Intent i = new Intent(HomeActivity.this, DetailPostActivity.class); i.putExtra("postPosition", position); i.putExtra("postTitle", mPosts.get(position).getHeadline()); i.putExtra("description", mPosts.get(position).getDescription()); startActivity(i); } } }); //TODO @Bryan uncommented this. Causes detail to page to keep opening endlessly after notification when you press back key // if (isNotification) { //This is a way of displaying a test article from push - To be removed in production // Utils.log("Displaying test article = notification"); // mListView.performItemClick(mListAdapter.getView(0, null, null), 0, mListAdapter.getItemId(0)); // } } catch (ParseException e) { e.printStackTrace(); } }
From source file:de.enlightened.peris.IntroScreen.java
private void connectToServer(final Server server) { if (this.runningManifestChecks != null) { int killedManifests = 0; for (ForumManifestCheckerTask cfm : this.runningManifestChecks) { if (cfm.getStatus() == Status.RUNNING) { cfm.cancel(true);/*from www . j a va 2 s .com*/ killedManifests++; } } if (killedManifests > 0) { Log.i(TAG, "Killed " + killedManifests + " manifest checks!"); } } final PerisApp app = (PerisApp) getApplication(); app.initSession(); if (server.serverTagline.contentEquals("[*WEBVIEW*]")) { app.getSession().setServer(server); final Intent myIntent = new Intent(IntroScreen.this, WebViewer.class); startActivity(myIntent); return; } final RelativeLayout connectingLayout = (RelativeLayout) findViewById(R.id.intro_connecting_layout); connectingLayout.setVisibility(View.VISIBLE); final TextView tvServerConnectionText = (TextView) findViewById(R.id.intro_connecting_text); tvServerConnectionText.setText("Logging in to\n" + server.getUrlString()); if (server.serverColor.contains("#")) { connectingLayout.setBackgroundColor(Color.parseColor(server.serverColor)); tvServerConnectionText.setTextColor(Color.parseColor(ThemeSetter.getForeground(server.serverColor))); } //getActionBar().hide(); app.getSession().setSessionListener(new Session.SessionListener() { @Override @SuppressWarnings("checkstyle:requirethis") public void onSessionConnected() { loadForum(); } @Override @SuppressWarnings("checkstyle:requirethis") public void onSessionConnectionFailed(final String reason) { final Toast toast = Toast.makeText(IntroScreen.this, "Unable to log in: " + reason, Toast.LENGTH_LONG); toast.show(); loadForum(); } }); app.getSession().setServer(server); }
From source file:com.phonegap.plugins.ChildBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load.//from w w w . j ava 2 s . c om * @param jsonObject */ public String showWebPage(final String url, JSONObject options) { // Determine if we should hide the location bar. if (options != null) { showLocationBar = options.optBoolean("showLocationBar", true); } // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } public void run() { // Let's create the main dialog dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); toolbar.setVisibility(View.GONE); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); actionButtonContainer.setVisibility(View.GONE); // Back button ImageButton back = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); try { back.setImageBitmap(loadDrawable("www/images/icon_arrow_left.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button ImageButton forward = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); try { forward.setImageBitmap(loadDrawable("www/images/icon_arrow_right.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close button ImageButton close = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); try { close.setImageBitmap(loadDrawable("www/images/icon_close.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView webview = new WebView(cordova.getActivity()); webview.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); webview.setWebChromeClient(new WebChromeClient()); WebViewClient client = new ChildBrowserClient(edittext); webview.setWebViewClient(client); WebSettings settings = webview.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginsEnabled(true); settings.setDomStorageEnabled(true); webview.loadUrl(url); webview.setId(6); webview.getSettings().setLoadWithOverviewMode(true); webview.getSettings().setUseWideViewPort(true); webview.requestFocus(); webview.requestFocusFromTouch(); // Add the back and forward buttons to our action button container layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(webview); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); } private Bitmap loadDrawable(String filename) throws java.io.IOException { InputStream input = cordova.getActivity().getAssets().open(filename); return BitmapFactory.decodeStream(input); } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:ablgroup.daily2.authentification.AuthentificationFragment.java
@Override public void onClick(View v) { RelativeLayout r = (RelativeLayout) findViewById(R.id.login_first); RelativeLayout r2 = (RelativeLayout) findViewById(R.id.email_password_fields); RelativeLayout r3 = (RelativeLayout) findViewById(R.id.login_retrieve); switch (v.getId()) { case R.id.sign_up: createAccount(mEmailField.getText().toString(), mPasswordField.getText().toString()); break;/*from w w w. j a v a 2 s . co m*/ case R.id.sign_in: signIn(mEmailField.getText().toString(), mPasswordField.getText().toString()); break; case R.id.log_out: signOut(); case R.id.sign_in_button_google: signIn(); break; case R.id.login_email_btn: r.setVisibility(View.INVISIBLE); r2.setVisibility(View.VISIBLE); r3.setVisibility(View.INVISIBLE); break; case R.id.login_comeback_btn: r.setVisibility(View.VISIBLE); r2.setVisibility(View.INVISIBLE); r3.setVisibility(View.INVISIBLE); break; case R.id.login_retrieve_comeback_btn: r.setVisibility(View.VISIBLE); r2.setVisibility(View.INVISIBLE); r3.setVisibility(View.INVISIBLE); break; case R.id.login_retrieve_btn: final TextView t = (TextView) findViewById(R.id.login_retrieve_email); final TextView t2 = (TextView) findViewById(R.id.login_retrieve_confirmation); final TextView btn = (Button) findViewById(R.id.login_retrieve_btn); String emailAddress = t.getText().toString(); mAuth.sendPasswordResetEmail(emailAddress).addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (task.isSuccessful()) { Log.d(TAG, "Email sent."); t.setVisibility(View.INVISIBLE); t2.setVisibility(View.VISIBLE); btn.setVisibility(View.INVISIBLE); } } }); break; case R.id.login_retrieve_view: r.setVisibility(View.INVISIBLE); r2.setVisibility(View.INVISIBLE); r3.setVisibility(View.VISIBLE); break; } }
From source file:de.baumann.hhsmoodle.data_subjects.Subjects_Fragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_screen_notes, container, false); PreferenceManager.setDefaultValues(getActivity(), R.xml.user_settings, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity()); ImageView imgHeader = (ImageView) rootView.findViewById(R.id.imageView_header); helper_main.setImageHeader(getActivity(), imgHeader); RelativeLayout filter_layout = (RelativeLayout) rootView.findViewById(R.id.filter_layout); filter_layout.setVisibility(View.GONE); lv = (ListView) rootView.findViewById(R.id.listNotes); viewPager = (ViewPager) getActivity().findViewById(R.id.viewpager); FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override//from w w w . java 2 s . co m public void onClick(View view) { LayoutInflater inflater = getActivity().getLayoutInflater(); final ViewGroup nullParent = null; View dialogView = inflater.inflate(R.layout.dialog_edit_subject, nullParent); titleInput = (EditText) dialogView.findViewById(R.id.subject_title_); titleInput.setSelection(titleInput.getText().length()); titleInput.setText(""); teacherInput = (EditText) dialogView.findViewById(R.id.subject_teacher); teacherInput.setText(""); roomInput = (EditText) dialogView.findViewById(R.id.subject_room); roomInput.setText(""); helper_main.showKeyboard(getActivity(), titleInput); final ImageButton be = (ImageButton) dialogView.findViewById(R.id.imageButtonPri); assert be != null; be.setImageResource(R.drawable.circle_grey); sharedPref.edit().putString("subject_color", "11").apply(); be.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final helper_main.Item[] items = { new helper_main.Item(getString(R.string.subjects_color_red), R.drawable.circle_red), new helper_main.Item(getString(R.string.subjects_color_pink), R.drawable.circle_pink), new helper_main.Item(getString(R.string.subjects_color_purple), R.drawable.circle_purple), new helper_main.Item(getString(R.string.subjects_color_blue), R.drawable.circle_blue), new helper_main.Item(getString(R.string.subjects_color_teal), R.drawable.circle_teal), new helper_main.Item(getString(R.string.subjects_color_green), R.drawable.circle_green), new helper_main.Item(getString(R.string.subjects_color_lime), R.drawable.circle_lime), new helper_main.Item(getString(R.string.subjects_color_yellow), R.drawable.circle_yellow), new helper_main.Item(getString(R.string.subjects_color_orange), R.drawable.circle_orange), new helper_main.Item(getString(R.string.subjects_color_brown), R.drawable.circle_brown), new helper_main.Item(getString(R.string.subjects_color_grey), R.drawable.circle_grey), }; ListAdapter adapter = new ArrayAdapter<helper_main.Item>(getActivity(), android.R.layout.select_dialog_item, android.R.id.text1, items) { @NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { //Use super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setTextSize(18); tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); //Add margin between image and text (support various screen densities) int dp5 = (int) (24 * getActivity().getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; new android.app.AlertDialog.Builder(getActivity()) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { be.setImageResource(R.drawable.circle_red); sharedPref.edit().putString("subject_color", "1").apply(); } else if (item == 1) { be.setImageResource(R.drawable.circle_pink); sharedPref.edit().putString("subject_color", "2").apply(); } else if (item == 2) { be.setImageResource(R.drawable.circle_purple); sharedPref.edit().putString("subject_color", "3").apply(); } else if (item == 3) { be.setImageResource(R.drawable.circle_blue); sharedPref.edit().putString("subject_color", "4").apply(); } else if (item == 4) { be.setImageResource(R.drawable.circle_teal); sharedPref.edit().putString("subject_color", "5").apply(); } else if (item == 5) { be.setImageResource(R.drawable.circle_green); sharedPref.edit().putString("subject_color", "6").apply(); } else if (item == 6) { be.setImageResource(R.drawable.circle_lime); sharedPref.edit().putString("subject_color", "7").apply(); } else if (item == 7) { be.setImageResource(R.drawable.circle_yellow); sharedPref.edit().putString("subject_color", "8").apply(); } else if (item == 8) { be.setImageResource(R.drawable.circle_orange); sharedPref.edit().putString("subject_color", "9").apply(); } else if (item == 9) { be.setImageResource(R.drawable.circle_brown); sharedPref.edit().putString("subject_color", "10").apply(); } else if (item == 10) { be.setImageResource(R.drawable.circle_grey); sharedPref.edit().putString("subject_color", "11").apply(); } } }).show(); } }); android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder( getActivity()); builder.setTitle(R.string.subjects_edit); builder.setView(dialogView); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Subject_DbAdapter db = new Subject_DbAdapter(getActivity()); db.open(); String inputTitle = titleInput.getText().toString().trim(); String inputTeacher = teacherInput.getText().toString().trim(); String inputRoom = roomInput.getText().toString().trim(); Date date = new Date(); DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd_HH-mm-ss", Locale.getDefault()); String creation = dateFormat.format(date); if (db.isExist(creation)) { Snackbar.make(titleInput, getString(R.string.toast_newTitle), Snackbar.LENGTH_LONG) .show(); } else { db.insert(inputTitle, inputTeacher, sharedPref.getString("subject_color", ""), inputRoom, creation); dialog.dismiss(); setSubjectsList(); } } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); final android.support.v7.app.AlertDialog dialog2 = builder.create(); dialog2.show(); } }); //calling Notes_DbAdapter db = new Subject_DbAdapter(getActivity()); db.open(); setSubjectsList(); setHasOptionsMenu(true); return rootView; }