Example usage for android.graphics Color parseColor

List of usage examples for android.graphics Color parseColor

Introduction

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

Prototype

@ColorInt
public static int parseColor(@Size(min = 1) String colorString) 

Source Link

Document

Parse the color string, and return the corresponding color-int.

Usage

From source file:it.feio.android.omninotes.async.DataBackupIntentService.java

/**
  * Imports notes and notebooks from Springpad exported archive
  *//from  w  w  w . j  a  va 2s . c o m
  * @param intent
  */
synchronized private void importDataFromSpringpad(Intent intent) {
    String backupPath = intent.getStringExtra(EXTRA_SPRINGPAD_BACKUP);
    Importer importer = new Importer();
    try {
        importer.setZipProgressesListener(percentage -> mNotificationsHelper
                .setMessage(getString(R.string.extracted) + " " + percentage + "%").show());
        importer.doImport(backupPath);
        // Updating notification
        updateImportNotification(importer);
    } catch (ImportException e) {
        new NotificationsHelper(this).createNotification(R.drawable.ic_emoticon_sad_white_24dp,
                getString(R.string.import_fail) + ": " + e.getMessage(), null).setLedActive().show();
        return;
    }
    List<SpringpadElement> elements = importer.getSpringpadNotes();

    // If nothing is retrieved it will exit
    if (elements == null || elements.size() == 0) {
        return;
    }

    // These maps are used to associate with post processing notes to categories (notebooks)
    HashMap<String, Category> categoriesWithUuid = new HashMap<>();

    // Adds all the notebooks (categories)
    for (SpringpadElement springpadElement : importer.getNotebooks()) {
        Category cat = new Category();
        cat.setName(springpadElement.getName());
        cat.setColor(String.valueOf(Color.parseColor("#F9EA1B")));
        DbHelper.getInstance().updateCategory(cat);
        categoriesWithUuid.put(springpadElement.getUuid(), cat);

        // Updating notification
        importedSpringpadNotebooks++;
        updateImportNotification(importer);
    }
    // And creates a default one for notes without notebook 
    Category defaulCategory = new Category();
    defaulCategory.setName("Springpad");
    defaulCategory.setColor(String.valueOf(Color.parseColor("#F9EA1B")));
    DbHelper.getInstance().updateCategory(defaulCategory);

    // And then notes are created
    Note note;
    Attachment mAttachment = null;
    Uri uri;
    for (SpringpadElement springpadElement : importer.getNotes()) {
        note = new Note();

        // Title
        note.setTitle(springpadElement.getName());

        // Content dependent from type of Springpad note
        StringBuilder content = new StringBuilder();
        content.append(
                TextUtils.isEmpty(springpadElement.getText()) ? "" : Html.fromHtml(springpadElement.getText()));
        content.append(
                TextUtils.isEmpty(springpadElement.getDescription()) ? "" : springpadElement.getDescription());

        // Some notes could have been exported wrongly
        if (springpadElement.getType() == null) {
            Toast.makeText(this, getString(R.string.error), Toast.LENGTH_SHORT).show();
            continue;
        }

        if (springpadElement.getType().equals(SpringpadElement.TYPE_VIDEO)) {
            try {
                content.append(System.getProperty("line.separator"))
                        .append(springpadElement.getVideos().get(0));
            } catch (IndexOutOfBoundsException e) {
                content.append(System.getProperty("line.separator")).append(springpadElement.getUrl());
            }
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_TVSHOW)) {
            content.append(System.getProperty("line.separator"))
                    .append(TextUtils.join(", ", springpadElement.getCast()));
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_BOOK)) {
            content.append(System.getProperty("line.separator")).append("Author: ")
                    .append(springpadElement.getAuthor()).append(System.getProperty("line.separator"))
                    .append("Publication date: ").append(springpadElement.getPublicationDate());
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_RECIPE)) {
            content.append(System.getProperty("line.separator")).append("Ingredients: ")
                    .append(springpadElement.getIngredients()).append(System.getProperty("line.separator"))
                    .append("Directions: ").append(springpadElement.getDirections());
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_BOOKMARK)) {
            content.append(System.getProperty("line.separator")).append(springpadElement.getUrl());
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_BUSINESS)
                && springpadElement.getPhoneNumbers() != null) {
            content.append(System.getProperty("line.separator")).append("Phone number: ")
                    .append(springpadElement.getPhoneNumbers().getPhone());
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_PRODUCT)) {
            content.append(System.getProperty("line.separator")).append("Category: ")
                    .append(springpadElement.getCategory()).append(System.getProperty("line.separator"))
                    .append("Manufacturer: ").append(springpadElement.getManufacturer())
                    .append(System.getProperty("line.separator")).append("Price: ")
                    .append(springpadElement.getPrice());
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_WINE)) {
            content.append(System.getProperty("line.separator")).append("Wine type: ")
                    .append(springpadElement.getWine_type()).append(System.getProperty("line.separator"))
                    .append("Varietal: ").append(springpadElement.getVarietal())
                    .append(System.getProperty("line.separator")).append("Price: ")
                    .append(springpadElement.getPrice());
        }
        if (springpadElement.getType().equals(SpringpadElement.TYPE_ALBUM)) {
            content.append(System.getProperty("line.separator")).append("Artist: ")
                    .append(springpadElement.getArtist());
        }
        for (SpringpadComment springpadComment : springpadElement.getComments()) {
            content.append(System.getProperty("line.separator")).append(springpadComment.getCommenter())
                    .append(" commented at 0").append(springpadComment.getDate()).append(": ")
                    .append(springpadElement.getArtist());
        }

        note.setContent(content.toString());

        // Checklists
        if (springpadElement.getType().equals(SpringpadElement.TYPE_CHECKLIST)) {
            StringBuilder sb = new StringBuilder();
            String checkmark;
            for (SpringpadItem mSpringpadItem : springpadElement.getItems()) {
                checkmark = mSpringpadItem.getComplete()
                        ? it.feio.android.checklistview.interfaces.Constants.CHECKED_SYM
                        : it.feio.android.checklistview.interfaces.Constants.UNCHECKED_SYM;
                sb.append(checkmark).append(mSpringpadItem.getName())
                        .append(System.getProperty("line.separator"));
            }
            note.setContent(sb.toString());
            note.setChecklist(true);
        }

        // Tags
        String tags = springpadElement.getTags().size() > 0
                ? "#" + TextUtils.join(" #", springpadElement.getTags())
                : "";
        if (note.isChecklist()) {
            note.setTitle(note.getTitle() + tags);
        } else {
            note.setContent(note.getContent() + System.getProperty("line.separator") + tags);
        }

        // Address
        String address = springpadElement.getAddresses() != null ? springpadElement.getAddresses().getAddress()
                : "";
        if (!TextUtils.isEmpty(address)) {
            try {
                double[] coords = GeocodeHelper.getCoordinatesFromAddress(this, address);
                note.setLatitude(coords[0]);
                note.setLongitude(coords[1]);
            } catch (IOException e) {
                Log.e(Constants.TAG,
                        "An error occurred trying to resolve address to coords during Springpad import");
            }
            note.setAddress(address);
        }

        // Reminder
        if (springpadElement.getDate() != null) {
            note.setAlarm(springpadElement.getDate().getTime());
        }

        // Creation, modification, category
        note.setCreation(springpadElement.getCreated().getTime());
        note.setLastModification(springpadElement.getModified().getTime());

        // Image
        String image = springpadElement.getImage();
        if (!TextUtils.isEmpty(image)) {
            try {
                File file = StorageHelper.createNewAttachmentFileFromHttp(this, image);
                uri = Uri.fromFile(file);
                String mimeType = StorageHelper.getMimeType(uri.getPath());
                mAttachment = new Attachment(uri, mimeType);
            } catch (MalformedURLException e) {
                uri = Uri.parse(importer.getWorkingPath() + image);
                mAttachment = StorageHelper.createAttachmentFromUri(this, uri, true);
            } catch (IOException e) {
                Log.e(Constants.TAG, "Error retrieving Springpad online image");
            }
            if (mAttachment != null) {
                note.addAttachment(mAttachment);
            }
            mAttachment = null;
        }

        // Other attachments
        for (SpringpadAttachment springpadAttachment : springpadElement.getAttachments()) {
            // The attachment could be the image itself so it's jumped
            if (image != null && image.equals(springpadAttachment.getUrl()))
                continue;

            if (TextUtils.isEmpty(springpadAttachment.getUrl())) {
                continue;
            }

            // Tries first with online images
            try {
                File file = StorageHelper.createNewAttachmentFileFromHttp(this, springpadAttachment.getUrl());
                uri = Uri.fromFile(file);
                String mimeType = StorageHelper.getMimeType(uri.getPath());
                mAttachment = new Attachment(uri, mimeType);
            } catch (MalformedURLException e) {
                uri = Uri.parse(importer.getWorkingPath() + springpadAttachment.getUrl());
                mAttachment = StorageHelper.createAttachmentFromUri(this, uri, true);
            } catch (IOException e) {
                Log.e(Constants.TAG, "Error retrieving Springpad online image");
            }
            if (mAttachment != null) {
                note.addAttachment(mAttachment);
            }
            mAttachment = null;
        }

        // If the note has a category is added to the map to be post-processed
        if (springpadElement.getNotebooks().size() > 0) {
            note.setCategory(categoriesWithUuid.get(springpadElement.getNotebooks().get(0)));
        } else {
            note.setCategory(defaulCategory);
        }

        // The note is saved
        DbHelper.getInstance().updateNote(note, false);
        ReminderHelper.addReminder(OmniNotes.getAppContext(), note);

        // Updating notification
        importedSpringpadNotes++;
        updateImportNotification(importer);
    }

    // Delete temp data
    try {
        importer.clean();
    } catch (IOException e) {
        Log.w(Constants.TAG, "Springpad import temp files not deleted");
    }

    String title = getString(R.string.data_import_completed);
    String text = getString(R.string.click_to_refresh_application);
    createNotification(intent, this, title, text, null);
}

From source file:com.amaze.filemanager.fragments.preference_fragments.Preffrag.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceUtils.reset();//from  w  w w.j  a  va  2s.  c om
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);

    sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());

    final int th1 = Integer.parseInt(sharedPref.getString("theme", "0"));
    theme = th1 == 2 ? PreferenceUtils.hourOfDay() : th1;
    findPreference("donate").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            ((com.amaze.filemanager.activities.Preferences) getActivity()).donate();
            return false;
        }
    });
    findPreference("columns").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            final String[] sort = getResources().getStringArray(R.array.columns);
            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.title(R.string.gridcolumnno);
            int current = Integer.parseInt(sharedPref.getString("columns", "-1"));
            current = current == -1 ? 0 : current;
            if (current != 0)
                current = current - 1;
            a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    sharedPref.edit().putString("columns", "" + (which != 0 ? sort[which] : "" + -1)).commit();
                    dialog.dismiss();
                    return true;
                }
            });
            a.build().show();
            return true;
        }
    });

    findPreference("theme").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            String[] sort = getResources().getStringArray(R.array.theme);
            int current = Integer.parseInt(sharedPref.getString("theme", "0"));
            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    sharedPref.edit().putString("theme", "" + which).commit();
                    dialog.dismiss();
                    restartPC(getActivity());
                    return true;
                }
            });
            a.title(R.string.theme);
            a.build().show();
            return true;
        }
    });
    findPreference("colors").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            ((com.amaze.filemanager.activities.Preferences) getActivity()).selectItem(1);
            return true;
        }
    });

    final CheckBx rootmode = (CheckBx) findPreference("rootmode");
    rootmode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            boolean b = sharedPref.getBoolean("rootmode", false);
            if (b) {
                if (RootTools.isAccessGiven()) {
                    rootmode.setChecked(true);

                } else {
                    rootmode.setChecked(false);

                    Toast.makeText(getActivity(), getResources().getString(R.string.rootfailure),
                            Toast.LENGTH_LONG).show();
                }
            } else {
                rootmode.setChecked(false);

            }

            return false;
        }
    });

    // Authors
    Preference preference4 = (Preference) findPreference("authors");
    preference4.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            skin = PreferenceUtils.getPrimaryColorString(sharedPref);
            int fab_skin = Color.parseColor(PreferenceUtils.getAccentString(sharedPref));
            if (theme == 1)
                a.theme(Theme.DARK);

            a.positiveText(R.string.close);
            a.positiveColor(fab_skin);
            LayoutInflater layoutInflater = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = layoutInflater.inflate(R.layout.authors, null);
            a.customView(view, true);
            a.title(R.string.authors);
            a.callback(new MaterialDialog.ButtonCallback() {
                @Override
                public void onPositive(MaterialDialog materialDialog) {

                    materialDialog.cancel();
                }

                @Override
                public void onNegative(MaterialDialog materialDialog) {

                }
            });
            /*a.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
            }
            });*/
            a.build().show();

            final Intent intent = new Intent(Intent.ACTION_VIEW);

            TextView googlePlus1 = (TextView) view.findViewById(R.id.googlePlus1);
            googlePlus1.setTextColor(Color.parseColor(skin));
            TextView googlePlus2 = (TextView) view.findViewById(R.id.googlePlus2);
            googlePlus2.setTextColor(Color.parseColor(skin));
            TextView git1 = (TextView) view.findViewById(R.id.git1);
            git1.setTextColor(Color.parseColor(skin));
            TextView git2 = (TextView) view.findViewById(R.id.git2);
            git2.setTextColor(Color.parseColor(skin));

            googlePlus1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://plus.google.com/u/0/110424067388738907251/"));
                    startActivity(intent);
                }
            });
            googlePlus2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://plus.google.com/+VishalNehra/"));
                    startActivity(intent);
                }
            });
            git1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://github.com/arpitkh96"));
                    startActivity(intent);
                }
            });
            git2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://github.com/vishal0071"));
                    startActivity(intent);
                }
            });

            // icon credits
            TextView textView = (TextView) view.findViewById(R.id.icon_credits);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
            textView.setLinksClickable(true);
            textView.setText(Html.fromHtml(getActivity().getString(R.string.icon_credits)));

            return false;
        }
    });

    // Changelog
    Preference preference1 = (Preference) findPreference("changelog");
    preference1.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.title(R.string.changelog);
            a.content(Html.fromHtml(getActivity().getString(R.string.changelog_version_9)
                    + getActivity().getString(R.string.changelog_change_9)
                    + getActivity().getString(R.string.changelog_version_8)
                    + getActivity().getString(R.string.changelog_change_8)
                    + getActivity().getString(R.string.changelog_version_7)
                    + getActivity().getString(R.string.changelog_change_7)
                    + getActivity().getString(R.string.changelog_version_6)
                    + getActivity().getString(R.string.changelog_change_6)
                    + getActivity().getString(R.string.changelog_version_5)
                    + getActivity().getString(R.string.changelog_change_5)
                    + getActivity().getString(R.string.changelog_version_4)
                    + getActivity().getString(R.string.changelog_change_4)
                    + getActivity().getString(R.string.changelog_version_3)
                    + getActivity().getString(R.string.changelog_change_3)
                    + getActivity().getString(R.string.changelog_version_2)
                    + getActivity().getString(R.string.changelog_change_2)
                    + getActivity().getString(R.string.changelog_version_1)
                    + getActivity().getString(R.string.changelog_change_1)));
            a.negativeText(R.string.close);
            a.positiveText(R.string.fullChangelog);
            int fab_skin = Color.parseColor(PreferenceUtils.getAccentString(sharedPref));
            a.positiveColor(fab_skin);
            a.negativeColor(fab_skin);
            a.callback(new MaterialDialog.ButtonCallback() {
                @Override
                public void onPositive(MaterialDialog materialDialog) {

                    Intent intent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("https://github.com/arpitkh96/AmazeFileManager/commits/master"));
                    startActivity(intent);
                }

                @Override
                public void onNegative(MaterialDialog materialDialog) {

                    materialDialog.cancel();
                }
            }).build().show();
            return false;
        }
    });

    // Open Source Licenses
    Preference preference2 = (Preference) findPreference("os");
    //Defining dialog layout
    final Dialog dialog = new Dialog(getActivity(),
            android.R.style.Theme_Holo_Light_DialogWhenLarge_NoActionBar);
    //dialog.setTitle("Open-Source Licenses");
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    final View dialog_view = inflater.inflate(R.layout.open_source_licenses, null);
    dialog.setContentView(dialog_view);

    preference2.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference arg0) {

            WebView wv = (WebView) dialog_view.findViewById(R.id.webView1);
            PreferenceUtils preferenceUtils = new PreferenceUtils();
            wv.loadData(PreferenceUtils.LICENCE_TERMS, "text/html", null);
            dialog.show();
            return false;
        }
    });

    // Feedback
    Preference preference3 = (Preference) findPreference("feedback");
    preference3.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("mailto", "arpitkh96@gmail.com", null));
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback : Amaze File Manager");
            Toast.makeText(getActivity(), getActivity().getFilesDir().getPath(), Toast.LENGTH_SHORT).show();
            File f = new File(getActivity().getExternalFilesDir("internal"), "log.txt");
            if (f.exists()) {
                emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
            }
            startActivity(Intent.createChooser(emailIntent, getResources().getString(R.string.feedback)));
            return false;
        }
    });

    // rate
    Preference preference5 = (Preference) findPreference("rate");
    preference5.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent1 = new Intent(Intent.ACTION_VIEW);
            intent1.setData(Uri.parse("market://details?id=com.amaze.filemanager"));
            startActivity(intent1);
            return false;
        }
    });

    // studio
    Preference studio = findPreference("studio");
    studio.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            COUNT++;
            if (COUNT >= 5) {
                if (toast != null)
                    toast.cancel();
                toast = Toast.makeText(getActivity(), "Studio Mode : " + COUNT, Toast.LENGTH_SHORT);
                toast.show();

                sharedPref.edit().putInt("studio", Integer.parseInt(Integer.toString(COUNT) + "000")).apply();
            } else {
                sharedPref.edit().putInt("studio", 0).apply();
            }
            return false;
        }
    });

    // G+
    gplus = (CheckBx) findPreference("plus_pic");
    gplus.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (gplus.isChecked()) {
                boolean b = checkGplusPermission();
                if (!b)
                    requestGplusPermission();
            }
            return false;
        }
    });
    if (BuildConfig.IS_VERSION_FDROID)
        gplus.setEnabled(false);

    // Colored navigation bar
}

From source file:com.flowzr.budget.holo.activity.FlowzrSyncActivity.java

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

    //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line,
    //only way found to remove on various devices 2.3x, 3.0, ...
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#121212")));

    renderLastTime();//from  www . j  a  v a  2s  .c o m

    CheckBox chkForce = (CheckBox) findViewById(R.id.chk_sync_from_zero);
    chkForce.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            resetLastTime();
            renderLastTime();
        }
    });
    Button syncButton = (Button) findViewById(R.id.sync);
    syncButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startSync();
        }
    });

    Button textViewAbout = (Button) findViewById(R.id.buySubscription);
    textViewAbout.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String accountName = MyPreferences.getFlowzrAccount(getApplicationContext());
            if (accountName == null) {
                Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_choose_account, Toast.LENGTH_SHORT)
                        .show();
                return;

            }
            if (isOnline(FlowzrSyncActivity.this)) {
                //checkPlayServices();
            } else {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
                return;
            }
            //
            Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_sync_auth_inprogress, Toast.LENGTH_SHORT)
                    .show();
            FlowzrBillTask ft = new FlowzrBillTask(FlowzrSyncActivity.this);
            ft.execute();
            //visitFlowzr(accountName);
        }
    });

    Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr);
    textViewAboutAnon.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (isOnline(FlowzrSyncActivity.this)) {
                visitFlowzr(null);
            } else {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
            }
        }
    });

    TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote);
    textViewNotes.setMovementMethod(LinkMovementMethod.getInstance());
    textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use)));

    if (MyPreferences.isAutoSync(this)) {
        if (checkPlayServices()) {
            gcm = GoogleCloudMessaging.getInstance(this);
            regid = getRegistrationId(getApplicationContext());

            if (regid.equals("")) {
                registerInBackground();
            }
            Log.i(TAG, "Google Cloud Messaging registered as :" + regid);
        } else {
            Log.i(TAG, "No valid Google Play Services APK found.");
        }
    }
}

From source file:com.amaze.filemanager.activities.Preferences.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    fabSkin = PreferenceUtils.getAccentString(Sp);

    int th = Integer.parseInt(Sp.getString("theme", "0"));

    theme = th == 2 ? PreferenceUtils.hourOfDay() : th;

    // setting accent theme
    if (Build.VERSION.SDK_INT >= 21) {

        switch (fabSkin) {
        case "#F44336":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_red);
            else//  w  ww. j ava 2s.  c  o  m
                setTheme(R.style.pref_accent_dark_red);
            break;

        case "#e91e63":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_pink);
            else
                setTheme(R.style.pref_accent_dark_pink);
            break;

        case "#9c27b0":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_purple);
            else
                setTheme(R.style.pref_accent_dark_purple);
            break;

        case "#673ab7":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_deep_purple);
            else
                setTheme(R.style.pref_accent_dark_deep_purple);
            break;

        case "#3f51b5":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_indigo);
            else
                setTheme(R.style.pref_accent_dark_indigo);
            break;

        case "#2196F3":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_blue);
            else
                setTheme(R.style.pref_accent_dark_blue);
            break;

        case "#03A9F4":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_light_blue);
            else
                setTheme(R.style.pref_accent_dark_light_blue);
            break;

        case "#00BCD4":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_cyan);
            else
                setTheme(R.style.pref_accent_dark_cyan);
            break;

        case "#009688":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_teal);
            else
                setTheme(R.style.pref_accent_dark_teal);
            break;

        case "#4CAF50":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_green);
            else
                setTheme(R.style.pref_accent_dark_green);
            break;

        case "#8bc34a":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_light_green);
            else
                setTheme(R.style.pref_accent_dark_light_green);
            break;

        case "#FFC107":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_amber);
            else
                setTheme(R.style.pref_accent_dark_amber);
            break;

        case "#FF9800":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_orange);
            else
                setTheme(R.style.pref_accent_dark_orange);
            break;

        case "#FF5722":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_deep_orange);
            else
                setTheme(R.style.pref_accent_dark_deep_orange);
            break;

        case "#795548":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_brown);
            else
                setTheme(R.style.pref_accent_dark_brown);
            break;

        case "#212121":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_black);
            else
                setTheme(R.style.pref_accent_dark_black);
            break;

        case "#607d8b":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_blue_grey);
            else
                setTheme(R.style.pref_accent_dark_blue_grey);
            break;

        case "#004d40":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_super_su);
            else
                setTheme(R.style.pref_accent_dark_super_su);
            break;
        }
    } else {
        if (theme == 1) {
            setTheme(R.style.appCompatDark);
        } else {
            setTheme(R.style.appCompatLight);
        }
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    skin = PreferenceUtils.getPrimaryColorString(Sp);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }
    skinStatusBar = PreferenceUtils.getStatusColor(skin);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP
            | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));
    int sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));

        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        boolean colourednavigation = Sp.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor((PreferenceUtils.getStatusColor(skin)));
        if (colourednavigation)
            window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin)));

    }
    selectItem(0);
}

From source file:adventure_fragments.Biking.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    ((MainActivityTrekkly) activity).onSectionAttached(1);
    MainActivityTrekkly mA = ((MainActivityTrekkly) getActivity());
    mA.restoreActionBar(Color.parseColor("#ffa500"));
}

From source file:com.amaze.filemanager.adapters.ZipAdapter.java

@Override
public void onBindViewHolder(RecyclerView.ViewHolder vholder, final int position1) {
    final ZipAdapter.ViewHolder holder = ((ZipAdapter.ViewHolder) vholder);
    if (!this.stoppedAnimation) {
        animate(holder);/*from w ww .ja va 2s.  com*/
    }
    if (position1 == 0) {
        holder.rl.setMinimumHeight(zipViewer.paddingTop);
        return;
    }
    final ZipObj rowItem = enter.get(position1 - 1);
    final int p = position1 - 1;
    GradientDrawable gradientDrawable = (GradientDrawable) holder.imageView.getBackground();
    if (rowItem.getEntry() == null) {
        holder.imageView.setImageResource(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
        gradientDrawable.setColor(Color.parseColor("#757575"));
        holder.txtTitle.setText("..");
        holder.txtDesc.setText("");
        holder.date.setText(R.string.goback);
    } else {
        holder.imageView.setImageDrawable(
                Icons.loadMimeIcon(zipViewer.getActivity(), rowItem.getName(), false, zipViewer.res));
        final StringBuilder stringBuilder = new StringBuilder(rowItem.getName());
        if (zipViewer.showLastModified)
            holder.date.setText(new Futils().getdate(rowItem.getTime(), "MMM dd, yyyy", zipViewer.year));
        if (rowItem.isDirectory()) {
            holder.imageView.setImageDrawable(folder);
            gradientDrawable.setColor(Color.parseColor(zipViewer.iconskin));
            if (stringBuilder.toString().length() > 0) {
                stringBuilder.deleteCharAt(rowItem.getName().length() - 1);
                try {
                    holder.txtTitle.setText(
                            stringBuilder.toString().substring(stringBuilder.toString().lastIndexOf("/") + 1));
                } catch (Exception e) {
                    holder.txtTitle.setText(rowItem.getName().substring(0, rowItem.getName().lastIndexOf("/")));
                }
            }
        } else {
            if (zipViewer.showSize)
                holder.txtDesc.setText(new Futils().readableFileSize(rowItem.getSize()));
            holder.txtTitle.setText(rowItem.getName().substring(rowItem.getName().lastIndexOf("/") + 1));
            if (zipViewer.coloriseIcons) {
                if (Icons.isVideo(rowItem.getName()) || Icons.isPicture(rowItem.getName()))
                    gradientDrawable.setColor(Color.parseColor("#f06292"));
                else if (Icons.isAudio(rowItem.getName()))
                    gradientDrawable.setColor(Color.parseColor("#9575cd"));
                else if (Icons.isPdf(rowItem.getName()))
                    gradientDrawable.setColor(Color.parseColor("#da4336"));
                else if (Icons.isCode(rowItem.getName()))
                    gradientDrawable.setColor(Color.parseColor("#00bfa5"));
                else if (Icons.isText(rowItem.getName()))
                    gradientDrawable.setColor(Color.parseColor("#e06055"));
                else if (Icons.isArchive(rowItem.getName()))
                    gradientDrawable.setColor(Color.parseColor("#f9a825"));
                else if (Icons.isApk(rowItem.getName()))
                    gradientDrawable.setColor(Color.parseColor("#a4c439"));
                else if (Icons.isgeneric(rowItem.getName()))
                    gradientDrawable.setColor(Color.parseColor("#9e9e9e"));
                else
                    gradientDrawable.setColor(Color.parseColor(zipViewer.iconskin));
            } else
                gradientDrawable.setColor(Color.parseColor(zipViewer.iconskin));
        }
    }

    holder.rl.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            if (rowItem.getEntry() != null) {

                final Animation animation = AnimationUtils.loadAnimation(zipViewer.getActivity(),
                        R.anim.holder_anim);

                holder.imageView.setAnimation(animation);
                toggleChecked(p);
            }
            System.out.println("onLongClick");
            return true;
        }
    });
    holder.imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (rowItem.getEntry() != null) {
                final Animation animation = AnimationUtils.loadAnimation(zipViewer.getActivity(),
                        R.anim.holder_anim);

                holder.imageView.setAnimation(animation);
                toggleChecked(p);
            }

        }
    });
    Boolean checked = myChecked.get(p);
    if (checked != null) {

        if (zipViewer.mainActivity.theme1 == 0) {

            holder.rl.setBackgroundResource(R.drawable.safr_ripple_white);
        } else {

            holder.rl.setBackgroundResource(R.drawable.safr_ripple_black);

        }
        holder.rl.setSelected(false);
        if (checked) {
            holder.imageView.setImageDrawable(
                    zipViewer.getResources().getDrawable(R.drawable.abc_ic_cab_done_holo_dark));
            gradientDrawable.setColor(Color.parseColor("#757575"));
            holder.rl.setSelected(true);
        }
    }
    holder.rl.setOnClickListener(new View.OnClickListener() {

        public void onClick(View p1) {
            if (rowItem.getEntry() == null)
                zipViewer.goBack();
            else {
                if (zipViewer.selection) {
                    final Animation animation = AnimationUtils.loadAnimation(zipViewer.getActivity(),
                            R.anim.holder_anim);
                    holder.imageView.setAnimation(animation);
                    toggleChecked(p);
                } else {
                    final StringBuilder stringBuilder = new StringBuilder(rowItem.getName());
                    if (rowItem.isDirectory())
                        stringBuilder.deleteCharAt(rowItem.getName().length() - 1);

                    if (rowItem.isDirectory()) {

                        new ZipHelperTask(zipViewer, stringBuilder.toString()).execute(zipViewer.f);

                    } else {
                        String x = rowItem.getName().substring(rowItem.getName().lastIndexOf("/") + 1);
                        File file = new File(c.getCacheDir().getAbsolutePath() + "/" + x);
                        zipViewer.files.clear();
                        zipViewer.files.add(0, file);

                        try {
                            ZipFile zipFile = new ZipFile(zipViewer.f);
                            new ZipExtractTask(zipFile, c.getCacheDir().getAbsolutePath(),
                                    zipViewer.getActivity(), x, true, rowItem.getEntry()).execute();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    });

}

From source file:com.amaze.filemanager.fragments.ZipViewer.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    s = getArguments().getString("path");
    Uri uri = Uri.parse(s);/*from   ww  w  . j a v a2s .  c  om*/
    f = new File(uri.getPath());
    mToolbarContainer = getActivity().findViewById(R.id.lin);
    mToolbarContainer.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (stopAnims) {
                if ((!rarAdapter.stoppedAnimation)) {
                    stopAnim();
                }
                rarAdapter.stoppedAnimation = true;

            }
            stopAnims = false;
            return false;
        }
    });
    hidemode = Sp.getInt("hidemode", 0);
    listView.setVisibility(View.VISIBLE);
    mLayoutManager = new LinearLayoutManager(getActivity());
    listView.setLayoutManager(mLayoutManager);
    res = getResources();
    mainActivity.supportInvalidateOptionsMenu();
    if (mainActivity.theme1 == 1)
        rootView.setBackgroundColor(getResources().getColor(R.color.holo_dark_background));
    else
        listView.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    gobackitem = Sp.getBoolean("goBack_checkbox", false);
    coloriseIcons = Sp.getBoolean("coloriseIcons", true);
    Calendar calendar = Calendar.getInstance();
    showSize = Sp.getBoolean("showFileSize", false);
    showLastModified = Sp.getBoolean("showLastModified", true);
    showDividers = Sp.getBoolean("showDividers", true);
    year = ("" + calendar.get(Calendar.YEAR)).substring(2, 4);
    skin = PreferenceUtils.getPrimaryColorString(Sp);
    iconskin = PreferenceUtils.getFolderColorString(Sp);
    mainActivity.findViewById(R.id.buttonbarframe).setBackgroundColor(Color.parseColor(skin));

    files = new ArrayList<>();
    if (savedInstanceState == null && f != null) {
        if (f.getPath().endsWith(".rar")) {
            openmode = 1;
            SetupRar(null);
        } else {
            openmode = 0;
            SetupZip(null);
        }
    } else {
        f = new File(savedInstanceState.getString("file"));
        s = savedInstanceState.getString("uri");
        uri = Uri.parse(s);
        f = new File(uri.getPath());
        if (f.getPath().endsWith(".rar")) {
            openmode = 1;
            SetupRar(savedInstanceState);
        } else {
            openmode = 0;
            SetupZip(savedInstanceState);
        }

    }
    String fileName = null;
    try {
        if (uri.getScheme().equals("file")) {
            fileName = uri.getLastPathSegment();
        } else {
            Cursor cursor = null;
            try {
                cursor = getActivity().getContentResolver().query(uri,
                        new String[] { MediaStore.Images.ImageColumns.DISPLAY_NAME }, null, null, null);

                if (cursor != null && cursor.moveToFirst()) {
                    fileName = cursor
                            .getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.DISPLAY_NAME));
                }
            } finally {

                if (cursor != null) {
                    cursor.close();
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (fileName == null || fileName.trim().length() == 0)
        fileName = f.getName();
    try {
        mainActivity.setActionBarTitle(fileName);
    } catch (Exception e) {
        mainActivity.setActionBarTitle(getResources().getString(R.string.zip_viewer));
    }
    mainActivity.supportInvalidateOptionsMenu();
    mToolbarHeight = getToolbarHeight(getActivity());
    paddingTop = (mToolbarHeight) + dpToPx(72);
    mToolbarContainer.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    paddingTop = mToolbarContainer.getHeight();
                    mToolbarHeight = mainActivity.toolbar.getHeight();

                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
                        mToolbarContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                    } else {
                        mToolbarContainer.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    }
                }

            });

}

From source file:com.zen.androidhtmleditor.AHEActivity.java

@SuppressLint("NewApi")
@Override//w w w.j ava2  s  .  c om
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    setContentView(R.layout.main);
    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    // enable status bar tint
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setTintColor(Color.parseColor("#4acab4"));

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
    Settings.init(settings);
    //Uncomment this for non Market installs. This will allow version checking.
    //new Version(this,getVersionName(this,DeveloperToolsActivity.class),"http://androidhtmleditor.com/version.php").execute();
    deviceId = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
    getOverflowMenu();
    getActionBar().setIcon(R.drawable.icon_white);

    tabactivity = (TabActivity) this;
    tabHost = tabactivity.getTabHost();
    hsv = (HorizontalScrollView) tabactivity.findViewById(R.id.topmenu);

    mLicenseCheckerCallback = new MyLicenseCheckerCallback();
    mChecker = new LicenseChecker(this,
            new ServerManagedPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId)),
            BASE64_PUBLIC_KEY // Your public licensing key.
    );

    mHandler = new Handler();
    // doCheck();

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (LinearLayout) findViewById(R.id.l1);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle("File(s)");
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle("Server");
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    Button button1 = (Button) findViewById(R.id.button1);

    button1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onButtonClickEvent(v);
        }
    });
    Button disconnect_button = (Button) findViewById(R.id.disconnect_button);

    disconnect_button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            disconnect();
        }
    });

    /* Button button2 = (Button)findViewById(R.id.button2);
     button2.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
               
       hsv.setVisibility(View.GONE);
       v.setVisibility(View.GONE);
       RelativeLayout rl = (RelativeLayout)v.getParent();
       Button button1 = (Button)findViewById(R.id.button1);
       button1.setVisibility(View.VISIBLE);
       Button button3 = (Button)findViewById(R.id.button3);
       button3.setVisibility(View.VISIBLE);
               
       ImageView logo = (ImageView)findViewById(R.id.logo);
       logo.setVisibility(View.VISIBLE);
               
       TextView slogan = (TextView)findViewById(R.id.appSlogan);
       slogan.setVisibility(View.VISIBLE);
               
       ScrollView frontLayout = (ScrollView)findViewById(R.id.front);
       frontLayout.setVisibility(View.VISIBLE);
               
       TextView appTitle = (TextView)findViewById(R.id.appTitle);
       appTitle.setVisibility(View.VISIBLE);
               
       Button backButton = (Button)rl.findViewById(R.id.backButton);
       backButton.setVisibility(View.GONE);
       arrayAdapter.clear();
       arrayAdapter.notifyDataSetChanged();
       TextView pathInfo = (TextView)rl.findViewById(R.id.path);
        pathInfo.setText("");
        folderPath = "";
       //new MyFetchTask("zenstudio.com.au", "zenstudi", ".-x$%Wmd5b#C","folder",folderPath).execute();
        connectedTo = -1;
                
                
                
                
        Toast.makeText(AHEActivity.this, "Disconnected", Toast.LENGTH_SHORT).show();
    }
     });*/

    Button button3 = (Button) findViewById(R.id.button3);
    button3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent SettingsIntent = new Intent(AHEActivity.this, Settings.class);
            startActivity(SettingsIntent);
        }
    });

    /*Button backButton = (Button)findViewById(R.id.backButton);
    backButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
       String[] pathBits = folderPath.split("/");
       folderPath = "";
       for(int i=0;i<pathBits.length-1;i++){
          folderPath += pathBits[i]+"/";
       }
       arrayAdapter.clear();
               
       //connectedTo
       SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        String currentServers = settings.getString("Accounts", "");
        if(currentServers.equals("")){}else{
       Gson gson = new Gson();
        SearchResponse response = gson.fromJson(currentServers, SearchResponse.class);
        List<Result> results = response.data;
        Result l = results.get(connectedTo);
                
       if(l.serverName!="" && l.userName!="" && l.port.trim()!=""){
               
          if(l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")){
             new MyFetchTask(l.serverName, l.userName, l.passWord,"folder",folderPath,l.sftp,l.port).execute();
          }else if(l.sftp.equals("3")){
             new FetchSSLTask(l.serverName, l.userName, l.passWord,"folder",folderPath,l.sftp,l.port).execute();
          }
               
       }
                
        }
    }
    });*/

    TextView pathInfo = (TextView) findViewById(R.id.path);
    pathInfo.setText(folderPath);

    lstTest = (ListView) findViewById(R.id.list);
    // lstTest.setDividerHeight(10);
    lstTest.setPadding(0, 5, 0, 5);
    alrts = new ArrayList<String[]>();
    arrayAdapter = new FetchAdapter(AHEActivity.this, R.layout.listitems, alrts);
    lstTest.setAdapter(arrayAdapter);

    lstTest.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
            final View d = v;
            final CharSequence[] items = { "Delete", "Rename", "Chmod", "Download" };

            TextView t = (TextView) v.findViewById(R.id.fileFolderName);
            final String oldName = t.getText().toString();

            final int position = pos;

            AlertDialog.Builder builder = new AlertDialog.Builder(AHEActivity.this);
            builder.setTitle("Choose Action");
            builder.setItems(items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {

                    if (item == 0) {
                        AlertDialog.Builder dbuilder = new AlertDialog.Builder(AHEActivity.this);
                        dbuilder.setMessage("Delete this file?").setCancelable(false)
                                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {

                                        deleteFile(d);
                                        dialog.cancel();
                                    }
                                }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        dialog.cancel();

                                    }
                                });
                        AlertDialog dalert = dbuilder.create();
                        dalert.show();

                    } else if (item == 1) {

                        final Dialog renameDialog = new Dialog(AHEActivity.this);
                        renameDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        renameDialog.setContentView(R.layout.renamediag);

                        renameDialog.setCancelable(true);

                        Button closeServer = (Button) renameDialog.findViewById(R.id.closeServer);
                        closeServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                renameDialog.cancel();
                            }
                        });

                        Button saveServer = (Button) renameDialog.findViewById(R.id.saveServer);
                        saveServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                EditText themeUrl = (EditText) renameDialog.findViewById(R.id.themeLink);
                                String newName = themeUrl.getText().toString();
                                //connectedTo
                                SharedPreferences settings = getSharedPreferences(PREFS_NAME,
                                        Context.MODE_PRIVATE);
                                String currentServers = settings.getString("Accounts", "");
                                if (currentServers.equals("")) {
                                } else {
                                    Gson gson = new Gson();
                                    SearchResponse response = gson.fromJson(currentServers,
                                            SearchResponse.class);
                                    List<Result> results = response.data;
                                    Result l = results.get(connectedTo);

                                    if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {

                                        new RenameTask(l.serverName, l.userName, l.passWord, oldName, newName,
                                                folderPath, l.sftp, l.port, position).execute();

                                        renameDialog.cancel();
                                    }
                                }
                            }
                        });
                        renameDialog.show();
                    } else if (item == 2) {

                        final Dialog chmodDialog = new Dialog(AHEActivity.this);
                        chmodDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        chmodDialog.setContentView(R.layout.chmoddiag);

                        chmodDialog.setCancelable(true);

                        Button closeServer = (Button) chmodDialog.findViewById(R.id.closeServer);
                        closeServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                chmodDialog.cancel();
                            }
                        });

                        Button saveServer = (Button) chmodDialog.findViewById(R.id.saveServer);
                        saveServer.setOnClickListener(new OnClickListener() {
                            public void onClick(View v) {

                                EditText themeUrl = (EditText) chmodDialog.findViewById(R.id.themeLink);
                                String perms = themeUrl.getText().toString();
                                //connectedTo
                                SharedPreferences settings = getSharedPreferences(PREFS_NAME,
                                        Context.MODE_PRIVATE);
                                String currentServers = settings.getString("Accounts", "");
                                if (currentServers.equals("")) {
                                } else {
                                    Gson gson = new Gson();
                                    SearchResponse response = gson.fromJson(currentServers,
                                            SearchResponse.class);
                                    List<Result> results = response.data;
                                    Result l = results.get(connectedTo);

                                    if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {

                                        if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) {
                                            new ChmodTask(l.serverName, l.userName, l.passWord, oldName, perms,
                                                    folderPath, l.sftp, l.port, position).execute();
                                        } else {
                                            Toast.makeText(AHEActivity.this,
                                                    "CHMOD could not be performed on your server via sftp",
                                                    Toast.LENGTH_SHORT).show();
                                        }
                                        chmodDialog.cancel();
                                    }
                                }
                            }
                        });
                        chmodDialog.show();

                    } else if (item == 3) {

                        //Make new class to download a file
                        SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
                        String currentServers = settings.getString("Accounts", "");
                        if (currentServers.equals("")) {
                        } else {
                            Gson gson = new Gson();
                            SearchResponse response = gson.fromJson(currentServers, SearchResponse.class);
                            List<Result> results = response.data;
                            Result l = results.get(connectedTo);

                            if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {

                                if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) {
                                    new DlTask(l.serverName, l.userName, l.passWord, oldName, l.sftp, l.port)
                                            .execute();

                                }
                            }
                        }
                    }

                    //Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();

                }
            });
            AlertDialog alert = builder.create();
            alert.show();
            return true;

        }
    });

    lstTest.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> av, View v, int pos, long id) {

            loadFileFolder(v);

        }
    });

}

From source file:adventure_fragments.Camping.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    ((MainActivityTrekkly) activity).onSectionAttached(2);
    MainActivityTrekkly mA = ((MainActivityTrekkly) getActivity());
    mA.restoreActionBar(Color.parseColor("#458B00"));
}

From source file:adventure_fragments.Climbing.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    ((MainActivityTrekkly) activity).onSectionAttached(3);
    MainActivityTrekkly mA = ((MainActivityTrekkly) getActivity());
    mA.restoreActionBar(Color.parseColor("#DB9356"));
}