Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
frendyxzc committed Sep 4, 2017
1 parent e7d195f commit 6c6db6d
Show file tree
Hide file tree
Showing 39 changed files with 1,930 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
.idea
/local.properties
.DS_Store
/build
/captures
.externalNativeBuild
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
38 changes: 38 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "vip.frendy.demosnack"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

compile project(':snackbar')
}
repositories {
mavenCentral()
}
25 changes: 25 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\iiMedia\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package vip.frendy.demosnack;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("vip.frendy.demosnack", appContext.getPackageName());
}
}
21 changes: 21 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="vip.frendy.demosnack" >

<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" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
86 changes: 86 additions & 0 deletions app/src/main/java/vip/frendy/demosnack/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package vip.frendy.demosnack

import android.graphics.Color
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.view.View
import android.widget.TextView
import kotlinx.android.synthetic.main.activity_main.*
import vip.frendy.snackbar.Snackbar

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

button_example_1.setOnClickListener {
val snackbar = Snackbar.make(relative_layout_main, "Hello from SnackBar 1", Snackbar.LENGTH_LONG)
val snackbarView = snackbar.getView()
snackbarView.setBackgroundColor(Color.parseColor("#4cef5350"))
snackbar.show()
}


button_example_2.setOnClickListener {
val snackbar = Snackbar
.make(relative_layout_main, "Had a snack at Snackbar", Snackbar.LENGTH_LONG)
.setAction("Undo", View.OnClickListener { Log.d("Action Button", "onClick triggered") })
snackbar.setActionTextColor(Color.LTGRAY)
snackbar.addIcon(R.mipmap.ic_core, 200)
val snackbarView = snackbar.getView()
snackbarView.setBackgroundColor(Color.parseColor("#555555"))
(snackbarView.findViewById(R.id.snackbar_text) as TextView).setTextColor(Color.WHITE)
snackbar.show()
}


button_example_3.setOnClickListener {
val snackbar = Snackbar
.make(relative_layout_main, "Had a snack at Snackbar", Snackbar.LENGTH_LONG)
.setAction("Action", View.OnClickListener { Log.d("CLICKED Action", "CLIDKED Action") })
snackbar.setActionTextColor(Color.WHITE)
val snackbarView = snackbar.getView()
snackbarView.setBackgroundColor(Color.parseColor("#0000CC"))
(snackbarView.findViewById(R.id.snackbar_text) as TextView).setTextColor(Color.WHITE)
snackbar.show()
}


button_example_4.setOnClickListener {
val snackbar = Snackbar
.make(relative_layout_main, "Had a snack at Snackbar Had a snack at Snackbar Had a snack at Snackbar Had a snack at Snackbar Had a snack at Snackbar Had a snack at Snackbar", Snackbar.LENGTH_LONG)
snackbar.setActionTextColor(Color.WHITE)
val snackbarView = snackbar.getView()
snackbarView.setBackgroundColor(Color.parseColor("#CC00CC"))
(snackbarView.findViewById(R.id.snackbar_text) as TextView).setTextColor(Color.YELLOW)
snackbar.show()
}

button_example_5.setOnClickListener {
val snackbar = Snackbar
.make(relative_layout_main, "Snacking with VectorDrawable", Snackbar.LENGTH_LONG)
snackbar.setActionTextColor(Color.WHITE)
snackbar.setIconLeft(R.drawable.ic_android_green_24dp, 24F)
val snackbarView = snackbar.getView()
snackbarView.setBackgroundColor(Color.parseColor("#CC00CC"))
(snackbarView.findViewById(R.id.snackbar_text) as TextView).setTextColor(Color.YELLOW)
snackbar.show()
}

button_example_6.setOnClickListener {
val snackbar = Snackbar
.make(relative_layout_main, "Snacking Left & Right", Snackbar.LENGTH_LONG)
snackbar.setActionTextColor(Color.WHITE)
snackbar.setIconLeft(R.mipmap.ic_core, 24F) //Size in dp - 24 is great!
snackbar.setIconRight(R.drawable.ic_android_green_24dp, 48F) //Resize to bigger dp
snackbar.setIconPadding(8)
snackbar.setMaxWidth(3000)
val snackbarView = snackbar.getView()
snackbarView.setBackgroundColor(Color.parseColor("#CC00CC"))
(snackbarView.findViewById(R.id.snackbar_text) as TextView).setTextColor(Color.YELLOW)
snackbar.show()
}
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_android_green_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFA4C639"
android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71 -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"/>
</vector>
109 changes: 109 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?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:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">


<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">


<RelativeLayout
android:layout_width="match_parent"
android:id="@+id/relative_layout_main"
android:layout_height="match_parent">

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:gravity="bottom"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">

<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="example 1"
android:id="@+id/button_example_1"
android:layout_weight="1" />

<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="example 2"
android:id="@+id/button_example_2"
android:layout_weight="1" />
</LinearLayout>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:gravity="bottom"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">

<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="example 3"
android:id="@+id/button_example_3"
android:layout_weight="1" />

<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="example 4"
android:id="@+id/button_example_4"
android:layout_weight="1" />
</LinearLayout>


<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:gravity="bottom"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">

<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Vector Icon"
android:id="@+id/button_example_5"
android:layout_weight="1" />

<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Icon Left &amp; Right"
android:id="@+id/button_example_6"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>

</RelativeLayout>

</LinearLayout>

</android.support.design.widget.CoordinatorLayout>
Binary file added app/src/main/res/mipmap-xhdpi/ic_core.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">demoSnack</string>
</resources>
11 changes: 11 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<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>

</resources>
17 changes: 17 additions & 0 deletions app/src/test/java/vip/frendy/demosnack/ExampleUnitTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package vip.frendy.demosnack;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
Loading

0 comments on commit 6c6db6d

Please sign in to comment.