Search in sources :

Example 26 with ActionBar

use of android.app.ActionBar in project android_packages_apps_Settings by LineageOS.

the class EntityHeaderController method styleActionBar.

public EntityHeaderController styleActionBar(Activity activity) {
    if (activity == null) {
        Log.w(TAG, "No activity, cannot style actionbar.");
        return this;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (actionBar == null) {
        Log.w(TAG, "No actionbar, cannot style actionbar.");
        return this;
    }
    actionBar.setBackgroundDrawable(new ColorDrawable(Utils.getColorAttr(activity, android.R.attr.colorSecondary)));
    actionBar.setElevation(0);
    if (mRecyclerView != null && mLifecycle != null) {
        ActionBarShadowController.attachToRecyclerView(mActivity, mLifecycle, mRecyclerView);
    }
    return this;
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ActionBar(android.app.ActionBar)

Example 27 with ActionBar

use of android.app.ActionBar in project android_packages_apps_Settings by LineageOS.

the class InputMethodAndSubtypeEnablerActivity method onCreate.

@Override
protected void onCreate(final Bundle savedState) {
    super.onCreate(savedState);
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }
}
Also used : ActionBar(android.app.ActionBar)

Example 28 with ActionBar

use of android.app.ActionBar in project samourai-wallet-android by Samourai-Wallet.

the class BIP47Activity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bip47_list);
    setTitle(R.string.paynyms);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    ibBIP47Menu = (FloatingActionsMenu) findViewById(R.id.bip47_menu);
    actionAdd = (FloatingActionButton) findViewById(R.id.bip47_add);
    actionAdd.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            doAdd();
        }
    });
    actionSign = (FloatingActionButton) findViewById(R.id.bip47_sign);
    actionSign.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            doSign();
        }
    });
    if (meta == null) {
        meta = new HashMap<String, String>();
    }
    if (bitmaps == null) {
        bitmaps = new HashMap<String, Bitmap>();
    }
    listView = (SwipeMenuListView) findViewById(R.id.list);
    handler = new Handler();
    refreshList();
    adapter = new BIP47EntryAdapter();
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final String itemValue = (String) listView.getItemAtPosition(position);
            String msg = "";
            if (BIP47Meta.getInstance().getLabel(itemValue) != null && BIP47Meta.getInstance().getLabel(itemValue).length() > 0) {
                msg = BIP47Meta.getInstance().getLabel(itemValue) + ":";
            }
            if (BIP47Meta.getInstance().getOutgoingStatus(itemValue) == BIP47Meta.STATUS_NOT_SENT) {
                doNotifTx(itemValue);
            } else if (BIP47Meta.getInstance().getOutgoingStatus(itemValue) == BIP47Meta.STATUS_SENT_NO_CFM) {
                // Toast.makeText(BIP47Activity.this, R.string.bip47_wait_for_confirmation, Toast.LENGTH_SHORT).show();
                AlertDialog.Builder dlg = new AlertDialog.Builder(BIP47Activity.this).setTitle(R.string.app_name).setMessage(R.string.bip47_wait_for_confirmation_or_retry).setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton) {
                        doNotifTx(itemValue);
                    }
                }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton) {
                        ;
                    }
                });
                if (!isFinishing()) {
                    dlg.show();
                }
            } else {
                AlertDialog.Builder dlg = new AlertDialog.Builder(BIP47Activity.this).setTitle(R.string.app_name).setMessage(R.string.bip47_spend_to_pcode).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton) {
                        AppUtil.getInstance(BIP47Activity.this).restartApp("pcode", itemValue);
                    }
                }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton) {
                        ;
                    }
                });
                dlg.show();
            }
        }
    });
    listView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(final int position, SwipeMenu menu, int index) {
            switch(index) {
                case 0:
                    {
                        Intent intent = new Intent(BIP47Activity.this, BIP47Add.class);
                        intent.putExtra("label", BIP47Meta.getInstance().getLabel(pcodes[position]));
                        intent.putExtra("pcode", pcodes[position]);
                        startActivityForResult(intent, EDIT_PCODE);
                    }
                    break;
                case 1:
                    doSync(pcodes[position]);
                    break;
                case 2:
                    {
                        Intent intent = new Intent(BIP47Activity.this, BIP47ShowQR.class);
                        intent.putExtra("label", BIP47Meta.getInstance().getLabel(pcodes[position]));
                        intent.putExtra("pcode", pcodes[position]);
                        startActivity(intent);
                    }
                    break;
                case 3:
                    // archive
                    BIP47Meta.getInstance().setArchived(pcodes[position], true);
                    refreshList();
                    adapter.notifyDataSetChanged();
                    break;
            }
            return false;
        }
    });
    listView.setLongClickable(true);
    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) {
            int outgoing = BIP47Meta.getInstance().getOutgoingIdx(pcodes[position]);
            int incoming = BIP47Meta.getInstance().getIncomingIdx(pcodes[position]);
            // Toast.makeText(BIP47Activity.this, pcodes[position], Toast.LENGTH_SHORT).show();
            Toast.makeText(BIP47Activity.this, "Incoming index:" + incoming + ", Outgoing index:" + outgoing, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
    SwipeMenuCreator creator = new SwipeMenuCreator() {

        @Override
        public void create(SwipeMenu menu) {
            // create "edit" item
            SwipeMenuItem openItem = new SwipeMenuItem(getApplicationContext());
            // set item background
            openItem.setBackground(new ColorDrawable(Color.rgb(0x17, 0x1B, 0x24)));
            // set item width
            openItem.setWidth(180);
            // set a icon
            openItem.setIcon(R.drawable.ic_edit_white_24dp);
            // add to menu
            menu.addMenuItem(openItem);
            // create "sync" item
            SwipeMenuItem syncItem = new SwipeMenuItem(getApplicationContext());
            // set item background
            syncItem.setBackground(new ColorDrawable(Color.rgb(0x17, 0x1B, 0x24)));
            // set item width
            syncItem.setWidth(180);
            // set a icon
            syncItem.setIcon(android.R.drawable.ic_popup_sync);
            // add to menu
            menu.addMenuItem(syncItem);
            // create "qr" item
            SwipeMenuItem qrItem = new SwipeMenuItem(getApplicationContext());
            // set item background
            qrItem.setBackground(new ColorDrawable(Color.rgb(0x17, 0x1B, 0x24)));
            // set item width
            qrItem.setWidth(180);
            // set a icon
            qrItem.setIcon(R.drawable.ic_receive_qr);
            // add to menu
            menu.addMenuItem(qrItem);
            // create "qr" item
            SwipeMenuItem archiveItem = new SwipeMenuItem(getApplicationContext());
            // set item background
            archiveItem.setBackground(new ColorDrawable(Color.rgb(0x17, 0x1B, 0x24)));
            // set item width
            archiveItem.setWidth(180);
            // set a icon
            archiveItem.setIcon(android.R.drawable.ic_media_pause);
            // add to menu
            menu.addMenuItem(archiveItem);
        }
    };
    listView.setMenuCreator(creator);
    listView.setSwipeDirection(SwipeMenuListView.DIRECTION_LEFT);
    doTimer();
    Bundle extras = getIntent().getExtras();
    if (extras != null && extras.containsKey("pcode")) {
        String pcode = extras.getString("pcode");
        String meta = null;
        if (extras.containsKey("meta")) {
            meta = extras.getString("meta");
        }
        String _meta = null;
        try {
            Map<String, String> map = new HashMap<String, String>();
            if (meta != null && meta.length() > 0) {
                _meta = URLDecoder.decode(meta, "UTF-8");
                map = Splitter.on('&').trimResults().withKeyValueSeparator("=").split(_meta);
            }
            Intent intent = new Intent(BIP47Activity.this, BIP47Add.class);
            intent.putExtra("pcode", pcode);
            intent.putExtra("label", map.containsKey("title") ? map.get("title").trim() : "");
            startActivityForResult(intent, EDIT_PCODE);
        } catch (UnsupportedEncodingException uee) {
            ;
        } catch (Exception e) {
            ;
        }
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) SwipeMenu(com.baoyz.swipemenulistview.SwipeMenu) HashMap(java.util.HashMap) Bitmap(android.graphics.Bitmap) SwipeMenuCreator(com.baoyz.swipemenulistview.SwipeMenuCreator) SwipeMenuItem(com.baoyz.swipemenulistview.SwipeMenuItem) ActionBar(android.app.ActionBar) Bundle(android.os.Bundle) Handler(android.os.Handler) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Intent(android.content.Intent) SwipeMenuListView(com.baoyz.swipemenulistview.SwipeMenuListView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) MyTransactionOutPoint(com.samourai.wallet.send.MyTransactionOutPoint) SecretPoint(com.samourai.wallet.bip47.rpc.SecretPoint) Point(android.graphics.Point) NotSecp256k1Exception(com.samourai.wallet.bip47.rpc.NotSecp256k1Exception) JSONException(org.json.JSONException) AddressFormatException(org.bitcoinj.core.AddressFormatException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) InvalidKeySpecException(java.security.spec.InvalidKeySpecException) DecryptionException(com.samourai.wallet.crypto.DecryptionException) IOException(java.io.IOException) DecoderException(org.bouncycastle.util.encoders.DecoderException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MnemonicException(org.bitcoinj.crypto.MnemonicException) NoSuchProviderException(java.security.NoSuchProviderException) SwipeMenuListView(com.baoyz.swipemenulistview.SwipeMenuListView) ColorDrawable(android.graphics.drawable.ColorDrawable) AdapterView(android.widget.AdapterView)

Example 29 with ActionBar

use of android.app.ActionBar in project samourai-wallet-android by Samourai-Wallet.

the class SettingsActivity2 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras();
    if (extras != null && extras.containsKey("branch")) {
        String strBranch = extras.getString("branch");
        if (strBranch.equals("prefs")) {
            addPreferencesFromResource(R.xml.settings_prefs);
            Preference fiatPref = (Preference) findPreference("fiat");
            fiatPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    getExchange();
                    return true;
                }
            });
            Preference explorersPref = (Preference) findPreference("explorer");
            explorersPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    getBlockExplorer();
                    return true;
                }
            });
        } else if (strBranch.equals("txs")) {
            addPreferencesFromResource(R.xml.settings_txs);
            final CheckBoxPreference cbPref0 = (CheckBoxPreference) findPreference("segwit");
            cbPref0.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    if (cbPref0.isChecked()) {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.USE_SEGWIT, false);
                    } else {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.USE_SEGWIT, true);
                    }
                    return true;
                }
            });
            final CheckBoxPreference cbPref15 = (CheckBoxPreference) findPreference("likeTypedChange");
            cbPref15.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    if (cbPref15.isChecked()) {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.USE_LIKE_TYPED_CHANGE, false);
                    } else {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.USE_LIKE_TYPED_CHANGE, true);
                    }
                    return true;
                }
            });
            final CheckBoxPreference cbPref7 = (CheckBoxPreference) findPreference("bip126");
            cbPref7.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    if (cbPref7.isChecked()) {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.USE_BIP126, false);
                    } else {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.USE_BIP126, true);
                    }
                    return true;
                }
            });
            final CheckBoxPreference cbPref9 = (CheckBoxPreference) findPreference("rbf");
            cbPref9.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    if (cbPref9.isChecked()) {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.RBF_OPT_IN, false);
                    } else {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.RBF_OPT_IN, true);
                    }
                    return true;
                }
            });
            Preference trustedNodePref = (Preference) findPreference("trustedNode");
            trustedNodePref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    getTrustedNode();
                    return true;
                }
            });
            final CheckBoxPreference cbPref8 = (CheckBoxPreference) findPreference("useTrustedNode");
            if (TrustedNodeUtil.getInstance().isSet() && TrustedNodeUtil.getInstance().isValidated()) {
                cbPref8.setEnabled(true);
            } else {
                cbPref8.setEnabled(false);
            }
            cbPref8.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    if (cbPref8.isChecked()) {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.USE_TRUSTED_NODE, false);
                    } else if (TrustedNodeUtil.getInstance().isSet() && TrustedNodeUtil.getInstance().isValidated()) {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.USE_TRUSTED_NODE, true);
                    } else {
                        Toast.makeText(SettingsActivity2.this, R.string.trusted_node_not_valid, Toast.LENGTH_SHORT).show();
                        cbPref8.setEnabled(false);
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.USE_TRUSTED_NODE, false);
                    }
                    return true;
                }
            });
            Preference feeproviderPref = (Preference) findPreference("feeProvider");
            feeproviderPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    getFeeProvider();
                    return true;
                }
            });
            final CheckBoxPreference cbPref10 = (CheckBoxPreference) findPreference("broadcastTx");
            cbPref10.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    if (cbPref10.isChecked()) {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.BROADCAST_TX, false);
                    } else {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.BROADCAST_TX, true);
                    }
                    return true;
                }
            });
            Preference broadcastHexPref = (Preference) findPreference("broadcastHex");
            broadcastHexPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    doBroadcastHex();
                    return true;
                }
            });
        } else if (strBranch.equals("stealth")) {
            addPreferencesFromResource(R.xml.settings_stealth);
            final CheckBoxPreference cbPref1 = (CheckBoxPreference) findPreference("stealthDisplay");
            cbPref1.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    final ComponentName component = new ComponentName(getApplicationContext().getPackageName(), "com.samourai.wallet.Launcher");
                    if (component != null) {
                        if (cbPref1.isChecked()) {
                            getPackageManager().setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
                            PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.ICON_HIDDEN, false);
                            stopService(new Intent(SettingsActivity2.this, BroadcastReceiverService.class));
                            startService(new Intent(SettingsActivity2.this, BroadcastReceiverService.class));
                            AppUtil.getInstance(SettingsActivity2.this).restartApp();
                        } else {
                            String strMsg = SettingsActivity2.this.getString(R.string.options_stealth_display2);
                            new AlertDialog.Builder(SettingsActivity2.this).setIcon(R.drawable.ic_launcher).setTitle(R.string.options_stealth_display).setMessage(strMsg).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

                                // @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    steathActivating = true;
                                    getPackageManager().setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
                                    PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.ICON_HIDDEN, true);
                                    stopService(new Intent(SettingsActivity2.this, BroadcastReceiverService.class));
                                    startService(new Intent(SettingsActivity2.this, BroadcastReceiverService.class));
                                    try {
                                        PayloadUtil.getInstance(SettingsActivity2.this).saveWalletToJSON(new CharSequenceX(AccessFactory.getInstance(SettingsActivity2.this).getGUID() + AccessFactory.getInstance(SettingsActivity2.this).getPIN()));
                                    } catch (Exception e) {
                                        ;
                                    }
                                }
                            }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {

                                // @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    cbPref1.setChecked(false);
                                }
                            }).show();
                        }
                    }
                    return true;
                }
            });
            final Preference remotePinPref = (Preference) findPreference("remote_pin");
            remotePinPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    if (steathActivating) {
                        Toast.makeText(SettingsActivity2.this, R.string.alternative_pin_wait, Toast.LENGTH_SHORT).show();
                    } else {
                        new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.alternative_pin_create).setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog, int whichButton) {
                                final EditText pin = new EditText(SettingsActivity2.this);
                                pin.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
                                new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.pin_5_8).setView(pin).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                                    public void onClick(DialogInterface dialog, int whichButton) {
                                        final String _pin = pin.getText().toString();
                                        if (_pin != null && _pin.length() >= AccessFactory.MIN_PIN_LENGTH && _pin.length() <= AccessFactory.MAX_PIN_LENGTH) {
                                            final EditText pin2 = new EditText(SettingsActivity2.this);
                                            pin2.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
                                            new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.pin_5_8_confirm).setView(pin2).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                                                public void onClick(DialogInterface dialog, int whichButton) {
                                                    String _pin2 = pin2.getText().toString();
                                                    if (_pin2 != null && _pin2.equals(_pin)) {
                                                        String hash = AccessFactory.getInstance(SettingsActivity2.this).getHash(AccessFactory.getInstance(SettingsActivity2.this).getGUID(), new CharSequenceX(_pin), AESUtil.DefaultPBKDF2Iterations);
                                                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.ACCESS_HASH2, hash);
                                                        AccessFactory.getInstance(SettingsActivity2.this).setPIN2(_pin2);
                                                        try {
                                                            PayloadUtil.getInstance(SettingsActivity2.this).saveWalletToJSON(new CharSequenceX(AccessFactory.getInstance(SettingsActivity2.this).getGUID() + AccessFactory.getInstance(SettingsActivity2.this).getPIN()));
                                                        } catch (JSONException je) {
                                                            je.printStackTrace();
                                                        } catch (IOException ioe) {
                                                            ioe.printStackTrace();
                                                        } catch (MnemonicException.MnemonicLengthException mle) {
                                                            mle.printStackTrace();
                                                        } catch (DecryptionException de) {
                                                            de.printStackTrace();
                                                        } finally {
                                                            Toast.makeText(SettingsActivity2.this.getApplicationContext(), R.string.success_change_pin, Toast.LENGTH_SHORT).show();
                                                        }
                                                    }
                                                }
                                            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                                                public void onClick(DialogInterface dialog, int whichButton) {
                                                    ;
                                                }
                                            }).show();
                                        } else {
                                            AccessFactory.getInstance(SettingsActivity2.this).setPIN2("");
                                            PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.ACCESS_HASH2, PrefsUtil.getInstance(SettingsActivity2.this).getValue(PrefsUtil.ACCESS_HASH, ""));
                                            Toast.makeText(SettingsActivity2.this, R.string.alternative_pin_deleted, Toast.LENGTH_SHORT).show();
                                        }
                                    }
                                }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                                    public void onClick(DialogInterface dialog, int whichButton) {
                                        ;
                                    }
                                }).show();
                            }
                        }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog, int whichButton) {
                                ;
                            }
                        }).show();
                    }
                    return true;
                }
            });
        } else if (strBranch.equals("remote")) {
            addPreferencesFromResource(R.xml.settings_remote);
            final CheckBoxPreference cbPref2 = (CheckBoxPreference) findPreference("stealthRemote");
            final CheckBoxPreference cbPref3 = (CheckBoxPreference) findPreference("trustedLock");
            final CheckBoxPreference cbPref4 = (CheckBoxPreference) findPreference("sim_switch");
            final EditTextPreference textPref1 = (EditTextPreference) findPreference("alertSMSNo");
            cbPref2.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    if (cbPref2.isChecked()) {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.ACCEPT_REMOTE, false);
                        stopService(new Intent(SettingsActivity2.this, BroadcastReceiverService.class));
                        startService(new Intent(SettingsActivity2.this, BroadcastReceiverService.class));
                    } else {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.ACCEPT_REMOTE, true);
                        stopService(new Intent(SettingsActivity2.this, BroadcastReceiverService.class));
                        startService(new Intent(SettingsActivity2.this, BroadcastReceiverService.class));
                    }
                    return true;
                }
            });
            cbPref3.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    if (cbPref3.isChecked()) {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.TRUSTED_LOCK, false);
                    } else {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.TRUSTED_LOCK, true);
                    }
                    return true;
                }
            });
            cbPref4.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    if (cbPref4.isChecked()) {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.CHECK_SIM, false);
                    } else {
                        SIMUtil.getInstance(SettingsActivity2.this).setStoredSIM();
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.CHECK_SIM, true);
                    }
                    return true;
                }
            });
            textPref1.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    String telno = newValue.toString();
                    if (telno != null && telno.length() > 0) {
                        String s = telno.replaceAll("[^\\+0-9]", "");
                        if (s.matches("^\\+[0-9]+$")) {
                            PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.ALERT_MOBILE_NO, s);
                            cbPref3.setEnabled(true);
                            cbPref4.setEnabled(true);
                        } else {
                            Toast.makeText(SettingsActivity2.this, "Use international dialing format. Ex.:'+447385555555'", Toast.LENGTH_SHORT).show();
                        }
                    } else {
                        cbPref3.setEnabled(false);
                        cbPref3.setChecked(false);
                        cbPref4.setEnabled(false);
                        cbPref4.setChecked(false);
                    }
                    return true;
                }
            });
        } else if (strBranch.equals("wallet")) {
            addPreferencesFromResource(R.xml.settings_wallet);
            Preference mnemonicPref = (Preference) findPreference("mnemonic");
            mnemonicPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    getHDSeed(true);
                    return true;
                }
            });
            Preference xpubPref = (Preference) findPreference("xpub");
            xpubPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    getXPUB();
                    return true;
                }
            });
            Preference ypubPref = (Preference) findPreference("ypub");
            ypubPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    getYPUB();
                    return true;
                }
            });
            Preference wipePref = (Preference) findPreference("wipe");
            wipePref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.sure_to_erase).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            final ProgressDialog progress = new ProgressDialog(SettingsActivity2.this);
                            progress.setTitle(R.string.app_name);
                            progress.setMessage(SettingsActivity2.this.getResources().getString(R.string.securely_wiping_wait));
                            progress.setCancelable(false);
                            progress.show();
                            new Thread(new Runnable() {

                                @Override
                                public void run() {
                                    Looper.prepare();
                                    AppUtil.getInstance(SettingsActivity2.this).wipeApp();
                                    Toast.makeText(SettingsActivity2.this, R.string.wallet_erased, Toast.LENGTH_SHORT).show();
                                    AppUtil.getInstance(SettingsActivity2.this).restartApp();
                                    if (progress != null && progress.isShowing()) {
                                        progress.dismiss();
                                    }
                                    Looper.loop();
                                }
                            }).start();
                        }
                    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            ;
                        }
                    }).show();
                    return true;
                }
            });
            final CheckBoxPreference cbPref5 = (CheckBoxPreference) findPreference("scramblePin");
            cbPref5.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    if (cbPref5.isChecked()) {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.SCRAMBLE_PIN, false);
                    } else {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.SCRAMBLE_PIN, true);
                    }
                    return true;
                }
            });
            final CheckBoxPreference cbPref11 = (CheckBoxPreference) findPreference("haptic");
            cbPref11.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    if (cbPref11.isChecked()) {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.HAPTIC_PIN, false);
                    } else {
                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.HAPTIC_PIN, true);
                    }
                    return true;
                }
            });
            Preference changePinPref = (Preference) findPreference("change_pin");
            changePinPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.confirm_change_pin).setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            final EditText pin = new EditText(SettingsActivity2.this);
                            pin.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
                            new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.pin_enter).setView(pin).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog, int whichButton) {
                                    String _pin = pin.getText().toString();
                                    if (_pin != null && _pin.length() >= AccessFactory.MIN_PIN_LENGTH && _pin.length() <= AccessFactory.MAX_PIN_LENGTH) {
                                        String hash = PrefsUtil.getInstance(SettingsActivity2.this).getValue(PrefsUtil.ACCESS_HASH, "");
                                        if (AccessFactory.getInstance(SettingsActivity2.this).validateHash(hash, AccessFactory.getInstance(SettingsActivity2.this).getGUID(), new CharSequenceX(_pin), AESUtil.DefaultPBKDF2Iterations)) {
                                            final EditText pin = new EditText(SettingsActivity2.this);
                                            pin.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
                                            new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.pin_5_8).setView(pin).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                                                public void onClick(DialogInterface dialog, int whichButton) {
                                                    final String _pin = pin.getText().toString();
                                                    if (_pin != null && _pin.length() >= AccessFactory.MIN_PIN_LENGTH && _pin.length() <= AccessFactory.MAX_PIN_LENGTH) {
                                                        final EditText pin2 = new EditText(SettingsActivity2.this);
                                                        pin2.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
                                                        new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.pin_5_8_confirm).setView(pin2).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                                                            public void onClick(DialogInterface dialog, int whichButton) {
                                                                String _pin2 = pin2.getText().toString();
                                                                if (_pin2 != null && _pin2.equals(_pin)) {
                                                                    String accessHash = PrefsUtil.getInstance(SettingsActivity2.this).getValue(PrefsUtil.ACCESS_HASH, "");
                                                                    String accessHash2 = PrefsUtil.getInstance(SettingsActivity2.this).getValue(PrefsUtil.ACCESS_HASH2, "");
                                                                    String hash = AccessFactory.getInstance(SettingsActivity2.this).getHash(AccessFactory.getInstance(SettingsActivity2.this).getGUID(), new CharSequenceX(_pin), AESUtil.DefaultPBKDF2Iterations);
                                                                    PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.ACCESS_HASH, hash);
                                                                    if (accessHash.equals(accessHash2)) {
                                                                        PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.ACCESS_HASH2, hash);
                                                                    }
                                                                    AccessFactory.getInstance(SettingsActivity2.this).setPIN(_pin2);
                                                                    try {
                                                                        PayloadUtil.getInstance(SettingsActivity2.this).saveWalletToJSON(new CharSequenceX(AccessFactory.getInstance(SettingsActivity2.this).getGUID() + _pin));
                                                                    } catch (JSONException je) {
                                                                        je.printStackTrace();
                                                                    } catch (IOException ioe) {
                                                                        ioe.printStackTrace();
                                                                    } catch (MnemonicException.MnemonicLengthException mle) {
                                                                        mle.printStackTrace();
                                                                    } catch (DecryptionException de) {
                                                                        de.printStackTrace();
                                                                    } finally {
                                                                        Toast.makeText(SettingsActivity2.this.getApplicationContext(), R.string.success_change_pin, Toast.LENGTH_SHORT).show();
                                                                    }
                                                                }
                                                            }
                                                        }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                                                            public void onClick(DialogInterface dialog, int whichButton) {
                                                                ;
                                                            }
                                                        }).show();
                                                    }
                                                }
                                            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                                                public void onClick(DialogInterface dialog, int whichButton) {
                                                    ;
                                                }
                                            }).show();
                                        } else {
                                            Toast.makeText(SettingsActivity2.this.getApplicationContext(), R.string.pin_error, Toast.LENGTH_SHORT).show();
                                        }
                                    } else {
                                        Toast.makeText(SettingsActivity2.this.getApplicationContext(), R.string.pin_error, Toast.LENGTH_SHORT).show();
                                    }
                                }
                            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog, int whichButton) {
                                    ;
                                }
                            }).show();
                        }
                    }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            ;
                        }
                    }).show();
                    return true;
                }
            });
            final CheckBoxPreference cbPref6 = (CheckBoxPreference) findPreference("autoBackup");
            if (!SamouraiWallet.getInstance().hasPassphrase(SettingsActivity2.this)) {
                cbPref6.setChecked(false);
                cbPref6.setEnabled(false);
            } else {
                cbPref6.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                    public boolean onPreferenceChange(Preference preference, Object newValue) {
                        if (cbPref6.isChecked()) {
                            PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.AUTO_BACKUP, false);
                        } else {
                            PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.AUTO_BACKUP, true);
                        }
                        return true;
                    }
                });
            }
        } else if (strBranch.equals("networking")) {
            addPreferencesFromResource(R.xml.settings_networking);
            Preference vpnPref = (Preference) findPreference("VPN");
            vpnPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    PackageManager pm = SettingsActivity2.this.getPackageManager();
                    try {
                        pm.getPackageInfo(AppUtil.OPENVPN_PACKAGE_ID, 0);
                        Intent intent = getPackageManager().getLaunchIntentForPackage(AppUtil.OPENVPN_PACKAGE_ID);
                        startActivity(intent);
                    } catch (PackageManager.NameNotFoundException nnfe) {
                        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + AppUtil.OPENVPN_PACKAGE_ID));
                        startActivity(intent);
                    }
                    return true;
                }
            });
            final Preference torPref = (Preference) findPreference("Tor");
            if (!OrbotHelper.isOrbotInstalled(SettingsActivity2.this)) {
                torPref.setSummary(R.string.tor_install);
            } else if (TorUtil.getInstance(SettingsActivity2.this).statusFromBroadcast()) {
                torPref.setSummary(R.string.tor_routing_on);
            } else {
                torPref.setSummary(R.string.tor_routing_off);
            }
            torPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    if (!OrbotHelper.isOrbotInstalled(SettingsActivity2.this)) {
                        new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.you_must_have_orbot).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog, int whichButton) {
                                Intent intent = OrbotHelper.getOrbotInstallIntent(SettingsActivity2.this);
                                startActivity(intent);
                            }
                        }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog, int whichButton) {
                                ;
                            }
                        }).show();
                    } else if (TorUtil.getInstance(SettingsActivity2.this).statusFromBroadcast()) {
                        TorUtil.getInstance(SettingsActivity2.this).setStatusFromBroadcast(false);
                        torPref.setSummary(R.string.tor_routing_off);
                    } else {
                        OrbotHelper.requestStartTor(SettingsActivity2.this);
                        TorUtil.getInstance(SettingsActivity2.this).setStatusFromBroadcast(true);
                        torPref.setSummary(R.string.tor_routing_on);
                    }
                    return true;
                }
            });
        } else if (strBranch.equals("troubleshoot")) {
            addPreferencesFromResource(R.xml.settings_troubleshoot);
            Preference troubleshootPref = (Preference) findPreference("troubleshoot");
            troubleshootPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    doTroubleshoot();
                    return true;
                }
            });
            Preference sendBackupPref = (Preference) findPreference("send_backup_support");
            sendBackupPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.prompt_send_backup_to_support).setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            doSendBackup();
                        }
                    }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            ;
                        }
                    }).show();
                    return true;
                }
            });
        } else if (strBranch.equals("other")) {
            addPreferencesFromResource(R.xml.settings_other);
            Preference hashPref = (Preference) findPreference("hash");
            hashPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    try {
                        File apk = new File(SettingsActivity2.this.getPackageCodePath());
                        MessageDigest md = MessageDigest.getInstance("SHA-256");
                        FileInputStream fis = new FileInputStream(apk);
                        byte[] dataBytes = new byte[1024 * 8];
                        int nread = 0;
                        while ((nread = fis.read(dataBytes)) != -1) {
                            md.update(dataBytes, 0, nread);
                        }
                        ;
                        byte[] hval = md.digest();
                        String hash = Hex.toHexString(hval);
                        TextView showText = new TextView(SettingsActivity2.this);
                        showText.setText(hash);
                        showText.setTextIsSelectable(true);
                        showText.setPadding(40, 10, 40, 10);
                        showText.setTextSize(18.0f);
                        new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setView(showText).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog, int whichButton) {
                                ;
                            }
                        }).show();
                    } catch (Exception e) {
                        ;
                    }
                    return true;
                }
            });
            Preference aboutPref = (Preference) findPreference("about");
            aboutPref.setSummary("Samourai," + " " + getResources().getString(R.string.version_name));
            aboutPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                public boolean onPreferenceClick(Preference preference) {
                    Intent intent = new Intent(SettingsActivity2.this, AboutActivity.class);
                    startActivity(intent);
                    return true;
                }
            });
        } else {
            finish();
        }
    } else {
        finish();
    }
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
}
Also used : AlertDialog(android.app.AlertDialog) CharSequenceX(com.samourai.wallet.util.CharSequenceX) DialogInterface(android.content.DialogInterface) ProgressDialog(android.app.ProgressDialog) BroadcastReceiverService(com.samourai.wallet.service.BroadcastReceiverService) OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) MnemonicException(org.bitcoinj.crypto.MnemonicException) PackageManager(android.content.pm.PackageManager) ComponentName(android.content.ComponentName) TextView(android.widget.TextView) MessageDigest(java.security.MessageDigest) ActionBar(android.app.ActionBar) EditText(android.widget.EditText) CheckBoxPreference(android.preference.CheckBoxPreference) Bundle(android.os.Bundle) JSONException(org.json.JSONException) Intent(android.content.Intent) IOException(java.io.IOException) EditTextPreference(android.preference.EditTextPreference) WriterException(com.google.zxing.WriterException) JSONException(org.json.JSONException) FileNotFoundException(java.io.FileNotFoundException) MnemonicException(org.bitcoinj.crypto.MnemonicException) DecryptionException(com.samourai.wallet.crypto.DecryptionException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) FileInputStream(java.io.FileInputStream) EditTextPreference(android.preference.EditTextPreference) CheckBoxPreference(android.preference.CheckBoxPreference) Preference(android.preference.Preference) JSONObject(org.json.JSONObject) DecryptionException(com.samourai.wallet.crypto.DecryptionException) File(java.io.File)

Example 30 with ActionBar

use of android.app.ActionBar in project GTFSOffline by wbrenna.

the class MainActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    // we want to refresh the databases list
    Set<String> emptyString = new HashSet<String>();
    emptyString.clear();
    Set<String> initial_preferences = mPrefs.getStringSet(getString(R.string.pref_dbs), emptyString);
    // in case we're on a low-ram system and things aren't cached
    try {
        if (!initial_preferences.equals(mDBListPrefsOld)) {
            mDBListPrefsOld = initial_preferences;
            // this is the list of currently checked databases
            mDBActive = null;
            // just to nullify the previous one.
            if (initial_preferences.size() != 0) {
                String[] tmpDBActive = initial_preferences.toArray(new String[initial_preferences.size()]);
                dbHelper.gatherFiles();
                mDBList = dbHelper.GetListofDB();
                List<String> workingDBList = new ArrayList<String>();
                for (int i = 0; i < tmpDBActive.length; i++) {
                    if (mDBList.contains(tmpDBActive[i])) {
                        workingDBList.add(tmpDBActive[i]);
                    }
                }
                if (workingDBList.size() == 0) {
                    mDBActive = null;
                } else {
                    mDBActive = workingDBList.toArray(new String[workingDBList.size()]);
                }
            }
            mSectionsPagerAdapter.notifyDataSetChanged();
            // totally kill the viewPager and all, and recreate!
            // mSectionsPagerAdapter = null;
            // getFragmentManager().beginTransaction().replace(containerViewId, fragment);
            // and create the appropriate tabs
            final ActionBar actionBar = getActionBar();
            /**
             *mSectionsPagerAdapter = new SectionsPagerAdapter(
             *						getSupportFragmentManager());
             *
             *				// Set up the ViewPager with the sections adapter.
             *				mViewPager = (ViewPager) findViewById(R.id.pager);
             *				mViewPager.setAdapter(mSectionsPagerAdapter);
             *
             *				mViewPager
             *						.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
             *							@Override
             *							public void onPageSelected(int position) {
             *								actionBar.setSelectedNavigationItem(position);
             *							}
             *						});*
             */
            if (actionBar != null) {
                actionBar.removeAllTabs();
            }
            for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
                actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
                /**
                 *if (i > 0 ) {
                 *						Fragment newFragment = new DBListFragment();
                 *						Bundle args = new Bundle();
                 *						args.putString(DBListFragment.DATABASE, mDBActive[i-1]);
                 *						newFragment.setArguments(args);
                 *
                 *						getFragmentManager().beginTransaction().replace(i, newFragment);
                 *					}*
                 */
                if (i > 0) {
                    DBListFragment aFragment = (DBListFragment) getSupportFragmentManager().findFragmentByTag("android:switcher:" + R.id.pager + ":" + Integer.toString(i));
                    if (aFragment != null) {
                        getSupportFragmentManager().beginTransaction().remove(aFragment).commit();
                        mSectionsPagerAdapter.notifyDataSetChanged();
                    // if (aFragment.getView() != null) {
                    // aFragment.updateDisplay();
                    // }
                    }
                } else if (i == 0) {
                    FavSectionFragment aFavFragment = (FavSectionFragment) getSupportFragmentManager().findFragmentByTag("android:switcher:" + R.id.pager + ":" + Integer.toString(i));
                    if (aFavFragment != null) {
                        // getSupportFragmentManager().beginTransaction().remove(aFavFragment).commit();
                        // mSectionsPagerAdapter.notifyDataSetChanged();
                        // if (aFavFragment.getView() != null) {
                        // aFavFragment.updateDisplay();
                        // }
                        aFavFragment.updatePositions();
                    }
                }
            }
        }
    } finally {
        // restart location manager
        // mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
        mLocationHelper.refresh(locationListener);
    }
}
Also used : ArrayList(java.util.ArrayList) ActionBar(android.app.ActionBar) HashSet(java.util.HashSet)

Aggregations

ActionBar (android.app.ActionBar)265 View (android.view.View)58 Intent (android.content.Intent)35 TextView (android.widget.TextView)21 ColorDrawable (android.graphics.drawable.ColorDrawable)20 OnClickListener (android.view.View.OnClickListener)14 AdapterView (android.widget.AdapterView)14 ListView (android.widget.ListView)12 Bundle (android.os.Bundle)10 Test (org.junit.Test)10 SharedPreferences (android.content.SharedPreferences)9 Uri (android.net.Uri)9 Button (android.widget.Button)9 AlertDialog (android.app.AlertDialog)8 DialogInterface (android.content.DialogInterface)8 ViewPager (android.support.v4.view.ViewPager)8 SpannableString (android.text.SpannableString)8 ComponentName (android.content.ComponentName)7 ArrayAdapter (android.widget.ArrayAdapter)7 FrameLayout (android.widget.FrameLayout)7