Rahul Upadhyay Drag to Connect

Created by Rahul Upadhyay last modified
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
...
    <application
 ..
 ..>
        <activity
            android:name=".view.activity.LoginActivity"
            android:label="@string/title_activity_login"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar.Transparent" />
            
    </application>
</manifest>
public class LoginActivity extends AppCompatActivity {

 private int MIN_VALUE = 100;
 private ShimmerFrameLayout mShimmerViewContainer;
 
 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window w = getWindow(); // in Activity's onCreate() for instance
            //use this to make transparent both status and navigationbar, add 24dp marginTop to toolbar in xml
            w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            // use this to make transparent status bar, No need to add 24dp marginTop to toolbar.
            /*w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);*/
        }
        setContentView(R.layout.activity_login);

        initUI();

    }
    
    private void initUI() {
        seekBar = (SeekBar)findViewById(R.id.seekBar);
        mShimmerViewContainer = (ShimmerFrameLayout) findViewById(R.id.shimmer_view_container);

        final Drawable d = getResources().getDrawable(R.mipmap.ic_google);
        d.setBounds(new Rect(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()));
        seekBar.setThumb(d);
        seekBar.setThumbOffset(0);
        seekBar.setMax(100);

        tvConnectApp = (AppCompatTextView)findViewById(R.id.tvConnectApp);
        tvAppLoginDetails= (AppCompatTextView)findViewById(R.id.tvAppLoginDetails);
        tvWhatApp = (AppCompatTextView)findViewById(R.id.tvWhatApp);

        tvConnectApp.setText(String.format(getString(R.string.message_connect_to_1_s),getString(R.string.app_name)));
        tvAppLoginDetails.setText(String.format(getString(R.string.message_drag_the_google),getString(R.string.app_name)));
        tvWhatApp.setText(String.format(getString(R.string.message_what_s_1_s),getString(R.string.app_name)));

        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @RequiresApi(api = Build.VERSION_CODES.N)
            public void onStopTrackingTouch(SeekBar seekBar) {
                if (seekBar.getProgress()<MIN_VALUE){
                    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                        seekBar.setProgress(0,true);
                    }else{
                        seekBar.setProgress(0);
                    }
                }

                if (seekBar.getProgress()==seekBar.getMax()){
                    mShimmerViewContainer.stopShimmerAnimation();
                    signInWithGoogle();
                }
            }

            public void onStartTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub

            }

            public void onProgressChanged(SeekBar seekBar, int progress,
                                          boolean fromUser) {
                seekBar.setProgress(progress);

            }
        });
    }
    
    @Override
    protected void onResume() {
        super.onResume();
        seekBar.setProgress(0);
        mShimmerViewContainer.startShimmerAnimation();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mShimmerViewContainer.stopShimmerAnimation();
    }

}
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.rahul.vaccinationdroid.view.activity.LoginActivity">

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


</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimary"
    android:fitsSystemWindows="true"
    xmlns:shimmer="http://schemas.android.com/apk/res-auto"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.rahul.vaccinationdroid.view.activity.LoginActivity"
    tools:showIn="@layout/activity_login">


    <!--Google Connect Slider-->
    <FrameLayout
        android:id="@+id/frameGoogleConnect"
        android:layout_marginTop="@dimen/DP_120"
        android:rotation="90"
        android:layout_centerHorizontal="true"
        android:layout_width="@dimen/DP_200"
        android:background="@drawable/rounded_corner_bg"
        android:layout_height="wrap_content">

        <com.facebook.shimmer.ShimmerFrameLayout
            android:id="@+id/shimmer_view_container"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            shimmer:duration="1000">
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal"
                >
                <android.support.v7.widget.AppCompatImageView
                    android:rotation="270"
                    app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
                <android.support.v7.widget.AppCompatImageView
                    android:rotation="270"
                    app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
                <android.support.v7.widget.AppCompatImageView
                    android:rotation="270"
                    app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
                </LinearLayout>
            </com.facebook.shimmer.ShimmerFrameLayout>

        <ImageView
            android:rotation="90"
            android:layout_marginRight="@dimen/DP_24"
            android:layout_gravity="right|center_vertical"
            android:src="@mipmap/ic_link"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <SeekBar
            android:layout_margin="@dimen/default_margin"
            android:progressDrawable="@drawable/seekbar_bg"
            android:id="@+id/seekBar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/DP_64"
            />


    </FrameLayout>
    <!--Google Connect slider over-->

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_marginTop="@dimen/DP_94"
        android:layout_centerHorizontal="true"
        android:gravity="center_horizontal"
        android:layout_below="@id/frameGoogleConnect"
        android:layout_height="wrap_content">

    <android.support.v7.widget.AppCompatTextView
        android:text="@string/message_welcome"
        android:textAllCaps="true"
        android:textColor="@color/blue_grey_50"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/tvConnectApp"
            android:layout_marginTop="@dimen/default_margin"
            android:text="@string/message_connect_to_1_s"
            android:textAllCaps="true"
            android:textColor="@color/blue_grey_50"
            android:textAppearance="@style/TextAppearance.AppCompat.Title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/DP_2"
            android:layout_marginTop="@dimen/DP_20"
            android:layout_marginBottom="@dimen/DP_20"
            android:layout_marginLeft="@dimen/DP_40"
            android:layout_marginRight="@dimen/DP_40"
            android:background="@color/colorPrimaryLight"
            />

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/tvAppLoginDetails"
            android:padding="@dimen/DP_20"
            android:layout_marginTop="@dimen/default_margin"
            android:gravity="center"
            android:text="@string/message_drag_the_google"
            android:textColor="@color/blue_grey_50"
            android:textAppearance="@style/TextAppearance.AppCompat.Body2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>

    <android.support.v7.widget.AppCompatTextView
        android:id="@+id/tvWhatApp"
        android:padding="@dimen/DP_20"
        android:layout_centerHorizontal="true"
        android:gravity="center"
        android:layout_alignParentBottom="true"
        android:layout_marginTop="@dimen/default_margin"
        android:textAllCaps="true"
        android:layout_marginBottom="@dimen/DP_40"
        android:text="@string/message_what_s_1_s"
        android:textColor="@color/blue_grey_50"
        android:textAppearance="@style/TextAppearance.AppCompat.Title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>
values : 

    <style name="AppTheme.NoActionBar.Transparent" parent="AppTheme.NoActionBar"/>


values-v19 : 

    <style name="AppTheme.NoActionBar.Transparent" parent="AppTheme.NoActionBar">
        <item name="android:windowTranslucentStatus">true</item>
    </style>

values-v21
    
    <style name="AppTheme.NoActionBar.Transparent" parent="AppTheme.NoActionBar">
        <item name="android:statusBarColor">@android:color/transparent</item>
    </style>

Comments (0)