Skip to content

Commit

Permalink
ended dialer activity
Browse files Browse the repository at this point in the history
  • Loading branch information
saulmm committed Nov 8, 2014
1 parent 3946376 commit eb20707
Show file tree
Hide file tree
Showing 27 changed files with 412 additions and 157 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ android {
}
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v4:21.0.0'
}
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
android:name=".activities.SlidingActivity" >
</activity>

<activity android:name=".activities.DialerSampleActivity">
<activity android:name=".activities.DialerSampleActivity"
android:screenOrientation="portrait">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -30,7 +32,6 @@

<activity
android:name=".activities.ColorActivity"
android:label="@string/title_activity_color" >
</activity>
android:label="@string/title_activity_color" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import android.widget.Switch;

import com.saulmm.material.R;
import com.saulmm.material.utils.Utils;
import com.saulmm.material.utils.GUIUtils;

public class ColorActivity extends Activity {

Expand Down Expand Up @@ -62,7 +62,7 @@ public void onViewAttachedToWindow(View v) {
getTheme().resolveAttribute(android.R.attr.colorPrimary, outValue, true);
revealView.setBackgroundColor(outValue.data);

Utils.hideRevealEffect(revealView, cx, cy, 1920);
GUIUtils.hideRevealEffect(revealView, cx, cy, 1920);
}

@Override
Expand Down Expand Up @@ -136,7 +136,7 @@ public void view(View view) {
view.getLocationOnScreen(location);

int cx = (location[0] + (view.getWidth() / 2));
int cy = location[1] + (Utils.getStatusBarHeight(this) / 2);
int cy = location[1] + (GUIUtils.getStatusBarHeight(this) / 2);

SharedPreferences.Editor ed = sharedpreferences.edit();
ed.putInt("x", cx);
Expand All @@ -145,7 +145,7 @@ public void view(View view) {
ed.apply();

hideNavigationStatus();
Utils.showRevealEFfect(revealView, cx, cy, revealAnimationListener);
GUIUtils.showRevealEffect(revealView, cx, cy, revealAnimationListener);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
/*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


package com.saulmm.material.activities;

import android.graphics.Point;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.Display;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.ImageButton;

import com.saulmm.material.R;
import com.saulmm.material.views.adapters.DialerPagerAdapter;
import com.saulmm.material.utils.GUIUtils;
import com.saulmm.material.views.adapters.SamplePagerAdapter;
import com.saulmm.material.views.widgets.SlidingTabLayout;

public class DialerSampleActivity extends ActionBarActivity {
public class DialerSampleActivity extends ActionBarActivity implements ViewPager.OnPageChangeListener {

private int screenWidth;
private ImageButton fabButton;
private FrameLayout dialerKeysContainer;
private float absolutefabPosition;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -35,22 +36,129 @@ protected void onCreate(Bundle savedInstanceState) {

configureToolbar();
configurePager();
configureFab();
configureDialer();

dialerKeysContainer = (FrameLayout) findViewById(R.id.activity_dialer_frame_container);

// Get the screen with
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenWidth = size.x;
}

private void configureFab() {

fabButton = (ImageButton) findViewById(R.id.view_fab_button);
fabButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

absolutefabPosition = v.getX();
GUIUtils.hideViewByScale(fabButton);
dialerKeysContainer.setVisibility(View.VISIBLE);

Animation showDialerContainerAnimation = AnimationUtils.loadAnimation(DialerSampleActivity.this, R.anim.translate_down_on);
showDialerContainerAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}

@Override
public void onAnimationEnd(Animation animation) {

fabButton.setBackgroundResource(R.drawable.ripple_dialer_call);
fabButton.setX(screenWidth / 2 - fabButton.getWidth() / 2);
GUIUtils.showViewByScale(fabButton);
}

@Override
public void onAnimationRepeat(Animation animation) {}
});

dialerKeysContainer.startAnimation(showDialerContainerAnimation);
}
});
}

private void configureToolbar() {

Toolbar mainToolbar = (Toolbar) findViewById(R.id.activity_dialer_toolbar);
mainToolbar.setTitleTextColor(getResources().getColor(R.color.theme_dialer_accent));
setSupportActionBar(mainToolbar);
getSupportActionBar().setTitle("Sliding");
getSupportActionBar().setTitle("Dialer");
}

private void configurePager() {

ViewPager mViewPager = (ViewPager) findViewById(R.id.activity_dialer_pager);
mViewPager.setAdapter(new DialerPagerAdapter(this));
ViewPager tabsViewPAger = (ViewPager) findViewById(R.id.activity_dialer_pager);
tabsViewPAger.setAdapter(new SamplePagerAdapter(this));
tabsViewPAger.setCurrentItem(1);

SlidingTabLayout mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.activity_dialer_tabs);
mSlidingTabLayout.setViewPager(mViewPager);
mSlidingTabLayout.addPagerListener(this);
mSlidingTabLayout.setViewPager(tabsViewPAger);
}

private void configureDialer() {

GridView dialerGrid = (GridView) findViewById(R.id.activity_dialer_pad);
dialerGrid.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item_dialer,
getResources().getStringArray(R.array.dialer_numbers)));
}

@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

float fabButtonPosition = (screenWidth / 2 - fabButton.getWidth()) * positionOffset;


if (fabButtonPosition != 0 && position != 1) {

absolutefabPosition = fabButtonPosition + (screenWidth/2 - fabButton.getWidth()/2);
fabButton.setX(absolutefabPosition);
}
}

@Override
public void onBackPressed() {

if (dialerKeysContainer.getVisibility() == View.VISIBLE) {

Animation hideAnimation = AnimationUtils.loadAnimation(this, R.anim.translate_down_off);
hideAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {

GUIUtils.hideViewByScale(fabButton);
}

@Override
public void onAnimationEnd(Animation animation) {

dialerKeysContainer.setVisibility(View.INVISIBLE);
fabButton.setBackgroundResource(R.drawable.ripple_dialer_idle);
GUIUtils.showViewByScale(fabButton);

fabButton.setX(absolutefabPosition);
}

@Override
public void onAnimationRepeat(Animation animation) {}
});

dialerKeysContainer.startAnimation(hideAnimation);



} else {
super.onBackPressed();
}
}

@Override
public void onPageSelected(int position) {}

@Override
public void onPageScrollStateChanged(int state) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import android.view.View;

import com.saulmm.material.R;
import com.saulmm.material.utils.Utils;
import com.saulmm.material.utils.GUIUtils;

public class TransitionFirstActivity extends Activity {

Expand All @@ -21,12 +21,12 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_transition_first);

// Set explode animation when enter and exit the activity
Utils.configureWindowEnterExitExplodeTransition(getWindow());
GUIUtils.configureWindowEnterExitExplodeTransition(getWindow());

// Fab Button
fabButton = findViewById(R.id.fab_button);
fabButton.setOnClickListener(fabClickListener);
Utils.configureFab(fabButton);
GUIUtils.configureFab(fabButton);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import android.widget.LinearLayout;

import com.saulmm.material.R;
import com.saulmm.material.utils.Utils;
import com.saulmm.material.utils.GUIUtils;

public class TransitionSecondActivity extends Activity {

Expand All @@ -25,7 +25,7 @@ protected void onCreate(Bundle savedInstanceState) {

rowContainer = (LinearLayout) findViewById(R.id.row_container2);

Utils.configureWindowEnterExitExplodeTransition(getWindow());
GUIUtils.configureWindowEnterExitExplodeTransition(getWindow());

getWindow().getEnterTransition().addListener(new Transition.TransitionListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
public class NavigationFragment extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

return inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.saulmm.material.fragments;

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

import com.saulmm.material.R;

public class SamplePageFragment extends Fragment {

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

View rootView = inflater.inflate(R.layout.fragment_dialer_sample_page, container);

return rootView;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public class SlidingTabFragment extends Fragment {
static final String LOG_TAG = "SlidingTabsBasicFragment";

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_sliding, container, false);
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

return inflater.inflate(R.layout.fragment_dialer_sliding, container, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
import android.transition.Slide;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewPropertyAnimator;
import android.view.Window;
import android.view.animation.PathInterpolator;

import com.saulmm.material.R;

public class Utils {
public class GUIUtils {

public static final int SCALE_FACTOR = 30;

public static void configureWindowEnterExitExplodeTransition(Window w) {

Expand Down Expand Up @@ -68,7 +71,7 @@ public void onAnimationEnd(Animator animation) {
anim.start();
}

public static void showRevealEFfect (final View v, int centerX, int centerY, Animator.AnimatorListener lis) {
public static void showRevealEffect(final View v, int centerX, int centerY, Animator.AnimatorListener lis) {

v.setVisibility(View.VISIBLE);

Expand All @@ -84,4 +87,22 @@ public static void showRevealEFfect (final View v, int centerX, int centerY, Ani
}



public static void hideViewByScale(View view) {

ViewPropertyAnimator propertyAnimator = view.animate().setStartDelay(SCALE_FACTOR)
.scaleX(0).scaleY(0);

propertyAnimator.start();
}

public static void showViewByScale(View view) {

ViewPropertyAnimator propertyAnimator = view.animate().setStartDelay(SCALE_FACTOR)
.scaleX(1).scaleY(1);

propertyAnimator.start();
}


}
Loading

0 comments on commit eb20707

Please sign in to comment.