Skip to content

Commit

Permalink
fix gradient issue and keyboard hide + hardcoded folder edittext color
Browse files Browse the repository at this point in the history
  • Loading branch information
codekidX committed Dec 21, 2016
1 parent e7a9fbf commit c02849f
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class StorageChooserView {

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

public static void setLabelSelect(String labelSelect) {
LABEL_SELECT = labelSelect;
Expand Down Expand Up @@ -63,6 +64,10 @@ public static void setTextfieldHint(String textfieldHint) {
TEXTFIELD_HINT = textfieldHint;
}

public static void setScTextfieldHintColor(int scTextfieldHintColor) {
SC_TEXTFIELD_HINT_COLOR = scTextfieldHintColor;
}

public static void setTextfieldError(String textfieldError) {
TEXTFIELD_ERROR = textfieldError;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.PorterDuff;
import android.content.res.ColorStateList;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.hardware.input.InputManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TextInputLayout;
import android.support.v4.app.DialogFragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.widget.AppCompatImageButton;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethod;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
Expand Down Expand Up @@ -75,6 +75,8 @@ public class CustomChooserFragment extends DialogFragment {
private static final int FLAG_DISSMISS_NORMAL = 0;
private static final int FLAG_DISSMISS_INIT_DIALOG = 1;

private boolean isOpen;

private static String theSelectedPath = "";
private static String mAddressClippedPath = "";

Expand Down Expand Up @@ -117,6 +119,7 @@ public void onClick(View view) {
@Override
public void onClick(View view) {
hideAddFolderView();
hideKeyboard();
}
};

Expand All @@ -128,13 +131,15 @@ public void onClick(View view) {
if(success) {
Toast.makeText(getContext(), StorageChooserView.TOAST_FOLDER_CREATED, Toast.LENGTH_SHORT).show();
trimPopulate(theSelectedPath);
hideKeyboard();
hideAddFolderView();
} else {
Toast.makeText(getContext(), StorageChooserView.TOAST_FOLDER_ERROR, Toast.LENGTH_SHORT).show();
}
}
}
};
private boolean keyboardToggle;

private void showAddFolderView() {
mNewFolderView.setVisibility(View.VISIBLE);
Expand All @@ -153,7 +158,6 @@ private void showAddFolderView() {
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));

//listview should not be clickable
Expand All @@ -163,9 +167,7 @@ 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);
mInactiveGradient.setVisibility(View.INVISIBLE);

if(isSleekView()) {
mNewFolderImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.drawable_close_to_plus));
Expand All @@ -181,11 +183,20 @@ private void hideAddFolderView() {
//listview should be clickable
StorageChooserCustomListAdapter.shouldEnable = true;

mInactiveGradient.startAnimation(anim);
mInactiveGradient.setVisibility(View.INVISIBLE);

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

private int isFolderViewVisible() {
return mNewFolderView.getVisibility();
private boolean isFolderViewVisible() {
return mNewFolderView.getVisibility() == View.VISIBLE;
}

public void hideKeyboard() {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mFolderNameEditText.getWindowToken(), 0);

}

private void performBackAction() {
Expand Down Expand Up @@ -249,6 +260,10 @@ private View getLayout(LayoutInflater inflater, ViewGroup container) {
mFolderNameETLayout = (TextInputLayout) mLayout.findViewById(R.id.et_folder_name_layout);
mFolderNameETLayout.setHint(StorageChooserView.TEXTFIELD_HINT);

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mFolderNameEditText.setHintTextColor(ContextCompat.getColor(getContext(), StorageChooserView.SC_TEXTFIELD_HINT_COLOR));
}

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

//at start dont show the new folder view unless user clicks on the add/plus button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
android:layout_toStartOf="@+id/create_folder_button"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
app:theme="@style/EditTextHint"
android:layout_margin="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
android:layout_toStartOf="@+id/create_folder_button"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
app:theme="@style/EditTextHint"
android:layout_margin="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand Down
1 change: 1 addition & 0 deletions storagechooser/src/main/res/layout/custom_storage_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
android:layout_toStartOf="@+id/create_folder_button"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
app:theme="@style/EditTextHint"
android:layout_margin="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand Down
1 change: 0 additions & 1 deletion storagechooser/src/main/res/layout/row_custom_paths.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
android:layout_marginStart="16dp"
android:layout_marginTop="6dp"
android:textSize="16sp"
android:textColor="@android:color/black"
android:layout_toEndOf="@id/path_folder_icon"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions storagechooser/src/main/res/layout/sheet_storage_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
android:layout_toStartOf="@+id/create_folder_button"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
app:theme="@style/EditTextHint"
android:layout_margin="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand Down
9 changes: 9 additions & 0 deletions storagechooser/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>

<style name="EditTextHint" parent="TextAppearance.AppCompat">
<item name="android:textColor">@color/chevronBgColor</item>
<item name="android:textColorHint">@color/chevronBgColor</item>
<item name="android:textSize">11.5sp</item>
<item name="colorAccent">@color/pathLayoutBgColor</item>
<item name="colorControlNormal">@color/chevronBgColor</item>
<item name="colorControlActivated">@color/pathLayoutBgColor</item>
</style>
</resources>

0 comments on commit c02849f

Please sign in to comment.