List of usage examples for android.widget RelativeLayout setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.RSMSA.policeApp.OffenceReportForm.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_report_offence); sharedpreferences = getSharedPreferences(MyPREF, Context.MODE_PRIVATE); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w w w .j a v a2 s . co m getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); } SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); ColorDrawable colorDrawable = new ColorDrawable(getResources().getColor(R.color.blue_900)); tintManager.setTintDrawable(colorDrawable); RelativeLayout inputs = (RelativeLayout) findViewById(R.id.inputs); plateNumberEdit = (EditText) findViewById(R.id.plate_number_edit_text); licenceNumberEdit = (EditText) findViewById(R.id.licence_number_edit_text); final Bundle bundle = getIntent().getExtras(); namePassed = bundle.getString("name"); dLicense = bundle.getString("licence_number"); plateNumberObtained = bundle.getString("plate_number"); driverUid = bundle.getString("driverUid"); vehicleUid = bundle.getString("vehicleUid"); try { invalidLicence = bundle.getString("invalidLicence"); expiredInsuarance = bundle.getString("expiredInsuarance"); } catch (NullPointerException e) { } if (dLicense.equals("") || dLicense == null) { licenceNumberEdit.setVisibility(View.VISIBLE); } else if (plateNumberObtained.equals("") || plateNumberObtained == null) { plateNumberEdit.setVisibility(View.VISIBLE); } submit = (TextView) findViewById(R.id.submit_text); plateNo = (TextView) findViewById(R.id.plate_no_); chargesAcceptance = (TextView) findViewById(R.id.charges_acceptance); chargesAcceptance.setTypeface(MainOffence.Roboto_Regular); offensesCommittedTextview = (TextView) findViewById(R.id.offences_committed_title); offensesCommittedTextview.setTypeface(MainOffence.Roboto_BoldCondensed); ChargesAcceptanceTitle = (TextView) findViewById(R.id.charges_acceptance_title); paymentMethodTitle = (TextView) findViewById(R.id.payment_method_title); PaymentTitle = (TextView) findViewById(R.id.payment_title); ChargesAcceptanceTitle.setTypeface(MainOffence.Roboto_BoldCondensed); paymentMethodTitle.setTypeface(MainOffence.Roboto_BoldCondensed); PaymentTitle.setTypeface(MainOffence.Roboto_BoldCondensed); offencesCostTitle = (TextView) findViewById(R.id.offences_cost_title); offencesCostTitle.setTypeface(MainOffence.Roboto_BoldCondensed); submitText = (TextView) findViewById(R.id.submit_text); license = (TextView) findViewById(R.id.license); license.setText(dLicense); report = (RelativeLayout) findViewById(R.id.report); summary = (RelativeLayout) findViewById(R.id.summary); submit_layout = (RelativeLayout) findViewById(R.id.submit_layout); submit_layout1 = (RelativeLayout) findViewById(R.id.submit_layout1); submit_layout1.setVisibility(View.GONE); progressBar = (ProgressBar) findViewById(R.id.pbar_report); TextView driverName = (TextView) findViewById(R.id.driver_name); driverName.setTypeface(MainOffence.Roboto_BoldCondensed); TextView plateNumberTitle = (TextView) findViewById(R.id.plate_no_title_); plateNumberTitle.setTypeface(MainOffence.Roboto_BoldCondensed); TextView driverLicense = (TextView) findViewById(R.id.driver_license); driverLicense.setTypeface(MainOffence.Roboto_BoldCondensed); RelativeLayout OffenseType = (RelativeLayout) findViewById(R.id.offense_type); OffenseType.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(OffenceReportForm.this, OffenseListActivity.class); OffenceReportForm.this.startActivityForResult(intent, REPORT_RESULT); } }); offense_type_text = (TextView) findViewById(R.id.offense_type_text); offencesSelectedTextView = (TextView) findViewById(R.id.offence_list); offensesCommittedTextview = (TextView) findViewById(R.id.offences_committed); TextView name = (TextView) findViewById(R.id.name); name.setText(namePassed); final RadioButton court = (RadioButton) findViewById(R.id.court); court.setTypeface(MainOffence.Roboto_BoldCondensed); final RadioButton guilty = (RadioButton) findViewById(R.id.guilty); guilty.setTypeface(MainOffence.Roboto_BoldCondensed); guilty.setChecked(true); court.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { guilty.setChecked(false); commit = false; } } }); guilty.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { court.setChecked(false); commit = true; } } }); final String[] paymentMethodsArray = this.getResources().getStringArray(R.array.payment_methods); final Spinner paymentMethodSpinner = (Spinner) findViewById(R.id.payment_method_spinner); final RadioButton paid = (RadioButton) findViewById(R.id.paid); paid.setTypeface(MainOffence.Roboto_Regular); final RadioButton not_paid = (RadioButton) findViewById(R.id.not_paid); final TextView receipt_title = (TextView) findViewById(R.id.receipt_title); receiptEditText = (EditText) findViewById(R.id.receipt); receipt_title.setTypeface(MainOffence.Roboto_BoldCondensed); not_paid.setTypeface(MainOffence.Roboto_Regular); not_paid.setChecked(true); paymentMethodSpinner.setBackground(null); paid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { paymentStatus = true; paymentMethodTitle.setVisibility(View.VISIBLE); paymentMethodSpinner.setVisibility(View.VISIBLE); paymentMethod = paymentMethodsArray[0]; paymentMethodSpinner.setSelection(0); receipt_title.setVisibility(View.VISIBLE); receiptEditText.setVisibility(View.VISIBLE); } } }); not_paid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { paymentStatus = false; paymentMethodTitle.setVisibility(View.GONE); paymentMethodSpinner.setVisibility(View.GONE); receipt_title.setVisibility(View.GONE); receiptEditText.setVisibility(View.GONE); paymentMethod = ""; receiptEditText.setText(""); } } }); PaymentMethodSpinnerAdapter adapter = new PaymentMethodSpinnerAdapter( getSupportActionBar().getThemedContext(), R.layout.row_menu, paymentMethodsArray); paymentMethodSpinner.setAdapter(adapter); paymentMethodSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { paymentMethod = paymentMethodsArray[position]; if (position == 0) { receiptEditText.setVisibility(View.VISIBLE); receipt_title.setVisibility(View.VISIBLE); } else { receiptEditText.setVisibility(View.GONE); receipt_title.setVisibility(View.GONE); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }
From source file:edu.berkeley.boinc.attach.BatchConflictListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { final ProjectAttachWrapper listItem = entries.get(position); if (Logging.VERBOSE) Log.d(Logging.TAG, "BatchConflictListAdapter.getView for: " + listItem.name + " at position: " + position + " with result: " + listItem.result); LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = vi.inflate(R.layout.attach_project_batch_conflicts_listitem, null); TextView name = (TextView) v.findViewById(R.id.name); name.setText(listItem.name);/*from w w w .j a v a2 s . c o m*/ TextView status = (TextView) v.findViewById(R.id.status); ImageView resolveIv = (ImageView) v.findViewById(R.id.resolve_button_image); ImageView statusImage = (ImageView) v.findViewById(R.id.status_image); ProgressBar statusPb = (ProgressBar) v.findViewById(R.id.status_pb); RelativeLayout itemWrapper = (RelativeLayout) v.findViewById(R.id.resolve_item_wrapper); if (listItem.result == ProjectAttachWrapper.RESULT_SUCCESS) { // success status.setVisibility(View.GONE); resolveIv.setVisibility(View.GONE); statusPb.setVisibility(View.GONE); statusImage.setVisibility(View.VISIBLE); statusImage.setImageDrawable(activity.getResources().getDrawable(R.drawable.checkb)); } else if (listItem.result == ProjectAttachWrapper.RESULT_ONGOING || listItem.result == ProjectAttachWrapper.RESULT_UNINITIALIZED) { // ongoing status.setVisibility(View.GONE); resolveIv.setVisibility(View.GONE); statusImage.setVisibility(View.GONE); statusPb.setVisibility(View.VISIBLE); } else if (listItem.result == ProjectAttachWrapper.RESULT_READY) { // ready status.setVisibility(View.VISIBLE); status.setText(listItem.getResultDescription()); resolveIv.setVisibility(View.VISIBLE); itemWrapper.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Logging.DEBUG) Log.d(Logging.TAG, "BatchConflictListAdapter: start resolution dialog for: " + listItem.name); IndividualCredentialInputFragment dialog = IndividualCredentialInputFragment .newInstance(listItem); dialog.show(fmgr, listItem.name); } }); } else if (listItem.result == ProjectAttachWrapper.RESULT_CONFIG_DOWNLOAD_FAILED) { // download failed, can not continue from here. // if user wants to retry, need to go back to selection activity status.setVisibility(View.VISIBLE); status.setText(listItem.getResultDescription()); resolveIv.setVisibility(View.GONE); statusPb.setVisibility(View.GONE); statusImage.setVisibility(View.VISIBLE); statusImage.setImageDrawable(activity.getResources().getDrawable(R.drawable.failedb)); } else { // failed status.setVisibility(View.VISIBLE); status.setText(listItem.getResultDescription()); resolveIv.setVisibility(View.VISIBLE); itemWrapper.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Logging.DEBUG) Log.d(Logging.TAG, "BatchConflictListAdapter: start resolution dialog for: " + listItem.name); IndividualCredentialInputFragment dialog = IndividualCredentialInputFragment .newInstance(listItem); dialog.show(fmgr, listItem.name); } }); statusPb.setVisibility(View.GONE); statusImage.setVisibility(View.VISIBLE); statusImage.setImageDrawable(activity.getResources().getDrawable(R.drawable.failedb)); } return v; }
From source file:com.equinox.prodriver.Activities.RegisterDriverActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register_driver); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from ww w. jav a2 s. c om getSupportActionBar().setDisplayHomeAsUpEnabled(true); context = this; appBarLayout = (AppBarLayout) findViewById(R.id.app_bar); appBarLayout.setExpanded(false, true); mainScrollView = (NestedScrollView) findViewById(R.id.content_register_driver); mainScrollView.setSmoothScrollingEnabled(true); selectorsLayouts = new ArrayList<>(); editDriver = new Driver(); preferredPlace = new PrologixPlace(); if (currentDriver == null) { getSupportActionBar().setTitle(getString(R.string.title_activity_register_driver)); if (savedInstanceState != null && savedInstanceState.getBoolean("EDITING")) { editDriver = tempDriver; if (editDriver == null) editDriver = new Driver(); } vehiclesList = new ArrayList<>(); } else { getSupportActionBar().setTitle(getString(R.string.title_activity_update_driver)); editDriver = currentDriver.clone(); if (editDriver.getPreferredAddress() != null) { preferredPlace.setAddress( driverGson.fromJson(driverGson.toJson(editDriver.getPreferredAddress()), GeoAddress.class)); preferredPlace.setLocation( driverGson.fromJson(driverGson.toJson(editDriver.getPreferredLocation()), LatLng.class)); } } storagePermission = new PermissionManager(this); if (!storagePermission.checkReadStoragePermission()) storagePermission.getReadStoragePermission(); registerEmailHeaderFragment = RegisterEmailHeaderFragment.newInstance(editDriver); vehicleIndicator = (ImageView) findViewById(R.id.driver_vehicle_indicator); if (editDriver.getVehicles() == null) editDriver.setVehicles(new ArrayList<Vehicle>()); vehicleRecyclerAdapter = new VehicleRecyclerAdapter(context, editDriver.getVehicles(), false); if (!editDriver.getVehicles().isEmpty()) setIndicator(context, vehicleIndicator, true); if (!editDriver.getVehicles().contains(createVehicle)) { editDriver.getVehicles().add(new Vehicle()); //TODO remove this.. just for testing only /*String vehicleId = "SA-3184VLB"; DriverTask driverTask = new DriverTask(vehicleFetcher, "en"); driverTask.getVehicle.execute(vehicleId);*/ } vehicleListView = (RecyclerView) findViewById(R.id.vehicle_list_view); vehicleListView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); vehicleListView.setHasFixedSize(true); vehicleListView.setAdapter(vehicleRecyclerAdapter); vehicleListView.setNestedScrollingEnabled(false); licenseIndicator = (ImageView) findViewById(R.id.license_info_indicator); licenseValueNumber = (TextView) findViewById(R.id.license_info_number); licenseValueExpiry = (TextView) findViewById(R.id.license_info_expiry); licenseImage = (ImageView) findViewById(R.id.license_image); licenseImageLoaded = (NetworkImageView) findViewById(R.id.license_image_loaded); licenseInfoLayout = (RelativeLayout) findViewById(R.id.license_info_layout); if (editDriver.getLicenseNumber() != null) { setIndicator(context, licenseIndicator, true); licenseValueNumber.setText(editDriver.getLicenseNumber()); licenseValueExpiry.setText(StringManipulation.getFormattedDate(editDriver.getLicenseExpiry())); if (editDriver.getLicenseImage() != null) licenseImageLoaded.setImageUrl(editDriver.getLicenseImage(), DataHolder.getInstance().getImageLoader()); } if (photo1 != null) licenseImage.setImageBitmap(photo1); licenseInfoLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent scanIdIntent = new Intent(context, CameraVisionActivity.class); scanIdIntent.putExtra("source", REQUEST_DRIVER_LICENSE); startActivity(scanIdIntent); } }); residenceIndicator = (ImageView) findViewById(R.id.residence_info_indicator); residenceValueNumber = (TextView) findViewById(R.id.residence_info_number); residenceValueExpiry = (TextView) findViewById(R.id.residence_info_expiry); residenceValueLegalName = (TextView) findViewById(R.id.residence_info_legal_name); residenceImage = (ImageView) findViewById(R.id.residence_image); residenceImageLoaded = (NetworkImageView) findViewById(R.id.residence_image_loaded); residenceInfoLayout = (RelativeLayout) findViewById(R.id.residence_info_layout); if (editDriver.getResidenceNumber() != null) { setIndicator(context, residenceIndicator, true); residenceValueNumber.setText(editDriver.getResidenceNumber()); residenceValueLegalName.setText(editDriver.getLegalName()); if (editDriver.getResidenceImage() != null) residenceImageLoaded.setImageUrl(editDriver.getResidenceImage(), DataHolder.getInstance().getImageLoader()); } if (photo2 != null) residenceImage.setImageBitmap(photo2); residenceInfoLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent scanIdIntent = new Intent(context, CameraVisionActivity.class); scanIdIntent.putExtra(SOURCE, REQUEST_RESIDENCE_ID); startActivity(scanIdIntent); } }); nationalityIndicator = (ImageView) findViewById(R.id.nationality_indicator); nationalityValue = (TextView) findViewById(R.id.nationality_value); nationalityLayout = (RelativeLayout) findViewById(R.id.nationality_layout); nationalityProgressLayout = (LinearLayout) findViewById(R.id.nationality_progress_layout); final RelativeLayout nationalitySelector = (RelativeLayout) findViewById(R.id.nationality_selector); selectorsLayouts.add(nationalitySelector); nationalitySelectorContent = (LinearLayout) findViewById(R.id.nationality_selector_content); countryTask = new CountryTask(countryListHandler, "en"); countryTask.getCountryList.execute("en"); if (editDriver.getNationality() != null) { setIndicator(context, nationalityIndicator, true); nationalityValue.setText(editDriver.getNationality().getCountryName()); } nationalityAuto = (InstantAutoComplete) findViewById(R.id.nationality_auto); nationalityLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (nationalitySelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, nationalitySelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, nationalityLayout.getTop()); nationalityAuto.showDropDown(); } }, 1000); } if (countryTask.getCountryList.getStatus().equals(AsyncTask.Status.RUNNING)) { nationalityProgressLayout.setVisibility(View.VISIBLE); nationalitySelectorContent.setVisibility(View.GONE); } LinearLayout okayButton = (LinearLayout) findViewById(R.id.nationality_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (editDriver.getNationality() != null) { setIndicator(context, nationalityIndicator, true); nationalityValue.setText(editDriver.getNationality().getCountryName()); addressLayout.postDelayed(new Runnable() { @Override public void run() { addressLayout.performClick(); } }, 1000); } else { setIndicator(context, nationalityIndicator, false); nationalitySelector.setVisibility(View.GONE); } } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.nationality_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { nationalitySelector.setVisibility(View.GONE); } }); } }); addressIndicator = (ImageView) findViewById(R.id.preferred_address_indicator); addressValue = (TextView) findViewById(R.id.preferred_address_value); addressLayout = (RelativeLayout) findViewById(R.id.preferred_address_layout); if (editDriver.getPreferredAddress() != null) { setIndicator(context, addressIndicator, true); preferredPlace.setAddress(transform(editDriver.getPreferredAddress())); preferredPlace.setLocation(transform(editDriver.getPreferredLocation())); addressValue.setText(preferredPlace.getAddress().getFullAddress()); } addressChooser = (FrameLayout) findViewById(R.id.preferred_address_chooser); selectorsLayouts.add(addressChooser); addressLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); try { if (addressChooser.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, addressChooser); getSupportFragmentManager().beginTransaction() .replace(R.id.preferred_address_chooser, PlaceChooserFragment.newInstance(preferredPlace, placeChooseHandler)) .commit(); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, addressLayout.getTop()); } }, 1500); } else { addressChooser.setVisibility(View.GONE); getSupportFragmentManager().popBackStack(); } } catch (Resources.NotFoundException | OutOfMemoryError ignored) { } } }); final ImageView phoneIndicator = (ImageView) findViewById(R.id.driver_phone_indicator); final TextView phoneValue = (TextView) findViewById(R.id.driver_phone_value); if (editDriver.getPhoneNumber() != null) { setIndicator(context, phoneIndicator, true); phoneValue.setText(editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "")); } final LinearLayout phoneSelector = (LinearLayout) findViewById(R.id.driver_phone_selector); selectorsLayouts.add(phoneSelector); phoneLayout = (RelativeLayout) findViewById(R.id.driver_phone_layout); phoneLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (phoneSelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, phoneSelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, phoneLayout.getTop()); } }, 1000); } final EditText input = (EditText) findViewById(R.id.phone_number); if (editDriver.getPhoneNumber() != null) input.setText(editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "")); TextView phoneCode = (TextView) findViewById(R.id.country_code); phoneCode.setText(currentCountry.getPhoneCode()); NetworkImageView countryFlag = (NetworkImageView) findViewById(R.id.country_flag); countryFlag.setImageUrl(currentCountry.getFlag(), DataHolder.getInstance().getImageLoader()); LinearLayout okayButton = (LinearLayout) findViewById(R.id.driver_phone_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!input.getText().toString().isEmpty()) { String phoneNumberEdit = currentCountry.getPhoneCode() + input.getText().toString().replaceAll(" ", ""); editDriver.setPhoneNumber(phoneNumberEdit); phoneValue.setText(phoneNumberEdit); setIndicator(context, phoneIndicator, true); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, dobLayout.getTop()); } }, 1000); } else { phoneValue.setText(getString(R.string.driver_phone_hint)); setIndicator(context, phoneIndicator, false); } phoneSelector.setVisibility(View.GONE); } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.driver_phone_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { phoneSelector.setVisibility(View.GONE); } }); } }); dobValue = (TextView) findViewById(R.id.driver_dob_value); if (editDriver.getDob() != null) dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); dobLayout = (RelativeLayout) findViewById(R.id.driver_dob_layout); dobLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Calendar calendar = Calendar.getInstance(); if (editDriver.getDob() != null) { dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); calendar.setTimeInMillis(editDriver.getDob()); } DatePickerDialog datePickerDialog = DatePickerDialog .newInstance(new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) { calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, monthOfYear); calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); editDriver.setDob(calendar.getTimeInMillis()); dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); datePickerDialog.show(getFragmentManager(), "Datepickerdialog"); } }); final TextView genderValue = (TextView) findViewById(R.id.driver_gender_value); if (editDriver.getGender() != null) genderValue.setText( editDriver.getGender() ? getString(R.string.male_option) : getString(R.string.female_option)); final LinearLayout genderSelector = (LinearLayout) findViewById(R.id.driver_gender_selector); selectorsLayouts.add(genderSelector); final RelativeLayout genderLayout = (RelativeLayout) findViewById(R.id.driver_gender_layout); genderLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (genderSelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, genderSelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, genderLayout.getTop()); } }, 1000); } else genderSelector.setVisibility(View.GONE); final int checkedPos = editDriver.getGender() == null ? -1 : (editDriver.getGender() ? R.id.driver_gender_male : R.id.driver_gender_female); final RadioGroup insuranceRadioGroup = (RadioGroup) findViewById(R.id.driver_gender_radio_group); if (checkedPos != -1) insuranceRadioGroup.check(checkedPos); LinearLayout okayButton = (LinearLayout) findViewById(R.id.driver_gender_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switch (insuranceRadioGroup.getCheckedRadioButtonId()) { case R.id.driver_gender_male: editDriver.setGender(true); genderValue.setText(getString(R.string.male_option)); break; case R.id.driver_gender_female: editDriver.setGender(false); genderValue.setText(getString(R.string.female_option)); break; default: break; } mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, 0); } }, 500); appBarLayout.postDelayed(new Runnable() { @Override public void run() { appBarLayout.setExpanded(true, true); } }, 1500); } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.driver_gender_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { genderSelector.setVisibility(View.GONE); } }); } }); //TODO image analyis on IDs (license) and cross check with profile photo1, or maybe selfie uploadCount = new AtomicInteger(0); saveDriverAction = (FloatingActionButton) findViewById(R.id.fab_save_id); saveDriverAction.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean error = false; hideKeyboard(context); if (editDriver.getVehicles().size() == 1) { setIndicator(context, vehicleIndicator, false); error = true; } if (licenseImage.getDrawable() == null || editDriver.getLicenseExpiry() == null || editDriver.getLicenseNumber() == null) { setIndicator(context, licenseIndicator, false); error = true; } if (residenceImage.getDrawable() == null || editDriver.getResidenceNumber() == null) { setIndicator(context, residenceIndicator, false); error = true; } if (editDriver.getNationality() == null) { setIndicator(context, nationalityIndicator, false); error = true; } if (editDriver.getPreferredAddress() == null) { setIndicator(context, addressIndicator, false); error = true; } if (editDriver.getPhoneNumber() == null || editDriver.getPhoneNumber().isEmpty()) { setIndicator(context, phoneIndicator, false); error = true; } if (user == null && !registerEmailHeaderFragment.setCustomerValues()) error = true; if (error) Snackbar.make(view, getString(R.string.incorrect_driver_data_message), Snackbar.LENGTH_LONG) .show(); else if (user != null) { signUpAnalytics(user.getProviderId()); editDriver.getVehicles().remove(editDriver.getVehicles().size() - 1); uploadImage("driver_license_snapshot", "image_" + editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "") + "_" + editDriver.getLicenseNumber() + ".jpg", ((BitmapDrawable) licenseImage.getDrawable()).getBitmap(), REQUEST_DRIVER_LICENSE); uploadImage("driver_residence_snapshot", "image_" + editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "") + "_" + editDriver.getResidenceNumber() + ".jpg", ((BitmapDrawable) residenceImage.getDrawable()).getBitmap(), REQUEST_RESIDENCE_ID); crossFade(context, findViewById(R.id.driver_progress_layout), findViewById(R.id.driver_main_layout), null); //TODO verify registration details for duplicate, correctness, etc } } }); imageUploadStatus = (TextSwitcher) findViewById(R.id.image_upload_status); imageUploadStatus.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView switcherTextView = new TextView(getApplicationContext()); switcherTextView.setTextSize(16); switcherTextView.setTypeface(null, Typeface.BOLD); switcherTextView.setText(getString(R.string.uploading_images)); switcherTextView.setTextColor(getResources().getColor(R.color.colorAccent)); return switcherTextView; } }); Animation animationOut = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); Animation animationIn = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); imageUploadStatus.setOutAnimation(animationOut); imageUploadStatus.setInAnimation(animationIn); }
From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fabric.with(this, new Crashlytics()); ActionBar actionbar = getSupportActionBar(); if (actionbar != null) { actionbar.show();//from w w w . j a v a2 s.co m } // ????APK???????BG???onCreate??Activity?? // Intent?????????????? if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { finish(); return; } if (!isRunningJunit) { setContentView(R.layout.activity_main); FirebaseRemoteConfigUtil.initialize(); LikeView likeView = (LikeView) findViewById(R.id.like_view); likeView.setObjectIdAndType(String.format(getString(R.string.app_googlePlay_url), getPackageName()), LikeView.ObjectType.PAGE); // Create the interstitial. mInterstitialAd = new InterstitialAd(this); mInterstitialAd.setAdUnitId(getString(R.string.ad_mob_id)); // Create ad request. final AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators .addTestDevice("1BEC3806A9717F2A87F4D1FC2039D5F2") // An device ID ASUS .addTestDevice("64D37FCE47B679A7F4639D180EC4C547").build(); // Begin loading your interstitial. mInterstitialAd.loadAd(adRequest); mInterstitialAd.setAdListener(new AdListener() { @Override public void onAdLeftApplication() { super.onAdLeftApplication(); enableNewFunction = true; supportInvalidateOptionsMenu(); } @Override public void onAdClosed() { super.onAdClosed(); // ????????????? if (!enableNewFunction) { // Begin loading your interstitial. mInterstitialAd.loadAd(adRequest); } else { LayoutInflater inflater = LayoutInflater.from(MainActivity.this); final View layout = inflater.inflate(R.layout.new_function_dialog, (ViewGroup) findViewById(R.id.layout_root_new)); new MaterialStyledDialog(MainActivity.this).setTitle("?").setDescription( "????????\n???????????") .setCustomView(layout).setIcon(R.drawable.ic_fiber_new_white_48dp) .setHeaderDrawable(R.drawable.pattern_bg_blue) .setPositive(getString(R.string.ok), null).show(); RealmUtil.insertHistoryItemAsync(realm, createHistoryItemData(), new RealmUtil.realmTransactionCallbackListener() { @Override public void OnSuccess() { } @Override public void OnError() { } }); } } }); // FIXME : ?????? AdView mAdView = (AdView) findViewById(R.id.adView); // mAdView.loadAd(adRequest); DefaultLayoutPromptView promptView = (DefaultLayoutPromptView) findViewById(R.id.prompt_view); final BasePromptViewConfig basePromptViewConfig = new BasePromptViewConfig.Builder() .setUserOpinionQuestionTitle(getString(R.string.prompt_title)) .setUserOpinionQuestionPositiveButtonLabel(getString(R.string.prompt_btn_yes)) .setUserOpinionQuestionNegativeButtonLabel(getString(R.string.prompt_btn_no)) .setPositiveFeedbackQuestionTitle(getString(R.string.prompt_title_feedback)) .setPositiveFeedbackQuestionPositiveButtonLabel(getString(R.string.prompt_btn_sure)) .setPositiveFeedbackQuestionNegativeButtonLabel(getString(R.string.prompt_btn_notnow)) .setCriticalFeedbackQuestionTitle(getString(R.string.prompt_title_feedback_2)) .setCriticalFeedbackQuestionNegativeButtonLabel(getString(R.string.prompt_btn_notnow)) .setCriticalFeedbackQuestionPositiveButtonLabel(getString(R.string.prompt_btn_sure)) .setThanksTitle(getString(R.string.prompt_thanks)).build(); promptView.applyBaseConfig(basePromptViewConfig); Amplify.getSharedInstance().promptIfReady(promptView); mAnimationBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink); int buttonColor = ContextCompat.getColor(this, R.color.colorPrimary); int buttonPressedColor = ContextCompat.getColor(this, R.color.colorPrimaryDark); mbtnStart = (ActionButton) findViewById(R.id.fabStart); mbtnStart.setButtonColor(buttonColor); mbtnStart.setButtonColorPressed(buttonPressedColor); // ? new MaterialIntroView.Builder(this).enableDotAnimation(false).enableIcon(true) .setFocusGravity(FocusGravity.CENTER).setFocusType(Focus.MINIMUM).setDelayMillis(500) .enableFadeAnimation(true).performClick(true).setInfoText(getString(R.string.intro_description)) .setTarget(mbtnStart).setUsageId(TUTORIAL_ID) //THIS SHOULD BE UNIQUE ID .dismissOnTouch(true).show(); mbtnStart.setOnClickListener(this); Intent mAlertServiceIntent = new Intent(MainActivity.this, AlertService.class); // ?????????????(???????) // ???????? if (!Utility.isTabletNotPhone(this)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } mTwitter = TwitterUtility.getTwitterInstance(this); mCallbackURL = getString(R.string.twitter_callback_url); mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button); // Refresh the state of the +1 button each time the activity receives focus. mPlusOneButton.initialize( String.format(getString(R.string.app_googlePlay_url_plusOne), getPackageName()), PLUS_ONE_REQUEST_CODE); RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.rtlMain); relativeLayout.setOnClickListener(this); findViewById(R.id.llStepCount).setVisibility(mShouldShowPedometer ? View.VISIBLE : View.INVISIBLE); // // Service?????Activity?Destroy????Activity?????? // // UI?Service????????Service??????????Bind???????? // // Application???? // if (((AlertApplication) getApplication()).IsRunningService()) { // btnIsStarted = false; // setStartButtonFunction(findViewById(R.id.fabStart)); // } // // startService(mAlertServiceIntent); bindService(mAlertServiceIntent, mConnection, Context.BIND_AUTO_CREATE); } mIsToastOn = SharedPreferencesUtil.getBoolean(this, SETTING_SHAREDPREF_NAME, "message", true); mIsVibrationOn = SharedPreferencesUtil.getBoolean(this, SETTING_SHAREDPREF_NAME, "vibrate", true); mToastPosition = SharedPreferencesUtil.getInt(this, SETTING_SHAREDPREF_NAME, "toastPosition", Gravity.CENTER); mAlertStartAngle = SharedPreferencesUtil.getInt(this, SETTING_SHAREDPREF_NAME, "progress", ALERT_ANGLE_INITIAL_VALUE) + ALERT_ANGLE_INITIAL_OFFSET; mShouldShowPedometer = SharedPreferencesUtil.getBoolean(this, SETTING_SHAREDPREF_NAME, "pedometer", true); // ?????(update??) or ??? enableNewFunction = RealmUtil.hasHistoryItem(realm) || SharedPreferencesUtil.getBoolean(this, AD_STATUS_SHAREDPREF_NAME, "AD_STATUS_SHAREDPREF_NAME", false); }
From source file:com.example.search.car.pools.welcome.java
public void dialog(String name, final String[] arr, final TextView tv) { final Dialog dialog = new Dialog(welcome.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.setContentView(R.layout.dialog); final ListView list = (ListView) dialog.findViewById(R.id.list_cities); DialogAdapter adapter = new DialogAdapter(welcome.this, arr); list.setAdapter(adapter);//from w w w.jav a 2 s . co m final TextView t = (TextView) dialog.findViewById(R.id.tv_1_send_msg); t.setText("Select " + name); Typeface tf = Typeface.createFromAsset(welcome.this.getAssets(), "AvenirLTStd_Book.otf"); t.setTypeface(tf); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { tv.setText(arr[position]); dialog.dismiss(); } }); final RelativeLayout l_close = (RelativeLayout) dialog.findViewById(R.id.l_close); l_close.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub dialog.dismiss(); } }); dialog.show(); }
From source file:com.breadwallet.presenter.fragments.FragmentSettings.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // The last two arguments ensure LayoutParams are inflated // properly./*from ww w .ja va2 s. c o m*/ View rootView = inflater.inflate(R.layout.fragment_settings, container, false); app = MainActivity.app; fragmentSettings = this; initList(); RelativeLayout about = (RelativeLayout) rootView.findViewById(R.id.about); TextView currencyName = (TextView) rootView.findViewById(R.id.three_letters_currency); RelativeLayout changePassword = (RelativeLayout) rootView.findViewById(R.id.change_password); final String tmp = SharedPreferencesManager.getIso(getActivity()); currencyName.setText(tmp); RelativeLayout localCurrency = (RelativeLayout) rootView.findViewById(R.id.local_currency); RelativeLayout recoveryPhrase = (RelativeLayout) rootView.findViewById(R.id.recovery_phrase); RelativeLayout startRecoveryWallet = (RelativeLayout) rootView.findViewById(R.id.start_recovery_wallet); RelativeLayout fingerprintLimit = (RelativeLayout) rootView.findViewById(R.id.fingerprint_limit); RelativeLayout earlyAccess = (RelativeLayout) rootView.findViewById(R.id.early_access); RelativeLayout line5 = (RelativeLayout) rootView.findViewById(R.id.settings_line_5); TextView theLimit = (TextView) rootView.findViewById(R.id.fingerprint_limit_text); RelativeLayout rescan = (RelativeLayout) rootView.findViewById(R.id.rescan_blockchain); theLimit.setText(BRStringFormatter.getFormattedCurrencyString("BTC", PassCodeManager.getInstance().getLimit(getActivity()))); FingerprintManager mFingerprintManager; mFingerprintManager = (FingerprintManager) getActivity().getSystemService(Context.FINGERPRINT_SERVICE); boolean useFingerPrint; useFingerPrint = ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.USE_FINGERPRINT) == PackageManager.PERMISSION_GRANTED && mFingerprintManager.isHardwareDetected() && mFingerprintManager.hasEnrolledFingerprints(); if (!useFingerPrint) { fingerprintLimit.setVisibility(View.GONE); line5.setVisibility(View.GONE); } fingerprintLimit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { ((BreadWalletApp) getActivity().getApplicationContext()).promptForAuthentication(getActivity(), BRConstants.AUTH_FOR_LIMIT, null, null, null, null, false); } } }); startRecoveryWallet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { BRAnimator.pressWipeWallet(app, new FragmentWipeWallet()); app.activityButtonsEnable(false); } } }); recoveryPhrase.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { BRWalletManager.getInstance(getActivity()).animateSavePhraseFlow(); } }); about.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { BRAnimator.animateSlideToLeft(app, new FragmentAbout(), fragmentSettings); } } }); localCurrency.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { BRAnimator.animateSlideToLeft(app, new FragmentCurrency(), fragmentSettings); } } }); changePassword.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { final android.app.FragmentManager fm = getActivity().getFragmentManager(); new PasswordDialogFragment().show(fm, PasswordDialogFragment.class.getName()); } } } ); rescan.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { new Thread(new Runnable() { @Override public void run() { BRAnimator.goToMainActivity(fragmentSettings); BRPeerManager.getInstance(getActivity()).rescan(); SharedPreferencesManager.putStartHeight(getActivity(), 0); } }).start(); } } } ); //keep it hidden until finished if (!PLATFORM_ON) { earlyAccess.setVisibility(View.GONE); rootView.findViewById(R.id.early_access_separator).setVisibility(View.GONE); rootView.findViewById(R.id.early_access_separator2).setVisibility(View.GONE); } else { earlyAccess.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (BRAnimator.checkTheMultipressingAvailability()) { BRAnimator.animateSlideToLeft(app, new FragmentWebView(), fragmentSettings); } } }); } return rootView; }
From source file:com.ivalentin.margolariak.SettingsLayout.java
/** * Run when the fragment is inflated.// w w w.j av a 2 s . c o m * Assigns the view and the click listeners. * * @param inflater A LayoutInflater to manage views * @param container The container View * @param savedInstanceState Bundle containing the state * * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) */ @SuppressLint("InflateParams") //Throws unknown error when done properly. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //Load the layout final View view = inflater.inflate(R.layout.fragment_layout_settings, null); //Set the title ((MainActivity) getActivity()).setSectionTitle(view.getContext().getString(R.string.menu_settings)); //Get views. RelativeLayout rlNotification = (RelativeLayout) view.findViewById(R.id.rl_settings_notifications); final CheckBox cbNotification = (CheckBox) view.findViewById(R.id.cb_settings_notifications); final TextView tvNotification = (TextView) view.findViewById(R.id.tv_settings_notifications_summary); TextView tvLicense = (TextView) view.findViewById(R.id.tv_setting_license); TextView tvPrivacy = (TextView) view.findViewById(R.id.tv_setting_privacy); TextView tvAbout = (TextView) view.findViewById(R.id.tv_setting_about); TextView tvTransparency = (TextView) view.findViewById(R.id.tv_setting_transparency); //Set initial state of the notification settings SharedPreferences settings = view.getContext().getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE); if (settings.getBoolean(GM.PREFERENCES.KEY.NOTIFICATIONS, GM.PREFERENCES.DEFAULT.NOTIFICATIONS)) { cbNotification.setChecked(true); tvNotification.setText(view.getContext().getString(R.string.settings_notification_on)); } else { cbNotification.setChecked(false); tvNotification.setText(view.getContext().getString(R.string.settings_notification_off)); } //Set click listener for "Notification" preference rlNotification.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (cbNotification.isChecked()) { cbNotification.setChecked(false); tvNotification.setText(view.getContext().getString(R.string.settings_notification_off)); SharedPreferences preferences = view.getContext() .getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean(GM.PREFERENCES.KEY.NOTIFICATIONS, false); editor.apply(); } else { cbNotification.setChecked(true); tvNotification.setText(view.getContext().getString(R.string.settings_notification_on)); SharedPreferences preferences = view.getContext() .getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean(GM.PREFERENCES.KEY.NOTIFICATIONS, true); editor.apply(); } } }); //Set listener for the other buttons tvLicense.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String title = v.getResources().getString(R.string.settings_license); String text = v.getResources().getString(R.string.settings_license_content); showDialog(title, text); } }); tvPrivacy.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String title = v.getResources().getString(R.string.settings_privacy); String text = v.getResources().getString(R.string.settings_privacy_content); showDialog(title, text); } }); tvAbout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String title = v.getResources().getString(R.string.settings_about); String text = v.getResources().getString(R.string.settings_about_content); showDialog(title, text); } }); tvTransparency.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String title = v.getResources().getString(R.string.settings_transparency); String text = v.getResources().getString(R.string.settings_transparency_content); showDialog(title, text); } }); return view; }
From source file:com.speed.traquer.app.TraqComplaintTaxi.java
private void PromptCustomDialog() { // Create custom dialog object final Dialog dialog = new Dialog(TraqComplaintTaxi.this); // Include dialog.xml file dialog.setContentView(R.layout.activity_submit_social); // Set dialog title dialog.setTitle("Submit via"); // set values for custom dialog components - text, image and button final TextView twitterText = (TextView) dialog.findViewById(R.id.textTwitterDialog); twitterText.setText("Twitter"); final TextView facebookText = (TextView) dialog.findViewById(R.id.textFacebookDialog); facebookText.setText("Facebook"); final TextView defaultText = (TextView) dialog.findViewById(R.id.textDefaultDialog); defaultText.setText("Default"); defaultText.setTextColor(getResources().getColor(R.color.Orange)); final TextView smsText = (TextView) dialog.findViewById(R.id.textSMSDialog); smsText.setText("SMS"); final ImageView image = (ImageView) dialog.findViewById(R.id.imageDialog); image.setImageResource(R.drawable.icon_twitter); final ImageView imageFb = (ImageView) dialog.findViewById(R.id.imageDialogFb); imageFb.setImageResource(R.drawable.ic_fb_grey); final ImageView imageDefault = (ImageView) dialog.findViewById(R.id.imageDialogDefault); imageDefault.setImageResource(R.drawable.icon_traquer_color); isDefaultSelected = true;/*ww w. j ava 2 s. co m*/ final ImageView imageSMS = (ImageView) dialog.findViewById(R.id.imageDialogSMS); imageSMS.setImageResource(R.drawable.icon_sms); dialog.show(); //Retrieve form info taxi_id = inputTaxi.getText().toString().toUpperCase(); taxi_id = taxi_id.replace(" ", ""); taxi_comp = actv_comp_taxi.getText().toString(); taxi_driver = taxiDriver.getText().toString(); taxi_license = taxiLic.getText().toString(); loc_frm = actv_from.getText().toString(); loc_to = actv_to.getText().toString(); dateBus = editDate.getText().toString(); timeBus = editTime.getText().toString(); curr_time = editCurrTime.getText().toString(); user_name = SaveSharedPreference.getUserName(TraqComplaintTaxi.this); //Twitter Button final RelativeLayout twitterLogin = (RelativeLayout) dialog.findViewById(R.id.twitterImageButton); twitterLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isTwitterSelected) { image.setImageResource(R.drawable.icon_twitter); twitterText.setTextColor(getResources().getColor(R.color.DarkGray)); isTwitterSelected = false; } else { loginToTwitter(); image.setImageResource(R.drawable.icon_twitter_blue); twitterText.setTextColor(getResources().getColor(R.color.TwitterBlue)); isTwitterSelected = true; } } }); //facebook Button final RelativeLayout facebookLogin = (RelativeLayout) dialog.findViewById(R.id.facebookImageButton); facebookLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isFacebookSelected) { imageFb.setImageResource(R.drawable.ic_fb_grey); if (fbUserName != null) facebookText.setText("Facebook"); facebookText.setTextColor(getResources().getColor(R.color.DarkGray)); isFacebookSelected = false; } else { //loginToTwitter(); // start Facebook Login loginToFacebook(); if (fbUserName != null) facebookText.setText(fbUserName); imageFb.setImageResource(R.drawable.ic_fb_blue); facebookText.setTextColor(getResources().getColor(R.color.TwitterBlue)); isFacebookSelected = true; } } }); //SMS Button final RelativeLayout SMSLogin = (RelativeLayout) dialog.findViewById(R.id.smsImageButton); SMSLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isSmsSelected) { imageSMS.setImageResource(R.drawable.icon_sms); smsText.setTextColor(getResources().getColor(R.color.DarkGray)); isSmsSelected = false; } else { imageSMS.setImageResource(R.drawable.icon_sms_color); smsText.setTextColor(getResources().getColor(R.color.Orange)); isSmsSelected = true; } } }); /*/Default Button final RelativeLayout defaultLogin = (RelativeLayout)dialog.findViewById(R.id.defaultImageButton); defaultLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(isDefaultSelected) { imageDefault.setImageResource(R.drawable.icon_traquer_color); defaultText.setTextColor(getResources().getColor(R.color.Orange)); isDefaultSelected = false; } else { imageDefault.setImageResource(R.drawable.icon_traquer_color); defaultText.setTextColor(getResources().getColor(R.color.Orange)); isDefaultSelected = true; } } });*/ //Submit Button Button declineButton = (Button) dialog.findViewById(R.id.submitButton); // if decline button is clicked, close the custom dialog declineButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //submit complaint isSubmitButtonClicked = true; if (isNetworkConnected() == true) { Toast.makeText(TraqComplaintTaxi.this, "Complaint sent. Thank you for taking action!", Toast.LENGTH_SHORT).show(); //Combine Strings for Twitter Status String status = taxi_id + ", " + taxi_comp + " taxi is speeding with " + speedTaxiExceed + "km/h at " + Double.toString(gLatitude) + "N, " + Double.toString(gLongitude) + "E, " + curr_time + " @aduanSPAD @MyTraquer #Traquer"; finalStatus = status; if (isFacebookSelected) { //share to facebook ShareToFacebook(status); //publishFeedDialog(); } if (isTwitterSelected) { //Toast.makeText(TraqComplaintTaxi.this, Long.toString(twitterID) + userName, Toast.LENGTH_SHORT).show(); // Check for blank text if (status.trim().length() > 0) { // update status if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR1) { new updateTwitterStatus().execute(status); } else new updateTwitterStatus().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, status); } else { // EditText is empty Toast.makeText(getApplicationContext(), "Please enter status message", Toast.LENGTH_SHORT).show(); } } else { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR1) new InsertForm().execute(); else new InsertForm().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } // Close dialog dialog.dismiss(); } else { if (isSmsSelected) { Log.i("Clicks", "You clicked sent."); Intent sendIntent = new Intent(Intent.ACTION_VIEW); sendIntent.putExtra("address", "15888"); sendIntent.putExtra("sms_body", "SPAD Aduan " + taxi_id + ", " + taxi_comp + " taxi is speeding with " + speedTaxiExceed + "km/h at " + Double.toString(gLatitude) + "N, " + Double.toString(gLongitude) + "E, " + curr_time + " - Traquer"); sendIntent.setType("vnd.android-dir/mms-sms"); startActivity(sendIntent); //1800-88-7723 } else { Toast.makeText(TraqComplaintTaxi.this, "Failed to send. Please check your network connection.", Toast.LENGTH_SHORT).show(); } } } }); //TraqComplaintTaxi.this.showDialog(ALERT_DIALOG); }
From source file:com.jaus.albertogiunta.justintrain_oraritreni.journeyFavourites.FavouriteJourneysActivity.java
@Override public boolean onItemClick(int position) { analyticsHelper.logScreenEvent(SCREEN_FAVOURITE_JOURNEYS, ACTION_NO_SWIPE_BUT_CLICK); Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); if (presenter.getRecyclerViewList().get(position) instanceof FavouriteJourneysItem) { boolean isFavourite = ((FavouriteJourneysItem) presenter.getRecyclerViewList().get(position)) .isPreferredInsteadOfRecent(); Log.d("onItemClick: ", position, presenter.getPreferredJourneys().size()); vibe.vibrate(25);/*from w w w . j a v a 2 s. c o m*/ PreferredJourney preferredJourney = ((FavouriteJourneysItem) presenter.getRecyclerViewList() .get(position)).getPreferredJourney(); AlertDialog.Builder alertDialog = new AlertDialog.Builder(FavouriteJourneysActivity.this); View view = LayoutInflater.from(FavouriteJourneysActivity.this) .inflate(R.layout.dialog_favourites_click, null); alertDialog.setView(view) .setPositiveButton("ANNULLA", (dialogInterface, i) -> dialogInterface.dismiss()).create(); Dialog dialog = alertDialog.show(); RelativeLayout rlSearchAR = view.findViewById(R.id.rl_search_ar); TextView searchAR = view.findViewById(R.id.tv_search_ar); RelativeLayout rlSearchRA = view.findViewById(R.id.rl_search_ra); TextView searchRA = view.findViewById(R.id.tv_search_ra); RelativeLayout rlRemoveFromList = view.findViewById(R.id.rl_remove_from_favourites); RelativeLayout rlTransformToFav = view.findViewById(R.id.rl_transform_into_favourites); searchAR.setText("Da " + preferredJourney.getStation1().getNameShort() + " a " + preferredJourney.getStation2().getNameShort()); searchRA.setText("Da " + preferredJourney.getStation2().getNameShort() + " a " + preferredJourney.getStation1().getNameShort()); if (!isFavourite) apply(rlTransformToFav, VISIBLE); else apply(rlTransformToFav, GONE); rlSearchAR.setOnClickListener(v -> { analyticsHelper.logScreenEvent(SCREEN_FAVOURITE_JOURNEYS, ACTION_AR_FROM_POPUP); Intent intent = new Intent(FavouriteJourneysActivity.this, JourneySearchActivity.class); intent.putExtra(I_STATIONS, gson.toJson(preferredJourney)); startActivity(intent); dialog.dismiss(); }); rlSearchRA.setOnClickListener(v -> { analyticsHelper.logScreenEvent(SCREEN_FAVOURITE_JOURNEYS, ACTION_RA_FROM_POPUP); Intent intent = new Intent(FavouriteJourneysActivity.this, JourneySearchActivity.class); intent.putExtra(I_STATIONS, gson.toJson(preferredJourney.swapStations())); startActivity(intent); dialog.dismiss(); }); rlRemoveFromList.setOnClickListener(v -> { analyticsHelper.logScreenEvent(SCREEN_FAVOURITE_JOURNEYS, ACTION_REMOVE_FROM_POPUP); if (isFavourite) { presenter.removeFavourite(preferredJourney.getStation1(), preferredJourney.getStation2()); } else { presenter.removeRecent(preferredJourney.getStation1(), preferredJourney.getStation2()); } updateFavouritesList(); btnSearch.animate().setInterpolator(new AccelerateDecelerateInterpolator()).translationY(0) .setDuration(0); dialog.dismiss(); }); rlTransformToFav.setOnClickListener(v -> { presenter.removeRecent(preferredJourney.getStation1(), preferredJourney.getStation2()); analyticsHelper.logScreenEvent(SCREEN_FAVOURITE_JOURNEYS, ACTION_TRANSFORM_TO_FAVS); presenter.addNewFavourite(preferredJourney.getStation1(), preferredJourney.getStation2()); updateFavouritesList(); btnSearch.animate().setInterpolator(new AccelerateDecelerateInterpolator()).translationY(0) .setDuration(0); dialog.dismiss(); }); } return false; }
From source file:com.mobicage.rogerthat.plugins.friends.ActionScreenActivity.java
@SuppressLint({ "SetJavaScriptEnabled", "JavascriptInterface", "NewApi" }) @Override//from ww w .j a v a2 s . c om public void onCreate(Bundle savedInstanceState) { if (CloudConstants.isContentBrandingApp()) { super.setTheme(android.R.style.Theme_Black_NoTitleBar_Fullscreen); } super.onCreate(savedInstanceState); setContentView(R.layout.action_screen); mBranding = (WebView) findViewById(R.id.branding); WebSettings brandingSettings = mBranding.getSettings(); brandingSettings.setJavaScriptEnabled(true); brandingSettings.setCacheMode(WebSettings.LOAD_DEFAULT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { brandingSettings.setAllowFileAccessFromFileURLs(true); } mBrandingHttp = (WebView) findViewById(R.id.branding_http); mBrandingHttp.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); WebSettings brandingSettingsHttp = mBrandingHttp.getSettings(); brandingSettingsHttp.setJavaScriptEnabled(true); brandingSettingsHttp.setCacheMode(WebSettings.LOAD_DEFAULT); if (CloudConstants.isContentBrandingApp()) { mSoundThread = new HandlerThread("rogerthat_actionscreenactivity_sound"); mSoundThread.start(); Looper looper = mSoundThread.getLooper(); mSoundHandler = new Handler(looper); int cameraPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA); if (cameraPermission == PackageManager.PERMISSION_GRANTED) { mQRCodeScanner = QRCodeScanner.getInstance(this); final LinearLayout previewHolder = (LinearLayout) findViewById(R.id.preview_view); previewHolder.addView(mQRCodeScanner.view); } mBranding.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { initFullScreenForContentBranding(); } }); mBrandingHttp.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { initFullScreenForContentBranding(); } }); } final View brandingHeader = findViewById(R.id.branding_header_container); final ImageView brandingHeaderClose = (ImageView) findViewById(R.id.branding_header_close); final TextView brandingHeaderText = (TextView) findViewById(R.id.branding_header_text); brandingHeaderClose .setColorFilter(UIUtils.imageColorFilter(getResources().getColor(R.color.mc_homescreen_text))); brandingHeaderClose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mQRCodeScanner != null) { mQRCodeScanner.onResume(); } brandingHeader.setVisibility(View.GONE); mBrandingHttp.setVisibility(View.GONE); mBranding.setVisibility(View.VISIBLE); mBrandingHttp.loadUrl("about:blank"); } }); final View brandingFooter = findViewById(R.id.branding_footer_container); if (CloudConstants.isContentBrandingApp()) { brandingHeaderClose.setVisibility(View.GONE); final ImageView brandingFooterClose = (ImageView) findViewById(R.id.branding_footer_close); final TextView brandingFooterText = (TextView) findViewById(R.id.branding_footer_text); brandingFooterText.setText(getString(R.string.back)); brandingFooterClose .setColorFilter(UIUtils.imageColorFilter(getResources().getColor(R.color.mc_homescreen_text))); brandingFooter.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mQRCodeScanner != null) { mQRCodeScanner.onResume(); } brandingHeader.setVisibility(View.GONE); brandingFooter.setVisibility(View.GONE); mBrandingHttp.setVisibility(View.GONE); mBranding.setVisibility(View.VISIBLE); mBrandingHttp.loadUrl("about:blank"); } }); } final RelativeLayout openPreview = (RelativeLayout) findViewById(R.id.preview_holder); openPreview.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mQRCodeScanner != null) { mQRCodeScanner.previewHolderClicked(); } } }); mBranding.addJavascriptInterface(new JSInterface(this), "__rogerthat__"); mBranding.setWebChromeClient(new WebChromeClient() { @Override public void onConsoleMessage(String message, int lineNumber, String sourceID) { if (sourceID != null) { try { sourceID = new File(sourceID).getName(); } catch (Exception e) { L.d("Could not get fileName of sourceID: " + sourceID, e); } } if (mIsHtmlContent) { L.i("[BRANDING] " + sourceID + ":" + lineNumber + " | " + message); } else { L.d("[BRANDING] " + sourceID + ":" + lineNumber + " | " + message); } } }); mBranding.setWebViewClient(new WebViewClient() { private boolean isExternalUrl(String url) { for (String regularExpression : mBrandingResult.externalUrlPatterns) { if (url.matches(regularExpression)) { return true; } } return false; } @SuppressLint("DefaultLocale") @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { L.i("Branding is loading url: " + url); Uri uri = Uri.parse(url); String lowerCaseUrl = url.toLowerCase(); if (lowerCaseUrl.startsWith("tel:") || lowerCaseUrl.startsWith("mailto:") || isExternalUrl(url)) { Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); return true; } else if (lowerCaseUrl.startsWith(POKE)) { String tag = url.substring(POKE.length()); poke(tag); return true; } else if (lowerCaseUrl.startsWith("http://") || lowerCaseUrl.startsWith("https://")) { if (mQRCodeScanner != null) { mQRCodeScanner.onPause(); } brandingHeaderText.setText(getString(R.string.loading)); brandingHeader.setVisibility(View.VISIBLE); if (CloudConstants.isContentBrandingApp()) { brandingFooter.setVisibility(View.VISIBLE); } mBranding.setVisibility(View.GONE); mBrandingHttp.setVisibility(View.VISIBLE); mBrandingHttp.loadUrl(url); return true; } else { brandingHeader.setVisibility(View.GONE); brandingFooter.setVisibility(View.GONE); mBrandingHttp.setVisibility(View.GONE); mBranding.setVisibility(View.VISIBLE); } return false; } @Override public void onPageFinished(WebView view, String url) { L.i("onPageFinished " + url); if (!mInfoSet && mService != null && mIsHtmlContent) { Map<String, Object> info = mFriendsPlugin.getRogerthatUserAndServiceInfo(mServiceEmail, mServiceFriend); executeJS(true, "if (typeof rogerthat !== 'undefined') rogerthat._setInfo(%s)", JSONValue.toJSONString(info)); mInfoSet = true; } } @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { L.i("Checking access to: '" + url + "'"); final URL parsedUrl; try { parsedUrl = new URL(url); } catch (MalformedURLException e) { L.d("Webview tried to load malformed URL"); return new WebResourceResponse("text/plain", "UTF-8", null); } if (!parsedUrl.getProtocol().equals("file")) { return null; } File urlPath = new File(parsedUrl.getPath()); if (urlPath.getAbsolutePath().startsWith(mBrandingResult.dir.getAbsolutePath())) { return null; } L.d("404: Webview tries to load outside its sandbox."); return new WebResourceResponse("text/plain", "UTF-8", null); } }); mBrandingHttp.setWebViewClient(new WebViewClient() { @SuppressLint("DefaultLocale") @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { L.i("BrandingHttp is loading url: " + url); return false; } @Override public void onPageFinished(WebView view, String url) { brandingHeaderText.setText(view.getTitle()); L.i("onPageFinished " + url); } }); Intent intent = getIntent(); mBrandingKey = intent.getStringExtra(BRANDING_KEY); mServiceEmail = intent.getStringExtra(SERVICE_EMAIL); mItemTagHash = intent.getStringExtra(ITEM_TAG_HASH); mItemLabel = intent.getStringExtra(ITEM_LABEL); mItemCoords = intent.getLongArrayExtra(ITEM_COORDS); mRunInBackground = intent.getBooleanExtra(RUN_IN_BACKGROUND, true); }