-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
442a86e
commit 272736f
Showing
24 changed files
with
515 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 /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 *; | ||
#} |
13 changes: 13 additions & 0 deletions
13
clingapp/src/androidTest/java/com/majeur/clingapp/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.majeur.clingapp; | ||
|
||
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<manifest | ||
package="com.majeur.clingapp" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="Cling Sample" | ||
android:supportsRtl="true" | ||
android:theme="@android:style/Theme.DeviceDefault.Light" | ||
tools:replace="android:label"> | ||
|
||
<activity | ||
android:name=".MainActivity" | ||
android:launchMode="singleTop"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
<category android:name="android.intent.category.DEFAULT"/> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity | ||
android:name=".DemoActivity" | ||
android:parentActivityName=".MainActivity"/> | ||
|
||
<activity | ||
android:name=".FirstLaunchDemoActivity" | ||
android:parentActivityName=".MainActivity"/> | ||
|
||
</application> | ||
|
||
</manifest> |
93 changes: 93 additions & 0 deletions
93
clingapp/src/main/java/com/majeur/clingapp/DemoActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
clingapp/src/main/java/com/majeur/clingapp/FirstLaunchDemoActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
clingapp/src/main/java/com/majeur/clingapp/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout | ||
android:id="@+id/button_container" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:orientation="vertical"> | ||
|
||
<Button | ||
android:id="@+id/btn_1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="No target | Default style"/> | ||
|
||
<Button | ||
android:id="@+id/btn_2" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="View target | Custom message color"/> | ||
|
||
<Button | ||
android:id="@+id/btn_3" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Action item target | Custom textAppearance, custom message color and custom Cling color"/> | ||
|
||
<Button | ||
android:id="@+id/btn_4" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Run Clings in sequence" | ||
android:layout_marginTop="15dp"/> | ||
|
||
</LinearLayout> |
Oops, something went wrong.