Add Shrine demo app to material_components.

This builds on Bazel - Gradle setup to come in a future commit.

PiperOrigin-RevId: 150927644
This commit is contained in:
afohrman 2017-03-22 21:26:03 +00:00 committed by Travis Collins
parent 8af4d85340
commit 42fb7311bd
61 changed files with 1984 additions and 0 deletions

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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="io.material.demo.shrine"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="24"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:label="@string/app_name"
android:icon="@mipmap/product_logo_shrine_launcher_color_48"
android:allowBackup="true"
android:theme="@style/Theme.Shrine">
</application>
</manifest>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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="io.material.demo.shrine.filters">
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="24"/>
<application>
<activity
android:name=".FiltersActivity"
android:parentActivityName="io.material.demo.shrine.products.ProductListActivity"
android:label="@string/shrine_filter_page_title"
android:theme="@style/Theme.Shrine.Filter"/>
</application>
</manifest>

View File

@ -0,0 +1,40 @@
/*
* Copyright (C) 2017 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.
*/
package io.material.demo.shrine.filters;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
/**
* Activity that displays a list of filters the user can set to refine the list of products.
*/
public class FiltersActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shrine_filters_activity);
initToolbar();
}
private void initToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.AppBar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(getString(R.string.shrine_filter_page_title));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}

View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<LinearLayout
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:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/AppBar"
style="@style/Widget.Shrine.Toolbar.Filter"
tools:ignore="UnusedAttribute"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
style="@style/Widget.Shrine.SectionItem.Container"
android:paddingTop="@dimen/shrine_large_spacing">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/Widget.Shrine.TextView.SectionHeader"
android:text="@string/shrine_price_range_section_title"/>
<TextView
style="@style/Widget.Shrine.TextView.SectionHeaderEnd"
android:text="@string/shrine_price_range_max"/>
</LinearLayout>
<SeekBar
android:id="@+id/PriceRangeSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/shrine_large_spacing"
android:layout_marginBottom="@dimen/shrine_large_spacing"
android:paddingEnd="@dimen/shrine_seekbar_padding"
android:paddingStart="@dimen/shrine_seekbar_padding"/>
</LinearLayout>
<LinearLayout
style="@style/Widget.Shrine.SectionItem.Container">
<LinearLayout
style="@style/Widget.Shrine.SectionItem"
android:paddingTop="@dimen/shrine_small_spacing">
<TextView
style="@style/Widget.Shrine.TextView"
android:text="@string/shrine_international_shipping"/>
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"/>
</LinearLayout>
<LinearLayout
style="@style/Widget.Shrine.SectionItem"
android:paddingBottom="@dimen/shrine_small_spacing">
<TextView
style="@style/Widget.Shrine.TextView"
android:text="@string/shrine_personalized_feeds"/>
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
style="@style/Widget.Shrine.SectionItem.Container">
<TextView
style="@style/Widget.Shrine.TextView.SectionHeader"
android:paddingTop="@dimen/shrine_standard_spacing"
android:paddingBottom="@dimen/shrine_standard_spacing"
android:text="@string/shrine_item_type_section_title"/>
<LinearLayout
style="@style/Widget.Shrine.SectionItem">
<TextView
style="@style/Widget.Shrine.TextView"
android:text="@string/shrine_item_type_women"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
style="@style/Widget.Shrine.SectionItem">
<TextView
style="@style/Widget.Shrine.TextView"
android:text="@string/shrine_item_type_men"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
style="@style/Widget.Shrine.SectionItem">
<TextView
style="@style/Widget.Shrine.TextView"
android:text="@string/shrine_item_type_girls"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
style="@style/Widget.Shrine.SectionItem">
<TextView
style="@style/Widget.Shrine.TextView"
android:text="@string/shrine_item_type_boys"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<dimen name="shrine_section_elevation">4dp</dimen>
<dimen name="shrine_section_header_text_size">16sp</dimen>
<dimen name="shrine_seekbar_padding">12dp</dimen>
</resources>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<string name="shrine_filter_page_title">Filters</string>
<string name="shrine_price_range_section_title">Price Range</string>
<string name="shrine_price_range_max">$1000+</string>
<string name="shrine_international_shipping">International Shipping</string>
<string name="shrine_personalized_feeds">Personalized Feeds</string>
<string name="shrine_item_type_section_title">Item Type</string>
<string name="shrine_item_type_women">Women</string>
<string name="shrine_item_type_men">Men</string>
<string name="shrine_item_type_girls">Girls</string>
<string name="shrine_item_type_boys">Boys</string>
</resources>

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<style name="Theme.Shrine.Filter">
<item name="android:textAppearance">@style/Widget.Shrine.TextView</item>
</style>
<style name="Widget.Shrine.Toolbar.Filter">
<item name="android:background">?attr/colorPrimary</item>
</style>
<style name="Widget.Shrine.SectionItem" parent="">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingTop">@dimen/shrine_standard_spacing</item>
<item name="android:paddingBottom">@dimen/shrine_standard_spacing</item>
<item name="android:orientation">horizontal</item>
</style>
<style name="Widget.Shrine.SectionItem.Container">
<item name="android:layout_marginBottom">@dimen/shrine_small_spacing</item>
<item name="android:background">?attr/colorPrimary</item>
<item name="android:elevation">@dimen/shrine_section_elevation</item>
<item name="android:paddingEnd">@dimen/shrine_standard_spacing</item>
<item name="android:paddingStart">@dimen/shrine_standard_spacing</item>
<item name="android:orientation">vertical</item>
</style>
<style name="Widget.Shrine.TextView" parent="">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textAppearance">@style/TextAppearance.Shrine.Filter</item>
<item name="android:layout_weight">1</item>
</style>
<style name="Widget.Shrine.TextView.SectionHeader">
<item name="android:textAppearance">@style/TextAppearance.Shrine.Filter.SubHead</item>
</style>
<style name="Widget.Shrine.TextView.SectionHeaderEnd">
<item name="android:layout_weight">0</item>
<item name="android:textSize">@dimen/shrine_section_header_text_size</item>
</style>
<style name="TextAppearance.Shrine.Filter" parent="TextAppearance.AppCompat.Medium">
<item name="android:textColor">@color/textColorPrimary</item>
</style>
<style name="TextAppearance.Shrine.Filter.SubHead" parent="TextAppearance.AppCompat.Subhead">
<item name="android:textSize">@dimen/shrine_section_header_text_size</item>
<item name="android:textColor">@color/textColorSecondary</item>
</style>
</resources>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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="io.material.demo.shrine.products">
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="24"/>
<application>
<activity
android:name=".ProductListActivity"
android:theme="@style/Theme.Shrine.Launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".ItemActivity"
android:theme="@style/Theme.Shrine.ItemActivity"
android:parentActivityName=".ProductListActivity"/>
</application>
</manifest>

View File

@ -0,0 +1,89 @@
/*
* Copyright (C) 2017 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.
*/
package io.material.demo.shrine.products;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.DisplayMetrics;
import android.util.LruCache;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
import com.android.volley.toolbox.Volley;
/** Singleton class that handles image requests using Volley. */
public class ImageRequester {
private static Context ctx;
private static ImageRequester instance;
private final RequestQueue requestQueue;
private final ImageLoader imageLoader;
private final int maxByteSize;
private ImageRequester(Context context) {
ctx = context;
this.requestQueue = Volley.newRequestQueue(ctx.getApplicationContext());
this.requestQueue.start();
this.maxByteSize = calculateMaxByteSize();
this.imageLoader =
new ImageLoader(
requestQueue,
new ImageLoader.ImageCache() {
private final LruCache<String, Bitmap> lruCache =
new LruCache<String, Bitmap>(maxByteSize) {
@Override
protected int sizeOf(String url, Bitmap bitmap) {
return bitmap.getByteCount();
}
};
@Override
public synchronized Bitmap getBitmap(String url) {
return lruCache.get(url);
}
@Override
public synchronized void putBitmap(String url, Bitmap bitmap) {
lruCache.put(url, bitmap);
}
});
instance = this;
}
private static int calculateMaxByteSize() {
DisplayMetrics displayMetrics = ctx.getResources().getDisplayMetrics();
final int screenBytes = displayMetrics.widthPixels * displayMetrics.heightPixels * 4;
return screenBytes * 3;
}
/**
* Returns the existing ImageRequester instantiated, or a new instance if there is not yet an
* instance.
*
* @param context Of the calling activity.
* @return ImageRequester
*/
public static synchronized ImageRequester getInstance(Context context) {
if (instance == null) {
instance = new ImageRequester(context);
}
return instance;
}
public void setImageFromUrl(NetworkImageView networkImageView, String url) {
networkImageView.setImageUrl(url, imageLoader);
}
}

View File

@ -0,0 +1,113 @@
/*
* Copyright (C) 2017 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.
*/
package io.material.demo.shrine.products;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import com.android.volley.toolbox.NetworkImageView;
/**
* Activity that displays an individual product, including an image, name, and a short description.
*/
public class ItemActivity extends AppCompatActivity {
private static final String PRODUCT_TITLE = "title";
private static final String PRODUCT_URL = "url";
private static final String PRODUCT_DESCRIPTION = "description";
private static final String TAG = ItemActivity.class.getSimpleName();
private String fabMessage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shrine_item_activity);
initToolbar();
populateProductViews();
initFab(fabMessage);
}
public static void createItemActivityIntent(Context context, ProductEntry productEntry) {
Intent intent = new Intent(context, ItemActivity.class);
intent.putExtra(PRODUCT_TITLE, productEntry.title);
intent.putExtra(PRODUCT_URL, productEntry.url);
intent.putExtra(PRODUCT_DESCRIPTION, productEntry.description);
context.startActivity(intent);
}
private void populateProductViews() {
Bundle bundle = getIntent().getExtras();
if (bundle == null) {
String error = "Error retrieving product information.";
Log.e(TAG, error);
Snackbar.make(findViewById(R.id.ProductTitle), error, Snackbar.LENGTH_SHORT).show();
fabMessage = error;
} else {
TextView productTitle = (TextView) findViewById(R.id.ProductTitle);
productTitle.setText(bundle.getString(PRODUCT_TITLE));
TextView productDescription = (TextView) findViewById(R.id.ProductDescription);
productDescription.setText(bundle.getString(PRODUCT_DESCRIPTION));
initSpinner();
NetworkImageView productImage = (NetworkImageView) findViewById(R.id.ProductImage);
ImageRequester.getInstance(this).setImageFromUrl(productImage, bundle.getString(PRODUCT_URL));
fabMessage = getString(R.string.shrine_product_added_message);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.shrine_toolbar_menu, menu);
menu.findItem(R.id.ShrineToolbarFilterIcon).setVisible(false);
return true;
}
private void initToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.AppBar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
private void initFab(String fabMessage) {
findViewById(R.id.FloatingActionButton)
.setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
Snackbar.make(v, fabMessage, Snackbar.LENGTH_SHORT).show();
}
});
}
private void initSpinner() {
Spinner spinner = (Spinner) findViewById(R.id.QuantitySpinner);
ArrayAdapter<CharSequence> adapter =
ArrayAdapter.createFromResource(
this, R.array.product_quantities, R.layout.shrine_spinner_item);
adapter.setDropDownViewResource(R.layout.shrine_spinner_dropdown);
spinner.setAdapter(adapter);
}
}

View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2017 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.
*/
package io.material.demo.shrine.products;
import android.net.Uri;
/** A product entry in the list of products. */
public class ProductEntry {
public final String title;
public final Uri dynamicUrl;
public final String url;
public final String price;
public final String description;
public ProductEntry(
String title, String dynamicUrl, String url, String price, String description) {
this.title = title;
this.dynamicUrl = Uri.parse(dynamicUrl);
this.url = url;
this.price = price;
this.description = description;
}
}

View File

@ -0,0 +1,205 @@
/*
* Copyright (C) 2017 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.
*/
package io.material.demo.shrine.products;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.Bundle;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
import com.android.volley.toolbox.NetworkImageView;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import io.material.demo.shrine.filters.FiltersActivity;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
/** Activity that displays a list of products. */
public class ProductListActivity extends AppCompatActivity {
private static final String TAG = ProductListActivity.class.getSimpleName();
private ImageRequester imageRequester;
private List<ProductEntry> productEntryList;
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(R.style.Theme_Shrine);
super.onCreate(savedInstanceState);
setContentView(R.layout.shrine_product_activity);
imageRequester = ImageRequester.getInstance(this);
initProductEntryList();
initCollapsingToolbar();
initItemGrid();
}
private void initProductEntryList() {
InputStream inputStream = getResources().openRawResource(R.raw.products);
Writer writer = new StringWriter();
char[] buffer = new char[1024];
try {
Reader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
int pointer;
while ((pointer = reader.read(buffer)) != -1) {
writer.write(buffer, 0, pointer);
}
} catch (IOException exception) {
Log.e(TAG, "Error writing/reading from the JSON file.", exception);
} finally {
try {
inputStream.close();
} catch (IOException exception) {
Log.e(TAG, "Error closing the input stream.", exception);
}
}
String jsonProductsString = writer.toString();
Gson gson = new Gson();
Type productListType = new TypeToken<ArrayList<ProductEntry>>() {}.getType();
this.productEntryList = gson.fromJson(jsonProductsString, productListType);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.shrine_toolbar_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.ShrineToolbarFilterIcon) {
startActivity(new Intent(this, FiltersActivity.class));
return true;
}
return false;
}
private void initCollapsingToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.AppBar);
int collapsingToolbarImageIndex = 6;
int collapsingImageToolbarSize = 1200;
NetworkImageView collapsingToolbarImage =
(NetworkImageView) findViewById(R.id.CollapsingToolbarImage);
StringBuilder collapsingToolbarImageUrl =
new StringBuilder(productEntryList.get(collapsingToolbarImageIndex).url);
collapsingToolbarImageUrl.append("=s");
collapsingToolbarImageUrl.append(collapsingImageToolbarSize);
setSupportActionBar(toolbar);
CollapsingToolbarLayout collapsingToolbarLayout =
(CollapsingToolbarLayout) findViewById(R.id.CollapsingToolbarLayout);
collapsingToolbarLayout.setTitle(toolbar.getTitle());
collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.TextAppearance_Shrine_Logo);
collapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.TextAppearance_Shrine_Logo);
imageRequester.setImageFromUrl(collapsingToolbarImage, collapsingToolbarImageUrl.toString());
Point windowSize = new Point();
getWindowManager().getDefaultDisplay().getSize(windowSize);
int windowWidth = windowSize.x;
collapsingToolbarImage.setX(collapsingToolbarImage.getX() - windowWidth / 4);
collapsingToolbarLayout.setScrimVisibleHeightTrigger(
(int) getResources().getDimension(R.dimen.shrine_tall_toolbar_height) / 2);
}
private void initItemGrid() {
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.ProductGrid);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
recyclerView.setAdapter(new ProductAdapter(this, productEntryList, imageRequester));
}
private static class ProductAdapter extends Adapter<ProductViewHolder> {
private final Activity activity;
private final List<ProductEntry> productEntries;
public ImageRequester imageRequester;
public ProductAdapter(
Activity activity, List<ProductEntry> productEntries, ImageRequester imageRequester) {
this.activity = activity;
this.productEntries = productEntries;
this.imageRequester = imageRequester;
}
@Override
public ProductViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
return new ProductViewHolder(activity, viewGroup);
}
@Override
public void onBindViewHolder(ProductViewHolder productViewHolder, int i) {
productViewHolder.bind(activity, productEntries.get(i), imageRequester);
}
@Override
public int getItemCount() {
return productEntries.size();
}
}
private static class ProductViewHolder extends ViewHolder {
private final TextView productPriceView;
private final NetworkImageView productImageView;
private final TextView productShopNameView;
private final CardView productEntryView;
public ProductViewHolder(Context context, ViewGroup parent) {
super(LayoutInflater.from(context).inflate(R.layout.shrine_product_entry, parent, false));
ViewGroup.LayoutParams layoutParams = itemView.getLayoutParams();
itemView.setLayoutParams(layoutParams);
productPriceView = (TextView) itemView.findViewById(R.id.ProductPrice);
productImageView = (NetworkImageView) itemView.findViewById(R.id.ProductImage);
productShopNameView = (TextView) itemView.findViewById(R.id.ProductShopName);
productEntryView = (CardView) itemView.findViewById(R.id.ProductEntry);
productEntryView.setOnClickListener(clickListener);
}
private final OnClickListener clickListener =
new OnClickListener() {
@Override
public void onClick(View v) {
ItemActivity.createItemActivityIntent(v.getContext(), (ProductEntry) v.getTag());
}
};
public void bind(Context context, ProductEntry productEntry, ImageRequester imageRequester) {
productPriceView.setText(productEntry.price);
imageRequester.setImageFromUrl(productImageView, productEntry.url);
productShopNameView.setText(productEntry.title);
productEntryView.setTag(productEntry);
}
}
}

View File

@ -0,0 +1,25 @@
<!--
Copyright (C) 2017 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M11,9h2L13,6h3L16,4h-3L13,1h-2v3L8,4v2h3v3zM7,18c-1.1,0 -1.99,0.9 -1.99,2S5.9,22 7,22s2,-0.9 2,-2 -0.9,-2 -2,-2zM17,18c-1.1,0 -1.99,0.9 -1.99,2s0.89,2 1.99,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM7.17,14.75l0.03,-0.12 0.9,-1.63h7.45c0.75,0 1.41,-0.41 1.75,-1.03l3.86,-7.01L19.42,4h-0.01l-1.1,2 -2.76,5L8.53,11l-0.13,-0.27L6.16,6l-0.95,-2 -0.94,-2L1,2v2h2l3.6,7.59 -1.35,2.45c-0.16,0.28 -0.25,0.61 -0.25,0.96 0,1.1 0.9,2 2,2h12v-2L7.42,15c-0.13,0 -0.25,-0.11 -0.25,-0.25z"/>
</vector>

View File

@ -0,0 +1,25 @@
<!--
Copyright (C) 2017 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M7,10l5,5 5,-5z"/>
</vector>

View File

@ -0,0 +1,25 @@
<!--
Copyright (C) 2017 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
</vector>

View File

@ -0,0 +1,25 @@
<!--
Copyright (C) 2017 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z"/>
</vector>

View File

@ -0,0 +1,25 @@
<!--
Copyright (C) 2017 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
</vector>

View File

@ -0,0 +1,25 @@
<!--
Copyright (C) 2017 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M7,18c-1.1,0 -1.99,0.9 -1.99,2S5.9,22 7,22s2,-0.9 2,-2 -0.9,-2 -2,-2zM1,2v2h2l3.6,7.59 -1.35,2.45c-0.16,0.28 -0.25,0.61 -0.25,0.96 0,1.1 0.9,2 2,2h12v-2L7.42,15c-0.14,0 -0.25,-0.11 -0.25,-0.25l0.03,-0.12 0.9,-1.63h7.45c0.75,0 1.41,-0.41 1.75,-1.03l3.58,-6.49c0.08,-0.14 0.12,-0.31 0.12,-0.48 0,-0.55 -0.45,-1 -1,-1L5.21,4l-0.94,-2L1,2zM17,18c-1.1,0 -1.99,0.9 -1.99,2s0.89,2 1.99,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
</vector>

View File

@ -0,0 +1,25 @@
<!--
Copyright (C) 2017 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M17,2L7,2L2,6.62 12,22 22,6.62 17,2zM11.25,11.5L6.96,11.5L4.69,8h6.56v3.5zM11.25,13v5.1L7.94,13h3.31zM12.75,8L15,8v6.63l-2.25,3.46L12.75,8zM16.5,8h2.81l-2.81,4.32L16.5,8zM19.66,6.5L16.5,6.5L16.5,3.58l3.16,2.92zM7.59,3.5L15,3.5v3L4.34,6.5l3.25,-3z"/>
</vector>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorPrimary"/>
<stroke
android:width="@dimen/shrine_spinner_border_width"
android:color="@color/colorDivider"/>
</shape>

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<!--
Wrapping the entire layout in a FrameLayout and setting a bottom margin on the CoordinatorLayout
because the BottomNavigationView doesn't display correctly inside a CoordinatorLayout.
-->
<FrameLayout
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:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/shrine_bottom_nav_view_height">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/AppBar"
style="@style/Widget.Shrine.Toolbar.Logo.Product"
tools:ignore="UnusedAttribute"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/shrine_standard_spacing"
android:layout_marginRight="@dimen/shrine_standard_spacing"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="@dimen/shrine_item_image_height">
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ProductImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/shrine_standard_spacing"
android:layout_marginBottom="@dimen/shrine_standard_spacing"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="fitCenter"/>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/shrine_large_spacing"
android:layout_marginStart="@dimen/shrine_large_margin_start"
android:orientation="vertical">
<TextView
android:id="@+id/ProductTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/shrine_standard_spacing"
android:layout_marginBottom="@dimen/shrine_standard_spacing"
android:textAppearance="@style/TextAppearance.AppCompat.Display2"
android:textSize="@dimen/shrine_item_product_title_size"/>
<Spinner
android:id="@+id/QuantitySpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/shrine_standard_spacing"
android:layout_marginBottom="@dimen/shrine_standard_spacing"
android:background="@drawable/shrine_spinner_border"
android:minWidth="@dimen/shrine_spinner_width"/>
<TextView
android:id="@+id/ProductDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/shrine_standard_spacing"
android:layout_marginBottom="@dimen/shrine_large_spacing"
android:lineSpacingMultiplier="1.5"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/shrine_standard_spacing"
android:layout_gravity="bottom|end"
android:src="@drawable/ic_add_shopping_cart_vd_theme_24"
app:fabSize="normal"/>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/BottomNavView"
style="@style/Shrine.BottomNavView"
app:menu="@menu/shrine_bottom_nav_view_menu"/>
</FrameLayout>

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<!--
Wrapping the entire layout in a FrameLayout and setting a bottom margin on the CoordinatorLayout
because the BottomNavigationView doesn't display correctly inside a CoordinatorLayout.
-->
<FrameLayout
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:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/CoordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/shrine_bottom_nav_view_height">
<android.support.v7.widget.RecyclerView
android:id="@+id/ProductGrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/shrine_grid_outer_margin"
android:layout_marginEnd="@dimen/shrine_grid_outer_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="@dimen/shrine_tall_toolbar_height">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/CollapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:collapsedTitleTextAppearance="@style/TextAppearance.Shrine.Logo"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleGravity="top"
app:expandedTitleMarginStart="@dimen/shrine_toolbar_offset_start"
app:expandedTitleMarginTop="@dimen/shrine_toolbar_offset_top"
app:expandedTitleTextAppearance="@style/TextAppearance.Shrine.Logo"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/CollapsingToolbarImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/shrine_toolbar_image_offset_top"
android:adjustViewBounds="true"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/shrine_toolbar_subtitle_offset_top"
android:layout_marginStart="@dimen/shrine_toolbar_subtitle_offset_start"
android:layout_marginEnd="@dimen/shrine_standard_spacing"
android:layout_gravity="top"
android:orientation="vertical"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/shrine_product_category"
android:textAppearance="@style/TextAppearance.AppCompat.Display2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/shrine_standard_spacing"
android:text="@string/shrine_product_description"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"/>
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/AppBar"
android:layout_width="match_parent"
android:layout_height="@dimen/shrine_toolbar_collapsed_height"
tools:ignore="UnusedAttribute"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/BottomNavView"
style="@style/Shrine.BottomNavView"
app:menu="@menu/shrine_bottom_nav_view_menu"/>
</FrameLayout>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ProductEntry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/shrine_grid_item_margin"
android:orientation="vertical"
app:cardElevation="@dimen/cardview_default_elevation">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/shrine_card_inner_padding">
<TextView
android:id="@+id/ProductPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:textColor="@color/textColorProduct"
android:textStyle="bold"/>
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ProductImage"
android:layout_width="wrap_content"
android:layout_height="@dimen/shrine_grid_image_height"
android:layout_gravity="center"
android:scaleType="fitCenter"/>
<TextView
android:id="@+id/ProductShopName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:textColor="@color/colorAccent"/>
</LinearLayout>
</android.support.v7.widget.CardView>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<TextView
style="@style/Shrine.SpinnerItem"/>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Shrine.SpinnerItem"
android:drawableEnd="@drawable/ic_arrow_drop_down_vd_theme_24"/>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/BottomNavFavorites"
android:enabled="true"
android:title="@string/shrine_bottom_nav_favorites"
android:icon="@drawable/ic_favorite_vd_theme_24"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/BottomNavHome"
android:enabled="true"
android:title="@string/shrine_bottom_nav_home"
android:icon="@drawable/ic_shrine_vd_theme_24"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/BottomNavCart"
android:enabled="true"
android:title="@string/shrine_bottom_nav_cart"
android:icon="@drawable/ic_shopping_cart_vd_theme_24"
app:showAsAction="ifRoom"/>
</menu>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/ShrineToolbarFilterIcon"
android:title="@string/shrine_icon_filter_title"
android:icon="@drawable/ic_filter_list_vd_theme_24"
app:showAsAction="always"/>
<item
android:id="@+id/ShrineToolbarSearchIcon"
android:title="@string/shrine_icon_search_title"
android:icon="@drawable/ic_search_vd_theme_24"
app:showAsAction="always"/>
</menu>

View File

@ -0,0 +1,74 @@
[
{
"title": "Red Popsicle",
"url": "https://lh3.googleusercontent.com/3w0neXbSlI4p6mtkRdwL7SwRH4NKHmmdBm1n58tNvUnV0DwnxZ6MfIwzSz0c7MlE3NZku1TmQAQm-4Tly6geteQpONOniM_m",
"price": "$5",
"description": "Looks can be deceiving. This Red Popsicle comes in a wide variety of flavors, including strawberry, that burst as soon as it hits the mouth. Red Popsicles melt slow, so savor the flavor."
},
{
"title": "Green Slip-ons",
"url": "https://lh3.googleusercontent.com/7O1nZyD9xwP0nel27kC49ZVfuUlMJrGdcI1j8PHBZxD2J8Gd-q1wQ5Rrn9sDQ_Q7Zi1-SNHDrBRaB5FD5zbtoEto1RpjBkXo",
"price": "$75",
"description": "Feetsy has been making extraordinary slip-ons for decades. With each pair of shoes purchased Feetsy donates a pair to those in need. Buy yourself a pair, buy someone else a pair. Very Comfortable."
},
{
"title": "Teapot",
"url": "https://lh3.googleusercontent.com/2L6RmCDcdBT_5160bg-rZaybSCGze6TCpEyTYko0Y6GWVp432qttKvXB19w4TgSnTz-Pxes12TPSzdRWT8Gq9dCJm2aF1zPj8g",
"price": "$210",
"description": "Impress your guests with Teapot by Kitchen Stuff. Teapot holds extremely hot liquids and pours them from the spout. Use the handle, shown on the left, so your fingers don’t get burnt while pouring."
},
{
"title": "Beachball",
"url": "https://lh3.googleusercontent.com/FDlLqxdGjraCR8J0QzcuCh7eRHvnXNyWwP9mOTMviY2IX4WglCbAobxBD8tfYvUk-gZeOwvv02IC5vhbgEAk7F7gV2XwLJpAaw",
"price": "$25",
"description": "Are you at a baseball game and feeling bored? At a pool party and looking for a laugh? Do you need something to take your anger out on? Beachball, by inflatable fun, is the perfect outlet."
},
{
"title": "Clock",
"url": "https://lh3.googleusercontent.com/RJIsp5e-fQ_oQBWR-OJfJgcvCmfFJ8ZCL5D5_4-P3U4h7Im-WDvVJYqTl_YsCWcKFn5xbLI_9flEzUr0CA1PwCYGqDQDLvKxDA",
"price": "$120",
"description": "Timekeeper Co makes clocks that tell time precisely. Clock is very simple to use, set the time using your phone, hang it, and viola! You’ll never be late again."
},
{
"title": "Lime Flippers",
"url": "https://lh3.googleusercontent.com/74P9JRtvjF4IIUYLxTZEFp9ffjNrcTFE1pCPduyTLPNjTAldtsRKn0iDx1CmOclJIsYJUWpyCKqXFrJzv3-ebEDe62wLci0R",
"price": "$25",
"description": "Flippers are a nice tool to have when you’re being chased by an oversized sea turtle. Never get caught again with these fast water shoes. You’re like a fish, but more graceful."
},
{
"title": "Perfect Goldfish \nBowl",
"url": "https://lh3.googleusercontent.com/pfgpUuVo_9zWqn2lI6gAlDK2ceLe_MEzgNtj-RaClJb0w41NvSrOg-xgwMcr5FrYTdC6wJHKDSdP7GiuSbNAdjTSHlOdfXR1",
"price": "$25",
"description": "The Perfect Bowl Co makes the best bowls for just about anything you can think of. This Perfect Goldfish Bowl holds water and fish perfectly. Looks great in living rooms. Keep out of reach from cats."
},
{
"title": "Surfboard",
"url": "https://lh3.googleusercontent.com/585zsoqfGl58nbCDgM3MXLcVcZCfriN1k4N7KTnHDBULhSmeF9D80HhLAuDixrk0gLp9YdArxCQfZ7Yg-3zlEgkvQBaXzBwYSg",
"price": "$300",
"description": "Who says you can’t walk on water? With Surfboard, by Surfboard Supply, you can fly on water. This beast is fast and handles like a porsche. Hang Ten Bro!"
},
{
"title": "Backpack",
"url": "https://lh3.googleusercontent.com/KE89imsb_0hMmO2YMxnZ6cQYelrmI3jdpDo06svFeNj_OjHUw9dfHoBj4pN7qqm1khs9-_japkG5As6TWgOmJzTa8Cv_9GcGfg",
"price": "$150",
"description": "This backpack by Bags ‘n’ stuff can hold just about anything: a laptop, a pen, a protractor, notebooks, small animals, plugs for your devices, sunglasses, gym clothes, shoes, gloves, two kittens, and even lunch!"
},
{
"title": "Sunglasses",
"url": "https://lh3.googleusercontent.com/-0TR98kQUVgeSGyK24T0181IwtNgCWhxfMejw-fEXQF005lfuDERc-B6hxtSPBsPyFEJBxPv8H9FSNb7k3AgjRO2wm8YXeMa",
"price": "$100",
"description": "Be an optimist. Carry Sunglasses with you at all times. All Tints and Shades products come with polarized lenses and super duper UV protection so you can look at the sun for however long you want. Sunglasses make you look cool, wear them."
},
{
"title": "Red Lipstick Set",
"url": "https://lh3.googleusercontent.com/w7BggGOgZEVuI4_wsSO96PDi-y4kqtHVHqQknCMN7eyraQLIlh58QK5Y1Wc-eTAYDcmn7KmiJNvKsoFLAZBClSAYpI9vyuDRIw",
"price": "$25",
"description": "Trying to find the perfect shade to match your mood? Try no longer. Red Lipstick Set by StickLips has you covered for those nights when you need to get out, or even if you’re just headed to work."
},
{
"title": "Dipped Brush",
"url": "https://lh3.googleusercontent.com/8dsHE4FwZ5VJOFj_EmhGt48r19ILh7rloMCBC5QPyP2Jrm7-Jz4wVZa1Q3cGFBBbi8OKJzb7nwUnBOqaPVwafMKOthbRtv6Z",
"price": "$15",
"description": "WeDipIt does it again. This handle dipped 4 inch brush is a perfect for painting 4 inch lines, or coloring in big areas with paint. Just be sure you don’t drop it in a bucket of red paint, then it won’t look dipped anymore."
}
]

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<color name="colorAccentSecondary">#ffb300</color>
<color name="colorDivider">#1f000000</color>
<color name="textColorProduct">#0a3142</color>
</resources>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<dimen name="shrine_tall_toolbar_height">474dp</dimen>
<dimen name="shrine_toolbar_image_offset_top">48dp</dimen>
<dimen name="shrine_toolbar_offset_start">124dp</dimen>
<dimen name="shrine_toolbar_offset_top">124dp</dimen>
<dimen name="shrine_toolbar_subtitle_offset_top">232dp</dimen>
<dimen name="shrine_toolbar_subtitle_offset_start">124dp</dimen>
<dimen name="shrine_card_inner_padding">8dp</dimen>
<dimen name="shrine_grid_item_margin">4dp</dimen>
<dimen name="shrine_grid_outer_margin">12dp</dimen>
<dimen name="shrine_grid_image_height">200dp</dimen>
<dimen name="shrine_item_image_height">292dp</dimen>
<dimen name="shrine_item_product_title_size">30sp</dimen>
<dimen name="shrine_large_margin_start">56dp</dimen>
<dimen name="shrine_spinner_width">212dp</dimen>
<dimen name="shrine_spinner_height">48dp</dimen>
<dimen name="shrine_spinner_border_width">2dp</dimen>
</resources>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<string name="shrine_product_category">Best Gifts for Teen Girls</string>
<string name="shrine_product_description">
Leave the tunnel and the rain is fallin amazing things happen when you wait
</string>
<string name="shrine_product_added_message">Product was added to your cart.</string>
<string name="shrine_bottom_nav_favorites">Favorites</string>
<string name="shrine_bottom_nav_home">Home</string>
<string name="shrine_bottom_nav_cart">Cart</string>
<string name="shrine_icon_search_title">Search</string>
<string name="shrine_icon_filter_title">Filter</string>
<string-array name="product_quantities">
<item>Quantity 1</item>
<item>Quantity 2</item>
<item>Quantity 3</item>
<item>Quantity 4</item>
</string-array>
</resources>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<style name="Theme.Shrine.ItemActivity">
<item name="colorAccent">@color/colorAccentSecondary</item>
<item name="android:textColor">@color/textColorProduct</item>
</style>
<style name="Widget.Shrine.Toolbar.Logo.Product">
<item name="android:background">?attr/colorPrimary</item>
</style>
<style name="Shrine.SpinnerItem" parent="">
<item name="android:layout_width">@dimen/shrine_spinner_width</item>
<item name="android:layout_height">@dimen/shrine_spinner_height</item>
<item name="android:fontFamily">sans-serif-light</item>
<item name="android:gravity">center_vertical</item>
<item name="android:paddingStart">@dimen/shrine_standard_spacing</item>
<item name="android:paddingEnd">@dimen/shrine_small_spacing</item>
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Subhead</item>
</style>
</resources>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<string name="app_name">Shrine</string>
</resources>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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="io.material.demo.shrine.theme">
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="24"/>
<application/>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2017 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.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item android:drawable="@android:color/white" />
<item
android:id="@+id/launchscreens_product_logo"
android:bottom="@dimen/launchscreens_product_logo_bottom">
<bitmap
android:src="@drawable/product_logo_shrine_color_192"
android:gravity="center"/>
</item>
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2017 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.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item android:drawable="@android:color/white" />
<item
android:id="@+id/launchscreens_product_logo"
android:bottom="@dimen/launchscreens_product_logo_bottom">
<bitmap
android:src="@drawable/product_logo_shrine_color_144"
android:gravity="center"/>
</item>
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<!-- Adjusted higher to deal with the smaller total height we have to deal with on phones -->
<dimen name="launchscreens_product_logo_bottom">48dp</dimen>
</resources>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<!-- Values adjusted for nav bar size due to windowDrawsSystemBarBackgrounds -->
<dimen name="launchscreens_product_logo_bottom">64dp</dimen>
</resources>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<!-- Values adjusted for nav bar size due to windowDrawsSystemBarBackgrounds -->
<dimen name="launchscreens_product_logo_bottom">72dp</dimen>
</resources>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<!-- Tablets have a lot more landscape height, so we undo the phone-only landscape adjustment -->
<dimen name="launchscreens_product_logo_bottom">24dp</dimen>
</resources>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<!-- Values adjusted for nav bar size due to windowDrawsSystemBarBackgrounds -->
<dimen name="launchscreens_product_logo_bottom">72dp</dimen>
</resources>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<dimen name="launchscreens_product_logo_bottom">24dp</dimen>
</resources>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<color name="colorPrimary">#ffffff</color>
<color name="colorPrimaryDark">#e0e0e0</color>
<color name="colorAccent">#607d8b</color>
<color name="textColorPrimary">#dd000000</color>
<color name="textColorSecondary">#89000000</color>
</resources>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<dimen name="shrine_standard_spacing">16dp</dimen>
<dimen name="shrine_small_spacing">8dp</dimen>
<dimen name="shrine_large_spacing">36dp</dimen>
<dimen name="shrine_toolbar_collapsed_height">72dp</dimen>
<dimen name="shrine_toolbar_elevation">4dp</dimen>
<dimen name="shrine_bottom_nav_view_elevation">16dp</dimen>
<dimen name="shrine_bottom_nav_view_height">56dp</dimen>
<dimen name="launchscreens_product_logo_bottom">16dp</dimen>
</resources>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright (C) 2017 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.
-->
<resources>
<style name="Theme.Shrine" parent="Base.Theme.Shrine"/>
<style name="Theme.Shrine.Launcher">
<item name="colorPrimaryDark">?attr/colorPrimary</item>
<item name="android:windowBackground">@drawable/launch_screen</item>
</style>
<style name="Base.Theme.Shrine" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorPrimary">@color/textColorPrimary</item>
<item name="toolbarStyle">@style/Widget.Shrine.Toolbar.Logo</item>
</style>
<style name="Widget.Shrine.Toolbar" parent="Widget.AppCompat.Toolbar">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">@dimen/shrine_toolbar_collapsed_height</item>
<item name="android:minHeight">@dimen/shrine_toolbar_collapsed_height</item>
</style>
<style name="Widget.Shrine.Toolbar.Logo">
<item name="android:elevation">@dimen/shrine_toolbar_elevation</item>
<item name="titleTextAppearance">@style/TextAppearance.Shrine.Logo</item>
</style>
<style name="TextAppearance.Shrine.Logo" parent="TextAppearance.AppCompat.Display3">
<item name="android:letterSpacing">0.20</item>
<item name="android:textAllCaps">true</item>
<item name="android:textSize">22sp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="ThemeOverlay.Shrine.BottomNavView" parent="">
<item name="colorPrimary">@color/colorAccent</item>
</style>
<style name="Shrine.BottomNavView" parent="">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">@dimen/shrine_bottom_nav_view_height</item>
<item name="android:layout_gravity">bottom</item>
<item name="android:background">@color/colorPrimary</item>
<item name="android:theme">@style/ThemeOverlay.Shrine.BottomNavView</item>
<item name="elevation">@dimen/shrine_bottom_nav_view_elevation</item>
</style>
</resources>

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) 2017 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.
*/
package io.material.demo.shrine.products;
import static com.google.common.truth.Truth.assertThat;
import android.support.v7.widget.RecyclerView;
import org.robolectric.RobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
/** Unit tests for {@link ProductListActivity}. */
@RunWith(RobolectricTestRunner.class)
@Config(
manifest =
"//third_party/java_src/android_libs/material_components/demos/java/io/material/demo/shrine/products" + ":products/AndroidManifest.xml"
)
public class ProductListActivityTest {
private ProductListActivity productListActivity;
private RecyclerView productsRecyclerView;
@Before
public void setUp() {
productListActivity = Robolectric.setupActivity(ProductListActivity.class);
productsRecyclerView = (RecyclerView) productListActivity.findViewById(R.id.ProductGrid);
}
@Test
public void testProductListIsNotNull() {
assertThat(productsRecyclerView).isNotNull();
}
@Test
public void testProductListHasProducts() {
int productCount = productsRecyclerView.getChildCount();
assertThat(productCount).isAtLeast(1);
}
}