Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Reorganized settings a little
Browse files Browse the repository at this point in the history
  • Loading branch information
rovo89 committed Jul 1, 2012
1 parent ccb6990 commit e2085b0
Show file tree
Hide file tree
Showing 6 changed files with 447 additions and 392 deletions.
Original file line number Diff line number Diff line change
@@ -1,36 +1,49 @@
package de.robv.android.xposed.library.ui;

import android.content.Context;
import android.graphics.Color;
import android.preference.Preference;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AbsListView;
import android.widget.ImageView;

public class SeparatorPreference extends Preference {
int color = Color.GRAY;
int height = 7;

public SeparatorPreference(Context context) {
super(context);
setSelectable(false);
}

public void setColor(int color) {
this.color = color;
}

public void setHeight(int height) {
this.height = height;
}

@Override
protected View onCreateView(ViewGroup parent) {
ImageView iview = new ImageView(getContext());
iview.setBackgroundColor(color);
iview.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, height));
return iview;
}
package de.robv.android.xposed.library.ui;

import android.content.Context;
import android.graphics.Color;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AbsListView;
import android.widget.ImageView;

public class SeparatorPreference extends Preference {
int color = Color.GRAY;
int height = 7;

public SeparatorPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setSelectable(false);

if (attrs != null) {
height = attrs.getAttributeIntValue(null, "height", height);
}
}

public SeparatorPreference(Context context, AttributeSet attrs) {
this(context, attrs, android.R.attr.preferenceStyle);
}

public SeparatorPreference(Context context) {
this(context, null);
}

public void setColor(int color) {
this.color = color;
}

public void setHeight(int height) {
this.height = height;
}

@Override
protected View onCreateView(ViewGroup parent) {
ImageView iview = new ImageView(getContext());
iview.setBackgroundColor(color);
iview.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, height));
return iview;
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,60 @@
package de.robv.android.xposed.library.ui;

import android.content.Context;
import android.preference.Preference;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class TextViewPreference extends Preference {
private TextView textView = null;

public TextViewPreference(Context context) {
super(context);
}

@Override
protected View onCreateView(ViewGroup parent) {
return getTextView();
}

public TextView getTextView() {
if (textView == null) {
textView = new TextView(getContext());
textView.setId(android.R.id.title);
textView.setPadding(5,5,5,5);
}
return textView;
}
}
package de.robv.android.xposed.library.ui;

import android.content.Context;
import android.graphics.Typeface;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class TextViewPreference extends Preference {
private TextView textView = null;
private int padding = 7;
private int textSize = -1;
private boolean bold = false;
private boolean italic = false;

public TextViewPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);

if (attrs != null) {
textSize = attrs.getAttributeIntValue(null, "textSize", textSize);
padding = attrs.getAttributeIntValue(null, "padding", padding);
bold = attrs.getAttributeBooleanValue(null, "bold", bold);
italic = attrs.getAttributeBooleanValue(null, "italic", italic);
}
}

public TextViewPreference(Context context, AttributeSet attrs) {
this(context, attrs, android.R.attr.preferenceStyle);
}

public TextViewPreference(Context context) {
this(context, null);
}

@Override
protected View onCreateView(ViewGroup parent) {
return getTextView();
}

public TextView getTextView() {
if (textView == null) {
textView = new TextView(getContext());
textView.setId(android.R.id.title);
textView.setPadding(padding,padding,padding,padding);

if (textSize > 0)
textView.setTextSize(textSize);

if (bold && italic)
textView.setTypeface(null, Typeface.BOLD_ITALIC);
else if (bold)
textView.setTypeface(null, Typeface.BOLD);
else if (italic)
textView.setTypeface(null, Typeface.ITALIC);
}
return textView;
}
}
Loading

0 comments on commit e2085b0

Please sign in to comment.