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

The following examples show how to use android.widget.LinearLayout#setOrientation() . 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: DialogRootView.java    From AndroidMaterialDialog with Apache License 2.0 6 votes vote down vote up
/**
 * Inflates the scroll view, which contains the dialog's scrollable areas, if it has not been
 * inflated yet.
 *
 * @param scrollableArea The scrollable area of the dialog, as an instance of the class {@link
 *                       ScrollableArea}. The scrollable area may not be null
 */
private void inflateScrollView(@NonNull final ScrollableArea scrollableArea) {
    if (scrollView == null) {
        LayoutInflater layoutInflater = LayoutInflater.from(getContext());
        scrollView = (ScrollView) layoutInflater
                .inflate(R.layout.material_dialog_scroll_view, this, false);
        scrollView.addScrollListener(createScrollViewScrollListener());
        scrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
        scrollView.setFocusableInTouchMode(true);

        if (scrollableArea.getBottomScrollableArea().getIndex() -
                scrollableArea.getTopScrollableArea().getIndex() > 0) {
            LinearLayout scrollContainer = new LinearLayout(getContext());
            scrollContainer.setOrientation(LinearLayout.VERTICAL);
            scrollView.addView(scrollContainer, ScrollView.LayoutParams.MATCH_PARENT,
                    ScrollView.LayoutParams.MATCH_PARENT);
        }

        addView(scrollView);
    }
}
 
Example 2
Source File: InstallActivity.java    From javainstaller with GNU General Public License v3.0 6 votes vote down vote up
public LinearLayout makell(int id){
	LinearLayout ll = new LinearLayout(this);
	ll.setOrientation(LinearLayout.VERTICAL);
	TextView tv = new TextView(this);
	tv.setText(((uninstall)?"uninstalling ":"installing ")+MainActivity.checks[id].text);
	ll.addView(tv);
	if(!uninstall){
		ProgressBar pb = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
		pb.setId(1);
		pb.setProgress(0);
		pb.setMax(100);
		ll.addView(pb);
		TextView tv1 = new TextView(this);
		tv1.setId(2);
		tv1.setText("0/0kb  0/100%");
		ll.addView(tv1);
	}
	return ll;
}
 
Example 3
Source File: MainActivity.java    From AndroidMaryTTS-Client with Apache License 2.0 6 votes vote down vote up
public TransparentProgressDialog(Context context, int resourceIdOfImage) {
    super(context, R.style.TransparentProgressDialog);
    WindowManager.LayoutParams wlmp = getWindow().getAttributes();
    wlmp.gravity = Gravity.CENTER_HORIZONTAL;
    getWindow().setAttributes(wlmp);
    setTitle(null);
    setCancelable(false);
    setOnCancelListener(null);
    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    iv = new ImageView(context);
    iv.setImageResource(resourceIdOfImage);
    layout.addView(iv, params);
    addContentView(layout, params);
}
 
Example 4
Source File: ScheduleView.java    From SmallGdufe-Android with GNU General Public License v3.0 6 votes vote down vote up
private View addStartView(int startnum, final int week, final int start) {
        LinearLayout mStartView = new LinearLayout(getContext());
        mStartView.setOrientation(VERTICAL);
        for (int i = 1; i < startnum; i++) {
            TextView mTime = new TextView(getContext());
            mTime.setGravity(Gravity.CENTER);
            mTime.setHeight(dip2px(TimeTableHeight));
            mTime.setWidth(dip2px(TimeTableHeight));
            mStartView.addView(mTime);
            mStartView.addView(getWeekTransverseLine());

            //这里可以处理空白处点击添加课表
            final int finalI = i;
            mTime.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
//                    Toast.makeText(getContext(), "星期" + week + "第" + (start + num) + "节", Toast.LENGTH_SHORT).show();
                    //TODO 添加课程
                    mClickListener.onClickScheduleAdd(week,start+ finalI);
                }
            });

        }
        return mStartView;
    }
 
Example 5
Source File: EditPagePort.java    From fingerpoetry-android with Apache License 2.0 5 votes vote down vote up
public void onCreate() {
	super.onCreate();

	int screenHeight = R.getScreenHeight(activity);
	float ratio = ((float) screenHeight) / DESIGN_SCREEN_HEIGHT;

	maxBodyHeight = 0;

	llPage = new LinearLayout(activity);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	rlTitle = new RelativeLayout(activity);
	rlTitle.setBackgroundColor(0xffe6e9ec);
	int titleHeight = (int) (DESIGN_TITLE_HEIGHT * ratio);

	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
	llPage.addView(rlTitle, lp);
	initTitle(rlTitle, ratio);

	RelativeLayout rlBody = new RelativeLayout(activity);
	rlBody.setBackgroundColor(0xffffffff);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(rlBody, lp);
	initBody(rlBody, ratio);

	LinearLayout llShadow = new LinearLayout(activity);
	llShadow.setOrientation(LinearLayout.VERTICAL);
	rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	initShadow(llShadow, ratio);

	llBottom = new LinearLayout(activity);
	llBottom.setOrientation(LinearLayout.VERTICAL);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(llBottom, lp);
	initBottom(llBottom, ratio);
}
 
Example 6
Source File: AudioFxDemo.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mStatusTextView = new TextView(this);

    mLinearLayout = new LinearLayout(this);
    mLinearLayout.setOrientation(LinearLayout.VERTICAL);
    mLinearLayout.addView(mStatusTextView);

    setContentView(mLinearLayout);

    // Create the MediaPlayer
    mMediaPlayer = MediaPlayer.create(this, R.raw.test_cbr);
    Log.d(TAG, "MediaPlayer audio session ID: " + mMediaPlayer.getAudioSessionId());

    setupVisualizerFxAndUI();
    setupEqualizerFxAndUI();

    // Make sure the visualizer is enabled only when you actually want to receive data, and
    // when it makes sense to receive data.
    mVisualizer.setEnabled(true);

    // When the stream ends, we don't need to collect any more data. We don't do this in
    // setupVisualizerFxAndUI because we likely want to have more, non-Visualizer related code
    // in this callback.
    mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        public void onCompletion(MediaPlayer mediaPlayer) {
            mVisualizer.setEnabled(false);
        }
    });

    mMediaPlayer.start();
    mStatusTextView.setText("Playing audio...");
}
 
Example 7
Source File: HorizontalPicker.java    From MyBlogDemo with Apache License 2.0 5 votes vote down vote up
public HorizontalPicker(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setOrientation(VERTICAL);
    header = new LinearLayout(context);
    header.setOrientation(LinearLayout.HORIZONTAL);
    float density = getResources().getDisplayMetrics().density;
    addView(header, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (density * 56)));
    mDetailContainer = new FrameLayout(context);
    addView(mDetailContainer, new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
 
Example 8
Source File: DemoScrollFragment.java    From MagicHeaderViewPager with Apache License 2.0 5 votes vote down vote up
private void initContent() {
    mScrollView.clearContent();

    if (getActivity() == null) {
        return;
    }

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

    // picture
    ImageView iv = new ImageView(getActivity());
    iv.setImageResource(RandomPic.getInstance().getPicResId());
    iv.setAdjustViewBounds(true);
    int _5dp = MagicHeaderUtils.dp2px(getActivity(), 5f);
    iv.setPadding(_5dp, 0, _5dp, _5dp);
    mContentLinearLayout.addView(iv, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    // Text data
    tv = new TextView(getActivity());
    tv.setText(getString(R.string.text_3_kingdoms_chapter_1));
    tv.setTextSize(20);
    tv.setTextColor(Color.parseColor("#2c3e50"));
    tv.setLineSpacing(0, 1.2f);
    tv.setPadding(_5dp, _5dp, _5dp, 0);
    mContentLinearLayout.addView(tv, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));

    mScrollView.setContentView(mContentLinearLayout);
}
 
Example 9
Source File: ChipsVerticalLinearLayout.java    From android-material-chips with Apache License 2.0 5 votes vote down vote up
private LinearLayout createHorizontalView() {
    LinearLayout ll = new LinearLayout(getContext());
    ll.setPadding(0, 0, 0, mRowSpacing);
    ll.setOrientation(HORIZONTAL);
    addView(ll);
    mLineLayouts.add(ll);
    return ll;
}
 
Example 10
Source File: BaseDialog.java    From AutoTest with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(mTag, "onCreate");
    mDisplayMetrics = mContext.getResources().getDisplayMetrics();
    mMaxHeight = mDisplayMetrics.heightPixels - StatusBarUtils.getHeight(mContext);
    // mMaxHeight = mDisplayMetrics.heightPixels;

    mLlTop = new LinearLayout(mContext);
    mLlTop.setGravity(Gravity.CENTER);

    mLlControlHeight = new LinearLayout(mContext);
    mLlControlHeight.setOrientation(LinearLayout.VERTICAL);

    mOnCreateView = onCreateView();
    mLlControlHeight.addView(mOnCreateView);
    mLlTop.addView(mLlControlHeight);
    onViewCreated(mOnCreateView);

    if (mIsPopupStyle) {
        setContentView(mLlTop, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
    } else {
        setContentView(mLlTop, new ViewGroup.LayoutParams(mDisplayMetrics.widthPixels, (int) mMaxHeight));
    }

    mLlTop.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mCancel) {
                dismiss();
            }
        }
    });

    mOnCreateView.setClickable(true);
}
 
Example 11
Source File: SeekBarPreference.java    From always-on-amoled with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected View onCreateDialogView() {

    LinearLayout.LayoutParams params;
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(6, 6, 6, 6);

    TextView mSplashText = new TextView(mContext);
    mSplashText.setPadding(72, 10, 30, 10);
    if (mDialogMessage != null)
        mSplashText.setText(mDialogMessage);
    layout.addView(mSplashText);

    mValueText = new TextView(mContext);
    mValueText.setGravity(Gravity.CENTER_HORIZONTAL);
    mValueText.setTextSize(32);
    params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    layout.addView(mValueText, params);

    mSeekBar = new SeekBar(mContext);
    mSeekBar.setOnSeekBarChangeListener(this);
    layout.addView(mSeekBar, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

    if (shouldPersist())
        mValue = getPersistedInt(mDefault);

    mSeekBar.setMax(mMax);
    mSeekBar.setProgress(mValue);

    return layout;
}
 
Example 12
Source File: FragmentTabHost.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
private void ensureHierarchy(Context context) {
    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.FILL_PARENT, 0, 1));
    }
}
 
Example 13
Source File: WXRefreshView.java    From weex-uikit with MIT License 5 votes vote down vote up
private void setupViews() {
  linearLayout = new LinearLayout(getContext());
  FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams
                                                                   .MATCH_PARENT,FrameLayout
      .LayoutParams.MATCH_PARENT);
  linearLayout.setOrientation(LinearLayout.VERTICAL);
  linearLayout.setGravity(Gravity.CENTER);
  addView(linearLayout,lp);
}
 
Example 14
Source File: DrawerUtils.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
/**
 * adds the shadow to the stickyFooter
 *
 * @param ctx
 * @param footerView
 */
private static void addStickyFooterDivider(Context ctx, ViewGroup footerView) {
    LinearLayout divider = new LinearLayout(ctx);
    LinearLayout.LayoutParams dividerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    //remove bottomMargin --> See inbox it also has no margin here
    //dividerParams.bottomMargin = mActivity.getResources().getDimensionPixelSize(R.dimen.material_drawer_padding);
    divider.setMinimumHeight((int) UIUtils.convertDpToPixel(1, ctx));
    divider.setOrientation(LinearLayout.VERTICAL);
    divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ctx, R.attr.material_drawer_divider, R.color.material_drawer_divider));
    footerView.addView(divider, dividerParams);
}
 
Example 15
Source File: EditPageLand.java    From Mobike with Apache License 2.0 4 votes vote down vote up
private void initBody(RelativeLayout rlBody, float ratio) {
	svContent = new ScrollView(activity);
	rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	LinearLayout llContent = new LinearLayout(activity);
	llContent.setOrientation(LinearLayout.HORIZONTAL);
	svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	etContent = new EditText(activity);
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	etContent.setPadding(padding, padding, padding, padding);
	etContent.setBackgroundDrawable(null);
	etContent.setTextColor(0xff3b3b3b);
	etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	etContent.setText(sp.getText());
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT);
	lp.weight = 1;
	llContent.addView(etContent, lp);
	etContent.addTextChangedListener(this);

	rlThumb = new RelativeLayout(activity);
	rlThumb.setBackgroundColor(0xff313131);
	int	thumbWidth = (int) (DESIGN_THUMB_HEIGHT_L * ratio);
	int	xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT_L * ratio);
	lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
	lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
	llContent.addView(rlThumb, lp);

	aivThumb = new AsyncImageView(activity) {
		public void onImageGot(String url, Bitmap bm) {
			thumb = bm;
			super.onImageGot(url, bm);
		}
	};
	aivThumb.setScaleToCropCenter(true);
	RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
	rlThumb.addView(aivThumb, rllp);
	aivThumb.setOnClickListener(this);
	initThumb(aivThumb);

	xvRemove = new XView(activity);
	xvRemove.setRatio(ratio);
	rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlThumb.addView(xvRemove, rllp);
	xvRemove.setOnClickListener(this);
}
 
Example 16
Source File: AlertsCreator.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public static AlertDialog createAccountSelectDialog(Activity parentActivity, final AccountSelectDelegate delegate)
{
    if (UserConfig.getActivatedAccountsCount() < 2)
    {
        return null;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
    final Runnable dismissRunnable = builder.getDismissRunnable();
    final AlertDialog[] alertDialog = new AlertDialog[1];

    final LinearLayout linearLayout = new LinearLayout(parentActivity);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++)
    {
        TLRPC.User u = UserConfig.getInstance(a).getCurrentUser();
        if (u != null)
        {
            AccountSelectCell cell = new AccountSelectCell(parentActivity);
            cell.setAccount(a, false);
            cell.setPadding(AndroidUtilities.dp(14), 0, AndroidUtilities.dp(14), 0);
            cell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
            linearLayout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
            cell.setOnClickListener(v ->
            {
                if (alertDialog[0] != null)
                {
                    alertDialog[0].setOnDismissListener(null);
                }
                dismissRunnable.run();
                AccountSelectCell cell1 = (AccountSelectCell) v;
                delegate.didSelectAccount(cell1.getAccountNumber());
            });
        }
    }

    builder.setTitle(LocaleController.getString("SelectAccount", R.string.SelectAccount));
    builder.setView(linearLayout);
    builder.setPositiveButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    return alertDialog[0] = builder.create();
}
 
Example 17
Source File: PagerSlidingTabStrip.java    From android-open-project-demo with Apache License 2.0 4 votes vote down vote up
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
	super(context, attrs, defStyle);

	setFillViewport(true);
	setWillNotDraw(false);

	tabsContainer = new LinearLayout(context);
	tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
	tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	addView(tabsContainer);

	DisplayMetrics dm = getResources().getDisplayMetrics();

	scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
	indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
	underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
	dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
	tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
	dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
	tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

	// get system attrs (android:textSize and android:textColor)

	TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

	tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
	tabTextColor = a.getColor(1, tabTextColor);

	a.recycle();

	// get custom attrs

	a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

	indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
	underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
	dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
	indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight);
	underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight);
	dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding);
	tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
	tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId);
	shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
	scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
	textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

	a.recycle();

	rectPaint = new Paint();
	rectPaint.setAntiAlias(true);
	rectPaint.setStyle(Style.FILL);

	dividerPaint = new Paint();
	dividerPaint.setAntiAlias(true);
	dividerPaint.setStrokeWidth(dividerWidth);

	defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

	if (locale == null) {
		locale = getResources().getConfiguration().locale;
	}
}
 
Example 18
Source File: SettingsFragment.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 4 votes vote down vote up
private void editPasswordDialog(final String oldPass) {
    mOldPassword = oldPass;

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER);
    int padding = Math.round(getResources().getDimension(R.dimen.dialog_padding));
    linearLayout.setPadding(padding, padding, padding, padding);

    final AppCompatEditText oldPassword = new AppCompatEditText(requireActivity());
    if (!oldPass.isEmpty()) {
        oldPassword.setInputType(InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        oldPassword.setHint(getString(R.string.old_password));
        linearLayout.addView(oldPassword);
    }

    final AppCompatEditText newPassword = new AppCompatEditText(requireActivity());
    newPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    newPassword.setHint(getString(R.string.new_password));
    linearLayout.addView(newPassword);

    final AppCompatEditText confirmNewPassword = new AppCompatEditText(requireActivity());
    confirmNewPassword.setInputType(InputType.TYPE_CLASS_TEXT
            | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    confirmNewPassword.setHint(getString(R.string.confirm_new_password));
    linearLayout.addView(confirmNewPassword);

    new Dialog(requireActivity()).setView(linearLayout)
            .setNegativeButton(getString(R.string.cancel), (dialogInterface, i) -> {
            })
            .setPositiveButton(getString(R.string.ok), (dialogInterface, i) -> {
                if (!oldPass.isEmpty() && !Objects.requireNonNull(oldPassword.getText()).toString().equals(Utils
                        .decodeString(oldPass))) {
                    Utils.snackbar(mRootView, getString(R.string.old_password_wrong));
                    return;
                }

                if (Objects.requireNonNull(newPassword.getText()).toString().isEmpty()) {
                    Utils.snackbar(mRootView, getString(R.string.password_empty));
                    return;
                }

                if (!newPassword.getText().toString().equals(Objects.requireNonNull(confirmNewPassword.getText())
                        .toString())) {
                    Utils.snackbar(mRootView, getString(R.string.password_not_match));
                    return;
                }

                if (newPassword.getText().toString().length() > 32) {
                    Utils.snackbar(mRootView, getString(R.string.password_too_long));
                    return;
                }

                Prefs.saveString("password", Utils.encodeString(newPassword.getText()
                        .toString()), getActivity());
                if (mFingerprint != null) {
                    mFingerprint.setEnabled(true);
                }
            }).setOnDismissListener(dialogInterface -> mOldPassword = null).show();
}
 
Example 19
Source File: EditPageLand.java    From fingerpoetry-android with Apache License 2.0 4 votes vote down vote up
private void initBody(RelativeLayout rlBody, float ratio) {
	svContent = new ScrollView(activity);
	rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	LinearLayout llContent = new LinearLayout(activity);
	llContent.setOrientation(LinearLayout.HORIZONTAL);
	svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	etContent = new EditText(activity);
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	etContent.setPadding(padding, padding, padding, padding);
	etContent.setBackgroundDrawable(null);
	etContent.setTextColor(0xff3b3b3b);
	etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	etContent.setText(sp.getText());
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT);
	lp.weight = 1;
	llContent.addView(etContent, lp);
	etContent.addTextChangedListener(this);

	rlThumb = new RelativeLayout(activity);
	rlThumb.setBackgroundColor(0xff313131);
	int	thumbWidth = (int) (DESIGN_THUMB_HEIGHT_L * ratio);
	int	xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT_L * ratio);
	lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
	lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
	llContent.addView(rlThumb, lp);

	aivThumb = new AsyncImageView(activity) {
		public void onImageGot(String url, Bitmap bm) {
			thumb = bm;
			super.onImageGot(url, bm);
		}
	};
	aivThumb.setScaleToCropCenter(true);
	RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
	rlThumb.addView(aivThumb, rllp);
	aivThumb.setOnClickListener(this);
	initThumb(aivThumb);

	xvRemove = new XView(activity);
	xvRemove.setRatio(ratio);
	rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlThumb.addView(xvRemove, rllp);
	xvRemove.setOnClickListener(this);
}
 
Example 20
Source File: PagerSlidingTabStrip.java    From Conquer with Apache License 2.0 4 votes vote down vote up
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
	super(context, attrs, defStyle);

	setFillViewport(true);
	setWillNotDraw(false);

	tabsContainer = new LinearLayout(context);
	tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
	tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	addView(tabsContainer);

	DisplayMetrics dm = getResources().getDisplayMetrics();

	scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
	indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
	underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
	dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
	tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
	dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
	tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

	// get system attrs (android:textSize and android:textColor)

	TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

	tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
	tabTextColor = a.getColor(1, tabTextColor);

	a.recycle();

	// get custom attrs
	a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
	indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
	underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
	dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
	indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
			indicatorHeight);
	underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
			underlineHeight);
	dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
			dividerPadding);
	tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight,
			tabPadding);
	tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
			tabBackgroundResId);
	shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
	scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset,
			scrollOffset);
	textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

	a.recycle();

	rectPaint = new Paint();
	rectPaint.setAntiAlias(true);
	rectPaint.setStyle(Style.FILL);

	dividerPaint = new Paint();
	dividerPaint.setAntiAlias(true);
	dividerPaint.setStrokeWidth(dividerWidth);

	defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
			LayoutParams.MATCH_PARENT);
	expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

	if (locale == null) {
		locale = getResources().getConfiguration().locale;
	}
}