############################################################################
#
# Copyright (c) 2012 - dsixda (dislam@rocketmail.com)
#
# Android Kitchen is 100% free.  This script file is intended for personal
# and/or educational use only.  It may not be duplicated for monetary
# benefit or any other purpose without the permission of the developer.
#
############################################################################

clear

if [ -d WORKING_* ]
then
  echo "Found working folder"
else
  echo "No working folder found!"
  exit 0
fi

clear
cd WORKING_*

if [ ! -e system/build.prop ]
then
  echo "Error: Cannot find build.prop"
  cd ..
  exit 0
fi

cd system

echo

if [ `grep -c ro.product.version build.prop` == 0 ]
then
  id_var=ro.build.display.id
else
  id_var=ro.product.version
fi


cd ../..
current_name=`scripts/get_build_prop_val $id_var`

if [ "$current_name" == "UNKNOWN" ]
then

  echo "Error: Cannot find $id_var in build.prop"
  cd ../..
  exit 0
fi


echo
echo "The current name of the ROM is:"
echo
echo "$current_name"
echo
echo
echo -n "Would you like to rename it (y/n)? (default: y): "

read do_rename
echo

if [ "$do_rename" == "n" ]
then
  echo "OK, nothing will be changed"

else 

  echo -n "Please enter the new name: "
  read new_name

  if [ "$new_name" == "" ]
  then
    echo
    echo "Error: Invalid name"
  else

    scripts/set_build_prop_val $id_var "$new_name"
    current_name=`scripts/get_build_prop_val $id_var`

    echo
    echo
    echo "In build.prop, $id_var is now set to:"
    echo
    echo "$current_name"

    if [ "$current_name" != "$new_name" ]
    then
      echo
      echo "Warning: Name is not the same as specified"
    fi
  fi

fi

echo

