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

changes added #349

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
7 changes: 7 additions & 0 deletions CardScrollView/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
1 change: 1 addition & 0 deletions CardScrollView/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
26 changes: 26 additions & 0 deletions CardScrollView/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.example.mukul.cardscrollview"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
Binary file added CardScrollView/app/libs/gdk.jar
Binary file not shown.
17 changes: 17 additions & 0 deletions CardScrollView/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\mukul\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.mukul.cardscrollview;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
30 changes: 30 additions & 0 deletions CardScrollView/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.androidhive.cardscrollview"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />

<uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />

<application
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name" >
<activity
android:name="com.example.mukul.cardscrollview.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>

<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="@xml/voice_trigger_start" />
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.example.mukul.cardscrollview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;

import com.google.android.glass.app.Card.ImageLayout;
import com.google.android.glass.widget.CardScrollView;

import info.androidhive.cardscrollview.R;


public class MainActivity extends Activity {

private List<MovieCard> mCards;
private CardScrollView mCardScrollView;
private Context context;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

context = this;

prepareMovieCards();

mCardScrollView = new CardScrollView(this);
MovieCardsAdapter adapter = new MovieCardsAdapter(context, mCards);
mCardScrollView.setAdapter(adapter);
mCardScrollView.activate();
setContentView(mCardScrollView);
}

private void prepareMovieCards() {
mCards = new ArrayList<MovieCard>();

// Card with no background image
MovieCard mc = new MovieCard("I don't know. But who cares! Ha ha!",
"Wait! What does that mean?", ImageLayout.FULL, new int[] {});
mCards.add(mc);

// Card with full background image
mc = new MovieCard("I wanna go home. Does anyone know where my dad is?",
"Pet store?", ImageLayout.FULL,
new int[] { R.drawable.card_full });
mCards.add(mc);

// Card with full background of 3 images
mc = new MovieCard("Dude? Dude? Focus dude... Dude?",
"Oh, he lives. Hey, dude!", ImageLayout.FULL, new int[] {
R.drawable.card_bottom_left,
R.drawable.card_bottom_right, R.drawable.card_top });
mCards.add(mc);

// Card with left aligned images
mc = new MovieCard("Just keep swimming.",
"I'm sorry, Dory. But I... do", ImageLayout.LEFT, new int[] {
R.drawable.card_bottom_left,
R.drawable.card_bottom_right, R.drawable.card_top });
mCards.add(mc);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.example.mukul.cardscrollview;

/**
* Created by mukul on 10/21/2015.
*/

import com.google.android.glass.app.Card.ImageLayout;

public class MovieCard {

private String text;
private String footerText;
private ImageLayout imgLayout;
private int[] images;

public MovieCard() {
}

public MovieCard(String text, String footerText,
ImageLayout imgLayout, int[] images) {
this.text = text;
this.footerText = footerText;
this.imgLayout = imgLayout;
this.images = images;
}

public String getText() {
return text;
}

public void setText(String text) {
this.text = text;
}

public String getFooterText() {
return footerText;
}

public void setFooterText(String footerText) {
this.footerText = footerText;
}

public ImageLayout getImgLayout() {
return imgLayout;
}

public void setImgLayout(ImageLayout imgLayout) {
this.imgLayout = imgLayout;
}

public int[] getImages() {
return images;
}

public void setImages(int[] images) {
this.images = images;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.example.mukul.cardscrollview;

/**
* Created by mukul on 10/21/2015.
*/




import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.google.android.glass.app.Card;
import com.google.android.glass.widget.CardScrollAdapter;

// import com.google.android.glass.app.Card;
// import com.google.android.glass.widget.CardScrollAdapter;

public class MovieCardsAdapter extends CardScrollAdapter {
private List<MovieCard> mCards;
private Context context;

public MovieCardsAdapter(Context context, List<MovieCard> mCards) {
this.context = context;
this.mCards = mCards;
}


public int getPosition(Object item) {
return mCards.indexOf(item);
}


public int getCount() {
return mCards.size();
}

@Override
public Object getItem(int position) {
return mCards.get(position);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
Card card = new Card(context);

MovieCard mc = mCards.get(position);

// Card text
if (mc.getText() != null)
card.setText(mc.getText());

// Card footer note
if (mc.getFooterText() != null)
card.setFootnote(mc.getFooterText());

// Set image layout
if (mc.getImgLayout() != null)
card.setImageLayout(mc.getImgLayout());

// loop and set card images
for(int img : mc.getImages()){
card.addImage(img);
}

return card.toView();
}

@Override
public int findIdPosition(Object o) {
return 0;
}

@Override
public int findItemPosition(Object o) {
return 0;
}


}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions CardScrollView/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</RelativeLayout>
6 changes: 6 additions & 0 deletions CardScrollView/app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<menu 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" tools:context=".MainActivity">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
</menu>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions CardScrollView/app/src/main/res/values-w820dp/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
5 changes: 5 additions & 0 deletions CardScrollView/app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
11 changes: 11 additions & 0 deletions CardScrollView/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<resources>
<string name="app_name">CardScrollView</string>

<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>


<!-- "ok glass" voice command -->
<string name="start_command">Movie Cards</string>

</resources>
8 changes: 8 additions & 0 deletions CardScrollView/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>

</resources>
2 changes: 2 additions & 0 deletions CardScrollView/app/src/main/res/xml/voice_trigger_start.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!--?xml version="1.0" encoding="utf-8"?-->
<trigger keyword="@string/start_command" />
19 changes: 19 additions & 0 deletions CardScrollView/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}
Loading