List of usage examples for android.app Dialog requestWindowFeature
public final boolean requestWindowFeature(int featureId)
From source file:com.birdeye.MainActivity.java
@Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.logout: fullReset();/*w ww . jav a 2s .com*/ startActivity(LoginActivity.create(this)); finish(); return true; case R.id.About: final Dialog dialog2 = new Dialog(MainActivity.this); dialog2.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog2.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog2.setContentView(R.layout.about); dialog2.setCancelable(false); dialog2.show(); return true; case R.id.ShareApp: Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/html"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml( "<p>Hey, am using this really cool hashtag activated camera app. Get it here #birdeyecamera.</p>")); startActivity(Intent.createChooser(sharingIntent, "Share using")); return true; case R.id.Recommend: Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("BirdEyeCamera", "birdeyecamera@digitalbabi.es", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Feature Recommendation"); startActivity(Intent.createChooser(emailIntent, "Send email...")); return true; case R.id.rateApp: final Uri uri = Uri.parse("market://details?id=" + getApplicationContext().getPackageName()); final Intent rateAppIntent = new Intent(Intent.ACTION_VIEW, uri); if (getPackageManager().queryIntentActivities(rateAppIntent, 0).size() > 0) { startActivity(rateAppIntent); } else { /* handle your error case: the device has no way to handle market urls */ } return true; case R.id.RemoveAds: if (Globals.hasPaid) { Toast.makeText(MainActivity.this, "You already are in a premium account", Toast.LENGTH_SHORT) .show(); } else { removeAdsDialog(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.aegiswallet.actions.MainActivity.java
private void doBackupReminder() { if (System.currentTimeMillis() - application.lastReminderTime < 60000) return;//ww w. ja v a2 s . c om String lastBackupString = prefs.getString(Constants.LAST_BACKUP_DATE, null); int lastBackupNumAddresses = prefs.getInt(Constants.LAST_BACKUP_NUM_ADDRESSES, 0); final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.backup_reminder_prompt); TextView backupText = (TextView) dialog.findViewById(R.id.backup_reminder_prompt_text); Button cancelButton = (Button) dialog.findViewById(R.id.backup_reminder_prompt_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); final Button okayButton = (Button) dialog.findViewById(R.id.backup_reminder_prompt_ok_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); if (nfcEnabled) { Intent intent = new Intent(context, NFCActivity.class); intent.putExtra("nfc_action", "backup"); startActivity(intent); } else application.showPasswordPrompt(context, Constants.ACTION_BACKUP); } }); try { if (dialog.isShowing()) return; if (lastBackupString != null) { Date lastBackupDate = Constants.backupDateFormat.parse(lastBackupString); long currentDate = System.currentTimeMillis(); long difference = currentDate - lastBackupDate.getTime(); long days = TimeUnit.MILLISECONDS.toDays(difference); int keyChainSize = wallet.getKeychainSize(); if (days > 6) { dialog.show(); application.lastReminderTime = System.currentTimeMillis(); } else if (!prefs.contains(Constants.LAST_BACKUP_NUM_ADDRESSES)) { dialog.show(); application.lastReminderTime = System.currentTimeMillis(); } else if (keyChainSize > lastBackupNumAddresses) { backupText.setText(getString(R.string.backup_reminder_new_address)); dialog.show(); application.lastReminderTime = System.currentTimeMillis(); } } else { application.lastReminderTime = System.currentTimeMillis(); dialog.show(); } } catch (ParseException e) { Log.d(TAG, e.getMessage()); } }
From source file:su.comp.bk.ui.BkEmuActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_COMPUTER_MODEL: final CharSequence[] models; List<String> modelList = new ArrayList<String>(); for (Configuration model : Configuration.values()) { int modelNameId = getResources().getIdentifier(model.name().toLowerCase(), "string", getPackageName());/*from w w w . j a va 2 s. com*/ modelList.add((modelNameId != 0) ? getString(modelNameId) : model.name()); } models = modelList.toArray(new String[modelList.size()]); return new AlertDialog.Builder(this).setTitle(R.string.menu_select_model).setSingleChoiceItems(models, getComputerConfiguration().ordinal(), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Mark selected item by tag ListView listView = ((AlertDialog) dialog).getListView(); listView.setTag(Integer.valueOf(which)); } }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Get tagged selected item, if any ListView listView = ((AlertDialog) dialog).getListView(); Integer selected = (Integer) listView.getTag(); if (selected != null) { Configuration config = Configuration.values()[selected]; if (computer.getConfiguration() != config) { // Set new computer configuration and restart activity setComputerConfiguration(config); restartActivity(null); } } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing on cancel } }).create(); case DIALOG_ABOUT: Dialog aboutDialog = new Dialog(this); aboutDialog.setTitle(R.string.menu_about); aboutDialog.requestWindowFeature(Window.FEATURE_LEFT_ICON); aboutDialog.setContentView(R.layout.about_dialog); aboutDialog.getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_info); TextView versionTextView = (TextView) aboutDialog.findViewById(R.id.about_version); try { versionTextView.setText(getResources().getString(R.string.about_version, getPackageManager().getPackageInfo(getPackageName(), 0).versionName)); } catch (NameNotFoundException e) { } return aboutDialog; case DIALOG_DISK_MANAGER: Dialog fddManagerDialog = new Dialog(this); fddManagerDialog.setTitle(R.string.menu_disk_manager); fddManagerDialog.setContentView(R.layout.fdd_mgr_dialog); return fddManagerDialog; case DIALOG_DISK_MOUNT_ERROR: return new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(R.string.err) .setMessage(R.string.dialog_disk_mount_error).setPositiveButton(R.string.ok, null).create(); } return null; }
From source file:com.kircherelectronics.accelerationfilter.activity.AccelerationPlotActivity.java
private void showHelpDialog() { Dialog helpDialog = new Dialog(this); helpDialog.setCancelable(true);/*from ww w. j ava2 s.c o m*/ helpDialog.setCanceledOnTouchOutside(true); helpDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); helpDialog.setContentView(getLayoutInflater().inflate(R.layout.help_dialog_view, null)); helpDialog.show(); }
From source file:com.thingsee.tracker.MainActivity.java
@Override public void onBackPressed() { if (touchActive) { if (onChildOnMapView) { if ((trackerModelWithMarker != null) && (trackerModelWithMarker.getMarker().isInfoWindowShown())) { trackerModelWithMarker.getMarker().hideInfoWindow(); }/*from ww w .j a v a 2 s. co m*/ displayTrackers(); trackerList.setVisibility(View.VISIBLE); onChildOnMapView = false; userZoomAndPanOnMap = false; zoomToBoundingBox(); } else { final Dialog exitQuery = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar); exitQuery.requestWindowFeature(Window.FEATURE_NO_TITLE); exitQuery.setCancelable(true); exitQuery.setContentView(R.layout.exit_app_query); ClearTextView cancel = (ClearTextView) exitQuery.findViewById(R.id.cancel); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { exitQuery.cancel(); } }); ClearTextView exit = (ClearTextView) exitQuery.findViewById(R.id.exit); exit.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { exitApplication(); startupDone = false; exitQuery.cancel(); } }); exitQuery.show(); exitQuery.getWindow().setDimAmount(0.5f); exitQuery.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); } } }
From source file:com.birdeye.MainActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!Prefs.usernames.isSet()) { Prefs.usernames.set(Twitter.getSessionManager().getActiveSession().getUserName()); }//from w w w .j a v a 2 s.c o m setContentView(R.layout.main); ButterKnife.bind(this); // hideSystemUI(this); Chartboost.startWithAppId(MainActivity.this, "57552756f6cd4526e365b9d1", "239b2e3aa657ccdcdf0b9674c8750f077b5e0aed"); Chartboost.setLoggingLevel(CBLogging.Level.ALL); Chartboost.setDelegate(delegate); Chartboost.onCreate(this); tv_cancel = (TextView) findViewById(R.id.tv_cancel); tvSetTimer = (Button) findViewById(R.id.tvSetTimer); if (!BillingProcessor.isIabServiceAvailable(MainActivity.this)) { // showToast("In-app billing service is unavailable, please upgrade Android Market/Play to version >= 3.9.16"); onBackPressed(); } bp = new BillingProcessor(this, LICENSE_KEY, MERCHANT_ID, new BillingProcessor.IBillingHandler() { @Override public void onProductPurchased(String productId, TransactionDetails details) { showToast("onProductPurchased: " + productId); // updateTextViews(); } @Override public void onBillingError(int errorCode, Throwable error) { showToast("onBillingError: " + Integer.toString(errorCode)); } @Override public void onBillingInitialized() { showToast("onBillingInitialized"); readyToPurchase = true; //updateTextViews(); } @Override public void onPurchaseHistoryRestored() { showToast("onPurchaseHistoryRestored"); for (String sku : bp.listOwnedProducts()) Log.d(LOG_TAG, "Owned Managed Product: " + sku); for (String sku : bp.listOwnedSubscriptions()) Log.d(LOG_TAG, "Owned Subscription: " + sku); //updateTextViews(); Log.i(LOG_TAG, String.format("%s is%s subscribed", SUBSCRIPTION_ID, bp.isSubscribed(SUBSCRIPTION_ID) ? "" : " not")); } }); subs = bp.getSubscriptionListingDetails(SUBSCRIPTION_ID); // showToast(subs != null ? subs.toString() : "Failed to load subscription details"); if (subs == null) { // showToast(subs != null ? subs.toString() : "Failed to load subscription details"); Globals.hasPaid = false; } else { Globals.hasPaid = true; } if (Globals.hasPaid) { tvSetTimer.setVisibility(View.VISIBLE); message4.setVisibility(View.VISIBLE); message5.setVisibility(View.VISIBLE); message6.setVisibility(View.VISIBLE); message7.setVisibility(View.VISIBLE); message8.setVisibility(View.VISIBLE); message9.setVisibility(View.VISIBLE); message10.setVisibility(View.VISIBLE); message11.setVisibility(View.VISIBLE); message12.setVisibility(View.VISIBLE); message13.setVisibility(View.VISIBLE); message14.setVisibility(View.VISIBLE); message15.setVisibility(View.VISIBLE); message16.setVisibility(View.VISIBLE); message17.setVisibility(View.VISIBLE); message18.setVisibility(View.VISIBLE); message19.setVisibility(View.VISIBLE); message20.setVisibility(View.VISIBLE); message21.setVisibility(View.VISIBLE); message22.setVisibility(View.VISIBLE); message23.setVisibility(View.VISIBLE); message24.setVisibility(View.VISIBLE); message25.setVisibility(View.VISIBLE); ets = Arrays.asList(usernames, hashtags, message1, message2, message3, message4, message5, message6, message7, message8, message9, message10, message11, message12, message13, message14, message15, message16, message17, message18, message19, message20, message21, message22, message23, message24, message25); } else { tvSetTimer.setVisibility(View.GONE); message4.setVisibility(View.GONE); message5.setVisibility(View.GONE); message6.setVisibility(View.GONE); message7.setVisibility(View.GONE); message8.setVisibility(View.GONE); message9.setVisibility(View.GONE); message10.setVisibility(View.GONE); message11.setVisibility(View.GONE); message12.setVisibility(View.GONE); message13.setVisibility(View.GONE); message14.setVisibility(View.GONE); message15.setVisibility(View.GONE); message16.setVisibility(View.GONE); message17.setVisibility(View.GONE); message18.setVisibility(View.GONE); message19.setVisibility(View.GONE); message20.setVisibility(View.GONE); message21.setVisibility(View.GONE); message22.setVisibility(View.GONE); message23.setVisibility(View.GONE); message24.setVisibility(View.GONE); message25.setVisibility(View.GONE); ets = Arrays.asList(usernames, hashtags, message1, message2, message3); } tvSetTimer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(MainActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.setContentView(R.layout.input_time); dialog.setCancelable(true); Button bt_set = (Button) dialog.findViewById(R.id.bt_set); final EditText et_time = (EditText) dialog.findViewById(R.id.et_time); bt_set.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (et_time.getText().toString().equalsIgnoreCase("")) { Toast.makeText(MainActivity.this, "Please enter time to auto shut down", Toast.LENGTH_SHORT).show(); } else { int valueTimer = Integer.parseInt(et_time.getText().toString()) * 1000; initateCounter(valueTimer); tv_cancel.setText("Auto ShutDown started"); tvSetTimer.setVisibility(View.GONE); tv_cancel.setVisibility(View.VISIBLE); dialog.dismiss(); } } }); dialog.show(); } }); cameras.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, Facing.values())); //noinspection ConstantConditions cameras.setSelection(Prefs.facing.get().ordinal()); cameras.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Prefs.facing.set(Facing.values()[position]); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); for (TextInputEditText et : ets) { DrawableCompat.setTint(et.getBackground(), ContextCompat.getColor(this, R.color.colorAccent)); final TextInputLayout til = textLayout(et); til.setError(null); til.setErrorEnabled(false); } TextViews.setText(usernames, Prefs.usernames.get()); TextViews.setText(hashtags, Prefs.hashtags.get()); TextViews.setText(message1, Prefs.message1.get()); TextViews.setText(message2, Prefs.message2.get()); TextViews.setText(message3, Prefs.message3.get()); TextViews.setText(message4, Prefs.message4.get()); TextViews.setText(message5, Prefs.message5.get()); TextViews.setText(message6, Prefs.message6.get()); TextViews.setText(message7, Prefs.message7.get()); TextViews.setText(message8, Prefs.message8.get()); TextViews.setText(message9, Prefs.message9.get()); TextViews.setText(message10, Prefs.message10.get()); TextViews.setText(message11, Prefs.message11.get()); TextViews.setText(message12, Prefs.message12.get()); TextViews.setText(message13, Prefs.message13.get()); TextViews.setText(message14, Prefs.message14.get()); TextViews.setText(message15, Prefs.message15.get()); TextViews.setText(message16, Prefs.message16.get()); TextViews.setText(message17, Prefs.message17.get()); TextViews.setText(message18, Prefs.message18.get()); TextViews.setText(message19, Prefs.message19.get()); TextViews.setText(message20, Prefs.message20.get()); TextViews.setText(message21, Prefs.message21.get()); TextViews.setText(message22, Prefs.message22.get()); TextViews.setText(message23, Prefs.message23.get()); TextViews.setText(message24, Prefs.message24.get()); TextViews.setText(message25, Prefs.message25.get()); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); getWindow().setBackgroundDrawableResource(R.color.bg); mAdView = (AdView) findViewById(R.id.adView); mInterstitialAd = new InterstitialAd(this); // set the ad unit ID mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen)); adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // Check the LogCat to get your test device ID .addTestDevice("EB02375D2DA62FFA0F6F145AD2302B3D").build(); // adRequest = new AdRequest.Builder().build(); mAdView.setAdListener(new AdListener() { @Override public void onAdLoaded() { } @Override public void onAdClosed() { // Toast.makeText(getApplicationContext(), "Ad is closed!", Toast.LENGTH_SHORT).show(); } @Override public void onAdFailedToLoad(int errorCode) { // Toast.makeText(getApplicationContext(), "Ad failed to load! error code: " + errorCode, Toast.LENGTH_SHORT).show(); } @Override public void onAdLeftApplication() { // Toast.makeText(getApplicationContext(), "Ad left application!", Toast.LENGTH_SHORT).show(); } @Override public void onAdOpened() { super.onAdOpened(); } }); mAdView.loadAd(adRequest); mInterstitialAd.loadAd(adRequest); mInterstitialAd.setAdListener(new AdListener() { public void onAdLoaded() { showInterstitial(); } @Override public void onAdClosed() { Toast.makeText(getApplicationContext(), "Ad is closed!", Toast.LENGTH_SHORT).show(); } @Override public void onAdFailedToLoad(int errorCode) { Toast.makeText(getApplicationContext(), "Ad failed to load! error code: " + errorCode, Toast.LENGTH_SHORT).show(); } @Override public void onAdLeftApplication() { Toast.makeText(getApplicationContext(), "Ad left application!", Toast.LENGTH_SHORT).show(); } @Override public void onAdOpened() { Toast.makeText(getApplicationContext(), "Ad is opened!", Toast.LENGTH_SHORT).show(); } }); if (Globals.hasPaid) { tv_cancel.setVisibility(View.GONE); mAdView.setVisibility(View.GONE); } else { // initateCounter(120000); startRepeatingTask(); mAdView.setVisibility(View.VISIBLE); } }
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 ww w. ja v a 2 s. c o 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.iiordanov.bVNC.RemoteCanvasActivity.java
private void selectColorModel() { String[] choices = new String[COLORMODEL.values().length]; int currentSelection = -1; for (int i = 0; i < choices.length; i++) { COLORMODEL cm = COLORMODEL.values()[i]; choices[i] = cm.toString();//from w ww . ja v a 2 s . c o m if (canvas.isColorModel(cm)) currentSelection = i; } final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); ListView list = new ListView(this); list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, choices)); list.setChoiceMode(ListView.CHOICE_MODE_SINGLE); list.setItemChecked(currentSelection, true); list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { dialog.dismiss(); COLORMODEL cm = COLORMODEL.values()[arg2]; canvas.setColorModel(cm); connection.setColorModel(cm.nameString()); connection.save(database.getWritableDatabase()); database.close(); Toast.makeText(RemoteCanvasActivity.this, getString(R.string.info_update_color_model_to) + cm.toString(), Toast.LENGTH_SHORT).show(); } }); dialog.setContentView(list); dialog.show(); }
From source file:com.alivenet.dmv.driverapplication.fragment.MyAccount.java
public void showActionSheet() { LayoutInflater inflater = LayoutInflater.from(getActivity()); final Dialog myDialog = new Dialog(getActivity(), android.R.style.Theme_Translucent_NoTitleBar); myDialog.setCanceledOnTouchOutside(true); myDialog.getWindow().setLayout(AbsoluteLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); myDialog.getWindow().setGravity(Gravity.BOTTOM); myDialog.getWindow().getAttributes().windowAnimations = R.anim.slide_up; WindowManager.LayoutParams lp = myDialog.getWindow().getAttributes(); lp.dimAmount = 0.75f;//from ww w. j a v a2 s . c om myDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); myDialog.getWindow(); View dialoglayout = inflater.inflate(R.layout.dialog_profile_actionsheet, null); myDialog.setContentView(dialoglayout); TextView mTvTakeFromCamera = (TextView) myDialog.findViewById(R.id.tvTakeFromCamera); TextView mTvTakeFromLibrary = (TextView) myDialog.findViewById(R.id.tvTakeFromLibrary); long timestamp = System.currentTimeMillis(); AppData.getSingletonObject().setmFileTemp(getActivity(), "" + timestamp); mTvTakeFromCamera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myDialog.dismiss(); takePicture(getActivity()); } }); mTvTakeFromLibrary.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myDialog.dismiss(); openGallery(getActivity()); } }); TextView tvCancel = (TextView) myDialog.findViewById(R.id.tvCancel); tvCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myDialog.dismiss(); } }); try { myDialog.show(); } catch (WindowManager.BadTokenException e) { Log.e("", "View not attached."); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.thingsee.tracker.MainActivity.java
@Override public void onMapReady(GoogleMap map) { mMap = map;// w w w . ja va2 s .co m TileProvider wmsTileProvider = TileProviderFactory.getKapsiWmsTileProvider(); mMap.addTileOverlay(new TileOverlayOptions().tileProvider(wmsTileProvider).fadeIn(true)); initGoogleMap(); trackerList = (HorizontalScrollView) this.findViewById(R.id.tracker_scroll_area); mTrackerItemLayout = (LinearLayout) findViewById(R.id.trackers); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mainari, 16)); Marker mark = mMap.addMarker(new MarkerOptions().position(mainari)); ImageView locateButton = (ImageView) findViewById(R.id.app_icon); //set the ontouch listener locateButton.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { ImageView view = (ImageView) v; view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } case MotionEvent.ACTION_UP: if (onChildOnMapView) { onUpPressed(); } else { userZoomAndPanOnMap = false; zoomToBoundingBox(); } case MotionEvent.ACTION_CANCEL: { ImageView view = (ImageView) v; //clear the overlay view.getDrawable().setColorFilter(mResources.getColor(R.color.white_effect), PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } } return true; } }); ImageView settingsButton = (ImageView) findViewById(R.id.header_settings_icon); //set the ontouch listener settingsButton.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { ImageView view = (ImageView) v; //overlay is black with transparency of 0x77 (119) view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } case MotionEvent.ACTION_UP: final Dialog verificationQuery = new Dialog(mContext, android.R.style.Theme_Translucent_NoTitleBar); verificationQuery.requestWindowFeature(Window.FEATURE_NO_TITLE); verificationQuery.setCancelable(false); verificationQuery.setContentView(R.layout.request_admin_code); ClearTextView ok = (ClearTextView) verificationQuery.findViewById(R.id.ok); ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { verificationQuery.dismiss(); EditText code = (EditText) verificationQuery.findViewById(R.id.verification_code); if (code.getText().toString().equalsIgnoreCase("password")) { Intent intent = new Intent(MainActivity.this, MenuActivity.class); startActivity(intent); } } }); ClearTextView cancel = (ClearTextView) verificationQuery.findViewById(R.id.cancel); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { verificationQuery.dismiss(); } }); verificationQuery.show(); verificationQuery.getWindow().setDimAmount(0.5f); verificationQuery.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); case MotionEvent.ACTION_CANCEL: { ImageView view = (ImageView) v; //clear the overlay view.getDrawable().setColorFilter(mResources.getColor(R.color.white_effect), PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } } return true; } }); mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng position) { if (onChildOnMapView) { if (trackerModelWithMarker != null) { trackerModelWithMarker.getMarker().showInfoWindow(); } } } }); mMap.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { if (trackersActive) { LatLng latlng = marker.getPosition(); userZoomAndPanOnMap = false; if ((latlng.latitude == mainari.latitude) && (latlng.longitude == mainari.longitude)) { if (onChildOnMapView) { if (trackerModelWithMarker != null) { trackerModelWithMarker.getMarker().showInfoWindow(); } } } else { if (!onChildOnMapView) { trackerModelWithMarker = null; // Zoom to marker tapped zoomToMarker(latlng); //Remove other markers for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); if (trackerModel.getLatestLatLng() != null) { if ((trackerModel.getLatestLatLng().latitude == latlng.latitude) && (trackerModel.getLatestLatLng().longitude == latlng.longitude)) { focusOnChildOnMap(trackerModel.getSerialNumber()); trackerModelWithMarker = trackerModel; trackerModelWithMarker.getMarker().showInfoWindow(); } } } } else { trackerModelWithMarker.getMarker().showInfoWindow(); for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); if (trackerModel.getLatestLatLng() != null) { if ((trackerModel.getLatestLatLng().latitude == latlng.latitude) && (trackerModel.getLatestLatLng().longitude == latlng.longitude)) { onBackPressed(); } } } } } } return true; } }); mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { // Use default InfoWindow frame @Override public View getInfoWindow(Marker arg0) { return null; } // Defines the contents of the InfoWindow @Override public View getInfoContents(Marker arg0) { // Getting view from the layout file info_window_layout View v = null; for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); if (trackerModel.getLatestLatLng() != null) { if ((trackerModel.getLatestLatLng().latitude == arg0.getPosition().latitude) && (trackerModel.getLatestLatLng().longitude == arg0.getPosition().longitude)) { v = getLayoutInflater().inflate(R.layout.info_window, null); trackerModelWithMarker = trackerModel; TextView trackerAccuracy = (TextView) v .findViewById(R.id.tracker_marker_popup_accuracy); if (trackerModelWithMarker.getAccuracy() != -1) { trackerAccuracy .setText(String.format(mResources.getString(R.string.tracker_accuracy), trackerModelWithMarker.getAccuracy())); } else { trackerAccuracy.setText( String.format(mResources.getString(R.string.tracker_accuracy), 0.0f)); } TextView trackerDistanceTs = (TextView) v .findViewById(R.id.tracker_marker_popup_update_timestamp); if (trackerModelWithMarker.getLastLocationUpdate() != 0) { String timeStampText = Utilities.getSmartTimeStampString(mContext, mResources, trackerModelWithMarker.getLastLocationUpdate()); trackerDistanceTs.setText( mResources.getString(R.string.tracker_timestamp) + " " + timeStampText); } else { trackerDistanceTs.setText(mResources.getString(R.string.tracker_timestamp) + " - "); } trackerInfoWindow = v; } } } // Returning the view containing InfoWindow contents return v; } }); IntentFilter statusIntentFilter = new IntentFilter(CommonConstants.BROADCAST_ACTION); statusIntentFilter.addCategory(Intent.CATEGORY_DEFAULT); mFetchCloudDataStateReceiver = new FetchCloudDataStateReceiver(); LocalBroadcastManager.getInstance(this).registerReceiver(mFetchCloudDataStateReceiver, statusIntentFilter); mapLoaded = true; if (splashReady) { mSplashHandler.postDelayed(splashScreenOffFromDisplay, 0); } }