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

The following examples show how to use android.widget.LinearLayout#setWeightSum() . 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: PluginElement.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected View createView(Context c) {
    Log.d(TAG, "");
    // New Layout
    LinearLayout container = new LinearLayout(c);
    container.setOrientation(LinearLayout.VERTICAL);
    container.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT));

    // Plugin Launcher
    View plug = getContentView(c);
    container.addView(plug, new LinearLayout.LayoutParams(
            LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.1f));

    //Add data viewer
    View review = viewDataView(c);
    container.addView(review, new LinearLayout.LayoutParams(
            LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.1f));
    container.setWeightSum(1.0f);
    return encapsulateQuestion(c, container);
}
 
Example 2
Source File: PluginEntryElement.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected View createView(Context c) {
    Log.d(TAG, "");
    // New Layout
    LinearLayout container = new LinearLayout(c);
    container.setOrientation(LinearLayout.VERTICAL);
    View plug = getContentView(c);
    container.addView(plug, new LinearLayout.LayoutParams(-1, -1, 0.1f));

    // Add text entry
    et = new EditText(c);
    et.setText(answer);
    et.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT));
    container.addView(et, new LinearLayout.LayoutParams(-1, -1, 0.1f));

    container.setWeightSum(1.0f);
    return encapsulateQuestion(c, container);
}
 
Example 3
Source File: MultiColumnListAdapter.java    From multi-column-list-adapter with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new row view.
 */
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    // create a row view
    LinearLayout row = new LinearLayout(context);
    row.setWeightSum(numColumns);

    V[] gridItemViewHolders = newGridItemViewHolderArray(numColumns);

    // inflate a grid item view for each column in the row
    for (int col = 0; col < numColumns; col++) {
        View gridItemView = newGridItemView(context, cursor, parent);
        LinearLayout.LayoutParams lp = newGridItemLayoutParams(col);

        gridItemViewHolders[col] = newGridItemViewHolder(gridItemView);
        row.addView(gridItemView, lp);
    }

    // save the grid item view holders in the row view holder
    RowViewHolder holder = new RowViewHolder(gridItemViewHolders);
    row.setTag(holder);
    return row;
}
 
Example 4
Source File: LegendActivity.java    From satstat with GNU General Public License v3.0 5 votes vote down vote up
protected void addLocationProvider(String title, String styleName) {
	Resources res = this.getBaseContext().getResources();
	TypedArray style = res.obtainTypedArray(res.getIdentifier(styleName, "array", this.getBaseContext().getPackageName()));
	Drawable drawable = style.getDrawable(STYLE_MARKER);
	style.recycle();

	LinearLayout lpLayout = new LinearLayout(legendMapContainer.getContext());
	lpLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	lpLayout.setOrientation(LinearLayout.HORIZONTAL);
	lpLayout.setWeightSum(22);
	lpLayout.setMeasureWithLargestChildEnabled(false);

	ImageView lpMarker = new ImageView(legendMapContainer.getContext());
	LinearLayout.LayoutParams lpMarkerParams = new LinearLayout.LayoutParams(0, getResources().getDimensionPixelSize(R.dimen.legend_rowheight), 3);
	int margin = getResources().getDimensionPixelSize(R.dimen.bitmap_padding);
	lpMarkerParams.gravity = Gravity.CENTER;
	lpMarker.setLayoutParams(lpMarkerParams);
	lpMarker.setPadding(margin, 0, margin, 0);
	lpMarker.setImageDrawable(drawable);
	lpMarker.setScaleType(ScaleType.CENTER);
	lpLayout.addView(lpMarker);

	TextView lpDesc = new TextView(legendMapContainer.getContext());
	LinearLayout.LayoutParams lpDescParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19);
	lpDescParams.gravity = Gravity.CENTER_VERTICAL;
	lpDesc.setLayoutParams(lpDescParams);
	lpDesc.setGravity(Gravity.CENTER_VERTICAL);
	lpDesc.setTextAppearance(this, R.style.TextAppearance_AppCompat_Medium);
	lpDesc.setText(title);
	lpLayout.addView(lpDesc);

	legendMapContainer.addView(lpLayout);
}
 
Example 5
Source File: PositionCallbackImpl.java    From android_app_cputempinstatusbar with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setup(MethodHookParam param, View v) {
	 cputemp = v;
	 mSystemIconArea = (LinearLayout)XposedHelpers.getObjectField(param.thisObject, "mSystemIconArea");
        mStatusBarContents = (LinearLayout)XposedHelpers.getObjectField(param.thisObject, "mStatusBarContents");
        Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext");

        container = new LinearLayout(mContext);
        container.setOrientation(LinearLayout.HORIZONTAL);
        container.setWeightSum(1);
        container.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
        container.setVisibility(View.GONE);
        mStatusBarContents.addView(container, 0);
}
 
Example 6
Source File: BaseDialog.java    From TestChat with Apache License 2.0 5 votes vote down vote up
public BaseDialog setCheckBoxName(List<String> list) {
        if (middleLayout.getChildCount() > 0) {
                middleLayout.removeAllViews();
        }
        for (String title :
                list) {
                TextView textView = new TextView(getContext());
                textView.setGravity(Gravity.START);
                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                layoutParams.weight = 1;
                textView.setLayoutParams(layoutParams);
                textView.setText(title);
                final CheckBox checkBox = new CheckBox(getContext());
                checkBox.setGravity(Gravity.END);
                LinearLayout.LayoutParams checkBoxLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                checkBoxLayout.weight = 1;
                checkBox.setLayoutParams(checkBoxLayout);
                LinearLayout linearLayout = new LinearLayout(getContext());
                LinearLayout.LayoutParams linearLayoutParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                linearLayout.setGravity(Gravity.CENTER_VERTICAL);
                linearLayout.setWeightSum(2);
                linearLayout.setLayoutParams(linearLayoutParam);
                linearLayout.addView(textView);
                linearLayout.addView(checkBox);
                middleLayout.addView(linearLayout);
        }
        return this;
}
 
Example 7
Source File: BaseDialog.java    From TestChat with Apache License 2.0 5 votes vote down vote up
public BaseDialog setCheckBoxName(List<String> list) {
        if (middleLayout.getChildCount() > 0) {
                middleLayout.removeAllViews();
        }
        for (String title :
                list) {
                TextView textView = new TextView(getContext());
                textView.setGravity(Gravity.START);
                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                layoutParams.weight = 1;
                textView.setLayoutParams(layoutParams);
                textView.setText(title);
                final CheckBox checkBox = new CheckBox(getContext());
                checkBox.setGravity(Gravity.END);
                LinearLayout.LayoutParams checkBoxLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                checkBoxLayout.weight = 1;
                checkBox.setLayoutParams(checkBoxLayout);
                LinearLayout linearLayout = new LinearLayout(getContext());
                LinearLayout.LayoutParams linearLayoutParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                linearLayout.setGravity(Gravity.CENTER_VERTICAL);
                linearLayout.setWeightSum(2);
                linearLayout.setLayoutParams(linearLayoutParam);
                linearLayout.addView(textView);
                linearLayout.addView(checkBox);
                middleLayout.addView(linearLayout);
        }
        return this;
}
 
Example 8
Source File: PRow.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
public PRow(Context c, LinearLayout cardLl, int n) {
    this.n = n;
    float t = 100f;
    float tt = t / n;

    ll = new LinearLayout(c);
    ll.setOrientation(LinearLayout.HORIZONTAL);
    ll.setWeightSum(t);
    cardLl.addView(ll);

    lParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, tt);
}
 
Example 9
Source File: AProgressBar.java    From Stylish-Widget-for-Android with Apache License 2.0 5 votes vote down vote up
private void setProgress(LinearLayout progressLayout, Progress progress, float previousValue, int i) {
    createGradientDrawableWithCorner(progressLayout, progress.color);

    LayoutParams params =
            new LayoutParams(0, RelativeLayout.LayoutParams.MATCH_PARENT, progress.value);

    progressLayout.setLayoutParams(params);

    progressLayout.setWeightSum(progress.value);

    ATextView textView = (ATextView) progressLayout.findViewById(i);
    LinearLayout layout = (LinearLayout) progressLayout.findViewById(100+i);
    if (textView != null) {
        textView.setText(progress.text);
        textView.setCompoundDrawablesWithIntrinsicBounds(
                progress.drawable,
                null,
                null,
                null
        );
        textView.setCompoundDrawablePadding(iconPadding);
        textView.setTextStyle(textStyle);
        textView.setTextSize(textSize);
        textView.setSupportTextAppearance(textAppearance);
        layout.setLayoutParams(new LayoutParams(
                0,
                ViewGroup.LayoutParams.MATCH_PARENT,
                progress.value - previousValue
        ));
    }

}
 
Example 10
Source File: QrDisplayActivity.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle state) {
	super.onCreate(state);

	setRequestedOrientation(SCREEN_ORIENTATION_NOSENSOR);

	getSupportActionBar().hide();

	String qrData = getIntent().getStringExtra(Intent.EXTRA_TEXT);

	ImageView qrCodeView = new ImageView(this);

	qrCodeView.setScaleType(FIT_CENTER);
	qrCodeView.setBackgroundColor(WHITE);
	qrCodeView.setLayoutParams(new LayoutParams(MATCH_PARENT,
			MATCH_PARENT, 1f));

	Display display = getWindowManager().getDefaultDisplay();
	boolean portrait = display.getWidth() < display.getHeight();
	layoutMain = new LinearLayout(this);
	if(portrait) layoutMain.setOrientation(VERTICAL);
	else layoutMain.setOrientation(HORIZONTAL);
	layoutMain.setWeightSum(1);
	layoutMain.addView(qrCodeView);
	setContentView(layoutMain);

	new QrGenAsyncTask(this, qrCodeView, 240).executeOnExecutor(ImApp.sThreadPoolExecutor,qrData);
}
 
Example 11
Source File: HashtagView.java    From hashtag-view with MIT License 5 votes vote down vote up
private ViewGroup getRowLayout(int weightSum) {
    LinearLayout rowLayout = new LinearLayout(getContext());
    rowLayout.setLayoutParams(rowLayoutParams);
    rowLayout.setOrientation(HORIZONTAL);
    rowLayout.setGravity(rowGravity);
    rowLayout.setWeightSum(weightSum);
    return rowLayout;
}
 
Example 12
Source File: QrDisplayActivity.java    From zom-android-matrix with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle state) {
	super.onCreate(state);

	setRequestedOrientation(SCREEN_ORIENTATION_NOSENSOR);

	getSupportActionBar().hide();

	String qrData = getIntent().getStringExtra(Intent.EXTRA_TEXT);

	ImageView qrCodeView = new ImageView(this);

	qrCodeView.setScaleType(FIT_CENTER);
	qrCodeView.setBackgroundColor(WHITE);
	qrCodeView.setLayoutParams(new LayoutParams(MATCH_PARENT,
			MATCH_PARENT, 1f));

	Display display = getWindowManager().getDefaultDisplay();
	boolean portrait = display.getWidth() < display.getHeight();
	layoutMain = new LinearLayout(this);
	if(portrait) layoutMain.setOrientation(VERTICAL);
	else layoutMain.setOrientation(HORIZONTAL);
	layoutMain.setWeightSum(1);
	layoutMain.addView(qrCodeView);
	setContentView(layoutMain);

	new QrGenAsyncTask(this, qrCodeView, 240).executeOnExecutor(ImApp.sThreadPoolExecutor,qrData);
}
 
Example 13
Source File: ShowPassword.java    From WiFiKeyView with Apache License 2.0 5 votes vote down vote up
/**
 * Display a row from the supplicant file in a human readable way
 * 
 * @param key
 * 	: The key for the entry
 * @param value
 * 	: The value for the entry
 * @return
 * 	: A TableRow object to be displayed
 */
private TableRow generateTableRow(String key, String value, int color) {
	// Generate row layout
	TableRow row = new TableRow(mContext);
	row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	
	// Add the key to the layout
	LinearLayout ll_key = new LinearLayout(mContext);
	TextView tv_key = new TextView(mContext);
	tv_key.setText(key);
	tv_key.setPadding(15, 0, 0, 0);
	tv_key.setTextColor(color);
	
	ll_key.addView(tv_key);
	ll_key.setOrientation(LinearLayout.VERTICAL);
	ll_key.setWeightSum(1.0f);
	row.addView(ll_key);
	
	// Add the value to the layout
	LinearLayout ll_value = new LinearLayout(mContext);
	TextView tv_value = new TextView(mContext);
	tv_value.setText(value);
	tv_value.setPadding(0, 0, 15, 0);
	tv_value.setTextColor(color);
	tv_value.setGravity(Gravity.RIGHT);
	
	ll_value.addView(tv_value);
	ll_value.setOrientation(LinearLayout.VERTICAL);
	ll_value.setWeightSum(1.0f);
	row.addView(ll_value);
	
	return row;
}
 
Example 14
Source File: BaseRunnerFragment.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Takes a view and wraps it with next/previous buttons for navigating.
 *
 * @param sub - the view which is to be wrapped
 * @return - a new view which is <param>sub</param> wrapped with next/prev
 * buttons.
 */
public View wrapViewWithInterface(View sub) {
    // View sub = state.current().toView(this);
    // RelativeLayout rl = new RelativeLayout(this);
    // rl.setLayoutParams( new ViewGroup.LayoutParams(
    // LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT ) );

    LinearLayout base = new LinearLayout(getActivity());
    base.setOrientation(LinearLayout.VERTICAL);

    LinearLayout ll = new LinearLayout(getActivity());
    ll.setOrientation(LinearLayout.HORIZONTAL);
    next = new Button(getActivity());
    next.setOnClickListener(this);
    info = new Button(getActivity());
    info.setOnClickListener(this);
    info.setText(getResources().getString(R.string.procedurerunner_info));
    info.setText(getResources().getString(R.string.procedurerunner_info));
    prev = new Button(getActivity());
    prev.setOnClickListener(this);

    next.setPadding(5, 5, 5, 5);
    prev.setPadding(5, 5, 5, 5);
    info.setPadding(5, 5, 5, 5);
    updateNextPrev();
    // Are we dispalying Info button
    boolean showEdu = PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean(
            Constants.PREFERENCE_EDUCATION_RESOURCE, false);
    float nextWeight = showEdu ? 0.333f : 0.5f;
    float infoWeight = showEdu ? 0.334f : 0.0f;
    float prevWeight = showEdu ? 0.333f : 0.5f;

    ll.addView(prev, new LinearLayout.LayoutParams(-2, -1, prevWeight));
    // Only show info button if Education Resource Setting is true
    if (showEdu)
        ll.addView(info, new LinearLayout.LayoutParams(-2, -1, infoWeight));
    ll.addView(next, new LinearLayout.LayoutParams(-2, -1, nextWeight));
    ll.setWeightSum(1.0f);

    // RelativeLayout.LayoutParams ll_lp = new
    // RelativeLayout.LayoutParams(-1,100);
    // ll_lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    // rl.addView(ll, ll_lp);

    // RelativeLayout.LayoutParams sub_lp = new
    // RelativeLayout.LayoutParams(-1,-1);
    // sub_lp.addRule(RelativeLayout.ABOVE, ll.getId());
    // rl.addView(sub, sub_lp);

    // ScrollView sv = new ScrollView(this);
    // sv.addView(sub, new ViewGroup.LayoutParams(-1,-1));
    // base.addView(sv, new LinearLayout.LayoutParams(-1,-2,0.99f));
    ViewGroup parent = (ViewGroup) sub.getParent();
    if (parent != null) {
        parent.removeView(sub);
    }
    base.addView(sub, new LinearLayout.LayoutParams(-1, -2, 0.99f));
    base.addView(ll, new LinearLayout.LayoutParams(-1, -2, 0.01f));

    base.setWeightSum(1.0f);

    return base;
}
 
Example 15
Source File: RadioSectionFragment.java    From satstat with GNU General Public License v3.0 4 votes vote down vote up
private final void addWifiResult(ScanResult result) {
	// needed to pass a persistent reference to the OnClickListener
	final ScanResult r = result;
	android.view.View.OnClickListener clis = new android.view.View.OnClickListener () {

		@Override
		public void onClick(View v) {
			onWifiEntryClick(r.BSSID);
		}
	};

	LinearLayout wifiLayout = new LinearLayout(wifiAps.getContext());
	wifiLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	wifiLayout.setOrientation(LinearLayout.HORIZONTAL);
	wifiLayout.setWeightSum(22);
	wifiLayout.setMeasureWithLargestChildEnabled(false);

	ImageView wifiType = new ImageView(wifiAps.getContext());
	wifiType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 3));
	if (WifiCapabilities.isAdhoc(result)) {
		wifiType.setImageResource(R.drawable.ic_content_wifi_adhoc);
	} else if ((WifiCapabilities.isEnterprise(result)) || (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.EAP)) {
		wifiType.setImageResource(R.drawable.ic_content_wifi_eap);
	} else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.PSK) {
		wifiType.setImageResource(R.drawable.ic_content_wifi_psk);
	} else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.WEP) {
		wifiType.setImageResource(R.drawable.ic_content_wifi_wep);
	} else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.OPEN) {
		wifiType.setImageResource(R.drawable.ic_content_wifi_open);
	} else {
		wifiType.setImageResource(R.drawable.ic_content_wifi_unknown);
	}

	wifiType.setScaleType(ScaleType.CENTER);
	wifiLayout.addView(wifiType);

	TableLayout wifiDetails = new TableLayout(wifiAps.getContext());
	wifiDetails.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
	TableRow innerRow1 = new TableRow(wifiAps.getContext());
	TextView newMac = new TextView(wifiAps.getContext());
	newMac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 14));
	newMac.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
	newMac.setText(result.BSSID);
	innerRow1.addView(newMac);
	TextView newCh = new TextView(wifiAps.getContext());
	newCh.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
	newCh.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
	newCh.setText(getChannelFromFrequency(result.frequency));
	innerRow1.addView(newCh);
	TextView newLevel = new TextView(wifiAps.getContext());
	newLevel.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
	newLevel.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
	newLevel.setText(String.valueOf(result.level));
	innerRow1.addView(newLevel);
	innerRow1.setOnClickListener(clis);
	wifiDetails.addView(innerRow1,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

	TableRow innerRow2 = new TableRow(wifiAps.getContext());
	TextView newSSID = new TextView(wifiAps.getContext());
	newSSID.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
	newSSID.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Small);
	newSSID.setText(result.SSID);
	innerRow2.addView(newSSID);
	innerRow2.setOnClickListener(clis);
	wifiDetails.addView(innerRow2, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

	wifiLayout.addView(wifiDetails);
	wifiLayout.setOnClickListener(clis);
	wifiAps.addView(wifiLayout);
}
 
Example 16
Source File: SessionCell.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public SessionCell(Context context, int type) {
    super(context);

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setWeightSum(1);

    if (type == 1) {
        addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 15 : 49), 11, (LocaleController.isRTL ? 49 : 15), 0));

        avatarDrawable = new AvatarDrawable();
        avatarDrawable.setTextSize(AndroidUtilities.dp(10));

        imageView = new BackupImageView(context);
        imageView.setRoundRadius(AndroidUtilities.dp(10));
        addView(imageView, LayoutHelper.createFrame(20, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 21), 13, (LocaleController.isRTL ? 21 : 0), 0));
    } else {
        addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 15 : 21), 11, (LocaleController.isRTL ? 21 : 15), 0));
    }

    nameTextView = new TextView(context);
    nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    nameTextView.setLines(1);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);

    onlineTextView = new TextView(context);
    onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    onlineTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP);

    if (LocaleController.isRTL) {
        linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 2, 0, 0));
        linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.RIGHT | Gravity.TOP, 10, 0, 0, 0));
    } else {
        linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.LEFT | Gravity.TOP, 0, 0, 10, 0));
        linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 2, 0, 0));
    }

    detailTextView = new TextView(context);
    detailTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    detailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    detailTextView.setLines(1);
    detailTextView.setMaxLines(1);
    detailTextView.setSingleLine(true);
    detailTextView.setEllipsize(TextUtils.TruncateAt.END);
    detailTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 36, 21, 0));

    detailExTextView = new TextView(context);
    detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
    detailExTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    detailExTextView.setLines(1);
    detailExTextView.setMaxLines(1);
    detailExTextView.setSingleLine(true);
    detailExTextView.setEllipsize(TextUtils.TruncateAt.END);
    detailExTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 59, 21, 0));
}
 
Example 17
Source File: PictureElement.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected View createView(Context c) {
    imageGrid = new GridView(c);
    Log.i(TAG, "Looking up for encounter: " + getProcedure().getInstanceUri());
    String procedureId =
            getProcedure().getInstanceUri().getLastPathSegment();
    Log.w(TAG, "PictureELement: Encounter id " + procedureId);
    String whereStr;
    if (!UUIDUtil.isValid(procedureId))
        whereStr = ImageSQLFormat.ENCOUNTER_ID + " = ? AND "
                + ImageSQLFormat.ELEMENT_ID + " = ? AND "
                + ImageSQLFormat.FILE_VALID + " = ?";
    else
        whereStr = ImageSQLFormat.ENCOUNTER_ID + " = '?' AND "
                + ImageSQLFormat.ELEMENT_ID + " = ? AND "
                + ImageSQLFormat.FILE_VALID + " = ?";

    Cursor cursor = c.getContentResolver().query(
            SanaDB.ImageSQLFormat.CONTENT_URI,
            new String[]{ImageSQLFormat._ID}, whereStr,
            new String[]{procedureId, id, "1"}, null);

    // HAXMODE -- if we don't do this we leak the Cursor
    if (c instanceof Activity) {
        ((Activity) c).startManagingCursor(cursor);
    }
    imageAdapter = new ScalingImageAdapter(c, cursor,
            THUMBNAIL_SCALE_FACTOR);
    imageGrid.setAdapter(imageAdapter);
    imageGrid.setNumColumns(3);
    imageGrid.setVerticalSpacing(5);
    imageGrid.setPadding(5, 0, 0, 0);

    imageGrid.setOnItemClickListener(this);
    imageGrid.setOnItemLongClickListener(this);

    //imageGrid.setTranscriptMode(imageGrid.TRANSCRIPT_MODE_ALWAYS_SCROLL);

    cameraButton = new Button(c);
    cameraButton.setText(R.string.btn_add_photo);
    cameraButton.setOnClickListener(this);

    imageReview = new ImagePreviewDialog(c);
    LinearLayout picContainer = new LinearLayout(c);
    picContainer.setOrientation(LinearLayout.VERTICAL);

    if (question == null) {
        question = c.getString(R.string.question_standard_picture_element);
    }

    //Set question
    TextView tv = new TextView(c);
    tv.setText(String.format("%s: %s", id, question));
    tv.setGravity(Gravity.CENTER);
    tv.setTextAppearance(c, android.R.style.TextAppearance_Medium);

    //Add to layout
    picContainer.addView(tv, new LinearLayout.LayoutParams(-1, -1, 0.1f));
    //picContainer.addView(imageView, new LinearLayout.LayoutParams(-1,-1,0.1f));

    //Add button
    picContainer.addView(cameraButton,
            new LinearLayout.LayoutParams(-1, -1, 0.1f));
    picContainer.addView(imageGrid,
            new LinearLayout.LayoutParams(-1, 210)); //LayoutParams(-1,-1,0.8f));
    picContainer.setWeightSum(1.0f);
    return picContainer;
}
 
Example 18
Source File: SessionCell.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public SessionCell(Context context, int type) {
    super(context);

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setWeightSum(1);

    if (type == 1) {
        addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 15 : 49), 11, (LocaleController.isRTL ? 49 : 15), 0));

        avatarDrawable = new AvatarDrawable();
        avatarDrawable.setTextSize(AndroidUtilities.dp(10));

        imageView = new BackupImageView(context);
        imageView.setRoundRadius(AndroidUtilities.dp(10));
        addView(imageView, LayoutHelper.createFrame(20, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 21), 13, (LocaleController.isRTL ? 21 : 0), 0));
    } else {
        addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 15 : 21), 11, (LocaleController.isRTL ? 21 : 15), 0));
    }

    nameTextView = new TextView(context);
    nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    nameTextView.setLines(1);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);

    onlineTextView = new TextView(context);
    onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    onlineTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP);

    if (LocaleController.isRTL) {
        linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 2, 0, 0));
        linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.RIGHT | Gravity.TOP, 10, 0, 0, 0));
    } else {
        linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.LEFT | Gravity.TOP, 0, 0, 10, 0));
        linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 2, 0, 0));
    }

    detailTextView = new TextView(context);
    detailTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    detailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    detailTextView.setLines(1);
    detailTextView.setMaxLines(1);
    detailTextView.setSingleLine(true);
    detailTextView.setEllipsize(TextUtils.TruncateAt.END);
    detailTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 36, 21, 0));

    detailExTextView = new TextView(context);
    detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
    detailExTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    detailExTextView.setLines(1);
    detailExTextView.setMaxLines(1);
    detailExTextView.setSingleLine(true);
    detailExTextView.setEllipsize(TextUtils.TruncateAt.END);
    detailExTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 59, 21, 0));
}
 
Example 19
Source File: SessionCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public SessionCell(Context context, int type) {
    super(context);

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setWeightSum(1);


    if (type == 1) {
        addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 11 : 45), 11, (LocaleController.isRTL ? 45 : 11), 0));

        avatarDrawable = new AvatarDrawable();
        avatarDrawable.setTextSize(AndroidUtilities.dp(10));

        imageView = new BackupImageView(context);
        imageView.setRoundRadius(AndroidUtilities.dp(10));
        addView(imageView, LayoutHelper.createFrame(20, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 17), 13, (LocaleController.isRTL ? 17 : 0), 0));
    } else {
        addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 11 : 17), 11, (LocaleController.isRTL ? 17 : 11), 0));
    }

    nameTextView = new TextView(context);
    nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    nameTextView.setLines(1);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);

    onlineTextView = new TextView(context);
    onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    onlineTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP);

    if (LocaleController.isRTL) {
        linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 2, 0, 0));
        linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.RIGHT | Gravity.TOP, 10, 0, 0, 0));
    } else {
        linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.LEFT | Gravity.TOP, 0, 0, 10, 0));
        linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 2, 0, 0));
    }

    detailTextView = new TextView(context);
    detailTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    detailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    detailTextView.setLines(1);
    detailTextView.setMaxLines(1);
    detailTextView.setSingleLine(true);
    detailTextView.setEllipsize(TextUtils.TruncateAt.END);
    detailTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 36, 17, 0));

    detailExTextView = new TextView(context);
    detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
    detailExTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    detailExTextView.setLines(1);
    detailExTextView.setMaxLines(1);
    detailExTextView.setSingleLine(true);
    detailExTextView.setEllipsize(TextUtils.TruncateAt.END);
    detailExTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 59, 17, 0));
}
 
Example 20
Source File: SessionCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public SessionCell(Context context, int type) {
    super(context);

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setWeightSum(1);


    if (type == 1) {
        addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 11 : 45), 11, (LocaleController.isRTL ? 45 : 11), 0));

        avatarDrawable = new AvatarDrawable();
        avatarDrawable.setTextSize(AndroidUtilities.dp(10));

        imageView = new BackupImageView(context);
        imageView.setRoundRadius(AndroidUtilities.dp(10));
        addView(imageView, LayoutHelper.createFrame(20, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 17), 13, (LocaleController.isRTL ? 17 : 0), 0));
    } else {
        addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 11 : 17), 11, (LocaleController.isRTL ? 17 : 11), 0));
    }

    nameTextView = new TextView(context);
    nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    nameTextView.setLines(1);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);

    onlineTextView = new TextView(context);
    onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    onlineTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP);

    if (LocaleController.isRTL) {
        linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 2, 0, 0));
        linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.RIGHT | Gravity.TOP, 10, 0, 0, 0));
    } else {
        linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.LEFT | Gravity.TOP, 0, 0, 10, 0));
        linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 2, 0, 0));
    }

    detailTextView = new TextView(context);
    detailTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    detailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    detailTextView.setLines(1);
    detailTextView.setMaxLines(1);
    detailTextView.setSingleLine(true);
    detailTextView.setEllipsize(TextUtils.TruncateAt.END);
    detailTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 36, 17, 0));

    detailExTextView = new TextView(context);
    detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
    detailExTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    detailExTextView.setLines(1);
    detailExTextView.setMaxLines(1);
    detailExTextView.setSingleLine(true);
    detailExTextView.setEllipsize(TextUtils.TruncateAt.END);
    detailExTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 59, 17, 0));
}