Search in sources :

Example 1 with I2PAndroidHelper

use of net.i2p.android.ui.I2PAndroidHelper in project i2p.i2p-bote by i2p.

the class EmailListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Set the action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
    setSupportActionBar(toolbar);
    // Initialize variables
    mHelper = new I2PAndroidHelper(this);
    mSharedPrefs = getSharedPreferences(Constants.SHARED_PREFS, 0);
    mAccountHeader = new AccountHeaderBuilder().withActivity(this).withHeaderBackground(R.drawable.drawer_header_background).withSelectionListEnabledForSingleProfile(false).addProfiles(getLockedProfile()).withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {

        @Override
        public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
            if (profile.getIdentifier() == ID_LOCKED)
                findViewById(R.id.action_log_in).performClick();
            else if (!currentProfile)
                identitySelected(profile);
            return false;
        }
    }).withSavedInstance(savedInstanceState).build();
    IDrawerItem addressBook = new PrimaryDrawerItem().withIdentifier(ID_ADDRESS_BOOK).withName(R.string.address_book).withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_contacts).colorRes(R.color.md_grey_600).sizeDp(24)).withIconTintingEnabled(true).withSelectedIconColorRes(R.color.primary);
    IDrawerItem networkStatus = getNetStatusItem(R.string.network_status, GoogleMaterial.Icon.gmd_cloud_off, R.color.md_grey_600, 0);
    // Set the drawer width per Material design spec
    // http://www.google.com/design/spec/layout/structure.html#structure-side-nav-1
    // Mobile: side nav width = min(screen width - app bar height, 320dp)
    // Desktop: side nav width = min(screen width - app bar height, 400dp)
    int maxWidth = getResources().getDimensionPixelSize(R.dimen.nav_max_width);
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    int drawerWidth = Math.min(dm.widthPixels - toolbar.getLayoutParams().height, maxWidth);
    mDrawer = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withDrawerWidthPx(drawerWidth).withShowDrawerOnFirstLaunch(true).withAccountHeader(mAccountHeader).addStickyDrawerItems(addressBook, networkStatus).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {

        @Override
        public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {
            long id = iDrawerItem.getIdentifier();
            if (id == ID_ADDRESS_BOOK) {
                mDrawer.setSelection(mSelected, false);
                mDrawer.closeDrawer();
                Intent ai = new Intent(EmailListActivity.this, AddressBookActivity.class);
                startActivity(ai);
                return true;
            } else if (id == ID_NET_STATUS) {
                mDrawer.setSelection(mSelected, false);
                netStatusSelected();
                return true;
            } else {
                drawerFolderSelected((EmailFolder) iDrawerItem.getTag(), mSelected == i);
                mSelected = mDrawer.getCurrentSelection();
                return false;
            }
        }
    }).withSavedInstance(savedInstanceState).build();
    mSelected = mDrawer.getCurrentSelection();
    // Enable ActionBar app icon to behave as action to toggle nav drawer
    // noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    mDrawer.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true);
    if (savedInstanceState == null) {
        EmailListFragment f = EmailListFragment.newInstance("inbox");
        getSupportFragmentManager().beginTransaction().add(R.id.list_fragment, f).commit();
    }
    // If first start, go to introduction and setup wizard
    if (mSharedPrefs.getBoolean(PREF_FIRST_START, true)) {
        mSharedPrefs.edit().putBoolean(PREF_FIRST_START, false).apply();
        Intent i = new Intent(EmailListActivity.this, IntroActivity.class);
        startActivityForResult(i, SHOW_INTRODUCTION);
    }
}
Also used : IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) AccountHeaderBuilder(com.mikepenz.materialdrawer.AccountHeaderBuilder) Intent(android.content.Intent) I2PAndroidHelper(net.i2p.android.ui.I2PAndroidHelper) View(android.view.View) AdapterView(android.widget.AdapterView) DisplayMetrics(android.util.DisplayMetrics) IProfile(com.mikepenz.materialdrawer.model.interfaces.IProfile) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) Toolbar(android.support.v7.widget.Toolbar) EmailFolder(i2p.bote.folder.EmailFolder)

Example 2 with I2PAndroidHelper

use of net.i2p.android.ui.I2PAndroidHelper in project i2p.i2p-bote by i2p.

the class BoteService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    mRouterChoice = (RouterChoice) intent.getSerializableExtra(ROUTER_CHOICE);
    if (mRouterChoice == RouterChoice.INTERNAL)
        new Thread(new RouterStarter()).start();
    I2PBote bote = I2PBote.getInstance();
    if (mRouterChoice == RouterChoice.ANDROID) {
        bote.getConfiguration().setI2CPDomainSocket(DomainSocketFactory.I2CP_SOCKET_ADDRESS);
    }
    bote.startUp();
    bote.addNewEmailListener(this);
    if (mRouterChoice == RouterChoice.ANDROID) {
        // Bind to I2P Android
        mTriedBindState = (new I2PAndroidHelper(this)).bind(mStateConnection, 0);
    } else if (mRouterChoice == RouterChoice.REMOTE)
        bote.connectNow();
    mStatusBuilder = new NotificationCompat.Builder(this).setContentTitle(getResources().getString(R.string.app_name)).setSmallIcon(R.drawable.ic_notif).setOngoing(true).setOnlyAlertOnce(true);
    Intent ni = new Intent(this, EmailListActivity.class);
    ni.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pi = PendingIntent.getActivity(this, 0, ni, PendingIntent.FLAG_UPDATE_CURRENT);
    mStatusBuilder.setContentIntent(pi);
    updateServiceNotifText();
    startForeground(NOTIF_ID_SERVICE, mStatusBuilder.build());
    bote.addNetworkStatusListener(this);
    return START_REDELIVER_INTENT;
}
Also used : I2PBote(i2p.bote.I2PBote) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) I2PAndroidHelper(net.i2p.android.ui.I2PAndroidHelper)

Example 3 with I2PAndroidHelper

use of net.i2p.android.ui.I2PAndroidHelper in project Lightning-Browser by anthonycr.

the class ProxyUtils method sanitizeProxyChoice.

public static ProxyChoice sanitizeProxyChoice(ProxyChoice choice, @NonNull Activity activity) {
    switch(choice) {
        case ORBOT:
            if (!OrbotHelper.isOrbotInstalled(activity)) {
                choice = ProxyChoice.NONE;
                ActivityExtensions.snackbar(activity, R.string.install_orbot);
            }
            break;
        case I2P:
            I2PAndroidHelper ih = new I2PAndroidHelper(activity.getApplication());
            if (!ih.isI2PAndroidInstalled()) {
                choice = ProxyChoice.NONE;
                ih.promptToInstall(activity);
            }
            break;
        case MANUAL:
            break;
    }
    return choice;
}
Also used : I2PAndroidHelper(net.i2p.android.ui.I2PAndroidHelper)

Example 4 with I2PAndroidHelper

use of net.i2p.android.ui.I2PAndroidHelper in project Lightning-Browser by anthonycr.

the class ProxyUtils method setProxyChoice.

@Constants.Proxy
public static int setProxyChoice(int choice, @NonNull Activity activity) {
    switch(choice) {
        case Constants.PROXY_ORBOT:
            if (!OrbotHelper.isOrbotInstalled(activity)) {
                choice = Constants.NO_PROXY;
                Utils.showSnackbar(activity, R.string.install_orbot);
            }
            break;
        case Constants.PROXY_I2P:
            I2PAndroidHelper ih = new I2PAndroidHelper(activity.getApplication());
            if (!ih.isI2PAndroidInstalled()) {
                choice = Constants.NO_PROXY;
                ih.promptToInstall(activity);
            }
            break;
        case Constants.PROXY_MANUAL:
            break;
    }
    return choice;
}
Also used : I2PAndroidHelper(net.i2p.android.ui.I2PAndroidHelper)

Aggregations

I2PAndroidHelper (net.i2p.android.ui.I2PAndroidHelper)4 Intent (android.content.Intent)2 PendingIntent (android.app.PendingIntent)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 Toolbar (android.support.v7.widget.Toolbar)1 DisplayMetrics (android.util.DisplayMetrics)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)1 AccountHeaderBuilder (com.mikepenz.materialdrawer.AccountHeaderBuilder)1 DrawerBuilder (com.mikepenz.materialdrawer.DrawerBuilder)1 PrimaryDrawerItem (com.mikepenz.materialdrawer.model.PrimaryDrawerItem)1 IDrawerItem (com.mikepenz.materialdrawer.model.interfaces.IDrawerItem)1 IProfile (com.mikepenz.materialdrawer.model.interfaces.IProfile)1 I2PBote (i2p.bote.I2PBote)1 EmailFolder (i2p.bote.folder.EmailFolder)1