〖Android〗依據資源資訊,Mock Android資源

來源:互聯網
上載者:User

標籤:android   des   style   blog   http   color   io   for   

 1 #!/bin/bash -  2 #=============================================================================== 3 # 4 #          FILE: mock_res.sh 5 #  6 #         USAGE: ./mock_res.sh  7 #  8 #   DESCRIPTION:  9 # 10 #       OPTIONS: ---11 #  REQUIREMENTS: ---12 #          BUGS: ---13 #         NOTES: ---14 #        AUTHOR: linkscue (scue), [email protected]15 #  ORGANIZATION: 16 #       CREATED: 2014年08月06日 20時37分46秒 CST17 #      REVISION:  ---18 #===============================================================================19 20 # 傳入參數21 # $1: Mock程式目錄 android create project..22 # $2: Mock資源類型 如 style/AppMyTheme string/app_name_emm ..23 android_res_mock(){24     dir=$125     res=$226     restype=$(echo $res|awk -F‘/‘ ‘{print $1}‘)27     echo "正在處理 $res"28     case $restype in29         xml )30             # TODO: cp31             path=$dir/res/${res}.xml32             mkdir -p $(dirname $path)33             cp ./empty_xml.xml $path34             ;;35         drawable )36             # TODO: touch37             path=$dir/res/${res}.png38             mkdir -p $(dirname $path)39             touch $path40             ;;41         string )42             # TODO: sed -i43             path=$dir/res/values/strings.xml44             mkdir -p $(dirname $path)45             string_name=$(echo $res|awk -F‘/‘ ‘{print $2}‘)46             string_model=‘    <string name="mock_string_modol">mock_string_modol</string>‘47             string_model_file=/tmp/mock_string_model.txt48             string_empty_file=./empty_strings.xml # TODO: 絕對路徑49             echo "$string_model" >$string_model_file50             sed -i "s/mock_string_modol/$string_name/g" $string_model_file51             test ! -e $path && cp $string_empty_file $path52             grep -qF \"$string_name\" $path || sed -i "2 r $string_model_file" $path53             rm -f $string_model_file54             ;;55         style )56             # TODO: sed -i57             path=$dir/res/values/styles.xml58             mkdir -p $(dirname $path)59             style_name=$(echo $res|awk -F‘/‘ ‘{print $2}‘)60             style_model=‘    <style name="MOCK_Style_Model" parent="android:Theme.Light"></style>‘61             style_model_file=/tmp/mock_style_model.txt62             style_empty_file=./empty_styles.xml63             echo "$style_model" >$style_model_file64             sed -i "s/MOCK_Style_Model/$style_name/g" $style_model_file65             test ! -e $path && cp $style_empty_file $path66             grep -qF \"$style_name\" $path || sed -i "1 r $style_model_file" $path67             rm -f $style_model_file68             ;;69         * )70             err "未知資源類型,請反饋給 [email protected]"71             exit 172     esac73 }74 75 # 調用方法76 for i in $(cat ./res_list.txt); do77     android_res_mock ./app $i78 done

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.