better looking demo app
This commit is contained in:
parent
4de65a2b25
commit
cb21f04794
10
.idea/codeStyles/Project.xml
generated
10
.idea/codeStyles/Project.xml
generated
@ -1,8 +1,18 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<AndroidXmlCodeStyleSettings>
|
||||
<option name="USE_CUSTOM_SETTINGS" value="true" />
|
||||
</AndroidXmlCodeStyleSettings>
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
|
||||
4
.idea/encodings.xml
generated
Normal file
4
.idea/encodings.xml
generated
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
|
||||
</project>
|
||||
@ -7,7 +7,7 @@ apply plugin: 'kotlin-android-extensions'
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
applicationId "me.gilo.wc_app"
|
||||
applicationId "me.gilo.wc"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 28
|
||||
versionCode 1
|
||||
@ -45,6 +45,12 @@ dependencies {
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
implementation 'com.android.support:design:28.0.0'
|
||||
|
||||
implementation 'io.github.inflationx:calligraphy3:3.0.0'
|
||||
implementation 'io.github.inflationx:viewpump:1.0.0'
|
||||
|
||||
implementation 'com.squareup.picasso:picasso:2.5.2'
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package me.gilo.wc_app
|
||||
package me.gilo.wc
|
||||
|
||||
import android.support.test.InstrumentationRegistry
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
@ -1,20 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="me.gilo.wc_app">
|
||||
package="me.gilo.wc">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
android:name=".WcApp"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".ui.ShopActivity"
|
||||
android:label="@string/title_activity_shop"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
android:name=".ui.MenuActivity"
|
||||
android:label="@string/title_activity_menu"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.CouponActivity"
|
||||
android:label="@string/title_activity_coupon"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.ShopActivity"
|
||||
android:label="@string/title_activity_shop"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
|
||||
BIN
app/src/main/assets/fonts/GT-America-Bold.otf
Normal file
BIN
app/src/main/assets/fonts/GT-America-Bold.otf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/GT-America-Medium.otf
Normal file
BIN
app/src/main/assets/fonts/GT-America-Medium.otf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/GT-America-Regular.otf
Normal file
BIN
app/src/main/assets/fonts/GT-America-Regular.otf
Normal file
Binary file not shown.
56
app/src/main/java/me/gilo/wc/MainActivity.kt
Normal file
56
app/src/main/java/me/gilo/wc/MainActivity.kt
Normal file
@ -0,0 +1,56 @@
|
||||
package me.gilo.wc
|
||||
|
||||
import android.content.Intent
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import me.gilo.wc.ui.MenuActivity
|
||||
import me.gilo.woodroid.Woocommerce
|
||||
import me.gilo.woodroid.models.Coupon
|
||||
import me.gilo.woodroid.models.Product
|
||||
import java.util.ArrayList
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
val TAG = "MainActivity";
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
startActivity(Intent(baseContext, MenuActivity::class.java));
|
||||
finish()
|
||||
|
||||
}
|
||||
|
||||
// private fun coupons() {
|
||||
// val woocommerce = Woocommerce.Builder()
|
||||
// .setSiteUrl("http://157.230.131.179")
|
||||
// .setApiVersion("2")
|
||||
// .setConsumerKey("ck_26c61abd7eeff238d87dc56585bf26cb2d1a1ec3")
|
||||
// .setConsumerSecret("cs_062e8e3a7ae0ce08fdebc0c39f8f834d5e87598e")
|
||||
// .build()
|
||||
//
|
||||
// tvText.append("\n")
|
||||
// tvText.append("\n")
|
||||
// tvText.append("Products")
|
||||
// tvText.append("\n")
|
||||
// tvText.append("\n")
|
||||
//
|
||||
// woocommerce.Coupon().coupons().enqueue(object : Callback<List<Coupon>> {
|
||||
// override fun onResponse(call: Call<List<Coupon>>, response: Response<List<Coupon>>) {
|
||||
// val coupons = response.body()
|
||||
// for (coupon in coupons!!) {
|
||||
// tvText.append(coupon.description + "\n")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onFailure(call: Call<List<Coupon>>, t: Throwable) {
|
||||
//
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
}
|
||||
24
app/src/main/java/me/gilo/wc/WcApp.java
Normal file
24
app/src/main/java/me/gilo/wc/WcApp.java
Normal file
@ -0,0 +1,24 @@
|
||||
package me.gilo.wc;
|
||||
|
||||
import android.app.Application;
|
||||
import io.github.inflationx.calligraphy3.CalligraphyConfig;
|
||||
import io.github.inflationx.calligraphy3.CalligraphyInterceptor;
|
||||
import io.github.inflationx.viewpump.ViewPump;
|
||||
|
||||
public class WcApp extends Application {
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
ViewPump.init(ViewPump.builder()
|
||||
.addInterceptor(new CalligraphyInterceptor(
|
||||
new CalligraphyConfig.Builder()
|
||||
.setDefaultFontPath("fonts/GT-America-Regular.otf")
|
||||
.setFontAttrId(R.attr.fontPath)
|
||||
.build()))
|
||||
.build());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
36
app/src/main/java/me/gilo/wc/adapter/MenuAdapter.java
Normal file
36
app/src/main/java/me/gilo/wc/adapter/MenuAdapter.java
Normal file
@ -0,0 +1,36 @@
|
||||
package me.gilo.wc.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import me.gilo.wc.R;
|
||||
import me.gilo.wc.adapter.viewholder.MenuViewHolder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class MenuAdapter extends RecyclerView.Adapter<MenuViewHolder> {
|
||||
private List<String> titles;
|
||||
|
||||
public MenuAdapter( List<String> titles) {
|
||||
this.titles = titles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new MenuViewHolder(parent.getContext(), LayoutInflater.from(parent.getContext()).inflate(R.layout.single_menu_item, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(MenuViewHolder holder, int position) {
|
||||
holder.renderView(titles.get(position));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return titles.size() == 0 ? 0 : titles.size();
|
||||
}
|
||||
}
|
||||
35
app/src/main/java/me/gilo/wc/adapter/ProductAdapter.java
Normal file
35
app/src/main/java/me/gilo/wc/adapter/ProductAdapter.java
Normal file
@ -0,0 +1,35 @@
|
||||
package me.gilo.wc.adapter;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import me.gilo.wc.R;
|
||||
import me.gilo.wc.adapter.viewholder.MenuViewHolder;
|
||||
import me.gilo.wc.adapter.viewholder.ProductViewHolder;
|
||||
import me.gilo.woodroid.models.Product;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProductAdapter extends RecyclerView.Adapter<ProductViewHolder> {
|
||||
private List<Product> products;
|
||||
|
||||
public ProductAdapter(List<Product> products) {
|
||||
this.products = products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new ProductViewHolder(parent.getContext(), LayoutInflater.from(parent.getContext()).inflate(R.layout.single_product_item, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ProductViewHolder holder, int position) {
|
||||
holder.renderView(products.get(position));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return products.size() == 0 ? 0 : products.size();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package me.gilo.wc.adapter.viewholder;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import me.gilo.wc.R;
|
||||
import me.gilo.wc.ui.CouponActivity;
|
||||
import me.gilo.wc.ui.ShopActivity;
|
||||
|
||||
public class MenuViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
View itemView;
|
||||
Context context;
|
||||
|
||||
public MenuViewHolder(Context context, View itemView) {
|
||||
super(itemView);
|
||||
|
||||
this.itemView = itemView;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void renderView(String title) {
|
||||
TextView tvTitle = itemView.findViewById(R.id.tvTitle);
|
||||
tvTitle.setText(title);
|
||||
|
||||
tvTitle.setOnClickListener(view -> startActivity(title));
|
||||
}
|
||||
|
||||
private void startActivity(String title) {
|
||||
Intent intent;
|
||||
|
||||
switch (title){
|
||||
case "Products":
|
||||
intent = new Intent(context, ShopActivity.class);
|
||||
context.startActivity(intent);
|
||||
break;
|
||||
case "Coupons":
|
||||
intent = new Intent(context, CouponActivity.class);
|
||||
context.startActivity(intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package me.gilo.wc.adapter.viewholder
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.text.Html
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.squareup.picasso.Picasso
|
||||
import me.gilo.wc.R
|
||||
import me.gilo.wc.ui.CouponActivity
|
||||
import me.gilo.wc.ui.ShopActivity
|
||||
import me.gilo.woodroid.models.Product
|
||||
|
||||
class ProductViewHolder(val context: Context, itemView: View) :
|
||||
RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
fun renderView(product: Product) {
|
||||
val ivImage = itemView.findViewById<ImageView>(R.id.ivImage)
|
||||
val tvTitle = itemView.findViewById<TextView>(R.id.tvTitle)
|
||||
val tvDescription = itemView.findViewById<TextView>(R.id.tvDescription)
|
||||
val tvCallToAction = itemView.findViewById<TextView>(R.id.tvCallToAction)
|
||||
|
||||
tvTitle.text = product.name
|
||||
tvDescription.text = Html.fromHtml(product.description)
|
||||
tvCallToAction.text = Html.fromHtml(product.price_html)
|
||||
|
||||
if (product.images != null && product.images.isNotEmpty()){
|
||||
Picasso.with(context).load(product.images[0].src).into(ivImage)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
23
app/src/main/java/me/gilo/wc/ui/BaseActivity.kt
Normal file
23
app/src/main/java/me/gilo/wc/ui/BaseActivity.kt
Normal file
@ -0,0 +1,23 @@
|
||||
package me.gilo.wc.ui
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import io.github.inflationx.viewpump.ViewPumpContextWrapper
|
||||
import me.gilo.wc.R
|
||||
|
||||
import kotlinx.android.synthetic.main.activity_menu.*
|
||||
import kotlinx.android.synthetic.main.content_menu.*
|
||||
import me.gilo.wc.adapter.MenuAdapter
|
||||
import java.util.ArrayList
|
||||
|
||||
open class BaseActivity : AppCompatActivity() {
|
||||
|
||||
override fun attachBaseContext(newBase: Context) {
|
||||
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase))
|
||||
}
|
||||
}
|
||||
21
app/src/main/java/me/gilo/wc/ui/CouponActivity.kt
Normal file
21
app/src/main/java/me/gilo/wc/ui/CouponActivity.kt
Normal file
@ -0,0 +1,21 @@
|
||||
package me.gilo.wc.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import me.gilo.wc.R
|
||||
|
||||
import kotlinx.android.synthetic.main.activity_coupon.*
|
||||
|
||||
class CouponActivity : BaseActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_coupon)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
title = "Coupon"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
38
app/src/main/java/me/gilo/wc/ui/MenuActivity.kt
Normal file
38
app/src/main/java/me/gilo/wc/ui/MenuActivity.kt
Normal file
@ -0,0 +1,38 @@
|
||||
package me.gilo.wc.ui
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import me.gilo.wc.R
|
||||
|
||||
import kotlinx.android.synthetic.main.activity_menu.*
|
||||
import kotlinx.android.synthetic.main.content_menu.*
|
||||
import me.gilo.wc.adapter.MenuAdapter
|
||||
import java.util.ArrayList
|
||||
|
||||
class MenuActivity : BaseActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_menu)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
title = "Menu"
|
||||
|
||||
val layoutManager = LinearLayoutManager(baseContext, LinearLayoutManager.VERTICAL, false)
|
||||
rvMenu.layoutManager = layoutManager
|
||||
rvMenu.isNestedScrollingEnabled = false
|
||||
|
||||
var titles = ArrayList<String>()
|
||||
titles.add("Products")
|
||||
titles.add("Coupons")
|
||||
|
||||
var adapter = MenuAdapter(titles)
|
||||
rvMenu.adapter = adapter
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
75
app/src/main/java/me/gilo/wc/ui/ShopActivity.kt
Normal file
75
app/src/main/java/me/gilo/wc/ui/ShopActivity.kt
Normal file
@ -0,0 +1,75 @@
|
||||
package me.gilo.wc.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.GridLayoutManager
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import me.gilo.wc.R
|
||||
|
||||
import kotlinx.android.synthetic.main.activity_shop.*
|
||||
import kotlinx.android.synthetic.main.content_menu.*
|
||||
import kotlinx.android.synthetic.main.content_shop.*
|
||||
import me.gilo.wc.adapter.MenuAdapter
|
||||
import me.gilo.wc.adapter.ProductAdapter
|
||||
import me.gilo.woodroid.Woocommerce
|
||||
import me.gilo.woodroid.models.Product
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
import java.util.ArrayList
|
||||
|
||||
class ShopActivity : BaseActivity() {
|
||||
|
||||
lateinit var adapter : ProductAdapter
|
||||
lateinit var products: ArrayList<Product>
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_shop)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
title = "Shop"
|
||||
|
||||
val layoutManager = GridLayoutManager(baseContext, 2)
|
||||
rvShop.layoutManager = layoutManager
|
||||
rvShop.isNestedScrollingEnabled = false
|
||||
|
||||
products = ArrayList<Product>()
|
||||
|
||||
adapter = ProductAdapter(products)
|
||||
rvShop.adapter = adapter
|
||||
|
||||
products()
|
||||
|
||||
}
|
||||
|
||||
//Not best practise, but works for purposes of demo
|
||||
private fun products() {
|
||||
val woocommerce = Woocommerce.Builder()
|
||||
.setSiteUrl("http://157.230.131.179")
|
||||
.setApiVersion("2")
|
||||
.setConsumerKey("ck_26c61abd7eeff238d87dc56585bf26cb2d1a1ec3")
|
||||
.setConsumerSecret("cs_062e8e3a7ae0ce08fdebc0c39f8f834d5e87598e")
|
||||
.build()
|
||||
|
||||
woocommerce.products.enqueue(object : Callback<ArrayList<Product>> {
|
||||
override fun onResponse(call: Call<ArrayList<Product>>, response: Response<ArrayList<Product>>) {
|
||||
val productsResponse = response.body()
|
||||
for (product in productsResponse!!) {
|
||||
products.add(product)
|
||||
}
|
||||
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<ArrayList<Product>>, t: Throwable) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,71 +0,0 @@
|
||||
package me.gilo.wc_app
|
||||
|
||||
import android.arch.lifecycle.Observer
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import me.gilo.woodroid.Woocommerce
|
||||
import me.gilo.woodroid.Woocommerce.Builder
|
||||
import me.gilo.woodroid.callback.Status
|
||||
import me.gilo.woodroid.models.Coupon
|
||||
import me.gilo.woodroid.models.Product
|
||||
import java.util.ArrayList
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
val TAG = "MainActivity";
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
val woocommerce = Woocommerce.Builder()
|
||||
.setSiteUrl("http://157.230.131.179")
|
||||
.setApiVersion("2")
|
||||
.setConsumerKey("ck_26c61abd7eeff238d87dc56585bf26cb2d1a1ec3")
|
||||
.setConsumerSecret("cs_062e8e3a7ae0ce08fdebc0c39f8f834d5e87598e")
|
||||
.build()
|
||||
|
||||
// tvText.append("\n")
|
||||
// tvText.append("\n")
|
||||
// tvText.append("Products")
|
||||
// tvText.append("\n")
|
||||
// tvText.append("\n")
|
||||
//
|
||||
// woocommerce.products.enqueue(object : Callback<ArrayList<Product>> {
|
||||
// override fun onResponse(call: Call<ArrayList<Product>>, response: Response<ArrayList<Product>>) {
|
||||
// val products = response.body()
|
||||
// for (product in products!!) {
|
||||
// tvText.append(product.title + "\n")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onFailure(call: Call<ArrayList<Product>>, t: Throwable) {
|
||||
//
|
||||
// }
|
||||
// })
|
||||
//
|
||||
// tvText.append("\n")
|
||||
// tvText.append("\n")
|
||||
// tvText.append("Coupons")
|
||||
// tvText.append("\n")
|
||||
// tvText.append("\n")
|
||||
|
||||
woocommerce.Coupon().coupons().enqueue(object : Callback<List<Coupon>> {
|
||||
override fun onResponse(call: Call<List<Coupon>>, response: Response<List<Coupon>>) {
|
||||
val coupons = response.body()
|
||||
for (coupon in coupons!!) {
|
||||
tvText.append(coupon.description + "\n")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<List<Coupon>>, t: Throwable) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
package me.gilo.wc_app.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import me.gilo.wc_app.R
|
||||
|
||||
import kotlinx.android.synthetic.main.activity_shop.*
|
||||
|
||||
class ShopActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_shop)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
fab.setOnClickListener { view ->
|
||||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
12
app/src/main/res/drawable/rect_white.xml
Normal file
12
app/src/main/res/drawable/rect_white.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners
|
||||
android:radius="4dp"
|
||||
/>
|
||||
|
||||
<solid android:color="#fdfdfd"/>
|
||||
|
||||
</shape>
|
||||
26
app/src/main/res/layout/activity_coupon.xml
Normal file
26
app/src/main/res/layout/activity_coupon.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
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"
|
||||
tools:context=".ui.CouponActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_coupon"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
27
app/src/main/res/layout/activity_menu.xml
Normal file
27
app/src/main/res/layout/activity_menu.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
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"
|
||||
tools:context=".ui.MenuActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_menu"/>
|
||||
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
@ -23,12 +23,4 @@
|
||||
|
||||
<include layout="@layout/content_shop"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:srcCompat="@android:drawable/ic_dialog_email"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
12
app/src/main/res/layout/content_coupon.xml
Normal file
12
app/src/main/res/layout/content_coupon.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:showIn="@layout/activity_coupon"
|
||||
tools:context=".ui.CouponActivity">
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
19
app/src/main/res/layout/content_menu.xml
Normal file
19
app/src/main/res/layout/content_menu.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:showIn="@layout/activity_menu"
|
||||
android:background="@color/bg"
|
||||
tools:context=".ui.MenuActivity">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/rvMenu"
|
||||
></android.support.v7.widget.RecyclerView>
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@ -9,9 +9,12 @@
|
||||
tools:showIn="@layout/activity_shop"
|
||||
tools:context=".ui.ShopActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:id="@+id/rvShop"
|
||||
></android.support.v7.widget.RecyclerView>
|
||||
|
||||
</LinearLayout>
|
||||
28
app/src/main/res/layout/single_menu_item.xml
Normal file
28
app/src/main/res/layout/single_menu_item.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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="wrap_content"
|
||||
tools:ignore="MissingPrefix"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTitle"
|
||||
fontPath="@string/font_regular"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:text="Ada Lovelace"
|
||||
android:textColor="@color/text_black_4"
|
||||
android:textSize="18sp"
|
||||
/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#d3d3d3"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
64
app/src/main/res/layout/single_product_item.xml
Normal file
64
app/src/main/res/layout/single_product_item.xml
Normal file
@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@drawable/rect_white"
|
||||
android:elevation="2dp"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="MissingPrefix">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivImage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
android:scaleType="centerCrop"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTitle"
|
||||
fontPath="@string/font_medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:gravity="left"
|
||||
android:textColor="@color/text"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDescription"
|
||||
fontPath="@string/font_regular"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:gravity="left"
|
||||
android:maxLines="2"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:textColor="@color/text_black_5"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCallToAction"
|
||||
fontPath="@string/font_regular"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginRight="0dp"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:gravity="left"
|
||||
android:padding="16dp"
|
||||
android:textColor="#1c5c9a"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@ -1,6 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#008577</color>
|
||||
<color name="colorPrimaryDark">#00574B</color>
|
||||
<color name="colorAccent">#D81B60</color>
|
||||
<color name="colorPrimary">#3781ee</color>
|
||||
<color name="colorPrimaryDark">#2e6dca</color>
|
||||
<color name="colorAccent">#3681ee</color>
|
||||
|
||||
<color name="bg">#e9ebf0</color>
|
||||
|
||||
<color name="text_white">#ffffff</color>
|
||||
<color name="text">#2a2f35</color>
|
||||
<color name="text_black_2">#2a2f35</color>
|
||||
<color name="text_black_4">#474d59</color>
|
||||
<color name="text_black_5">#5e6573</color>
|
||||
<color name="text_black_9">#949aa6</color>
|
||||
|
||||
</resources>
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
</resources>
|
||||
|
||||
@ -1,4 +1,12 @@
|
||||
<resources>
|
||||
<string name="app_name">wc-app</string>
|
||||
<string name="title_activity_shop">ShopActivity</string>
|
||||
<string name="app_name">wc-app</string>
|
||||
<string name="title_activity_shop">ShopActivity</string>
|
||||
<string name="title_activity_coupon">CouponActivity</string>
|
||||
<string name="title_activity_menu">MenuActivity</string>
|
||||
|
||||
|
||||
<string name="font_bold">fonts/GT-America-Bold.otf</string>
|
||||
<string name="font_medium">fonts/GT-America-Medium.otf</string>
|
||||
<string name="font_regular">fonts/GT-America-Regular.otf</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@ -1,17 +1,20 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
||||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
|
||||
|
||||
</resources>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package me.gilo.wc_app
|
||||
package me.gilo.wc
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
BIN
screens/screenshot-1549248597583.jpg
Normal file
BIN
screens/screenshot-1549248597583.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 713 KiB |
Loading…
Reference in New Issue
Block a user