diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java index c527ed5f..e5d6ac6d 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java @@ -299,16 +299,19 @@ public class DoricDevActivity extends AppCompatActivity implements DoricDev.Stat holder.layoutBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - final String[] items = DoricDev.getInstance().isInDevMode() - ? new String[]{"View source",} - : new String[]{"View source",}; + ArrayList list = new ArrayList<>(); + list.add("View source"); + if (context.getDriver() instanceof DoricDebugDriver) { + list.add("Stop debugging"); + } + final String[] items = list.toArray(new String[0]); AlertDialog.Builder builder = new AlertDialog.Builder(holder.itemView.getContext(), R.style.Theme_Doric_Modal); builder.setTitle(String.format("%s %s", context.getContextId(), context.getSource())); builder.setIcon(new BitmapDrawable(holder.itemView.getContext().getResources(), icon_on)); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if (which == 0) { + if ("View source".equals(items[which])) { AlertDialog.Builder builder = new AlertDialog.Builder(holder.itemView.getContext(), R.style.Theme_Doric_Modal_Alert); builder.setTitle(String.format(Locale.getDefault(), "View source: %s", @@ -328,6 +331,8 @@ public class DoricDevActivity extends AppCompatActivity implements DoricDev.Stat }); builder.setCancelable(false); builder.show(); + } else if ("Stop debugging".equals(items[which])) { + DoricDev.getInstance().stopDebugging(true); } dialog.dismiss(); } diff --git a/doric-iOS/Devkit/Classes/DoricDevViewController.m b/doric-iOS/Devkit/Classes/DoricDevViewController.m index 6b5a514b..4dfd270c 100644 --- a/doric-iOS/Devkit/Classes/DoricDevViewController.m +++ b/doric-iOS/Devkit/Classes/DoricDevViewController.m @@ -105,6 +105,13 @@ - (void)onClick { }]; [alertController addAction:cancel]; [alertController addAction:viewSource]; + if ([self.doricContext.driver isKindOfClass:DoricDebugDriver.class]) { + UIAlertAction *stopDebugging = [UIAlertAction actionWithTitle:@"Stop debugging" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_) { + [DoricDev.instance stopDebugging:YES]; + }]; + [alertController addAction:stopDebugging]; + } + [self.vc presentViewController:alertController animated:true completion:nil]; } @end @@ -311,11 +318,15 @@ - (UIImage *)decodeImage:(BOOL)on { return [UIImage imageWithData:imageData]; } -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { +- (NSInteger)tableView:(UITableView *)tableView + numberOfRowsInSection: + (NSInteger)section { return [DoricContextManager.instance aliveContexts].count; } -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { +- (UITableViewCell *)tableView:(UITableView *)tableView + cellForRowAtIndexPath: + (NSIndexPath *)indexPath { DoricContextCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; if (cell == nil) { cell = [[DoricContextCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; @@ -351,7 +362,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N return cell; } -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { +- (CGFloat) tableView:(UITableView *)tableView +heightForRowAtIndexPath: + (NSIndexPath *)indexPath { return 60.f; } @@ -375,7 +388,9 @@ - (void)onFailure:(NSError *)error { [self.listView reloadData]; } -- (void)onReload:(DoricContext *)context script:(NSString *)script { +- (void)onReload:(DoricContext *)context + script: + (NSString *)script { [self.listView reloadData]; }