Android Open Source - sdl_tester_android Show Dialog






From Project

Back to project page sdl_tester_android.

License

The source code is released under:

Copyright (c) 2014, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are m...

If you think the Android project sdl_tester_android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.livio.sdltester.dialogs;
//from w  w  w. j  av  a2  s  .  c  om
import java.util.List;
import java.util.Vector;

import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

import com.livio.sdl.SdlImageItem;
import com.livio.sdl.SdlRequestFactory;
import com.livio.sdl.dialogs.BaseAlertDialog;
import com.livio.sdl.dialogs.BaseOkCancelDialog;
import com.livio.sdl.dialogs.ImageListDialog;
import com.livio.sdl.enums.SdlCommand;
import com.livio.sdl.enums.SdlTextAlignment;
import com.livio.sdl.utils.AndroidUtils;
import com.livio.sdltester.R;
import com.smartdevicelink.proxy.rpc.Show;
import com.smartdevicelink.proxy.rpc.SoftButton;
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;

public class ShowDialog extends BaseOkCancelDialog{

  private static final SdlCommand SYNC_COMMAND = SdlCommand.SHOW;
  private static final String DIALOG_TITLE = SYNC_COMMAND.toString();

  private CheckBox check_show1, check_show2, check_show3, check_show4, check_statusBar, check_imageName, check_softButtons;
  private EditText et_show1, et_show2, et_show3, et_show4, et_statusBar, et_imageName;
  private Spinner spin_textAlignment;
  private SdlImageItem selectedImage;
  private List<SoftButton> softButtons;
  
  public ShowDialog(final Context context, final List<SdlImageItem> images){
    super(context, DIALOG_TITLE, R.layout.show);
    setPositiveButton(okButtonListener);
    
    if(images == null || images.size() <= 0){
      check_imageName.setVisibility(View.GONE);
      et_imageName.setVisibility(View.GONE);
    }
    
    check_imageName.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if(isChecked){
          if(images == null || images.size() <= 0){
            Toast.makeText(context, "No images have been added to the system yet.", Toast.LENGTH_LONG).show();
          }
          else{
            BaseAlertDialog selectImageDialog = new ImageListDialog(context, images);
            selectImageDialog.setListener(new BaseAlertDialog.Listener() {
              @Override
              public void onResult(Object resultData) {
                selectedImage = (SdlImageItem) resultData;
                et_imageName.setText(selectedImage.getImageName());
              }
            });
            selectImageDialog.show();
          }
        }
        else{
          et_imageName.setText("");
        }
      }
    });
    
    check_softButtons.setOnCheckedChangeListener(new OnCheckedChangeListener(){
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked){
                if(isChecked){
                    BaseAlertDialog softButtonDialog = new SoftButtonListDialog(context, images);
                    softButtonDialog.setListener(new BaseAlertDialog.Listener(){
                        @SuppressWarnings("unchecked")
                        @Override
                        public void onResult(Object resultData){
                            softButtons = (List<SoftButton>) resultData;
                        }
                    });
                    softButtonDialog.show();
                }
                else{
                    softButtons = null;
                }
            }
        });
    
    createDialog();
  }
  
  @Override
  protected void findViews(View view){
    check_show1 = (CheckBox) view.findViewById(R.id.check_show1);
    check_show1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        et_show1.setEnabled(isChecked);
      }
    });
    check_show2 = (CheckBox) view.findViewById(R.id.check_show2);
    check_show2.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        et_show2.setEnabled(isChecked);
      }
    });
    check_show3 = (CheckBox) view.findViewById(R.id.check_show3);
    check_show3.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        et_show3.setEnabled(isChecked);
      }
    });
    check_show4 = (CheckBox) view.findViewById(R.id.check_show4);
    check_show4.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        et_show4.setEnabled(isChecked);
      }
    });
    check_statusBar = (CheckBox) view.findViewById(R.id.check_statusBar);
    check_statusBar.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        et_statusBar.setEnabled(isChecked);
      }
    });
    check_imageName = (CheckBox) view.findViewById(R.id.check_enable_image);
    check_softButtons = (CheckBox) view.findViewById(R.id.cb_include_softbuttons);
    
    et_show1 = (EditText) view.findViewById(R.id.et_show1);
    et_show1.setEnabled(check_show1.isChecked());
    et_show2 = (EditText) view.findViewById(R.id.et_show2);
    et_show2.setEnabled(check_show2.isChecked());
    et_show3 = (EditText) view.findViewById(R.id.et_show3);
    et_show3.setEnabled(check_show3.isChecked());
    et_show4 = (EditText) view.findViewById(R.id.et_show4);
    et_show4.setEnabled(check_show4.isChecked());
    et_statusBar = (EditText) view.findViewById(R.id.et_statusBar);
    et_statusBar.setEnabled(check_statusBar.isChecked());
    et_imageName = (EditText) view.findViewById(R.id.et_show_image);
    
    
    spin_textAlignment = (Spinner) view.findViewById(R.id.spin_textAlignment);
    spin_textAlignment.setAdapter(AndroidUtils.createSpinnerAdapter(context, SdlTextAlignment.values()));
  }
  
  //dialog button listeners
  private final DialogInterface.OnClickListener okButtonListener = new DialogInterface.OnClickListener() {
    
    @Override
    public void onClick(DialogInterface dialog, int which) {
      String line1 = null, line2 = null, line3 = null, line4 = null, statusBar = null, imageName = null;
      TextAlignment alignment = null;
      
      if(et_show1.isEnabled()){
        line1 = et_show1.getText().toString();
      }
      
      if(et_show2.isEnabled()){
        line2 = et_show2.getText().toString();
      }
      
      if(et_show3.isEnabled()){
        line3 = et_show3.getText().toString();
      }
      
      if(et_show4.isEnabled()){
        line4 = et_show4.getText().toString();
      }
      
      if(et_statusBar.isEnabled()){
        statusBar = et_statusBar.getText().toString();
      }
      
      if(spin_textAlignment.getSelectedItemPosition() != 0){
        SdlTextAlignment sdlAlignment = (SdlTextAlignment) spin_textAlignment.getSelectedItem();
        alignment = SdlTextAlignment.translateToLegacy(sdlAlignment);
      }
      
      if(selectedImage != null){
        imageName = selectedImage.getImageName();
      }

      Show result = (Show) SdlRequestFactory.show(line1, line2, line3, line4, statusBar, alignment, imageName);
      if(softButtons != null && softButtons.size() > 0){
          result.setSoftButtons(new Vector<SoftButton>(softButtons));
      }
      notifyListener(result);
    }
  };
  
}




Java Source Code List

com.livio.sdl.IdGenerator.java
com.livio.sdl.IpAddress.java
com.livio.sdl.SdlConstants.java
com.livio.sdl.SdlImageItem.java
com.livio.sdl.SdlLogMessage.java
com.livio.sdl.SdlRequestFactory.java
com.livio.sdl.SdlResponseFactory.java
com.livio.sdl.SdlResponseTracker.java
com.livio.sdl.SdlService.java
com.livio.sdl.adapters.SdlImageAdapter.java
com.livio.sdl.adapters.SdlMessageAdapter.java
com.livio.sdl.dialogs.BaseAlertDialog.java
com.livio.sdl.dialogs.BaseImageListDialog.java
com.livio.sdl.dialogs.BaseMultipleListViewDialog.java
com.livio.sdl.dialogs.BaseOkCancelDialog.java
com.livio.sdl.dialogs.BaseSingleListViewDialog.java
com.livio.sdl.dialogs.ImageListDialog.java
com.livio.sdl.dialogs.IndeterminateProgressDialog.java
com.livio.sdl.dialogs.JsonFlipperDialog.java
com.livio.sdl.dialogs.ListViewDialog.java
com.livio.sdl.dialogs.MultipleListViewDialog.java
com.livio.sdl.dialogs.SingleJsonDialog.java
com.livio.sdl.dialogs.TextViewAlertDialog.java
com.livio.sdl.dialogs.TextViewOkCancelDialog.java
com.livio.sdl.enums.EnumClickListener.java
com.livio.sdl.enums.EnumComparator.java
com.livio.sdl.enums.SdlButton.java
com.livio.sdl.enums.SdlCommand.java
com.livio.sdl.enums.SdlImageType.java
com.livio.sdl.enums.SdlInteractionMode.java
com.livio.sdl.enums.SdlLanguage.java
com.livio.sdl.enums.SdlSpeechCapability.java
com.livio.sdl.enums.SdlSystemAction.java
com.livio.sdl.enums.SdlTextAlignment.java
com.livio.sdl.enums.SdlTransportType.java
com.livio.sdl.enums.SdlUpdateMode.java
com.livio.sdl.enums.SdlVehicleData.java
com.livio.sdl.menu.CommandButton.java
com.livio.sdl.menu.MenuItem.java
com.livio.sdl.menu.MenuManager.java
com.livio.sdl.menu.SubmenuButton.java
com.livio.sdl.utils.AndroidUtils.java
com.livio.sdl.utils.ApplicationPreferences.java
com.livio.sdl.utils.Counter.java
com.livio.sdl.utils.DownCounter.java
com.livio.sdl.utils.MathUtils.java
com.livio.sdl.utils.SdlUtils.java
com.livio.sdl.utils.StringUtils.java
com.livio.sdl.utils.Timeout.java
com.livio.sdl.utils.UpCounter.java
com.livio.sdl.utils.WifiUtils.java
com.livio.sdl.viewhelpers.MinMaxInputFilter.java
com.livio.sdl.viewhelpers.SeekBarCalculator.java
com.livio.sdltester.HelpActivity.java
com.livio.sdltester.LivioSdlTesterPreferences.java
com.livio.sdltester.MainActivity.java
com.livio.sdltester.SdlTesterImageResource.java
com.livio.sdltester.dialogs.AddCommandDialog.java
com.livio.sdltester.dialogs.AddSubMenuDialog.java
com.livio.sdltester.dialogs.ButtonSubscriptionDialog.java
com.livio.sdltester.dialogs.ButtonUnsubscriptionDialog.java
com.livio.sdltester.dialogs.ChangeRegistrationDialog.java
com.livio.sdltester.dialogs.ChoiceItemDialog.java
com.livio.sdltester.dialogs.CreateInteractionChoiceSetDialog.java
com.livio.sdltester.dialogs.DeleteCommandDialog.java
com.livio.sdltester.dialogs.DeleteFileDialog.java
com.livio.sdltester.dialogs.DeleteInteractionDialog.java
com.livio.sdltester.dialogs.DeleteSubmenuDialog.java
com.livio.sdltester.dialogs.GetDtcsDialog.java
com.livio.sdltester.dialogs.PerformInteractionDialog.java
com.livio.sdltester.dialogs.PutFileDialog.java
com.livio.sdltester.dialogs.ReadDidsDialog.java
com.livio.sdltester.dialogs.ScrollableMessageDialog.java
com.livio.sdltester.dialogs.SdlAlertDialog.java
com.livio.sdltester.dialogs.SdlConnectionDialog.java
com.livio.sdltester.dialogs.SetAppIconDialog.java
com.livio.sdltester.dialogs.SetMediaClockTimerDialog.java
com.livio.sdltester.dialogs.ShowDialog.java
com.livio.sdltester.dialogs.SliderDialog.java
com.livio.sdltester.dialogs.SoftButtonItemDialog.java
com.livio.sdltester.dialogs.SoftButtonListDialog.java
com.livio.sdltester.dialogs.SpeakDialog.java