-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.2" | ||
|
||
defaultConfig { | ||
applicationId "com.Joker.smartdrawing" | ||
minSdkVersion 14 | ||
targetSdkVersion 23 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: ['*.jar'], dir: 'libs') | ||
testCompile 'junit:junit:4.12' | ||
compile 'com.android.support:appcompat-v7:23.1.1' | ||
compile 'com.android.support:appcompat-v7:23.1.1' | ||
compile 'com.jakewharton:butterknife:7.0.1' | ||
compile 'com.android.support:cardview-v7:23.1.1' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in E:\Android_AllSdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.Joker.smartdrawing; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.Joker.smartdrawing"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme.SplashStyle"> | ||
<activity android:name=".MainActivity" android:screenOrientation="portrait"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity android:name=".DrawingActivity" android:screenOrientation="portrait" | ||
android:theme="@style/AppTheme.DrawingStyle" | ||
/> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.Joker.smartdrawing; | ||
|
||
import android.graphics.drawable.Drawable; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.support.annotation.CallSuper; | ||
import android.support.annotation.ColorRes; | ||
import android.support.annotation.DrawableRes; | ||
import android.support.annotation.LayoutRes; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.AppCompatImageButton; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.KeyEvent; | ||
import android.view.MenuItem; | ||
import android.widget.TextView; | ||
import butterknife.Bind; | ||
import butterknife.ButterKnife; | ||
|
||
public abstract class BaseActivity extends AppCompatActivity { | ||
|
||
@Nullable @Bind(R.id.toolbar_layout_root) protected Toolbar toolbar; | ||
@Nullable @Bind(R.id.toolbar_layout_title_tv) protected TextView titleTv; | ||
|
||
@Override public void setContentView(@LayoutRes int layoutResID) { | ||
super.setContentView(layoutResID); | ||
getWindow().setBackgroundDrawable(null); | ||
ButterKnife.bind(BaseActivity.this); | ||
BaseActivity.this.bindView(); | ||
} | ||
|
||
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(getLayoutId()); | ||
} | ||
|
||
private void bindView() { | ||
setSupportActionBar(toolbar); | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) toolbar.setElevation(0.0f); | ||
BaseActivity.this.setupToolBar(); | ||
} | ||
|
||
@Override public boolean onOptionsItemSelected(MenuItem item) { | ||
switch (item.getItemId()) { | ||
case android.R.id.home: | ||
BaseActivity.this.exit(); | ||
return true; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { | ||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { | ||
BaseActivity.this.exit(); | ||
} | ||
return false; | ||
} | ||
|
||
protected void bindActionDrawable(@NonNull AppCompatImageButton actionView, @DrawableRes int drawable) { | ||
actionView.setImageDrawable(SomeCompat.getImageDrawable(BaseActivity.this, drawable)); | ||
} | ||
|
||
protected void polishDrawable(@NonNull Drawable drawable, @ColorRes int color) { | ||
SomeCompat.polishDrawable(BaseActivity.this, drawable, color); | ||
} | ||
|
||
protected void setNavigationIcon(@NonNull Toolbar toolbar, @DrawableRes int drawableId) { | ||
SomeCompat.setNavigationIcon(toolbar, BaseActivity.this, drawableId); | ||
} | ||
|
||
@CallSuper @Override protected void onDestroy() { | ||
super.onDestroy(); | ||
ButterKnife.unbind(BaseActivity.this); | ||
} | ||
|
||
protected abstract int getLayoutId(); | ||
|
||
protected abstract void setupToolBar(); | ||
|
||
protected abstract void exit(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.Joker.smartdrawing; | ||
|
||
import android.content.Intent; | ||
import android.graphics.Bitmap; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.AppCompatImageButton; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import butterknife.Bind; | ||
import com.Joker.smartdrawing.view.DrawingViewInflater; | ||
import com.Joker.smartdrawing.view.FingerViewInflater; | ||
import com.Joker.smartdrawing.view.SmartDrawingView; | ||
|
||
public class DrawingActivity extends BaseActivity implements View.OnClickListener { | ||
|
||
private static final String TAG = DrawingActivity.class.getSimpleName(); | ||
|
||
@Nullable @Bind(R.id.drawing_layout_smart_view) protected SmartDrawingView smartDrawingView; | ||
|
||
public static void navigateToDrawing(AppCompatActivity startingActivity) { | ||
Intent intent = new Intent(startingActivity, DrawingActivity.class); | ||
startingActivity.startActivity(intent); | ||
} | ||
|
||
@Override public boolean onCreateOptionsMenu(Menu menu) { | ||
getMenuInflater().inflate(R.menu.menu_main, menu); | ||
MenuItem menuItem = menu.findItem(R.id.action_inbox); | ||
menuItem.setActionView(R.layout.action_layout); | ||
|
||
FingerViewInflater.createdFingerInflater().setupFingerView(DrawingActivity.this); | ||
|
||
AppCompatImageButton actionView = (AppCompatImageButton) menuItem.getActionView(); | ||
|
||
actionView.setOnClickListener(DrawingActivity.this); | ||
DrawingActivity.this.bindActionDrawable(actionView, R.drawable.ic_touch_icon2); | ||
DrawingActivity.this.polishDrawable(actionView.getDrawable(), android.R.color.white); | ||
|
||
return true; | ||
} | ||
|
||
@Override protected int getLayoutId() { | ||
return R.layout.drawing_layout; | ||
} | ||
|
||
@Override protected void setupToolBar() { | ||
DrawingActivity.this.setNavigationIcon(toolbar, R.drawable.ic_arrow_back); | ||
DrawingActivity.this.polishDrawable(toolbar.getNavigationIcon(), android.R.color.white); | ||
} | ||
|
||
@Override protected void exit() { | ||
|
||
DrawingActivity.this.finish(); | ||
overridePendingTransition(R.anim.activity_open_scale, R.anim.activity_close_translate); | ||
} | ||
|
||
@Override public void onClick(View v) { | ||
|
||
if (smartDrawingView.isDrawingCacheEnabled()) { | ||
smartDrawingView.destroyDrawingCache(); | ||
} | ||
|
||
smartDrawingView.setDrawingCacheEnabled(true); | ||
Bitmap drawingCache = smartDrawingView.getDrawingCache(); | ||
|
||
DrawingViewInflater.createdDrawingInflater(DrawingActivity.this).setDrawable(drawingCache); | ||
} | ||
} |