Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

androidx basic widget direct support #402

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import android.content.res.TypedArray;
import android.os.Build;

import androidx.appcompat.widget.AppCompatCheckedTextView;
import androidx.core.view.ViewCompat;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.appcompat.widget.TintContextWrapper;
import androidx.appcompat.widget.VectorEnabledTintResources;

import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewParent;

Expand Down Expand Up @@ -57,10 +59,11 @@ public View createView(Context context, String name, AttributeSet attrs) {
}

private View createViewFromFV(Context context, String name, AttributeSet attrs) {

View view = null;
if (name.contains(".")) {
return null;
}
// if (name.contains(".")) {
// return null;
// }
switch (name) {
case "View":
view = new SkinCompatView(context, attrs);
Expand All @@ -75,45 +78,58 @@ private View createViewFromFV(Context context, String name, AttributeSet attrs)
view = new SkinCompatFrameLayout(context, attrs);
break;
case "TextView":
case "androidx.appcompat.widget.AppCompatTextView":
view = new SkinCompatTextView(context, attrs);
break;
case "ImageView":
case "androidx.appcompat.widget.AppCompatImageView":
view = new SkinCompatImageView(context, attrs);
break;
case "Button":
case "androidx.appcompat.widget.AppCompatButton":
view = new SkinCompatButton(context, attrs);
break;
case "EditText":
case "androidx.appcompat.widget.AppCompatEditText":
view = new SkinCompatEditText(context, attrs);
break;
case "Spinner":
case "androidx.appcompat.widget.AppCompatSpinner":
view = new SkinCompatSpinner(context, attrs);
break;
case "ImageButton":
case "androidx.appcompat.widget.AppCompatImageButton":
view = new SkinCompatImageButton(context, attrs);
break;
case "CheckBox":
case "androidx.appcompat.widget.AppCompatCheckBox":
view = new SkinCompatCheckBox(context, attrs);
break;
case "RadioButton":
case "androidx.appcompat.widget.AppCompatRadioButton":
view = new SkinCompatRadioButton(context, attrs);
break;
case "RadioGroup":
view = new SkinCompatRadioGroup(context, attrs);
break;
case "CheckedTextView":
case "androidx.appcompat.widget.AppCompatCheckedTextView":
view = new SkinCompatCheckedTextView(context, attrs);
break;
case "AutoCompleteTextView":
case "androidx.appcompat.widget.AppCompatAutoCompleteTextView":
view = new SkinCompatAutoCompleteTextView(context, attrs);
break;
case "MultiAutoCompleteTextView":
case "androidx.appcompat.widget.AppCompatMultiAutoCompleteTextView":
view = new SkinCompatMultiAutoCompleteTextView(context, attrs);
break;
case "RatingBar":
case "androidx.appcompat.widget.AppCompatRatingBar":
view = new SkinCompatRatingBar(context, attrs);
break;
case "SeekBar":
case "androidx.appcompat.widget.AppCompatSeekBar":
view = new SkinCompatSeekBar(context, attrs);
break;
case "ProgressBar":
Expand Down
2 changes: 2 additions & 0 deletions demo/skin-androidx-app/src/main/res-night/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,6 @@

<color name="msg_background_color_night">#dcd3a3</color>
<color name="msg_stroke_color_night">#ce2736</color>

<color name="tint_color_night">#0f0</color>
</resources>
29 changes: 16 additions & 13 deletions demo/skin-androidx-app/src/main/res/layout/fragment_first.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows="true"
android:orientation="vertical">

Expand All @@ -16,14 +17,14 @@
android:layout_height="match_parent"
android:orientation="vertical">

<ImageButton
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/image_button"
android:layout_width="match_parent"
android:layout_height="112dp"
android:background="@drawable/picture"
android:scaleType="fitXY" />

<TextView
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
Expand All @@ -32,15 +33,15 @@
android:textColor="@color/text_color"
android:textSize="18sp" />

<TextView
<androidx.appcompat.widget.AppCompatTextView
style="@style/TextStyle"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="center_vertical"
android:text="style=@style/TextStyle"
android:textSize="18sp" />

<MultiAutoCompleteTextView
<androidx.appcompat.widget.AppCompatMultiAutoCompleteTextView
android:id="@+id/auto"
style="@style/TextStyle"
android:layout_width="match_parent"
Expand All @@ -49,7 +50,7 @@
android:popupBackground="@color/background"
android:text="MultiAutoCompleteTextView" />

<TextView
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:clickable="true"
Expand All @@ -58,12 +59,14 @@
android:textColor="@drawable/color_selector"
android:textSize="18sp" />

<ImageView
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:srcCompat="@color/colorPrimary"
app:tint="@color/tint_color"
android:background="@drawable/image_background" />

<Button
<androidx.appcompat.widget.AppCompatButton
style="@style/TextStyle"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
Expand All @@ -72,7 +75,7 @@
android:textAllCaps="false"
android:textSize="18sp" />

<EditText
<androidx.appcompat.widget.AppCompatEditText
style="@style/TextStyle"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
Expand All @@ -87,7 +90,7 @@
android:layout_height="?attr/actionBarSize"
android:orientation="horizontal">

<CheckBox
<androidx.appcompat.widget.AppCompatCheckBox
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:button="@drawable/button_checked" />
Expand All @@ -98,24 +101,24 @@
android:background="@color/t2_7_background"
android:orientation="horizontal">

<RadioButton
<androidx.appcompat.widget.AppCompatRadioButton
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:button="@drawable/button_radio" />

<RadioButton
<androidx.appcompat.widget.AppCompatRadioButton
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:button="@drawable/button_radio" />

<RadioButton
<androidx.appcompat.widget.AppCompatRadioButton
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary" />
</RadioGroup>
</LinearLayout>

<CheckedTextView
<androidx.appcompat.widget.AppCompatCheckedTextView
android:id="@+id/checked_text_view"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
Expand Down
2 changes: 2 additions & 0 deletions demo/skin-androidx-app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@

<color name="msg_background_color">#cd3d3a</color>
<color name="msg_stroke_color">#f6ce59</color>

<color name="tint_color">#f00</color>
</resources>