List of usage examples for android.widget TextView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.ivalentin.margolariak.SettingsLayout.java
/** * Run when the fragment is inflated./*w w w .j a va 2 s . c om*/ * 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.limewoodmedia.nsdroid.fragments.EmbassiesFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { root = inflater.inflate(R.layout.embassies, null, false); list = (ListView) root.findViewById(R.id.embassies_list); embassies = new ArrayList<Embassy>(); listAdapter = new ArrayAdapter<Embassy>(context, 0, embassies) { @Override/*from ww w. j a v a 2s. c o m*/ public View getView(int position, View convertView, ViewGroup parent) { View view; TextView name, status; Embassy embassy; if (convertView == null) { view = inflater.inflate(R.layout.embassy, null); name = (TextView) view.findViewById(R.id.embassy_name); name.setMovementMethod(LinkMovementMethod.getInstance()); status = (TextView) view.findViewById(R.id.embassy_status); } else { view = convertView; name = (TextView) view.findViewById(R.id.embassy_name); status = (TextView) view.findViewById(R.id.embassy_status); } embassy = getItem(position); // Region String eName = TagParser.idToName(embassy.region); name.setText(Html.fromHtml(eName)); // Status String str = null; Resources res = getResources(); int background = R.drawable.embassy_established; switch (embassy.status) { case INVITED: str = res.getString(R.string.embassy_invited); background = R.drawable.embassy_invited; break; case PENDING: str = res.getString(R.string.embassy_pending); background = R.drawable.embassy_pending; break; case REQUESTED: str = res.getString(R.string.embassy_requested); background = R.drawable.embassy_requested; break; case REJECTED: str = res.getString(R.string.embassy_rejected); background = R.drawable.embassy_denied; break; case CLOSING: str = res.getString(R.string.embassy_closing); background = R.drawable.embassy_closing; break; case ESTABLISHED: break; } status.setText(str); view.setBackgroundResource(background); view.setTag(embassy); view.setOnClickListener(EmbassiesFragment.this); name.setOnClickListener(EmbassiesFragment.this); status.setOnClickListener(EmbassiesFragment.this); return view; } }; list.setAdapter(listAdapter); ((Spinner) root.findViewById(R.id.embassies_filter)).setOnItemSelectedListener(this); return root; }
From source file:com.npi.muzeiflickr.ui.activities.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); CalligraphyConfig.initDefault(""); setContentView(R.layout.settings_activity); final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); final SharedPreferences.Editor editor = settings.edit(); //Find views//from w w w. j a va2 s. c o m Switch wifiOnly = (Switch) findViewById(R.id.wifi_only); mRefreshRate = (TextView) findViewById(R.id.refresh_rate); ImageView aboutShortcut = (ImageView) findViewById(R.id.about); mRequestList = (DragSortListView) findViewById(R.id.content_list); mUndoContainer = (RelativeLayout) findViewById(R.id.undo_container); mLastDeletedItemText = (TextView) findViewById(R.id.last_deleted_item); TextView mLastDeletedUndo = (TextView) findViewById(R.id.last_deleted_undo); List<RequestData> items = new ArrayList<RequestData>(); items.addAll(Search.listAll(Search.class)); items.addAll(User.listAll(User.class)); items.addAll(Tag.listAll(Tag.class)); items.addAll(FGroup.listAll(FGroup.class)); mRequestAdapter = new RequestAdapter(this, items); final View footerView = getLayoutInflater().inflate(R.layout.list_footer, null); mRequestList.addFooterView(footerView); mRequestList.setAdapter(mRequestAdapter); mRequestList.setRemoveListener(onRemove); populateFooter(footerView); //Wifi status and setting wifiOnly.setChecked(settings.getBoolean(PreferenceKeys.WIFI_ONLY, false)); wifiOnly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { editor.putBoolean(PreferenceKeys.WIFI_ONLY, isChecked); editor.commit(); } }); //Other settings population int refreshRate = settings.getInt(PreferenceKeys.REFRESH_TIME, FlickrSource.DEFAULT_REFRESH_TIME); mRefreshRate.setText(Utils.convertDurationtoString(refreshRate)); mRefreshRate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { HHmsPickerBuilder hpb = new HHmsPickerBuilder().setFragmentManager(getSupportFragmentManager()) .setStyleResId(R.style.MyCustomBetterPickerTheme); hpb.show(); } }); aboutShortcut.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AboutActivity.launchActivity(SettingsActivity.this); } }); mLastDeletedUndo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mLastDeletedItem instanceof User) { User user = ((User) mLastDeletedItem); user.setId(null); user.save(); } else if (mLastDeletedItem instanceof Search) { Search search = ((Search) mLastDeletedItem); search.setId(null); search.save(); } mRequestAdapter.add(mLastDeletedItem); mRequestAdapter.notifyDataSetChanged(); mUndoContainer.setVisibility(View.GONE); } }); }
From source file:com.mitre.holdshort.MainActivity.java
private void showDisclaimer() { final Dialog dialog = new Dialog(MainActivity.this); OnClickListener disclaimerBtnClick;//from ww w .j a v a 2 s.c om dialog.setContentView(R.layout.legal_stuff_dialog); dialog.setTitle("RIPPLE - Informed Consent"); dialog.setCancelable(false); dialog.getWindow().setLayout(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); TextView consent = (TextView) dialog.findViewById(R.id.disclaimerAccept); TextView reject = (TextView) dialog.findViewById(R.id.disclaimerReject); disclaimerBtnClick = new OnClickListener() { @Override public void onClick(View v) { if (v.getId() == R.id.disclaimerAccept) { settings.edit().putBoolean("consent", true).commit(); dialog.dismiss(); waiverAccept = true; startUp(); } else { finish(); } } }; consent.setOnClickListener(disclaimerBtnClick); reject.setOnClickListener(disclaimerBtnClick); dialog.show(); }
From source file:com.haibison.android.anhuu.FragmentFiles.java
/** * As the name means./*from www . ja va 2 s . c om*/ */ private void buildAddressBar(final Uri path) { if (path == null) return; mViewAddressBar.removeAllViews(); new LoadingDialog<Void, Cursor, Void>(getActivity(), false) { LinearLayout.LayoutParams lpBtnLoc; LinearLayout.LayoutParams lpDivider; LayoutInflater inflater = getLayoutInflater(null); final int dim = getResources().getDimensionPixelSize(R.dimen.anhuu_f5be488d_5dp); int count = 0; @Override protected void onPreExecute() { super.onPreExecute(); lpBtnLoc = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lpBtnLoc.gravity = Gravity.CENTER; }// onPreExecute() @Override protected Void doInBackground(Void... params) { Cursor cursor = getActivity().getContentResolver().query(path, null, null, null, null); while (cursor != null) { if (cursor.moveToFirst()) { publishProgress(cursor); cursor.close(); } else break; /* * Process the parent directory. */ Uri uri = Uri.parse(cursor.getString(cursor.getColumnIndex(BaseFile.COLUMN_URI))); cursor = getActivity().getContentResolver() .query(BaseFile.genContentUriApi(uri.getAuthority()).buildUpon() .appendPath(BaseFile.CMD_GET_PARENT) .appendQueryParameter(BaseFile.PARAM_SOURCE, uri.getLastPathSegment()).build(), null, null, null, null); } // while return null; }// doInBackground() @Override protected void onProgressUpdate(Cursor... progress) { /* * Add divider. */ if (mViewAddressBar.getChildCount() > 0) { View divider = inflater.inflate(R.layout.anhuu_f5be488d_view_locations_divider, null); if (lpDivider == null) { lpDivider = new LinearLayout.LayoutParams(dim, dim); lpDivider.gravity = Gravity.CENTER; lpDivider.setMargins(dim, dim, dim, dim); } mViewAddressBar.addView(divider, 0, lpDivider); } Uri lastUri = Uri.parse(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_URI))); TextView btnLoc = (TextView) inflater.inflate(R.layout.anhuu_f5be488d_button_location, null); String name = BaseFileProviderUtils.getFileName(progress[0]); btnLoc.setText(TextUtils.isEmpty(name) ? getString(R.string.anhuu_f5be488d_root) : name); btnLoc.setTag(lastUri); btnLoc.setOnClickListener(mBtnLocationOnClickListener); btnLoc.setOnLongClickListener(mBtnLocationOnLongClickListener); mViewAddressBar.addView(btnLoc, 0, lpBtnLoc); if (count++ == 0) { Rect r = new Rect(); btnLoc.getPaint().getTextBounds(name, 0, name.length(), r); if (r.width() >= getResources() .getDimensionPixelSize(R.dimen.anhuu_f5be488d_button_location_max_width) - btnLoc.getPaddingLeft() - btnLoc.getPaddingRight()) { mTextFullDirName .setText(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_NAME))); mTextFullDirName.setVisibility(View.VISIBLE); } else mTextFullDirName.setVisibility(View.GONE); } // if }// onProgressUpdate() @Override protected void onPostExecute(Void result) { super.onPostExecute(result); /* * Sometimes without delay time, it doesn't work... */ mViewLocationsContainer.postDelayed(new Runnable() { public void run() { mViewLocationsContainer.fullScroll(HorizontalScrollView.FOCUS_RIGHT); }// run() }, Display.DELAY_TIME_FOR_VERY_SHORT_ANIMATION); }// onPostExecute() }.execute(); }
From source file:com.mdlive.sav.MDLiveProviderDetails.java
/** * Parses JSON response from Cigna Coach request and displays popup displaying the extracted info * * data structure:/*from w w w . j av a2 s . c om*/ * "appointment_instructions" : { * "title" : "Schedule an Appointment", * "description" : "To schedule a video coaching appointment, please call:", * "team_name" : "Marriott TakeCare Team", * "toll_free_number" : "1-800-700-1092", * "additional_info" : "Se habla Espaol" * } * * @param response HTTP response object */ private void handleCignaCoachSuccessResponse(String response) { //Fetch Data From the Services //Log.e("Response details", "************\n**********"+response.toString()); JsonParser parser = new JsonParser(); JsonObject responseObj = null, profileObj = null, providerObj = null, appointment_obj = null; String dialog_title = null, dialog_desc = null, dialog_teamname = null, dialog_extrainfo = null, phonenumber = null; try { responseObj = (JsonObject) parser.parse(response.toString()); profileObj = responseObj.get("doctor_profile").getAsJsonObject(); providerObj = profileObj.get("provider_details").getAsJsonObject(); appointment_obj = providerObj.get("appointment_instructions").getAsJsonObject(); dialog_title = appointment_obj.get("title").getAsString(); dialog_desc = appointment_obj.get("description").getAsString(); dialog_teamname = appointment_obj.get("team_name").getAsString(); phonenumber = appointment_obj.get("toll_free_number").getAsString(); dialog_extrainfo = appointment_obj.get("additional_info").getAsString(); } catch (NullPointerException nex) { //Log.e("Error details", "************\n" + nex.getMessage()); /*Toast.makeText(this, R.string.mdl_cignacoach_data_error, Toast.LENGTH_SHORT).show();*/ Snackbar.make(findViewById(android.R.id.content), getString(R.string.mdl_cignacoach_data_error), Snackbar.LENGTH_SHORT).show(); return; } final String dialog_phonenumber = phonenumber; AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MDLiveProviderDetails.this); LayoutInflater inflater = MDLiveProviderDetails.this.getLayoutInflater(); View dialogView = inflater.inflate(R.layout.cignacoach_popup, null); messagesView = dialogView; alertDialogBuilder.setView(dialogView); // populate the dialog's text fields final TextView txt_title = (TextView) dialogView.findViewById(R.id.title); txt_title.setText(dialog_title); final TextView txt_desc = (TextView) dialogView.findViewById(R.id.desc); txt_desc.setText(dialog_desc); final TextView txt_team = (TextView) dialogView.findViewById(R.id.team); txt_team.setText(dialog_teamname); final TextView txt_phone = (TextView) dialogView.findViewById(R.id.phone); txt_phone.setText(getString(R.string.mdl_cignacoach_phonenumber, dialog_phonenumber)); final TextView txt_extra = (TextView) dialogView.findViewById(R.id.extra); txt_extra.setText(dialog_extrainfo); alertDialogBuilder.setCancelable(true); // create alert dialog final AlertDialog alertDialog = alertDialogBuilder.create(); // suppress default background to allow rounded corners to show through alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); txt_phone.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (ContextCompat.checkSelfPermission(MDLiveProviderDetails.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(MDLiveProviderDetails.this, new String[] { android.Manifest.permission.CALL_PHONE }, MDLiveProviderDetails.PERMISSION_ACCESS_PHONE); } else { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + dialog_phonenumber)); startActivity(callIntent); } alertDialog.dismiss(); } }); // display it alertDialog.show(); }
From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java
private void displayArtistInfo_bk(JSONObject j) throws JSONException { if (imageLoader == null) imageLoader = ImageLoader.getInstance(); if (!imageLoader.isInited()) imageLoader.init(config);//from www.j a v a 2 s . co m Log.i("musicInfo", "LinkPopUp. displayArtistInfo " + j.toString()); JSONObject j_artist_info = j.getJSONObject("artist"); tArtistName.setText(j_artist_info.getString("name")); final JSONObject urls = j_artist_info.optJSONObject("urls"); final JSONArray videos = j_artist_info.optJSONArray("video"); final JSONArray images = j_artist_info.optJSONArray("images"); final String fm_image = j.optString("fm_image"); final JSONArray available_images = new JSONArray(); ArrayList<String> image_urls = new ArrayList<String>(); if (fm_image != null) { image_urls.add(fm_image); } Log.i("musicInfo", images.toString()); if (images != null) { for (int i = 0; i < images.length(); i++) { JSONObject image = images.getJSONObject(i); int width = image.optInt("width", 0); int height = image.optInt("height", 0); String url = image.optString("url", ""); Log.i("musicInfo", i + ": " + url); if ((width * height > 10000) && (width * height < 100000) && (!url.contains("userserve-ak"))) { //if ((width>300&&width<100)&&(height>300&&height<1000)&&(!url.contains("userserve-ak"))) { image_urls.add(url); Log.i("musicInfo", "Selected: " + url); //available_images.put(image); } } int random = (int) (Math.random() * image_urls.size()); final String f_url = image_urls.get(random); //int random = (int) (Math.random() * available_images.length()); //final JSONObject fImage = available_images.length()>0?available_images.getJSONObject(random > images.length() ? 0 : random):images.getJSONObject(0); Log.i("musicInfo", "Total image#=" + available_images.length() + " Selected image#=" + random + " " + f_url); imageLoader.displayImage(f_url, ArtistImage, new ImageLoadingListener() { @Override public void onLoadingStarted(String imageUri, View view) { } @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { } @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { lLinkList.removeAllViews(); //String attr = fImage.optJSONObject("license").optString("attribution"); //tAttribution.setText("Credit. " + ((attr == null) || (attr.contains("n/a")) ? "Unknown" : attr)); if (urls != null) { String[] jsonName = { "wikipedia_url", "mb_url", "lastfm_url", "official_url", "twitter_url" }; for (int i = 0; i < jsonName.length; i++) { if ((urls.optString(jsonName[i]) != null) && (urls.optString(jsonName[i]) != "")) { Log.d("musicinfo", "Link URL: " + urls.optString(jsonName[i])); TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); tv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); switch (jsonName[i]) { case "official_url": tv.setText("HOME."); break; case "wikipedia_url": tv.setText("WIKI."); break; case "mb_url": tv.setText("Music Brainz."); break; case "lastfm_url": tv.setText("Last FM."); break; case "twitter_url": tv.setText("Twitter."); break; } try { tv.setTag(urls.getString(jsonName[i])); } catch (JSONException e) { e.printStackTrace(); } tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse((String) v.getTag())); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); Toast.makeText(getApplicationContext(), "Open the Link...", Toast.LENGTH_SHORT).show(); //finish(); } }); lLinkList.addView(tv); } } } else { TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); tv.setText("Sorry, No Link Here..."); lLinkList.addView(tv); } if (videos != null) { jVideoArray = videos; mAdapter = new StaggeredViewAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, generateImageData(videos)); //if (mData == null) { mData = generateImageData(videos); //} //mAdapter.clear(); for (JSONObject data : mData) { mAdapter.add(data); } mGridView.setAdapter(mAdapter); } else { } adjBottomColor(((ImageView) view).getDrawable()); } @Override public void onLoadingCancelled(String imageUri, View view) { } }); } }
From source file:azad.hallaji.farzad.com.masirezendegi.PageVirayesh.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_page_virayesh); Fabric.with(this, new Crashlytics()); TextView virayeshTextinToolbar = (TextView) findViewById(R.id.virayeshTextinToolbar); final TextView zaxireTextinToolbar = (TextView) findViewById(R.id.zaxireTextinToolbar); init();/* w w w. j ava2 s.com*/ ableall(false); drawer = (DrawerLayout) findViewById(R.id.drawer_layout); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); ImageView imageView = (ImageView) findViewById(R.id.menuButton); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { drawer.openDrawer(Gravity.END); } }); if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) { Menu nav_Menu = navigationView.getMenu(); nav_Menu.findItem(R.id.nav_marakez).setVisible(true); nav_Menu.findItem(R.id.nav_profile).setVisible(true); nav_Menu.findItem(R.id.nav_login).setVisible(false); nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true); nav_Menu.findItem(R.id.nav_porseshha).setVisible(true); nav_Menu.findItem(R.id.nav_logout).setVisible(true); } else { Menu nav_Menu = navigationView.getMenu(); nav_Menu.findItem(R.id.nav_marakez).setVisible(true); nav_Menu.findItem(R.id.nav_profile).setVisible(false); nav_Menu.findItem(R.id.nav_login).setVisible(true); nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true); nav_Menu.findItem(R.id.nav_porseshha).setVisible(true); nav_Menu.findItem(R.id.nav_logout).setVisible(false); } final ImageView imageView1 = (ImageView) findViewById(R.id.onclickeasadinchimastanxanim); imageView1.setVisibility(View.GONE); if (isOnline()) { setAlage(); if (GlobalVar.getUserType().equals("adviser")) { virayeshTextinToolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ableall(true); sihhhhh1.setVisibility(View.VISIBLE); sihhhhh2.setVisibility(View.VISIBLE); imageView1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent pickPhoto = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(pickPhoto, 1);//one can be replaced with any action code } }); zaxireTextinToolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { postgetData(); } }); } }); imageView1.setVisibility(View.VISIBLE); barchasbEdit.setVisibility(View.VISIBLE); costperminEdit.setVisibility(View.VISIBLE); maxtimeEdit.setVisibility(View.VISIBLE); sexEdit.setVisibility(View.VISIBLE); dialtecEdit.setVisibility(View.VISIBLE); aboutmeEdit.setVisibility(View.VISIBLE); } else if (GlobalVar.getUserType().equals("user")) { virayeshTextinToolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TextView textView = (TextView) findViewById(R.id.sihhhhh1); TextView textView2 = (TextView) findViewById(R.id.sihhhhh2); textView.setVisibility(View.GONE); textView2.setVisibility(View.GONE); imageView1.setVisibility(View.VISIBLE); boolean b = false; sihhhhh1.setVisibility(View.GONE); sihhhhh2.setVisibility(View.GONE); namexanivadeEdit.setEnabled(!b); shomareteleEdit.setEnabled(!b); emailEdit.setEnabled(!b); barchasbEdit.setVisibility(View.GONE); costperminEdit.setVisibility(View.GONE); maxtimeEdit.setVisibility(View.GONE); sexEdit.setVisibility(View.GONE); dialtecEdit.setVisibility(View.GONE); aboutmeEdit.setVisibility(View.GONE); imageView1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent pickPhoto = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(pickPhoto, 1);//one can be replaced with any action code } }); zaxireTextinToolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { postgetData(); } }); } }); } } else { Toast.makeText(getApplicationContext(), "Network isn't available", Toast.LENGTH_LONG).show(); } }
From source file:com.keylesspalace.tusky.ComposeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); String theme = preferences.getString("appTheme", ThemeUtils.APP_THEME_DEFAULT); if (theme.equals("black")) { setTheme(R.style.TuskyDialogActivityBlackTheme); }// www . j a va 2 s .c om setContentView(R.layout.activity_compose); replyTextView = findViewById(R.id.composeReplyView); replyContentTextView = findViewById(R.id.composeReplyContentView); textEditor = findViewById(R.id.composeEditField); mediaPreviewBar = findViewById(R.id.compose_media_preview_bar); contentWarningBar = findViewById(R.id.composeContentWarningBar); contentWarningEditor = findViewById(R.id.composeContentWarningField); charactersLeft = findViewById(R.id.composeCharactersLeftView); tootButton = findViewById(R.id.composeTootButton); pickButton = findViewById(R.id.composeAddMediaButton); visibilityButton = findViewById(R.id.composeToggleVisibilityButton); contentWarningButton = findViewById(R.id.composeContentWarningButton); emojiButton = findViewById(R.id.composeEmojiButton); hideMediaToggle = findViewById(R.id.composeHideMediaButton); emojiView = findViewById(R.id.emojiView); emojiList = Collections.emptyList(); saveTootHelper = new SaveTootHelper(database.tootDao(), this); // Setup the toolbar. Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(null); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); Drawable closeIcon = AppCompatResources.getDrawable(this, R.drawable.ic_close_24dp); ThemeUtils.setDrawableTint(this, closeIcon, R.attr.compose_close_button_tint); actionBar.setHomeAsUpIndicator(closeIcon); } // setup the account image final AccountEntity activeAccount = accountManager.getActiveAccount(); if (activeAccount != null) { ImageView composeAvatar = findViewById(R.id.composeAvatar); if (TextUtils.isEmpty(activeAccount.getProfilePictureUrl())) { composeAvatar.setImageResource(R.drawable.avatar_default); } else { Picasso.with(this).load(activeAccount.getProfilePictureUrl()).error(R.drawable.avatar_default) .placeholder(R.drawable.avatar_default).into(composeAvatar); } composeAvatar.setContentDescription( getString(R.string.compose_active_account_description, activeAccount.getFullName())); mastodonApi.getInstance().enqueue(new Callback<Instance>() { @Override public void onResponse(@NonNull Call<Instance> call, @NonNull Response<Instance> response) { if (response.isSuccessful() && response.body().getMaxTootChars() != null) { maximumTootCharacters = response.body().getMaxTootChars(); updateVisibleCharactersLeft(); cacheInstanceMetadata(activeAccount); } } @Override public void onFailure(@NonNull Call<Instance> call, @NonNull Throwable t) { Log.w(TAG, "error loading instance data", t); loadCachedInstanceMetadata(activeAccount); } }); mastodonApi.getCustomEmojis().enqueue(new Callback<List<Emoji>>() { @Override public void onResponse(@NonNull Call<List<Emoji>> call, @NonNull Response<List<Emoji>> response) { emojiList = response.body(); setEmojiList(emojiList); cacheInstanceMetadata(activeAccount); } @Override public void onFailure(@NonNull Call<List<Emoji>> call, @NonNull Throwable t) { Log.w(TAG, "error loading custom emojis", t); loadCachedInstanceMetadata(activeAccount); } }); } else { // do not do anything when not logged in, activity will be finished in super.onCreate() anyway return; } composeOptionsView = findViewById(R.id.composeOptionsBottomSheet); composeOptionsView.setListener(this); composeOptionsBehavior = BottomSheetBehavior.from(composeOptionsView); composeOptionsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); addMediaBehavior = BottomSheetBehavior.from(findViewById(R.id.addMediaBottomSheet)); emojiBehavior = BottomSheetBehavior.from(emojiView); emojiView.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.HORIZONTAL, false)); enableButton(emojiButton, false, false); // Setup the interface buttons. tootButton.setOnClickListener(v -> onSendClicked()); pickButton.setOnClickListener(v -> openPickDialog()); visibilityButton.setOnClickListener(v -> showComposeOptions()); contentWarningButton.setOnClickListener(v -> onContentWarningChanged()); emojiButton.setOnClickListener(v -> showEmojis()); hideMediaToggle.setOnClickListener(v -> toggleHideMedia()); TextView actionPhotoTake = findViewById(R.id.action_photo_take); TextView actionPhotoPick = findViewById(R.id.action_photo_pick); int textColor = ThemeUtils.getColor(this, android.R.attr.textColorTertiary); Drawable cameraIcon = new IconicsDrawable(this, GoogleMaterial.Icon.gmd_camera_alt).color(textColor) .sizeDp(18); TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(actionPhotoTake, cameraIcon, null, null, null); Drawable imageIcon = new IconicsDrawable(this, GoogleMaterial.Icon.gmd_image).color(textColor).sizeDp(18); TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(actionPhotoPick, imageIcon, null, null, null); actionPhotoTake.setOnClickListener(v -> initiateCameraApp()); actionPhotoPick.setOnClickListener(v -> onMediaPick()); thumbnailViewSize = getResources().getDimensionPixelSize(R.dimen.compose_media_preview_size); /* Initialise all the state, or restore it from a previous run, to determine a "starting" * state. */ Status.Visibility startingVisibility = Status.Visibility.UNKNOWN; boolean startingHideText; ArrayList<SavedQueuedMedia> savedMediaQueued = null; if (savedInstanceState != null) { startingVisibility = Status.Visibility .byNum(savedInstanceState.getInt("statusVisibility", Status.Visibility.PUBLIC.getNum())); statusMarkSensitive = savedInstanceState.getBoolean("statusMarkSensitive"); startingHideText = savedInstanceState.getBoolean("statusHideText"); // Keep these until everything needed to put them in the queue is finished initializing. savedMediaQueued = savedInstanceState.getParcelableArrayList("savedMediaQueued"); // These are for restoring an in-progress commit content operation. InputContentInfoCompat previousInputContentInfo = InputContentInfoCompat .wrap(savedInstanceState.getParcelable("commitContentInputContentInfo")); int previousFlags = savedInstanceState.getInt("commitContentFlags"); if (previousInputContentInfo != null) { onCommitContentInternal(previousInputContentInfo, previousFlags); } photoUploadUri = savedInstanceState.getParcelable("photoUploadUri"); } else { statusMarkSensitive = false; startingHideText = false; photoUploadUri = null; } /* If the composer is started up as a reply to another post, override the "starting" state * based on what the intent from the reply request passes. */ Intent intent = getIntent(); String[] mentionedUsernames = null; ArrayList<String> loadedDraftMediaUris = null; inReplyToId = null; if (intent != null) { if (startingVisibility == Status.Visibility.UNKNOWN) { Status.Visibility preferredVisibility = Status.Visibility.byString( preferences.getString("defaultPostPrivacy", Status.Visibility.PUBLIC.serverString())); Status.Visibility replyVisibility = Status.Visibility .byNum(intent.getIntExtra(REPLY_VISIBILITY_EXTRA, Status.Visibility.UNKNOWN.getNum())); startingVisibility = Status.Visibility .byNum(Math.max(preferredVisibility.getNum(), replyVisibility.getNum())); } inReplyToId = intent.getStringExtra(IN_REPLY_TO_ID_EXTRA); mentionedUsernames = intent.getStringArrayExtra(MENTIONED_USERNAMES_EXTRA); String contentWarning = intent.getStringExtra(CONTENT_WARNING_EXTRA); if (contentWarning != null) { startingHideText = !contentWarning.isEmpty(); if (startingHideText) { startingContentWarning = contentWarning; } } // If come from SavedTootActivity String savedTootText = intent.getStringExtra(SAVED_TOOT_TEXT_EXTRA); if (!TextUtils.isEmpty(savedTootText)) { startingText = savedTootText; textEditor.setText(savedTootText); } String savedJsonUrls = intent.getStringExtra(SAVED_JSON_URLS_EXTRA); if (!TextUtils.isEmpty(savedJsonUrls)) { // try to redo a list of media loadedDraftMediaUris = new Gson().fromJson(savedJsonUrls, new TypeToken<ArrayList<String>>() { }.getType()); } int savedTootUid = intent.getIntExtra(SAVED_TOOT_UID_EXTRA, 0); if (savedTootUid != 0) { this.savedTootUid = savedTootUid; } if (intent.hasExtra(REPLYING_STATUS_AUTHOR_USERNAME_EXTRA)) { replyTextView.setVisibility(View.VISIBLE); String username = intent.getStringExtra(REPLYING_STATUS_AUTHOR_USERNAME_EXTRA); replyTextView.setText(getString(R.string.replying_to, username)); Drawable arrowDownIcon = new IconicsDrawable(this, GoogleMaterial.Icon.gmd_arrow_drop_down) .sizeDp(12); ThemeUtils.setDrawableTint(this, arrowDownIcon, android.R.attr.textColorTertiary); TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(replyTextView, null, null, arrowDownIcon, null); replyTextView.setOnClickListener(v -> { TransitionManager.beginDelayedTransition((ViewGroup) replyContentTextView.getParent()); if (replyContentTextView.getVisibility() != View.VISIBLE) { replyContentTextView.setVisibility(View.VISIBLE); Drawable arrowUpIcon = new IconicsDrawable(this, GoogleMaterial.Icon.gmd_arrow_drop_up) .sizeDp(12); ThemeUtils.setDrawableTint(this, arrowUpIcon, android.R.attr.textColorTertiary); TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(replyTextView, null, null, arrowUpIcon, null); } else { replyContentTextView.setVisibility(View.GONE); TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(replyTextView, null, null, arrowDownIcon, null); } }); } if (intent.hasExtra(REPLYING_STATUS_CONTENT_EXTRA)) { replyContentTextView.setText(intent.getStringExtra(REPLYING_STATUS_CONTENT_EXTRA)); } } // After the starting state is finalised, the interface can be set to reflect this state. setStatusVisibility(startingVisibility); updateHideMediaToggle(); updateVisibleCharactersLeft(); // Setup the main text field. textEditor.setOnCommitContentListener(this); final int mentionColour = textEditor.getLinkTextColors().getDefaultColor(); SpanUtilsKt.highlightSpans(textEditor.getText(), mentionColour); textEditor.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable editable) { SpanUtilsKt.highlightSpans(editable, mentionColour); updateVisibleCharactersLeft(); } }); textEditor.setAdapter(new MentionAutoCompleteAdapter(this, R.layout.item_autocomplete, this)); textEditor.setTokenizer(new MentionTokenizer()); // Add any mentions to the text field when a reply is first composed. if (mentionedUsernames != null) { StringBuilder builder = new StringBuilder(); for (String name : mentionedUsernames) { builder.append('@'); builder.append(name); builder.append(' '); } startingText = builder.toString(); textEditor.setText(startingText); textEditor.setSelection(textEditor.length()); } // work around Android platform bug -> https://issuetracker.google.com/issues/67102093 if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O || Build.VERSION.SDK_INT == Build.VERSION_CODES.O_MR1) { textEditor.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } // Initialise the content warning editor. contentWarningEditor.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateVisibleCharactersLeft(); } @Override public void afterTextChanged(Editable s) { } }); showContentWarning(startingHideText); if (startingContentWarning != null) { contentWarningEditor.setText(startingContentWarning); } // Initialise the empty media queue state. waitForMediaLatch = new CountUpDownLatch(); // These can only be added after everything affected by the media queue is initialized. if (!ListUtils.isEmpty(loadedDraftMediaUris)) { for (String uriString : loadedDraftMediaUris) { Uri uri = Uri.parse(uriString); long mediaSize = MediaUtils.getMediaSize(getContentResolver(), uri); pickMedia(uri, mediaSize); } } else if (savedMediaQueued != null) { for (SavedQueuedMedia item : savedMediaQueued) { Bitmap preview = MediaUtils.getImageThumbnail(getContentResolver(), item.uri, thumbnailViewSize); addMediaToQueue(item.id, item.type, preview, item.uri, item.mediaSize, item.readyStage, item.description); } } else if (intent != null && savedInstanceState == null) { /* Get incoming images being sent through a share action from another app. Only do this * when savedInstanceState is null, otherwise both the images from the intent and the * instance state will be re-queued. */ String type = intent.getType(); if (type != null) { if (type.startsWith("image/")) { List<Uri> uriList = new ArrayList<>(); if (intent.getAction() != null) { switch (intent.getAction()) { case Intent.ACTION_SEND: { Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (uri != null) { uriList.add(uri); } break; } case Intent.ACTION_SEND_MULTIPLE: { ArrayList<Uri> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (list != null) { for (Uri uri : list) { if (uri != null) { uriList.add(uri); } } } break; } } } for (Uri uri : uriList) { long mediaSize = MediaUtils.getMediaSize(getContentResolver(), uri); pickMedia(uri, mediaSize); } } else if (type.equals("text/plain")) { String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_SEND)) { String text = intent.getStringExtra(Intent.EXTRA_TEXT); if (text != null) { int start = Math.max(textEditor.getSelectionStart(), 0); int end = Math.max(textEditor.getSelectionEnd(), 0); int left = Math.min(start, end); int right = Math.max(start, end); textEditor.getText().replace(left, right, text, 0, text.length()); } } } } } textEditor.requestFocus(); }
From source file:com.msopentech.applicationgateway.EnterpriseBrowserActivity.java
/** * Shows dialog enabling user to bookmark current (by default) or any other page. * //from ww w.j a v a 2 s . c o m * @param v View this method is attached to. */ public void showAddBookmarkDialog(View v) { try { final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.create_bookmark_dialog); dialog.setTitle(getString(R.string.bookmark_dialog_title)); dialog.setCanceledOnTouchOutside(false); TextView cancelButton = (TextView) dialog.findViewById(R.id.create_bookmark_cancel); TextView saveButton = (TextView) dialog.findViewById(R.id.create_bookmark_ok); OnClickListener listener = new OnClickListener() { public void onClick(View v) { switch (v.getId()) { case R.id.create_bookmark_cancel: { dialog.dismiss(); break; } case R.id.create_bookmark_ok: { String name = ((EditText) dialog.findViewById(R.id.create_bookmark_name)).getText() .toString(); String address = ((EditText) dialog.findViewById(R.id.create_bookmark_url)).getText() .toString(); if (null != name && !(name.contentEquals("")) && null != address && !(address.contentEquals(""))) { PersistenceManager.addRecord(PersistenceManager.ContentType.BOOKMARKS, new URLInfo(address, name)); } dialog.dismiss(); break; } } } }; cancelButton.setOnClickListener(listener); saveButton.setOnClickListener(listener); EditText name = (EditText) dialog.findViewById(R.id.create_bookmark_name); EditText address = (EditText) dialog.findViewById(R.id.create_bookmark_url); name.setText(mActiveWebView.getTitle()); address.setText(mUrlEditTextView.getText()); dialog.show(); } catch (final Exception e) { Utility.showAlertDialog(EnterpriseBrowserActivity.class.getSimpleName() + ".showAddBookmarkDialog(): Failed. " + e.toString(), EnterpriseBrowserActivity.this); } }