Skip to content

Commit

Permalink
Sample project is updated. Gravity and Focus example fragments are ad…
Browse files Browse the repository at this point in the history
…ded.
  • Loading branch information
iammert committed Jan 31, 2016
1 parent 7fd9c70 commit 448d6e4
Show file tree
Hide file tree
Showing 16 changed files with 404 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ public void setDisplayed(String id){
public void reset(String id){
sharedPreferences.edit().putBoolean(id, false).apply();
}

public void resetAll(){
sharedPreferences.edit().clear().apply();
}
}
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.github.iammert:MaterialIntroView:1.2'
//compile project(':materialintro')
//compile 'com.github.iammert:MaterialIntroView:1.2'
compile project(':materialintro')
}
72 changes: 17 additions & 55 deletions sample/src/main/java/co/mobiwise/sample/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package co.mobiwise.sample;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.CardView;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
Expand All @@ -13,14 +9,10 @@
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.Toast;

import co.mobiwise.materialintro.MaterialIntroConfiguration;
import co.mobiwise.materialintro.animation.MaterialIntroListener;
import co.mobiwise.materialintro.shape.Focus;
import co.mobiwise.materialintro.shape.FocusGravity;
import co.mobiwise.materialintro.view.MaterialIntroView;
import co.mobiwise.sample.fragment.FocusFragment;
import co.mobiwise.sample.fragment.GravityFragment;
import co.mobiwise.sample.fragment.MainFragment;

public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
Expand All @@ -32,16 +24,12 @@ protected void onCreate(Bundle savedInstanceState) {
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
if(savedInstanceState == null)
getSupportFragmentManager()
.beginTransaction()
.add(R.id.container,new MainFragment())
.commit();

@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}

});

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
Expand All @@ -52,16 +40,6 @@ public void onClick(View view) {
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);

CardView cardView = (CardView) findViewById(R.id.my_card);
cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(),"Clicked!",Toast.LENGTH_SHORT).show();
}
});

showCardViewIntro(cardView);

}

@Override
Expand Down Expand Up @@ -102,39 +80,23 @@ public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();

if (id == R.id.nav_camera) {
// Handle the camera action
} else if (id == R.id.nav_gallery) {

} else if (id == R.id.nav_slideshow) {
if(id == R.id.nav_demo){
getSupportFragmentManager().beginTransaction().replace(R.id.container, new MainFragment()).commit();
}else if (id == R.id.nav_gravity) {
getSupportFragmentManager().beginTransaction().replace(R.id.container, new GravityFragment()).commit();
} else if (id == R.id.nav_focus) {
getSupportFragmentManager().beginTransaction().replace(R.id.container, new FocusFragment()).commit();
} else if (id == R.id.nav_recyclerview) {

} else if (id == R.id.nav_manage) {
} else if (id == R.id.nav_toolbar) {

} else if (id == R.id.nav_share) {

} else if (id == R.id.nav_send) {
} else if (id == R.id.nav_tab) {

}

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}

private void showCardViewIntro(View view){


new MaterialIntroView.Builder(this)
.enableDotAnimation(true)
.setFocusGravity(FocusGravity.CENTER)
.setFocusType(Focus.MINIMUM)
.setDelayMillis(500)
.setTargetPadding(70)
.enableFadeAnimation(true)
.performClick(true)
.setInfoText("Hi There! Click this card and see what happens.")
.setTarget(view)
.setUsageId("intro_card")
.show();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package co.mobiwise.sample.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import co.mobiwise.materialintro.animation.MaterialIntroListener;
import co.mobiwise.materialintro.shape.Focus;
import co.mobiwise.materialintro.shape.FocusGravity;
import co.mobiwise.materialintro.view.MaterialIntroView;
import co.mobiwise.sample.R;

/**
* Created by mertsimsek on 31/01/16.
*/
public class FocusFragment extends Fragment implements MaterialIntroListener{

private static final String INTRO_FOCUS_1 = "intro_focus_1";
private static final String INTRO_FOCUS_2 = "intro_focus_2";
private static final String INTRO_FOCUS_3 = "intro_focus_3";

Button button1;
Button button2;
Button button3;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_focus, container, false);

button1 = (Button) view.findViewById(R.id.button_focus_1);
button2 = (Button) view.findViewById(R.id.button_focus_2);
button3 = (Button) view.findViewById(R.id.button_focus_3);

showIntro(button1,INTRO_FOCUS_1,"This intro view focus on all target.", Focus.ALL);

return view;
}

public void showIntro(View view, String id, String text, Focus focusType){
new MaterialIntroView.Builder(getActivity())
.enableDotAnimation(false)
.setFocusGravity(FocusGravity.CENTER)
.setFocusType(focusType)
.setDelayMillis(200)
.enableFadeAnimation(true)
.setListener(this)
.performClick(true)
.setInfoText(text)
.setTarget(view)
.setUsageId(id) //THIS SHOULD BE UNIQUE ID
.show();
}

@Override
public void onUserClicked(String materialIntroViewId) {
if(materialIntroViewId == INTRO_FOCUS_1)
showIntro(button2,INTRO_FOCUS_2,"This intro view focus on minimum size", Focus.MINIMUM);
else if(materialIntroViewId == INTRO_FOCUS_2)
showIntro(button3,INTRO_FOCUS_3,"This intro view focus on normal size (avarage of MIN and ALL)", Focus.NORMAL);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package co.mobiwise.sample.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import co.mobiwise.materialintro.animation.MaterialIntroListener;
import co.mobiwise.materialintro.shape.Focus;
import co.mobiwise.materialintro.shape.FocusGravity;
import co.mobiwise.materialintro.view.MaterialIntroView;
import co.mobiwise.sample.R;

/**
* Created by mertsimsek on 31/01/16.
*/
public class GravityFragment extends Fragment implements MaterialIntroListener{

private static final String INTRO_CARD1 = "intro_card_1";
private static final String INTRO_CARD2 = "intro_card_2";
private static final String INTRO_CARD3 = "intro_card_3";

CardView cardView1;
CardView cardView2;
CardView cardView3;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_gravity, container, false);

cardView1 = (CardView) view.findViewById(R.id.my_card);
cardView2 = (CardView) view.findViewById(R.id.my_card2);
cardView3 = (CardView) view.findViewById(R.id.my_card3);

showIntro(cardView1, INTRO_CARD1, "This intro focuses on RIGHT", FocusGravity.RIGHT);

return view;
}

@Override
public void onUserClicked(String materialIntroViewId) {
if(materialIntroViewId == INTRO_CARD1)
showIntro(cardView2, INTRO_CARD2, "This intro focuses on CENTER.", FocusGravity.CENTER);
if(materialIntroViewId == INTRO_CARD2)
showIntro(cardView3, INTRO_CARD3, "This intro focuses on LEFT.", FocusGravity.LEFT);
}

public void showIntro(View view, String id, String text, FocusGravity focusGravity){
new MaterialIntroView.Builder(getActivity())
.enableDotAnimation(true)
.setFocusGravity(focusGravity)
.setFocusType(Focus.MINIMUM)
.setDelayMillis(200)
.enableFadeAnimation(true)
.performClick(true)
.setInfoText(text)
.setTarget(view)
.setListener(this)
.setUsageId(id) //THIS SHOULD BE UNIQUE ID
.show();
}
}
64 changes: 64 additions & 0 deletions sample/src/main/java/co/mobiwise/sample/fragment/MainFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package co.mobiwise.sample.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import co.mobiwise.materialintro.prefs.PreferencesManager;
import co.mobiwise.materialintro.shape.Focus;
import co.mobiwise.materialintro.shape.FocusGravity;
import co.mobiwise.materialintro.view.MaterialIntroView;
import co.mobiwise.sample.R;

/**
* Created by mertsimsek on 31/01/16.
*/
public class MainFragment extends Fragment implements View.OnClickListener{

private static final String INTRO_CARD = "material_intro";
private static final String INTRO_RESET_BUTTON = "material_reset";

private CardView cardView;
private Button button;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.content_main, container, false);
cardView = (CardView) view.findViewById(R.id.my_card);
button = (Button) view.findViewById(R.id.button_reset_all);
button.setOnClickListener(this);

//Show intro
showIntro(cardView, INTRO_CARD, "This is card! Hello There. You can set this text!");

return view;
}

@Override
public void onClick(View v) {
int id = v.getId();

if(id == R.id.button_reset_all)
new PreferencesManager(getActivity().getApplicationContext()).resetAll();
}

private void showIntro(View view, String usageId, String text){
new MaterialIntroView.Builder(getActivity())
.enableDotAnimation(true)
.setFocusGravity(FocusGravity.CENTER)
.setFocusType(Focus.MINIMUM)
.setDelayMillis(200)
.enableFadeAnimation(true)
.performClick(true)
.setInfoText(text)
.setTarget(view)
.setUsageId(usageId) //THIS SHOULD BE UNIQUE ID
.show();
}
}
Binary file added sample/src/main/res/drawable/icon_miv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions sample/src/main/res/drawable/side_nav_bar.xml

This file was deleted.

10 changes: 1 addition & 9 deletions sample/src/main/res/layout/app_bar_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main"/>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email"/>
<include layout="@layout/container"/>

</android.support.design.widget.CoordinatorLayout>
9 changes: 9 additions & 0 deletions sample/src/main/res/layout/container.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

</FrameLayout>
7 changes: 7 additions & 0 deletions sample/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@

</android.support.v7.widget.CardView>

<Button
android:id="@+id/button_reset_all"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RESET ALL"
android:layout_alignParentBottom="true"/>

</RelativeLayout>
Loading

0 comments on commit 448d6e4

Please sign in to comment.