Example usage for android.graphics Color DKGRAY

List of usage examples for android.graphics Color DKGRAY

Introduction

In this page you can find the example usage for android.graphics Color DKGRAY.

Prototype

int DKGRAY

To view the source code for android.graphics Color DKGRAY.

Click Source Link

Usage

From source file:com.sentaroh.android.TaskAutomation.ActivityTaskStatus.java

private void showMainDialog(String action) {

    // common ??/*from  w  ww .  ja v a2 s .  c  o m*/
    mainDialog = new Dialog(context);
    mainDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mainDialog.setContentView(R.layout.task_status_dlg);

    if (util.isKeyguardEffective()) {
        Window win = mainDialog.getWindow();
        win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER
                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                //            WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    }
    ;

    TextView title = (TextView) mainDialog.findViewById(R.id.task_status_dlg_title);
    title.setText(getString(R.string.msgs_status_dialog_title));
    setSchedulerStatus();
    historyListView = (ListView) mainDialog.findViewById(R.id.task_status_dlg_history_listview);
    statusListView = (ListView) mainDialog.findViewById(R.id.task_status_dlg_status_listview);

    historyAdapter = new AdapterTaskStatusHistoryList(this, R.layout.task_history_list_item,
            getTaskHistoryList());
    historyListView.setAdapter(historyAdapter);
    historyListView.setSelection(historyAdapter.getCount() - 1);
    historyListView.setEnabled(true);
    historyListView.setSelected(true);
    setTaskListLongClickListener();

    statusAdapter = new AdapterTaskStatusActiveList(this, R.layout.task_status_list_item, getActiveTaskList(1));
    statusListView.setAdapter(statusAdapter);
    statusListView.setSelection(statusAdapter.getCount() - 1);
    statusListView.setEnabled(true);
    statusListView.setSelected(true);

    setCancelBtnListener();

    final Button btnStatus = (Button) mainDialog.findViewById(R.id.task_status_dlg_status_btn);
    final Button btnHistory = (Button) mainDialog.findViewById(R.id.task_status_dlg_history_btn);

    final CheckBox cb_enable_scheduler = (CheckBox) mainDialog
            .findViewById(R.id.task_status_dlg_status_enable_scheduler);

    final Button btnLog = (Button) mainDialog.findViewById(R.id.task_status_dlg_log_btn);
    final Button btnClose = (Button) mainDialog.findViewById(R.id.task_status_dlg_close_btn);

    CommonDialog.setDlgBoxSizeLimit(mainDialog, true);
    //      mainDialog.setOnKeyListener(new DialogOnKeyListener(context));

    cb_enable_scheduler.setChecked(envParms.settingEnableScheduler);
    cb_enable_scheduler.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        private boolean ignoreEvent = false;

        @Override
        public void onCheckedChanged(CompoundButton arg0, final boolean isChecked) {
            if (ignoreEvent) {
                ignoreEvent = false;
                return;
            }
            NotifyEvent ntfy = new NotifyEvent(null);
            ntfy.setListener(new NotifyEventListener() {
                @Override
                public void positiveResponse(Context c, Object[] o) {
                    envParms.setSettingEnableScheduler(context, isChecked);
                    try {
                        svcServer.aidlCancelAllActiveTask();
                        svcServer.aidlResetScheduler();
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
                    setSchedulerStatus();
                }

                @Override
                public void negativeResponse(Context c, Object[] o) {
                    ignoreEvent = true;
                    cb_enable_scheduler.setChecked(!isChecked);
                }
            });
            String msg = "";
            if (!isChecked)
                msg = context.getString(R.string.msgs_status_dialog_enable_scheduler_confirm_msg_disable);
            else
                msg = context.getString(R.string.msgs_status_dialog_enable_scheduler_confirm_msg_enable);
            CommonDialog cd = new CommonDialog(context, getSupportFragmentManager());
            cd.showCommonDialog(true, "W", "", msg, ntfy);
        }
    });

    btnStatus.setBackgroundResource(R.drawable.button_back_ground_color_selector);
    btnHistory.setBackgroundResource(R.drawable.button_back_ground_color_selector);

    if (action.equals("History")) {
        statusListView.setVisibility(ListView.GONE);
        historyListView.setVisibility(ListView.VISIBLE);
        btnStatus.setTextColor(Color.DKGRAY);
        btnHistory.setTextColor(Color.GREEN);
        btnHistory.setClickable(false);
    } else {
        statusListView.setVisibility(ListView.VISIBLE);
        historyListView.setVisibility(ListView.GONE);
        btnStatus.setTextColor(Color.GREEN);
        btnHistory.setTextColor(Color.DKGRAY);
        btnStatus.setClickable(false);
    }

    btnStatus.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            statusListView.setVisibility(ListView.VISIBLE);
            historyListView.setVisibility(ListView.GONE);
            btnStatus.setTextColor(Color.GREEN);
            btnHistory.setTextColor(Color.DKGRAY);
            btnStatus.setClickable(false);
            btnHistory.setClickable(true);
            setSchedulerStatus();
        }
    });

    btnHistory.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            statusListView.setVisibility(ListView.GONE);
            historyListView.setVisibility(ListView.VISIBLE);
            btnStatus.setTextColor(Color.DKGRAY);
            btnHistory.setTextColor(Color.GREEN);
            btnStatus.setClickable(true);
            btnHistory.setClickable(false);
            setSchedulerStatus();
        }
    });

    if (util.isLogFileExists())
        btnLog.setEnabled(true);
    else
        btnLog.setEnabled(false);
    btnLog.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            util.resetLogReceiver();
            Intent intent = new Intent();
            intent = new Intent(android.content.Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse("file://" + util.getLogFilePath()), "text/plain");
            startActivity(intent);
            setSchedulerStatus();
        }
    });

    // Close?
    btnClose.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mainDialog.dismiss();
            //            commonDlg.setFixedOrientation(false);
        }
    });
    mainDialog.setOnDismissListener(new OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface arg0) {
            finish();
        }
    });
    // Cancel?
    mainDialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnClose.performClick();
        }
    });
    //      commonDlg.setFixedOrientation(true);
    mainDialog.setCancelable(true);
    mainDialog.show();

}

From source file:org.mixare.MixListView.java

public void colorSource(String source) {
    for (int i = 0; i < bgcolors.length; i++) {
        bgcolors[i] = 0;/*from   ww  w.ja v a2 s .  c o  m*/
        textcolors[i] = Color.WHITE;
    }

    if (source.equals("Wikipedia"))
        changeColor(0, Color.WHITE, Color.DKGRAY);
    else if (source.equals("Twitter"))
        changeColor(1, Color.WHITE, Color.DKGRAY);
    else if (source.equals("Buzz"))
        changeColor(2, Color.WHITE, Color.DKGRAY);
    else if (source.equals("OpenStreetMap"))
        changeColor(3, Color.WHITE, Color.DKGRAY);
    else if (source.equals("OwnURL"))
        changeColor(4, Color.WHITE, Color.DKGRAY);
}

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

public void makeLayout() {
    // make fonts
    this.makeFonts();
    // clear the existing themes. 
    themes.clear();/*  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:terse.a1.TerseActivity.java

public void viewPath(String path, String queryStr, Bundle extras, Bundle savedInstanceState) {
    // Stop any running WorkThread before we continue.
    viewPath1prepare(path, queryStr);/*from   w w w .jav a 2s .c o  m*/
    viewPath2parseQuery(queryStr, extras);

    final LayoutParams widgetParams = new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT, 1.0f);

    TextView splash = new TextView(TerseActivity.this);
    splash.setText("Launching\n\n" + taPath + "\n\n" + Static.hashMapToMultiLineString(taQuery));
    splash.setTextAppearance(this, R.style.teletype);
    splash.setBackgroundColor(Color.BLACK);
    splash.setTextColor(Color.DKGRAY);
    splash.setTextSize(24);

    Runnable bg = new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    };

    Runnable fg = new Runnable() {
        @Override
        public void run() {
            viewPath9display(taPath, widgetParams);
        }
    };

    setContentViewThenBgThenFg("viewPath8", splash, bg, fg);
}

From source file:org.mixare.MixViewActivity.java

/**
 * Part of Android LifeCycle that gets called when "MixViewActivity" resumes.
 * <br/>/*from  w w w.  j  av a2 s  . c o  m*/
 * Does:
 * - Acquire Screen Lock
 * - Refreshes Data and Downloads
 * - Initiate four Matrixes that holds user's rotation markerRenderer.
 * - Re-register Sensors. {@link android.hardware.SensorManager SensorManager}
 * - Re-register Location Manager. {@link org.mixare.mgr.location.LocationFinder LocationFinder}
 * - Switch on Download Thread. {@link org.mixare.mgr.downloader.DownloadManager DownloadManager}
 * - restart markerRenderer refresh Timer.
 * <br/>
 * {@inheritDoc}
 */
@Override
protected void onResume() {
    super.onResume();
    if (cubeView != null) {
        //mRenderer.start();
        cubeView.onResume();
    }
    mSensorManager.registerListener(cubeView, mOrienation, SensorManager.SENSOR_DELAY_NORMAL);

    try {
        killOnError();
        MixContext.setActualMixViewActivity(this);
        HttpTools.setContext(MixContext.getInstance());

        //repaint(); //repaint when requested
        getMarkerRenderer().doStart();
        getMarkerRenderer().clearEvents();
        MixContext.getInstance().getNotificationManager().setEnabled(true);
        refreshDownload();

        MixContext.getInstance().getDataSourceManager().refreshDataSources();

        float angleX, angleY;

        int marker_orientation = -90;

        int rotation = Compatibility.getRotation(this);

        // display text from left to right and keep it horizontal
        angleX = (float) Math.toRadians(marker_orientation);
        getMixViewData().getM1().set(1f, 0f, 0f, 0f, (float) Math.cos(angleX), (float) -Math.sin(angleX), 0f,
                (float) Math.sin(angleX), (float) Math.cos(angleX));
        angleX = (float) Math.toRadians(marker_orientation);
        angleY = (float) Math.toRadians(marker_orientation);
        if (rotation == 1) {
            getMixViewData().getM2().set(1f, 0f, 0f, 0f, (float) Math.cos(angleX), (float) -Math.sin(angleX),
                    0f, (float) Math.sin(angleX), (float) Math.cos(angleX));
            getMixViewData().getM3().set((float) Math.cos(angleY), 0f, (float) Math.sin(angleY), 0f, 1f, 0f,
                    (float) -Math.sin(angleY), 0f, (float) Math.cos(angleY));
        } else {
            getMixViewData().getM2().set((float) Math.cos(angleX), 0f, (float) Math.sin(angleX), 0f, 1f, 0f,
                    (float) -Math.sin(angleX), 0f, (float) Math.cos(angleX));
            getMixViewData().getM3().set(1f, 0f, 0f, 0f, (float) Math.cos(angleY), (float) -Math.sin(angleY),
                    0f, (float) Math.sin(angleY), (float) Math.cos(angleY));

        }

        getMixViewData().getM4().toIdentity();

        for (int i = 0; i < getMixViewData().getHistR().length; i++) {
            getMixViewData().getHistR()[i] = new Matrix();
        }

        getMixViewData()
                .addListSensors(getMixViewData().getSensorMgr().getSensorList(Sensor.TYPE_ACCELEROMETER));
        if (getMixViewData().getSensor(0).getType() == Sensor.TYPE_ACCELEROMETER) {
            getMixViewData().setSensorGrav(getMixViewData().getSensor(0));
        } //else report error (unsupported hardware)

        getMixViewData()
                .addListSensors(getMixViewData().getSensorMgr().getSensorList(Sensor.TYPE_MAGNETIC_FIELD));
        if (getMixViewData().getSensor(1).getType() == Sensor.TYPE_MAGNETIC_FIELD) {
            getMixViewData().setSensorMag(getMixViewData().getSensor(1));
        } //else report error (unsupported hardware)

        if (!getMixViewData().getSensorMgr().getSensorList(Sensor.TYPE_GYROSCOPE).isEmpty()) {
            getMixViewData()
                    .addListSensors(getMixViewData().getSensorMgr().getSensorList(Sensor.TYPE_GYROSCOPE));
            if (getMixViewData().getSensor(2).getType() == Sensor.TYPE_GYROSCOPE) {
                getMixViewData().setSensorGyro(getMixViewData().getSensor(2));
            }
            getMixViewData().getSensorMgr().registerListener(this, getMixViewData().getSensorGyro(),
                    SENSOR_DELAY_GAME);
        }

        getMixViewData().getSensorMgr().registerListener(this, getMixViewData().getSensorGrav(),
                SENSOR_DELAY_GAME);
        getMixViewData().getSensorMgr().registerListener(this, getMixViewData().getSensorMag(),
                SENSOR_DELAY_GAME);

        try {
            GeomagneticField gmf = MixContext.getInstance().getLocationFinder().getGeomagneticField();
            angleY = (float) Math.toRadians(-gmf.getDeclination());
            getMixViewData().getM4().set((float) Math.cos(angleY), 0f, (float) Math.sin(angleY), 0f, 1f, 0f,
                    (float) -Math.sin(angleY), 0f, (float) Math.cos(angleY));
        } catch (Exception ex) {
            doError(ex, GPS_ERROR);
        }

        if (!isNetworkAvailable()) {
            Log.d(Config.TAG, "no network");
            doError(null, NO_NETWORK_ERROR);
        } else {
            Log.d(Config.TAG, "network");
        }

        MixContext.getInstance().getDownloadManager().switchOn();
        MixContext.getInstance().getLocationFinder().switchOn();
    } catch (Exception ex) {
        doError(ex, GENERAL_ERROR);
        try {
            if (getMixViewData().getSensorMgr() != null) {
                getMixViewData().getSensorMgr().unregisterListener(this, getMixViewData().getSensorGrav());
                getMixViewData().getSensorMgr().unregisterListener(this, getMixViewData().getSensorMag());
                getMixViewData().getSensorMgr().unregisterListener(this, getMixViewData().getSensorGyro());
                getMixViewData().setSensorMgr(null);
            }

            if (MixContext.getInstance() != null) {
                MixContext.getInstance().getLocationFinder().switchOff();
                MixContext.getInstance().getDownloadManager().switchOff();
            }
        } catch (Exception ignore) {
        }
    } finally {
        //This does not conflict with registered sensors (sensorMag, sensorGrav)
        //This is a place holder to API returned listed of sensors, we registered
        //what we need, the rest is unnecessary.
        getMixViewData().clearAllSensors();
    }

    Log.d(Config.TAG, "resume");
    if (getMarkerRenderer() == null) {
        return;
    }
    if (getMarkerRenderer().isFrozen() && getMixViewData().getSearchNotificationTxt() == null) {
        getMixViewData().setSearchNotificationTxt(new TextView(this));
        getMixViewData().getSearchNotificationTxt().setWidth(getPaintScreen().getWidth());
        getMixViewData().getSearchNotificationTxt().setPadding(10, 2, 0, 0);
        getMixViewData().getSearchNotificationTxt().setText(getString(R.string.search_active_1) + " "
                + DataSourceList.getDataSourcesStringList() + getString(R.string.search_active_2));
        ;
        getMixViewData().getSearchNotificationTxt().setBackgroundColor(Color.DKGRAY);
        getMixViewData().getSearchNotificationTxt().setTextColor(Color.WHITE);

        getMixViewData().getSearchNotificationTxt().setOnTouchListener(this);
        addContentView(getMixViewData().getSearchNotificationTxt(),
                new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    } else if (!getMarkerRenderer().isFrozen() && getMixViewData().getSearchNotificationTxt() != null) {
        getMixViewData().getSearchNotificationTxt().setVisibility(View.GONE);
        getMixViewData().setSearchNotificationTxt(null);
    }
}

From source file:com.aware.Aware_Preferences.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mSensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE);

    //Start the Aware
    Intent startAware = new Intent(getApplicationContext(), Aware.class);
    startService(startAware);//from  w  w w.j  a v a  2  s  . c om

    addPreferencesFromResource(R.xml.aware_preferences);
    setContentView(R.layout.aware_ui);

    navigationDrawer = (DrawerLayout) findViewById(R.id.aware_ui_main);
    navigationList = (ListView) findViewById(R.id.aware_navigation);
    navigationToggle = new ActionBarDrawerToggle(this, navigationDrawer, R.drawable.ic_drawer,
            R.string.drawer_open, R.string.drawer_close) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (Build.VERSION.SDK_INT > 11) {
                getActionBar().setTitle(getTitle());
                invalidateOptionsMenu();
            }
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (Build.VERSION.SDK_INT > 11) {
                getActionBar().setTitle(getTitle());
                invalidateOptionsMenu();
            }
        }
    };

    navigationDrawer.setDrawerListener(navigationToggle);

    String[] options = { "Stream", "Sensors", "Plugins", "Studies" };
    NavigationAdapter nav_adapter = new NavigationAdapter(getApplicationContext(), options);
    navigationList.setAdapter(nav_adapter);
    navigationList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            LinearLayout item_container = (LinearLayout) view.findViewById(R.id.nav_container);
            item_container.setBackgroundColor(Color.DKGRAY);

            for (int i = 0; i < navigationList.getChildCount(); i++) {
                if (i != position) {
                    LinearLayout other = (LinearLayout) navigationList.getChildAt(i);
                    LinearLayout other_item = (LinearLayout) other.findViewById(R.id.nav_container);
                    other_item.setBackgroundColor(Color.TRANSPARENT);
                }
            }

            Bundle animations = ActivityOptions.makeCustomAnimation(Aware_Preferences.this,
                    R.anim.anim_slide_in_left, R.anim.anim_slide_out_left).toBundle();
            switch (position) {
            case 0: //Stream
                Intent stream_ui = new Intent(Aware_Preferences.this, Stream_UI.class);
                startActivity(stream_ui, animations);
                break;
            case 1: //Sensors
                Intent sensors_ui = new Intent(Aware_Preferences.this, Aware_Preferences.class);
                startActivity(sensors_ui, animations);
                break;
            case 2: //Plugins
                Intent plugin_manager = new Intent(Aware_Preferences.this, Plugins_Manager.class);
                startActivity(plugin_manager, animations);
                break;
            case 3: //Studies
                if (Aware.getSetting(getApplicationContext(), "study_id").length() > 0) {
                    new Async_StudyData().execute(
                            Aware.getSetting(getApplicationContext(), Aware_Preferences.WEBSERVICE_SERVER));
                } else {
                    Intent join_study = new Intent(Aware_Preferences.this, CameraStudy.class);
                    startActivityForResult(join_study, REQUEST_JOIN_STUDY, animations);
                }
                break;
            }

            navigationDrawer.closeDrawer(navigationList);
        }
    });

    if (getActionBar() != null) {
        getActionBar().setDisplayHomeAsUpEnabled(true);
        getActionBar().setHomeButtonEnabled(true);
    }

    SharedPreferences prefs = getSharedPreferences(getPackageName(), Context.MODE_PRIVATE);
    if (prefs.getAll().isEmpty()
            && Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID).length() == 0) {
        is_first_time = true;
        PreferenceManager.setDefaultValues(getApplicationContext(), getPackageName(), Context.MODE_PRIVATE,
                R.xml.aware_preferences, true);
        prefs.edit().commit(); //commit changes
    } else {
        PreferenceManager.setDefaultValues(getApplicationContext(), getPackageName(), Context.MODE_PRIVATE,
                R.xml.aware_preferences, false);
    }

    Map<String, ?> defaults = prefs.getAll();
    for (Map.Entry<String, ?> entry : defaults.entrySet()) {
        if (Aware.getSetting(getApplicationContext(), entry.getKey()).length() == 0) {
            Aware.setSetting(getApplicationContext(), entry.getKey(), entry.getValue());
        }
    }

    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID).length() == 0) {
        UUID uuid = UUID.randomUUID();
        Aware.setSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID, uuid.toString());
    }
}

From source file:org.chromium.latency.walt.ScreenResponseFragment.java

private void drawBrightnessChart() {
    final String brightnessCurveString = brightnessCurveData.toString();
    List<Entry> entries = new ArrayList<>();

    // "u" marks the start of the brightness curve data
    int startIndex = brightnessCurveString.indexOf("u") + 1;
    int endIndex = brightnessCurveString.indexOf("end");
    if (endIndex == -1)
        endIndex = brightnessCurveString.length();

    String[] brightnessStrings = brightnessCurveString.substring(startIndex, endIndex).trim().split("\n");
    for (String str : brightnessStrings) {
        String[] arr = str.split(" ");
        final float timestampMs = Integer.parseInt(arr[0]) / 1000f;
        final float brightness = Integer.parseInt(arr[1]);
        entries.add(new Entry(timestampMs, brightness));
    }//from   w w  w  . ja va  2s  .c o  m
    LineDataSet dataSet = new LineDataSet(entries, "Brightness");
    dataSet.setColor(Color.BLACK);
    dataSet.setValueTextColor(Color.BLACK);
    dataSet.setCircleColor(Color.BLACK);
    dataSet.setCircleRadius(1.5f);
    dataSet.setCircleColorHole(Color.DKGRAY);
    LineData lineData = new LineData(dataSet);
    brightnessChart.setData(lineData);
    final Description desc = new Description();
    desc.setText("Screen Brightness [digital level 0-1023] vs. Time [ms]");
    desc.setTextSize(12f);
    brightnessChart.setDescription(desc);
    brightnessChart.getLegend().setEnabled(false);
    brightnessChart.invalidate();
    brightnessChartLayout.setVisibility(View.VISIBLE);
}

From source file:com.jinfukeji.jinyihuiup.indexBannerClick.ZhiboActivity.java

private void initTabImage() {
    chat_txt.setTextColor(Color.DKGRAY);
    jianjie_txt.setTextColor(Color.DKGRAY);
    video_txt.setTextColor(Color.DKGRAY);
    chat_img.setImageResource(R.mipmap.ic_broadcastroom_chat_default);
    jianjie_img.setImageResource(R.mipmap.ic_broadcastroom_intro_default);
    video_img.setImageResource(R.mipmap.ic_broadcastroom_video_default);
}

From source file:com.ruesga.timelinechart.TimelineChartView.java

private void init(Context ctx, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    mUiHandler = new Handler(Looper.getMainLooper(), mMessenger);
    if (!isInEditMode()) {
        mAudioManager = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
    }/*  w  w w  .  jav  a 2 s.  com*/

    final Resources res = getResources();
    final Resources.Theme theme = ctx.getTheme();

    mTickFormats = getResources().getStringArray(R.array.tlcDefTickLabelFormats);
    mTickLabels = getResources().getStringArray(R.array.tlcDefTickLabelValues);

    final DisplayMetrics dp = getResources().getDisplayMetrics();
    mSize8 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 8, dp);
    mSize12 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, dp);
    mSize20 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 20, dp);

    final ViewConfiguration vc = ViewConfiguration.get(ctx);
    mLongPressTimeout = ViewConfiguration.getLongPressTimeout();
    mTouchSlop = vc.getScaledTouchSlop() / 2;
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mScroller = new OverScroller(ctx);

    int graphBgColor = ContextCompat.getColor(ctx, R.color.tlcDefGraphBackgroundColor);
    int footerBgColor = ContextCompat.getColor(ctx, R.color.tlcDefFooterBackgroundColor);

    mDefFooterBarHeight = mFooterBarHeight = res.getDimension(R.dimen.tlcDefFooterBarHeight);
    mShowFooter = res.getBoolean(R.bool.tlcDefShowFooter);
    mGraphMode = res.getInteger(R.integer.tlcDefGraphMode);
    mPlaySelectionSoundEffect = res.getBoolean(R.bool.tlcDefPlaySelectionSoundEffect);
    mSelectionSoundEffectSource = res.getInteger(R.integer.tlcDefSelectionSoundEffectSource);
    mAnimateCursorTransition = res.getBoolean(R.bool.tlcDefAnimateCursorTransition);
    mFollowCursorPosition = res.getBoolean(R.bool.tlcDefFollowCursorPosition);
    mAlwaysEnsureSelection = res.getBoolean(R.bool.tlcDefAlwaysEnsureSelection);

    mGraphAreaBgPaint = new Paint();
    mGraphAreaBgPaint.setColor(graphBgColor);
    mFooterAreaBgPaint = new Paint();
    mFooterAreaBgPaint.setColor(footerBgColor);
    mTickLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
    mTickLabelFgPaint.setFakeBoldText(true);
    mTickLabelFgPaint.setColor(MaterialPaletteHelper.isDarkColor(footerBgColor) ? Color.LTGRAY : Color.DKGRAY);

    mBarItemWidth = res.getDimension(R.dimen.tlcDefBarItemWidth);
    mBarItemSpace = res.getDimension(R.dimen.tlcDefBarItemSpace);

    TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.tlcTimelineChartView, defStyleAttr,
            defStyleRes);
    try {
        int n = a.getIndexCount();
        for (int i = 0; i < n; i++) {
            int attr = a.getIndex(i);
            if (attr == R.styleable.tlcTimelineChartView_tlcGraphBackground) {
                graphBgColor = a.getColor(attr, graphBgColor);
                mGraphAreaBgPaint.setColor(graphBgColor);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcShowFooter) {
                mShowFooter = a.getBoolean(attr, mShowFooter);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcFooterBackground) {
                footerBgColor = a.getColor(attr, footerBgColor);
                mFooterAreaBgPaint.setColor(footerBgColor);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcFooterBarHeight) {
                mFooterBarHeight = a.getDimension(attr, mFooterBarHeight);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcGraphMode) {
                mGraphMode = a.getInt(attr, mGraphMode);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcAnimateCursorTransition) {
                mAnimateCursorTransition = a.getBoolean(attr, mAnimateCursorTransition);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcFollowCursorPosition) {
                mFollowCursorPosition = a.getBoolean(attr, mFollowCursorPosition);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcAlwaysEnsureSelection) {
                mAlwaysEnsureSelection = a.getBoolean(attr, mAlwaysEnsureSelection);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcBarItemWidth) {
                mBarItemWidth = a.getDimension(attr, mBarItemWidth);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcBarItemSpace) {
                mBarItemSpace = a.getDimension(attr, mBarItemSpace);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcPlaySelectionSoundEffect) {
                mPlaySelectionSoundEffect = a.getBoolean(attr, mPlaySelectionSoundEffect);
            } else if (attr == R.styleable.tlcTimelineChartView_tlcSelectionSoundEffectSource) {
                mSelectionSoundEffectSource = a.getInt(attr, mSelectionSoundEffectSource);
            }
        }
    } finally {
        a.recycle();
    }

    // SurfaceView requires a background
    if (getBackground() == null) {
        setBackgroundColor(ContextCompat.getColor(ctx, android.R.color.transparent));
    }

    // Minimize the impact of create dynamic layouts by assume that in most case
    // we will have a day formatter
    mTickHasDayFormat = true;

    // Initialize stuff
    setupBackgroundHandler();
    setupTickLabels();
    if (ViewCompat.getOverScrollMode(this) != ViewCompat.OVER_SCROLL_NEVER) {
        setupEdgeEffects();
    }
    setupAnimators();
    setupSoundEffects();

    // Initialize the drawing refs (this will be update when we have
    // the real size of the canvas)
    computeBoundAreas();

    // Create a fake data for the edit mode
    if (isInEditMode()) {
        setupViewInEditMode();
    }
}