List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:com.alexcruz.papuhwalls.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { this.Preferences = new Preferences(getApplicationContext()); super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); context = this; CustomActivityOnCrash.install(this); prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (prefs.getBoolean(Preferences.IS_FIRST__RUN, true)) { startActivity(new Intent(this, Slides.class)); finish();/*w ww . j a v a 2 s . co m*/ } if (Build.VERSION.SDK_INT >= 23 && PermissionChecker.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PermissionChecker.PERMISSION_GRANTED) { requestPermissions(new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_READ_STORAGE_PERMISSION); } else { // Do absolutely NOTHING } final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); com.alexcruz.papuhwalls.Preferences.themeMe(this, toolbar); Home = getResources().getString(R.string.app_name); final String Home = getResources().getString(R.string.section_home); AllWalls = getResources().getString(R.string.section_all_walls); AndroidWalls = getResources().getString(R.string.section_android_walls); BwWalls = getResources().getString(R.string.section_bw_walls); BlurWalls = getResources().getString(R.string.section_blur_walls); CloudsWalls = getResources().getString(R.string.section_clouds_walls); MiscWalls = getResources().getString(R.string.section_misc_walls); MustachesWalls = getResources().getString(R.string.section_mustaches_walls); NexusWalls = getResources().getString(R.string.section_nexus_walls); OriginalWalls = getResources().getString(R.string.section_original_walls); PapuhWalls = getResources().getString(R.string.section_papuh_walls); SolidsWalls = getResources().getString(R.string.section_solids_walls); StarsWalls = getResources().getString(R.string.section_stars_walls); RomCategory = getResources().getString(R.string.section_rom_category); AicpWalls = getResources().getString(R.string.section_aicp_walls); BrokenOsWalls = getResources().getString(R.string.section_brokenos_walls); CandyWalls = getResources().getString(R.string.section_candy_walls); DuWalls = getResources().getString(R.string.section_du_walls); EosWalls = getResources().getString(R.string.section_eos_walls); LiquidsmoothWalls = getResources().getString(R.string.section_liquidsmooth_walls); OmniWalls = getResources().getString(R.string.section_omni_walls); OrionWalls = getResources().getString(R.string.section_orion_walls); PaWalls = getResources().getString(R.string.section_pa_walls); PacromWalls = getResources().getString(R.string.section_pacrom_walls); RrWalls = getResources().getString(R.string.section_rr_walls); SlimWalls = getResources().getString(R.string.section_slim_walls); TeslaWalls = getResources().getString(R.string.section_tesla_walls); TwistedAOSPWalls = getResources().getString(R.string.section_twistedaosp_walls); ValidusWalls = getResources().getString(R.string.section_validus_walls); Settings = getResources().getString(R.string.settings); LiveWallpaper = getResources().getString(R.string.live_wallpaper_description); MuzeiSettings = getResources().getString(R.string.muzei_settings); AboutApp = getResources().getString(R.string.section_aboutapp); currentItem = 1; final IProfile profile = new ProfileDrawerItem().withName("Alex Cruz aka Mazda") .withIcon(getResources().getDrawable(R.drawable.alexcruz)).withIdentifier(1); int header = Calendar.getInstance().get(Calendar.HOUR_OF_DAY); if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(getString(R.string.time_context_headers), false)) { if (header < TIME_SUNRISE || header >= TIME_NIGHT) { if (PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(getString(R.string.poly_time_context_headers), false)) { header = R.drawable.poly_night; } else { header = R.drawable.night; } } else if (header >= TIME_SUNRISE && header < TIME_MORNING) { if (PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(getString(R.string.poly_time_context_headers), false)) { header = R.drawable.poly_sunrise; } else { header = R.drawable.sunrise; } } else if (header >= TIME_MORNING && header < TIME_NOON) { if (PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(getString(R.string.poly_time_context_headers), false)) { header = R.drawable.poly_morning; } else { header = R.drawable.morning; } } else if (header >= TIME_NOON && header < TIME_AFTERNOON) { if (PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(getString(R.string.poly_time_context_headers), false)) { header = R.drawable.poly_noon; } else { header = R.drawable.noon; } } else if (header >= TIME_AFTERNOON && header < TIME_SUNSET) { if (PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(getString(R.string.poly_time_context_headers), false)) { header = R.drawable.poly_afternoon; } else { header = R.drawable.afternoon; } } else if (header >= TIME_SUNSET && header < TIME_NIGHT) { if (PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(getString(R.string.poly_time_context_headers), false)) { header = R.drawable.poly_sunset; } else { header = R.drawable.sunset; } } } else { header = R.drawable.header; } String versionName; try { versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; } catch (Exception e) { throw new RuntimeException(e); } headerResult = new AccountHeaderBuilder().withActivity(this).withHeaderBackground(header) .withSelectionFirstLine(getResources().getString(R.string.app_long_name)) .withSelectionSecondLine("v" + versionName).withSelectionListEnabledForSingleProfile(false) .addProfiles(profile).withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() { @Override public boolean onProfileChanged(View view, IProfile profile, boolean current) { if (profile instanceof IDrawerItem && ((IDrawerItem) profile).getIdentifier() == PROFILE_SETTING) { int count = 100 + headerResult.getProfiles().size() + 1; if (headerResult.getProfiles() != null) { Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { getResources().getString(R.string.email_address) }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getText(R.string.artsource_name)); emailIntent.setType("plain/text"); startActivity(Intent.createChooser(emailIntent, "Contact Alex")); } else { headerResult.addProfiles(profile); } } return false; } }).withSavedInstance(savedInstanceState).build(); result = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(headerResult) .withHeader(R.layout.header).withSavedInstance(savedInstanceState).withScrollToTopAfterClick(true) .withFooterDivider(true).withSliderBackgroundColor(Preferences.Drawer()) .withStatusBarColor( Preferences.StatusBarTint() ? tint(Preferences.Theme(), 0.8) : Preferences.Theme()) .addDrawerItems( new PrimaryDrawerItem().withName(Home).withIcon(R.drawable.ic_home) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(1), new PrimaryDrawerItem().withName(AllWalls).withIcon(R.drawable.ic_allwalls) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(2).withBadge("1630+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(AndroidWalls).withIcon(R.drawable.ic_android) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(3).withBadge("17+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(BwWalls).withIcon(R.drawable.ic_bw) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(4).withBadge("56+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(BlurWalls).withIcon(R.drawable.ic_blur) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(5).withBadge("10+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(CloudsWalls).withIcon(R.drawable.ic_clouds) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(6).withBadge("60+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(MiscWalls).withIcon(R.drawable.ic_misc) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(7).withBadge("41+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(MustachesWalls).withIcon(R.drawable.ic_mustaches) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(8).withBadge("10+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(NexusWalls).withIcon(R.drawable.ic_nexus) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(9).withBadge("98+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(OriginalWalls).withIcon(R.drawable.ic_original) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(10).withBadge("343+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(PapuhWalls).withIcon(R.drawable.ic_papuh) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(11).withBadge("24+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(SolidsWalls).withIcon(R.drawable.ic_solids) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(12).withBadge("72+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(StarsWalls).withIcon(R.drawable.ic_stars) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(13).withBadge("11+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new SectionDrawerItem().withName(RomCategory).withTypeface(Typeface.DEFAULT_BOLD) .withTextColor(Preferences.DrawerText()), new PrimaryDrawerItem().withName(AicpWalls).withIcon(R.drawable.ic_aicp) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(15).withBadge("84+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(BrokenOsWalls).withIcon(R.drawable.ic_brokenos) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(16).withBadge("53+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(CandyWalls).withIcon(R.drawable.ic_candy) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(17).withBadge("80+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(DuWalls).withIcon(R.drawable.ic_dirtyunicorns) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(18).withBadge("139+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(EosWalls).withIcon(R.drawable.ic_eos) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(19).withBadge("48+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(LiquidsmoothWalls).withIcon(R.drawable.ic_liquidsmooth) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(20).withBadge("65+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(OmniWalls).withIcon(R.drawable.ic_omni) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(21).withBadge("29+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(OrionWalls).withIcon(R.drawable.ic_orion) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(22).withBadge("10+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(PaWalls).withIcon(R.drawable.ic_pa) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(23).withBadge("10+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(PacromWalls).withIcon(R.drawable.ic_pacrom) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(24).withBadge("21+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(RrWalls).withIcon(R.drawable.ic_rr) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(25).withBadge("54+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(SlimWalls).withIcon(R.drawable.ic_slim) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(26).withBadge("8+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(TeslaWalls).withIcon(R.drawable.ic_tesla) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(27).withBadge("43+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(TwistedAOSPWalls).withIcon(R.drawable.ic_twistedaosp) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(28).withBadge("43+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new PrimaryDrawerItem().withName(ValidusWalls).withIcon(R.drawable.ic_validus) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(29).withBadge("258+") .withBadgeStyle(new BadgeStyle().withTextColor(Preferences.BadgeText()) .withColor(Preferences.BadgeBackground())), new DividerDrawerItem(), new SecondaryDrawerItem().withName(Settings).withIcon(R.drawable.ic_settings) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(30), new SecondaryDrawerItem().withName(LiveWallpaper) .withIcon(R.drawable.ic_device_now_wallpaper).withIconTintingEnabled(true) .withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(33), new SecondaryDrawerItem().withName(MuzeiSettings).withIcon(R.drawable.ic_muzei) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(31), new SecondaryDrawerItem().withName(AboutApp).withIcon(R.drawable.ic_about) .withIconTintingEnabled(true).withSelectedIconColor(Preferences.SelectedIcon()) .withIconColor(Preferences.NormalIcon()) .withSelectedTextColor(tint(Preferences.SelectedDrawerText(), 1.0)) .withSelectedColor(tint(Preferences.DrawerSelector(), 1.0)) .withTextColor(Preferences.DrawerText()).withIdentifier(32)) .withOnDrawerListener(new Drawer.OnDrawerListener() { @Override public void onDrawerOpened(View drawerView) { } @Override public void onDrawerClosed(View drawerView) { } @Override public void onDrawerSlide(View drawerView, float slideOffset) { } }).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { boolean isMuzeiInstalled = Preferences.isAppInstalled(context, "net.nurik.roman.muzei"); boolean isConnected = isConnected(MainActivity.this); if (drawerItem != null) { switch (drawerItem.getIdentifier()) { case 1: switchFragment(1, Home, "BaseActivity"); break; case 2: if (isConnected) { switchWalls(2, AllWalls, "AllWalls"); } else { showNotConnectedDialog(); } break; case 3: if (isConnected) { switchWalls(3, AndroidWalls, "AndroidWalls"); } else { showNotConnectedDialog(); } break; case 4: if (isConnected) { switchWalls(4, BwWalls, "BwWalls"); } else { showNotConnectedDialog(); } break; case 5: if (isConnected) { switchWalls(5, BlurWalls, "BlurWalls"); } else { showNotConnectedDialog(); } break; case 6: if (isConnected) { switchWalls(6, BwWalls, "CloudsWalls"); } else { showNotConnectedDialog(); } break; case 7: if (isConnected) { switchWalls(7, MiscWalls, "MiscWalls"); } else { showNotConnectedDialog(); } break; case 8: if (isConnected) { switchWalls(8, MustachesWalls, "MustachesWalls"); } else { showNotConnectedDialog(); } break; case 9: if (isConnected) { switchWalls(9, NexusWalls, "NexusWalls"); } else { showNotConnectedDialog(); } break; case 10: if (isConnected) { switchWalls(10, OriginalWalls, "OriginalWalls"); } else { showNotConnectedDialog(); } break; case 11: if (isConnected) { switchWalls(11, PapuhWalls, "PapuhWalls"); } else { showNotConnectedDialog(); } break; case 12: if (isConnected) { switchWalls(12, SolidsWalls, "SolidsWalls"); } else { showNotConnectedDialog(); } break; case 13: if (isConnected) { switchWalls(13, StarsWalls, "StarsWalls"); } else { showNotConnectedDialog(); } break; case 14: setTitle(R.string.section_rom_category); ; break; case 15: if (isConnected) { switchWalls(15, AicpWalls, "AicpWalls"); } else { showNotConnectedDialog(); } break; case 16: if (isConnected) { switchWalls(16, BrokenOsWalls, "BrokenOsWalls"); } else { showNotConnectedDialog(); } break; case 17: if (isConnected) { switchWalls(17, CandyWalls, "CandyWalls"); } else { showNotConnectedDialog(); } break; case 18: if (isConnected) { switchWalls(18, DuWalls, "DuWalls"); } else { showNotConnectedDialog(); } break; case 19: if (isConnected) { switchWalls(19, EosWalls, "EosWalls"); } else { showNotConnectedDialog(); } break; case 20: if (isConnected) { switchWalls(20, LiquidsmoothWalls, "LiquidsmoothWalls"); } else { showNotConnectedDialog(); } break; case 21: if (isConnected) { switchWalls(21, OmniWalls, "OmniWalls"); } else { showNotConnectedDialog(); } break; case 22: if (isConnected) { switchWalls(22, OrionWalls, "OrionWalls"); } else { showNotConnectedDialog(); } break; case 23: if (isConnected) { switchWalls(23, PaWalls, "PaWalls"); } else { showNotConnectedDialog(); } break; case 24: if (isConnected) { switchWalls(24, PacromWalls, "PacromWalls"); } else { showNotConnectedDialog(); } break; case 25: if (isConnected) { switchWalls(25, RrWalls, "RrWalls"); } else { showNotConnectedDialog(); } break; case 26: if (isConnected) { switchWalls(26, SlimWalls, "SlimWalls"); } else { showNotConnectedDialog(); } break; case 27: if (isConnected) { switchWalls(27, TeslaWalls, "TeslaWalls"); } else { showNotConnectedDialog(); } break; case 28: if (isConnected) { switchWalls(28, TwistedAOSPWalls, "TwistedAOSPWalls"); } else { showNotConnectedDialog(); } break; case 29: if (isConnected) { switchWalls(29, ValidusWalls, "ValidusWalls"); } else { showNotConnectedDialog(); } break; case 30: Intent SettingsIntent = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(SettingsIntent, 0); break; case 31: if (isMuzeiInstalled) { Intent launchMuzeiIntent = new Intent(MainActivity.this, Settings.class); startActivityForResult(launchMuzeiIntent, 0); } else { // Do absolutely NOTHING } break; case 32: switchFragment(32, AboutApp, "Credits"); break; case 33: Intent LWIntent = new Intent(MainActivity.this, com.alexcruz.papuhwalls.Live.Settings.class); startActivityForResult(LWIntent, 0); break; } } return false; } }).withOnDrawerItemLongClickListener(new Drawer.OnDrawerItemLongClickListener() { @Override public boolean onItemLongClick(View view, int position, IDrawerItem drawerItem) { if (drawerItem instanceof SecondaryDrawerItem) { } return false; } }).build(); result.setSelection(1, true); boolean isMuzeiInstalled = Preferences.isAppInstalled(context, "net.nurik.roman.muzei"); if (!isMuzeiInstalled) { result.removeItem(31); } else { // Do absolutely NOTHING } if (Preferences.getLiveWalls().size() == 0 & isConnected(this)) new SetupLW(this).execute(); }
From source file:com.jtechme.apphub.FDroidApp.java
public void sendViaBluetooth(Activity activity, int resultCode, String packageName) { if (resultCode == Activity.RESULT_CANCELED) return;//from w w w . j a v a2s . c o m String bluetoothPackageName = null; String className = null; boolean found = false; Intent sendBt = null; try { PackageManager pm = getPackageManager(); ApplicationInfo appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); sendBt = new Intent(Intent.ACTION_SEND); // The APK type is blocked by stock Android, so use zip // sendBt.setType("application/vnd.android.package-archive"); sendBt.setType("application/zip"); sendBt.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + appInfo.publicSourceDir)); // not all devices have the same Bluetooth Activities, so // let's find it for (ResolveInfo info : pm.queryIntentActivities(sendBt, 0)) { bluetoothPackageName = info.activityInfo.packageName; if ("com.android.bluetooth".equals(bluetoothPackageName) || "com.mediatek.bluetooth".equals(bluetoothPackageName)) { className = info.activityInfo.name; found = true; break; } } } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Could not get application info to send via bluetooth", e); found = false; } if (sendBt != null) { if (found) { sendBt.setClassName(bluetoothPackageName, className); activity.startActivity(sendBt); } else { Toast.makeText(this, R.string.bluetooth_activity_not_found, Toast.LENGTH_SHORT).show(); activity.startActivity(Intent.createChooser(sendBt, getString(R.string.choose_bt_send))); } } }
From source file:com.denel.facepatrol.MainActivity.java
public void ContactEdit(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Contact Information Feedback") .setMessage("You're about to edit and send personal information. " + "Please note that the current database will only reflect your modification" + " once the IT department verifies the change and the updated database" + " is synced to your device. \n \n Do you want to continue?") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent emailIntent = new Intent(Intent.ACTION_SENDTO); emailIntent.setData(Uri.parse("mailto:")); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "pkantue@gmail.com" }); // this email address will change emailIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); emailIntent.putExtra(Intent.EXTRA_SUBJECT, feedback_subject); emailIntent.putExtra(Intent.EXTRA_TEXT, feedback_body); startActivity(Intent.createChooser(emailIntent, "Send Email...")); }/*from www . jav a 2 s . c o m*/ }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); builder.show(); // exit the application //finish(); }
From source file:com.remobile.camera.CameraLauncher.java
/** * Get image from photo library./*from w ww . j a va 2 s . c om*/ * * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param srcType The album to get image from. * @param returnType Set the type of image to return. * @param encodingType */ // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do! // TODO: Images from kitkat filechooser not going into crop function public void getImage(int srcType, int returnType, int encodingType) { Intent intent = new Intent(); String title = GET_PICTURE; croppedUri = null; if (this.mediaType == PICTURE) { intent.setType("image/*"); if (this.allowEdit) { intent.setAction(Intent.ACTION_PICK); intent.putExtra("crop", "true"); if (targetWidth > 0) { intent.putExtra("outputX", targetWidth); } if (targetHeight > 0) { intent.putExtra("outputY", targetHeight); } if (targetHeight > 0 && targetWidth > 0 && targetWidth == targetHeight) { intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); } File photo = createCaptureFile(encodingType); croppedUri = Uri.fromFile(photo); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, croppedUri); } else { intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } } else if (this.mediaType == VIDEO) { intent.setType("video/*"); title = GET_VIDEO; intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } else if (this.mediaType == ALLMEDIA) { // I wanted to make the type 'image/*, video/*' but this does not work on all versions // of android so I had to go with the wildcard search. intent.setType("*/*"); title = GET_All; intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } if (this.cordova != null) { this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent, new String(title)), (srcType + 1) * 16 + returnType + 1); } }
From source file:com.apotheosis.acceleration.monitor.MainMenuActivity.java
private void setUpListView() { ListView lv = (ListView) findViewById(R.id.fileList); List<String> fileNames = FileUtilities.getFileList(); if (fileNames != null) { FileListAdapter listAdapter = new FileListAdapter(this); lv.setAdapter(listAdapter);/*from w ww . j a va 2 s .c om*/ lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.mainDrawerLayout); boolean isDrawerOpen = drawerLayout.isDrawerOpen(findViewById(R.id.side_drawer)); if (isDrawerOpen) drawerLayout.closeDrawers(); new LoadData(TimeXYZDataPackage.DataType.ACCELERATION, MainMenuActivity.this, parent.getAdapter().getItem(position).toString()).execute((Void[]) null); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) { final String fileName = parent.getAdapter().getItem(position).toString(); final AlertDialog.Builder optionsMenu = new AlertDialog.Builder(MainMenuActivity.this); optionsMenu.setItems(new String[] { "Open Acceleration Graph", "Open Raw Data", "Share Data", "Delete Data", "Cancel" }, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.mainDrawerLayout); boolean isDrawerOpen = drawerLayout .isDrawerOpen(findViewById(R.id.side_drawer)); Intent i; Tracker tracker; switch (which) { case 0: dialog.dismiss(); if (isDrawerOpen) drawerLayout.closeDrawers(); new LoadData(TimeXYZDataPackage.DataType.ACCELERATION, MainMenuActivity.this, fileName).execute((Void[]) null); break; case 1: if (isDrawerOpen) drawerLayout.closeDrawers(); new LoadData(TimeXYZDataPackage.DataType.RAW_DATA, MainMenuActivity.this, fileName).execute((Void[]) null); break; case 2: if (isDrawerOpen) drawerLayout.closeDrawers(); tracker = AnalyticsTrackers.getInstance().get(AnalyticsTrackers.Target.APP); tracker.send(new HitBuilders.EventBuilder().setCategory("Data Function") .setAction("Share Data").build()); i = new Intent(Intent.ACTION_SEND); i.setType("text/xml"); i.putExtra(Intent.EXTRA_SUBJECT, "Sending " + fileName + "as attachment"); i.putExtra(Intent.EXTRA_TEXT, fileName + "is attached."); File f = new File(FileUtilities.path + fileName + ".csv"); i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f)); startActivity(Intent.createChooser(i, "Choose an application...")); break; case 3: final AlertDialog.Builder confirmDelete = new AlertDialog.Builder( MainMenuActivity.this); confirmDelete .setMessage("Are you sure you want to delete " + fileName + "?"); confirmDelete.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { File f = new File(FileUtilities.path + fileName + ".csv"); Log.d("DELETION_SUCESS", String.valueOf(f.delete())); setUpListView(); } }); confirmDelete.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); confirmDelete.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); } }); confirmDelete.show(); break; } } }); optionsMenu.show(); return true; } }); } }
From source file:com.androidinspain.deskclock.stopwatch.StopwatchFragment.java
/** * Send stopwatch time and lap times to an external sharing application. *///from ww w .j a v a2s. c o m private void doShare() { // Disable the fab buttons to avoid double-taps on the share button. updateFab(BUTTONS_DISABLE); final String[] subjects = getResources().getStringArray(R.array.sw_share_strings); final String subject = subjects[(int) (Math.random() * subjects.length)]; final String text = mLapsAdapter.getShareText(); @SuppressLint("InlinedApi") @SuppressWarnings("deprecation") final Intent shareIntent = new Intent(Intent.ACTION_SEND) .addFlags(Utils.isLOrLater() ? Intent.FLAG_ACTIVITY_NEW_DOCUMENT : Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) .putExtra(Intent.EXTRA_SUBJECT, subject).putExtra(Intent.EXTRA_TEXT, text).setType("text/plain"); final Context context = getActivity(); final String title = context.getString(R.string.sw_share_button); final Intent shareChooserIntent = Intent.createChooser(shareIntent, title); try { context.startActivity(shareChooserIntent); } catch (ActivityNotFoundException anfe) { LogUtils.e("Cannot share lap data because no suitable receiving Activity exists"); updateFab(BUTTONS_IMMEDIATE); } }
From source file:com.ibuildapp.romanblack.WebPlugin.WebPlugin.java
@Override public void create() { try {//ww w .java2 s . c o m setContentView(R.layout.romanblack_html_main); root = (FrameLayout) findViewById(R.id.romanblack_root_layout); webView = new ObservableWebView(this); webView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); root.addView(webView); webView.setHorizontalScrollBarEnabled(false); setTitle("HTML"); Intent currentIntent = getIntent(); Bundle store = currentIntent.getExtras(); widget = (Widget) store.getSerializable("Widget"); if (widget == null) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } appName = widget.getAppName(); if (widget.getPluginXmlData().length() == 0) { if (currentIntent.getStringExtra("WidgetFile").length() == 0) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } } if (widget.getTitle() != null && widget.getTitle().length() > 0) { setTopBarTitle(widget.getTitle()); } else { setTopBarTitle(getResources().getString(R.string.romanblack_html_web)); } currentUrl = (String) getSession(); if (currentUrl == null) { currentUrl = ""; } ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null && ni.isConnectedOrConnecting()) { isOnline = true; } // topbar initialization setTopBarLeftButtonText(getString(R.string.common_home_upper), true, new View.OnClickListener() { @Override public void onClick(View view) { onBackPressed(); } }); if (isOnline) { webView.getSettings().setJavaScriptEnabled(true); } webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.getSettings().setGeolocationEnabled(true); webView.getSettings().setAllowFileAccess(true); webView.getSettings().setAppCacheEnabled(true); webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setUseWideViewPort(false); webView.getSettings().setSavePassword(false); webView.clearHistory(); webView.invalidate(); if (Build.VERSION.SDK_INT >= 19) { } webView.getSettings().setUserAgentString( "Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; Nexus One Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"); webView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.invalidate(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { } break; case MotionEvent.ACTION_UP: { if (!v.hasFocus()) { v.requestFocus(); } } break; case MotionEvent.ACTION_MOVE: { } break; } return false; } }); webView.setBackgroundColor(Color.WHITE); try { if (widget.getBackgroundColor() != Color.TRANSPARENT) { webView.setBackgroundColor(widget.getBackgroundColor()); } } catch (IllegalArgumentException e) { } webView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); } }); webView.setWebChromeClient(new WebChromeClient() { FrameLayout.LayoutParams LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); @Override public void onGeolocationPermissionsShowPrompt(final String origin, final GeolocationPermissions.Callback callback) { AlertDialog.Builder builder = new AlertDialog.Builder(WebPlugin.this); builder.setTitle(R.string.location_dialog_title); builder.setMessage(R.string.location_dialog_description); builder.setCancelable(true); builder.setPositiveButton(R.string.location_dialog_allow, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { callback.invoke(origin, true, false); } }); builder.setNegativeButton(R.string.location_dialog_not_allow, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { callback.invoke(origin, false, false); } }); AlertDialog alert = builder.create(); alert.show(); } @Override public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { if (customView != null) { customViewCallback.onCustomViewHidden(); return; } view.setBackgroundColor(Color.BLACK); view.setLayoutParams(LayoutParameters); root.addView(view); customView = view; customViewCallback = callback; webView.setVisibility(View.GONE); } @Override public void onHideCustomView() { if (customView == null) { return; } else { closeFullScreenVideo(); } } public void openFileChooser(ValueCallback<Uri> uploadMsg) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT);//Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); isMedia = true; startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } // For Android 3.0+ public void openFileChooser(ValueCallback uploadMsg, String acceptType) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE); } //For Android 4.1 public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); isMedia = true; i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } @Override public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { isV21 = true; mUploadMessageV21 = filePathCallback; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); return true; } @Override public void onReceivedTouchIconUrl(WebView view, String url, boolean precomposed) { super.onReceivedTouchIconUrl(view, url, precomposed); } }); webView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); if (state == states.EMPTY) { currentUrl = url; setSession(currentUrl); state = states.LOAD_START; handler.sendEmptyMessage(SHOW_PROGRESS); } } @Override public void onLoadResource(WebView view, String url) { if (!alreadyLoaded && (url.startsWith("http://www.youtube.com/get_video_info?") || url.startsWith("https://www.youtube.com/get_video_info?")) && Build.VERSION.SDK_INT < 11) { try { String path = url.contains("https://www.youtube.com/get_video_info?") ? url.replace("https://www.youtube.com/get_video_info?", "") : url.replace("http://www.youtube.com/get_video_info?", ""); String[] parqamValuePairs = path.split("&"); String videoId = null; for (String pair : parqamValuePairs) { if (pair.startsWith("video_id")) { videoId = pair.split("=")[1]; break; } } if (videoId != null) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com")) .setData(Uri.parse("http://www.youtube.com/watch?v=" + videoId))); needRefresh = true; alreadyLoaded = !alreadyLoaded; return; } } catch (Exception ex) { } } else { super.onLoadResource(view, url); } } @Override public void onPageFinished(WebView view, String url) { if (hideProgress) { if (TextUtils.isEmpty(WebPlugin.this.url)) { state = states.LOAD_COMPLETE; handler.sendEmptyMessage(HIDE_PROGRESS); super.onPageFinished(view, url); } else { view.loadUrl("javascript:(function(){" + "l=document.getElementById('link');" + "e=document.createEvent('HTMLEvents');" + "e.initEvent('click',true,true);" + "l.dispatchEvent(e);" + "})()"); hideProgress = false; } } else { state = states.LOAD_COMPLETE; handler.sendEmptyMessage(HIDE_PROGRESS); super.onPageFinished(view, url); } } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { if (errorCode == WebViewClient.ERROR_BAD_URL) { startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), DOWNLOAD_REQUEST_CODE); } } @Override public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) { final AlertDialog.Builder builder = new AlertDialog.Builder(WebPlugin.this); builder.setMessage(R.string.notification_error_ssl_cert_invalid); builder.setPositiveButton(WebPlugin.this.getResources().getString(R.string.wp_continue), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.proceed(); } }); builder.setNegativeButton(WebPlugin.this.getResources().getString(R.string.wp_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.cancel(); } }); final AlertDialog dialog = builder.create(); dialog.show(); } @Override public void onFormResubmission(WebView view, Message dontResend, Message resend) { super.onFormResubmission(view, dontResend, resend); } @Override public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { return super.shouldInterceptRequest(view, request); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { try { if (url.contains("youtube.com/watch")) { if (Build.VERSION.SDK_INT < 11) { try { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com")) .setData(Uri.parse(url))); return true; } catch (Exception ex) { return false; } } else { return false; } } else if (url.contains("paypal.com")) { if (url.contains("&bn=ibuildapp_SP")) { return false; } else { url = url + "&bn=ibuildapp_SP"; webView.loadUrl(url); return true; } } else if (url.contains("sms:")) { try { Intent smsIntent = new Intent(Intent.ACTION_VIEW); smsIntent.setData(Uri.parse(url)); startActivity(smsIntent); return true; } catch (Exception ex) { Log.e("", ex.getMessage()); return false; } } else if (url.contains("tel:")) { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse(url)); startActivity(callIntent); return true; } else if (url.contains("mailto:")) { MailTo mailTo = MailTo.parse(url); Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { mailTo.getTo() }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mailTo.getSubject()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, mailTo.getBody()); WebPlugin.this.startActivity(Intent.createChooser(emailIntent, getString(R.string.romanblack_html_send_email))); return true; } else if (url.contains("rtsp:")) { Uri address = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, address); final PackageManager pm = getPackageManager(); final List<ResolveInfo> matches = pm.queryIntentActivities(intent, 0); if (matches.size() > 0) { startActivity(intent); } else { Toast.makeText(WebPlugin.this, getString(R.string.romanblack_html_no_video_player), Toast.LENGTH_SHORT).show(); } return true; } else if (url.startsWith("intent:") || url.startsWith("market:") || url.startsWith("col-g2m-2:")) { Intent it = new Intent(); it.setData(Uri.parse(url)); startActivity(it); return true; } else if (url.contains("//play.google.com/")) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } else { if (url.contains("ibuildapp.com-1915109")) { String param = Uri.parse(url).getQueryParameter("widget"); finish(); if (param != null && param.equals("1001")) com.appbuilder.sdk.android.Statics.launchMain(); else if (param != null && !"".equals(param)) { View.OnClickListener widget = Statics.linkWidgets.get(Integer.valueOf(param)); if (widget != null) widget.onClick(view); } return false; } currentUrl = url; setSession(currentUrl); if (!isOnline) { handler.sendEmptyMessage(HIDE_PROGRESS); handler.sendEmptyMessage(STOP_LOADING); } else { String pageType = "application/html"; if (!url.contains("vk.com")) { getPageType(url); } if (pageType.contains("application") && !pageType.contains("html") && !pageType.contains("xml")) { startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), DOWNLOAD_REQUEST_CODE); return super.shouldOverrideUrlLoading(view, url); } else { view.getSettings().setLoadWithOverviewMode(true); view.getSettings().setUseWideViewPort(true); view.setBackgroundColor(Color.WHITE); } } return false; } } catch (Exception ex) { // Error Logging return false; } } }); handler.sendEmptyMessage(SHOW_PROGRESS); new Thread() { @Override public void run() { EntityParser parser; if (widget.getPluginXmlData() != null) { if (widget.getPluginXmlData().length() > 0) { parser = new EntityParser(widget.getPluginXmlData()); } else { String xmlData = readXmlFromFile(getIntent().getStringExtra("WidgetFile")); parser = new EntityParser(xmlData); } } else { String xmlData = readXmlFromFile(getIntent().getStringExtra("WidgetFile")); parser = new EntityParser(xmlData); } parser.parse(); url = parser.getUrl(); html = parser.getHtml(); if (url.length() > 0 && !isOnline) { handler.sendEmptyMessage(NEED_INTERNET_CONNECTION); } else { if (isOnline) { } else { if (html.length() == 0) { } } if (html.length() > 0 || url.length() > 0) { handler.sendEmptyMessageDelayed(SHOW_HTML, 700); } else { handler.sendEmptyMessage(HIDE_PROGRESS); handler.sendEmptyMessage(INITIALIZATION_FAILED); } } } }.start(); } catch (Exception ex) { } }
From source file:com.android.music.AlbumBrowserActivity.java
void doSearch() { CharSequence title = null;/* w ww .jav a 2s.c o m*/ String query = ""; Intent i = new Intent(); i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); title = ""; if (!mIsUnknownAlbum) { query = mCurrentAlbumName; i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, mCurrentAlbumName); title = mCurrentAlbumName; } if (!mIsUnknownArtist) { query = query + " " + mCurrentArtistNameForAlbum; i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, mCurrentArtistNameForAlbum); title = title + " " + mCurrentArtistNameForAlbum; } // Since we hide the 'search' menu item when both album and artist are // unknown, the query and title strings will have at least one of those. i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, MediaStore.Audio.Albums.ENTRY_CONTENT_TYPE); title = getString(R.string.mediasearch, title); i.putExtra(SearchManager.QUERY, query); startActivity(Intent.createChooser(i, title)); }
From source file:org.sirimangalo.meditationplus.ActivityMain.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); Intent i;/* w w w.j a v a2 s . c o m*/ switch (id) { case R.id.action_htm: Utils.openHTM(this); return true; case R.id.action_refresh: listVersion = -1; chatVersion = -1; restartTimer = true; ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair("full_update", "true")); doSubmit(null, nvp, true); return true; case R.id.action_profile: showProfile(username); return true; case R.id.action_schedule: i = new Intent(this, ActivitySchedule.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); return true; case R.id.action_settings: i = new Intent(this, ActivityPrefs.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); return true; case R.id.action_help: i = new Intent(this, ActivityHelp.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); return true; case R.id.action_share: String playStoreLink = "https://play.google.com/store/apps/details?id=" + getPackageName(); String yourShareText = playStoreLink; Intent shareIntent = ShareCompat.IntentBuilder.from(this).setType("text/plain").setText(yourShareText) .setSubject("Meditation Plus").getIntent(); // Set the share Intent startActivity(Intent.createChooser(shareIntent, "Share App via")); return true; } return super.onOptionsItemSelected(item); }