コード例 #1
0
  @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);
    }
  }
コード例 #2
0
  public void refreshData(DialogInterface dialog) {
    txtSectionSelection.setText(
        mLanguageManager.getSelectedSection() + ": " + Prefs.getKey(Prefs.SECTION_NAME));

    WaiterPadApplication.LOG.debug("menu obtained .. ");
    dialog.dismiss();
    Intent intent = new Intent(SettingsActivity.this, TableListActivity.class);
    startActivity(intent);
    // activity out animation
    Global.activityFinishAnimationLeftToRight(SettingsActivity.this);
    finish();
  }
コード例 #3
0
  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();
  }
コード例 #4
0
  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());
          }
        });
  }
コード例 #5
0
  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);
    }
  }
コード例 #6
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.txtLeftMenuLink:
        Intent browserIntent =
            new Intent(Intent.ACTION_VIEW, Uri.parse("http://" + getString(R.string.site)));

        // changes as on 2nd Jan 2014
        StartActivity.currentIntent = browserIntent;
        // changes end here

        startActivity(browserIntent);
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

        // changes as on 15th July 2013
        // added this because of design changes
      case R.id.menuIcon:
        toggle();
        setSelectedView();
        break;

      case R.id.txtLanguage:
        setSelectedView();
        languageCall();
        break;

      case R.id.txtSectionSelection:
        setSelectedView();
        showSectionBox();
        break;

      case R.id.txtConfigureSettings:
        setSelectedView();
        Intent intent = new Intent(SettingsActivity.this, ConfigureServiceActivity.class);
        intent.putExtra(Global.FROM_ACTIVITY, TAG);
        startActivity(intent);
        // activity in animation
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

      case R.id.txtForceSync:
        setSelectedView();
        // sync all data
        GetAllDataAsyncTask getAllDataAsyncTask =
            new GetAllDataAsyncTask(SettingsActivity.this, Global.SETTINGS);
        getAllDataAsyncTask.execute();
        break;

      case R.id.txtSendLog:
        setSelectedView();
        InputStream is = mUtils.readFromLogFile();

        if (is != null) {
          sendLogAsyncTask = new SendLogAsyncTask(SettingsActivity.this, is);
          sendLogAsyncTask.execute();
        }

        break;

      case R.id.txtLogout:
        setSelectedView();
        callDialog(Global.FROM_EXIT);
        break;

      case R.id.lnrSectionSelection:
        showSectionBox();
        setSelectedView();
        break;

      case R.id.lnrLanguage:
        languageCall();
        setSelectedView();
        break;

      case R.id.txtSyncMenu:
        // sync just the menu
        showSyncDialogBox();
        setSelectedView();
        break;

      case R.id.btnPlaceOrderLeftMenu:
        // lead to the table selection list
        Prefs.addKey(Prefs.MENU_SELECTED, Global.TABLES);
        setSelectedView();
        intent = new Intent(this, TableListActivity.class);
        startActivity(intent);
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

      case R.id.txtSettingsLeftMenu:
        toggle();
        Prefs.addKey(Prefs.MENU_SELECTED, Global.SETTINGS);
        setSelectedView();
        break;

      case R.id.txtOrdersLeftMenu:
        Prefs.addKey(Prefs.MENU_SELECTED, Global.ORDERS);
        setSelectedView();
        finish();
        intent = new Intent(this, MyOrderActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(intent);
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

      case R.id.txtNotificationsLeftMenu:
        // take to the notification screen
        Prefs.addKey(Prefs.MENU_SELECTED, Global.NOTIFICATIONS);
        setSelectedView();
        intent = new Intent(this, NotificationListActivity.class);
        startActivity(intent);
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

      case R.id.relNotificationCentre:
        Prefs.addKey(Prefs.MENU_SELECTED, Global.NOTIFICATIONS);
        setSelectedView();
        intent = new Intent(this, NotificationListActivity.class);
        startActivity(intent);
        overridePendingTransition(R.anim.activity_in_anim, R.anim.activity_out_anim);
        break;

      case R.id.txtTablesLeftMenu:
        Prefs.addKey(Prefs.MENU_SELECTED, Global.TABLES);
        setSelectedView();
        intent = new Intent(this, TableListActivity.class);
        startActivity(intent);
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

      case R.id.btnLeftMenuLock:
        intent = new Intent(this, LoginActivity.class);
        intent.putExtra(Global.ACTION, Global.FROM_LOCK);
        startActivity(intent);
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

      case R.id.btnLeftMenuWaiterChange:
        callDialog(Global.FROM_CHANGE_WAITER_CODE);
        break;

      default:
        break;
    }
  }
コード例 #7
0
  @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();
  }
コード例 #8
0
  @Override
  public void onBackPressed() {
    // unregisterReceiver(SettingsFragment.this);
    if (isSectionSelectionChanged != true) {
      if (mFrom != null && mFrom.equalsIgnoreCase(Global.FROM_HOME_ACTIVITY)) {
        finish();
        Intent intent = new Intent(SettingsActivity.this, MyOrderActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(intent);
        // activity out animation
        Global.activityFinishAnimationLeftToRight(SettingsActivity.this);
      } else if (mFrom != null && mFrom.equalsIgnoreCase(Global.FROM_TABLE_LIST)) {

        if (sectionId != null && sectionId.trim().length() > 0) {
          Prefs.addKey(SettingsActivity.this, Prefs.SECTION_ID, sectionId);
          Prefs.addKey(SettingsActivity.this, Prefs.SECTION_NAME, sectionName);
        }

        Intent intent = new Intent(SettingsActivity.this, TableListActivity.class);
        startActivity(intent);

        // activity out animation
        Global.activityFinishAnimationLeftToRight(SettingsActivity.this);
        finish();
      } else if (mFrom != null && mFrom.equalsIgnoreCase(Global.FROM_ORDER_RELATED)) {
        Intent intent = new Intent(SettingsActivity.this, OrderRelatedActivity.class);
        intent.putExtra(Global.TIME_STAMP, mTimestamp);

        if (previousValue != null && previousValue.trim().length() > 0) {
          intent.putExtra(Global.FROM_ACTIVITY, previousValue);
        } else {
          intent.putExtra(Global.FROM_ACTIVITY, Global.FROM_TABLE_LIST);
        }
        startActivity(intent);

        // activity out animation
        Global.activityFinishAnimationLeftToRight(SettingsActivity.this);
        finish();
      } else if (mFrom != null && mFrom.equalsIgnoreCase(Global.FROM_TABLE_ORDER_LIST)) {
        if (previousValue != null) {
          if (previousValue.equalsIgnoreCase(Global.FROM_TABLE_LIST)) {
            Intent intent = new Intent(SettingsActivity.this, TableOrderListActivity.class);
            intent.putExtra(Global.TABLE_ID, mTableId);
            intent.putExtra(Global.TABLE_NUMBER, mTableNumber);
            intent.putExtra(Global.FROM_ACTIVITY, previousValue);
            startActivity(intent);

            // activity out animation
            Global.activityFinishAnimationLeftToRight(SettingsActivity.this);
            finish();
          }
        } else {
          Intent intent = new Intent(SettingsActivity.this, TableOrderListActivity.class);
          intent.putExtra(Global.TABLE_ID, mTableId);
          intent.putExtra(Global.TABLE_NUMBER, mTableNumber);
          intent.putExtra(Global.FROM_ACTIVITY, Global.FROM_TABLE_LIST);
          startActivity(intent);

          // activity out animation
          Global.activityFinishAnimationLeftToRight(SettingsActivity.this);
          finish();
        }
      } else if (mFrom == null) {
        // activity out animation
        finish();
        Global.activityFinishAnimationLeftToRight(SettingsActivity.this);
        super.onBackPressed();
      }
    } else {
      // section has been changed
      Intent intent = new Intent(SettingsActivity.this, TableListActivity.class);
      startActivity(intent);
      // activity out animation
      Global.activityFinishAnimationLeftToRight(SettingsActivity.this);
      finish();
    }
  }