Java Code Examples for android.widget.LinearLayout#removeAllViews()

The following examples show how to use android.widget.LinearLayout#removeAllViews() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdvancedShortcutActivity.java    From TvAppRepo with Apache License 2.0 6 votes vote down vote up
@Override
public void onIcons(PackedIcon[] icons) {
    if (getResources().getBoolean(R.bool.ENABLE_ICON_PACKS)) {
        Log.d(TAG, icons.length + "<<<");
        // Show all icons for the user to select (or let them do their own)
        LinearLayout iconDialogLayout = (LinearLayout) findViewById(R.id.icon_list);
        iconDialogLayout.requestFocus();
        iconDialogLayout.removeAllViews();
        for (final PackedIcon icon : icons) {
            ImageButton imageButton = new ImageButton(AdvancedShortcutActivity.this);
            imageButton.setImageDrawable(icon.icon);
            imageButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (icon.isBanner) {
                        advancedOptions.setBannerBitmap(icon.getBitmap());
                    } else {
                        advancedOptions.setIconBitmap(icon.getBitmap());
                    }
                    Log.d(TAG, advancedOptions.toString());
                }
            });
            iconDialogLayout.addView(imageButton);
        }
    }
}
 
Example 2
Source File: AppLists.java    From YalpStore with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void draw() {
    LinearLayout relatedLinksLayout = activity.findViewById(R.id.related_links);
    boolean developerLinkFound = false;
    relatedLinksLayout.removeAllViews();
    for (final String label: app.getRelatedLinks().keySet()) {
        relatedLinksLayout.setVisibility(View.VISIBLE);
        relatedLinksLayout.addView(buildLinkView(label, app.getRelatedLinks().get(label)));
        if (label.contains(app.getDeveloperName())) {
            developerLinkFound = true;
        }
    }
    if (!developerLinkFound && !TextUtils.isEmpty(app.getDeveloperName())) {
        addAppsByThisDeveloper();
    }
}
 
Example 3
Source File: RecordPopup.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
private void setTimelineRow(LinearLayout timelineRow, BaseItemDto program) {
    timelineRow.removeAllViews();
    if (program.getStartDate() == null) return;

    Date local = TimeUtils.convertToLocalDate(program.getStartDate());
    TextView on = new TextView(mActivity);
    on.setText(mActivity.getString(R.string.lbl_on));
    timelineRow.addView(on);
    TextView channel = new TextView(mActivity);
    channel.setText(program.getChannelName());
    channel.setTypeface(null, Typeface.BOLD);
    channel.setTextColor(mActivity.getResources().getColor(android.R.color.holo_blue_light));
    timelineRow.addView(channel);
    TextView datetime = new TextView(mActivity);
    datetime.setText(TimeUtils.getFriendlyDate(local)+ " @ "+android.text.format.DateFormat.getTimeFormat(mActivity).format(local)+ " ("+ DateUtils.getRelativeTimeSpanString(local.getTime())+")");
    timelineRow.addView(datetime);

}
 
Example 4
Source File: EnterpriseHDMSendCollectSignatureActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private void initView() {
    findViewById(R.id.ibtn_back).setOnClickListener(new IBackClickListener());
    findViewById(R.id.btn_add).setOnClickListener(addClick);
    tvSignatureNeeded = (TextView) findViewById(R.id.tv_signature_needed);
    llSignatures = (LinearLayout) findViewById(R.id.ll_signatures);
    tvSignatureNeeded.setText(String.format(getString(R.string
            .enterprise_hdm_keychain_payment_proposal_signature_needed), pool.threshold(),
            pool.pubCount()));
    llSignatures.removeAllViews();
    LayoutInflater inflater = LayoutInflater.from(this);
    for (int i = 0;
         i < pool.threshold();
         i++) {
        inflater.inflate(R.layout.list_item_enterprise_hdm_collector, llSignatures, true);
    }
}
 
Example 5
Source File: TvManager.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
public static void setTimelineRow(Activity activity, LinearLayout timelineRow, BaseItemDto program) {
    timelineRow.removeAllViews();
    Date local = TimeUtils.convertToLocalDate(program.getStartDate());
    TextView on = new TextView(activity);
    on.setText(activity.getResources().getString(R.string.lbl_on));
    timelineRow.addView(on);
    TextView channel = new TextView(activity);
    channel.setText(program.getChannelName());
    channel.setTypeface(null, Typeface.BOLD);
    channel.setTextColor(activity.getResources().getColor(android.R.color.holo_blue_light));
    timelineRow.addView(channel);
    TextView datetime = new TextView(activity);
    datetime.setText(TimeUtils.getFriendlyDate(local)+ " @ "+android.text.format.DateFormat.getTimeFormat(activity).format(local)+ " ("+ DateUtils.getRelativeTimeSpanString(local.getTime())+")");
    timelineRow.addView(datetime);

}
 
Example 6
Source File: MaterialDialog.java    From DialogUtil with Apache License 2.0 6 votes vote down vote up
public void setContentView(View contentView) {
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    contentView.setLayoutParams(layoutParams);
    if (contentView instanceof ListView) {
        setListViewHeightBasedOnChildren((ListView) contentView);
    }
    LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
            R.id.message_content_view);
    if (linearLayout != null) {
        linearLayout.removeAllViews();
        linearLayout.addView(contentView);
    }
    for (int i = 0; i < (linearLayout != null ? linearLayout.getChildCount() : 0); i++) {
        if (linearLayout.getChildAt(i) instanceof AutoCompleteTextView) {
            AutoCompleteTextView autoCompleteTextView
                    = (AutoCompleteTextView) linearLayout.getChildAt(i);
            autoCompleteTextView.setFocusable(true);
            autoCompleteTextView.requestFocus();
            autoCompleteTextView.setFocusableInTouchMode(true);
        }
    }
}
 
Example 7
Source File: AppSecurityPermissions.java    From fdroidclient with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Utility method that displays permissions from a map containing group name and
 * list of permission descriptions.
 */
private void displayPermissions(List<MyPermissionGroupInfo> groups,
                                LinearLayout permListView, int which) {
    permListView.removeAllViews();

    int spacing = (int) (8 * context.getResources().getDisplayMetrics().density);

    for (MyPermissionGroupInfo grp : groups) {
        final List<MyPermissionInfo> perms = getPermissionList(grp, which);
        for (int j = 0; j < perms.size(); j++) {
            MyPermissionInfo perm = perms.get(j);
            View view = getPermissionItemView(grp, perm, j == 0,
                    which != WHICH_NEW ? newPermPrefix : null);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
            if (j == 0) {
                lp.topMargin = spacing;
            }
            if (j == grp.allPermissions.size() - 1) {
                lp.bottomMargin = spacing;
            }
            if (permListView.getChildCount() == 0) {
                lp.topMargin *= 2;
            }
            permListView.addView(view, lp);
        }
    }
}
 
Example 8
Source File: VideoViewManager.java    From sealrtc-android with MIT License 5 votes vote down vote up
public void initViews(Context context, boolean isObserver) {
    this.context = context;
    getSize();
    int base = screenHeight < screenWidth ? screenHeight : screenWidth;
    remoteLayoutParams = new LinearLayout.LayoutParams(base / 4, base / 3);

    SessionManager.getInstance().put(Utils.KEY_screeHeight, base / 3);
    SessionManager.getInstance().put(Utils.KEY_screeWidth, base / 4);

    holderContainer =
            (LinearLayout) ((Activity) context).findViewById(R.id.call_reder_container);
    holderBigContainer =
            (ContainerLayout) ((Activity) context).findViewById(R.id.call_render_big_container);
    holderBigContainer.setGestureEvents(this);
    debugInfoView = (LinearLayout) ((Activity) context).findViewById(R.id.debug_info);
    //        debugInfoView.setOnClickListener(
    //                new View.OnClickListener() {
    //                    @Override
    //                    public void onClick(View v) {
    //                        doubleClick(false);
    //                    }
    //                });

    this.isObserver = isObserver;

    holderContainer.removeAllViews();
    holderBigContainer.removeAllViews();
    toggleTips();
}
 
Example 9
Source File: SimpleOperater.java    From TimetableView with MIT License 5 votes vote down vote up
/**
 * 构建侧边栏
 *
 * @param slidelayout 侧边栏的容器
 */
public void newSlideView(LinearLayout slidelayout) {
    if (slidelayout == null) return;
    slidelayout.removeAllViews();

    ISchedule.OnSlideBuildListener listener = mView.onSlideBuildListener();
    listener.onInit(slidelayout, mView.slideAlpha());
    for (int i = 0; i < mView.maxSlideItem(); i++) {
        View view = listener.getView(i, inflater, mView.itemHeight(), mView.marTop());
        slidelayout.addView(view);
    }
}
 
Example 10
Source File: EntitySubnodeDetailFragment.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        this.modifier = savedInstanceState.getParcelable(MODIFIER_KEY);
    }

    Detail detailToDisplay = getDetailToUseForDisplay();
    TreeReference referenceToDisplay = getReferenceToDisplay();

    View rootView = inflater.inflate(R.layout.entity_detail_list, container, false);
    final Activity thisActivity = getActivity();
    this.listView = rootView.findViewById(R.id.screen_entity_detail_list);
    if (this.adapter == null && this.loader == null && !EntityLoaderTask.attachToActivity(this)) {
        // Set up task to fetch entity data
        EntityLoaderTask theLoader =
                new EntityLoaderTask(detailToDisplay, getFactoryContextForRef(referenceToDisplay));
        theLoader.attachListener(this);
        theLoader.executeParallel(detailToDisplay.getNodeset().contextualize(referenceToDisplay));

        // Add header row
        final LinearLayout headerLayout = rootView.findViewById(R.id.entity_detail_header);
        String[] headers = new String[detailToDisplay.getFields().length];
        for (int i = 0; i < headers.length; ++i) {
            headers[i] = detailToDisplay.getFields()[i].getHeader().evaluate();
        }
        EntityView headerView = EntityView.buildHeadersEntityView(thisActivity, detailToDisplay,
                headers, false);
        headerLayout.removeAllViews();
        headerLayout.addView(headerView);
        headerLayout.setVisibility(View.VISIBLE);
    }

    return rootView;
}
 
Example 11
Source File: InfoLayoutHelper.java    From jellyfin-androidtv with GNU General Public License v2.0 5 votes vote down vote up
private static void addSubText(Activity activity, BaseRowItem item, LinearLayout layout) {
    layout.removeAllViews();
    TextView text = new TextView(activity);
    text.setTextSize(textSize);
    text.setText(item.getSubText() + " ");
    layout.addView(text);

}
 
Example 12
Source File: NotificationsCard.java    From WaniKani-for-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.card_notifications, container, false);

    Bundle bundle = getArguments();
    //noinspection unchecked
    List<Notification> notifications = (List<Notification>) bundle.getSerializable(ARG_NOTIFICATIONS);

    if (notifications != null && notifications.size() != 0) {
        LinearLayout holder = (LinearLayout) rootView.findViewById(R.id.notifications_holder);

        holder.removeAllViews();
        for (final Notification n : notifications) {
            ViewGroup item = (ViewGroup) inflater.inflate(R.layout.item_notification, holder, false);

            TextView title = (TextView) item.findViewById(R.id.notification_title);
            TextView shortText = (TextView) item.findViewById(R.id.notification_short_text);

            title.setText(n.getTitle());
            shortText.setText(n.getShortText());

            item.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getContext(), NotificationDetailsActivity.class);
                    intent.putExtra(NotificationDetailsActivity.ARG_NOTIFICATION, n);
                    startActivity(intent);
                }
            });

            holder.addView(item);
        }
    }

    return rootView;
}
 
Example 13
Source File: FaBoVirtualServiceActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
/**
 * プロファイルのリストをを再設定します.
 */
private void resetProfileLayout() {
    LinearLayout profileLayout = findViewById(R.id.activity_fabo_profile_list);
    profileLayout.removeAllViews();

    for (ProfileData profileData : mServiceData.getProfileDataList()) {
        View view = createProfileView(profileData);
        profileLayout.addView(view);
    }
}
 
Example 14
Source File: QueryByIpActivity.java    From styT with Apache License 2.0 4 votes vote down vote up
private void onWeatherDetailsGot(Map<String, Object> result) {
	TextView tvWeather = (TextView) findViewById(R.id.tvWeather);
	TextView tvTemperature = (TextView) findViewById(R.id.tvTemperature);
	TextView tvHumidity = (TextView) findViewById(R.id.tvHumidity);
	TextView tvWind = (TextView) findViewById(R.id.tvWind);
	TextView tvSunrise = (TextView) findViewById(R.id.tvSunrise);
	TextView tvSunset = (TextView) findViewById(R.id.tvSunset);
	TextView tvAirCondition = (TextView) findViewById(R.id.tvAirCondition);
	TextView tvPollution = (TextView) findViewById(R.id.tvPollution);
	TextView tvCold = (TextView) findViewById(R.id.tvCold);
	TextView tvDressing = (TextView) findViewById(R.id.tvDressing);
	TextView tvExercise = (TextView) findViewById(R.id.tvExercise);
	TextView tvWash = (TextView) findViewById(R.id.tvWash);
	TextView tvCrawlerTime = (TextView) findViewById(R.id.tvCrawlerTime);

	@SuppressWarnings("unchecked")
	ArrayList<HashMap<String, Object>> results = (ArrayList<HashMap<String, Object>>) result.get("result");
	HashMap<String, Object> weather = results.get(0);
	tvWeather.setText(com.mob.tools.utils.ResHelper.toString(weather.get("weather")));
	tvTemperature.setText(com.mob.tools.utils.ResHelper.toString(weather.get("temperature")));
	tvHumidity.setText(com.mob.tools.utils.ResHelper.toString(weather.get("humidity")));
	tvWind.setText(com.mob.tools.utils.ResHelper.toString(weather.get("wind")));
	tvSunrise.setText(com.mob.tools.utils.ResHelper.toString(weather.get("sunrise")));
	tvSunset.setText(com.mob.tools.utils.ResHelper.toString(weather.get("sunset")));
	tvAirCondition.setText(com.mob.tools.utils.ResHelper.toString(weather.get("airCondition")));
	tvPollution.setText(com.mob.tools.utils.ResHelper.toString(weather.get("pollutionIndex")));
	tvCold.setText(com.mob.tools.utils.ResHelper.toString(weather.get("coldIndex")));
	tvDressing.setText(com.mob.tools.utils.ResHelper.toString(weather.get("dressingIndex")));
	tvExercise.setText(com.mob.tools.utils.ResHelper.toString(weather.get("exerciseIndex")));
	tvWash.setText(com.mob.tools.utils.ResHelper.toString(weather.get("washIndex")));
	String time = com.mob.tools.utils.ResHelper.toString(weather.get("updateTime"));
	String date = time.substring(0, 4) + "-" + time.substring(4, 6) + "-" + time.substring(6, 8);
	time = time.substring(8, 10) + ":" + time.substring(10, 12) + ":" + time.substring(12);
	tvCrawlerTime.setText(date + " " + time);

	@SuppressWarnings("unchecked")
	ArrayList<HashMap<String, Object>> weeks = (ArrayList<HashMap<String,Object>>) weather.get("future");
	if (weeks != null) {
		LinearLayout llWeekList = (LinearLayout) findViewById(R.id.llWeekList);
		llWeekList.removeAllViews();
		for (HashMap<String, Object> week : weeks) {
			View llWeek = View.inflate(this, R.layout.view_weather_week, null);
			llWeekList.addView(llWeek);

			TextView tvWeek = (TextView) llWeek.findViewById(R.id.tvWeek);
			TextView tvWeekTemperature = (TextView) llWeek.findViewById(R.id.tvWeekTemperature);
			TextView tvWeekDayTime = (TextView) llWeek.findViewById(R.id.tvWeekDayTime);
			TextView tvWeekNight = (TextView) llWeek.findViewById(R.id.tvWeekNight);
			TextView tvWeekWind = (TextView) llWeek.findViewById(R.id.tvWeekWind);

			tvWeek.setText(com.mob.tools.utils.ResHelper.toString(week.get("week")));
			tvWeekTemperature.setText(com.mob.tools.utils.ResHelper.toString(week.get("temperature")));
			tvWeekDayTime.setText(com.mob.tools.utils.ResHelper.toString(week.get("dayTime")));
			tvWeekNight.setText(com.mob.tools.utils.ResHelper.toString(week.get("night")));
			tvWeekWind.setText(com.mob.tools.utils.ResHelper.toString(week.get("wind")));
		}
	}
}
 
Example 15
Source File: PopupManager.java    From onpc with GNU General Public License v3.0 4 votes vote down vote up
private void updateTrackMenuGroup(@NonNull final MainActivity activity,
                                  @NonNull final State state,
                                  @NonNull LinearLayout trackMenuGroup)
{
    trackMenuGroup.removeAllViews();
    final List<XmlListItemMsg> menuItems = state.cloneMediaItems();
    for (final XmlListItemMsg msg : menuItems)
    {
        if (msg.getTitle() == null || msg.getTitle().isEmpty())
        {
            continue;
        }
        Logging.info(this, "    menu item: " + msg.toString());
        final LinearLayout itemView = (LinearLayout) LayoutInflater.from(activity).
                inflate(R.layout.media_item, trackMenuGroup, false);
        final View textView = itemView.findViewById(R.id.media_item_title);
        if (textView != null)
        {
            ((TextView) textView).setText(msg.getTitle());
            if (!msg.isSelectable())
            {
                ((TextView) textView).setTextColor(Utils.getThemeColorAttr(activity,
                        android.R.attr.textColorSecondary));
                ((TextView) textView).setTextSize(TypedValue.COMPLEX_UNIT_PX,
                        activity.getResources().getDimensionPixelSize(R.dimen.secondary_text_size));
            }
        }
        itemView.setOnClickListener((View v) ->
        {
            if (activity.isConnected())
            {
                activity.getStateManager().sendMessage(msg);
            }
            if (trackMenuDialog != null)
            {
                trackMenuDialog.dismiss();
            }
        });
        trackMenuGroup.addView(itemView);
    }
}
 
Example 16
Source File: QueryByCityNameActivity.java    From stynico with MIT License 4 votes vote down vote up
private void onWeatherDetailsGot(Map<String, Object> result)
{
	TextView tvWeather = (TextView) findViewById(R.id.tvWeather);
	TextView tvTemperature = (TextView) findViewById(R.id.tvTemperature);
	TextView tvHumidity = (TextView) findViewById(R.id.tvHumidity);
	TextView tvWind = (TextView) findViewById(R.id.tvWind);
	TextView tvSunrise = (TextView) findViewById(R.id.tvSunrise);
	TextView tvSunset = (TextView) findViewById(R.id.tvSunset);
	TextView tvAirCondition = (TextView) findViewById(R.id.tvAirCondition);
	TextView tvPollution = (TextView) findViewById(R.id.tvPollution);
	TextView tvCold = (TextView) findViewById(R.id.tvCold);
	TextView tvDressing = (TextView) findViewById(R.id.tvDressing);
	TextView tvExercise = (TextView) findViewById(R.id.tvExercise);
	TextView tvWash = (TextView) findViewById(R.id.tvWash);
	TextView tvCrawlerTime = (TextView) findViewById(R.id.tvCrawlerTime);

	@SuppressWarnings("unchecked")
		ArrayList<HashMap<String, Object>> results = (ArrayList<HashMap<String, Object>>) result.get("result");
	HashMap<String, Object> weather = results.get(0);
	tvWeather.setText(com.mob.tools.utils.R.toString(weather.get("weather")));
	tvTemperature.setText(com.mob.tools.utils.R.toString(weather.get("temperature")));
	tvHumidity.setText(com.mob.tools.utils.R.toString(weather.get("humidity")));
	tvWind.setText(com.mob.tools.utils.R.toString(weather.get("wind")));
	tvSunrise.setText(com.mob.tools.utils.R.toString(weather.get("sunrise")));
	tvSunset.setText(com.mob.tools.utils.R.toString(weather.get("sunset")));
	tvAirCondition.setText(com.mob.tools.utils.R.toString(weather.get("airCondition")));
	tvPollution.setText(com.mob.tools.utils.R.toString(weather.get("pollutionIndex")));
	tvCold.setText(com.mob.tools.utils.R.toString(weather.get("coldIndex")));
	tvDressing.setText(com.mob.tools.utils.R.toString(weather.get("dressingIndex")));
	tvExercise.setText(com.mob.tools.utils.R.toString(weather.get("exerciseIndex")));
	tvWash.setText(com.mob.tools.utils.R.toString(weather.get("washIndex")));
	String time = com.mob.tools.utils.R.toString(weather.get("updateTime"));
	String date = time.substring(0, 4) + "-" + time.substring(4, 6) + "-" + time.substring(6, 8);
	time = time.substring(8, 10) + ":" + time.substring(10, 12) + ":" + time.substring(12);
	tvCrawlerTime.setText(date + " " + time);

	@SuppressWarnings("unchecked")
		ArrayList<HashMap<String, Object>> weeks = (ArrayList<HashMap<String,Object>>) weather.get("future");
	if (weeks != null)
	{
		LinearLayout llWeekList = (LinearLayout) findViewById(R.id.llWeekList);
		llWeekList.removeAllViews();
		for (HashMap<String, Object> week : weeks)
		{
			View llWeek = View.inflate(this, R.layout.view_weather_week, null);
			llWeekList.addView(llWeek);

			TextView tvWeek = (TextView) llWeek.findViewById(R.id.tvWeek);
			TextView tvWeekTemperature = (TextView) llWeek.findViewById(R.id.tvWeekTemperature);
			TextView tvWeekDayTime = (TextView) llWeek.findViewById(R.id.tvWeekDayTime);
			TextView tvWeekNight = (TextView) llWeek.findViewById(R.id.tvWeekNight);
			TextView tvWeekWind = (TextView) llWeek.findViewById(R.id.tvWeekWind);

			tvWeek.setText(com.mob.tools.utils.R.toString(week.get("week")));
			tvWeekTemperature.setText(com.mob.tools.utils.R.toString(week.get("temperature")));
			tvWeekDayTime.setText(com.mob.tools.utils.R.toString(week.get("dayTime")));
			tvWeekNight.setText(com.mob.tools.utils.R.toString(week.get("night")));
			tvWeekWind.setText(com.mob.tools.utils.R.toString(week.get("wind")));
		}
	}
}
 
Example 17
Source File: EditorActivity.java    From APDE with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Set up the character inserts tray.
     */
	public void reloadCharInserts() {
		if (!keyboardVisible) {
			return;
		}
		
    	if (message == -1) {
			message = findViewById(R.id.buffer).getHeight();
		}
    	
    	//Get a reference to the button container
    	LinearLayout container = ((LinearLayout) findViewById(R.id.char_insert_tray_list));
    	//Clear any buttons from before
    	container.removeAllViews();
    	
    	//The (temporary) list of character inserts TODO make this list configurable
    	//"\u2192" is Unicode for the right arrow (like "->") - this is a graphical representation of the TAB key
    	String[] chars;
    	//This branch isn't very elegant... but it will work for now...
    	if(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("char_inserts_include_numbers", true))
    		chars = new String[] {"\u2192", ";", ".", ",", "{", "}", "(", ")", "=", "*", "/", "+", "-", "&", "|", "!", "[", "]", "<", ">", "\"", "'", "\\", "_", "?", ":", "%", "@", "#", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"};
    	else
    		chars = new String[] {"\u2192", ";", ".", ",", "{", "}", "(", ")", "=", "*", "/", "+", "-", "&", "|", "!", "[", "]", "<", ">", "\"", "'", "\\", "_", "?", ":", "%", "@", "#"};
    	
    	//This works for now... as far as I can tell
    	final int keyboardID = 0;
		
    	//Add each button to the container
    	for(final String c : chars) {
    		Button button = (Button) LayoutInflater.from(this).inflate(R.layout.char_insert_button, null);
    		button.setText(c);
    		button.setTextColor(getResources().getColor(messageType != MessageType.MESSAGE ? R.color.char_insert_button_light : R.color.char_insert_button));
    		button.setLayoutParams(new LinearLayout.LayoutParams((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, getResources().getDisplayMetrics()), message));
    		button.setPadding(0, 0, 0, 0);
    		
    		// Disable key press sounds if the user wants them disabled
    		button.setSoundEffectsEnabled(getGlobalState().getPref("char_inserts_key_press_sound", false));
    		
    		//Maybe we'll want these at some point in time... but for now, they just cause more problems...
    		//...and the user won't be dragging the divider around if the keyboard is open (which it really should be)
//    		//Still let the user drag the message area
//    		button.setOnLongClickListener(messageListener);
//    		button.setOnTouchListener(messageListener);
    		
    		container.addView(button);
    		
    		button.setOnClickListener(view -> {
				// A special check for the tab key... making special exceptions aren't exactly ideal, but this is probably the most concise solution (for now)...
				KeyEvent event = c.equals("\u2192") ? new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_TAB) : new KeyEvent(SystemClock.uptimeMillis(), c, keyboardID, 0);
				
				boolean dispatched = false;
				
				if (extraHeaderView != null) {
					// If the find/replace toolbar is open
					
					EditText findTextField = extraHeaderView.findViewById(R.id.find_replace_find_text);
					EditText replaceTextField = extraHeaderView.findViewById(R.id.find_replace_replace_text);
					
					if (findTextField != null) {
						if (findTextField.hasFocus()) {
							findTextField.dispatchKeyEvent(event);
							dispatched = true;
						} else {
							if (replaceTextField != null && replaceTextField.hasFocus()) {
								replaceTextField.dispatchKeyEvent(event);
								dispatched = true;
							}
						}
					}
				}
				
				if (!dispatched) {
					getSelectedCodeArea().dispatchKeyEvent(event);
				}
				
				// Provide haptic feedback (if the user has vibrations enabled)
				if(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("pref_vibrate", true))
					((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(10); //10 millis
			});
    	}
    }
 
Example 18
Source File: MaterialDialog.java    From DialogUtil with Apache License 2.0 4 votes vote down vote up
public void setView(View view) {
    LinearLayout l = (LinearLayout) mAlertDialogWindow.findViewById(R.id.contentView);
    l.removeAllViews();
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    view.setLayoutParams(layoutParams);

    view.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override public void onFocusChange(View v, boolean hasFocus) {
            mAlertDialogWindow.setSoftInputMode(
                    WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            // show imm
            InputMethodManager imm = (InputMethodManager) mContext.getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
                    InputMethodManager.HIDE_IMPLICIT_ONLY);
        }
    });

    l.addView(view);

    if (view instanceof ViewGroup) {

        ViewGroup viewGroup = (ViewGroup) view;

        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            if (viewGroup.getChildAt(i) instanceof EditText) {
                EditText editText = (EditText) viewGroup.getChildAt(i);
                editText.setFocusable(true);
                editText.requestFocus();
                editText.setFocusableInTouchMode(true);
            }
        }
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            if (viewGroup.getChildAt(i) instanceof AutoCompleteTextView) {
                AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) viewGroup
                        .getChildAt(i);
                autoCompleteTextView.setFocusable(true);
                autoCompleteTextView.requestFocus();
                autoCompleteTextView.setFocusableInTouchMode(true);
            }
        }
    }
}
 
Example 19
Source File: PolygonMainEditingToolGroup.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
public void disable() {
    EditManager.INSTANCE.setActiveTool(null);
    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
    if (parent != null)
        parent.removeAllViews();
}
 
Example 20
Source File: MainActivity.java    From views-widgets-samples with Apache License 2.0 4 votes vote down vote up
/**
 * This method is called to populate the UI according to which interpolator was
 * selected.
 */
private void populateParametersUI(String interpolatorName, LinearLayout parent) {
    parent.removeAllViews();
    try {
        switch (interpolatorName) {
            case "Quadratic Path":
                createQuadraticPathInterpolator(parent);
                break;
            case "Cubic Path":
                createCubicPathInterpolator(parent);
                break;
            case "AccelerateDecelerate":
                mVisualizer.setInterpolator(new AccelerateDecelerateInterpolator());
                break;
            case "Linear":
                mVisualizer.setInterpolator(new LinearInterpolator());
                break;
            case "Bounce":
                mVisualizer.setInterpolator(new BounceInterpolator());
                break;
            case "Accelerate":
                Constructor<AccelerateInterpolator> decelConstructor =
                        AccelerateInterpolator.class.getConstructor(float.class);
                createParamaterizedInterpolator(parent, decelConstructor, "Factor", 1, 5, 1);
                break;
            case "Decelerate":
                Constructor<DecelerateInterpolator> accelConstructor =
                        DecelerateInterpolator.class.getConstructor(float.class);
                createParamaterizedInterpolator(parent, accelConstructor, "Factor", 1, 5, 1);
                break;
            case "Overshoot":
                Constructor<OvershootInterpolator> overshootConstructor =
                        OvershootInterpolator.class.getConstructor(float.class);
                createParamaterizedInterpolator(parent, overshootConstructor, "Tension", 1, 5, 1);
                break;
            case "Anticipate":
                Constructor<AnticipateInterpolator> anticipateConstructor =
                        AnticipateInterpolator.class.getConstructor(float.class);
                createParamaterizedInterpolator(parent, anticipateConstructor, "Tension", 1, 5, 1);
                break;
        }
    } catch (NoSuchMethodException e) {
        Log.e("InterpolatorPlayground", "Error constructing interpolator: " + e);
    }
}