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);
}
}
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;
}
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;
}
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;
}
Aggregations