def restart_app(show_log=False): """ Restart the app (for rooted devices) or bring the app to the front (for non-rooted devices) with the current version. Show logcat output if 'show_log' is true. """ if is_device_rooted(): # Stopping an app is not possible on non-rooted devices stop_cmd = [adb_path(), "shell", "am", "force-stop", package_name()] subprocess.call(stop_cmd) start_cmd = [adb_path(), "shell", "am", "start", "-n", "%s/org.kde.necessitas.origo.QtActivity" % package_name()] subprocess.call(start_cmd) if show_log: log_cmd = [adb_path(), "shell", "logcat"] clear_log_cmd = log_cmd + ["-c"] try: subprocess.call(clear_log_cmd) subprocess.call(log_cmd) except KeyboardInterrupt: sys.exit(0)
def rename_project(new_name, new_domain): """ Renames all directories and files to the new name and domain and adapts the code accordingly. """ old_project_dir = project_dir() new_project_dir = os.path.join(os.path.dirname(project_dir()), new_name) new_package_name = '.'.join([new_domain, new_name]) shutil.move("%s.pro" % app_name(), "%s.pro" % new_name) files = [ "main.h", "android/src/org/kde/necessitas/origo/QtActivity.java", "android/AndroidManifest.xml" ] for fn in files: python_sed(package_name(), new_package_name, fn) files = [ "%s.pro" % new_name, "android/AndroidManifest.xml", "android/res/values/strings.xml", "android/build.xml", "main.h" ] for fn in files: python_sed(app_name(), new_name, fn) shutil.move(old_project_dir, new_project_dir) os.chdir(new_project_dir) conf = ConfigParser.ConfigParser() conf.read(naming_config_file()) conf.set("General", "app_name", new_name) conf.set("General", "package_name", new_package_name) with file(naming_config_file(), "w") as fobj: conf.write(fobj)
def rename_project(new_name, new_domain): """ Renames all directories and files to the new name and domain and adapts the code accordingly. """ old_project_dir = project_dir() new_project_dir = os.path.join(os.path.dirname(project_dir()), new_name) new_package_name = '.'.join([new_domain, new_name]) shutil.move("%s.pro" % app_name(), "%s.pro" % new_name) files = ["main.h", "android/src/org/kde/necessitas/origo/QtActivity.java", "android/AndroidManifest.xml"] for fn in files: python_sed(package_name(), new_package_name, fn) files = ["%s.pro" % new_name, "android/AndroidManifest.xml", "android/res/values/strings.xml", "android/build.xml", "main.h"] for fn in files: python_sed(app_name(), new_name, fn) shutil.move(old_project_dir, new_project_dir) os.chdir(new_project_dir) conf = ConfigParser.ConfigParser() conf.read(naming_config_file()) conf.set("General", "app_name", new_name) conf.set("General", "package_name", new_package_name) with file(naming_config_file(), "w") as fobj: conf.write(fobj)