Skip to content

Commit

Permalink
new sheet layout
Browse files Browse the repository at this point in the history
  • Loading branch information
codekidX committed Dec 20, 2016
1 parent 3c6ea37 commit e7a9fbf
Show file tree
Hide file tree
Showing 8 changed files with 373 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.widget.TextView;

import com.codekidlabs.storagechooser.StorageChooser;
import com.codekidlabs.storagechooser.StorageChooserView;
import com.codekidlabs.storagechooserdemo.utils.TypefaceUtil;

public class MainActivity extends AppCompatActivity {
Expand Down Expand Up @@ -90,6 +91,8 @@ public void onSelect(String path) {
}
});

StorageChooserView.setViewSc(StorageChooserView.SC_LAYOUT_SHEET);

storageChooser.show();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@ public class StorageChooserView {

public static String LABEL_SELECT = "Select";
public static String LABEL_CREATE = "Create";
public static String LABEL_NEW_FOLDER = "New Folder";
public static String LABEL_CANCEL = "Cancel";
public static String CHOOSER_HEADING;
public static String INTERNAL_STORAGE_TEXT;
public static String TOAST_FOLDER_CREATED = "Folder Created";
public static String TOAST_FOLDER_ERROR = "Error occured while creating folder. Try again.";
public static String TEXTFIELD_HINT = "Folder Name";
public static String TEXTFIELD_ERROR = "Empty Folder Name";

// LAYOUTS
public static int VIEW_SC = R.layout.custom_storage_list;

// layout choices
public static int SC_LAYOUT_SLEEK = R.layout.custom_storage_list;
public static int SC_LAYOUT_SHEET = R.layout.sheet_storage_list;

// COLORS
public static int SC_SECONDARY_ACTION_COLOR = android.R.color.black;

public static void setLabelSelect(String labelSelect) {
LABEL_SELECT = labelSelect;
}
Expand All @@ -23,6 +35,14 @@ public static void setLabelCreate(String labelCreate) {
LABEL_CREATE = labelCreate;
}

public static void setLabelNewFolder(String labelNewFolder) {
LABEL_NEW_FOLDER = labelNewFolder;
}

public static void setLabelCancel(String labelCancel) {
LABEL_CANCEL = labelCancel;
}

public static void setChooserHeading(String chooserHeading) {
CHOOSER_HEADING = chooserHeading;
}
Expand All @@ -46,4 +66,12 @@ public static void setTextfieldHint(String textfieldHint) {
public static void setTextfieldError(String textfieldError) {
TEXTFIELD_ERROR = textfieldError;
}

public static void setViewSc(int viewSc) {
VIEW_SC = viewSc;
}

public static void setScSecondaryActionColor(int scSecondaryActionColor) {
SC_SECONDARY_ACTION_COLOR = scSecondaryActionColor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@
public class CustomChooserFragment extends DialogFragment {

private View mLayout;
private View mInactiveGradient;
private ViewGroup mContainer;

private TextView mPathChosen;
private ImageButton mBackButton;
private Button mSelectButton;
private Button mCreateButton;
private ImageView mNewFolderButton;
private ImageView mNewFolderImageView;
private Button mNewFolderButton;
private EditText mFolderNameEditText;
private TextInputLayout mFolderNameETLayout;

Expand Down Expand Up @@ -138,14 +140,21 @@ private void showAddFolderView() {
mNewFolderView.setVisibility(View.VISIBLE);
Animation anim = AnimationUtils.loadAnimation(getContext(), R.anim.anim_new_folder_view);
mNewFolderView.startAnimation(anim);

mNewFolderButton.setImageDrawable(ContextCompat.getDrawable(getContext(),R.drawable.drawable_plus_to_close));
// image button animation
Animatable animatable = (Animatable) mNewFolderButton.getDrawable();
animatable.start();
mInactiveGradient.startAnimation(anim);

if(isSleekView()) {
mNewFolderImageView.setImageDrawable(ContextCompat.getDrawable(getContext(),R.drawable.drawable_plus_to_close));
// image button animation
Animatable animatable = (Animatable) mNewFolderImageView.getDrawable();
animatable.start();
mNewFolderImageView.setOnClickListener(mNewFolderButtonCloseListener);
} else {
mNewFolderButton.setOnClickListener(mNewFolderButtonCloseListener);
mNewFolderButton.setText(StorageChooserView.LABEL_CANCEL);
// mNewFolderButton.setTextColor(ContextCompat.getColor(getContext(), android.R.color.holo_red_light));
}

// mNewFolderButton.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.window_close));
mNewFolderButton.setOnClickListener(mNewFolderButtonCloseListener);

//listview should not be clickable
StorageChooserCustomListAdapter.shouldEnable = false;
Expand All @@ -154,18 +163,25 @@ private void showAddFolderView() {
private void hideAddFolderView() {
Animation anim = AnimationUtils.loadAnimation(getContext(), R.anim.anim_close_folder_view);
mNewFolderView.startAnimation(anim);
mInactiveGradient.startAnimation(anim);
mNewFolderView.setVisibility(View.INVISIBLE);

mNewFolderButton.setImageDrawable(ContextCompat.getDrawable(getContext(),R.drawable.drawable_close_to_plus));
// image button animation
Animatable animatable = (Animatable) mNewFolderButton.getDrawable();
animatable.start();

mInactiveGradient.setVisibility(View.INVISIBLE);

if(isSleekView()) {
mNewFolderImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.drawable_close_to_plus));
// image button animation
Animatable animatable = (Animatable) mNewFolderImageView.getDrawable();
animatable.start();
mNewFolderImageView.setOnClickListener(mNewFolderButtonClickListener);
} else {
mNewFolderButton.setOnClickListener(mNewFolderButtonClickListener);
mNewFolderButton.setText(StorageChooserView.LABEL_NEW_FOLDER);
// mNewFolderButton.setTextColor(ContextCompat.getColor(getContext(), StorageChooserView.SC_SECONDARY_ACTION_COLOR));
}
//listview should be clickable
StorageChooserCustomListAdapter.shouldEnable = true;

// mNewFolderButton.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.plus));
mNewFolderButton.setOnClickListener(mNewFolderButtonClickListener);
}

private int isFolderViewVisible() {
Expand Down Expand Up @@ -212,21 +228,32 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
}

private View getLayout(LayoutInflater inflater, ViewGroup container) {
mLayout = inflater.inflate(R.layout.custom_storage_list, container, false);
mLayout = inflater.inflate(StorageChooserView.VIEW_SC, container, false);
initListView(getContext(), mLayout, StorageChooser.sConfig.isShowMemoryBar());

mBackButton = (ImageButton) mLayout.findViewById(R.id.back_button);
mSelectButton = (Button) mLayout.findViewById(R.id.select_button);
mNewFolderButton = (ImageView) mLayout.findViewById(R.id.new_folder_button);
if(isSleekView()) {
mNewFolderImageView = (ImageView) mLayout.findViewById(R.id.new_folder_button);
mNewFolderImageView.setOnClickListener(mNewFolderButtonClickListener);
} else {
mNewFolderButton = (Button) mLayout.findViewById(R.id.new_folder_button);
mNewFolderButton.setText(StorageChooserView.LABEL_NEW_FOLDER);
mNewFolderButton.setOnClickListener(mNewFolderButtonClickListener);
mNewFolderButton.setTextColor(ContextCompat.getColor(getContext(), StorageChooserView.SC_SECONDARY_ACTION_COLOR));
}
mCreateButton = (Button) mLayout.findViewById(R.id.create_folder_button);
RelativeLayout mNewFolderButtonHolder = (RelativeLayout) mLayout.findViewById(R.id.new_folder_button_holder);
mNewFolderView = (RelativeLayout) mLayout.findViewById(R.id.new_folder_view);
mFolderNameEditText = (EditText) mLayout.findViewById(R.id.et_folder_name);
mFolderNameETLayout = (TextInputLayout) mLayout.findViewById(R.id.et_folder_name_layout);
mFolderNameETLayout.setHint(StorageChooserView.TEXTFIELD_HINT);

mInactiveGradient = mLayout.findViewById(R.id.inactive_gradient);

//at start dont show the new folder view unless user clicks on the add/plus button
mNewFolderView.setVisibility(View.INVISIBLE);
mInactiveGradient.setVisibility(View.INVISIBLE);

if(!StorageChooser.sConfig.isAllowAddFolder()) {
mNewFolderButtonHolder.setVisibility(View.GONE);
Expand All @@ -238,12 +265,15 @@ private View getLayout(LayoutInflater inflater, ViewGroup container) {

mBackButton.setOnClickListener(mBackButtonClickListener);
mSelectButton.setOnClickListener(mSelectButtonClickListener);
mNewFolderButton.setOnClickListener(mNewFolderButtonClickListener);
mCreateButton.setOnClickListener(mCreateButtonClickListener);

return mLayout;
}

private boolean isSleekView() {
return StorageChooserView.VIEW_SC == StorageChooserView.SC_LAYOUT_SLEEK;
}


/**
* storage listView related code in this block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@

</RelativeLayout>

<View
android:id="@+id/inactive_gradient"
android:layout_below="@id/custom_path_header"
android:layout_marginBottom="130dp"
android:background="@color/inactiveGradientColor"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<Button
android:id="@+id/select_button"
android:textColor="@color/colorPrimaryDark"
Expand Down
138 changes: 138 additions & 0 deletions storagechooser/src/main/res/layout-v21/sheet_storage_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
android:id="@+id/custom_path_header"
android:background="@color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="60dp">

<LinearLayout
android:layout_margin="8dp"
android:orientation="horizontal"
android:background="@drawable/path_layout_bg"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
android:id="@+id/back_button_holder"
android:layout_width="50dp"
android:background="@color/chevronBgColor"
android:layout_height="match_parent">

<ImageButton
android:id="@+id/back_button"
android:src="@drawable/chevron_left"
android:tint="@android:color/white"
android:background="@android:color/transparent"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>


<TextView
android:id="@+id/path_chosen"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="blahblahblah"
android:fontFamily="sans-serif-condensed"
android:textSize="16sp"
android:textColor="@android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>

</RelativeLayout>

<ListView
android:layout_below="@id/custom_path_header"
android:id="@+id/storage_list_view"
android:divider="@null"
android:fastScrollEnabled="true"
android:fadeScrollbars="true"
android:layout_marginBottom="50dp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<RelativeLayout
android:id="@+id/new_folder_view"
android:background="@color/colorPrimary"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="50dp"
android:layout_width="match_parent"
android:layout_height="80dp">

<android.support.design.widget.TextInputLayout
android:id="@+id/et_folder_name_layout"
android:textColorHint="@color/chevronBgColor"
android:layout_toStartOf="@+id/create_folder_button"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_margin="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/et_folder_name"
android:textColor="@android:color/white"
android:textSize="16sp"
android:backgroundTint="@color/pathLayoutBgColor"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.TextInputLayout>

<Button
android:id="@+id/create_folder_button"
android:textColor="@android:color/white"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="8dp"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:background="@null"
android:layout_width="wrap_content"
android:layout_height="match_parent" />

</RelativeLayout>

<Button
android:id="@+id/new_folder_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:background="@android:color/transparent"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginStart="16dp" />

<View
android:id="@+id/inactive_gradient"
android:layout_below="@id/custom_path_header"
android:layout_marginBottom="130dp"
android:background="@color/inactiveGradientColor"
android:layout_width="match_parent"
android:layout_height="match_parent" />


<Button
android:id="@+id/select_button"
android:textColor="@color/colorPrimaryDark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:background="@android:color/transparent"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="16dp" />

</RelativeLayout>
8 changes: 8 additions & 0 deletions storagechooser/src/main/res/layout/custom_storage_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@

</RelativeLayout>

<View
android:id="@+id/inactive_gradient"
android:layout_below="@id/custom_path_header"
android:layout_marginBottom="130dp"
android:background="@color/inactiveGradientColor"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<Button
android:id="@+id/select_button"
android:textColor="@color/colorPrimaryDark"
Expand Down
Loading

0 comments on commit e7a9fbf

Please sign in to comment.