Example usage for android.os Bundle getBoolean

List of usage examples for android.os Bundle getBoolean

Introduction

In this page you can find the example usage for android.os Bundle getBoolean.

Prototype

public boolean getBoolean(String key) 

Source Link

Document

Returns the value associated with the given key, or false if no mapping of the desired type exists for the given key.

Usage

From source file:com.android.dialer.DialtactsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Trace.beginSection(TAG + " onCreate");
    super.onCreate(savedInstanceState);

    mFirstLaunch = true;/*ww w  .j  a  v a  2 s  .com*/

    final Resources resources = getResources();
    mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large);

    Trace.beginSection(TAG + " setContentView");
    setContentView(R.layout.dialtacts_activity);
    Trace.endSection();
    getWindow().setBackgroundDrawable(null);

    Trace.beginSection(TAG + " setup Views");
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setCustomView(R.layout.search_edittext);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setBackgroundDrawable(null);

    SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView()
            .findViewById(R.id.search_view_container);
    searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener);

    mActionBarController = new ActionBarController(this, searchEditTextLayout);

    mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view);
    mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
    mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button);
    searchEditTextLayout.findViewById(R.id.search_magnifying_glass)
            .setOnClickListener(mSearchViewOnClickListener);
    searchEditTextLayout.findViewById(R.id.search_box_start_search)
            .setOnClickListener(mSearchViewOnClickListener);
    searchEditTextLayout.setOnClickListener(mSearchViewOnClickListener);
    searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() {
        @Override
        public void onBackButtonClicked() {
            onBackPressed();
        }

        @Override
        public void onSearchViewClicked() {
            // Hide FAB, as the keyboard is shown.
            mFloatingActionButtonController.scaleOut();
        }
    });

    mIsLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    mPreviouslySelectedTabIndex = ListsFragment.TAB_INDEX_SPEED_DIAL;
    final View floatingActionButtonContainer = findViewById(R.id.floating_action_button_container);
    ImageButton floatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
    floatingActionButton.setOnClickListener(this);
    mFloatingActionButtonController = new FloatingActionButtonController(this, floatingActionButtonContainer,
            floatingActionButton);

    ImageButton optionsMenuButton = (ImageButton) searchEditTextLayout
            .findViewById(R.id.dialtacts_options_menu_button);
    optionsMenuButton.setOnClickListener(this);
    mOverflowMenu = buildOptionsMenu(searchEditTextLayout);
    optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener());

    // Add the favorites fragment but only if savedInstanceState is null. Otherwise the
    // fragment manager is responsible for recreating it.
    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT).commit();
    } else {
        mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
        mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI);
        mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI);
        mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
        mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN);
        mActionBarController.restoreInstanceState(savedInstanceState);
    }

    final boolean isLayoutRtl = DialerUtils.isRtl();
    if (mIsLandscape) {
        mSlideIn = AnimationUtils.loadAnimation(this,
                isLayoutRtl ? R.anim.dialpad_slide_in_left : R.anim.dialpad_slide_in_right);
        mSlideOut = AnimationUtils.loadAnimation(this,
                isLayoutRtl ? R.anim.dialpad_slide_out_left : R.anim.dialpad_slide_out_right);
    } else {
        mSlideIn = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_in_bottom);
        mSlideOut = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_out_bottom);
    }

    mSlideIn.setInterpolator(AnimUtils.EASE_IN);
    mSlideOut.setInterpolator(AnimUtils.EASE_OUT);

    mSlideIn.setAnimationListener(mSlideInListener);
    mSlideOut.setAnimationListener(mSlideOutListener);

    mParentLayout = (CoordinatorLayout) findViewById(R.id.dialtacts_mainlayout);
    mParentLayout.setOnDragListener(new LayoutOnDragListener());
    floatingActionButtonContainer.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    final ViewTreeObserver observer = floatingActionButtonContainer.getViewTreeObserver();
                    if (!observer.isAlive()) {
                        return;
                    }
                    observer.removeOnGlobalLayoutListener(this);
                    int screenWidth = mParentLayout.getWidth();
                    mFloatingActionButtonController.setScreenWidth(screenWidth);
                    mFloatingActionButtonController.align(getFabAlignment(), false /* animate */);
                }
            });

    Trace.endSection();

    Trace.beginSection(TAG + " initialize smart dialing");
    mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this);
    SmartDialPrefix.initializeNanpSettings(this);
    Trace.endSection();
    Trace.endSection();
}

From source file:com.irccloud.android.fragment.MessageViewFragment.java

@Override
public void setArguments(Bundle args) {
    ready = false;//from w  ww  . ja va  2 s.c o m
    if (heartbeatTask != null)
        heartbeatTask.cancel(true);
    heartbeatTask = null;
    if (tapTimerTask != null)
        tapTimerTask.cancel();
    tapTimerTask = null;
    if (buffer != null && buffer.bid != args.getInt("bid", -1) && adapter != null)
        adapter.clearLastSeenEIDMarker();
    buffer = BuffersDataSource.getInstance().getBuffer(args.getInt("bid", -1));
    if (buffer != null) {
        server = ServersDataSource.getInstance().getServer(buffer.cid);
        Crashlytics.log(Log.DEBUG, "IRCCloud", "MessageViewFragment: switched to bid: " + buffer.bid);
    } else {
        Crashlytics.log(Log.WARN, "IRCCloud", "MessageViewFragment: couldn't find buffer to switch to");
    }
    requestingBacklog = false;
    avgInsertTime = 0;
    newMsgs = 0;
    newMsgTime = 0;
    newHighlights = 0;
    earliest_eid = 0;
    backlog_eid = 0;
    currentCollapsedEid = -1;
    lastCollapsedDay = -1;
    if (server != null) {
        ignore.setIgnores(server.ignores);
        if (server.away != null && server.away.length() > 0) {
            awayTxt.setText(ColorFormatter
                    .html_to_spanned(
                            ColorFormatter.irc_to_html(TextUtils.htmlEncode("Away (" + server.away + ")")))
                    .toString());
            awayView.setVisibility(View.VISIBLE);
        } else {
            awayView.setVisibility(View.GONE);
        }
        collapsedEvents.setServer(server);
        update_status(server.status, server.fail_info);
    }
    if (unreadTopView != null)
        unreadTopView.setVisibility(View.GONE);
    backlogFailed.setVisibility(View.GONE);
    loadBacklogButton.setVisibility(View.GONE);
    try {
        if (getListView().getHeaderViewsCount() == 0) {
            getListView().addHeaderView(headerViewContainer);
        }
    } catch (IllegalStateException e) {
    }
    ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) headerView.getLayoutParams();
    lp.topMargin = 0;
    headerView.setLayoutParams(lp);
    lp = (ViewGroup.MarginLayoutParams) backlogFailed.getLayoutParams();
    lp.topMargin = 0;
    backlogFailed.setLayoutParams(lp);
    if (buffer != null && EventsDataSource.getInstance().getEventsForBuffer(buffer.bid) != null) {
        requestingBacklog = true;
        if (refreshTask != null)
            refreshTask.cancel(true);
        refreshTask = new RefreshTask();
        if (args.getBoolean("fade")) {
            Crashlytics.log(Log.DEBUG, "IRCCloud",
                    "MessageViewFragment: Loading message contents in the background");
            refreshTask.execute((Void) null);
        } else {
            Crashlytics.log(Log.DEBUG, "IRCCloud", "MessageViewFragment: Loading message contents");
            refreshTask.onPreExecute();
            refreshTask.onPostExecute(refreshTask.doInBackground());
        }
    } else {
        if (buffer == null || buffer.min_eid == 0 || earliest_eid == buffer.min_eid
                || conn.getState() != NetworkConnection.STATE_CONNECTED || !conn.ready) {
            headerView.setVisibility(View.GONE);
        } else {
            headerView.setVisibility(View.VISIBLE);
        }
        if (adapter != null) {
            adapter.clear();
            adapter.notifyDataSetInvalidated();
        }
        mListener.onMessageViewReady();
        ready = true;
    }
}

From source file:android.support.mediacompat.client.ClientBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    MediaControllerCompat controller;/*from  ww w . j  av a 2 s . co  m*/
    try {
        controller = new MediaControllerCompat(context,
                (MediaSessionCompat.Token) extras.getParcelable(KEY_SESSION_TOKEN));
    } catch (RemoteException ex) {
        // Do nothing.
        return;
    }
    int method = extras.getInt(KEY_METHOD_ID, 0);

    if (ACTION_CALL_MEDIA_CONTROLLER_METHOD.equals(intent.getAction()) && extras != null) {
        Bundle arguments;
        switch (method) {
        case SEND_COMMAND:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controller.sendCommand(arguments.getString("command"), arguments.getBundle("extras"),
                    new ResultReceiver(null));
            break;
        case ADD_QUEUE_ITEM:
            controller.addQueueItem((MediaDescriptionCompat) extras.getParcelable(KEY_ARGUMENT));
            break;
        case ADD_QUEUE_ITEM_WITH_INDEX:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controller.addQueueItem((MediaDescriptionCompat) arguments.getParcelable("description"),
                    arguments.getInt("index"));
            break;
        case REMOVE_QUEUE_ITEM:
            controller.removeQueueItem((MediaDescriptionCompat) extras.getParcelable(KEY_ARGUMENT));
            break;
        case SET_VOLUME_TO:
            controller.setVolumeTo(extras.getInt(KEY_ARGUMENT), 0);
            break;
        case ADJUST_VOLUME:
            controller.adjustVolume(extras.getInt(KEY_ARGUMENT), 0);
            break;
        }
    } else if (ACTION_CALL_TRANSPORT_CONTROLS_METHOD.equals(intent.getAction()) && extras != null) {
        TransportControls controls = controller.getTransportControls();
        Bundle arguments;
        switch (method) {
        case PLAY:
            controls.play();
            break;
        case PAUSE:
            controls.pause();
            break;
        case STOP:
            controls.stop();
            break;
        case FAST_FORWARD:
            controls.fastForward();
            break;
        case REWIND:
            controls.rewind();
            break;
        case SKIP_TO_PREVIOUS:
            controls.skipToPrevious();
            break;
        case SKIP_TO_NEXT:
            controls.skipToNext();
            break;
        case SEEK_TO:
            controls.seekTo(extras.getLong(KEY_ARGUMENT));
            break;
        case SET_RATING:
            controls.setRating((RatingCompat) extras.getParcelable(KEY_ARGUMENT));
            break;
        case PLAY_FROM_MEDIA_ID:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.playFromMediaId(arguments.getString("mediaId"), arguments.getBundle("extras"));
            break;
        case PLAY_FROM_SEARCH:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.playFromSearch(arguments.getString("query"), arguments.getBundle("extras"));
            break;
        case PLAY_FROM_URI:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.playFromUri((Uri) arguments.getParcelable("uri"), arguments.getBundle("extras"));
            break;
        case SEND_CUSTOM_ACTION:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.sendCustomAction(arguments.getString("action"), arguments.getBundle("extras"));
            break;
        case SEND_CUSTOM_ACTION_PARCELABLE:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.sendCustomAction((PlaybackStateCompat.CustomAction) arguments.getParcelable("action"),
                    arguments.getBundle("extras"));
            break;
        case SKIP_TO_QUEUE_ITEM:
            controls.skipToQueueItem(extras.getLong(KEY_ARGUMENT));
            break;
        case PREPARE:
            controls.prepare();
            break;
        case PREPARE_FROM_MEDIA_ID:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.prepareFromMediaId(arguments.getString("mediaId"), arguments.getBundle("extras"));
            break;
        case PREPARE_FROM_SEARCH:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.prepareFromSearch(arguments.getString("query"), arguments.getBundle("extras"));
            break;
        case PREPARE_FROM_URI:
            arguments = extras.getBundle(KEY_ARGUMENT);
            controls.prepareFromUri((Uri) arguments.getParcelable("uri"), arguments.getBundle("extras"));
            break;
        case SET_CAPTIONING_ENABLED:
            controls.setCaptioningEnabled(extras.getBoolean(KEY_ARGUMENT));
            break;
        case SET_REPEAT_MODE:
            controls.setRepeatMode(extras.getInt(KEY_ARGUMENT));
            break;
        case SET_SHUFFLE_MODE:
            controls.setShuffleMode(extras.getInt(KEY_ARGUMENT));
            break;
        }
    }
}

From source file:com.skytree.epubtest.BookViewActivity.java

public void makeLayout() {
    // make fonts
    this.makeFonts();
    // clear the existing themes. 
    themes.clear();/*from   w  w w .j  a v  a 2s  .c  om*/
    // add themes 
    // String name,int foregroundColor,int backgroundColor,int controlColor,int controlHighlightColor,int seekBarColor,int seekThumbColor,int selectorColor,int selectionColor,String portraitName,String landscapeName,String doublePagedName,int bookmarkId
    themes.add(new Theme("white", Color.BLACK, 0xffffffff, Color.argb(240, 94, 61, 35), Color.LTGRAY,
            Color.argb(240, 94, 61, 35), Color.argb(120, 160, 124, 95), Color.DKGRAY, 0x22222222,
            "Phone-Portrait-White.png", "Phone-Landscape-White.png", "Phone-Landscape-Double-White.png",
            R.drawable.bookmark2x));
    themes.add(new Theme("brown", Color.BLACK, 0xffece3c7, Color.argb(240, 94, 61, 35),
            Color.argb(255, 255, 255, 255), Color.argb(240, 94, 61, 35), Color.argb(120, 160, 124, 95),
            Color.DKGRAY, 0x22222222, "Phone-Portrait-Brown.png", "Phone-Landscape-Brown.png",
            "Phone-Landscape-Double-Brown.png", R.drawable.bookmark2x));
    themes.add(new Theme("black", Color.LTGRAY, 0xff323230, Color.LTGRAY, Color.LTGRAY, Color.LTGRAY,
            Color.LTGRAY, Color.LTGRAY, 0x77777777, null, null, "Phone-Landscape-Double-Black.png",
            R.drawable.bookmarkgray2x));
    themes.add(new Theme("Leaf", 0xFF1F7F0E, 0xffF8F7EA, 0xFF186D08, Color.LTGRAY, 0xFF186D08, 0xFF186D08,
            Color.DKGRAY, 0x22222222, null, null, null, R.drawable.bookmarkgray2x));
    themes.add(new Theme("", 0xFFA13A0A, 0xFFF6DFD9, 0xFFA13A0A, 0xFFDC4F0E, 0xFFA13A0A, 0xFFA13A0A,
            Color.DKGRAY, 0x22222222, null, null, null, R.drawable.bookmarkgray2x));
    this.setBrightness((float) setting.brightness);
    // create highlights object to contains highlights of this book. 
    highlights = new Highlights();
    Bundle bundle = getIntent().getExtras();
    fileName = bundle.getString("BOOKNAME");
    author = bundle.getString("AUTHOR");
    title = bundle.getString("TITLE");
    bookCode = bundle.getInt("BOOKCODE");
    if (pagePositionInBook == -1)
        pagePositionInBook = bundle.getDouble("POSITION");
    themeIndex = setting.theme;
    this.isGlobalPagination = bundle.getBoolean("GLOBALPAGINATION");
    this.isRTL = bundle.getBoolean("RTL");
    this.isVerticalWriting = bundle.getBoolean("VERTICALWRITING");
    this.isDoublePagedForLandscape = bundle.getBoolean("DOUBLEPAGED");
    //      if (this.isRTL) this.isDoublePagedForLandscape = false; // In RTL mode, SDK does not support double paged. 

    ePubView = new RelativeLayout(this);

    RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,
            RelativeLayout.LayoutParams.FILL_PARENT);
    ePubView.setLayoutParams(rlp);

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); // width,height
    if (this.getOSVersion() >= 11) {
        rv = new ReflowableControl(this); // in case that device supports transparent webkit, the background image under the content can be shown. in some devices, content may be overlapped.
    } else {
        rv = new ReflowableControl(this, getCurrentTheme().backgroundColor); // in case that device can not support transparent webkit, the background color will be set in one color.
    }

    // if false highlight will be drawed on the back of text - this is default. 
    // for the very old devices of which GPU does not support transparent webView background, set the value to true.  
    rv.setDrawingHighlightOnFront(false);

    // set the bookCode to identify the book file. 
    rv.bookCode = this.bookCode;

    // set bitmaps for engine. 
    rv.setPagesStackImage(this.getBitmap("PagesStack.png"));
    rv.setPagesCenterImage(this.getBitmap("PagesCenter.png"));
    // for epub3 which has page-progression-direction="rtl", rv.isRTL() will return true.
    // for old RTL epub which does not have <spine toc="ncx" page-progression-direction="rtl"> in opf file. 
    // you can enforce RTL mode.  

    /*      
          // delay times for proper operations. 
          // !! DO NOT SET these values if there's no issue on your epub reader. !!
          // !! if delayTime is decresed, performance will be increase
          // !! if delayTime is set to too low value, a lot of problem can be occurred. 
          // bringDelayTime(default 500 ms) is for curlView and mainView transition - if the value is too short, blink may happen.
          rv.setBringDelayTime(500);
          // reloadDelayTime(default 100) is used for delay before reload (eg. changeFont, loadChapter or etc) 
          rv.setReloadDelayTime(100);
          // reloadDelayTimeForRotation(default 1000) is used for delay before rotation
          rv.setReloadDelayTimeForRotation(1000);
          // retotaionDelayTime(default 1500) is used for delay after rotation.
          rv.setRotationDelayTime(1500);
          // finalDelayTime(default 500) is used for the delay after loading chapter. 
          rv.setFinalDelayTime(500);
          // rotationFactor affects the delayTime before Rotation. default value 1.0f
          rv.setRotationFactor(1.0f);      
          // If recalcDelayTime is too short, setContentBackground function failed to work properly.  
          rv.setRecalcDelayTime(2500);
    */

    // set the max width or height for background. 
    rv.setMaxSizeForBackground(1024);
    //      rv.setBaseDirectory(SkySetting.getStorageDirectory() + "/books");
    //      rv.setBookName(fileName);
    // set the file path of epub to open
    // Be sure that the file exists before setting.
    rv.setBookPath(SkySetting.getStorageDirectory() + "/books/" + fileName);
    // if true, double pages will be displayed on landscape mode. 
    rv.setDoublePagedForLandscape(this.isDoublePagedForLandscape);
    // set the initial font style for book. 
    rv.setFont(setting.fontName, this.getRealFontSize(setting.fontSize));
    // set the initial line space for book. 
    rv.setLineSpacing(this.getRealLineSpace(setting.lineSpacing)); // the value is supposed to be percent(%).
    // set the horizontal gap(margin) on both left and right side of each page.  
    rv.setHorizontalGapRatio(0.30);
    // set the vertical gap(margin) on both top and bottom side of each page. 
    rv.setVerticalGapRatio(0.22);
    // set the HighlightListener to handle text highlighting. 
    rv.setHighlightListener(new HighlightDelegate());
    // set the PageMovedListener which is called whenever page is moved. 
    rv.setPageMovedListener(new PageMovedDelegate());
    // set the SelectionListener to handle text selection. 
    rv.setSelectionListener(new SelectionDelegate());
    // set the pagingListener which is called when GlobalPagination is true. this enables the calculation for the total number of pages in book, not in chapter.   
    rv.setPagingListener(new PagingDelegate());
    // set the searchListener to search keyword.
    rv.setSearchListener(new SearchDelegate());
    // set the stateListener to monitor the state of sdk engine. 
    rv.setStateListener(new StateDelegate());
    // set the clickListener which is called when user clicks
    rv.setClickListener(new ClickDelegate());
    // set the bookmarkListener to toggle bookmark
    rv.setBookmarkListener(new BookmarkDelegate());
    // set the scriptListener to set custom javascript. 
    rv.setScriptListener(new ScriptDelegate());

    // enable/disable scroll mode
    rv.setScrollMode(false);

    // for some anroid device, when rendering issues are occurred, use "useSoftwareLayer"
    //      rv.useSoftwareLayer();
    // In search keyword, if true, sdk will return search result with the full information such as position, pageIndex. 
    rv.setFullSearch(true);
    // if true, sdk will return raw text for search result, highlight text or body text without character escaping.  
    rv.setRawTextRequired(false);

    // if true, sdk will read the content of book directry from file system, not via Internal server. 
    //      rv.setDirectRead(true);

    // If you want to make your own provider, please look into EpubProvider.java in Advanced demo.
    //      EpubProvider epubProvider = new EpubProvider();
    //      rv.setContentProvider(epubProvider);      

    // SkyProvider is the default ContentProvider which is presented with SDK. 
    // SkyProvider can read the content of epub file without unzipping. 
    // SkyProvider is also fully integrated with SkyDRM solution.  
    SkyProvider skyProvider = new SkyProvider();
    skyProvider.setKeyListener(new KeyDelegate());
    rv.setContentProvider(skyProvider);

    // set the start positon to open the book. 
    rv.setStartPositionInBook(pagePositionInBook);
    // DO NOT USE BELOW, if true , sdk will use DOM to highlight text.  
    //      rv.useDOMForHighlight(false);
    // if true, globalPagination will be activated. 
    // this enables the calculation of page number based on entire book ,not on each chapter.
    // this globalPagination consumes huge computing power. 
    // AVOID GLOBAL PAGINATION FOR LOW SPEC DEVICES.
    rv.setGlobalPagination(this.isGlobalPagination);
    // set the navigation area on both left and right side to go to the previous or next page when the area is clicked. 
    rv.setNavigationAreaWidthRatio(0.1f); // both left and right side.
    // set the device locked to prevent Rotation. 
    rv.setRotationLocked(setting.lockRotation);
    isRotationLocked = setting.lockRotation;
    // set the mediaOverlayListener for MediaOverlay.
    rv.setMediaOverlayListener(new MediaOverlayDelegate());
    // set the audio playing based on Sequence. 
    rv.setSequenceBasedForMediaOverlay(false);

    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    params.width = LayoutParams.MATCH_PARENT;
    params.height = LayoutParams.MATCH_PARENT;

    rv.setLayoutParams(params);
    this.applyThemeToRV(themeIndex);

    if (this.isFullScreenForNexus && SkyUtility.isNexus() && Build.VERSION.SDK_INT >= 19) {
        rv.setImmersiveMode(true);
    }
    // If you want to get the license key for commercial use, please email us (skytree21@gmail.com). 
    // Without the license key, watermark message will be shown in background. 
    rv.setLicenseKey("a99b-3914-a63b-8ecb");

    // set PageTransition Effect 
    int transitionType = bundle.getInt("transitionType");
    if (transitionType == 0) {
        rv.setPageTransition(PageTransition.None);
    } else if (transitionType == 1) {
        rv.setPageTransition(PageTransition.Slide);
    } else if (transitionType == 2) {
        rv.setPageTransition(PageTransition.Curl);
    }

    // setCurlQuality effects the image quality when tuning page in Curl Transition Mode. 
    // If "Out of Memory" occurs in high resolution devices with big screen, 
    // this value should be decreased like 0.25f or below.
    if (this.getMaxSize() > 1280) {
        rv.setCurlQuality(0.5f);
    }

    // set the color of text selector. 
    rv.setSelectorColor(getCurrentTheme().selectorColor);
    // set the color of text selection area. 
    rv.setSelectionColor(getCurrentTheme().selectionColor);

    // setCustomDrawHighlight & setCustomDrawCaret work only if SDK >= 11
    // if true, sdk will ask you how to draw the highlighted text
    rv.setCustomDrawHighlight(true);
    // if true, sdk will require you to draw the custom selector.
    rv.setCustomDrawCaret(true);

    rv.setFontUnit("px");

    rv.setFingerTractionForSlide(true);
    rv.setVideoListener(new VideoDelegate());

    // make engine not to send any event to iframe
    // if iframe clicked, onIFrameClicked will be fired with source of iframe
    // By Using that source of iframe, you can load the content of iframe in your own webView or another browser. 
    rv.setSendingEventsToIFrameEnabled(false);

    // make engine send any event to video(tag) or not
    // if video tag is clicked, onVideoClicked will be fired with source of iframe
    // By Using that source of video, you can load the content of video in your own media controller or another browser. 
    rv.setSendingEventsToVideoEnabled(true);

    // make engine send any event to video(tag) or not
    // if video tag is clicked, onVideoClicked will be fired with source of iframe
    // By Using that source of video, you can load the content of video in your own media controller or another browser.
    rv.setSendingEventsToAudioEnabled(true);

    // if true, sdk will return the character offset from the chapter beginning , not from element index.
    // then startIndex, endIndex of highlight will be 0 (zero) 
    rv.setGlobalOffset(true);
    // if true, sdk will return the text of each page in the PageInformation object which is passed in onPageMoved event. 
    rv.setExtractText(true);

    ePubView.addView(rv);

    this.makeControls();
    this.makeBoxes();
    this.makeIndicator();
    this.recalcFrames();
    if (this.isRTL) {
        this.seekBar.setReversed(true);
    }
    setContentView(ePubView);
    this.isInitialized = true;
}

From source file:com.rsltc.profiledata.main.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button loginButton = (Button) findViewById(R.id.button);
    loginButton.setOnClickListener(new View.OnClickListener() {
        @Override//w w w. j av  a  2 s. co  m
        public void onClick(View v) {
            try {
                AlertDialog.Builder alert = new AlertDialog.Builder(thisActivity);
                alert.setTitle("Title here");

                StringBuilder query = new StringBuilder();

                query.append("redirect_uri=" + URLEncoder.encode(redirectUri, "utf-8"));
                query.append("&client_id=" + URLEncoder.encode(clientId, "utf-8"));
                query.append("&scope=" + URLEncoder.encode(scopes, "utf-8"));

                query.append("&response_type=code");
                URI uri = new URI("https://login.live.com/oauth20_authorize.srf?" + query.toString());

                URL url = uri.toURL();

                final WebView wv = new WebView(thisActivity);

                WebSettings webSettings = wv.getSettings();
                webSettings.setJavaScriptEnabled(true);
                wv.loadUrl(url.toString());
                wv.setWebViewClient(new WebViewClient() {
                    @Override
                    public boolean shouldOverrideUrlLoading(WebView view, String location) {
                        Log.e(TAG, location);
                        // TODO: extract to method
                        try {
                            URL url = new URL(location);

                            if (url.getPath().equalsIgnoreCase("/oauth20_desktop.srf")) {
                                System.out.println("Dit werkt al!");
                                System.out.println(url.getQuery());
                                Map<String, List<String>> result = splitQuery(url);
                                if (result.containsKey("code")) {
                                    System.out.println("bevat code");
                                    if (result.containsKey("error")) {
                                        System.out.println(String.format("{0}\r\n{1}", result.get("error"),
                                                result.get("errorDesc")));
                                    }
                                    System.out.println(result.get("code").get(0));
                                    String tokenError = GetToken(result.get("code").get(0), false);
                                    if (tokenError == null || "".equals(tokenError)) {
                                        System.out.println("Successful sign-in!");
                                        Log.e(TAG, "Successful sign-in!");
                                    } else {
                                        Log.e(TAG, "tokenError: " + tokenError);
                                    }
                                } else {
                                    System.out.println("Successful sign-out!");
                                }
                            }
                        } catch (IOException | URISyntaxException e) {
                            e.printStackTrace();
                        }

                        view.loadUrl(location);

                        return true;
                    }
                });
                LinearLayout linearLayout = new LinearLayout(thisActivity);
                linearLayout.setMinimumHeight(500);
                ArrayList<View> views = new ArrayList<View>();
                views.add(wv);
                linearLayout.addView(wv);
                EditText text = new EditText(thisActivity);
                text.setVisibility(View.GONE);
                linearLayout.addView(text);
                alert.setView(linearLayout);
                alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();
                    }
                });
                alert.show();
            } catch (Exception e) {
                Log.e(TAG, "dd");
            }
        }
    });
    Button showProfile = (Button) findViewById(R.id.button2);
    showProfile.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showProfile();
        }
    });
    Button showSummmary = (Button) findViewById(R.id.button3);
    showSummmary.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showSummaries();
        }
    });

    if (savedInstanceState != null)

    {
        authInProgress = savedInstanceState.getBoolean(AUTH_PENDING);
    }

    buildFitnessClient();
}

From source file:com.ibuildapp.romanblack.MultiContactsPlugin.ContactDetailsActivity.java

@Override
public void create() {
    try {//from   w w w.ja  va2 s  .co  m
        setContentView(R.layout.grouped_contacts_details);

        Intent currentIntent = getIntent();
        Bundle store = currentIntent.getExtras();
        widget = (Widget) store.getSerializable("Widget");
        if (widget == null) {
            handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
            return;
        }

        person = (Person) store.getSerializable("person");
        if (person == null) {
            handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
            return;
        }
        setTopBarTitle(widget.getTitle());

        Boolean single = currentIntent.getBooleanExtra("single", true);

        setTopBarLeftButtonTextAndColor(
                single ? getResources().getString(R.string.common_home_upper)
                        : getResources().getString(R.string.common_back_upper),
                getResources().getColor(android.R.color.black), true, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        finish();
                    }
                });
        setTopBarTitleColor(getResources().getColor(android.R.color.black));
        setTopBarBackgroundColor(Statics.color1);

        if ((Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL)))
                || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))
                || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))) {

            ImageView shareButton = (ImageView) getLayoutInflater()
                    .inflate(R.layout.grouped_contacts_share_button, null);
            shareButton.setLayoutParams(
                    new LinearLayout.LayoutParams((int) (29 * getResources().getDisplayMetrics().density),
                            (int) (39 * getResources().getDisplayMetrics().density)));
            shareButton.setColorFilter(Color.BLACK);
            setTopBarRightButton(shareButton, getString(R.string.multicontacts_list_share),
                    new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            DialogSharing.Configuration.Builder sharingDialogBuilder = new DialogSharing.Configuration.Builder();

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL)))
                                sharingDialogBuilder
                                        .setEmailSharingClickListener(new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                String message = getContactInfo();
                                                Intent email = new Intent(Intent.ACTION_SEND);
                                                email.putExtra(Intent.EXTRA_TEXT, message);
                                                email.setType("message/rfc822");
                                                startActivity(Intent.createChooser(email,
                                                        getString(R.string.choose_email_client)));
                                            }
                                        });

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))
                                sharingDialogBuilder
                                        .setSmsSharingClickListener(new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                String message = getContactInfo();

                                                try {
                                                    Utils.sendSms(ContactDetailsActivity.this, message);
                                                } catch (ActivityNotFoundException e) {
                                                    e.printStackTrace();
                                                }
                                            }
                                        });

                            if (Boolean.TRUE.equals(widget.getParameter(PARAM_ADD_CONTACT)))
                                sharingDialogBuilder.addCustomListener(R.string.multicontacts_add_to_phonebook,
                                        R.drawable.gc_add_to_contacts, true,
                                        new DialogSharing.Item.OnClickListener() {
                                            @Override
                                            public void onClick() {
                                                createNewContact(person.getName(), person.getPhone(),
                                                        person.getEmail());
                                            }
                                        });

                            showDialogSharing(sharingDialogBuilder.build());
                        }
                    });

        }

        boolean hasSchema = store.getBoolean("hasschema");
        cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder();

        contacts = person.getContacts();

        if (widget.getTitle().length() > 0) {
            setTitle(widget.getTitle());
        }

        root = (LinearLayout) findViewById(R.id.grouped_contacts_details_root);

        if (hasSchema) {
            root.setBackgroundColor(Statics.color1);
        } else if (widget.isBackgroundURL()) {
            cacheBackgroundFile = cachePath + "/" + Utils.md5(widget.getBackgroundURL());
            File backgroundFile = new File(cacheBackgroundFile);
            if (backgroundFile.exists()) {
                root.setBackgroundDrawable(
                        new BitmapDrawable(BitmapFactory.decodeStream(new FileInputStream(backgroundFile))));
            } else {
                BackgroundDownloadTask dt = new BackgroundDownloadTask();
                dt.execute(widget.getBackgroundURL());
            }
        } else if (widget.isBackgroundInAssets()) {
            AssetManager am = this.getAssets();
            root.setBackgroundDrawable(new BitmapDrawable(am.open(widget.getBackgroundURL())));
        }

        if (contacts != null) {
            ImageView avatarImage = (ImageView) findViewById(R.id.grouped_contacts_details_avatar);

            avatarImage.setImageResource(R.drawable.gc_profile_avatar);
            if (person.hasAvatar() && NetworkUtils.isOnline(this)) {
                avatarImage.setVisibility(View.VISIBLE);
                Glide.with(this).load(person.getAvatarUrl()).placeholder(R.drawable.gc_profile_avatar)
                        .dontAnimate().into(avatarImage);
            } else {
                avatarImage.setVisibility(View.VISIBLE);
                avatarImage.setImageResource(R.drawable.gc_profile_avatar);
            }

            String name = "";
            neededContacts = new ArrayList<>();
            for (Contact con : contacts) {
                if ((con.getType() == 5) || (con.getDescription().length() == 0)) {
                } else {
                    if (con.getType() == 0) {
                        name = con.getDescription();
                    } else
                        neededContacts.add(con);
                }
            }

            if (neededContacts.isEmpty()) {
                handler.sendEmptyMessage(THERE_IS_NO_CONTACT_DATA);
                return;
            }

            headSeparator = findViewById(R.id.gc_head_separator);
            bottomSeparator = findViewById(R.id.gc_bottom_separator);
            imageBottom = findViewById(R.id.gc_image_bottom_layout);
            personName = (TextView) findViewById(R.id.gc_details_description);

            if ("".equals(name))
                personName.setVisibility(View.GONE);
            else {
                personName.setVisibility(View.VISIBLE);
                personName.setText(name);
                personName.setTextColor(Statics.color3);
            }
            if (Statics.isLight) {
                headSeparator.setBackgroundColor(Color.parseColor("#4d000000"));
                bottomSeparator.setBackgroundColor(Color.parseColor("#4d000000"));
            } else {
                headSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF"));
                bottomSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF"));
            }

            ViewUtils.setBackgroundLikeHeader(imageBottom, Statics.color1);

            ListView list = (ListView) findViewById(R.id.grouped_contacts_details_list_view);
            list.setDivider(null);

            ContactDetailsAdapter adapter = new ContactDetailsAdapter(ContactDetailsActivity.this,
                    R.layout.grouped_contacts_details_item, neededContacts, isChemeDark(Statics.color1));
            list.setAdapter(adapter);
            list.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
                    listViewItemClick(position);
                }
            });
        }

        if (widget.hasParameter("add_contact")) {
            HashMap<String, String> hm = new HashMap<>();
            for (int i = 0; i < contacts.size(); i++) {
                switch (contacts.get(i).getType()) {
                case 0: {
                    hm.put("contactName", contacts.get(i).getDescription());
                }
                    break;
                case 1: {
                    hm.put("contactNumber", contacts.get(i).getDescription());
                }
                    break;
                case 2: {
                    hm.put("contactEmail", contacts.get(i).getDescription());
                }
                    break;
                case 3: {
                    hm.put("contactSite", contacts.get(i).getDescription());
                }
                    break;
                }
            }
            addNativeFeature(NATIVE_FEATURES.ADD_CONTACT, null, hm);
        }
        if (widget.hasParameter("send_sms")) {
            HashMap<String, String> hm = new HashMap<>();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < contacts.size(); i++) {
                sb.append(contacts.get(i).getDescription());
                if (i < contacts.size() - 1) {
                    sb.append(", ");
                }
            }
            hm.put("text", sb.toString());
            addNativeFeature(NATIVE_FEATURES.SMS, null, hm);
        }
        if (widget.hasParameter("send_mail")) {
            HashMap<String, CharSequence> hm = new HashMap<>();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < contacts.size(); i++) {
                switch (contacts.get(i).getType()) {
                case 0: {
                    sb.append("Name: ");
                }
                    break;
                case 1: {
                    sb.append("Phone: ");
                }
                    break;
                case 2: {
                    sb.append("Email: ");
                }
                    break;
                case 3: {
                    sb.append("Site: ");
                }
                    break;
                case 4: {
                    sb.append("Address: ");
                }
                    break;
                }
                sb.append(contacts.get(i).getDescription());
                sb.append("<br/>");
            }

            if (widget.isHaveAdvertisement()) {
                sb.append("<br>\n (sent from <a href=\"http://ibuildapp.com\">iBuildApp</a>)");
            }

            hm.put("text", sb.toString());
            hm.put("subject", "Contacts");
            addNativeFeature(NATIVE_FEATURES.EMAIL, null, hm);
        }

    } catch (Exception e) {
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
    }
}

From source file:com.owncloud.android.authentication.AuthenticatorActivity.java

/**
 * {@inheritDoc}//from w  w w  . j a v a  2 s  .  co m
 * 
 * IMPORTANT ENTRY POINT 1: activity is shown to the user
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.account_setup);
    mAuthMessage = (TextView) findViewById(R.id.auth_message);
    mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput);
    mHostUrlInput.setText(getString(R.string.server_url)); // valid although
                                                           // R.string.server_url
                                                           // is an empty
                                                           // string
    mUsernameInput = (EditText) findViewById(R.id.account_username);
    mPasswordInput = (EditText) findViewById(R.id.account_password);
    mPasswordInput2 = (EditText) findViewById(R.id.account_password2);
    mOAuthAuthEndpointText = (TextView) findViewById(R.id.oAuthEntryPoint_1);
    mOAuthTokenEndpointText = (TextView) findViewById(R.id.oAuthEntryPoint_2);
    mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check);
    mOkButton = findViewById(R.id.buttonOK);
    mAuthStatusLayout = (TextView) findViewById(R.id.auth_status_text);

    // / set Host Url Input Enabled
    mHostUrlInputEnabled = getResources().getBoolean(R.bool.show_server_url_input);
    locationSpinner = (Spinner) findViewById(R.id.spinner1);

    // / complete label for 'register account' button
    Button b = (Button) findViewById(R.id.account_register);
    if (b != null) {
        b.setText(String.format(getString(R.string.auth_register), getString(R.string.app_name)));
    }

    // / initialization
    mAccountMgr = AccountManager.get(this);
    mNewCapturedUriFromOAuth2Redirection = null;
    mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE);
    mAccount = null;
    mHostBaseUrl = "";
    location = " ";//locationSpinner.getSelectedItem();
    locationSpinner.setOnItemSelectedListener(this);
    boolean refreshButtonEnabled = false;

    // URL input configuration applied
    if (!mHostUrlInputEnabled) {
        findViewById(R.id.hostUrlFrame).setVisibility(View.GONE);
        mRefreshButton = findViewById(R.id.centeredRefreshButton);

    } else {
        mRefreshButton = findViewById(R.id.embeddedRefreshButton);
    }

    if (savedInstanceState == null) {
        mResumed = false;
        // / connection state and info
        mAuthMessageVisibility = View.GONE;
        mServerStatusText = mServerStatusIcon = 0;
        mServerIsValid = false;
        mServerIsChecked = false;
        mIsSslConn = false;
        mAuthStatusText = mAuthStatusIcon = 0;

        // / retrieve extras from intent
        mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);

        if (mAccount != null) {
            String ocVersion = mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION);
            Log.d("!!!!!!!!!!!!!!!!!!!!!!!!! ", mAccount.name);
            if (ocVersion != null) {
                mDiscoveredVersion = new OwnCloudVersion(ocVersion);
            }
            mHostBaseUrl = normalizeUrl(
                    mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL));
            mHostUrlInput.setText(mHostBaseUrl);

            String userName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@'));
            Log.d("!!!!!!!!!!!!!!!!!!!!!!!!!4234 ", userName);
            mUsernameInput.setText(userName);
        }
        initAuthorizationMethod(); // checks intent and setup.xml to
                                   // determine mCurrentAuthorizationMethod
        mJustCreated = true;

        if (mAction == ACTION_UPDATE_TOKEN || !mHostUrlInputEnabled) {
            checkOcServer();
        }

    } else {
        mResumed = true;
        // / connection state and info
        mAuthMessageVisibility = savedInstanceState.getInt(KEY_AUTH_MESSAGE_VISIBILITY);
        mAuthMessageText = savedInstanceState.getString(KEY_AUTH_MESSAGE_TEXT);
        mServerIsValid = savedInstanceState.getBoolean(KEY_SERVER_VALID);
        mServerIsChecked = savedInstanceState.getBoolean(KEY_SERVER_CHECKED);
        mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT);
        mServerStatusIcon = savedInstanceState.getInt(KEY_SERVER_STATUS_ICON);
        mIsSslConn = savedInstanceState.getBoolean(KEY_IS_SSL_CONN);
        mAuthStatusText = savedInstanceState.getInt(KEY_AUTH_STATUS_TEXT);
        mAuthStatusIcon = savedInstanceState.getInt(KEY_AUTH_STATUS_ICON);
        if (savedInstanceState.getBoolean(KEY_PASSWORD_VISIBLE, false)) {
            showPassword();
        }

        // / server data
        String ocVersion = savedInstanceState.getString(KEY_OC_VERSION);
        if (ocVersion != null) {
            mDiscoveredVersion = new OwnCloudVersion(ocVersion);
        }
        mHostBaseUrl = savedInstanceState.getString(KEY_HOST_URL_TEXT);

        // account data, if updating
        mAccount = savedInstanceState.getParcelable(KEY_ACCOUNT);
        // Log.d("////////////////// ",mAccount.name);
        mAuthTokenType = savedInstanceState.getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE);
        if (mAuthTokenType == null) {
            mAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_PASSWORD;

        }

        // check if server check was interrupted by a configuration change
        if (savedInstanceState.getBoolean(KEY_SERVER_CHECK_IN_PROGRESS, false)) {
            checkOcServer();
        }

        // refresh button enabled
        refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED);

    }

    if (mAuthMessageVisibility == View.VISIBLE) {
        showAuthMessage(mAuthMessageText);
    } else {
        hideAuthMessage();
    }
    adaptViewAccordingToAuthenticationMethod();
    showServerStatus();
    showAuthStatus();

    if (mAction == ACTION_UPDATE_TOKEN) {
        // / lock things that should not change
        mHostUrlInput.setEnabled(false);
        mHostUrlInput.setFocusable(false);
        mUsernameInput.setEnabled(false);
        mUsernameInput.setFocusable(false);
        mOAuth2Check.setVisibility(View.GONE);
    }

    // if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled)
    // showRefreshButton();
    if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled)
        showRefreshButton();
    mOkButton.setEnabled(mServerIsValid); // state not automatically
                                          // recovered in configuration
                                          // changes

    if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType)
            || !AUTH_OPTIONAL.equals(getString(R.string.auth_method_oauth2))) {
        mOAuth2Check.setVisibility(View.GONE);
    }

    mPasswordInput.setText(""); // clean password to avoid social hacking
                                // (disadvantage: password in removed if the
                                // device is turned aside)

    // / bind view elements to listeners and other friends
    mHostUrlInput.setOnFocusChangeListener(this);
    mHostUrlInput.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    mHostUrlInput.setOnEditorActionListener(this);
    mHostUrlInput.addTextChangedListener(new TextWatcher() {

        @Override
        public void afterTextChanged(Editable s) {
            if (!mHostBaseUrl.equals(normalizeUrl(mHostUrlInput.getText().toString()))) {
                mOkButton.setEnabled(false);
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (!mResumed) {
                mAuthStatusIcon = 0;
                mAuthStatusText = 0;
                showAuthStatus();
            }
            mResumed = false;
        }
    });

    mPasswordInput.setOnFocusChangeListener(this);
    mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE);
    mPasswordInput.setOnEditorActionListener(this);
    mPasswordInput.setOnTouchListener(new RightDrawableOnTouchListener() {
        @Override
        public boolean onDrawableTouch(final MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                AuthenticatorActivity.this.onViewPasswordClick();
            }
            return true;
        }
    });

    findViewById(R.id.scroll).setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType)
                        && mHostUrlInput.hasFocus()) {
                    checkOcServer();
                }
            }
            return false;
        }
    });
}

From source file:com.android.dialer.DialtactsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.e(TAG, " --- onCreate(Bundle savedInstanceState) ---  start ");
    Trace.beginSection(TAG + " onCreate");
    View retView = null;//w  w w  . ja va2 s .  co  m
    super.onCreateView(inflater, container, savedInstanceState);

    //??
    iControlDeleteBtn = (IControlDeleteBtn) getActivity();

    //mFirstLaunch = true;

    final Resources resources = getResources();
    int temp = resources.getDimensionPixelSize(R.dimen.floating_action_button_width);
    //?actionbar
    mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large);

    Trace.beginSection(TAG + " setContentView");
    //setContentView(R.layout.dialtacts_activity);
    retView = inflater.inflate(R.layout.dialtacts_activity, container, false);
    Trace.endSection();

    Trace.beginSection(TAG + " setup Views");
    final ActionBar actionBar = getActivity().getActionBar();
    //actionbar?
    //actionBar.setCustomView(R.layout.dialtacts_actionbar);
    //actionBar.setDisplayShowCustomEnabled(true);
    TextView actionbarNameTxt = (TextView) actionBar.getCustomView().findViewById(R.id.actionbar_name);
    actionbarNameTxt.setOnClickListener(this);
    ImageView actionbarMenu = (ImageView) actionBar.getCustomView().findViewById(R.id.actionbar_menu);
    actionbarMenu.setOnClickListener(this);
    TextView editerToCalldetail = (TextView) actionBar.getCustomView()
            .findViewById(R.id.actionbar_call_dialtacts_action_editer);
    editerToCalldetail.setOnClickListener(this);
    TextView cancelTxt = (TextView) actionBar.getCustomView()
            .findViewById(R.id.actionbar_call_dialtacts_action_cancel);
    cancelTxt.setOnClickListener(this);
    actionbarNameTxt.setText(getString(R.string.all_calls));
    mSearchView = (EditText) actionBar.getCustomView().findViewById(R.id.edittext);
    mSearchView.setVisibility(View.GONE);
    mDialtactsActionBarController = new DialtactsActionBarController(actionbarMenu, editerToCalldetail,
            cancelTxt, actionbarNameTxt, this);
    //        actionBar.setBackgroundDrawable(null);

    SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView()
            .findViewById(R.id.search_view_container);
    //        searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener);

    //        mActionBarController = new DialtactsActionBarController(this, searchEditTextLayout);

    //        mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view);
    mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
    //        mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button);
    //        mSearchView.setOnClickListener(mSearchViewOnClickListener);
    //        searchEditTextLayout.findViewById(R.id.search_box_start_search)
    //                .setOnClickListener(mSearchViewOnClickListener);
    //        searchEditTextLayout.setOnClickListener(mSearchViewOnClickListener);
    //        searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() {
    //            @Override
    //            public void onBackButtonClicked() {
    //                onBackPressed();
    //            }
    //
    //            @Override
    //            public void onSearchViewClicked() {
    //                // Hide FAB, as the keyboard is shown.
    ////                mFloatingActionButtonController.scaleOut();
    //            }
    //        });
    mIsLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

    //        ImageButton optionsMenuButton =
    //                (ImageButton) searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button);
    //        optionsMenuButton.setOnClickListener(this);
    //        mOverflowMenu = buildOptionsMenu(searchEditTextLayout);
    //        optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener());

    // Add the favorites fragment but only if savedInstanceState is null. Otherwise the
    // fragment manager is responsible for recreating it.
    //???
    if (savedInstanceState == null) {
        getChildFragmentManager().beginTransaction()
                .add(R.id.dialtacts_container, new DialpadFragment(getActivity()), TAG_DIALPAD_FRAGMENT)
                //                   .add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT)
                .commit();
    } else {
        mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
        mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI);
        mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI);
        mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
        mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN);
        //            mActionBarController.restoreInstanceState(savedInstanceState);
    }

    final boolean isLayoutRtl = DialerUtils.isRtl();
    //??????
    if (mIsLandscape) {
        //??
        mSlideIn = AnimationUtils.loadAnimation(getActivity(),
                isLayoutRtl ? R.anim.dialpad_slide_in_left : R.anim.dialpad_slide_in_right);
        mSlideOut = AnimationUtils.loadAnimation(getActivity(),
                isLayoutRtl ? R.anim.dialpad_slide_out_left : R.anim.dialpad_slide_out_right);
    } else {
        mSlideIn = AnimationUtils.loadAnimation(getActivity(), R.anim.dialpad_slide_in_bottom);
        mSlideOut = AnimationUtils.loadAnimation(getActivity(), R.anim.dialpad_slide_out_bottom);
    }

    //        mSlideIn.setInterpolator(AnimUtils.EASE_IN);
    mSlideOut.setInterpolator(AnimUtils.EASE_OUT);

    mSlideIn.setAnimationListener(mSlideInListener);
    mSlideOut.setAnimationListener(mSlideOutListener);

    Trace.endSection();

    Trace.beginSection(TAG + " initialize smart dialing");
    mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(getActivity());
    SmartDialPrefix.initializeNanpSettings(getActivity());
    Trace.endSection();
    Trace.endSection();
    initFlushHandler();

    Log.e(TAG, " onCreate()  dialerFragment  " + mIsDialpadShown);
    return retView;
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

public void onCreate(Bundle savedInstanceState) {
    ctx = this.getApplicationContext();

    super.onCreate(savedInstanceState);

    //restore saved instances if necessary
    if (savedInstanceState != null) {
        Toast.makeText(HomeScreen.this, savedInstanceState.getString("message"), Toast.LENGTH_LONG).show();

        GTConstants.darfileName = savedInstanceState.getString("darfileName");
        GTConstants.tarfileName = savedInstanceState.getString("tarfileName");
        GTConstants.trpfilename = savedInstanceState.getString("trpfilename");
        GTConstants.srpfileName = savedInstanceState.getString("srpfileName");
        Utility.setcurrentState(savedInstanceState.getString("currentState"));
        Utility.setsessionStart(savedInstanceState.getString("getsessionStart"));
        selectedCode = savedInstanceState.getString("selectedCode");
        lunchTime = savedInstanceState.getString("lunchTime");
        breakTime = savedInstanceState.getString("breakTime");
        signaturefileName = savedInstanceState.getString("signaturefileName");
        GTConstants.tourName = savedInstanceState.getString("tourName");
        tourTime = savedInstanceState.getString("tourTime");
        tourEnd = savedInstanceState.getLong("tourEnd");
        lunchoutLocation = savedInstanceState.getInt("lunchoutLocation");
        breakoutLocation = savedInstanceState.getInt("breakoutLocation");
        touritemNumber = savedInstanceState.getInt("touritemNumber");
        chekUpdate = savedInstanceState.getBoolean("chekUpdate");
        GTConstants.sendData = savedInstanceState.getBoolean("send_data");
        GTConstants.isTour = savedInstanceState.getBoolean("isTour");
        GTConstants.isGeoFence = savedInstanceState.getBoolean("isGeoFence");
    } else {//from ww w. j  a  va2s  .c  o m
        //set the current state
        Utility.setcurrentState(GTConstants.offShift);

        //set the default startup code to start shift
        selectedCode = "start_shift";
    }

    /*
    //Determine screen size
     if ((getResources().getConfiguration().screenLayout &      Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {     
         Toast.makeText(this, "Large screen",Toast.LENGTH_LONG).show();
     }
     else if ((getResources().getConfiguration().screenLayout &      Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {     
         Toast.makeText(this, "Normal sized screen" , Toast.LENGTH_LONG).show();
     } 
     else if ((getResources().getConfiguration().screenLayout &      Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {     
         Toast.makeText(this, "Small sized screen" , Toast.LENGTH_LONG).show();
     }
     else {
         Toast.makeText(this, "Screen size is neither large, normal or small" , Toast.LENGTH_LONG).show();
     }
             
      //initialize receiver to monitor for screen on / off
    /*
      IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
      filter.addAction(Intent.ACTION_SCREEN_OFF);
      BroadcastReceiver mReceiver = new ScreenReceiver();
      registerReceiver(mReceiver, filter);
      */

    setContentView(R.layout.homescreen);

    //Create object to call the Database class
    myDatabase = new GuardTraxDB(this);
    preferenceDB = new PreferenceDB(this);
    ftpdatabase = new ftpDataBase(this);
    gtDB = new GTParams(this);
    aDB = new accountsDB(this);
    trafficDB = new trafficDataBase(this);
    tourDB = new tourDataBase(this);

    //check for updates
    if (chekUpdate) {
        //reset the preference value
        chekUpdate = false;

        //check for application updates
        checkUpdate();
    }

    //initialize the message timer
    //initializeOnModeTimerEvent();

    //get the version number and set it in constants
    String version_num = "";

    PackageManager manager = this.getPackageManager();
    try {
        PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
        version_num = info.versionName.toString();

    } catch (NameNotFoundException e) {
        version_num = "0.00.00";
    }
    GTConstants.version = version_num;

    //final TextView version = (TextView) findViewById(R.id.textVersion);
    //version.setText(version_num);

    //set up the animation
    animation.setDuration(500); // duration - half a second
    animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
    animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely
    animation.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in

    buttonClick.setDuration(50); // duration - half a second
    buttonClick.setInterpolator(new LinearInterpolator()); // do not alter animation rate
    buttonClick.setRepeatCount(1); // Repeat animation once
    buttonClick.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in

    textWarning = (TextView) findViewById(R.id.txtWarning);
    textWarning.setWidth(500);
    textWarning.setGravity(Gravity.CENTER);

    //allow the text to be clicked if necessary 
    textWarning.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (GTConstants.isTour && GTConstants.tourName.length() > 1)
                displaytourInfo();
        }
    });

    //goto scan page button
    btn_scan_screen = (Button) findViewById(R.id.btn_goto_scan);

    btn_scan_screen.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            btn_scan_screen.startAnimation(buttonClick);

            //Utility.showScan(HomeScreen.this);
            scan_click(false);
        }
    });

    //goto report page button
    btn_report_screen = (Button) findViewById(R.id.btn_goto_report);
    btn_report_screen.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            btn_report_screen.startAnimation(buttonClick);

            report_click();
        }
    });

    //goto dial page button
    btn_dial_screen = (Button) findViewById(R.id.btn_goto_dial);
    btn_dial_screen.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            btn_dial_screen.startAnimation(buttonClick);

            dial_click();
        }
    });

    //microphone button
    btn_mic = (Button) findViewById(R.id.btn_mic);
    btn_mic.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            btn_mic.startAnimation(buttonClick);

            voice_click();
        }

    });

    //camera button
    btn_camera = (Button) findViewById(R.id.btn_camera);
    btn_camera.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            btn_camera.startAnimation(buttonClick);

            camera_click();
        }
    });

    //video button
    btn_video = (Button) findViewById(R.id.btn_video);
    btn_video.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            btn_video.startAnimation(buttonClick);

            video_click();
        }

    });

    // Register a callback to be invoked when this view is clicked. If this view is not clickable, it becomes clickable.
    btn_send = (Button) findViewById(R.id.btn_Send);
    btn_send.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            //prevent multiple fast clicking
            if (SystemClock.elapsedRealtime() - mLastClickTime < 2000)
                return;

            mLastClickTime = SystemClock.elapsedRealtime();

            incidentcodeSent = true;

            btn_send.startAnimation(buttonClick);

            //if start shift has not been sent then the device is in do not send data mode.  Warn the user 
            if (Utility.getcurrentState().equals(GTConstants.offShift) && !selectedCode.equals("start_shift")) {
                show_alert_title = "Error";
                show_alert_message = "You must start your shift!";
                showAlert(show_alert_title, show_alert_message, true);

                //set spinner back to start shift
                spinner.setSelection(0);
            } else {
                if (Utility.deviceRegistered()) {
                    show_alert_title = "Success";
                    show_alert_message = "Action success";
                } else {
                    show_alert_title = "Warning";
                    show_alert_message = "You are NOT registered!";

                    showAlert(show_alert_title, show_alert_message, true);
                }

                if (selectedCode.equals("start_shift")) {
                    //if shift already started
                    if (Utility.getcurrentState().equals(GTConstants.onShift)) {
                        show_alert_title = "Warning";
                        show_alert_message = "You must end shift!";

                        showAlert(show_alert_title, show_alert_message, true);

                        //set spinner back to all clear
                        spinner.setSelection(2);
                    } else {
                        ToastMessage.displayToastFromResource(HomeScreen.this, 5, Gravity.CENTER,
                                (ViewGroup) findViewById(R.id.toast_layout_root));

                        pdialog = ProgressDialog.show(HomeScreen.this, "Please wait", "Starting shift ...",
                                true);

                        //set the current state
                        Utility.setcurrentState(GTConstants.onShift);
                        setuserBanner();

                        //wait for start shift actions to complete (or timeout occurs) before dismissing wait dialog
                        new CountDownTimer(5000, 1000) {
                            @Override
                            public void onTick(long millisUntilFinished) {
                                if (start_shift_wait)
                                    pdialog.dismiss();
                            }

                            @Override
                            public void onFinish() {
                                if (!(pdialog == null))
                                    pdialog.dismiss();
                            }
                        }.start();

                        //create dar file
                        try {
                            //create the dar file name
                            GTConstants.darfileName = GTConstants.LICENSE_ID.substring(7) + "_"
                                    + Utility.getUTCDate() + "_" + Utility.getUTCTime() + ".dar";

                            //write the version to the dar file
                            Utility.write_to_file(HomeScreen.this,
                                    GTConstants.dardestinationFolder + GTConstants.darfileName,
                                    "Version;" + GTConstants.version + "\r\n", false);

                            //write the start shift event to the dar file
                            Utility.write_to_file(HomeScreen.this,
                                    GTConstants.dardestinationFolder + GTConstants.darfileName,
                                    "Start shift;" + GTConstants.currentBatteryPercent + ";"
                                            + Utility.getLocalTime() + ";" + Utility.getLocalDate() + "\r\n",
                                    true);

                            //create the tar file name if module installed
                            if (GTConstants.isTimeandAttendance) {
                                GTConstants.tarfileName = GTConstants.LICENSE_ID.substring(7) + "_"
                                        + Utility.getUTCDate() + "_" + Utility.getUTCTime() + ".tar";

                                //write the start shift event to the tar file
                                Utility.write_to_file(HomeScreen.this,
                                        GTConstants.dardestinationFolder + GTConstants.tarfileName,
                                        "Name;" + GTConstants.report_name + "\r\n" + "Start shift;"
                                                + Utility.getLocalTime() + ";" + Utility.getLocalDate()
                                                + "\r\n",
                                        false);
                            }

                        } catch (Exception e) {
                            Toast.makeText(HomeScreen.this, "error = " + e, Toast.LENGTH_LONG).show();
                        }

                        GTConstants.sendData = true;

                        //if not time and attendance then send start shift event now, otherwise wait till after location scan
                        send_event("11");

                        //set the session start time
                        SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yy HH:mm:ss");
                        Utility.setsessionStart(sdf.format(new Date()));

                        //reset the server connection flag
                        Utility.resetisConnecting();

                        //start the GPS location service
                        MainService.openLocationListener();

                        //set spinner back to all clear
                        spinner.setSelection(2);

                        setwarningText("");

                        if (GTConstants.isTimeandAttendance) {
                            show_taa_scan(true, false);
                        }
                    }

                } else if (selectedCode.equals("end_shift")) {
                    if (!Utility.getcurrentState().equals(GTConstants.onShift)
                            && GTConstants.isTimeandAttendance) {
                        show_alert_title = "Error";
                        show_alert_message = "You must end your Lunch / Break!";
                        showAlert(show_alert_title, show_alert_message, true);

                        //set spinner back to start shift
                        spinner.setSelection(2);
                    } else {
                        btn_send.setEnabled(false);
                        if (GTConstants.isTimeandAttendance) {
                            show_taa_scan(false, true);
                        } else
                            endshiftCode();
                    }
                } else {
                    if (Utility.isselectionValid(HomeScreen.this, selectedCode)) {
                        //if time and attendance then write to file
                        if (selectedCode.equalsIgnoreCase(GTConstants.lunchin)
                                || selectedCode.equalsIgnoreCase(GTConstants.lunchout)
                                || selectedCode.equalsIgnoreCase(GTConstants.startbreak)
                                || selectedCode.equalsIgnoreCase(GTConstants.endbreak)) {
                            if (GTConstants.isTimeandAttendance)
                                Utility.write_to_file(HomeScreen.this,
                                        GTConstants.dardestinationFolder + GTConstants.tarfileName,
                                        spinner.getSelectedItem().toString() + ";" + Utility.getLocalTime()
                                                + ";" + Utility.getLocalDate() + "\r\n",
                                        true);

                            if (selectedCode.equalsIgnoreCase(GTConstants.lunchin)) {
                                Utility.setcurrentState(GTConstants.onLunch);
                                Utility.setlunchStart(true);
                                setuserBanner();
                            }

                            if (selectedCode.equalsIgnoreCase(GTConstants.startbreak)) {
                                Utility.setcurrentState(GTConstants.onBreak);
                                Utility.setbreakStart(true);
                                setuserBanner();
                            }

                            if (selectedCode.equalsIgnoreCase(GTConstants.lunchout)) {
                                Utility.setcurrentState(GTConstants.onShift);
                                lunchTime = Utility.gettimeDiff(Utility.getlunchStart(),
                                        Utility.getLocalDateTime());
                                setuserBanner();
                            }

                            if (selectedCode.equalsIgnoreCase(GTConstants.endbreak)) {
                                Utility.setcurrentState(GTConstants.onShift);
                                breakTime = Utility.gettimeDiff(Utility.getbreakStart(),
                                        Utility.getLocalDateTime());
                                setuserBanner();
                            }
                        }

                        ToastMessage.displayToastFromResource(HomeScreen.this, 5, Gravity.CENTER,
                                (ViewGroup) findViewById(R.id.toast_layout_root));

                        //save the event description as may be needed for incident report
                        incidentDescription = spinner.getSelectedItem().toString();

                        //write to dar
                        Utility.write_to_file(HomeScreen.this,
                                GTConstants.dardestinationFolder + GTConstants.darfileName,
                                "Event; " + incidentDescription + ";" + Utility.getLocalTime() + ";"
                                        + Utility.getLocalDate() + "\r\n",
                                true);

                        //write to srp
                        if (GTConstants.srpfileName.length() > 1)
                            Utility.write_to_file(HomeScreen.this,
                                    GTConstants.dardestinationFolder + GTConstants.srpfileName,
                                    "Event; " + incidentDescription + ";" + Utility.getLocalTime() + ";"
                                            + Utility.getLocalDate() + "\r\n",
                                    true);

                        //send the data
                        send_event(selectedCode);

                        //ask if user wants to create an incident report.  If the last character is a space, that indicates not to ask for report
                        if (!(incidentDescription.charAt(incidentDescription.length() - 1) == ' ')
                                && !trafficIncident)
                            showYesNoAlert("Report", "Create an Incident Report?", incidentreportScreen);
                        if (!(incidentDescription.charAt(incidentDescription.length() - 1) == ' ')
                                && trafficIncident)
                            showYesNoAlert("Report", "Create a Traffic Violation?", incidentreportScreen);

                        //if last two characters are spaces then ask to write a note
                        if (incidentDescription.charAt(incidentDescription.length() - 1) == ' '
                                && incidentDescription.charAt(incidentDescription.length() - 2) == ' ')
                            showYesNoAlert("Report", "Create a Note?", createNote);

                    }

                    //set spinner back to required state
                    if (selectedCode.equalsIgnoreCase(GTConstants.lunchin))
                        spinner.setSelection(lunchoutLocation);
                    else if (selectedCode.equalsIgnoreCase(GTConstants.startbreak))
                        spinner.setSelection(breakoutLocation);
                    else
                        spinner.setSelection(2);

                }
            }
        }

    });

    //Finds a view that was identified by the id attribute from the XML that was processed in onCreate(Bundle).
    spinner = (Spinner) findViewById(R.id.spinner_list);

    //method initialize the spinner action
    initializeSpinnerControl();

    if (GTConstants.service_intent == null) {
        //Condition to check whether the Database exist and if so load data into constants
        try {
            if (preferenceDB.checkDataBase()) {
                preferenceDB.open();

                Cursor cursor = preferenceDB.getRecordByRowID("1");

                preferenceDB.close();

                if (cursor == null)
                    loadPreferenceDataBase();
                else {
                    saveInConstants(cursor);
                    cursor.close();
                }
                syncDB();
                syncFTP();
                syncftpUpload();
            } else {
                preferenceDB.open();
                preferenceDB.close();
                //Toast.makeText(HomeScreen.this, "Path = " + preferenceDB.get_path(), Toast.LENGTH_LONG).show();
                //Toast.makeText(HomeScreen.this, "No database found", Toast.LENGTH_LONG).show();

                loadPreferenceDataBase();

                syncDB();
                syncFTP();
                syncftpUpload();
            }
        } catch (Exception e) {
            preferenceDB.createDataBase();
            loadPreferenceDataBase();
            Toast.makeText(HomeScreen.this, "Creating database", Toast.LENGTH_LONG).show();
        }

        //setup the auxiliary databases
        if (!aDB.checkDataBase()) {
            aDB.open();
            aDB.close();
        }

        if (!ftpdatabase.checkDataBase()) {
            ftpdatabase.open();
            ftpdatabase.close();
        }

        if (!gtDB.checkDataBase()) {
            gtDB.open();
            gtDB.close();
        }

        if (!trafficDB.checkDataBase()) {
            trafficDB.open();
            trafficDB.close();
        }

        if (!tourDB.checkDataBase()) {
            tourDB.open();
            tourDB.close();
        }

        //get the parameters from the parameter database
        loadGTParams();

        //this code starts the main service running which contains all the event timers
        if (Utility.deviceRegistered()) {
            //this is the application started event - sent once when application starts up
            if (savedInstanceState == null)
                send_event("PU");

            initService();
        }
    }

    //if device not registered than go straight to scan screen
    if (!Utility.deviceRegistered()) {
        newRegistration = true;
        //send_data = true;
        scan_click(false);
    }

    //setup the user banner
    setuserBanner();

    //set the warning text
    setwarningText("");

}