Dake Gu | 1585785 | 2015-09-04 15:25:49 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # Copyright (C) 2015 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | import os |
| 18 | import sys |
| 19 | |
Dake Gu | 48b4a13 | 2015-09-29 15:32:42 -0700 | [diff] [blame] | 20 | def write_java_head(tofile, name): |
| 21 | tofile.write("/* This file is auto-generated from {}.java. DO NOT MODIFY. */\n\n".format(name)) |
| 22 | |
| 23 | def replace_xml_head(line, name): |
| 24 | return line.replace('<?xml version="1.0" encoding="utf-8"?>', '<?xml version="1.0" encoding="utf-8"?>\n<!-- This file is auto-generated from {}.xml. DO NOT MODIFY. -->\n'.format(name)) |
| 25 | |
Dake Gu | 1585785 | 2015-09-04 15:25:49 -0700 | [diff] [blame] | 26 | file = open('src/com/example/android/leanback/GuidedStepActivity.java', 'r') |
| 27 | outfile = open('src/com/example/android/leanback/GuidedStepSupportActivity.java', 'w') |
Dake Gu | 48b4a13 | 2015-09-29 15:32:42 -0700 | [diff] [blame] | 28 | write_java_head(outfile, "GuidedStepActivity") |
Dake Gu | 1585785 | 2015-09-04 15:25:49 -0700 | [diff] [blame] | 29 | for line in file: |
| 30 | line = line.replace('android.app.Fragment', 'android.support.v4.app.Fragment') |
| 31 | line = line.replace('android.app.Activity', 'android.support.v4.app.FragmentActivity') |
| 32 | line = line.replace('GuidedStepFragment', 'GuidedStepSupportFragment') |
| 33 | line = line.replace('GuidedStepActivity', 'GuidedStepSupportActivity') |
| 34 | line = line.replace('extends Activity', 'extends FragmentActivity') |
Dake Gu | 1585785 | 2015-09-04 15:25:49 -0700 | [diff] [blame] | 35 | outfile.write(line) |
| 36 | file.close() |
| 37 | outfile.close() |
Dake Gu | 48b4a13 | 2015-09-29 15:32:42 -0700 | [diff] [blame] | 38 | |
| 39 | file = open('src/com/example/android/leanback/BrowseFragment.java', 'r') |
| 40 | outfile = open('src/com/example/android/leanback/BrowseSupportFragment.java', 'w') |
| 41 | write_java_head(outfile, "BrowseFragment") |
| 42 | for line in file: |
| 43 | line = line.replace('android.app.Fragment', 'android.support.v4.app.Fragment') |
| 44 | line = line.replace('android.app.Activity', 'android.support.v4.app.FragmentActivity') |
| 45 | line = line.replace('BrowseFragment', 'BrowseSupportFragment') |
| 46 | line = line.replace('GuidedStepFragment', 'GuidedStepSupportFragment') |
| 47 | line = line.replace('GuidedStepActivity', 'GuidedStepSupportActivity') |
| 48 | line = line.replace('BrowseActivity', 'BrowseSupportActivity') |
| 49 | line = line.replace('DetailsActivity', 'DetailsSupportActivity') |
| 50 | line = line.replace('SearchActivity', 'SearchSupportActivity') |
| 51 | line = line.replace('RowsActivity', 'RowsSupportActivity') |
| 52 | outfile.write(line) |
| 53 | file.close() |
| 54 | outfile.close() |
| 55 | |
| 56 | file = open('src/com/example/android/leanback/BrowseActivity.java', 'r') |
| 57 | outfile = open('src/com/example/android/leanback/BrowseSupportActivity.java', 'w') |
| 58 | write_java_head(outfile, "BrowseActivity") |
| 59 | for line in file: |
| 60 | line = line.replace('BrowseActivity', 'BrowseSupportActivity') |
| 61 | line = line.replace('android.app.Activity', 'android.support.v4.app.FragmentActivity') |
| 62 | line = line.replace('extends Activity', 'extends FragmentActivity') |
| 63 | line = line.replace('R.layout.browse', 'R.layout.browse_support') |
| 64 | outfile.write(line) |
| 65 | file.close() |
| 66 | outfile.close() |
| 67 | |
| 68 | file = open('res/layout/browse.xml', 'r') |
| 69 | outfile = open('res/layout/browse_support.xml', 'w') |
| 70 | for line in file: |
| 71 | line = replace_xml_head(line, "browse") |
| 72 | line = line.replace('com.example.android.leanback.BrowseFragment', 'com.example.android.leanback.BrowseSupportFragment') |
| 73 | outfile.write(line) |
| 74 | file.close() |
| 75 | outfile.close() |
| 76 | |
| 77 | |
| 78 | file = open('src/com/example/android/leanback/DetailsFragment.java', 'r') |
| 79 | outfile = open('src/com/example/android/leanback/DetailsSupportFragment.java', 'w') |
| 80 | write_java_head(outfile, "DetailsFragment") |
| 81 | for line in file: |
| 82 | line = line.replace('android.app.Fragment', 'android.support.v4.app.Fragment') |
| 83 | line = line.replace('android.app.Activity', 'android.support.v4.app.FragmentActivity') |
| 84 | line = line.replace('DetailsFragment', 'DetailsSupportFragment') |
| 85 | line = line.replace('DetailsActivity', 'DetailsSupportActivity') |
Dake Gu | c7e4f19 | 2015-09-30 13:41:45 -0700 | [diff] [blame] | 86 | line = line.replace('PlaybackOverlayActivity', 'PlaybackOverlaySupportActivity') |
Dake Gu | 48b4a13 | 2015-09-29 15:32:42 -0700 | [diff] [blame] | 87 | line = line.replace('SearchActivity', 'SearchSupportActivity') |
| 88 | outfile.write(line) |
| 89 | file.close() |
| 90 | outfile.close() |
| 91 | |
| 92 | file = open('src/com/example/android/leanback/NewDetailsFragment.java', 'r') |
| 93 | outfile = open('src/com/example/android/leanback/NewDetailsSupportFragment.java', 'w') |
| 94 | write_java_head(outfile, "NewDetailsFragment") |
| 95 | for line in file: |
| 96 | line = line.replace('android.app.Fragment', 'android.support.v4.app.Fragment') |
| 97 | line = line.replace('android.app.Activity', 'android.support.v4.app.FragmentActivity') |
| 98 | line = line.replace('DetailsFragment', 'DetailsSupportFragment') |
| 99 | line = line.replace('DetailsActivity', 'DetailsSupportActivity') |
Dake Gu | c7e4f19 | 2015-09-30 13:41:45 -0700 | [diff] [blame] | 100 | line = line.replace('PlaybackOverlayActivity', 'PlaybackOverlaySupportActivity') |
Dake Gu | 48b4a13 | 2015-09-29 15:32:42 -0700 | [diff] [blame] | 101 | line = line.replace('SearchActivity', 'SearchSupportActivity') |
| 102 | outfile.write(line) |
| 103 | file.close() |
| 104 | outfile.close() |
| 105 | |
| 106 | file = open('src/com/example/android/leanback/DetailsActivity.java', 'r') |
| 107 | outfile = open('src/com/example/android/leanback/DetailsSupportActivity.java', 'w') |
| 108 | write_java_head(outfile, "DetailsActivity") |
| 109 | for line in file: |
| 110 | line = line.replace('DetailsActivity', 'DetailsSupportActivity') |
| 111 | line = line.replace('android.app.Activity', 'android.support.v4.app.FragmentActivity') |
| 112 | line = line.replace('extends Activity', 'extends FragmentActivity') |
| 113 | line = line.replace('R.layout.details', 'R.layout.details_support') |
| 114 | line = line.replace('R.layout.legacy_details', 'R.layout.legacy_details_support') |
| 115 | line = line.replace('getFragmentManager()', 'getSupportFragmentManager()') |
| 116 | line = line.replace('DetailsFragment', 'DetailsSupportFragment') |
| 117 | line = line.replace('NewDetailsFragment', 'NewDetailsSupportFragment') |
| 118 | outfile.write(line) |
| 119 | file.close() |
| 120 | outfile.close() |
| 121 | |
| 122 | file = open('res/layout/details.xml', 'r') |
| 123 | outfile = open('res/layout/details_support.xml', 'w') |
| 124 | for line in file: |
| 125 | line = replace_xml_head(line, "details") |
| 126 | line = line.replace('com.example.android.leanback.NewDetailsFragment', 'com.example.android.leanback.NewDetailsSupportFragment') |
| 127 | outfile.write(line) |
| 128 | file.close() |
| 129 | outfile.close() |
| 130 | |
| 131 | |
| 132 | file = open('res/layout/legacy_details.xml', 'r') |
| 133 | outfile = open('res/layout/legacy_details_support.xml', 'w') |
| 134 | for line in file: |
| 135 | line = replace_xml_head(line, "legacy_details") |
| 136 | line = line.replace('com.example.android.leanback.DetailsFragment', 'com.example.android.leanback.DetailsSupportFragment') |
| 137 | outfile.write(line) |
| 138 | file.close() |
| 139 | outfile.close() |
| 140 | |
| 141 | |
| 142 | file = open('src/com/example/android/leanback/SearchDetailsActivity.java', 'r') |
| 143 | outfile = open('src/com/example/android/leanback/SearchDetailsSupportActivity.java', 'w') |
| 144 | write_java_head(outfile, "SearchDetailsActivity") |
| 145 | for line in file: |
| 146 | line = line.replace('DetailsActivity', 'DetailsSupportActivity') |
| 147 | outfile.write(line) |
| 148 | file.close() |
| 149 | outfile.close() |
| 150 | |
| 151 | |
| 152 | file = open('src/com/example/android/leanback/SearchFragment.java', 'r') |
| 153 | outfile = open('src/com/example/android/leanback/SearchSupportFragment.java', 'w') |
| 154 | write_java_head(outfile, "SearchFragment") |
| 155 | for line in file: |
| 156 | line = line.replace('SearchFragment', 'SearchSupportFragment') |
| 157 | line = line.replace('DetailsActivity', 'DetailsSupportActivity') |
| 158 | outfile.write(line) |
| 159 | file.close() |
| 160 | outfile.close() |
| 161 | |
| 162 | file = open('src/com/example/android/leanback/SearchActivity.java', 'r') |
| 163 | outfile = open('src/com/example/android/leanback/SearchSupportActivity.java', 'w') |
| 164 | write_java_head(outfile, "SearchActivity") |
| 165 | for line in file: |
| 166 | line = line.replace('SearchActivity', 'SearchSupportActivity') |
| 167 | line = line.replace('extends Activity', 'extends FragmentActivity') |
| 168 | line = line.replace('R.layout.search', 'R.layout.search_support') |
| 169 | line = line.replace('android.app.Activity', 'android.support.v4.app.FragmentActivity') |
| 170 | line = line.replace('getFragmentManager()', 'getSupportFragmentManager()') |
| 171 | line = line.replace('SearchFragment', 'SearchSupportFragment') |
| 172 | outfile.write(line) |
| 173 | file.close() |
| 174 | outfile.close() |
| 175 | |
| 176 | file = open('res/layout/search.xml', 'r') |
| 177 | outfile = open('res/layout/search_support.xml', 'w') |
| 178 | for line in file: |
| 179 | line = replace_xml_head(line, "search") |
| 180 | line = line.replace('com.example.android.leanback.SearchFragment', 'com.example.android.leanback.SearchSupportFragment') |
| 181 | outfile.write(line) |
| 182 | file.close() |
| 183 | outfile.close() |
| 184 | |
| 185 | file = open('src/com/example/android/leanback/VerticalGridFragment.java', 'r') |
| 186 | outfile = open('src/com/example/android/leanback/VerticalGridSupportFragment.java', 'w') |
| 187 | outfile.write("/* This file is auto-generated from VerticalGridFragment. DO NOT MODIFY. */\n\n") |
| 188 | for line in file: |
| 189 | line = line.replace('VerticalGridFragment', 'VerticalGridSupportFragment') |
| 190 | line = line.replace('DetailsActivity', 'DetailsSupportActivity') |
| 191 | line = line.replace('SearchActivity', 'SearchSupportActivity') |
| 192 | outfile.write(line) |
| 193 | file.close() |
| 194 | outfile.close() |
| 195 | |
| 196 | file = open('src/com/example/android/leanback/VerticalGridActivity.java', 'r') |
| 197 | outfile = open('src/com/example/android/leanback/VerticalGridSupportActivity.java', 'w') |
| 198 | write_java_head(outfile, "VerticalGridActivity") |
| 199 | for line in file: |
| 200 | line = line.replace('VerticalGridActivity', 'VerticalGridSupportActivity') |
| 201 | line = line.replace('extends Activity', 'extends FragmentActivity') |
| 202 | line = line.replace('R.layout.vertical_grid', 'R.layout.vertical_grid_support') |
| 203 | line = line.replace('android.app.Activity', 'android.support.v4.app.FragmentActivity') |
| 204 | line = line.replace('getFragmentManager()', 'getSupportFragmentManager()') |
| 205 | line = line.replace('VerticalGridFragment', 'VerticalGridSupportFragment') |
| 206 | outfile.write(line) |
| 207 | file.close() |
| 208 | outfile.close() |
| 209 | |
| 210 | file = open('res/layout/vertical_grid.xml', 'r') |
| 211 | outfile = open('res/layout/vertical_grid_support.xml', 'w') |
| 212 | for line in file: |
| 213 | line = replace_xml_head(line, "vertical_grid") |
| 214 | line = line.replace('com.example.android.leanback.VerticalGridFragment', 'com.example.android.leanback.VerticalGridSupportFragment') |
| 215 | outfile.write(line) |
| 216 | file.close() |
| 217 | outfile.close() |
| 218 | |
| 219 | |
| 220 | file = open('src/com/example/android/leanback/ErrorFragment.java', 'r') |
| 221 | outfile = open('src/com/example/android/leanback/ErrorSupportFragment.java', 'w') |
| 222 | write_java_head(outfile, "ErrorFragment") |
| 223 | for line in file: |
| 224 | line = line.replace('ErrorFragment', 'ErrorSupportFragment') |
| 225 | outfile.write(line) |
| 226 | file.close() |
| 227 | outfile.close() |
| 228 | |
| 229 | file = open('src/com/example/android/leanback/BrowseErrorActivity.java', 'r') |
| 230 | outfile = open('src/com/example/android/leanback/BrowseErrorSupportActivity.java', 'w') |
| 231 | write_java_head(outfile, "BrowseErrorActivity") |
| 232 | for line in file: |
| 233 | line = line.replace('BrowseErrorActivity', 'BrowseErrorSupportActivity') |
| 234 | line = line.replace('extends Activity', 'extends FragmentActivity') |
| 235 | line = line.replace('R.layout.browse', 'R.layout.browse_support') |
| 236 | line = line.replace('android.app.Activity', 'android.support.v4.app.FragmentActivity') |
| 237 | line = line.replace('getFragmentManager()', 'getSupportFragmentManager()') |
| 238 | line = line.replace('ErrorFragment', 'ErrorSupportFragment') |
| 239 | line = line.replace('SpinnerFragment', 'SpinnerSupportFragment') |
| 240 | line = line.replace('android.app.Fragment', 'android.support.v4.app.Fragment') |
| 241 | outfile.write(line) |
| 242 | file.close() |
| 243 | outfile.close() |
| 244 | |
| 245 | file = open('src/com/example/android/leanback/RowsFragment.java', 'r') |
| 246 | outfile = open('src/com/example/android/leanback/RowsSupportFragment.java', 'w') |
| 247 | write_java_head(outfile, "RowsFragment") |
| 248 | for line in file: |
| 249 | line = line.replace('RowsFragment', 'RowsSupportFragment') |
| 250 | line = line.replace('DetailsActivity', 'DetailsSupportActivity') |
| 251 | outfile.write(line) |
| 252 | file.close() |
| 253 | outfile.close() |
| 254 | |
| 255 | file = open('src/com/example/android/leanback/RowsActivity.java', 'r') |
| 256 | outfile = open('src/com/example/android/leanback/RowsSupportActivity.java', 'w') |
| 257 | write_java_head(outfile, "RowsActivity") |
| 258 | for line in file: |
| 259 | line = line.replace('RowsActivity', 'RowsSupportActivity') |
| 260 | line = line.replace('extends Activity', 'extends FragmentActivity') |
| 261 | line = line.replace('R.layout.rows', 'R.layout.rows_support') |
| 262 | line = line.replace('android.app.Activity', 'android.support.v4.app.FragmentActivity') |
| 263 | line = line.replace('RowsFragment', 'RowsSupportFragment') |
| 264 | line = line.replace('getFragmentManager()', 'getSupportFragmentManager()') |
| 265 | line = line.replace('SearchActivity', 'SearchSupportActivity') |
| 266 | outfile.write(line) |
| 267 | file.close() |
| 268 | outfile.close() |
| 269 | |
| 270 | file = open('res/layout/rows.xml', 'r') |
| 271 | outfile = open('res/layout/rows_support.xml', 'w') |
| 272 | for line in file: |
| 273 | line = replace_xml_head(line, "rows") |
| 274 | line = line.replace('com.example.android.leanback.RowsFragment', 'com.example.android.leanback.RowsSupportFragment') |
| 275 | outfile.write(line) |
| 276 | file.close() |
| 277 | outfile.close() |
| 278 | |
Dake Gu | c7e4f19 | 2015-09-30 13:41:45 -0700 | [diff] [blame] | 279 | |
| 280 | file = open('src/com/example/android/leanback/PlaybackOverlayFragment.java', 'r') |
| 281 | outfile = open('src/com/example/android/leanback/PlaybackOverlaySupportFragment.java', 'w') |
| 282 | write_java_head(outfile, "PlaybackOverlayFragment") |
| 283 | for line in file: |
| 284 | line = line.replace('PlaybackOverlayFragment', 'PlaybackOverlaySupportFragment') |
| 285 | line = line.replace('PlaybackControlHelper', 'PlaybackControlSupportHelper') |
| 286 | outfile.write(line) |
| 287 | file.close() |
| 288 | outfile.close() |
| 289 | |
| 290 | file = open('src/com/example/android/leanback/PlaybackControlHelper.java', 'r') |
| 291 | outfile = open('src/com/example/android/leanback/PlaybackControlSupportHelper.java', 'w') |
| 292 | write_java_head(outfile, "PlaybackControlHelper") |
| 293 | for line in file: |
| 294 | line = line.replace('PlaybackControlHelper', 'PlaybackControlSupportHelper') |
| 295 | line = line.replace('PlaybackControlGlue', 'PlaybackControlSupportGlue') |
| 296 | line = line.replace('PlaybackOverlayFragment', 'PlaybackOverlaySupportFragment') |
| 297 | outfile.write(line) |
| 298 | file.close() |
| 299 | outfile.close() |
| 300 | |
| 301 | file = open('src/com/example/android/leanback/PlaybackOverlayActivity.java', 'r') |
| 302 | outfile = open('src/com/example/android/leanback/PlaybackOverlaySupportActivity.java', 'w') |
| 303 | write_java_head(outfile, "PlaybackOverlayActivity") |
| 304 | for line in file: |
| 305 | line = line.replace('PlaybackOverlayActivity', 'PlaybackOverlaySupportActivity') |
| 306 | line = line.replace('extends Activity', 'extends FragmentActivity') |
| 307 | line = line.replace('R.layout.playback_controls', 'R.layout.playback_controls_support') |
| 308 | line = line.replace('android.app.Activity', 'android.support.v4.app.FragmentActivity') |
| 309 | outfile.write(line) |
| 310 | file.close() |
| 311 | outfile.close() |
| 312 | |
| 313 | file = open('res/layout/playback_controls.xml', 'r') |
| 314 | outfile = open('res/layout/playback_controls_support.xml', 'w') |
| 315 | for line in file: |
| 316 | line = replace_xml_head(line, "playback_controls") |
| 317 | line = line.replace('com.example.android.leanback.PlaybackOverlayFragment', 'com.example.android.leanback.PlaybackOverlaySupportFragment') |
| 318 | outfile.write(line) |
| 319 | file.close() |
| 320 | outfile.close() |