diff --git a/README.md b/README.md new file mode 100644 index 0000000..e467a86 --- /dev/null +++ b/README.md @@ -0,0 +1,122 @@ +# AmazingAvatar + +An android amazing avatar anim in CollapsingToolbarLayout. + +## Screenshot + + +### Expanded + +### Collapsed + + +# Usage + +Just Clone and Build. + +# Customization + +You can change header view to what you want. +```xml + + + + + + + + + + + + + + + + + + +``` + +## Compatibility + +Android GINGERBREAD 4.1+ + +## Credits + +Avatars from [maximedegreve/TinyFaces](https://github.com/maximedegreve/TinyFaces). + +### Let me know! + +I'd be really happy if you sent me links to your projects where you use my component. Just send an email to hear.silent1995@gmail.com And do let me know if you have any questions or suggestion regarding the example. + +## License + + MIT License + + Copyright (c) 2017 HearSilent + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..50c5ec1 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 25 + buildToolsVersion "25.0.2" + defaultConfig { + applicationId "hearsilent.amazingavatar" + minSdkVersion 16 + targetSdkVersion 25 + versionCode 100 + versionName "1.0.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.2.0' + compile 'com.android.support:recyclerview-v7:25.2.0' + compile 'com.android.support:design:25.2.0' + compile 'de.hdodenhof:circleimageview:2.1.0' + compile 'com.loopj.android:android-async-http:1.4.9' + compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' + testCompile 'junit:junit:4.12' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..3d12b3d --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in D:\Program\AndroidSDK/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 diff --git a/app/src/androidTest/java/hearsilent/amazingavatar/ExampleInstrumentedTest.java b/app/src/androidTest/java/hearsilent/amazingavatar/ExampleInstrumentedTest.java new file mode 100644 index 0000000..799b814 --- /dev/null +++ b/app/src/androidTest/java/hearsilent/amazingavatar/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package hearsilent.amazingavatar; + +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 Testing documentation + */ +@RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { + + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("hearsilent.amazingavatar", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..ce1f6d1 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/hearsilent/amazingavatar/MainActivity.java b/app/src/main/java/hearsilent/amazingavatar/MainActivity.java new file mode 100644 index 0000000..7b1590c --- /dev/null +++ b/app/src/main/java/hearsilent/amazingavatar/MainActivity.java @@ -0,0 +1,177 @@ +package hearsilent.amazingavatar; + +import android.os.Bundle; +import android.support.design.widget.AppBarLayout; +import android.support.v4.widget.Space; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.DefaultItemAnimator; +import android.support.v7.widget.DividerItemDecoration; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.util.TypedValue; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.nostra13.universalimageloader.core.ImageLoader; + +import java.util.Locale; + +import de.hdodenhof.circleimageview.CircleImageView; +import hearsilent.amazingavatar.callbacks.AvatarCallback; +import hearsilent.amazingavatar.libs.AppBarStateChangeListener; +import hearsilent.amazingavatar.libs.NetworkHelper; +import hearsilent.amazingavatar.libs.Utils; +import hearsilent.amazingavatar.models.AvatarModel; + +import static hearsilent.amazingavatar.R.id.recyclerView; + +public class MainActivity extends AppCompatActivity { + + private final static float EXPAND_AVATAR_SIZE_DP = 80f; + private final static float COLLAPSED_AVATAR_SIZE_DP = 32f; + + private AppBarLayout mAppBarLayout; + private CircleImageView mAvatarImageView; + private TextView mToolbarTextView, mTitleTextView; + private Space mSpace; + private Toolbar mToolBar; + + private RecyclerView mRecyclerView; + + private int[] mAvatarPoint = new int[2], mSpacePoint = new int[2], mToolbarTextPoint = + new int[2], mTitleTextViewPoint = new int[2]; + private float mTitleTextSize; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + findViews(); + setUpViews(); + fetchAvatar(); + } + + private void findViews() { + mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar); + mAvatarImageView = (CircleImageView) findViewById(R.id.imageView_avatar); + mToolbarTextView = (TextView) findViewById(R.id.toolbar_title); + mTitleTextView = (TextView) findViewById(R.id.textView_title); + mSpace = (Space) findViewById(R.id.space); + mToolBar = (Toolbar) findViewById(R.id.toolbar); + mRecyclerView = (RecyclerView) findViewById(recyclerView); + } + + private void setUpViews() { + mTitleTextSize = mTitleTextView.getTextSize(); + setUpToolbar(); + setUpRecyclerView(); + setUpAmazingAvatar(); + } + + private void setUpRecyclerView() { + mRecyclerView.setHasFixedSize(true); + mRecyclerView.setItemAnimator(new DefaultItemAnimator()); + mRecyclerView + .addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); + mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); + mRecyclerView.setAdapter(new Adapter()); + } + + private void setUpToolbar() { + setSupportActionBar(mToolBar); + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayShowTitleEnabled(false); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } + } + + private void setUpAmazingAvatar() { + mAppBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() { + + @Override + public void onStateChanged(AppBarLayout appBarLayout, + AppBarStateChangeListener.State state) { + } + + @Override + public void onOffsetChanged(AppBarStateChangeListener.State state, float offset) { + float xOffset = -(mAvatarPoint[0] - mSpacePoint[0]) * offset; + float yOffset = -(mAvatarPoint[1] - mSpacePoint[1]) * offset; + float xTitleOffset = -(mTitleTextViewPoint[0] - mToolbarTextPoint[0]) * offset; + float yTitleOffset = -(mTitleTextViewPoint[1] - mToolbarTextPoint[1]) * offset; + int newSize = Utils.convertDpToPixelSize(EXPAND_AVATAR_SIZE_DP - + (EXPAND_AVATAR_SIZE_DP - COLLAPSED_AVATAR_SIZE_DP) * offset, MainActivity + .this); + float newTextSize = + mTitleTextSize - (mTitleTextSize - mToolbarTextView.getTextSize()) * offset; + mAvatarImageView.getLayoutParams().width = newSize; + mAvatarImageView.getLayoutParams().height = newSize; + mAvatarImageView.setTranslationX(xOffset); + mAvatarImageView.setTranslationY(yOffset); + mTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, newTextSize); + mTitleTextView.setTranslationX(xTitleOffset); + mTitleTextView.setTranslationY(yTitleOffset); + } + }); + } + + /** + * Avatar from TinyFaces (https://github.com/maximedegreve/TinyFaces) + */ + private void fetchAvatar() { + NetworkHelper.getAvatar(new AvatarCallback() { + + @Override + public void onSuccess(AvatarModel avatarModel) { + super.onSuccess(avatarModel); + ImageLoader.getInstance().displayImage(avatarModel.url, mAvatarImageView); + } + }); + } + + @Override + public void onWindowFocusChanged(boolean hasFocus) { + super.onWindowFocusChanged(hasFocus); + + mAvatarImageView.getLocationOnScreen(mAvatarPoint); + mSpace.getLocationOnScreen(mSpacePoint); + mToolbarTextView.getLocationOnScreen(mToolbarTextPoint); + mToolbarTextPoint[0] += Utils.convertDpToPixelSize(COLLAPSED_AVATAR_SIZE_DP, this); + mTitleTextView.getLocationOnScreen(mTitleTextViewPoint); + } + + private class Adapter extends RecyclerView.Adapter { + + private class DemoViewHolder extends RecyclerView.ViewHolder { + + private TextView textView; + + private DemoViewHolder(View view) { + super(view); + + textView = (TextView) view.findViewById(R.id.textView); + } + } + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + return new DemoViewHolder(LayoutInflater.from(parent.getContext()) + .inflate(R.layout.item_demo, parent, false)); + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + ((DemoViewHolder) holder).textView + .setText(String.format(Locale.getDefault(), "HearSilent %d", position)); + } + + @Override + public int getItemCount() { + return 100; + } + } +} diff --git a/app/src/main/java/hearsilent/amazingavatar/base/BaseApplication.java b/app/src/main/java/hearsilent/amazingavatar/base/BaseApplication.java new file mode 100644 index 0000000..1aaca7c --- /dev/null +++ b/app/src/main/java/hearsilent/amazingavatar/base/BaseApplication.java @@ -0,0 +1,44 @@ +package hearsilent.amazingavatar.base; + +import android.app.Application; +import android.content.Context; +import android.os.StrictMode; + +import com.nostra13.universalimageloader.core.ImageLoader; +import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; + +import hearsilent.amazingavatar.BuildConfig; + +public class BaseApplication extends Application { + + @Override + public void onCreate() { + super.onCreate(); + + if (BuildConfig.DEBUG) { + enableStrictMode(); + } + + initImageLoader(this); + } + + private static void initImageLoader(Context context) { + ImageLoaderConfiguration config = + new ImageLoaderConfiguration.Builder(context).threadPoolSize(5).build(); + + ImageLoader.getInstance().init(config); + } + + private void enableStrictMode() { + StrictMode.setThreadPolicy( + new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites() + .detectNetwork().penaltyLog().build()); + StrictMode.setVmPolicy( + new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().penaltyLog() + .penaltyDeath().build()); + } + + public BaseApplication() { + super(); + } +} \ No newline at end of file diff --git a/app/src/main/java/hearsilent/amazingavatar/callbacks/AvatarCallback.java b/app/src/main/java/hearsilent/amazingavatar/callbacks/AvatarCallback.java new file mode 100644 index 0000000..570cd86 --- /dev/null +++ b/app/src/main/java/hearsilent/amazingavatar/callbacks/AvatarCallback.java @@ -0,0 +1,15 @@ +package hearsilent.amazingavatar.callbacks; + +import hearsilent.amazingavatar.models.AvatarModel; + +public class AvatarCallback { + + public void onSuccess(AvatarModel avatarModel) { + } + + public void onFail(String errorMessage) { + } + + public void onFail() { + } +} \ No newline at end of file diff --git a/app/src/main/java/hearsilent/amazingavatar/libs/AppBarStateChangeListener.java b/app/src/main/java/hearsilent/amazingavatar/libs/AppBarStateChangeListener.java new file mode 100644 index 0000000..a0c8440 --- /dev/null +++ b/app/src/main/java/hearsilent/amazingavatar/libs/AppBarStateChangeListener.java @@ -0,0 +1,43 @@ +package hearsilent.amazingavatar.libs; + +import android.support.design.widget.AppBarLayout; + +public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener { + + public enum State { + EXPANDED, + COLLAPSED, + IDLE + } + + private State mCurrentState = State.IDLE; + + @Override + public final void onOffsetChanged(AppBarLayout appBarLayout, int i) { + if (i == 0) { + if (mCurrentState != State.EXPANDED) { + onStateChanged(appBarLayout, State.EXPANDED); + } + mCurrentState = State.EXPANDED; + } else if (Math.abs(i) >= appBarLayout.getTotalScrollRange()) { + if (mCurrentState != State.COLLAPSED) { + onStateChanged(appBarLayout, State.COLLAPSED); + } + mCurrentState = State.COLLAPSED; + } else { + if (mCurrentState != State.IDLE) { + onStateChanged(appBarLayout, State.IDLE); + } + mCurrentState = State.IDLE; + } + onOffsetChanged(mCurrentState, Math.abs(i / (float) appBarLayout.getTotalScrollRange())); + } + + public State getCurrentState() { + return mCurrentState; + } + + public abstract void onStateChanged(AppBarLayout appBarLayout, State state); + + public abstract void onOffsetChanged(State state, float offset); +} \ No newline at end of file diff --git a/app/src/main/java/hearsilent/amazingavatar/libs/FlingBehavior.java b/app/src/main/java/hearsilent/amazingavatar/libs/FlingBehavior.java new file mode 100644 index 0000000..3921aa9 --- /dev/null +++ b/app/src/main/java/hearsilent/amazingavatar/libs/FlingBehavior.java @@ -0,0 +1,44 @@ +package hearsilent.amazingavatar.libs; + +import android.content.Context; +import android.support.design.widget.AppBarLayout; +import android.support.design.widget.CoordinatorLayout; +import android.support.v7.widget.RecyclerView; +import android.util.AttributeSet; +import android.view.View; + +public final class FlingBehavior extends AppBarLayout.Behavior { + + private static final int TOP_CHILD_FLING_THRESHOLD = 3; + private boolean isPositive; + + public FlingBehavior() { + } + + public FlingBehavior(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, + View target, float velocityX, float velocityY, boolean consumed) { + if (velocityY > 0 && !isPositive || velocityY < 0 && isPositive) { + velocityY = velocityY * -1; + } + if (target instanceof RecyclerView && velocityY < 0) { + final RecyclerView recyclerView = (RecyclerView) target; + final View firstChild = recyclerView.getChildAt(0); + final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild); + consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD; + } + return super + .onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed); + } + + @Override + public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, + View target, int dx, int dy, int[] consumed) { + super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed); + isPositive = dy > 0; + } +} \ No newline at end of file diff --git a/app/src/main/java/hearsilent/amazingavatar/libs/NetworkHelper.java b/app/src/main/java/hearsilent/amazingavatar/libs/NetworkHelper.java new file mode 100644 index 0000000..5a344f6 --- /dev/null +++ b/app/src/main/java/hearsilent/amazingavatar/libs/NetworkHelper.java @@ -0,0 +1,65 @@ +package hearsilent.amazingavatar.libs; + +import android.support.annotation.NonNull; + +import com.loopj.android.http.AsyncHttpClient; +import com.loopj.android.http.JsonHttpResponseHandler; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import cz.msebera.android.httpclient.Header; +import hearsilent.amazingavatar.callbacks.AvatarCallback; +import hearsilent.amazingavatar.models.AvatarModel; + +public class NetworkHelper { + + private static AsyncHttpClient mClient = null; + + private static AsyncHttpClient init() { + AsyncHttpClient client = new AsyncHttpClient(); + client.addHeader("Connection", "Keep-Alive"); + client.setEnableRedirects(true, true, true); + + client.setTimeout(8 * 1000); + return client; + } + + private static AsyncHttpClient getClient() { + if (mClient == null) { + mClient = init(); + } + return mClient; + } + + private static final String AVATAR_URL = "https://tinyfac.es/api/users"; + + public static void getAvatar(@NonNull final AvatarCallback callback) { + AsyncHttpClient client = getClient(); + + client.get(AVATAR_URL, new JsonHttpResponseHandler() { + + @Override + public void onSuccess(int statusCode, Header[] headers, JSONArray response) { + super.onSuccess(statusCode, headers, response); + if (statusCode != 200) { + callback.onFail(); + } else { + try { + JSONObject jsonObject = response.getJSONObject(0); + AvatarModel model = new AvatarModel(); + model.url = jsonObject.getJSONArray("avatars").getJSONObject(0) + .getString("url"); + model.firstName = jsonObject.getString("first_name"); + model.lastName = jsonObject.getString("last_name"); + callback.onSuccess(model); + } catch (JSONException ignore) { + callback.onFail(); + } + } + } + }); + } + +} diff --git a/app/src/main/java/hearsilent/amazingavatar/libs/Utils.java b/app/src/main/java/hearsilent/amazingavatar/libs/Utils.java new file mode 100644 index 0000000..082a58a --- /dev/null +++ b/app/src/main/java/hearsilent/amazingavatar/libs/Utils.java @@ -0,0 +1,31 @@ +package hearsilent.amazingavatar.libs; + +import android.content.Context; +import android.content.res.Resources; +import android.util.DisplayMetrics; + +public class Utils { + + public static DisplayMetrics getDisplayMetrics(Context context) { + Resources resources = context.getResources(); + return resources.getDisplayMetrics(); + } + + public static float convertDpToPixel(float dp, Context context) { + return dp * (getDisplayMetrics(context).densityDpi / 160f); + } + + public static int convertDpToPixelSize(float dp, Context context) { + float pixels = convertDpToPixel(dp, context); + final int res = (int) (pixels + 0.5f); + if (res != 0) { + return res; + } else if (pixels == 0) { + return 0; + } else if (pixels > 0) { + return 1; + } + return -1; + } + +} diff --git a/app/src/main/java/hearsilent/amazingavatar/models/AvatarModel.java b/app/src/main/java/hearsilent/amazingavatar/models/AvatarModel.java new file mode 100644 index 0000000..d647635 --- /dev/null +++ b/app/src/main/java/hearsilent/amazingavatar/models/AvatarModel.java @@ -0,0 +1,8 @@ +package hearsilent.amazingavatar.models; + +public class AvatarModel { + + public String url; + public String firstName; + public String lastName; +} diff --git a/app/src/main/res/drawable/avatar_background.xml b/app/src/main/res/drawable/avatar_background.xml new file mode 100644 index 0000000..83c1290 --- /dev/null +++ b/app/src/main/res/drawable/avatar_background.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..738f19d --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_demo.xml b/app/src/main/res/layout/item_demo.xml new file mode 100644 index 0000000..cd917cc --- /dev/null +++ b/app/src/main/res/layout/item_demo.xml @@ -0,0 +1,11 @@ + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..9a078e3 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..efc028a Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..3af2608 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9bec2e6 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..aee44e1 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..34947cd Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..9865995 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #3F51B5 + #303F9F + #FF4081 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..aed9f5b --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + AmazingAvatar + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..8124c3c --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/app/src/test/java/hearsilent/amazingavatar/ExampleUnitTest.java b/app/src/test/java/hearsilent/amazingavatar/ExampleUnitTest.java new file mode 100644 index 0000000..37d462b --- /dev/null +++ b/app/src/test/java/hearsilent/amazingavatar/ExampleUnitTest.java @@ -0,0 +1,18 @@ +package hearsilent.amazingavatar; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..1ea4bd0 --- /dev/null +++ b/build.gradle @@ -0,0 +1,23 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.3.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..aac7c9b --- /dev/null +++ b/gradle.properties @@ -0,0 +1,17 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..13372ae Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..7ca2874 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Mar 08 14:56:05 GMT+08:00 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..9d82f78 --- /dev/null +++ b/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/screenshots/caf28b9c-42e8-40c7-a68e-7a069e4e9123.png b/screenshots/caf28b9c-42e8-40c7-a68e-7a069e4e9123.png new file mode 100644 index 0000000..0aa4d90 Binary files /dev/null and b/screenshots/caf28b9c-42e8-40c7-a68e-7a069e4e9123.png differ diff --git a/screenshots/fc2af320-da03-42ec-ac79-723ec75a3fad.png b/screenshots/fc2af320-da03-42ec-ac79-723ec75a3fad.png new file mode 100644 index 0000000..ad04065 Binary files /dev/null and b/screenshots/fc2af320-da03-42ec-ac79-723ec75a3fad.png differ diff --git a/screenshots/screenrecord.gif b/screenshots/screenrecord.gif new file mode 100644 index 0000000..5808c35 Binary files /dev/null and b/screenshots/screenrecord.gif differ diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app'