Skip to content

Commit

Permalink
Merge pull request #7256 from ashcoding/TIMOB-17361
Browse files Browse the repository at this point in the history
[TIMOB-17361] Android: Initial CardView support
  • Loading branch information
hieupham007 committed Oct 7, 2015
2 parents ff62c23 + b1ff7d3 commit a73d539
Show file tree
Hide file tree
Showing 18 changed files with 538 additions and 2 deletions.
2 changes: 2 additions & 0 deletions android/build/common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Common ant tasks and macros for building Android-based Titanium modules and proj
</path>

<property name="v7appcompat.project.dir" location="${ti.android.root}/modules/appcompat"/>
<property name="v7cardview.project.dir" location="${ti.android.root}/modules/cardview"/>
<property name="titanium.project.dir" location="${ti.android.root}/titanium"/>
<property name="kroll.apt.project.dir" location="${ti.android.root}/kroll-apt"/>
<property name="kroll.common.project.dir" location="${ti.android.root}/runtime/common"/>
Expand Down Expand Up @@ -145,6 +146,7 @@ Common ant tasks and macros for building Android-based Titanium modules and proj
<pathelement path="${dist.classes.dir}/titanium"/>
<fileset dir="${titanium.project.dir}/lib" includes="**/*.jar"/>
<fileset dir="${v7appcompat.project.dir}/lib" includes="**/*.jar"/>
<fileset dir="${v7cardview.project.dir}/lib" includes="**/*.jar"/>
</path>

<macrodef name="build.project">
Expand Down
7 changes: 5 additions & 2 deletions android/dependency.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"min_api_level": "10",
"min_api_level": "13",
"dependencies":
{
"appcompat":[],
"cardview":[],
"accelerometer":[],
"analytics":[],
"android":[],
Expand All @@ -18,7 +19,7 @@
"media":["filesystem"],
"network":["xml"],
"platform":[],
"ui":["filesystem","media","appcompat"],
"ui":["filesystem","media","appcompat","cardview"],
"utils":[],
"xml":[]
},
Expand All @@ -29,6 +30,7 @@
"xml":["jaxen-1.1.1.jar"],
"ui":["nineoldandroids-appc-2.4.0.jar"],
"appcompat":["android-support-v4.jar", "android-support-v7-appcompat.jar"],
"cardview":["cardview-v7-23.0.1.jar"],
"analytics":["aps-analytics.jar"]
},
"runtimes":
Expand All @@ -39,6 +41,7 @@
"modulepackage":
{
"appcompat":"android.support.v7.appcompat",
"cardview":"android.support.v7.cardview",
"ui":"ti.modules.titanium.ui"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ protected void genModules(String modulesDestDir)
ArrayList<String> appCompatHack = new ArrayList<String>();
appCompatHack.add("appcompat");
modulesJSON.put("titanium-appcompat.jar", appCompatHack);

//Hack in the cardview module for now. revisit later.
ArrayList<String> cardViewHack = new ArrayList<String>();
cardViewHack.add("cardview");
modulesJSON.put("titanium-cardview.jar", cardViewHack);

File modules = new File(modulesDestDir, "modules.json");

Expand Down
10 changes: 10 additions & 0 deletions android/modules/cardview/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry exported="true" kind="lib" path="lib/cardview-v7-23.0.1.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions android/modules/cardview/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android-support-v7-cardview</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
12 changes: 12 additions & 0 deletions android/modules/cardview/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
24 changes: 24 additions & 0 deletions android/modules/cardview/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.support.v7.cardview" >

<uses-sdk android:minSdkVersion="7" />

<application />

</manifest>
24 changes: 24 additions & 0 deletions android/modules/cardview/aapt/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.support.v7.cardview" >

<uses-sdk android:minSdkVersion="7" />

<application />

</manifest>
3 changes: 3 additions & 0 deletions android/modules/cardview/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<project name="cardview" default="build">
<import file="../../build/build-module.xml"/>
</project>
Binary file not shown.
15 changes: 15 additions & 0 deletions android/modules/cardview/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-23
android.library=true
31 changes: 31 additions & 0 deletions android/modules/cardview/res/values/values.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- From: file:/usr/local/google/buildbot/repo_clients/https___googleplex-android.googlesource.com_a_platform_manifest.git/mnc-sdk-release/frameworks/support/v7/cardview/res/values/colors.xml -->
<eat-comment/>
<color name="cardview_dark_background">#FF202020</color>
<color name="cardview_light_background">#FFFAFAFA</color>
<color name="cardview_shadow_end_color">#03000000</color>
<color name="cardview_shadow_start_color">#37000000</color>
<declare-styleable name="CardView"><attr format="color" name="cardBackgroundColor"/><attr format="dimension" name="cardCornerRadius"/><attr format="dimension" name="cardElevation"/><attr format="dimension" name="cardMaxElevation"/><attr format="boolean" name="cardUseCompatPadding"/><attr format="boolean" name="cardPreventCornerOverlap"/><attr format="dimension" name="contentPadding"/><attr format="dimension" name="contentPaddingLeft"/><attr format="dimension" name="contentPaddingRight"/><attr format="dimension" name="contentPaddingTop"/><attr format="dimension" name="contentPaddingBottom"/></declare-styleable>
<!-- From: file:/usr/local/google/buildbot/repo_clients/https___googleplex-android.googlesource.com_a_platform_manifest.git/mnc-sdk-release/frameworks/support/v7/cardview/res/values/dimens.xml -->
<eat-comment/>
<dimen name="cardview_compat_inset_shadow">1dp</dimen>
<dimen name="cardview_default_elevation">2dp</dimen>
<dimen name="cardview_default_radius">2dp</dimen>
<!-- From: file:/usr/local/google/buildbot/repo_clients/https___googleplex-android.googlesource.com_a_platform_manifest.git/mnc-sdk-release/frameworks/support/v7/cardview/res/values/styles.xml -->
<eat-comment/>
<style name="CardView">
<item name="cardBackgroundColor">@color/cardview_light_background</item>
<item name="cardCornerRadius">@dimen/cardview_default_radius</item>
<item name="cardElevation">@dimen/cardview_default_elevation</item>
<item name="cardMaxElevation">@dimen/cardview_default_elevation</item>
<item name="cardUseCompatPadding">false</item>
<item name="cardPreventCornerOverlap">true</item>
</style>
<style name="CardView.Dark">
<item name="cardBackgroundColor">@color/cardview_dark_background</item>
</style>
<style name="CardView.Light">
<item name="cardBackgroundColor">@color/cardview_light_background</item>
</style>
</resources>
1 change: 1 addition & 0 deletions android/modules/cardview/src/java/.readme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file exists to keep src/java around
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2015 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
package ti.modules.titanium.ui.android;

import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.TiContext;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.view.TiUIView;

import ti.modules.titanium.ui.widget.TiUICardView;
import android.app.Activity;

@Kroll.proxy(creatableInModule = AndroidModule.class, propertyAccessors = {
TiC.PROPERTY_CARD_BACKGROUND_COLOR,
TiC.PROPERTY_CARD_CORNER_RADIUS,
TiC.PROPERTY_CARD_ELEVATION,
TiC.PROPERTY_CARD_MAX_ELEVATION,
TiC.PROPERTY_CARD_PREVENT_CORNER_OVERLAP,
TiC.PROPERTY_CARD_USE_COMPAT_PADDING,
TiC.PROPERTY_CONTENT_PADDING,
TiC.PROPERTY_CONTENT_PADDING_BOTTOM,
TiC.PROPERTY_CONTENT_PADDING_LEFT,
TiC.PROPERTY_CONTENT_PADDING_RIGHT,
TiC.PROPERTY_CONTENT_PADDING_TOP
})
public class CardViewProxy extends TiViewProxy
{
private static final int MSG_FIRST_ID = KrollProxy.MSG_LAST_ID + 1;
protected static final int MSG_LAST_ID = MSG_FIRST_ID + 999;

public CardViewProxy()
{
super();
}

public CardViewProxy(TiContext tiContext)
{
this();
}

@Override
public TiUIView createView(Activity activity)
{
return new TiUICardView(this);
}

@Override
public String getApiName()
{
return "Ti.UI.Android.CardView";
}
}

0 comments on commit a73d539

Please sign in to comment.