示例#1
0
        private void UpdateActuatorFunctionList()
        {
            int    selectedFunction = _instanceData.SelectedFunction;
            int    selection        = 0;
            string language         = ActivityCommon.GetCurrentLanguage();

            CreateActuatorJobList();

            _spinnerBmwActuatorFunctionAdapter.Items.Clear();

            int index = 0;

            foreach (XmlToolEcuActivity.JobInfo jobInfo in _jobActuatorList)
            {
                string displayText = jobInfo.EcuFixedFuncStruct.Title?.GetTitle(language);
                _spinnerBmwActuatorFunctionAdapter.Items.Add(new StringObjType(displayText, index));

                if (index == selectedFunction)
                {
                    selection = index;
                }

                index++;
            }

            _spinnerBmwActuatorFunctionAdapter.NotifyDataSetChanged();
            _spinnerBmwActuatorFunction.SetSelection(selection);

            UpdateActuator();
        }
示例#2
0
        protected override void OnDestroy()
        {
            base.OnDestroy();
            _ediabasJobAbort = true;
            if (IsJobRunning())
            {
                _jobThread.Join();
            }
            EdiabasClose();
            _activityCommon?.Dispose();
            _activityCommon = null;

            if (_updateHandler != null)
            {
                try
                {
                    _updateHandler.RemoveCallbacksAndMessages(null);
                    _updateHandler.Dispose();
                }
                catch (Exception)
                {
                    // ignored
                }
                _updateHandler = null;
            }
        }
示例#3
0
        protected override void OnDestroy()
        {
            base.OnDestroy();

            _activityCommon?.Dispose();
            _activityCommon = null;
        }
        private void UpdateDisplay()
        {
            if (_activityCommon == null)
            {
                return;
            }

            string displayName = GetString(Resource.String.default_media);

            if (!string.IsNullOrEmpty(_activityCommon.CustomStorageMedia))
            {
                string shortName = ActivityCommon.GetTruncatedPathName(_activityCommon.CustomStorageMedia);
                if (!string.IsNullOrEmpty(shortName))
                {
                    displayName = shortName;
                }
            }
            _buttonStorageLocation.Text = displayName;

            bool snoopLogEnabled = false;

            if (_activityCommon.GetConfigHciSnoopLog(out bool enabledConfig))
            {
                snoopLogEnabled = enabledConfig;
            }
            if (ActivityCommon.ReadHciSnoopLogSettings(out bool enabledSettings, out string logFileName))
            {
                if (!enabledSettings)
                {
                    snoopLogEnabled = false;
                }
            }
            _checkBoxHciSnoopLog.Checked = snoopLogEnabled;
            _checkBoxHciSnoopLog.Text    = string.Format(GetString(Resource.String.settings_hci_snoop_log), logFileName ?? "-");
        }
        public static string GetAssetFilename()
        {
            if (!string.IsNullOrEmpty(_assetFileName))
            {
                return(_assetFileName);
            }

            try
            {
                Regex        regex  = new Regex(@"^Ecu.*\.bin$", RegexOptions.IgnoreCase);
                AssetManager assets = ActivityCommon.GetPackageContext()?.Assets;
                if (assets != null)
                {
                    string[] assetFiles = assets.List(string.Empty);
                    if (assetFiles != null)
                    {
                        foreach (string fileName in assetFiles)
                        {
                            if (regex.IsMatch(fileName))
                            {
                                _assetFileName = fileName;
                                return(fileName);
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }

            _assetFileName = string.Empty;
            return(null);
        }
示例#6
0
        public override void OnDestroy()
        {
            // We need to shut things down.
            //Log.Info(Tag, "OnDestroy: The started service is shutting down.");

            // Remove the notification from the status bar.
            NotificationManagerCompat notificationManager = NotificationManagerCompat.From(this);

            notificationManager.Cancel(ServiceRunningNotificationId);
            _activityCommon.SetLock(ActivityCommon.LockType.None);
            DisconnectEdiabasEvents();
            lock (ActivityCommon.GlobalLockObject)
            {
                EdiabasThread ediabasThread = ActivityCommon.EdiabasThread;
                if (ediabasThread != null)
                {
                    ediabasThread.ActiveContext = null;
                }
            }

            _activityCommon.Dispose();
            _activityCommon = null;
            _isStarted      = false;

            if (_stopHandler != null)
            {
                _stopHandler.Dispose();
                _stopHandler = null;
            }
            base.OnDestroy();
        }
        public override void OnCreate()
        {
            base.OnCreate();
#if DEBUG
            Android.Util.Log.Info(Tag, "OnCreate: the service is initializing.");
#endif
            _stopHandler    = new Handler();
            _activityCommon = new ActivityCommon(this, null, BroadcastReceived);
            _activityCommon.SetLock(ActivityCommon.LockType.Cpu);
            if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
            {
                if (_activityCommon.NotificationManager != null)
                {
                    Android.App.NotificationChannel notificationChannel = new Android.App.NotificationChannel(
                        ServiceNotificationChannelId,
                        Resources.GetString(Resource.String.app_name), Android.App.NotificationImportance.Low);
                    _activityCommon.NotificationManager.CreateNotificationChannel(notificationChannel);
                }
            }
            lock (ActivityCommon.GlobalLockObject)
            {
                EdiabasThread ediabasThread = ActivityCommon.EdiabasThread;
                if (ediabasThread != null)
                {
                    ediabasThread.ActiveContext = this;
                }
            }
        }
示例#8
0
        public override void OnDestroy()
        {
            // We need to shut things down.
            //Log.Info(Tag, "OnDestroy: The started service is shutting down.");

            // Remove the notification from the status bar.
            NotificationManagerCompat notificationManager = NotificationManagerCompat.From(this);

            notificationManager.Cancel(ServiceRunningNotificationId);

            if (_wakeLockCpu != null)
            {
                try
                {
                    _wakeLockCpu.Release();
                    _wakeLockCpu.Dispose();
                }
                catch (Exception)
                {
                    // ignored
                }
                _wakeLockCpu = null;
            }

            _activityCommon.Dispose();
            _activityCommon = null;
            _isStarted      = false;
            base.OnDestroy();
        }
示例#9
0
        protected void InitBaseVariables()
        {
            _imm         = (InputMethodManager)GetSystemService(InputMethodService);
            _contentView = FindViewById <View>(Android.Resource.Id.Content);

            _barView = LayoutInflater.Inflate(Resource.Layout.bar_arg_assist, null);
            ActionBar.LayoutParams barLayoutParams = new ActionBar.LayoutParams(
                ViewGroup.LayoutParams.MatchParent,
                ViewGroup.LayoutParams.WrapContent);
            barLayoutParams.Gravity = barLayoutParams.Gravity &
                                      (int)(~(GravityFlags.HorizontalGravityMask | GravityFlags.VerticalGravityMask)) |
                                      (int)(GravityFlags.Left | GravityFlags.CenterVertical);
            SupportActionBar.SetCustomView(_barView, barLayoutParams);

            SetResult(Android.App.Result.Canceled);

            _serviceId = Intent.GetIntExtra(ExtraServiceId, -1);
            _offline   = Intent.GetBooleanExtra(ExtraOffline, false);

            _activityCommon = new ActivityCommon(this);

            _sgFuncInfoList = IntentSgFuncInfo;

            _buttonApply = _barView.FindViewById <Button>(Resource.Id.buttonApply);
            _buttonApply.SetOnTouchListener(this);

            _buttonExecute = _barView.FindViewById <Button>(Resource.Id.buttonExecute);
            _buttonExecute.SetOnTouchListener(this);

            _radioButtonArgTypeArg = FindViewById <RadioButton>(Resource.Id.radioButtonArgTypeArg);
            _radioButtonArgTypeArg.SetOnTouchListener(this);

            _radioButtonArgTypeId = FindViewById <RadioButton>(Resource.Id.radioButtonArgTypeId);
            _radioButtonArgTypeId.SetOnTouchListener(this);
        }
        protected override void OnDestroy()
        {
            StoreSettings();

            base.OnDestroy();
            _activityCommon.Dispose();
            _activityCommon = null;
        }
示例#11
0
        private void UpdateActuatorInfo()
        {
            UpdateActuatorStatus();

            string        language = ActivityCommon.GetCurrentLanguage();
            StringBuilder stringBuilderComments = new StringBuilder();

            XmlToolEcuActivity.JobInfo       selectedJob = GetSelectedJob();
            List <EcuFunctionStructs.EcuJob> ecuJobList  = selectedJob?.EcuFixedFuncStruct?.EcuJobList;

            if (ecuJobList != null)
            {
                string preOpText = selectedJob.EcuFixedFuncStruct.PrepOp?.GetTitle(language);
                if (!string.IsNullOrWhiteSpace(preOpText))
                {
                    int presetCount = ecuJobList.Count(x => x.GetPhaseType() == EcuFunctionStructs.EcuJob.PhaseType.Preset);
                    if (presetCount > 0)
                    {
                        AppendSbText(stringBuilderComments, preOpText);
                    }
                    else
                    {
                        preOpText = string.Empty;
                    }
                }

                string procOpText = selectedJob.EcuFixedFuncStruct.ProcOp?.GetTitle(language);
                if (!string.IsNullOrWhiteSpace(procOpText) && procOpText != preOpText)
                {
                    int mainCount = ecuJobList.Count(x => x.GetPhaseType() == EcuFunctionStructs.EcuJob.PhaseType.Main);
                    if (mainCount > 0)
                    {
                        AppendSbText(stringBuilderComments, procOpText);
                    }
                    else
                    {
                        procOpText = string.Empty;
                    }
                }

                string postOpText = selectedJob.EcuFixedFuncStruct.PostOp?.GetTitle(language);
                if (!string.IsNullOrWhiteSpace(postOpText) && postOpText != preOpText && postOpText != procOpText)
                {
                    int resetCount = ecuJobList.Count(x => x.GetPhaseType() == EcuFunctionStructs.EcuJob.PhaseType.Reset);
                    if (resetCount > 0)
                    {
                        AppendSbText(stringBuilderComments, postOpText);
                    }
                }
            }

            string actuatorFunctionComment = stringBuilderComments.ToString();

            _layoutBmwActuatorComments.Visibility = !string.IsNullOrWhiteSpace(actuatorFunctionComment) ? ViewStates.Visible : ViewStates.Gone;
            _textBmwActuatorComments.Text         = actuatorFunctionComment;
        }
示例#12
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            if (savedInstanceState != null)
            {
                _activityRecreated = true;
                _instanceData      = ActivityCommon.GetInstanceState(savedInstanceState, _instanceData) as InstanceData;
            }

            string initDir = Activity.Intent.GetStringExtra(FilePickerActivity.ExtraInitDir) ?? string.Empty;

            if (Directory.Exists(initDir))
            {
                try
                {
                    DirectoryInfo dir = new DirectoryInfo(initDir);
                    dir.GetFileSystemInfos();
                    if (!_activityRecreated && _instanceData != null)
                    {
                        _instanceData.DefaultInitialDirectory = initDir;
                    }
                }
                catch
                {
                    // ignored
                }
            }

            _extensionList = new List <string>();
            string fileExtensions = Activity.Intent.GetStringExtra(FilePickerActivity.ExtraFileExtensions);

            if (!string.IsNullOrEmpty(fileExtensions))
            {
                string[] extensions = fileExtensions.Split(';');
                foreach (string extension in extensions)
                {
                    _extensionList.Add(extension);
                }
            }

            string fileFilter = Activity.Intent.GetStringExtra(FilePickerActivity.ExtraFileRegex);

            _fileNameRegex = null;
            if (!string.IsNullOrEmpty(fileFilter))
            {
                _fileNameRegex = new Regex(fileFilter, RegexOptions.IgnoreCase);
            }

            _allowDirChange     = Activity.Intent.GetBooleanExtra(FilePickerActivity.ExtraDirChange, true);
            _showFileExtensions = Activity.Intent.GetBooleanExtra(FilePickerActivity.ExtraShowExtension, true);

            _adapter    = new FileListAdapter(Activity, new FileInfoEx[0]);
            ListAdapter = _adapter;
        }
示例#13
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     _ediabasJobAbort = true;
     if (IsJobRunning())
     {
         _jobThread.Join();
     }
     EdiabasClose();
     _activityCommon.Dispose();
     _activityCommon = null;
 }
示例#14
0
        protected override void OnDestroy()
        {
            base.OnDestroy();

            if (IsJobRunning())
            {
                _adapterThread.Join();
            }
            EdiabasClose();
            _activityCommon.Dispose();
            _activityCommon = null;
        }
示例#15
0
        public EdiabasThread(string ecuPath, ActivityCommon activityCommon)
        {
            _stopThread    = false;
            _threadRunning = false;
            _workerThread  = null;
            Ediabas        = new EdiabasNet
            {
                EdInterfaceClass = activityCommon.GetEdiabasInterfaceClass(),
                AbortJobFunc     = AbortEdiabasJob
            };
            Ediabas.SetConfigProperty("EcuPath", ecuPath);

            InitProperties();
        }
示例#16
0
        public override void OnCreate()
        {
            base.OnCreate();
#if DEBUG
            Log.Info(Tag, "OnCreate: the service is initializing.");
#endif
            _activityCommon = new ActivityCommon(null);
            _powerManager   = GetSystemService(PowerService) as PowerManager;
            if (_powerManager != null)
            {
                _wakeLockCpu = _powerManager.NewWakeLock(WakeLockFlags.Partial, "PartialLock");
                _wakeLockCpu.SetReferenceCounted(false);
                _wakeLockCpu.Acquire();
            }
        }
示例#17
0
        public override void OnCreate()
        {
            base.OnCreate();
#if DEBUG
            Android.Util.Log.Info(Tag, "OnCreate: the service is initializing.");
#endif
            _stopHandler    = new Handler();
            _activityCommon = new ActivityCommon(this, null, BroadcastReceived);
            _activityCommon.SetLock(ActivityCommon.LockType.Cpu);
            lock (ActivityCommon.GlobalLockObject)
            {
                EdiabasThread ediabasThread = ActivityCommon.EdiabasThread;
                if (ediabasThread != null)
                {
                    ediabasThread.ActiveContext = this;
                }
            }
        }
示例#18
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SetContentView(Resource.Layout.settings);

            SetResult(Android.App.Result.Canceled);
            _selection = Intent.GetStringExtra(ExtraSelection);

            _activityCommon = new ActivityCommon(this);

            _radioButtonAskForBtEnable = FindViewById <RadioButton>(Resource.Id.radioButtonAskForBtEnable);
            _radioButtonAlwaysEnableBt = FindViewById <RadioButton>(Resource.Id.radioButtonAlwaysEnableBt);
            _radioButtonNoBtHandling   = FindViewById <RadioButton>(Resource.Id.radioButtonNoBtHandling);

            _checkBoxDisableBtAtExit = FindViewById <CheckBox>(Resource.Id.checkBoxDisableBtAtExit);

            _radioButtonCommLockNone   = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockNone);
            _radioButtonCommLockCpu    = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockCpu);
            _radioButtonCommLockDim    = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockDim);
            _radioButtonCommLockBright = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockBright);

            _radioButtonLogLockNone   = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockNone);
            _radioButtonLogLockCpu    = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockCpu);
            _radioButtonLogLockDim    = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockDim);
            _radioButtonLogLockBright = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockBright);

            _checkBoxStoreDataLogSettings  = FindViewById <CheckBox>(Resource.Id.checkBoxStoreDataLogSettings);
            _checkBoxDoubleClickForAppExit = FindViewById <CheckBox>(Resource.Id.checkBoxDoubleClickForAppExit);

            _buttonStorageLocation        = FindViewById <Button>(Resource.Id.buttonStorageLocation);
            _buttonStorageLocation.Click += (sender, args) =>
            {
                SelectMedia();
            };

            _checkBoxCollectDebugInfo = FindViewById <CheckBox>(Resource.Id.checkBoxCollectDebugInfo);

            ReadSettings();
            CheckSelection(_selection);
        }
示例#19
0
 private void PerformUpdateMessage()
 {
     if (!ActivityCommon.IsBtReliable())
     {
         _activityCommon.ShowAlert(GetString(Resource.String.can_adapter_bt_not_reliable), Resource.String.alert_title_error);
         return;
     }
     new AlertDialog.Builder(this)
     .SetPositiveButton(Resource.String.button_yes, (sender, args) =>
     {
         PerformUpdate();
     })
     .SetNegativeButton(Resource.String.button_no, (sender, args) =>
     {
     })
     .SetCancelable(true)
     .SetMessage(Resource.String.can_adapter_fw_update_info)
     .SetTitle(Resource.String.alert_title_warning)
     .Show();
 }
示例#20
0
        private void LogData(JobReader.PageInfo pageInfo, MultiMap <string, EdiabasNet.ResultData> resultDict)
        {
            if (_swDataLog == null)
            {
                return;
            }
            StringBuilder sbLog        = new StringBuilder();
            string        currDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);

            sbLog.Append(currDateTime);
            bool logDataPresent = false;

            foreach (JobReader.DisplayInfo displayInfo in pageInfo.DisplayList)
            {
                string result = ActivityCommon.FormatResult(pageInfo, displayInfo, resultDict, out Android.Graphics.Color? _);
                if (result != null)
                {
                    if (!string.IsNullOrEmpty(displayInfo.LogTag))
                    {
                        if (!string.IsNullOrWhiteSpace(result))
                        {
                            logDataPresent = true;
                        }
                        sbLog.Append(DataLogSeparator);
                        sbLog.Append(result.Replace(DataLogSeparator, ' '));
                    }
                }
            }
            if (logDataPresent)
            {
                try
                {
                    sbLog.Append("\r\n");
                    _swDataLog.Write(sbLog.ToString());
                }
                catch (Exception)
                {
                    // ignored
                }
            }
        }
示例#21
0
        private void CreateActuatorJobList()
        {
            if (_jobActuatorList != null)
            {
                return;
            }

            string language = ActivityCommon.GetCurrentLanguage();

            _jobActuatorList = new List <XmlToolEcuActivity.JobInfo>();
            foreach (XmlToolEcuActivity.JobInfo jobInfo in _ecuInfo.JobList)
            {
                if (jobInfo.EcuFixedFuncStruct != null &&
                    jobInfo.EcuFixedFuncStruct.GetNodeClassType() == EcuFunctionStructs.EcuFixedFuncStruct.NodeClassType.ControlActuator)
                {
                    string displayText = jobInfo.EcuFixedFuncStruct.Title?.GetTitle(language);
                    if (!string.IsNullOrWhiteSpace(displayText))
                    {
                        _jobActuatorList.Add(jobInfo);
                    }
                }
            }
        }
        private bool SelectCopyDocumentTree(bool fromApp)
        {
            if (!ActivityCommon.IsDocumentTreeSupported())
            {
                return(false);
            }

            try
            {
                ActivityRequest request;
                Intent          intent = new Intent(Intent.ActionOpenDocumentTree);
                intent.PutExtra(Intent.ExtraTitle, GetString(Resource.String.settings_storage_sel_public_dir));
                if (fromApp)
                {
                    request = ActivityRequest.RequestOpenDocumentTreeFromApp;
                    if (!string.IsNullOrEmpty(_instanceData.CopyFromAppDstUri))
                    {
                        intent.PutExtra(Android.Provider.DocumentsContract.ExtraInitialUri, _instanceData.CopyFromAppDstUri);
                    }
                }
                else
                {
                    request = ActivityRequest.RequestOpenDocumentTreeToApp;
                    if (!string.IsNullOrEmpty(_instanceData.CopyToAppSrcUri))
                    {
                        intent.PutExtra(Android.Provider.DocumentsContract.ExtraInitialUri, _instanceData.CopyToAppSrcUri);
                    }
                }

                StartActivityForResult(intent, (int)request);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#23
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            SetTheme(ActivityCommon.SelectedThemeId);
            base.OnCreate(savedInstanceState);
            _allowFullScreenMode = false;
            if (savedInstanceState != null)
            {
                _instanceData = GetInstanceState(savedInstanceState, _instanceData) as InstanceData;
            }

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            //SupportActionBar.SetDisplayShowCustomEnabled(true);
            SetContentView(Resource.Layout.bmw_actuator);

            _imm         = (InputMethodManager)GetSystemService(InputMethodService);
            _contentView = FindViewById <View>(Android.Resource.Id.Content);

            SetResult(Android.App.Result.Canceled);

            if (IntentEcuInfo == null)
            {
                Finish();
                return;
            }

            _activityCommon = new ActivityCommon(this, () =>
            {
            }, BroadcastReceived);
            _updateHandler = new Handler(Looper.MainLooper);

            _ecuDir      = Intent.GetStringExtra(ExtraEcuDir);
            _traceDir    = Intent.GetStringExtra(ExtraTraceDir);
            _traceAppend = Intent.GetBooleanExtra(ExtraTraceAppend, true);
            _activityCommon.SelectedInterface = (ActivityCommon.InterfaceType)
                                                Intent.GetIntExtra(ExtraInterface, (int)ActivityCommon.InterfaceType.None);
            _deviceAddress = Intent.GetStringExtra(ExtraDeviceAddress);
            _activityCommon.SelectedEnetIp = Intent.GetStringExtra(ExtraEnetIp);

            _ecuInfo = IntentEcuInfo;
            UpdateInfoAdaptionList();

            SupportActionBar.Title = string.Format(GetString(Resource.String.bmw_actuator_title), Intent.GetStringExtra(ExtraEcuName) ?? string.Empty);

            _scrollViewBmwActuator = FindViewById <ScrollView>(Resource.Id.scrollViewBmwActuator);
            _scrollViewBmwActuator.SetOnTouchListener(this);

            _layoutBmwActuator = FindViewById <LinearLayout>(Resource.Id.layoutBmwActuator);
            _layoutBmwActuator.SetOnTouchListener(this);

            _layoutBmwActuatorFunction = FindViewById <LinearLayout>(Resource.Id.layoutBmwActuatorFunction);
            _layoutBmwActuatorFunction.SetOnTouchListener(this);

            _textViewBmwActuatorFunction = FindViewById <TextView>(Resource.Id.textViewBmwActuatorFunction);
            _textViewBmwActuatorFunction.SetOnTouchListener(this);

            _spinnerBmwActuatorFunction = FindViewById <Spinner>(Resource.Id.spinnerBmwActuatorFunction);
            _spinnerBmwActuatorFunction.SetOnTouchListener(this);
            _spinnerBmwActuatorFunctionAdapter        = new StringObjAdapter(this);
            _spinnerBmwActuatorFunction.Adapter       = _spinnerBmwActuatorFunctionAdapter;
            _spinnerBmwActuatorFunction.ItemSelected += ActuatorFunctionItemSelected;

            _layoutBmwActuatorInfo = FindViewById <LinearLayout>(Resource.Id.layoutBmwActuatorInfo);
            _layoutBmwActuatorInfo.SetOnTouchListener(this);

            _layoutBmwActuatorComments = FindViewById <LinearLayout>(Resource.Id.layoutBmwActuatorComments);
            _layoutBmwActuatorComments.SetOnTouchListener(this);

            _textViewBmwActuatorCommentsTitle = FindViewById <TextView>(Resource.Id.textViewBmwActuatorCommentsTitle);
            _textViewBmwActuatorCommentsTitle.SetOnTouchListener(this);

            _textBmwActuatorComments = FindViewById <TextView>(Resource.Id.textBmwActuatorComments);
            _textBmwActuatorComments.SetOnTouchListener(this);
            _textBmwActuatorComments.MovementMethod = new ScrollingMovementMethod();

            _layoutBmwActuatorStatus = FindViewById <LinearLayout>(Resource.Id.layoutBmwActuatorStatus);
            _layoutBmwActuatorStatus.SetOnTouchListener(this);

            _textViewBmwActuatorStatusTitle = FindViewById <TextView>(Resource.Id.textViewBmwActuatorStatusTitle);
            _textViewBmwActuatorStatusTitle.SetOnTouchListener(this);

            _textBmwActuatorStatus = FindViewById <TextView>(Resource.Id.textBmwActuatorStatus);
            _textBmwActuatorStatus.SetOnTouchListener(this);
            _textBmwActuatorStatus.MovementMethod = new ScrollingMovementMethod();

            _layoutBmwActuatorOperation = FindViewById <LinearLayout>(Resource.Id.layoutBmwActuatorOperation);
            _layoutBmwActuatorOperation.SetOnTouchListener(this);

            _textViewBmwActuatorOperationTitle = FindViewById <TextView>(Resource.Id.textViewBmwActuatorOperationTitle);
            _textViewBmwActuatorOperationTitle.SetOnTouchListener(this);

            _buttonBmwActuatorExecuteSingle = FindViewById <Button>(Resource.Id.buttonBmwActuatorExecuteSingle);
            _buttonBmwActuatorExecuteSingle.SetOnTouchListener(this);
            _buttonBmwActuatorExecuteSingle.Click += (sender, args) =>
            {
                ExecuteActuatorFunction(false);
            };

            _buttonBmwActuatorExecuteContinuous = FindViewById <Button>(Resource.Id.buttonBmwActuatorExecuteContinuous);
            _buttonBmwActuatorExecuteContinuous.SetOnTouchListener(this);
            _buttonBmwActuatorExecuteContinuous.Click += (sender, args) =>
            {
                ExecuteActuatorFunction(true);
            };

            _buttonBmwActuatorStop = FindViewById <Button>(Resource.Id.buttonBmwActuatorStop);
            _buttonBmwActuatorStop.SetOnTouchListener(this);
            _buttonBmwActuatorStop.Click += (sender, args) =>
            {
                _instanceData.StopActuator = true;
            };

            UpdateActuatorFunctionList();
        }
示例#24
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SetContentView(Resource.Layout.yandex_key_select);

            _imm         = (InputMethodManager)GetSystemService(InputMethodService);
            _contentView = FindViewById <View>(Android.Resource.Id.Content);

            SetResult(Android.App.Result.Canceled);

            _oldYandexApiKey = ActivityCommon.YandexApiKey ?? string.Empty;

            _activityCommon = new ActivityCommon(this);

            _layoutYandexKey = FindViewById <LinearLayout>(Resource.Id.layoutYandexKey);
            _layoutYandexKey.SetOnTouchListener(this);

            _editTextYandexApiKey      = FindViewById <EditText>(Resource.Id.editTextYandexApiKey);
            _editTextYandexApiKey.Text = _oldYandexApiKey;

            _buttonYandexApiKeyCreate = FindViewById <Button>(Resource.Id.buttonYandexKeyCreate);
            _buttonYandexApiKeyCreate.SetOnTouchListener(this);
            _buttonYandexApiKeyCreate.Click += (sender, args) =>
            {
                _activityCommon.ShowWifiConnectedWarning(() =>
                {
                    StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse(@"https://tech.yandex.com/keys/get/?service=trnsl")));
                });
            };

            _buttonYandexApiKeyGet = FindViewById <Button>(Resource.Id.buttonYandexKeyGet);
            _buttonYandexApiKeyGet.SetOnTouchListener(this);
            _buttonYandexApiKeyGet.Click += (sender, args) =>
            {
                _activityCommon.ShowWifiConnectedWarning(() =>
                {
                    StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse(@"https://tech.yandex.com/keys/")));
                });
            };

            _buttonYandexApiKeyPaste = FindViewById <Button>(Resource.Id.buttonYandexKeyPaste);
            _buttonYandexApiKeyPaste.SetOnTouchListener(this);
            _buttonYandexApiKeyPaste.Click += (sender, args) =>
            {
                string clipText = _activityCommon.GetClipboardText();
                if (!string.IsNullOrWhiteSpace(clipText))
                {
                    _editTextYandexApiKey.Text = clipText.Trim();
                    UpdateDisplay();
                }
            };
            _buttonYandexApiKeyPaste.TextChanged += (sender, args) =>
            {
                UpdateDisplay();
            };

            _textViewYandexApiKeyTestResult = FindViewById <TextView>(Resource.Id.textViewYandexKeyTestResult);

            _buttonYandexApiKeyTest = FindViewById <Button>(Resource.Id.buttonYandexKeyTest);
            _buttonYandexApiKeyTest.SetOnTouchListener(this);
            _buttonYandexApiKeyTest.Click += (sender, args) =>
            {
                _textViewYandexApiKeyTestResult.Text = string.Empty;
                ActivityCommon.YandexApiKey          = _editTextYandexApiKey.Text.Trim();
                if (!_activityCommon.TranslateStrings(new List <string> {
                    @"Dieser Text wurde erfolgreich übersetzt"
                }, list =>
                {
                    if (list != null && list.Count > 0)
                    {
                        _textViewYandexApiKeyTestResult.Text = list[0];
                    }
                    else
                    {
                        _textViewYandexApiKeyTestResult.Text = GetString(Resource.String.button_yandex_key_test_failed);
                    }
                }, true))
                {
                    _textViewYandexApiKeyTestResult.Text = GetString(Resource.String.button_yandex_key_test_failed);
                }
            };

            UpdateDisplay();
        }
示例#25
0
 protected override void OnSaveInstanceState(Bundle outState)
 {
     ActivityCommon.StoreInstanceState(outState, _instanceData);
     base.OnSaveInstanceState(outState);
 }
示例#26
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowCustomEnabled(true);
            SetContentView(Resource.Layout.can_adapter_config);

            _imm         = (InputMethodManager)GetSystemService(InputMethodService);
            _contentView = FindViewById <View>(Android.Resource.Id.Content);

            _barView = LayoutInflater.Inflate(Resource.Layout.bar_can_adapter, null);
            ActionBar.LayoutParams barLayoutParams = new ActionBar.LayoutParams(
                ViewGroup.LayoutParams.MatchParent,
                ViewGroup.LayoutParams.WrapContent);
            barLayoutParams.Gravity = barLayoutParams.Gravity &
                                      (int)(~(GravityFlags.HorizontalGravityMask | GravityFlags.VerticalGravityMask)) |
                                      (int)(GravityFlags.Left | GravityFlags.CenterVertical);
            SupportActionBar.SetCustomView(_barView, barLayoutParams);

            SetResult(Android.App.Result.Canceled);

            _deviceAddress = Intent.GetStringExtra(ExtraDeviceAddress);
            ActivityCommon.InterfaceType interfaceType = (ActivityCommon.InterfaceType)Intent.GetIntExtra(ExtraInterfaceType,
                                                                                                          (int)ActivityCommon.InterfaceType.Bluetooth);
            ViewStates visibility = interfaceType == ActivityCommon.InterfaceType.Bluetooth ? ViewStates.Visible : ViewStates.Gone;

            _buttonRead = _barView.FindViewById <Button>(Resource.Id.buttonAdapterRead);
            _buttonRead.SetOnTouchListener(this);
            _buttonRead.Click += (sender, args) =>
            {
                PerformRead();
            };
            _buttonRead.Visibility = visibility;

            _buttonWrite = _barView.FindViewById <Button>(Resource.Id.buttonAdapterWrite);
            _buttonWrite.SetOnTouchListener(this);
            _buttonWrite.Click += (sender, args) =>
            {
                PerformWrite();
            };

            _layoutCanAdapter = FindViewById <LinearLayout>(Resource.Id.layoutCanAdapter);
            _layoutCanAdapter.SetOnTouchListener(this);

            _spinnerCanAdapterMode = FindViewById <Spinner>(Resource.Id.spinnerCanAdapterMode);
            _spinnerCanAdapterMode.SetOnTouchListener(this);
            _spinnerCanAdapterModeAdapter  = new StringObjAdapter(this);
            _spinnerCanAdapterMode.Adapter = _spinnerCanAdapterModeAdapter;
            _spinnerCanAdapterModeAdapter.Items.Add(new StringObjType(GetString(Resource.String.button_can_adapter_can_500), AdapterMode.Can500));
            _spinnerCanAdapterModeAdapter.Items.Add(new StringObjType(GetString(Resource.String.button_can_adapter_can_100), AdapterMode.Can100));
            _spinnerCanAdapterModeAdapter.Items.Add(new StringObjType(GetString(Resource.String.button_can_adapter_can_off), AdapterMode.CanOff));
            _spinnerCanAdapterModeAdapter.NotifyDataSetChanged();

            _textViewCanAdapterSepTimeTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterSepTimeTitle);
            _textViewCanAdapterSepTimeTitle.Visibility = visibility;

            _spinnerCanAdapterSepTime = FindViewById <Spinner>(Resource.Id.spinnerCanAdapterSepTime);
            _spinnerCanAdapterSepTime.SetOnTouchListener(this);
            _spinnerCanAdapterSepTimeAdapter  = new StringAdapter(this);
            _spinnerCanAdapterSepTime.Adapter = _spinnerCanAdapterSepTimeAdapter;
            _spinnerCanAdapterSepTimeAdapter.Items.Add(GetString(Resource.String.can_adapter_text_off));
            for (int i = 1; i <= 2; i++)
            {
                _spinnerCanAdapterSepTimeAdapter.Items.Add(i.ToString());
            }
            _spinnerCanAdapterSepTimeAdapter.NotifyDataSetChanged();
            _spinnerCanAdapterSepTime.Visibility = visibility;

            _textViewCanAdapterBlockSizeTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterBlockSizeTitle);
            _textViewCanAdapterBlockSizeTitle.Visibility = visibility;

            _spinnerCanAdapterBlockSize = FindViewById <Spinner>(Resource.Id.spinnerCanAdapterBlockSize);
            _spinnerCanAdapterBlockSize.SetOnTouchListener(this);
            _spinnerCanAdapterBlockSizeAdapter  = new StringAdapter(this);
            _spinnerCanAdapterBlockSize.Adapter = _spinnerCanAdapterBlockSizeAdapter;
            _spinnerCanAdapterBlockSizeAdapter.Items.Add(GetString(Resource.String.can_adapter_text_off));
            for (int i = 0; i <= 15; i++)
            {
                _spinnerCanAdapterBlockSizeAdapter.Items.Add(i.ToString());
            }
            _spinnerCanAdapterBlockSizeAdapter.NotifyDataSetChanged();
            _spinnerCanAdapterBlockSize.Visibility = visibility;

            _textViewBtPinTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterBtPinTitle);
            _textViewBtPinTitle.Visibility = visibility;

            _editTextBtPin            = FindViewById <EditText>(Resource.Id.editTextBtPin);
            _editTextBtPin.Visibility = visibility;

            _textViewBtNameTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterBtNameTitle);
            _textViewBtNameTitle.Visibility = visibility;

            _editTextBtName            = FindViewById <EditText>(Resource.Id.editTextBtName);
            _editTextBtName.Visibility = visibility;

            _textViewCanAdapterIgnitionStateTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterIgnitionStateTitle);
            _textViewCanAdapterIgnitionStateTitle.Visibility = visibility;

            _textViewIgnitionState            = FindViewById <TextView>(Resource.Id.textViewCanAdapterIgnitionState);
            _textViewIgnitionState.Visibility = visibility;

            _textViewBatteryVoltageTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterBatVoltageTitle);
            _textViewBatteryVoltageTitle.Visibility = visibility;

            _textViewBatteryVoltage            = FindViewById <TextView>(Resource.Id.textViewCanAdapterBatVoltage);
            _textViewBatteryVoltage.Visibility = visibility;

            _textViewFwVersionTitle            = FindViewById <TextView>(Resource.Id.textViewCanAdapterFwVersionTitle);
            _textViewFwVersionTitle.Visibility = visibility;

            _textViewFwVersion            = FindViewById <TextView>(Resource.Id.textViewCanAdapterFwVersion);
            _textViewFwVersion.Visibility = visibility;

            _textViewSerNumTitle = FindViewById <TextView>(Resource.Id.textViewCanAdapterSerNumTitle);
            _textViewSerNum      = FindViewById <TextView>(Resource.Id.textViewCanAdapterSerNum);
#if DEBUG
            _textViewSerNumTitle.Visibility = visibility;
            _textViewSerNum.Visibility      = visibility;
#else
            _textViewSerNumTitle.Visibility = ViewStates.Gone;
            _textViewSerNum.Visibility      = ViewStates.Gone;
#endif
            _buttonFwUpdate            = FindViewById <Button>(Resource.Id.buttonCanAdapterFwUpdate);
            _buttonFwUpdate.Visibility = visibility;
            _buttonFwUpdate.Click     += (sender, args) =>
            {
                PerformUpdateMessage();
            };
            _checkBoxExpert            = FindViewById <CheckBox>(Resource.Id.checkBoxCanAdapterExpert);
            _checkBoxExpert.Visibility = visibility;
            _checkBoxExpert.Click     += (sender, args) =>
            {
                UpdateDisplay();
            };

            _activityCommon = new ActivityCommon(this)
            {
                SelectedInterface = interfaceType
            };

            UpdateDisplay();
            PerformRead();
        }
示例#27
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SetContentView(Resource.Layout.yandex_key_select);

            _clipboardManager = GetSystemService(ClipboardService);
            _imm         = (InputMethodManager)GetSystemService(InputMethodService);
            _contentView = FindViewById <View>(Android.Resource.Id.Content);

            SetResult(Android.App.Result.Canceled);

            _oldYandexApiKey = ActivityCommon.YandexApiKey ?? string.Empty;

            _activityCommon = new ActivityCommon(this);

            _layoutYandexKey = FindViewById <LinearLayout>(Resource.Id.layoutYandexKey);
            _layoutYandexKey.SetOnTouchListener(this);

            _editTextYandexApiKey      = FindViewById <EditText>(Resource.Id.editTextYandexApiKey);
            _editTextYandexApiKey.Text = _oldYandexApiKey;

            _buttonYandexApiKeyCreate = FindViewById <Button>(Resource.Id.buttonYandexKeyCreate);
            _buttonYandexApiKeyCreate.SetOnTouchListener(this);
            _buttonYandexApiKeyCreate.Click += (sender, args) =>
            {
                StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse(@"https://tech.yandex.com/keys/get/?service=trnsl")));
            };

            _buttonYandexApiKeyGet = FindViewById <Button>(Resource.Id.buttonYandexKeyGet);
            _buttonYandexApiKeyGet.SetOnTouchListener(this);
            _buttonYandexApiKeyGet.Click += (sender, args) =>
            {
                StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse(@"https://tech.yandex.com/keys/")));
            };

            _buttonYandexApiKeyPaste = FindViewById <Button>(Resource.Id.buttonYandexKeyPaste);
            _buttonYandexApiKeyPaste.SetOnTouchListener(this);
            _buttonYandexApiKeyPaste.Click += (sender, args) =>
            {
                ClipboardManager clipboardManagerNew = _clipboardManager as ClipboardManager;
                if (clipboardManagerNew != null)
                {
                    if (clipboardManagerNew.HasPrimaryClip)
                    {
                        string        clipText = string.Empty;
                        ClipData.Item item     = clipboardManagerNew.PrimaryClip.GetItemAt(0);
                        if (item != null)
                        {
                            clipText = clipboardManagerNew.PrimaryClipDescription.HasMimeType(ClipDescription.MimetypeTextPlain) ?
                                       item.Text : item.CoerceToText(this);
                        }
                        if (!string.IsNullOrWhiteSpace(clipText))
                        {
                            _editTextYandexApiKey.Text = clipText.Trim();
                            UpdateDisplay();
                        }
                    }
                }
                else
                {
#pragma warning disable 618
                    Android.Text.ClipboardManager clipboardManagerOld = _clipboardManager as Android.Text.ClipboardManager;
#pragma warning restore 618
                    if (!string.IsNullOrWhiteSpace(clipboardManagerOld?.Text))
                    {
                        _editTextYandexApiKey.Text = clipboardManagerOld.Text.Trim();
                        UpdateDisplay();
                    }
                }
            };
            _buttonYandexApiKeyPaste.TextChanged += (sender, args) =>
            {
                UpdateDisplay();
            };

            _textViewYandexApiKeyTestResult = FindViewById <TextView>(Resource.Id.textViewYandexKeyTestResult);

            _buttonYandexApiKeyTest = FindViewById <Button>(Resource.Id.buttonYandexKeyTest);
            _buttonYandexApiKeyTest.SetOnTouchListener(this);
            _buttonYandexApiKeyTest.Click += (sender, args) =>
            {
                _textViewYandexApiKeyTestResult.Text = string.Empty;
                ActivityCommon.YandexApiKey          = _editTextYandexApiKey.Text.Trim();
                if (!_activityCommon.TranslateStrings(new List <string> {
                    @"Dieser Text wurde erfolgreich übersetzt"
                }, list =>
                {
                    if (list != null && list.Count > 0)
                    {
                        _textViewYandexApiKeyTestResult.Text = list[0];
                    }
                    else
                    {
                        _textViewYandexApiKeyTestResult.Text = GetString(Resource.String.button_yandex_key_test_failed);
                    }
                }, true))
                {
                    _textViewYandexApiKeyTestResult.Text = GetString(Resource.String.button_yandex_key_test_failed);
                }
            };

            UpdateDisplay();
        }
示例#28
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SetContentView(Resource.Layout.settings);

            SetResult(Android.App.Result.Canceled);
            _selection = Intent.GetStringExtra(ExtraSelection);

            _activityCommon = new ActivityCommon(this);

            _radioButtonAskForBtEnable = FindViewById <RadioButton>(Resource.Id.radioButtonAskForBtEnable);
            _radioButtonAlwaysEnableBt = FindViewById <RadioButton>(Resource.Id.radioButtonAlwaysEnableBt);
            _radioButtonNoBtHandling   = FindViewById <RadioButton>(Resource.Id.radioButtonNoBtHandling);

            _checkBoxDisableBtAtExit = FindViewById <CheckBox>(Resource.Id.checkBoxDisableBtAtExit);

            _radioButtonCommLockNone   = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockNone);
            _radioButtonCommLockCpu    = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockCpu);
            _radioButtonCommLockDim    = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockDim);
            _radioButtonCommLockBright = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockBright);

            _radioButtonLogLockNone   = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockNone);
            _radioButtonLogLockCpu    = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockCpu);
            _radioButtonLogLockDim    = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockDim);
            _radioButtonLogLockBright = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockBright);

            _checkBoxStoreDataLogSettings = FindViewById <CheckBox>(Resource.Id.checkBoxStoreDataLogSettings);

            _radioButtonStartOffline      = FindViewById <RadioButton>(Resource.Id.radioButtonStartOffline);
            _radioButtonStartConnect      = FindViewById <RadioButton>(Resource.Id.radioButtonStartConnect);
            _radioButtonStartConnectClose = FindViewById <RadioButton>(Resource.Id.radioButtonStartConnectClose);

            _radioButtonUpdateOff   = FindViewById <RadioButton>(Resource.Id.radioButtonUpdateOff);
            _radioButtonUpdate1Day  = FindViewById <RadioButton>(Resource.Id.radioButtonUpdate1Day);
            _radioButtonUpdate1Week = FindViewById <RadioButton>(Resource.Id.radioButtonUpdate1Week);

            _checkBoxDoubleClickForAppExit = FindViewById <CheckBox>(Resource.Id.checkBoxDoubleClickForAppExit);
            _checkBoxSendDataBroadcast     = FindViewById <CheckBox>(Resource.Id.checkBoxSendDataBroadcast);

            _textViewCaptionCpuUsage = FindViewById <TextView>(Resource.Id.textViewCaptionCpuUsage);
            _checkBoxCheckCpuUsage   = FindViewById <CheckBox>(Resource.Id.checkBoxCheckCpuUsage);
            ViewStates viewStateCpuUsage = ActivityCommon.IsCpuStatisticsSupported() ? ViewStates.Visible : ViewStates.Gone;

            _textViewCaptionCpuUsage.Visibility = viewStateCpuUsage;
            _checkBoxCheckCpuUsage.Visibility   = viewStateCpuUsage;

            _checkBoxCheckEcuFiles             = FindViewById <CheckBox>(Resource.Id.checkBoxCheckEcuFiles);
            _checkBoxShowBatteryVoltageWarning = FindViewById <CheckBox>(Resource.Id.checkBoxShowBatteryVoltageWarning);
            _checkBoxOldVagMode = FindViewById <CheckBox>(Resource.Id.checkBoxOldVagMode);

            _buttonStorageLocation        = FindViewById <Button>(Resource.Id.buttonStorageLocation);
            _buttonStorageLocation.Click += (sender, args) =>
            {
                SelectMedia();
            };

            _checkBoxCollectDebugInfo = FindViewById <CheckBox>(Resource.Id.checkBoxCollectDebugInfo);

            ViewStates viewStateSnoopLog = _activityCommon.GetConfigHciSnoopLog(out bool _) ? ViewStates.Visible : ViewStates.Gone;

            _checkBoxHciSnoopLog            = FindViewById <CheckBox>(Resource.Id.checkBoxHciSnoopLog);
            _checkBoxHciSnoopLog.Visibility = viewStateSnoopLog;
            _checkBoxHciSnoopLog.Enabled    = false;

            _buttonHciSnoopLog            = FindViewById <Button>(Resource.Id.buttonHciSnoopLog);
            _buttonHciSnoopLog.Visibility = viewStateSnoopLog;
            _buttonHciSnoopLog.Click     += (sender, args) =>
            {
                ShowDevelopmentSettings();
            };

            ReadSettings();
            CheckSelection(_selection);
        }
示例#29
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            SetTheme(ActivityCommon.SelectedThemeId);
            base.OnCreate(savedInstanceState);

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SetContentView(Resource.Layout.settings);

            SetResult(Android.App.Result.Canceled);
            _appDataDir = Intent.GetStringExtra(ExtraAppDataDir);
            _selection  = Intent.GetStringExtra(ExtraSelection);

            _activityCommon = new ActivityCommon(this);

            bool allowExport = false;
            bool allowImport = false;

            try
            {
                if (!string.IsNullOrEmpty(_appDataDir))
                {
                    _exportFileName = Path.Combine(_appDataDir, SettingsFileName);
                    allowExport     = true;
                    if (File.Exists(_exportFileName))
                    {
                        allowImport = true;
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }

            _radioButtonLocaleDefault = FindViewById <RadioButton>(Resource.Id.radioButtonLocaleDefault);
            _radioButtonLocaleEn      = FindViewById <RadioButton>(Resource.Id.radioButtonLocaleEn);
            _radioButtonLocaleDe      = FindViewById <RadioButton>(Resource.Id.radioButtonLocaleDe);
            _radioButtonLocaleRu      = FindViewById <RadioButton>(Resource.Id.radioButtonLocaleRu);

            _radioButtonThemeDark  = FindViewById <RadioButton>(Resource.Id.radioButtonThemeDark);
            _radioButtonThemeLight = FindViewById <RadioButton>(Resource.Id.radioButtonThemeLight);

            ViewStates viewStateTranslation = ActivityCommon.IsTranslationRequired() ? ViewStates.Visible : ViewStates.Gone;

            _textViewCaptionTranslator              = FindViewById <TextView>(Resource.Id.textViewCaptionTranslator);
            _textViewCaptionTranslator.Visibility   = viewStateTranslation;
            _radioButtonTranslatorYandex            = FindViewById <RadioButton>(Resource.Id.radioButtonTranslatorYandex);
            _radioButtonTranslatorYandex.Visibility = viewStateTranslation;
            _radioButtonTranslatorIbm            = FindViewById <RadioButton>(Resource.Id.radioButtonTranslatorIbm);
            _radioButtonTranslatorIbm.Visibility = viewStateTranslation;

            ViewStates viewStateTransLogin =
                ActivityCommon.IsTranslationRequired() ||
                (ActivityCommon.SelectedTranslator == ActivityCommon.TranslatorType.IbmWatson && ActivityCommon.IsTranslationAvailable()) ?
                ViewStates.Visible : ViewStates.Gone;

            _checkBoxTranslatorLogin            = FindViewById <CheckBox>(Resource.Id.checkBoxTranslatorLogin);
            _checkBoxTranslatorLogin.Visibility = viewStateTransLogin;

            _checkBoxAutoHideTitleBar = FindViewById <CheckBox>(Resource.Id.checkBoxAutoHideTitleBar);
            _checkBoxSuppressTitleBar = FindViewById <CheckBox>(Resource.Id.checkBoxSuppressTitleBar);
            _checkBoxFullScreenMode   = FindViewById <CheckBox>(Resource.Id.checkBoxFullScreenMode);

            ViewStates viewStateMultiWindow = Build.VERSION.SdkInt >= BuildVersionCodes.N ? ViewStates.Visible : ViewStates.Gone;

            _textViewCaptionMultiWindow                    = FindViewById <TextView>(Resource.Id.textViewCaptionMultiWindow);
            _checkBoxSwapMultiWindowOrientation            = FindViewById <CheckBox>(Resource.Id.checkBoxSwapMultiWindowOrientation);
            _textViewCaptionMultiWindow.Visibility         = viewStateMultiWindow;
            _checkBoxSwapMultiWindowOrientation.Visibility = viewStateMultiWindow;

            ViewStates viewStateInternet = Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop ? ViewStates.Visible : ViewStates.Gone;

            _textViewCaptionInternet            = FindViewById <TextView>(Resource.Id.textViewCaptionInternet);
            _radioGroupInternet                 = FindViewById <RadioGroup>(Resource.Id.radioGroupInternet);
            _textViewCaptionInternet.Visibility = viewStateInternet;
            _radioGroupInternet.Visibility      = viewStateInternet;

            _radioButtonInternetCellular = FindViewById <RadioButton>(Resource.Id.radioButtonInternetCellular);
            _radioButtonInternetWifi     = FindViewById <RadioButton>(Resource.Id.radioButtonInternetWifi);
            _radioButtonInternetEthernet = FindViewById <RadioButton>(Resource.Id.radioButtonInternetEthernet);

            _radioButtonAskForBtEnable = FindViewById <RadioButton>(Resource.Id.radioButtonAskForBtEnable);
            _radioButtonAlwaysEnableBt = FindViewById <RadioButton>(Resource.Id.radioButtonAlwaysEnableBt);
            _radioButtonNoBtHandling   = FindViewById <RadioButton>(Resource.Id.radioButtonNoBtHandling);

            _checkBoxDisableBtAtExit = FindViewById <CheckBox>(Resource.Id.checkBoxDisableBtAtExit);

            _radioButtonCommLockNone   = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockNone);
            _radioButtonCommLockCpu    = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockCpu);
            _radioButtonCommLockDim    = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockDim);
            _radioButtonCommLockBright = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockBright);

            _radioButtonLogLockNone   = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockNone);
            _radioButtonLogLockCpu    = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockCpu);
            _radioButtonLogLockDim    = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockDim);
            _radioButtonLogLockBright = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockBright);

            _checkBoxStoreDataLogSettings = FindViewById <CheckBox>(Resource.Id.checkBoxStoreDataLogSettings);

            _radioButtonStartOffline      = FindViewById <RadioButton>(Resource.Id.radioButtonStartOffline);
            _radioButtonStartConnect      = FindViewById <RadioButton>(Resource.Id.radioButtonStartConnect);
            _radioButtonStartConnectClose = FindViewById <RadioButton>(Resource.Id.radioButtonStartConnectClose);

            _checkBoxDoubleClickForAppExit = FindViewById <CheckBox>(Resource.Id.checkBoxDoubleClickForAppExit);
            _checkBoxSendDataBroadcast     = FindViewById <CheckBox>(Resource.Id.checkBoxSendDataBroadcast);

            _radioButtonUpdateOff   = FindViewById <RadioButton>(Resource.Id.radioButtonUpdateOff);
            _radioButtonUpdate1Day  = FindViewById <RadioButton>(Resource.Id.radioButtonUpdate1Day);
            _radioButtonUpdate1Week = FindViewById <RadioButton>(Resource.Id.radioButtonUpdate1Week);

            _textViewCaptionCpuUsage = FindViewById <TextView>(Resource.Id.textViewCaptionCpuUsage);
            _checkBoxCheckCpuUsage   = FindViewById <CheckBox>(Resource.Id.checkBoxCheckCpuUsage);
            ViewStates viewStateCpuUsage = ActivityCommon.IsCpuStatisticsSupported() ? ViewStates.Visible : ViewStates.Gone;

            _textViewCaptionCpuUsage.Visibility = viewStateCpuUsage;
            _checkBoxCheckCpuUsage.Visibility   = viewStateCpuUsage;

            _checkBoxCheckEcuFiles             = FindViewById <CheckBox>(Resource.Id.checkBoxCheckEcuFiles);
            _checkBoxShowBatteryVoltageWarning = FindViewById <CheckBox>(Resource.Id.checkBoxShowBatteryVoltageWarning);
            _checkBoxOldVagMode     = FindViewById <CheckBox>(Resource.Id.checkBoxOldVagMode);
            _checkBoxUseBmwDatabase = FindViewById <CheckBox>(Resource.Id.checkBoxUseBmwDatabase);
            _checkBoxScanAllEcus    = FindViewById <CheckBox>(Resource.Id.checkBoxScanAllEcus);

            _buttonStorageLocation        = FindViewById <Button>(Resource.Id.buttonStorageLocation);
            _buttonStorageLocation.Click += (sender, args) =>
            {
                SelectMedia();
            };

            ViewStates viewStateNotifications = Build.VERSION.SdkInt >= BuildVersionCodes.O ? ViewStates.Visible : ViewStates.Gone;

            _textViewCaptionNotifications     = FindViewById <TextView>(Resource.Id.textViewCaptionNotifications);
            _buttonManageNotifications        = FindViewById <Button>(Resource.Id.buttonManageNotifications);
            _buttonManageNotifications.Click += (sender, args) =>
            {
                ShowNotificationSettings();
            };
            _textViewCaptionNotifications.Visibility = viewStateNotifications;
            _buttonManageNotifications.Visibility    = viewStateNotifications;

            _checkBoxCollectDebugInfo = FindViewById <CheckBox>(Resource.Id.checkBoxCollectDebugInfo);

            ViewStates viewStateSnoopLog = _activityCommon.GetConfigHciSnoopLog(out bool _) ? ViewStates.Visible : ViewStates.Gone;

            _checkBoxHciSnoopLog            = FindViewById <CheckBox>(Resource.Id.checkBoxHciSnoopLog);
            _checkBoxHciSnoopLog.Visibility = viewStateSnoopLog;
            _checkBoxHciSnoopLog.Enabled    = false;

            _buttonHciSnoopLog            = FindViewById <Button>(Resource.Id.buttonHciSnoopLog);
            _buttonHciSnoopLog.Visibility = viewStateSnoopLog;
            _buttonHciSnoopLog.Click     += (sender, args) =>
            {
                ShowDevelopmentSettings();
            };

            _buttonDefaultSettings        = FindViewById <Button>(Resource.Id.buttonDefaultSettings);
            _buttonDefaultSettings.Click += (sender, args) =>
            {
                DefaultSettings();
            };

            _buttonExportSettings         = FindViewById <Button>(Resource.Id.buttonExportSettings);
            _buttonExportSettings.Enabled = allowExport;
            _buttonExportSettings.Click  += (sender, args) =>
            {
                ExportSettings();
            };

            _buttonImportSettings         = FindViewById <Button>(Resource.Id.buttonImportSettings);
            _buttonImportSettings.Enabled = allowImport;
            _buttonImportSettings.Click  += (sender, args) =>
            {
                ImportSettings();
            };

            ReadSettings();
            CheckSelection(_selection);
        }
示例#30
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            SetTheme(ActivityCommon.SelectedThemeId);
            base.OnCreate(savedInstanceState);

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SetContentView(Resource.Layout.settings);

            SetResult(Android.App.Result.Canceled);
            _selection = Intent.GetStringExtra(ExtraSelection);

            _activityCommon = new ActivityCommon(this);

            _radioButtonLocaleDefault = FindViewById <RadioButton>(Resource.Id.radioButtonLocaleDefault);
            _radioButtonLocaleEn      = FindViewById <RadioButton>(Resource.Id.radioButtonLocaleEn);
            _radioButtonLocaleDe      = FindViewById <RadioButton>(Resource.Id.radioButtonLocaleDe);
            _radioButtonLocaleRu      = FindViewById <RadioButton>(Resource.Id.radioButtonLocaleRu);

            _radioButtonThemeDark  = FindViewById <RadioButton>(Resource.Id.radioButtonThemeDark);
            _radioButtonThemeLight = FindViewById <RadioButton>(Resource.Id.radioButtonThemeLight);

            _checkBoxAutoHideTitleBar = FindViewById <CheckBox>(Resource.Id.checkBoxAutoHideTitleBar);
            _checkBoxSuppressTitleBar = FindViewById <CheckBox>(Resource.Id.checkBoxSuppressTitleBar);

            ViewStates viewStateMultiWindow = Build.VERSION.SdkInt >= BuildVersionCodes.N ? ViewStates.Visible : ViewStates.Gone;

            _textViewCaptionMultiWindow                    = FindViewById <TextView>(Resource.Id.textViewCaptionMultiWindow);
            _checkBoxSwapMultiWindowOrientation            = FindViewById <CheckBox>(Resource.Id.checkBoxSwapMultiWindowOrientation);
            _textViewCaptionMultiWindow.Visibility         = viewStateMultiWindow;
            _checkBoxSwapMultiWindowOrientation.Visibility = viewStateMultiWindow;

            ViewStates viewStateInternet = Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop ? ViewStates.Visible : ViewStates.Gone;

            _textViewCaptionInternet            = FindViewById <TextView>(Resource.Id.textViewCaptionInternet);
            _radioGroupInternet                 = FindViewById <RadioGroup>(Resource.Id.radioGroupInternet);
            _textViewCaptionInternet.Visibility = viewStateInternet;
            _radioGroupInternet.Visibility      = viewStateInternet;

            _radioButtonInternetCellular = FindViewById <RadioButton>(Resource.Id.radioButtonInternetCellular);
            _radioButtonInternetWifi     = FindViewById <RadioButton>(Resource.Id.radioButtonInternetWifi);
            _radioButtonInternetEthernet = FindViewById <RadioButton>(Resource.Id.radioButtonInternetEthernet);

            _radioButtonAskForBtEnable = FindViewById <RadioButton>(Resource.Id.radioButtonAskForBtEnable);
            _radioButtonAlwaysEnableBt = FindViewById <RadioButton>(Resource.Id.radioButtonAlwaysEnableBt);
            _radioButtonNoBtHandling   = FindViewById <RadioButton>(Resource.Id.radioButtonNoBtHandling);

            _checkBoxDisableBtAtExit = FindViewById <CheckBox>(Resource.Id.checkBoxDisableBtAtExit);

            _radioButtonCommLockNone   = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockNone);
            _radioButtonCommLockCpu    = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockCpu);
            _radioButtonCommLockDim    = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockDim);
            _radioButtonCommLockBright = FindViewById <RadioButton>(Resource.Id.radioButtonCommLockBright);

            _radioButtonLogLockNone   = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockNone);
            _radioButtonLogLockCpu    = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockCpu);
            _radioButtonLogLockDim    = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockDim);
            _radioButtonLogLockBright = FindViewById <RadioButton>(Resource.Id.radioButtonLogLockBright);

            _checkBoxStoreDataLogSettings = FindViewById <CheckBox>(Resource.Id.checkBoxStoreDataLogSettings);

            _radioButtonStartOffline      = FindViewById <RadioButton>(Resource.Id.radioButtonStartOffline);
            _radioButtonStartConnect      = FindViewById <RadioButton>(Resource.Id.radioButtonStartConnect);
            _radioButtonStartConnectClose = FindViewById <RadioButton>(Resource.Id.radioButtonStartConnectClose);

            _checkBoxDoubleClickForAppExit = FindViewById <CheckBox>(Resource.Id.checkBoxDoubleClickForAppExit);
            _checkBoxSendDataBroadcast     = FindViewById <CheckBox>(Resource.Id.checkBoxSendDataBroadcast);

            _radioButtonUpdateOff   = FindViewById <RadioButton>(Resource.Id.radioButtonUpdateOff);
            _radioButtonUpdate1Day  = FindViewById <RadioButton>(Resource.Id.radioButtonUpdate1Day);
            _radioButtonUpdate1Week = FindViewById <RadioButton>(Resource.Id.radioButtonUpdate1Week);

            _textViewCaptionCpuUsage = FindViewById <TextView>(Resource.Id.textViewCaptionCpuUsage);
            _checkBoxCheckCpuUsage   = FindViewById <CheckBox>(Resource.Id.checkBoxCheckCpuUsage);
            ViewStates viewStateCpuUsage = ActivityCommon.IsCpuStatisticsSupported() ? ViewStates.Visible : ViewStates.Gone;

            _textViewCaptionCpuUsage.Visibility = viewStateCpuUsage;
            _checkBoxCheckCpuUsage.Visibility   = viewStateCpuUsage;

            _checkBoxCheckEcuFiles             = FindViewById <CheckBox>(Resource.Id.checkBoxCheckEcuFiles);
            _checkBoxShowBatteryVoltageWarning = FindViewById <CheckBox>(Resource.Id.checkBoxShowBatteryVoltageWarning);
            _checkBoxOldVagMode     = FindViewById <CheckBox>(Resource.Id.checkBoxOldVagMode);
            _checkBoxUseBmwDatabase = FindViewById <CheckBox>(Resource.Id.checkBoxUseBmwDatabase);
            _checkBoxScanAllEcus    = FindViewById <CheckBox>(Resource.Id.checkBoxScanAllEcus);

            _buttonStorageLocation        = FindViewById <Button>(Resource.Id.buttonStorageLocation);
            _buttonStorageLocation.Click += (sender, args) =>
            {
                SelectMedia();
            };

            ViewStates viewStateNotifications = Build.VERSION.SdkInt >= BuildVersionCodes.O ? ViewStates.Visible : ViewStates.Gone;

            _textViewCaptionNotifications     = FindViewById <TextView>(Resource.Id.textViewCaptionNotifications);
            _buttonManageNotifications        = FindViewById <Button>(Resource.Id.buttonManageNotifications);
            _buttonManageNotifications.Click += (sender, args) =>
            {
                ShowNotificationSettings();
            };
            _textViewCaptionNotifications.Visibility = viewStateNotifications;
            _buttonManageNotifications.Visibility    = viewStateNotifications;

            _checkBoxCollectDebugInfo = FindViewById <CheckBox>(Resource.Id.checkBoxCollectDebugInfo);

            ViewStates viewStateSnoopLog = _activityCommon.GetConfigHciSnoopLog(out bool _) ? ViewStates.Visible : ViewStates.Gone;

            _checkBoxHciSnoopLog            = FindViewById <CheckBox>(Resource.Id.checkBoxHciSnoopLog);
            _checkBoxHciSnoopLog.Visibility = viewStateSnoopLog;
            _checkBoxHciSnoopLog.Enabled    = false;

            _buttonHciSnoopLog            = FindViewById <Button>(Resource.Id.buttonHciSnoopLog);
            _buttonHciSnoopLog.Visibility = viewStateSnoopLog;
            _buttonHciSnoopLog.Click     += (sender, args) =>
            {
                ShowDevelopmentSettings();
            };

            ReadSettings();
            CheckSelection(_selection);
        }