Example usage for android.graphics Typeface createFromAsset

List of usage examples for android.graphics Typeface createFromAsset

Introduction

In this page you can find the example usage for android.graphics Typeface createFromAsset.

Prototype

public static Typeface createFromAsset(AssetManager mgr, String path) 

Source Link

Document

Create a new typeface from the specified font data.

Usage

From source file:com.arman.efficientqhalgoforch.SuperAwesomeCardFragment.java

public void doHardcore(View v, final LayoutInflater inflater) {
    tvX = (TextView) v.findViewById(R.id.tvXMax);

    mChart = (ScatterChart) v.findViewById(R.id.chart1);
    mChart.setDescription("");

    tf = Typeface.createFromAsset((SuperAwesomeCardFragment.this).getActivity().getAssets(),
            "OpenSans-Regular.ttf");

    mChart.setOnChartValueSelectedListener(this);

    mChart.setDrawGridBackground(false);

    mChart.setTouchEnabled(true);/*from  w ww.ja v a 2 s .  c  om*/
    mChart.setHighlightEnabled(true);

    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);

    mChart.setMaxVisibleValueCount(200);
    mChart.setPinchZoom(true);

    Legend l = mChart.getLegend();
    l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
    l.setTypeface(tf);

    YAxis yl = mChart.getAxisLeft();
    yl.setTypeface(tf);

    mChart.getAxisRight().setEnabled(false);

    XAxis xl = mChart.getXAxis();
    xl.setTypeface(tf);
    xl.setDrawGridLines(false);

}

From source file:com.sythealth.fitness.util.Utils.java

public static void setTypeface2(Context context, TextView tv) {
    Typeface typeface = Typeface.createFromAsset(context.getAssets(), "fonts/shishanghei.ttf");
    tv.setTypeface(typeface);//from   w w  w .j av  a2 s. c  o  m
}

From source file:com.appsummary.luoxf.myappsummary.navigationtabstrip.NavigationTabStrip.java

public void setTypeface(final String typeface) {
    Typeface tempTypeface;//w  ww.  j a va2s . c o m
    try {
        tempTypeface = Typeface.createFromAsset(getContext().getAssets(), typeface);
    } catch (Exception e) {
        tempTypeface = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL);
        e.printStackTrace();
    }

    setTypeface(tempTypeface);
}

From source file:flex.android.magiccube.activity.ActivityBattleMode.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mode_battle);
    btMoveBack = (ImageButton) findViewById(R.id.bt_battle_moveback);
    btMoveForward = (ImageButton) findViewById(R.id.bt_battle_moveforward);
    btStartOb = (ImageButton) findViewById(R.id.bt_battle_startob);

    clock = (ImageView) findViewById(R.id.img_battle_clock);
    txtTime = (TextView) findViewById(R.id.txt_battle_time);
    txtNStep = (TextView) findViewById(R.id.txt_battle_nStep);
    img_nstep = (ImageView) findViewById(R.id.img_battle_nstep);
    progress = (SeekBar) findViewById(R.id.sbar_battle_timer);

    /*//w  w  w  .j  ava  2 s  .c o m
     * clock.setVisibility(View.VISIBLE);
     * btMoveForward.setVisibility(View.VISIBLE);
     * btMoveBack.setVisibility(View.VISIBLE);
     */

    glView = (ViewBattleMode) findViewById(R.id.game_view_battle);
    glView.SetOnTimerListener(this);
    // glView.setOnStateListener(this);
    glView.SetOnStepListener(this);
    glView.SetMessageSender(this);
    glView.SetDrawCube(false);
    glView.setOnStateListener(this);

    glView2 = (ViewBattleMode) findViewById(R.id.game_view_battle2);
    glView2.SetCanMove(false);

    btMoveBack.setOnClickListener(buttonListener);
    btMoveForward.setOnClickListener(buttonListener);
    btStartOb.setOnClickListener(buttonListener);

    float fontsize = 25.f;
    Typeface typeFace = Typeface.createFromAsset(getAssets(), "fonts/Angies New House.ttf");
    txtTime.setTypeface(typeFace);
    txtTime.setTextColor(Color.GRAY);
    txtTime.setTextSize(fontsize);

    txtNStep.setTypeface(typeFace);
    txtNStep.setTextColor(Color.GRAY);
    txtNStep.setTextSize(fontsize);

    State = OnStateListener.NONE;

    BgVolume = MagiccubePreference.GetPreference(MagiccubePreference.BgVolume, this);
    LinearBgVolume = MusicPlayThread.GetLinearVolume(BgVolume);

    GamingbgmPlayer = MediaPlayer.create(this, R.raw.bg2);
    ObservingbgmPlayer = MediaPlayer.create(this, R.raw.bg);
    FinishbgmPlayer = MediaPlayer.create(this, R.raw.finish);

    GamingbgmPlayer.setVolume(LinearBgVolume, LinearBgVolume);
    ObservingbgmPlayer.setVolume(LinearBgVolume, LinearBgVolume);
    FinishbgmPlayer.setVolume(LinearBgVolume, LinearBgVolume);

    Init();

    // Get local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
        Toast.makeText(this, "...", Toast.LENGTH_LONG).show();
        finish();
        return;
    }

    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

    width = wm.getDefaultDisplay().getWidth();
    height = wm.getDefaultDisplay().getHeight();

    layout_moveforward = (LinearLayout) findViewById(R.id.layout_battle_moveforward);
    layout_moveback = (LinearLayout) findViewById(R.id.layout_battle_moveback);

    int buttonwidth = width / 5;
    int buttonheight = height / 13;

    LinearLayout.LayoutParams parms = new LinearLayout.LayoutParams(buttonwidth, buttonheight);

    btMoveForward.setLayoutParams(parms);
    btMoveBack.setLayoutParams(parms);

    layout_moveforward.setPadding(width / 2 - buttonwidth / 2, height - buttonheight, 0, 0);
    layout_moveback.setPadding(width / 15, height - buttonheight, 0, 0);

}

From source file:com.handpoint.headstart.client.ui.ReceiptActivity.java

private void initReceiptView() {
    Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/roboto-regular.ttf");

    TextView merchantName = (TextView) findViewById(R.id.merchant_name);
    merchantName.setTypeface(tf, Typeface.BOLD);
    merchantName.setText(getMerchantName());

    TextView transactionDateView = (TextView) findViewById(R.id.date);
    java.text.DateFormat df = DateFormat.getDateFormat(this);
    transactionDateView.setTypeface(tf);
    transactionDateView.setText(" " + df.format(mResult.getDateTime()));

    TextView transactionResult = (TextView) findViewById(R.id.transaction_result);
    transactionResult.setTypeface(tf, Typeface.BOLD);
    transactionResult.setText(mResult.getFinancialStatus());

    TextView messageView = (TextView) findViewById(R.id.message);
    messageView.setTypeface(tf);//from w w  w .  ja v  a 2s. com
    String message = ((Application) getApplication()).formatErrorMessage(mResult.getStatusMessage(),
            mResult.getErrorMessage());
    messageView.setText(message);

    ImageView cardSchemeLogo = (ImageView) findViewById(R.id.card_scheme_logo);
    cardSchemeLogo.setImageDrawable(getCardSchemeLogo());

    TextView amountView = (TextView) findViewById(R.id.amount_text);
    amountView.setTypeface(tf);
    amountView.setText(getTotalAmount(mResult.getAuthorizedAmount(), mResult.getCurrency()));

    TextView descriptionView = (TextView) findViewById(R.id.item_description_text);
    descriptionView.setTypeface(tf);
    descriptionView.setText(getDescriptionText());

    ImageView productImageView = (ImageView) findViewById(R.id.picture);
    productImageView.setImageBitmap(getImageBitmap());
}

From source file:com.openerp.addons.idea.product.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case R.id.Dash_Board:

        Dash_Board detail = new Dash_Board();
        FragmentListener frag = (FragmentListener) getActivity();
        frag.startDetailFragment(detail);

        return true;

    case R.id.Search_product:

        final Dialog dialog = new Dialog(getActivity());
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.product_search_custom_dialog);
        //   dialog.setTitle("Product Search");
        dialog.setOnCancelListener(new OnCancelListener() {

            @Override//from w ww .  j  a  v  a2 s.  c  om
            public void onCancel(DialogInterface dialog) {

                dialog.dismiss();
            }
        });

        AutoCompleteTextView autotext = (AutoCompleteTextView) dialog
                .findViewById(R.id.autoCompleteTextView_product_search);
        final ArrayAdapter adapter = new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_1,
                OEHelper.datatemplate);
        TextView txv = (TextView) dialog.findViewById(R.id.textView1);
        Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Georgia.ttf");
        autotext.setTypeface(font, Typeface.BOLD);
        autotext.setAdapter(adapter);
        txv.setTypeface(font, Typeface.BOLD);
        autotext.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

                String name = adapter.getItem(arg2).toString();
                callmethod_for_position_productdetail(OEHelper.datatemplate.indexOf(name));
                dialog.dismiss();
            }
        });

        dialog.show();
        return true;
    }
    return true;
}

From source file:com.example.drugsformarinemammals.General_Info_Drug.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.general_info_drug);
    isStoredInLocal = false;// www.  ja  va  2s .  c  o m
    fiveLastScreen = false;
    helper = new Handler_Sqlite(this);
    helper.open();
    Bundle extras1 = this.getIntent().getExtras();
    if (extras1 != null) {
        infoBundle = extras1.getStringArrayList("generalInfoDrug");
        fiveLastScreen = extras1.getBoolean("fiveLastScreen");
        if (infoBundle == null)
            isStoredInLocal = true;
        if (!isStoredInLocal) {
            initializeGeneralInfoDrug();
            initializeCodesInformation();
            initializeCodes();
        } else {
            drug_name = extras1.getString("drugName");
            codes = helper.getCodes(drug_name);
            codesInformation = helper.getCodesInformation(drug_name);
        }
        //Title
        TextView drugTitle = (TextView) findViewById(R.id.drugTitle);
        drugTitle.setText(drug_name);
        drugTitle.setTypeface(Typeface.SANS_SERIF);

        //Description 
        LinearLayout borderDescription = new LinearLayout(this);
        borderDescription.setOrientation(LinearLayout.VERTICAL);
        borderDescription
                .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        borderDescription.setBackgroundResource(R.drawable.layout_border);

        TextView description = new TextView(this);
        if (isStoredInLocal)
            description.setText(helper.getDescription(drug_name));
        else
            description.setText(this.description);
        description.setTextSize(18);
        description.setTypeface(Typeface.SANS_SERIF);

        LinearLayout.LayoutParams paramsDescription = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsDescription.leftMargin = 60;
        paramsDescription.rightMargin = 60;
        paramsDescription.topMargin = 20;

        borderDescription.addView(description, borderDescription.getChildCount(), paramsDescription);

        LinearLayout layoutDescription = (LinearLayout) findViewById(R.id.layoutDescription);
        layoutDescription.addView(borderDescription, layoutDescription.getChildCount());

        //Animals
        TextView headerAnimals = (TextView) findViewById(R.id.headerAnimals);
        headerAnimals.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        Button cetaceansButton = (Button) findViewById(R.id.cetaceansButton);
        cetaceansButton.setText("CETACEANS");
        cetaceansButton.setTypeface(Typeface.SANS_SERIF);
        cetaceansButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Cetaceans");
            }
        });

        Button pinnipedsButton = (Button) findViewById(R.id.pinnipedsButton);
        pinnipedsButton.setText("PINNIPEDS");
        pinnipedsButton.setTypeface(Typeface.SANS_SERIF);
        pinnipedsButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                SQLiteDatabase db = helper.open();
                ArrayList<String> families = new ArrayList<String>();
                if (db != null)
                    families = helper.read_animals_family(drug_name, "Pinnipeds");
                if ((families != null && families.size() == 1 && families.get(0).equals(""))
                        || (families != null && families.size() == 0))
                    showDoseInformation(drug_name, "Pinnipeds");
                else
                    showDoseInformationPinnipeds(drug_name, families);
            }
        });

        Button otherButton = (Button) findViewById(R.id.otherButton);
        otherButton.setText("OTHER MM");
        otherButton.setTypeface(Typeface.SANS_SERIF);
        otherButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Other MM");
            }
        });

        //Codes & therapeutic target & anatomical target
        TextView headerATCvetCodes = (TextView) findViewById(R.id.headerATCvetCodes);
        headerATCvetCodes.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        //Action
        TextView headerActionAnatomical = (TextView) findViewById(R.id.headerActionAnatomical);
        headerActionAnatomical.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewAnatomical();
        createBorderAnatomicalGroup();

        TextView headerActionTherapeutic = (TextView) findViewById(R.id.headerActionTherapeutic);
        headerActionTherapeutic.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewTherapeutic();
        createBorderTherapeuticGroup();

        params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.leftMargin = 60;
        params.rightMargin = 60;
        params.topMargin = 20;

        Spinner codesSpinner = (Spinner) findViewById(R.id.codesSpinner);
        SpinnerAdapter adapterCodes = new SpinnerAdapter(this, R.layout.item_spinner, codes);
        adapterCodes.setDropDownViewResource(R.layout.spinner_dropdown_item);
        codesSpinner.setAdapter(adapterCodes);
        codesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

            public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
                userEntryCode = parent.getSelectedItem().toString();
                int numCodes = codesInformation.size();

                layoutAnatomicalGroup.removeView(borderAnatomicalGroup);
                createBorderAnatomicalGroup();

                boolean founded = false;
                int i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewAnatomical();
                        anatomicalGroup.setText(codesInformation.get(i).getAnatomic_group() + "\n");
                        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }

                layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
                layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
                layoutTherapeuticGroup.removeView(borderTherapeuticGroup);
                createBorderTherapeuticGroup();
                founded = false;
                i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewTherapeutic();
                        therapeuticGroup.setText(codesInformation.get(i).getTherapeutic_group() + "\n");
                        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }
                layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);
                layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());
            }

            public void onNothingSelected(AdapterView<?> arg0) {
            }
        });

        layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
        layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);

        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params);
        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params);

        layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
        layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());

        //Generic Drug
        TextView headerGenericDrug = (TextView) findViewById(R.id.headerGenericDrug);
        headerGenericDrug.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
        boolean isAvalaible = false;
        if (isStoredInLocal)
            isAvalaible = helper.isAvalaible(drug_name);
        else
            isAvalaible = available.equals("Yes");
        if (isAvalaible) {
            ImageView genericDrug = new ImageView(this);
            genericDrug.setImageResource(R.drawable.tick_verde);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        } else {
            Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
            TextView genericDrug = new TextView(this);
            genericDrug.setTypeface(font);
            genericDrug.setText("Nd");
            genericDrug.setTextColor(getResources().getColor(R.color.maroon));
            genericDrug.setTextSize(20);
            DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            int size = metrics.widthPixels;
            int middle = size / 2;
            int quarter = size / 4;
            genericDrug.setTranslationX(middle - quarter);
            genericDrug.setTranslationY(-3);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        }

        //Licenses
        TextView headerLicense = (TextView) findViewById(R.id.headerLicense);
        headerLicense.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        TextView fdaLicense = (TextView) findViewById(R.id.license1);
        Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
        fdaLicense.setTypeface(font);

        String fda;
        if (isStoredInLocal)
            fda = helper.getLicense_FDA(drug_name);
        else
            fda = license_FDA;
        if (fda.equals("Yes")) {
            fdaLicense.setText("Yes");
            fdaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            fdaLicense.setText("Nd");
            fdaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView emaLicense = (TextView) findViewById(R.id.license3);
        emaLicense.setTypeface(font);
        String ema;
        if (isStoredInLocal)
            ema = helper.getLicense_EMA(drug_name);
        else
            ema = license_EMA;
        if (ema.equals("Yes")) {
            emaLicense.setText("Yes");
            emaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            emaLicense.setText("Nd");
            emaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView aempsLicense = (TextView) findViewById(R.id.license2);
        aempsLicense.setTypeface(font);
        String aemps;
        if (isStoredInLocal)
            aemps = helper.getLicense_AEMPS(drug_name);
        else
            aemps = license_AEMPS;
        if (aemps.equals("Yes")) {
            aempsLicense.setText("Yes");
            aempsLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            aempsLicense.setText("Nd");
            aempsLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        ImageButton food_and_drug = (ImageButton) findViewById(R.id.food_and_drug);
        food_and_drug.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.fda.gov/animalveterinary/products/approvedanimaldrugproducts/default.htm"));
                startActivity(intent);
            }
        });

        ImageButton european_medicines_agency = (ImageButton) findViewById(R.id.european_medicines_agency);
        european_medicines_agency.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.ema.europa.eu/ema/index.jsp?curl=pages/medicines/landing/vet_epar_search.jsp&mid=WC0b01ac058001fa1c"));
                startActivity(intent);
            }
        });

        ImageButton logo_aemps = (ImageButton) findViewById(R.id.logo_aemps);
        logo_aemps.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.aemps.gob.es/medicamentosVeterinarios/Med-Vet-autorizados/home.htm"));
                startActivity(intent);
            }

        });

        if (helper.existDrug(drug_name)) {
            int drug_priority = helper.getDrugPriority(drug_name);
            ArrayList<String> sorted_drugs = new ArrayList<String>();
            sorted_drugs.add(0, drug_name);
            for (int i = 1; i < drug_priority; i++) {
                String name = helper.getDrugName(i);
                sorted_drugs.add(i, name);
            }

            for (int i = 0; i < sorted_drugs.size(); i++)
                helper.setDrugPriority(sorted_drugs.get(i), i + 1);
        }

        if (!isStoredInLocal) {
            //Server code
            String[] urls = { "http://formmulary.tk/Android/getDoseInformation.php?drug_name=",
                    "http://formmulary.tk/Android/getGeneralNotesInformation.php?drug_name=" };
            new GetDoseInformation(this).execute(urls);
        }

        helper.close();
    }

}

From source file:com.irccloud.android.activity.LoginActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 21) {
        Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
        setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name),
                cloud, 0xff0b2e60));//from w w w.  ja  v  a  2 s  .c  om
        cloud.recycle();
    }

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    setContentView(R.layout.activity_login);

    loading = findViewById(R.id.loading);

    connecting = findViewById(R.id.connecting);
    connectingMsg = (TextView) findViewById(R.id.connectingMsg);
    progressBar = (ProgressBar) findViewById(R.id.connectingProgress);

    loginHint = (LinearLayout) findViewById(R.id.loginHint);
    signupHint = (LinearLayout) findViewById(R.id.signupHint);
    hostHint = (TextView) findViewById(R.id.hostHint);

    login = findViewById(R.id.login);
    name = (EditText) findViewById(R.id.name);
    if (savedInstanceState != null && savedInstanceState.containsKey("name"))
        name.setText(savedInstanceState.getString("name"));
    email = (AutoCompleteTextView) findViewById(R.id.email);
    if (BuildConfig.ENTERPRISE)
        email.setHint(R.string.email_enterprise);
    ArrayList<String> accounts = new ArrayList<String>();
    AccountManager am = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE);
    for (Account a : am.getAccounts()) {
        if (a.name.contains("@") && !accounts.contains(a.name))
            accounts.add(a.name);
    }
    if (accounts.size() > 0)
        email.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
                accounts.toArray(new String[accounts.size()])));

    if (savedInstanceState != null && savedInstanceState.containsKey("email"))
        email.setText(savedInstanceState.getString("email"));

    password = (EditText) findViewById(R.id.password);
    password.setOnEditorActionListener(new OnEditorActionListener() {
        public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                new LoginTask().execute((Void) null);
                return true;
            }
            return false;
        }
    });
    if (savedInstanceState != null && savedInstanceState.containsKey("password"))
        password.setText(savedInstanceState.getString("password"));

    host = (EditText) findViewById(R.id.host);
    if (BuildConfig.ENTERPRISE)
        host.setText(NetworkConnection.IRCCLOUD_HOST);
    else
        host.setVisibility(View.GONE);
    host.setOnEditorActionListener(new OnEditorActionListener() {
        public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                new LoginTask().execute((Void) null);
                return true;
            }
            return false;
        }
    });
    if (savedInstanceState != null && savedInstanceState.containsKey("host"))
        host.setText(savedInstanceState.getString("host"));
    else
        host.setText(getSharedPreferences("prefs", 0).getString("host", BuildConfig.HOST));

    if (host.getText().toString().equals("api.irccloud.com")
            || host.getText().toString().equals("www.irccloud.com"))
        host.setText("");

    loginBtn = (Button) findViewById(R.id.loginBtn);
    loginBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            new LoginTask().execute((Void) null);
        }
    });
    loginBtn.setFocusable(true);
    loginBtn.requestFocus();

    sendAccessLinkBtn = (Button) findViewById(R.id.sendAccessLink);
    sendAccessLinkBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            new ResetPasswordTask().execute((Void) null);
        }
    });

    nextBtn = (Button) findViewById(R.id.nextBtn);
    nextBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (host.getText().length() > 0) {
                NetworkConnection.IRCCLOUD_HOST = host.getText().toString();
                trimHost();

                new EnterpriseConfigTask().execute((Void) null);
            }
        }
    });

    TOS = (TextView) findViewById(R.id.TOS);
    TOS.setMovementMethod(new LinkMovementMethod());

    forgotPassword = (TextView) findViewById(R.id.forgotPassword);
    forgotPassword.setOnClickListener(forgotPasswordClickListener);

    enterpriseLearnMore = (TextView) findViewById(R.id.enterpriseLearnMore);
    enterpriseLearnMore.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (isPackageInstalled("com.irccloud.android", LoginActivity.this)) {
                startActivity(getPackageManager().getLaunchIntentForPackage("com.irccloud.android"));
            } else {
                try {
                    startActivity(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("market://details?id=com.irccloud.android")));
                } catch (Exception e) {
                    startActivity(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("http://play.google.com/store/apps/details?id=com.irccloud.android")));
                }
            }
        }

        private boolean isPackageInstalled(String packagename, Context context) {
            PackageManager pm = context.getPackageManager();
            try {
                pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
                return true;
            } catch (NameNotFoundException e) {
                return false;
            }
        }
    });
    enterpriseHint = (LinearLayout) findViewById(R.id.enterpriseHint);

    EnterYourEmail = (TextView) findViewById(R.id.enterYourEmail);

    signupHint.setOnClickListener(signupHintClickListener);
    loginHint.setOnClickListener(loginHintClickListener);

    signupBtn = (Button) findViewById(R.id.signupBtn);
    signupBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            new LoginTask().execute((Void) null);
        }
    });

    TextView version = (TextView) findViewById(R.id.version);
    try {
        version.setText("Version " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
    } catch (NameNotFoundException e) {
        version.setVisibility(View.GONE);
    }

    Typeface LatoRegular = Typeface.createFromAsset(getAssets(), "Lato-Regular.ttf");
    Typeface LatoLightItalic = Typeface.createFromAsset(getAssets(), "Lato-LightItalic.ttf");

    for (int i = 0; i < signupHint.getChildCount(); i++) {
        View v = signupHint.getChildAt(i);
        if (v instanceof TextView) {
            ((TextView) v).setTypeface(LatoRegular);
        }
    }

    for (int i = 0; i < loginHint.getChildCount(); i++) {
        View v = loginHint.getChildAt(i);
        if (v instanceof TextView) {
            ((TextView) v).setTypeface(LatoRegular);
        }
    }

    LinearLayout IRCCloud = (LinearLayout) findViewById(R.id.IRCCloud);
    for (int i = 0; i < IRCCloud.getChildCount(); i++) {
        View v = IRCCloud.getChildAt(i);
        if (v instanceof TextView) {
            ((TextView) v).setTypeface(LatoRegular);
        }
    }

    notAProblem = (LinearLayout) findViewById(R.id.notAProblem);
    for (int i = 0; i < notAProblem.getChildCount(); i++) {
        View v = notAProblem.getChildAt(i);
        if (v instanceof TextView) {
            ((TextView) v).setTypeface((i == 0) ? LatoRegular : LatoLightItalic);
        }
    }

    loginSignupHint = (LinearLayout) findViewById(R.id.loginSignupHint);
    for (int i = 0; i < loginSignupHint.getChildCount(); i++) {
        View v = loginSignupHint.getChildAt(i);
        if (v instanceof TextView) {
            ((TextView) v).setTypeface(LatoRegular);
            ((TextView) v).setOnClickListener((i == 0) ? loginHintClickListener : signupHintClickListener);
        }
    }

    name.setTypeface(LatoRegular);
    email.setTypeface(LatoRegular);
    password.setTypeface(LatoRegular);
    host.setTypeface(LatoRegular);
    loginBtn.setTypeface(LatoRegular);
    signupBtn.setTypeface(LatoRegular);
    TOS.setTypeface(LatoRegular);
    EnterYourEmail.setTypeface(LatoRegular);
    hostHint.setTypeface(LatoLightItalic);

    if (BuildConfig.ENTERPRISE) {
        name.setVisibility(View.GONE);
        email.setVisibility(View.GONE);
        password.setVisibility(View.GONE);
        loginBtn.setVisibility(View.GONE);
        signupBtn.setVisibility(View.GONE);
        TOS.setVisibility(View.GONE);
        signupHint.setVisibility(View.GONE);
        loginHint.setVisibility(View.GONE);
        forgotPassword.setVisibility(View.GONE);
        loginSignupHint.setVisibility(View.GONE);
        EnterYourEmail.setVisibility(View.GONE);
        sendAccessLinkBtn.setVisibility(View.GONE);
        notAProblem.setVisibility(View.GONE);
        enterpriseLearnMore.setVisibility(View.VISIBLE);
        enterpriseHint.setVisibility(View.VISIBLE);
        host.setVisibility(View.VISIBLE);
        nextBtn.setVisibility(View.VISIBLE);
        hostHint.setVisibility(View.VISIBLE);
        host.requestFocus();
    }

    if (savedInstanceState != null && savedInstanceState.containsKey("signup")
            && savedInstanceState.getBoolean("signup")) {
        signupHintClickListener.onClick(null);
    }

    if (savedInstanceState != null && savedInstanceState.containsKey("login")
            && savedInstanceState.getBoolean("login")) {
        loginHintClickListener.onClick(null);
    }

    if (savedInstanceState != null && savedInstanceState.containsKey("forgotPassword")
            && savedInstanceState.getBoolean("forgotPassword")) {
        forgotPasswordClickListener.onClick(null);
    }

    mResolvingError = savedInstanceState != null && savedInstanceState.getBoolean("resolving_error", false);

    mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Auth.CREDENTIALS_API)
            .addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();
}

From source file:ua.mkh.settings.full.MainActivity.java

@SuppressLint("NewApi")
@Override/*from  w  w w  . jav a2 s  .c  o  m*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //try {
    String roman = "fonts/Regular.otf";
    String medium = "fonts/Medium.otf";
    String bold = "fonts/Bold.otf";
    String thin = "fonts/Thin.otf";
    typefaceRoman = Typeface.createFromAsset(getAssets(), roman);
    typefaceMedium = Typeface.createFromAsset(getAssets(), medium);
    typefaceBold = Typeface.createFromAsset(getAssets(), bold);
    typefaceThin = Typeface.createFromAsset(getAssets(), thin);

    mSettings = getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);

    ll1 = (LinearLayout) findViewById(R.id.ll1);
    ll1.requestFocus();
    searchView = (SearchView) findViewById(R.id.search);
    searchView.setIconifiedByDefault(false);
    searchView.setOnQueryTextListener(this);
    searchView.setOnCloseListener(this);

    mListView = (ListView) findViewById(R.id.list);

    b1 = (Button) findViewById(R.id.button1);
    b2 = (Button) findViewById(R.id.button2);
    b11 = (Button) findViewById(R.id.button11);
    b21 = (Button) findViewById(R.id.button21);
    ed1 = (EditText) findViewById(R.id.EditText01);
    ed11 = (EditText) findViewById(R.id.EditText011);

    b21.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            b11.setVisibility(View.GONE);
            b21.setVisibility(View.GONE);
            ed11.clearFocus();
            ed1.clearFocus();
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(ed1.getWindowToken(), 0);
            ed11.setText("");
            ed1.setText("");
            LinearLayout list_res_top = (LinearLayout) findViewById(R.id.list_res_top);
            list_res_top.setVisibility(View.GONE);
            LinearLayout list_res = (LinearLayout) findViewById(R.id.list_res);
            list_res.setVisibility(View.GONE);
            ll1.setVisibility(View.VISIBLE);
            sear = false;
        }
    });

    ed1.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                b11.setVisibility(View.VISIBLE);
                b21.setVisibility(View.VISIBLE);
                LinearLayout list_res_top = (LinearLayout) findViewById(R.id.list_res_top);
                list_res_top.setVisibility(View.VISIBLE);
                LinearLayout list_res = (LinearLayout) findViewById(R.id.list_res);
                list_res.setVisibility(View.VISIBLE);
                sear = true;

                //ll1.setVisibility(View.INVISIBLE);

                ed11.requestFocus();
                ed1.clearFocus();
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(ed11, InputMethodManager.SHOW_IMPLICIT);
                //LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                //lp.setMargins(0, 0, 0, 0);
                //ll1.setLayoutParams(lp);

            } else {
                ll1.setVisibility(View.GONE);
                b11.setVisibility(View.VISIBLE);
                LinearLayout list_res = (LinearLayout) findViewById(R.id.list_res);
                list_res.setVisibility(View.VISIBLE);
                //LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                //lp.setMargins(0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 39, getResources().getDisplayMetrics()), 0, 0);
                //ll1.setLayoutParams(lp);
            }
        }
    });

    ed11.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
            // When user changed the Text
            searchView.setQuery(cs, false);
            mListView.setVisibility(View.VISIBLE);

        }

        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {

        }

        @Override
        public void afterTextChanged(Editable arg0) {

        }
    });

    mDbHelper = new CustomersDbAdapter(this);
    mDbHelper.open();

    /*
            
    //Clean all Customers
    mDbHelper.deleteAllCustomers();
            
    */
    //////////////////////

    LinearLayoutWiFi = (LinearLayout) findViewById(R.id.LinearLayoutWiFi);
    LinearLayoutBluetooth = (LinearLayout) findViewById(R.id.LinearLayoutBluetooth);
    LinearLayoutSotSvyaz = (LinearLayout) findViewById(R.id.LinearLayoutSotSvyaz);
    LinearLayoutOperator = (LinearLayout) findViewById(R.id.LinearLayoutOperator);
    LinearLayoutGeo = (LinearLayout) findViewById(R.id.LinearLayoutGeo);
    LinearLayoutNotif = (LinearLayout) findViewById(R.id.LinearLayoutNotif);
    LinearLayoutControl = (LinearLayout) findViewById(R.id.LinearLayoutControl);
    LinearLayoutMail = (LinearLayout) findViewById(R.id.LinearLayoutMail);
    LinearLayoutNotes = (LinearLayout) findViewById(R.id.LinearLayoutNotes);
    LinearLayoutMessages = (LinearLayout) findViewById(R.id.LinearLayoutMessages);
    LinearLayoutPhone = (LinearLayout) findViewById(R.id.LinearLayoutPhone);
    LinearLayoutSafari = (LinearLayout) findViewById(R.id.LinearLayoutSafari);
    LinearLayoutMusic = (LinearLayout) findViewById(R.id.LinearLayoutMusic);
    LinearLayoutCompass = (LinearLayout) findViewById(R.id.LinearLayoutCompass);
    LinearLayoutWeather = (LinearLayout) findViewById(R.id.LinearLayoutWeather);
    LinearLayoutGameCenter = (LinearLayout) findViewById(R.id.LinearLayoutGameCenter);
    LinearLayoutPasscode = (LinearLayout) findViewById(R.id.LinearLayoutPasscode);
    LinearLayoutPrivacy = (LinearLayout) findViewById(R.id.LinearLayoutPrivacy);
    LinearLayoutApn = (LinearLayout) findViewById(R.id.LinearLayoutApn);
    LinearLayoutCloud = (LinearLayout) findViewById(R.id.LinearLayoutCloud);
    LinearLayoutTunes = (LinearLayout) findViewById(R.id.LinearLayoutTunes);
    LinearLayoutMaps = (LinearLayout) findViewById(R.id.LinearLayoutMaps);
    LinearLayoutVk = (LinearLayout) findViewById(R.id.LinearLayoutVk);
    LinearLayoutViber = (LinearLayout) findViewById(R.id.LinearLayoutViber);
    LinearLayoutOk = (LinearLayout) findViewById(R.id.LinearLayoutOK);
    LinearLayoutSkype = (LinearLayout) findViewById(R.id.LinearLayoutSkype);
    LinearLayoutWhatsapp = (LinearLayout) findViewById(R.id.LinearLayoutWhatsApp);
    LinearLayoutTwitter = (LinearLayout) findViewById(R.id.LinearLayoutTwitter);
    LinearLayoutFacebook = (LinearLayout) findViewById(R.id.LinearLayoutFacebook);
    LinearLayoutInstagram = (LinearLayout) findViewById(R.id.LinearLayoutInstagram);

    LinearLayoutNew1 = (LinearLayout) findViewById(R.id.LinearLayoutApp1);
    LinearLayoutNew2 = (LinearLayout) findViewById(R.id.LinearLayoutApp2);
    LinearLayoutNew3 = (LinearLayout) findViewById(R.id.LinearLayoutApp3);
    LinearLayoutNew4 = (LinearLayout) findViewById(R.id.LinearLayoutApp4);

    LinearLayoutNew1.setVisibility(View.GONE);
    LinearLayoutNew2.setVisibility(View.GONE);
    LinearLayoutNew3.setVisibility(View.GONE);
    LinearLayoutNew4.setVisibility(View.GONE);

    LinearLayoutGeo.setVisibility(View.GONE);
    LinearLayoutMail.setVisibility(View.GONE);
    LinearLayoutNotes.setVisibility(View.GONE);
    LinearLayoutMessages.setVisibility(View.GONE);
    LinearLayoutPhone.setVisibility(View.GONE);
    LinearLayoutSafari.setVisibility(View.GONE);
    LinearLayoutMusic.setVisibility(View.GONE);
    LinearLayoutCompass.setVisibility(View.GONE);
    LinearLayoutWeather.setVisibility(View.GONE);
    LinearLayoutGameCenter.setVisibility(View.GONE);
    LinearLayoutNotif.setVisibility(View.GONE);
    LinearLayoutControl.setVisibility(View.GONE);
    LinearLayoutTunes.setVisibility(View.GONE);
    LinearLayoutMaps.setVisibility(View.GONE);
    LinearLayoutVk.setVisibility(View.GONE);
    LinearLayoutViber.setVisibility(View.GONE);
    LinearLayoutOk.setVisibility(View.GONE);
    LinearLayoutSkype.setVisibility(View.GONE);
    LinearLayoutWhatsapp.setVisibility(View.GONE);
    LinearLayoutTwitter.setVisibility(View.GONE);
    LinearLayoutFacebook.setVisibility(View.GONE);
    LinearLayoutInstagram.setVisibility(View.GONE);

    textwifi = (TextView) findViewById(R.id.textwifi);
    textbt = (TextView) findViewById(R.id.textbt);
    TextOper = (TextView) findViewById(R.id.TextOper);
    textVPN = (TextView) findViewById(R.id.TextView01);

    wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);

    btn_avia = (Button) findViewById(R.id.Button01);
    tb_am = (ToggleButton) findViewById(R.id.ToggleButton01);
    tb_am.setOnClickListener(this);

    btn_wifi = (Button) findViewById(R.id.ButtonWifi);
    btn_wifi.setOnClickListener(this);

    btn_bluetooth = (Button) findViewById(R.id.ButtonBluetooth);
    btn_bluetooth.setOnClickListener(this);

    btn_sota = (Button) findViewById(R.id.ButtonSota);
    btn_sota.setOnClickListener(this);

    startService(new Intent(this, NotificationService.class));

    btn_operator = (Button) findViewById(R.id.ButtonOperator);
    btn_operator.setOnClickListener(this);

    btn_osnova = (Button) findViewById(R.id.ButtonOsnova);
    btn_osnova.setOnClickListener(this);

    btn_zvuki = (Button) findViewById(R.id.ButtonZvuki);
    btn_zvuki.setOnClickListener(this);

    btn_oboi = (Button) findViewById(R.id.ButtonOboi);
    btn_oboi.setOnClickListener(this);

    btn_gps = (Button) findViewById(R.id.ButtonGeo);
    btn_gps.setOnClickListener(this);

    btn_passcode = (Button) findViewById(R.id.ButtonPasscode);
    btn_passcode.setOnClickListener(this);

    btn_battery = (Button) findViewById(R.id.ButtonBattery);
    btn_battery.setOnClickListener(this);

    btn_privacy = (Button) findViewById(R.id.ButtonPrivacy);
    btn_privacy.setOnClickListener(this);

    btn_notification = (Button) findViewById(R.id.ButtonNotification);
    btn_notification.setOnClickListener(this);

    btn_control = (Button) findViewById(R.id.ButtonControl);
    btn_control.setOnClickListener(this);

    btn_disturb = (Button) findViewById(R.id.ButtonDisturb);
    btn_disturb.setOnClickListener(this);

    btn_mail = (Button) findViewById(R.id.ButtonMail);
    btn_mail.setOnClickListener(this);

    btn_notes = (Button) findViewById(R.id.ButtonNotes);
    btn_notes.setOnClickListener(this);

    btn_messages = (Button) findViewById(R.id.ButtonMessages);
    btn_messages.setOnClickListener(this);

    btn_phone = (Button) findViewById(R.id.ButtonPhone);
    btn_phone.setOnClickListener(this);

    btn_safari = (Button) findViewById(R.id.ButtonSafari);
    btn_safari.setOnClickListener(this);

    btn_music = (Button) findViewById(R.id.ButtonMusic);
    btn_music.setOnClickListener(this);

    btn_compass = (Button) findViewById(R.id.ButtonCompass);
    btn_compass.setOnClickListener(this);

    btn_weather = (Button) findViewById(R.id.ButtonWeather);
    btn_weather.setOnClickListener(this);

    btn_games = (Button) findViewById(R.id.ButtonGameCenter);
    btn_games.setOnClickListener(this);

    btn_maps = (Button) findViewById(R.id.ButtonMaps);
    btn_maps.setOnClickListener(this);

    btn_vk = (Button) findViewById(R.id.ButtonVk);
    btn_vk.setOnClickListener(this);

    btn_viber = (Button) findViewById(R.id.ButtonViber);
    btn_viber.setOnClickListener(this);

    btn_ok = (Button) findViewById(R.id.ButtonOk);
    btn_ok.setOnClickListener(this);

    btn_skype = (Button) findViewById(R.id.ButtonSkype);
    btn_skype.setOnClickListener(this);

    btn_whatsapp = (Button) findViewById(R.id.ButtonWhatsapp);
    btn_whatsapp.setOnClickListener(this);

    btn_twitter = (Button) findViewById(R.id.ButtonTwitter);
    btn_twitter.setOnClickListener(this);

    btn_facebook = (Button) findViewById(R.id.ButtonFacebook);
    btn_facebook.setOnClickListener(this);

    btn_instagram = (Button) findViewById(R.id.ButtonInstagram);
    btn_instagram.setOnClickListener(this);

    btn_new1 = (Button) findViewById(R.id.Button02);
    btn_new1.setOnClickListener(this);

    btn_new2 = (Button) findViewById(R.id.Button03);
    btn_new2.setOnClickListener(this);

    btn_new3 = (Button) findViewById(R.id.Button04);
    btn_new3.setOnClickListener(this);

    btn_new4 = (Button) findViewById(R.id.Button05);
    btn_new4.setOnClickListener(this);

    btn_vpn = (Button) findViewById(R.id.Button06);
    btn_vpn.setOnClickListener(this);

    btn_display = (Button) findViewById(R.id.ButtonDisplay);
    btn_display.setOnClickListener(this);

    btn_iCloud = (Button) findViewById(R.id.ButtonCloud);
    btn_iCloud.setOnClickListener(this);

    btn_iTunes = (Button) findViewById(R.id.ButtonTunes);
    btn_iTunes.setOnClickListener(this);

    buttonBack = (Button) findViewById(R.id.buttonBack);
    btn_menu_settings = (Button) findViewById(R.id.ButtonMenuSettings);
    btn_menu_cancel = (Button) findViewById(R.id.ButtonMenuCancel);

    textView1 = (TextView) findViewById(R.id.textView1);
    textView2 = (TextView) findViewById(R.id.textView2);
    textView3 = (TextView) findViewById(R.id.textView3);

    text_app_main = (TextView) findViewById(R.id.text_app_main);

    text_app_main.setText(R.string.text_app_name);

    ImageView imageView2 = (ImageView) findViewById(R.id.imageView2);
    imageView2.setVisibility(View.GONE);

    text_app_main.setTypeface(typefaceBold);
    btn_avia.setTypeface(typefaceRoman);
    //textView1.setTypeface(typefaceRoman);
    textView3.setTypeface(typefaceRoman);
    btn_wifi.setTypeface(typefaceRoman);
    btn_bluetooth.setTypeface(typefaceRoman);
    btn_sota.setTypeface(typefaceRoman);
    btn_operator.setTypeface(typefaceRoman);
    btn_osnova.setTypeface(typefaceRoman);
    btn_passcode.setTypeface(typefaceRoman);
    btn_battery.setTypeface(typefaceRoman);
    btn_privacy.setTypeface(typefaceRoman);
    btn_zvuki.setTypeface(typefaceRoman);
    btn_oboi.setTypeface(typefaceRoman);
    btn_notification.setTypeface(typefaceRoman);
    btn_control.setTypeface(typefaceRoman);
    btn_disturb.setTypeface(typefaceRoman);
    btn_gps.setTypeface(typefaceRoman);
    btn_mail.setTypeface(typefaceRoman);
    btn_notes.setTypeface(typefaceRoman);
    btn_messages.setTypeface(typefaceRoman);
    btn_phone.setTypeface(typefaceRoman);
    btn_safari.setTypeface(typefaceRoman);
    btn_music.setTypeface(typefaceRoman);
    btn_compass.setTypeface(typefaceRoman);
    btn_weather.setTypeface(typefaceRoman);
    btn_games.setTypeface(typefaceRoman);
    btn_new1.setTypeface(typefaceRoman);
    btn_new2.setTypeface(typefaceRoman);
    btn_new3.setTypeface(typefaceRoman);
    btn_new4.setTypeface(typefaceRoman);
    btn_vpn.setTypeface(typefaceRoman);
    btn_display.setTypeface(typefaceRoman);
    btn_maps.setTypeface(typefaceRoman);
    btn_vk.setTypeface(typefaceRoman);
    btn_viber.setTypeface(typefaceRoman);
    btn_ok.setTypeface(typefaceRoman);
    btn_skype.setTypeface(typefaceRoman);
    btn_whatsapp.setTypeface(typefaceRoman);
    btn_twitter.setTypeface(typefaceRoman);
    btn_facebook.setTypeface(typefaceRoman);
    btn_instagram.setTypeface(typefaceRoman);

    btn_iCloud.setTypeface(typefaceRoman);
    btn_iTunes.setTypeface(typefaceRoman);

    textwifi.setTypeface(typefaceRoman);
    textbt.setTypeface(typefaceRoman);
    TextOper.setTypeface(typefaceRoman);
    textVPN.setTypeface(typefaceRoman);

    //LinearLayoutPrivacy.setVisibility(View.GONE);
    //LinearLayoutApn.setVisibility(View.GONE);
    //LinearLayoutPasscode.setVisibility(View.GONE);
    //layoutTunes.setVisibility(View.GONE);

    //////////////////START///////////////////   

    ///////////////////APP//////////////
    pm = this.getPackageManager();
    //Notification 
    notif_inoty = pm.getLaunchIntentForPackage("net.suckga.inoty");
    notif_espier = pm.getLaunchIntentForPackage("mobi.espier.launcher.plugin.notifications7pro");
    //Control Center
    control_hi = pm.getLaunchIntentForPackage("com.hi.apps.studio.control.center");
    control_espier = pm.getLaunchIntentForPackage("mobi.espier.launcher.plugin.controller7pro");
    //Mail
    mail_stok = pm.getLaunchIntentForPackage("com.android.email");
    //Phone
    phone_stok = pm.getLaunchIntentForPackage("com.android.dialer");
    //Messages
    messages_stok = pm.getLaunchIntentForPackage("com.android.mms");
    //Safari
    safari_stok = pm.getLaunchIntentForPackage("com.android.browser");
    //Music;
    music_stok = pm.getLaunchIntentForPackage("com.android.music");
    //VK
    vk_stok = pm.getLaunchIntentForPackage("com.vkontakte.android");
    //Viber
    viber_stok = pm.getLaunchIntentForPackage("com.viber.voip");
    //Ok
    ok_stok = pm.getLaunchIntentForPackage("ru.ok.android");
    //Skype
    skype_stok = pm.getLaunchIntentForPackage("com.skype.raider");
    //WhatsApp!!!!
    whatsapp_stok = pm.getLaunchIntentForPackage("com.whatsapp");
    //Twitter
    twitter_stok = pm.getLaunchIntentForPackage("com.twitter.android");
    //Facebook
    facebook_stok = pm.getLaunchIntentForPackage("com.facebook.katana");
    //Instagram
    instagram_stok = pm.getLaunchIntentForPackage("com.instagram.android");
    //Maps
    maps_stok = pm.getLaunchIntentForPackage("com.google.android.apps.maps");

    bt = BluetoothAdapter.getDefaultAdapter();
    //Check Availability of bluetooth
    if (bt == null) {
        LinearLayoutBluetooth.setVisibility(View.GONE);
    }
}

From source file:com.silentcircle.accounts.AccountStep1.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View stepView = inflater.inflate(R.layout.provisioning_bp_s1, container, false);
    if (stepView == null)
        return null;

    ProvisioningActivity.FilterEnter filterEnter = new ProvisioningActivity.FilterEnter();

    mUsernameInput = (EditText) stepView.findViewById(R.id.ProvisioningUsernameInput);
    mUsernameInput.addTextChangedListener(filterEnter);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        mUsernameInput.setBackground(mUsernameInput.getBackground().getConstantState().newDrawable());

    mUsernameLayout = (TextInputLayout) stepView.findViewById(R.id.ProvisioningUsernameLayout);
    mUsernameLayout.setErrorEnabled(true);

    mPasswordInput = (EditText) stepView.findViewById(R.id.ProvisioningPasswordInput);
    mPasswordInput.setTag("current_password");

    mPasswordLayout = (TextInputLayout) stepView.findViewById(R.id.ProvisioningPasswordLayout);
    mPasswordLayout.setErrorEnabled(true);

    mUsernameInput.addTextChangedListener(new TextWatcher() {
        @Override/*from  w w  w .j  av a 2  s  .c om*/
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            boolean newState = s.toString().contains("@");
            if (newState != loginSso) {
                loginSso = newState;
                updateVisibility();
            }
            mUserValid = checkValid(mUsernameInput, mUsernameLayout, null, false);
            updateLoginButton();
        }
    });

    mUsernameInput.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                // scroll up to try to make sure password field also visible
                scrollViewToTop(mUsernameLayout);
            } else {
                checkValid(mUsernameInput, mUsernameLayout, getString(R.string.provisioning_user_req), false);
            }
        }
    });

    mUsernameInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            return actionId == EditorInfo.IME_ACTION_NEXT && !checkValid(mUsernameInput, mUsernameLayout,
                    getString(R.string.provisioning_user_req), true);
        }
    });

    mPasswordInput.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            mPassValid = checkValid(mPasswordInput, mPasswordLayout, null, false);
            updateLoginButton();
        }
    });

    mPasswordInput.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            // make sure password field visible
            if (!hasFocus) {
                checkValid(mPasswordInput, mPasswordLayout, getString(R.string.provisioning_password_req),
                        false);
            }
        }
    });

    mPasswordInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            return actionId == EditorInfo.IME_ACTION_DONE && !checkValid(mPasswordInput, mPasswordLayout,
                    getString(R.string.provisioning_password_req), true);
        }
    });

    mRegisterNew = (Button) stepView.findViewById(R.id.registerNew);
    mRegisterNew.setOnClickListener(this);

    mLoginExisting = (Button) stepView.findViewById(R.id.loginExisting);
    mLoginExisting.setOnClickListener(this);
    mLoginSavedText = mLoginExisting.getText();

    // FIXME: Remove when account creation is enabled
    // only allow create account when a license code is present
    // the following three lines should be removed when freemium support is to be included in the product
    Bundle args = getArguments();
    if (args == null || TextUtils.isEmpty(args.getString(AuthenticatorActivity.ARG_RONIN_CODE, null)))
        mRegisterNew.setVisibility(View.GONE);

    mShowPassword = (CheckBox) stepView.findViewById(R.id.ShowPassword);
    mShowPassword.setOnClickListener(this);

    mUserFields = (RelativeLayout) stepView.findViewById(R.id.ProvisioningUserFields);

    ((TextView) stepView.findViewById(R.id.ProvisioningVersion)).setText("version " + BuildConfig.VERSION_NAME);

    TextView privacy = (TextView) stepView.findViewById(R.id.ProvisioningPrivacy);
    privacy.setText(Html.fromHtml("<a href=\"https://accounts.silentcircle.com/privacy-policy\">"
            + getResources().getString(R.string.provisioning_privacy) + "</a>"));
    privacy.setMovementMethod(LinkMovementMethod.getInstance());
    stripUnderlines(privacy);

    TextView terms = (TextView) stepView.findViewById(R.id.ProvisioningTerms);
    terms.setText(Html.fromHtml("<a href=\"https://accounts.silentcircle.com/terms\">"
            + getResources().getString(R.string.provisioning_terms) + "</a>"));
    terms.setMovementMethod(LinkMovementMethod.getInstance());
    stripUnderlines(terms);

    mForgotPassword = (TextView) stepView.findViewById(R.id.ProvisioningForgotPassword);
    mForgotPassword.setText(Html.fromHtml("<a href=\"https://accounts.silentcircle.com/account/recover/\">"
            + getResources().getString(R.string.provisioning_forgot_pwd) + "</a>"));
    mForgotPassword.setMovementMethod(LinkMovementMethod.getInstance());
    stripUnderlines(mForgotPassword);

    mScrollView = (ScrollView) stepView.findViewById(R.id.ProvisioningScrollFrameLayout);

    Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "fonts/TiemposHeadline-Regular.otf");
    TextView tv = (TextView) stepView.findViewById(R.id.AppText);
    tv.setTypeface(tf);

    stepView.setBackgroundColor(getResources().getColor(R.color.auth_background_grey));

    if (ConfigurationUtilities.mEnableDevDebOptions) {
        mEnvironmentButton = (Button) stepView.findViewById(R.id.switchConfiguration);
        mEnvironmentButton.setVisibility(View.VISIBLE);
        mEnvironmentButton
                .setText(ConfigurationUtilities.mUseDevelopConfiguration ? R.string.switch_to_production
                        : R.string.switch_to_develop);
        mEnvironmentButton.setOnClickListener(this);
    }
    return stepView;
}