@Override public void onClick(DialogInterface dialog, int which) { // checks if this button is the ok button or not if (which == -1) { // if just ok is pressed then get the selected first value Section section = lstSection.get(selectionVal); sectionId = String.valueOf(section.getSectionId()); sectionName = section.getSectionName().toString(); Prefs.addKey(SettingsActivity.this, Prefs.SECTION_ID, sectionId); Prefs.addKey(SettingsActivity.this, Prefs.SECTION_NAME, sectionName); txtSectionSelection.setText(mLanguageManager.getSelectedSection() + ": " + sectionName); Global.logd(TAG + " section name: " + sectionName); txtSectionSelection.setTextColor(getResources().getColor(R.color.black)); dialog.dismiss(); } else if (which != -1) { isSectionSelectionChanged = true; selectionVal = which; Section section = lstSection.get(which); sectionId = String.valueOf(section.getSectionId()); sectionName = section.getSectionName().toString(); Log.i(TAG, "value of sectionId : " + sectionId); Prefs.addKey(SettingsActivity.this, Prefs.SECTION_ID, sectionId); Prefs.addKey(SettingsActivity.this, Prefs.SECTION_NAME, sectionName); refreshData(dialog); } }
public void refreshGUI(String name) { try { mUtils.changeKeyBoardSettings(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } Global.logd(TAG + " name of string to be passed ! "); langSelection = name; setGuiLabels(); }
public void setButtonWidth() { final int offset = getWidth() / 3; Global.logd(TAG + " offset " + offset); mBtnLockLeftMenu.post( new Runnable() { @Override public void run() { mBtnLockLeftMenu.setWidth(offset); Log.i("Dhara", "mBtnLockLeftMenu " + mBtnLockLeftMenu.getWidth()); } }); mBtnWaiterChangeLeftMenu.post( new Runnable() { @Override public void run() { mBtnWaiterChangeLeftMenu.setWidth(offset); Log.i("Dhara", "mBtnChangeWaiterLeftMenu " + mBtnWaiterChangeLeftMenu.getWidth()); } }); }
public void logoutMessage(WaiterPadResponse result, String fromWhere) { if (result != null) { if (result.isError() && result.getErrorMessage().toLowerCase().contains("invalid")) { String message = mLanguageManager.getInvalidUser(); showMessage(message); if (editEnterPinToExit != null) { editEnterPinToExit.setText(""); } } else if (result.isError() && result.getErrorMessage().toLowerCase().contains("device not registred")) { /*String message = mLanguageManager.getDeviceNotRegistered(); showMessage(message); if (editEnterPinToExit != null) { editEnterPinToExit.setText(""); }*/ // only when the valid pin is entered // this will be reached // so exit user, since device not registered will only happen // when iiko is restarted. // changes as on 22nd Jan 2014 Intent intent = new Intent(SettingsActivity.this, ExitActivity.class); intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); // intent.putExtra(Global.FROM_ACTIVITY, // Global.FROM_SPLASH); startActivity(intent); finish(); Global.activityStartAnimationRightToLeft(SettingsActivity.this); // changes end here } else { if (builderEnterPin != null) { builderEnterPin.dismiss(); } // Remove from sharedpreferences String[] keys = new String[] {Prefs.WAITER_CODE, Prefs.WAITER_ID, Prefs.WAITER_NAME, Prefs.USER_PIN}; Prefs.removeKeys(SettingsActivity.this, keys); Prefs.addKey(SettingsActivity.this, Prefs.LANGUAGE_SELECTED, langSelection); stopService(SettingsActivity.this); Global.logd(TAG + " From : " + fromWhere); if (fromWhere != null) { if (fromWhere.equalsIgnoreCase(Global.FROM_CHANGE_WAITER_CODE)) { Intent intent = new Intent(SettingsActivity.this, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Global.FROM_ACTIVITY, Global.FROM_SPLASH); startActivity(intent); finish(); Global.activityStartAnimationRightToLeft(SettingsActivity.this); } else if (fromWhere.equalsIgnoreCase(Global.FROM_EXIT)) { Log.d("Home", "exit else if condition"); Intent intent = new Intent(SettingsActivity.this, ExitActivity.class); intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); // intent.putExtra(Global.FROM_ACTIVITY, // Global.FROM_SPLASH); startActivity(intent); finish(); Global.activityStartAnimationRightToLeft(SettingsActivity.this); } } } } else { // commenting this, as Nick wants the ability to logout when // the server is not reachable /*String message = mLanguageManager.getServerUnreachable(); showMessage(message); if (editEnterPinToExit != null) { editEnterPinToExit.setText(""); }*/ // exiting the app since it would have been called only when the correct pin is entered // so instead of displaying the message the app will exit normally Intent intent = new Intent(SettingsActivity.this, ExitActivity.class); intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); // intent.putExtra(Global.FROM_ACTIVITY, // Global.FROM_SPLASH); startActivity(intent); finish(); Global.activityStartAnimationRightToLeft(SettingsActivity.this); } }
@SuppressWarnings("unchecked") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Global.logd(TAG + " on create called "); setContentView(R.layout.activity_settings); mLanguageManager = LanguageManager.getInstance(); SlidingMenu menu = new SlidingMenu(this); menu.setShadowWidthRes(R.dimen.shadow_res); menu.setFadeDegree(0.35f); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.layout_left_menu, null); setBehindContentView(view); // changes as on 2nd Jan 2014 StartActivity.currentIntent = getIntent(); // changes end here getSlidingMenu().setFadeEnabled(true); getSlidingMenu().setFadeDegree(0.35f); getSlidingMenu().setSlidingEnabled(true); getSlidingMenu().setSelectorEnabled(true); getSlidingMenu().setSelected(true); getSlidingMenu().setShadowDrawable(R.drawable.drop_shadow_for_menu); getSlidingMenu().setBehindOffset((int) getWidth() / 3); getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); // registerReceiver(SettingsFragment.this); if (getIntent().getExtras() != null) { if (getIntent().getStringExtra(Global.FROM_ACTIVITY) != null) { mFrom = getIntent().getStringExtra(Global.FROM_ACTIVITY); } if (getIntent().getStringExtra(Global.TIME_STAMP) != null) { mTimestamp = getIntent().getStringExtra(Global.TIME_STAMP); } if (getIntent().getStringExtra(Global.PREVIOUS) != null) { previousValue = getIntent().getStringExtra(Global.PREVIOUS); } if (getIntent().getStringExtra(Global.TABLE_ID) != null) { mTableId = getIntent().getStringExtra(Global.TABLE_ID); } if (getIntent().getStringExtra(Global.TABLE_NUMBER) != null) { mTableNumber = getIntent().getStringExtra(Global.TABLE_NUMBER); } } txtHeader = (TextView) findViewById(R.id.txtHeader); txtSectionSelection = (TextView) findViewById(R.id.txtSectionSelection); txtLanguage = (TextView) findViewById(R.id.txtLanguage); txtConfigureSettings = (TextView) findViewById(R.id.txtConfigureSettings); txtForceSync = (TextView) findViewById(R.id.txtForceSync); txtSyncMenu = (TextView) findViewById(R.id.txtSyncMenu); txtSendLog = (TextView) findViewById(R.id.txtSendLog); txtLogout = (TextView) findViewById(R.id.txtLogout); lnrSectionBox = (LinearLayout) findViewById(R.id.lnrSectionSelection); mTxtNotificationsEnabled = (TextView) findViewById(R.id.txtNotificationSettings); lnrLanguageBox = (LinearLayout) findViewById(R.id.lnrLanguage); mTxtNotificationCount = (TextView) findViewById(R.id.txtNotificationNumber); mRelNotificationCentre = (RelativeLayout) findViewById(R.id.relNotificationCentre); // changes as on 16th july 2013 mTxtLeftMenuWaiterName = (TextView) view.findViewById(R.id.txtWaiterName); mTxtLeftMenuOrders = (TextView) view.findViewById(R.id.txtOrdersLeftMenu); mTxtLeftMenuSettings = (TextView) view.findViewById(R.id.txtSettingsLeftMenu); mTxtLeftMenuLink = (TextView) view.findViewById(R.id.txtLeftMenuLink); mTxtLeftMenuNotifications = (TextView) view.findViewById(R.id.txtNotificationsLeftMenu); mTxtLeftMenuTables = (TextView) view.findViewById(R.id.txtTablesLeftMenu); mBtnLockLeftMenu = (Button) view.findViewById(R.id.btnLeftMenuLock); mBtnWaiterChangeLeftMenu = (Button) view.findViewById(R.id.btnLeftMenuWaiterChange); mBtnPlaceOrderLeftMenu = (Button) view.findViewById(R.id.btnPlaceOrderLeftMenu); imageMenuIcon = (ImageButton) findViewById(R.id.menuIcon); // changes as on 6th December 2013 mSwitchForNotifications = (Switch) findViewById(R.id.switchForNotifications); if (Prefs.getKey_boolean_with_default_true(this, Prefs.ARE_NOTIFICATIONS_ENABLED)) { mSwitchForNotifications.setChecked(true); } else { mSwitchForNotifications.setChecked(false); } mSwitchForNotifications.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Log.i("dhara", "isChecked : " + isChecked); Prefs.addKey(SettingsActivity.this, Prefs.ARE_NOTIFICATIONS_ENABLED, isChecked); } }); mSwitchForNotifications.setOnClickListener( new OnClickListener() { @Override public void onClick(View view) { // do nothing } }); // changes end here mTxtLeftMenuLink.setMovementMethod(LinkMovementMethod.getInstance()); mTxtLeftMenuLink.setLinksClickable(true); mTxtLeftMenuOrders.setOnClickListener(this); mTxtLeftMenuSettings.setOnClickListener(this); mTxtLeftMenuNotifications.setOnClickListener(this); mTxtLeftMenuTables.setOnClickListener(this); mBtnPlaceOrderLeftMenu.setOnClickListener(this); mBtnLockLeftMenu.setOnClickListener(this); mBtnWaiterChangeLeftMenu.setOnClickListener(this); imageMenuIcon.setOnClickListener(this); mTxtLeftMenuLink.setOnClickListener(this); mRelNotificationCentre.setOnClickListener(this); sectionCache = SectionManager.getInstance().getSectionCache(); mUtils = new Utils(SettingsActivity.this); sectionId = Prefs.getKey(Prefs.SECTION_ID); sectionName = Prefs.getKey(Prefs.SECTION_NAME); waiterName = Prefs.getKey(Prefs.WAITER_NAME); mTxtLeftMenuWaiterName.setText(waiterName); // Get the language selection value from shared preferences // show it on the screen langSelection = Prefs.getKey(Prefs.LANGUAGE_SELECTED); // Gets the list of languages mLanguageList = (List<String>) LanguageManager.getInstance().getLanguageCache().get(Global.LANGUAGES); Log.i(TAG, "value of mLanguageList " + mLanguageList); if (mLanguageList != null && mLanguageList.size() > 0) { // set the first value if (langSelection != null && langSelection.trim().length() > 0) { // Get the language xml file to set the values of the GUI String language = mLanguageManager.getStartNode(); if (!langSelection.equalsIgnoreCase(language)) { getLanguageXmlAsyncTask = new GetLanguageXmlAsyncTask(SettingsActivity.this, langSelection); getLanguageXmlAsyncTask.execute(); } else { setGuiLabels(); } } } if (sectionId != null && sectionId.trim().length() > 0) { if (Prefs.getKey(Prefs.SECTION_NAME) != null && Prefs.getKey(Prefs.SECTION_NAME).trim().length() > 0) { txtSectionSelection.setText(mLanguageManager.getSelectedSection() + ": " + sectionName); } } txtHeader.setText(mLanguageManager.getSettings()); txtSectionSelection.setOnClickListener(SettingsActivity.this); txtLanguage.setOnClickListener(SettingsActivity.this); txtConfigureSettings.setOnClickListener(SettingsActivity.this); txtForceSync.setOnClickListener(SettingsActivity.this); txtSyncMenu.setOnClickListener(SettingsActivity.this); txtSendLog.setOnClickListener(SettingsActivity.this); txtLogout.setOnClickListener(SettingsActivity.this); lnrLanguageBox.setOnClickListener(SettingsActivity.this); lnrSectionBox.setOnClickListener(SettingsActivity.this); Prefs.addKey(SettingsActivity.this, Prefs.MENU_SELECTED, Global.SETTINGS); mTxtLeftMenuSettings.setPressed(true); setGuiLabels(); }