Created new attribute adapters

Use ConstraintLayout in some layouts
This commit is contained in:
Akash Yadav
2021-12-11 15:40:47 +05:30
parent 643053f0c3
commit 9ad2d6f26a
25 changed files with 649 additions and 355 deletions
+6
View File
@@ -0,0 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value=" This file is part of AndroidIDE.&#10; &#10; AndroidIDE is free software: you can redistribute it and/or modify&#10; it under the terms of the GNU General Public License as published by&#10; the Free Software Foundation, either version 3 of the License, or&#10; (at your option) any later version.&#10; &#10; AndroidIDE is distributed in the hope that it will be useful,&#10; but WITHOUT ANY WARRANTY; without even the implied warranty of&#10; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the&#10; GNU General Public License for more details.&#10; &#10; You should have received a copy of the GNU General Public License&#10; along with AndroidIDE. If not, see &lt;https://www.gnu.org/licenses/&gt;." />
<option name="myName" value="Akash Yadav" />
</copyright>
</component>
+13
View File
@@ -0,0 +1,13 @@
<component name="CopyrightManager">
<settings>
<module2copyright>
<element module="Project Files" copyright="Akash Yadav" />
</module2copyright>
<LanguageOptions name="JAVA">
<option name="fileTypeOverride" value="3" />
</LanguageOptions>
<LanguageOptions name="XML">
<option name="fileTypeOverride" value="3" />
</LanguageOptions>
</settings>
</component>
+9
View File
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/layout/activity_main.xml" value="0.264" />
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/layout/layout_create_project.xml" value="0.20854700854700856" />
<entry key="..\:/Users/Akash Yadav/AndroidStudioProjects/android-ide/app/src/main/res/layout/layout_create_project_content.xml" value="0.33" />
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
@@ -58,7 +58,7 @@ public class ProjectResourceFinder implements IResourceFinder {
}
@Override
public Object[] findArray(String name) {
public String[] findArray(String name) {
return null;
}
@@ -1,48 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:layout_width="48dp"
style="?android:attr/buttonBarButtonStyle"
android:layout_height="48dp"
app:srcCompat="@drawable/ic_close"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_margin="16dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:id="@+id/createproject_close"
android:layout_marginBottom="16dp"/>
style="?android:attr/buttonBarButtonStyle"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="?attr/selectableItemBackgroundBorderless"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_close" />
<TextView
android:layout_width="wrap_content"
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/new_project"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:layout_toStartOf="@id/createproject_close"
android:layout_alignTop="@id/createproject_close"
android:layout_alignBottom="@id/createproject_close"
android:layout_alignParentStart="true"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center_vertical"
android:singleLine="true"
android:text="@string/new_project"
android:textColor="@color/primaryTextColor"
android:textSize="23sp"
android:textColor="@color/primaryTextColor"/>
android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@id/createproject_close"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/createproject_close" />
<androidx.core.widget.NestedScrollView
android:layout_below="@id/createproject_close"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/textView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="16dp"
android:fillViewport="true">
<include
android:id="@+id/createProjectContent"
layout="@layout/layout_create_project_content"/>
layout="@layout/layout_create_project_content">
</include>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -1,203 +1,223 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp">
android:paddingStart="8dp"
android:paddingEnd="8dp">
<com.google.android.material.textfield.TextInputLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:hint="@string/project_app_name"
android:id="@+id/createproject_textAppName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:hint="@string/project_app_name"
android:theme="@style/AppTheme.ProjectCreator.TextInput"
app:counterEnabled="true"
app:counterMaxLength="20"
app:layout_constraintBottom_toTopOf="@+id/createproject_textPackageName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="@+id/createproject_textPackageName"
app:layout_constraintTop_toTopOf="parent"
app:startIconDrawable="@drawable/ic_android"
app:startIconTint="@color/primaryIconColor"
app:counterEnabled="true"
app:counterMaxLength="20">
app:startIconTint="@color/primaryIconColor">
<com.google.android.material.textfield.TextInputEditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:singleLine="true"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"/>
android:layout_height="wrap_content"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:hint="@string/package_name"
android:id="@+id/createproject_textPackageName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:hint="@string/package_name"
android:theme="@style/AppTheme.ProjectCreator.TextInput"
app:startIconTint="@color/primaryIconColor"
app:counterEnabled="true"
app:counterMaxLength="40"
app:layout_constraintBottom_toTopOf="@+id/createproject_textMinSdk"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/createproject_textMinSdk"
app:layout_constraintTop_toBottomOf="@+id/createproject_textAppName"
app:startIconDrawable="@drawable/ic_package"
app:counterEnabled="true"
app:counterMaxLength="40">
app:startIconTint="@color/primaryIconColor">
<com.google.android.material.textfield.TextInputEditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:singleLine="true"
android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890."/>
android:layout_height="wrap_content"
android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890."
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:hint="@string/minimum_sdk"
android:id="@+id/createproject_textMinSdk"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:hint="@string/minimum_sdk"
android:theme="@style/AppTheme.ProjectCreator.TextInput"
app:startIconTint="@color/primaryIconColor"
app:startIconDrawable="@drawable/ic_min_sdk"
app:counterEnabled="true"
app:counterMaxLength="2">
app:counterMaxLength="2"
app:layout_constraintBottom_toTopOf="@+id/createproject_textTargetSdk"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/createproject_textPackageName"
app:startIconDrawable="@drawable/ic_min_sdk"
app:startIconTint="@color/primaryIconColor">
<com.google.android.material.textfield.TextInputEditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:singleLine="true"
android:layout_height="wrap_content"
android:digits="1234567890"
android:inputType="number"/>
android:inputType="number"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:hint="@string/target_sdk"
android:id="@+id/createproject_textTargetSdk"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:hint="@string/target_sdk"
android:theme="@style/AppTheme.ProjectCreator.TextInput"
app:startIconTint="@color/primaryIconColor"
app:startIconDrawable="@drawable/ic_target_sdk"
app:counterEnabled="true"
app:counterMaxLength="2">
app:counterMaxLength="2"
app:layout_constraintBottom_toTopOf="@+id/createproject_templateImage"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/createproject_textMinSdk"
app:startIconDrawable="@drawable/ic_target_sdk"
app:startIconTint="@color/primaryIconColor">
<com.google.android.material.textfield.TextInputEditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:singleLine="true"
android:layout_height="wrap_content"
android:digits="1234567890"
android:inputType="number"/>
android:inputType="number"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="250dp"
android:orientation="horizontal"
android:weightSum="2.0">
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/createproject_templateLabel"
android:text="@string/template_empty"
android:textStyle="bold"
android:singleLine="true"
android:layout_marginBottom="8dp"
android:textColor="@color/secondaryColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/createproject_templateDescription"
android:layout_weight="1.0"
android:textColor="@color/secondaryTextColor"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:gravity="center">
<com.google.android.material.card.MaterialCardView
android:id="@+id/previousCard"
android:layout_height="50dp"
android:layout_width="50dp"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:descendantFocusability="blocksDescendants"
android:layout_marginEnd="16dp"
app:cardBackgroundColor="@android:color/transparent"
app:cardCornerRadius="50dp"
app:cardElevation="0dp"
app:strokeColor="@color/secondaryColor"
app:strokeWidth="0.75dp">
<ImageView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/createproject_previousTemplate"
android:scaleType="fitCenter"
android:padding="10dp"
app:srcCompat="@drawable/ic_chevron_left"/>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/nextCard"
android:layout_height="50dp"
android:layout_width="50dp"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:descendantFocusability="blocksDescendants"
app:cardBackgroundColor="@android:color/transparent"
app:cardCornerRadius="50dp"
app:cardElevation="0dp"
app:strokeColor="@color/secondaryColor"
app:strokeWidth="0.75dp"
android:layout_marginStart="16dp">
<ImageView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/createproject_nextTemplate"
android:scaleType="fitCenter"
android:padding="10dp"
app:srcCompat="@drawable/ic_chevron_right"/>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/createproject_templateImage"
android:layout_height="match_parent"
android:layout_width="0dp"
android:scaleType="fitCenter"
android:layout_weight="1.0"/>
</LinearLayout>
<Button
<TextView
android:id="@+id/createproject_templateLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/create_project"
android:layout_margin="16dp"
android:layout_gravity="center_horizontal"
android:textColor="@color/primaryTextColor"
android:id="@+id/createproject_create"/>
android:layout_marginStart="48dp"
android:layout_marginEnd="62dp"
android:layout_marginBottom="8dp"
android:singleLine="true"
android:text="@string/template_empty"
android:textColor="@color/secondaryColor"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/createproject_templateDescription"
app:layout_constraintEnd_toStartOf="@+id/createproject_templateImage"
app:layout_constraintStart_toStartOf="parent" />
</LinearLayout>
<TextView
android:id="@+id/createproject_templateDescription"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="48dp"
android:layout_marginEnd="16dp"
android:textColor="@color/secondaryTextColor"
app:layout_constraintBottom_toTopOf="@+id/previousCard"
app:layout_constraintEnd_toStartOf="@+id/createproject_templateImage"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/createproject_templateImage" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/previousCard"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="48dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp"
android:clickable="true"
android:descendantFocusability="blocksDescendants"
android:focusable="true"
android:foreground="?attr/selectableItemBackgroundBorderless"
app:cardBackgroundColor="@android:color/transparent"
app:cardCornerRadius="50dp"
app:cardElevation="0dp"
app:layout_constraintBottom_toTopOf="@+id/createproject_create"
app:layout_constraintEnd_toStartOf="@+id/nextCard"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/createproject_templateDescription"
app:strokeColor="@color/secondaryColor"
app:strokeWidth="0.75dp">
<ImageView
android:id="@+id/createproject_previousTemplate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_chevron_left" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/nextCard"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginEnd="180dp"
android:clickable="true"
android:descendantFocusability="blocksDescendants"
android:focusable="true"
android:foreground="?attr/selectableItemBackgroundBorderless"
app:cardBackgroundColor="@android:color/transparent"
app:cardCornerRadius="50dp"
app:cardElevation="0dp"
app:layout_constraintBottom_toBottomOf="@+id/previousCard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/previousCard"
app:layout_constraintTop_toBottomOf="@+id/createproject_templateDescription"
app:strokeColor="@color/secondaryColor"
app:strokeWidth="0.75dp">
<ImageView
android:id="@+id/createproject_nextTemplate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_chevron_right" />
</com.google.android.material.card.MaterialCardView>
<ImageView
android:id="@+id/createproject_templateImage"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
app:layout_constraintBottom_toTopOf="@+id/createproject_templateDescription"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/createproject_templateDescription"
app:layout_constraintTop_toBottomOf="@+id/createproject_textTargetSdk" />
<Button
android:id="@+id/createproject_create"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginBottom="16dp"
android:text="@string/create_project"
android:textColor="@color/primaryTextColor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/previousCard" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -41,7 +41,7 @@ public interface IAttribute {
@NonNull
String getAttributeName ();
@Nullable
@NonNull
String getValue ();
@NonNull
@@ -64,7 +64,7 @@ public interface IResourceFinder {
* @param name The name of the resource
* @return Value of the resource
*/
Object[] findArray (String name);
String[] findArray (String name);
/**
* Find the dimension value with the given name.
@@ -1,3 +1,20 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.view.View;
@@ -0,0 +1,66 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.view.View;
import android.widget.AbsSpinner;
import android.widget.ArrayAdapter;
import android.widget.SimpleAdapter;
import com.itsaky.layoutinflater.IAttribute;
import com.itsaky.layoutinflater.IResourceFinder;
public class AbsSpinnerAttrAdapter extends AdapterViewAttrAdapter {
@Override
public boolean isApplicableTo(View view) {
return view instanceof AbsSpinner;
}
@Override
public boolean apply(IAttribute attribute, View view, IResourceFinder resFinder) {
final var spinner = (AbsSpinner) view;
final var context = spinner.getContext();
final var namespace = attribute.getNamespace();
final var name = attribute.getAttributeName();
final var value = attribute.getValue();
boolean handled = true;
if (!canHandleNamespace(namespace)) {
return false;
}
switch (name) {
case "entries" :
final var adapter = newSimpleAdapter(context, resFinder.findArray(value));
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
break;
default:
handled = false;
break;
}
if (!handled){
handled = super.apply(attribute, view, resFinder);
}
return handled;
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.content.Context;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import com.itsaky.layoutinflater.IAttribute;
import com.itsaky.layoutinflater.IResourceFinder;
import com.itsaky.layoutinflater.adapters.android.view.ViewGroupAttrAdapter;
/**
* Adapter for handling attributes related to
* AdapterView.
*
* @author Akash Yadav
*/
public abstract class AdapterViewAttrAdapter extends ViewGroupAttrAdapter {
@Override
public boolean isApplicableTo(View view) {
return view instanceof AdapterView;
}
@Override
public boolean apply(IAttribute attribute, View view, IResourceFinder resFinder) {
// No special attributes for AdapterView
return super.apply(attribute, view, resFinder);
}
protected ArrayAdapter <String> newSimpleAdapter (Context ctx) {
return newSimpleAdapter(ctx, newAdapterItems(4));
}
protected ArrayAdapter <String> newSimpleAdapter (Context ctx, String[] items) {
return new ArrayAdapter<String>(ctx, android.R.layout.simple_list_item_1, items);
}
protected String[] newAdapterItems (int size) {
final var items = new String [size];
for (var i = 0;i<size;i++) {
items[i] = "Item " + i;
}
return items;
}
}
@@ -1,20 +1,20 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
/*
* This file is part of AndroidIDE.
*
**************************************************************************************/
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.view.View;
@@ -1,20 +1,19 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
/*
* This file is part of AndroidIDE.
*
**************************************************************************************/
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.view.View;
@@ -1,20 +1,19 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
/*
* This file is part of AndroidIDE.
*
**************************************************************************************/
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.view.View;
@@ -1,20 +1,3 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.content.Context;
@@ -1,20 +1,20 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
/*
* This file is part of AndroidIDE.
*
**************************************************************************************/
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.view.View;
@@ -1,20 +1,19 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
/*
* This file is part of AndroidIDE.
*
**************************************************************************************/
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.view.View;
@@ -1,20 +1,20 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
/*
* This file is part of AndroidIDE.
*
**************************************************************************************/
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.content.Context;
@@ -1,20 +1,19 @@
/************************************************************************************
* This file is part of AndroidIDE.
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
**************************************************************************************/
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.view.View;
@@ -1,20 +1,20 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
/*
* This file is part of AndroidIDE.
*
**************************************************************************************/
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.content.Context;
@@ -1,3 +1,20 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.view.View;
@@ -1,20 +1,19 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
/*
* This file is part of AndroidIDE.
*
**************************************************************************************/
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.view.View;
@@ -1,3 +1,20 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.view.View;
@@ -0,0 +1,81 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.view.View;
import android.widget.Spinner;
import com.itsaky.layoutinflater.IAttribute;
import com.itsaky.layoutinflater.IResourceFinder;
/**
* Attribute adapter for handling attributes related to
* Spinner.
*
* @author Akash Yadav
*/
public class SpinnerAttrAdapter extends AbsSpinnerAttrAdapter {
@Override
public boolean isApplicableTo(View view) {
return view instanceof Spinner;
}
@Override
public boolean apply(IAttribute attribute, View view, IResourceFinder resFinder) {
final var spinner = (Spinner) view;
final var context = spinner.getContext();
final var dm = context.getResources().getDisplayMetrics();
final var namespace = attribute.getNamespace();
final var name = attribute.getAttributeName();
final var value = attribute.getValue();
if (!canHandleNamespace(namespace)) {
return false;
}
boolean handled = true;
switch (name) {
case "dropDownHorizontalOffset":
spinner.setDropDownHorizontalOffset(parseDimension(value, 0, dm, resFinder));
break;
case "dropDownVerticalOffset":
spinner.setDropDownVerticalOffset(parseDimension(value, 0, dm, resFinder));
break;
case "dropDownWidth":
spinner.setDropDownWidth(parseDimension(value, 0, dm, resFinder));
break;
case "gravity" :
spinner.setGravity(parseGravity(value));
break;
case "popupBackground" :
spinner.setPopupBackgroundDrawable(parseDrawable(value, resFinder, context));
break;
default:
handled = false;
break;
}
if (!handled) {
handled = super.apply(attribute, view, resFinder);
}
return handled;
}
}
@@ -1,20 +1,20 @@
/************************************************************************************
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
/*
* This file is part of AndroidIDE.
*
**************************************************************************************/
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.layoutinflater.adapters.android.widget;
import android.content.Context;