diff --git a/.idea/gradle.xml b/.idea/gradle.xml index ed4b899..c500559 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -11,6 +11,7 @@ diff --git a/.idea/modules.xml b/.idea/modules.xml index ed3bd3f..c1e8557 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -4,6 +4,7 @@ + \ No newline at end of file diff --git a/clingapp/.gitignore b/clingapp/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/clingapp/.gitignore @@ -0,0 +1 @@ +/build diff --git a/clingapp/build.gradle b/clingapp/build.gradle new file mode 100644 index 0000000..92313c8 --- /dev/null +++ b/clingapp/build.gradle @@ -0,0 +1,26 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.3" + + defaultConfig { + applicationId "com.majeur.clingapp" + minSdkVersion 16 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + testCompile 'junit:junit:4.12' + compile project(':cling') +} diff --git a/clingapp/proguard-rules.pro b/clingapp/proguard-rules.pro new file mode 100644 index 0000000..8eec3f5 --- /dev/null +++ b/clingapp/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/pdroid/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 *; +#} diff --git a/clingapp/src/androidTest/java/com/majeur/clingapp/ApplicationTest.java b/clingapp/src/androidTest/java/com/majeur/clingapp/ApplicationTest.java new file mode 100644 index 0000000..8d5035f --- /dev/null +++ b/clingapp/src/androidTest/java/com/majeur/clingapp/ApplicationTest.java @@ -0,0 +1,13 @@ +package com.majeur.clingapp; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/clingapp/src/main/AndroidManifest.xml b/clingapp/src/main/AndroidManifest.xml new file mode 100644 index 0000000..ae48469 --- /dev/null +++ b/clingapp/src/main/AndroidManifest.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/clingapp/src/main/java/com/majeur/clingapp/DemoActivity.java b/clingapp/src/main/java/com/majeur/clingapp/DemoActivity.java new file mode 100644 index 0000000..d848292 --- /dev/null +++ b/clingapp/src/main/java/com/majeur/clingapp/DemoActivity.java @@ -0,0 +1,93 @@ +package com.majeur.clingapp; + +import android.app.Activity; +import android.os.Bundle; +import android.view.Menu; +import android.view.View; +import android.view.ViewGroup; + +import com.majeur.cling.ActionItemTarget; +import com.majeur.cling.Cling; +import com.majeur.cling.ClingManager; +import com.majeur.cling.ViewTarget; + +public class DemoActivity extends Activity implements View.OnClickListener { + + private ClingManager mClingManager; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_demo); + + mClingManager = new ClingManager(this); + + ViewGroup viewGroup = (ViewGroup) findViewById(R.id.button_container); + for (int i = 0; i < viewGroup.getChildCount(); i++) + viewGroup.getChildAt(i).setOnClickListener(this); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.demo, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public void onClick(View view) { + switch (view.getId()) { + case R.id.btn_1: + showClings(getNoTargetCling()); + break; + + case R.id.btn_2: + showClings(getViewTargetCling(view)); + break; + + case R.id.btn_3: + showClings(getActionViewTargetCling()); + break; + + case R.id.btn_4: + showClings(getNoTargetCling(), + getViewTargetCling(view), + getActionViewTargetCling()); + break; + } + } + + private void showClings(Cling... clings) { + mClingManager.stop(); + for (Cling cling : clings) + mClingManager.addCling(cling); + mClingManager.start(); + } + + Cling getNoTargetCling() { + return new Cling.Builder(this) + .setTitle("Welcome to this app") + .setContent("This application is meant to be the best app you will ever try on android.") + .build(); + } + + Cling getViewTargetCling(View view) { + return new Cling.Builder(this) + .setTitle(R.string.drawer_tutorial_title) + .setContent(R.string.drawer_tutorial_message) + .setMessageBackground(getResources().getColor(R.color.teal)) + .setTarget(new ViewTarget(view)) + .build(); + } + + Cling getActionViewTargetCling() { + return new Cling.Builder(this) + .setTitle("Here is another feature") + .setTitleTextAppearance(R.style.textAppearanceTitleNice) + .setContent("Look how amazing this feature is, blablabla blablabla bla bla.") + .setContentTextAppearance(R.style.textAppearanceContentNice) + .setTarget(new ActionItemTarget(this, R.id.action_share)) + .setClingColor(getResources().getColor(R.color.cling)) + .setMessageBackground(getResources().getColor(R.color.red)) + .build(); + } +} \ No newline at end of file diff --git a/clingapp/src/main/java/com/majeur/clingapp/FirstLaunchDemoActivity.java b/clingapp/src/main/java/com/majeur/clingapp/FirstLaunchDemoActivity.java new file mode 100644 index 0000000..db37c0d --- /dev/null +++ b/clingapp/src/main/java/com/majeur/clingapp/FirstLaunchDemoActivity.java @@ -0,0 +1,118 @@ +package com.majeur.clingapp; + +import android.app.Activity; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.view.Menu; +import android.view.View; +import android.widget.SlidingDrawer; + +import com.majeur.cling.ActionItemTarget; +import com.majeur.cling.Cling; +import com.majeur.cling.ClingManager; +import com.majeur.cling.ViewTarget; + +public class FirstLaunchDemoActivity extends Activity { + + private static final String START_TUTORIAL_KEY = "show_tutorial"; + + private SharedPreferences mSharedPreferences; + private ClingManager mClingManager; + + private SlidingDrawer mSlidingDrawer; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_firstlaunch_demo); + + mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); + mClingManager = new ClingManager(this); + + mSlidingDrawer = (SlidingDrawer) findViewById(R.id.drawer); + + findViewById(R.id.clear_preference).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + mSharedPreferences.edit() + .remove(START_TUTORIAL_KEY) + .apply(); + finish(); + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + + if (mSharedPreferences.getBoolean(START_TUTORIAL_KEY, true) + && (mClingManager == null || !mClingManager.isStarted())) { + + mClingManager = new ClingManager(this); + + // When no Target is set, Target.NONE is used + mClingManager.addCling(new Cling.Builder(this) + .setTitle("Welcome to this app") + .setContent("This application is meant to be the best app you will ever try on android.") + .build()); + + mClingManager.addCling(new Cling.Builder(this) + .setTitle(R.string.drawer_tutorial_title) + .setContent(R.string.drawer_tutorial_message) + .setMessageBackground(getResources().getColor(R.color.teal)) + .setTarget(new ViewTarget(this, R.id.button_container)) + .build()); + + mClingManager.addCling(new Cling.Builder(this) + .setTitle("Content sharing") + .setContent("You can share the content with your friends by clicking here.") + .setTarget(new ActionItemTarget(this, R.id.action_share)) + .build()); + + mClingManager.addCling(new Cling.Builder(this) + .setTitle("Here is the drawer") + .setTitleTextAppearance(R.style.textAppearanceTitleNice) + .setContent("You can access this icon by swipping the handle to the top of the screen.") + .setContentTextAppearance(R.style.textAppearanceContentNice) + .setTarget(new ViewTarget(this, R.id.drawer_item)) + .setClingColor(getResources().getColor(R.color.cling)) + .setMessageBackground(getResources().getColor(R.color.red)) + .build()); + + mClingManager.setCallbacks(new ClingManager.Callbacks() { + + @Override + public void onClingHide(int position) { + switch (position) { + // Open the drawer for the next cling. + case 2: + mSlidingDrawer.animateOpen(); + break; + + // Last Cling has been shown, tutorial is ended. + case 3: + mSharedPreferences.edit() + .putBoolean(START_TUTORIAL_KEY, false) + .apply(); + + mClingManager = null; + + mSlidingDrawer.animateClose(); + break; + + } + } + }); + + mClingManager.start(); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.demo, menu); + return super.onCreateOptionsMenu(menu); + } +} diff --git a/clingapp/src/main/java/com/majeur/clingapp/MainActivity.java b/clingapp/src/main/java/com/majeur/clingapp/MainActivity.java new file mode 100644 index 0000000..98592b0 --- /dev/null +++ b/clingapp/src/main/java/com/majeur/clingapp/MainActivity.java @@ -0,0 +1,28 @@ +package com.majeur.clingapp; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; + +public class MainActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + findViewById(R.id.btn_1).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + startActivity(new Intent(MainActivity.this, DemoActivity.class)); + } + }); + + findViewById(R.id.btn_2).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + startActivity(new Intent(MainActivity.this, FirstLaunchDemoActivity.class)); + } + }); + } +} diff --git a/clingapp/src/main/res/layout/activity_demo.xml b/clingapp/src/main/res/layout/activity_demo.xml new file mode 100644 index 0000000..970780e --- /dev/null +++ b/clingapp/src/main/res/layout/activity_demo.xml @@ -0,0 +1,35 @@ + + + +