Skip to content

Commit

Permalink
[Tabs] replace text by icons for kids.
Browse files Browse the repository at this point in the history
picker and palette icons has been kept for the
fab since it's represent well the action behind.
Color and Palette words of the tabs have been replaced
by icons which represent what kids are going to find
in the list : rounds for colors and squares for palettes.
  • Loading branch information
tbarthel-fr committed Jul 25, 2016
1 parent d118d62 commit 3435104
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package fr.tvbarthel.apps.cameracolorpicker.adapters;

import android.support.v4.view.PagerAdapter;

/**
* Adpater used to display the tab of the
* {@link fr.tvbarthel.apps.cameracolorpicker.activities.MainActivity}
* <p/>
* No specific behaviour.
*/
public abstract class MainPagerAdapter extends PagerAdapter {
}
5 changes: 5 additions & 0 deletions CameraColorPicker/app/src/adult/res/values/drawables.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="ic_fab_color_picker_action">@drawable/ic_image_colorize</drawable>
<drawable name="ic_fab_palette_creation_action">@drawable/ic_image_palette</drawable>
</resources>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package fr.tvbarthel.apps.cameracolorpicker.adapters;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.astuetz.PagerSlidingTabStrip;

import fr.tvbarthel.apps.cameracolorpicker.R;

/**
* Adpater used to display the tab of the
* {@link fr.tvbarthel.apps.cameracolorpicker.activities.MainActivity}
*/
public abstract class MainPagerAdapter extends PagerAdapter implements PagerSlidingTabStrip.CustomTabProvider {
@Override
public View getCustomTabView(ViewGroup parent, int position) {
Context context = parent.getContext();
ImageView imageView = new ImageView(context);
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
imageView.setContentDescription(getPageTitle(position));
switch (position) {
case 0:
imageView.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_round_white));
break;
case 1:
imageView.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_square_white));
break;
default:
throw new IllegalStateException("Can't instantiate tab view for position : " + position);
}
return imageView;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#aaffffff" />
<size
android:width="30dp"
android:height="30dp" />
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#aaffffff" />
<size
android:width="25dp"
android:height="25dp" />
</shape>
1 change: 1 addition & 0 deletions CameraColorPicker/app/src/kids/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Kids Camera Color Picker</string>
<string name="activity_main_error_not_enough_colors"></string>
</resources>
5 changes: 5 additions & 0 deletions CameraColorPicker/app/src/kids/res/values/drawables.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="ic_fab_color_picker_action">@drawable/ic_image_colorize</drawable>
<drawable name="ic_fab_palette_creation_action">@drawable/ic_image_palette</drawable>
</resources>
1 change: 1 addition & 0 deletions CameraColorPicker/app/src/kids/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Kids Camera Color Picker</string>
<string name="activity_main_error_not_enough_colors"></string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import android.os.Bundle;
import android.support.annotation.IntDef;
import android.support.annotation.StringRes;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -26,6 +26,7 @@

import cameracolorpicker.flavors.MainActivityFlavor;
import fr.tvbarthel.apps.cameracolorpicker.R;
import fr.tvbarthel.apps.cameracolorpicker.adapters.MainPagerAdapter;
import fr.tvbarthel.apps.cameracolorpicker.data.ColorItems;
import fr.tvbarthel.apps.cameracolorpicker.fragments.AboutDialogFragment;
import fr.tvbarthel.apps.cameracolorpicker.views.ColorItemListPage;
Expand Down Expand Up @@ -207,6 +208,7 @@ public void onClick(View v) {
// Check if there is at least two color items.
// Creating a color palette with 1 or 0 colors make no sense.
if (ColorItems.getSavedColorItems(this).size() <= 1) {
onEmphasisOnPaletteCreationRequested();
showToast(R.string.activity_main_error_not_enough_colors);
} else {
final Intent intentColorPaletteActivity = new Intent(this, PaletteCreationActivity.class);
Expand Down Expand Up @@ -280,9 +282,9 @@ public void onEmphasisOnPaletteCreationRequested() {
private void setCurrentPage(@PageId int pageId) {
mCurrentPageId = pageId;
if (pageId == PAGE_ID_COLOR_ITEM_LIST) {
mFab.setImageResource(R.drawable.ic_image_colorize);
mFab.setImageResource(R.drawable.ic_fab_color_picker_action);
} else if (pageId == PAGE_ID_PALETTE_LIST) {
mFab.setImageResource(R.drawable.ic_image_palette);
mFab.setImageResource(R.drawable.ic_fab_palette_creation_action);
}
}

Expand All @@ -303,8 +305,11 @@ private void hideToast() {
*/
private void showToast(@StringRes int resId) {
hideToast();
mToast = Toast.makeText(this, resId, Toast.LENGTH_SHORT);
mToast.show();
String toastText = getString(resId);
if (!TextUtils.isEmpty(toastText)) {
mToast = Toast.makeText(this, resId, Toast.LENGTH_SHORT);
mToast.show();
}
}

/**
Expand Down Expand Up @@ -350,7 +355,7 @@ public void run() {
}, delay);
}

private class MyPagerAdapter extends PagerAdapter {
private class MyPagerAdapter extends MainPagerAdapter {

@Override
public CharSequence getPageTitle(int position) {
Expand Down Expand Up @@ -396,6 +401,5 @@ public int getCount() {
public boolean isViewFromObject(View view, Object object) {
return view == object;
}

}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions CameraColorPicker/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
android:textColor="@color/secondary_text_default_material_dark"
app:pstsTabBackground="@drawable/bg_tab"
app:pstsIndicatorColor="@android:color/white"
app:pstsShouldExpand="true"
app:pstsTabBackground="@drawable/bg_tab"
app:pstsTextColorSelected="@android:color/white" />

<FrameLayout
Expand All @@ -45,7 +45,7 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="@drawable/ic_image_colorize"
android:src="@drawable/ic_fab_color_picker_action"
app:fab_colorNormal="@color/color_accent"
app:fab_colorPressed="@color/color_accent"
app:fab_colorRipple="?attr/colorControlHighlight" />
Expand Down

0 comments on commit 3435104

Please sign in to comment.