Skip to content

Commit

Permalink
[Palette creation] Adapt the palette creation to the kid flavor.
Browse files Browse the repository at this point in the history
In the kid version, the instruction is represented as an image, and a default name is used.
In the default version, the instruction is in plain text, and the name of the palette
is choose by the user from a dialog.
  • Loading branch information
vbarthel-fr authored and tbarthel-fr committed Aug 3, 2016
1 parent 85d4255 commit 9eda833
Show file tree
Hide file tree
Showing 14 changed files with 335 additions and 169 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package fr.tvbarthel.apps.cameracolorpicker.activities;

import fr.tvbarthel.apps.cameracolorpicker.R;
import fr.tvbarthel.apps.cameracolorpicker.data.Palette;
import fr.tvbarthel.apps.cameracolorpicker.data.Palettes;
import fr.tvbarthel.apps.cameracolorpicker.fragments.EditTextDialogFragment;
import fr.tvbarthel.apps.cameracolorpicker.views.PaletteMakerView;

/**
* The flavor implementation of {@link PaletteCreationBaseActivity}.
* <p/>
* In the adult version, a name is asked to the user.
*/
public class PaletteCreationActivity extends PaletteCreationBaseActivity implements EditTextDialogFragment.Callback {


@Override
protected void createPalette(PaletteMakerView paletteMakerView) {
final EditTextDialogFragment editTextDialogFragment = EditTextDialogFragment.newInstance(0,
R.string.activity_palette_creation_edit_text_dialog_fragment_title,
R.string.activity_palette_creation_edit_text_dialog_fragment_positive_button,
android.R.string.cancel,
getString(R.string.activity_palette_creation_edit_text_dialog_fragment_hint),
null);
editTextDialogFragment.show(getSupportFragmentManager(), null);
}

@Override
public void onEditTextDialogFragmentPositiveButtonClick(int requestCode, String text) {
final Palette newPalette = mPaletteMakerView.make(text);
if (Palettes.saveColorPalette(this, newPalette)) {
finish();
}
}


@Override
public void onEditTextDialogFragmentNegativeButtonClick(int requestCode) {
// Do nothing when the user cancels.
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
import android.os.Bundle;

/**
* Static methods for specific flavor behaviour of {@link PaletteCreationActivity}.
* Static methods for specific flavor behaviour of {@link PaletteCreationBaseActivity}.
*/
/* package */
final class PaletteCreationActivityFlavor {
final class PaletteCreationBaseActivityFlavor {

/**
* Called when {@link PaletteCreationActivity#onCreate(Bundle)} is called.
* Called when {@link PaletteCreationBaseActivity#onCreate(Bundle)} is called.
* <p/>
* <b>Note</b> this should be the last methods called in {@link PaletteCreationActivity#onCreate(Bundle)}.
* <b>Note</b> this should be the last methods called in {@link PaletteCreationBaseActivity#onCreate(Bundle)}.
*
* @param activity the {@link PaletteCreationActivity}.
* @param activity the {@link PaletteCreationBaseActivity}.
*/
/* package */
static void onCreate(PaletteCreationActivity activity) {
static void onCreate(PaletteCreationBaseActivity activity) {
// nothing specific for the adult flavor.
}
}
19 changes: 17 additions & 2 deletions CameraColorPicker/app/src/adult/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@
<resources>
<!-- Delete color dialog fragment -->
<string name="fragment_dialog_delete_color_title">Attention</string>
<string name="fragment_dialog_delete_color_message">Supprimer la couleur de votre téléphone ?</string>
<string name="fragment_dialog_delete_color_message">Supprimer la couleur de votre téléphone ?
</string>

<!-- Delete palette dialog fragment -->
<string name="fragment_dialog_delete_palette_title">Attention</string>
<string name="fragment_dialog_delete_palette_message">Supprimer la palette %1$s de votre téléphone ?</string>
<string name="fragment_dialog_delete_palette_message">Supprimer la palette %1$s de votre
téléphone ?
</string>

<!-- Palette creation activity -->
<string name="activity_palette_creation_instruction">Pour ajouter des couleurs à votre
palette\ncliquez sur la liste en dessus.
</string>
<string name="activity_palette_creation_edit_text_dialog_fragment_title">Créez votre palette
</string>
<string name="activity_palette_creation_edit_text_dialog_fragment_hint">Ma nouvelle palette
</string>
<string name="activity_palette_creation_edit_text_dialog_fragment_positive_button">Créer
</string>

</resources>
15 changes: 14 additions & 1 deletion CameraColorPicker/app/src/adult/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,18 @@

<!-- Delete palette dialog fragment -->
<string name="fragment_dialog_delete_palette_title">Warning</string>
<string name="fragment_dialog_delete_palette_message">Delete the palette %1$s from your phone?</string>
<string name="fragment_dialog_delete_palette_message">Delete the palette %1$s from your phone?
</string>

<!-- Palette creation activity -->
<string name="activity_palette_creation_instruction">To add colors to your palette\nsimply click
on the list bellow.
</string>
<string name="activity_palette_creation_edit_text_dialog_fragment_title">Create your palette
</string>
<string name="activity_palette_creation_edit_text_dialog_fragment_hint">My new awesome palette
</string>
<string name="activity_palette_creation_edit_text_dialog_fragment_positive_button">Create
</string>

</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package fr.tvbarthel.apps.cameracolorpicker.activities;

import fr.tvbarthel.apps.cameracolorpicker.R;
import fr.tvbarthel.apps.cameracolorpicker.data.Palette;
import fr.tvbarthel.apps.cameracolorpicker.data.Palettes;
import fr.tvbarthel.apps.cameracolorpicker.views.PaletteMakerView;

/**
* The flavor implementation of {@link PaletteCreationBaseActivity}.
*
* In the kids version, a default name is used.
*/
public class PaletteCreationActivity extends PaletteCreationBaseActivity {

@Override
protected void createPalette(PaletteMakerView paletteMakerView) {
final Palette newPalette = paletteMakerView.make(getString(R.string.activity_palette_creation_default_palette_name, System.currentTimeMillis()));
if (Palettes.saveColorPalette(this, newPalette)) {
finish();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
import android.os.Bundle;

/**
* Static methods for specific flavor behaviour of {@link PaletteCreationActivity}.
* Static methods for specific flavor behaviour of {@link PaletteCreationBaseActivity}.
*/
/* package */
final class PaletteCreationActivityFlavor {
final class PaletteCreationBaseActivityFlavor {

/**
* Called when {@link PaletteCreationActivity#onCreate(Bundle)} is called.
* Called when {@link PaletteCreationBaseActivity#onCreate(Bundle)} is called.
* <p/>
* <b>Note</b> this should be the last methods called in {@link PaletteCreationActivity#onCreate(Bundle)}.
* <b>Note</b> this should be the last methods called in {@link PaletteCreationBaseActivity#onCreate(Bundle)}.
*
* @param activity the {@link PaletteCreationActivity}.
* @param activity the {@link PaletteCreationBaseActivity}.
*/
/* package */
static void onCreate(PaletteCreationActivity activity) {
static void onCreate(PaletteCreationBaseActivity activity) {
// For the kid version, set the title to null.
//noinspection ConstantConditions
activity.getSupportActionBar().setTitle(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<merge 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">

<ImageView
android:id="@+id/activity_palette_creation_instruction"
android:layout_width="match_parent"
android:layout_height="150dp"
android:alpha="0.3"
android:padding="@dimen/default_padding"
android:scaleType="centerInside"
android:src="@drawable/drop_sad" />

<fr.tvbarthel.apps.cameracolorpicker.views.PaletteMakerView
android:id="@+id/activity_palette_creation_color_palette_builder"
android:layout_width="match_parent"
android:layout_height="150dp" />

<FrameLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="@android:color/transparent">

<ImageButton
android:id="@+id/activity_palette_creation_remove_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|top"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="8dp"
android:src="@drawable/ic_action_delete" />

</FrameLayout>

<View
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_marginTop="150dp"
android:background="@drawable/linear_gradient_bottom" />

<android.support.v7.widget.RecyclerView
android:id="@+id/activity_palette_creation_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="150dp"
tools:listitem="@layout/row_color_item" />

<com.melnykov.fab.FloatingActionButton
android:id="@+id/activity_palette_creation_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="@drawable/ic_check_white"
app:fab_colorNormal="@color/color_accent"
app:fab_colorPressed="@color/color_accent"
app:fab_colorRipple="?attr/colorControlHighlight" />

</merge>
3 changes: 3 additions & 0 deletions CameraColorPicker/app/src/kids/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
<resources>
<string name="app_name">Kids Camera Color Picker</string>
<string name="activity_main_error_not_enough_colors"></string>

<!-- Palette creation activity -->
<string name="activity_palette_creation_default_palette_name">Palette %d</string>
</resources>
3 changes: 3 additions & 0 deletions CameraColorPicker/app/src/kids/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
<resources>
<string name="app_name">Kids Camera Color Picker</string>
<string name="activity_main_error_not_enough_colors"></string>

<!-- Palette creation activity -->
<string name="activity_palette_creation_default_palette_name">Palette %d</string>
</resources>

This file was deleted.

0 comments on commit 9eda833

Please sign in to comment.