List of usage examples for android.content ActivityNotFoundException printStackTrace
public void printStackTrace()
From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActivity.java
private void requestPickImage() { // gallery? image . try {//from w w w. jav a 2 s . c om Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT); galleryIntent.setType("image/*"); startActivityForResult(galleryIntent, REQUEST_CODE_ATTACH_IMAGE); } catch (ActivityNotFoundException e) { e.printStackTrace(); } }
From source file:com.amaze.carbonfilemanager.fragments.MainFragment.java
public static void launchSMB(final SmbFile smbFile, final long si, final Activity activity) { final Streamer s = Streamer.getInstance(); new Thread() { public void run() { try { /*/*from www . j a va2 s . c o m*/ List<SmbFile> subtitleFiles = new ArrayList<SmbFile>(); // finding subtitles for (Layoutelements layoutelement : LIST_ELEMENTS) { SmbFile smbFile = new SmbFile(layoutelement.getDesc()); if (smbFile.getName().contains(smbFile.getName())) subtitleFiles.add(smbFile); } */ s.setStreamSrc(smbFile, si); activity.runOnUiThread(new Runnable() { public void run() { try { Uri uri = Uri.parse(Streamer.URL + Uri.fromFile(new File(Uri.parse(smbFile.getPath()).getPath())) .getEncodedPath()); Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(uri, MimeTypes.getMimeType(new File(smbFile.getPath()))); PackageManager packageManager = activity.getPackageManager(); List<ResolveInfo> resInfos = packageManager.queryIntentActivities(i, 0); if (resInfos != null && resInfos.size() > 0) activity.startActivity(i); else Toast.makeText(activity, activity.getResources().getString(R.string.smb_launch_error), Toast.LENGTH_SHORT).show(); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } }); } catch (Exception e) { e.printStackTrace(); } } }.start(); }
From source file:com.ibuildapp.romanblack.MultiContactsPlugin.ContactDetailsActivity.java
@Override public void create() { try {/* w w w . java2 s. co m*/ setContentView(R.layout.grouped_contacts_details); Intent currentIntent = getIntent(); Bundle store = currentIntent.getExtras(); widget = (Widget) store.getSerializable("Widget"); if (widget == null) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } person = (Person) store.getSerializable("person"); if (person == null) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } setTopBarTitle(widget.getTitle()); Boolean single = currentIntent.getBooleanExtra("single", true); setTopBarLeftButtonTextAndColor( single ? getResources().getString(R.string.common_home_upper) : getResources().getString(R.string.common_back_upper), getResources().getColor(android.R.color.black), true, new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); setTopBarTitleColor(getResources().getColor(android.R.color.black)); setTopBarBackgroundColor(Statics.color1); if ((Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL))) || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS))) || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))) { ImageView shareButton = (ImageView) getLayoutInflater() .inflate(R.layout.grouped_contacts_share_button, null); shareButton.setLayoutParams( new LinearLayout.LayoutParams((int) (29 * getResources().getDisplayMetrics().density), (int) (39 * getResources().getDisplayMetrics().density))); shareButton.setColorFilter(Color.BLACK); setTopBarRightButton(shareButton, getString(R.string.multicontacts_list_share), new View.OnClickListener() { @Override public void onClick(View v) { DialogSharing.Configuration.Builder sharingDialogBuilder = new DialogSharing.Configuration.Builder(); if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL))) sharingDialogBuilder .setEmailSharingClickListener(new DialogSharing.Item.OnClickListener() { @Override public void onClick() { String message = getContactInfo(); Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_TEXT, message); email.setType("message/rfc822"); startActivity(Intent.createChooser(email, getString(R.string.choose_email_client))); } }); if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS))) sharingDialogBuilder .setSmsSharingClickListener(new DialogSharing.Item.OnClickListener() { @Override public void onClick() { String message = getContactInfo(); try { Utils.sendSms(ContactDetailsActivity.this, message); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } }); if (Boolean.TRUE.equals(widget.getParameter(PARAM_ADD_CONTACT))) sharingDialogBuilder.addCustomListener(R.string.multicontacts_add_to_phonebook, R.drawable.gc_add_to_contacts, true, new DialogSharing.Item.OnClickListener() { @Override public void onClick() { createNewContact(person.getName(), person.getPhone(), person.getEmail()); } }); showDialogSharing(sharingDialogBuilder.build()); } }); } boolean hasSchema = store.getBoolean("hasschema"); cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder(); contacts = person.getContacts(); if (widget.getTitle().length() > 0) { setTitle(widget.getTitle()); } root = (LinearLayout) findViewById(R.id.grouped_contacts_details_root); if (hasSchema) { root.setBackgroundColor(Statics.color1); } else if (widget.isBackgroundURL()) { cacheBackgroundFile = cachePath + "/" + Utils.md5(widget.getBackgroundURL()); File backgroundFile = new File(cacheBackgroundFile); if (backgroundFile.exists()) { root.setBackgroundDrawable( new BitmapDrawable(BitmapFactory.decodeStream(new FileInputStream(backgroundFile)))); } else { BackgroundDownloadTask dt = new BackgroundDownloadTask(); dt.execute(widget.getBackgroundURL()); } } else if (widget.isBackgroundInAssets()) { AssetManager am = this.getAssets(); root.setBackgroundDrawable(new BitmapDrawable(am.open(widget.getBackgroundURL()))); } if (contacts != null) { ImageView avatarImage = (ImageView) findViewById(R.id.grouped_contacts_details_avatar); avatarImage.setImageResource(R.drawable.gc_profile_avatar); if (person.hasAvatar() && NetworkUtils.isOnline(this)) { avatarImage.setVisibility(View.VISIBLE); Glide.with(this).load(person.getAvatarUrl()).placeholder(R.drawable.gc_profile_avatar) .dontAnimate().into(avatarImage); } else { avatarImage.setVisibility(View.VISIBLE); avatarImage.setImageResource(R.drawable.gc_profile_avatar); } String name = ""; neededContacts = new ArrayList<>(); for (Contact con : contacts) { if ((con.getType() == 5) || (con.getDescription().length() == 0)) { } else { if (con.getType() == 0) { name = con.getDescription(); } else neededContacts.add(con); } } if (neededContacts.isEmpty()) { handler.sendEmptyMessage(THERE_IS_NO_CONTACT_DATA); return; } headSeparator = findViewById(R.id.gc_head_separator); bottomSeparator = findViewById(R.id.gc_bottom_separator); imageBottom = findViewById(R.id.gc_image_bottom_layout); personName = (TextView) findViewById(R.id.gc_details_description); if ("".equals(name)) personName.setVisibility(View.GONE); else { personName.setVisibility(View.VISIBLE); personName.setText(name); personName.setTextColor(Statics.color3); } if (Statics.isLight) { headSeparator.setBackgroundColor(Color.parseColor("#4d000000")); bottomSeparator.setBackgroundColor(Color.parseColor("#4d000000")); } else { headSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF")); bottomSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF")); } ViewUtils.setBackgroundLikeHeader(imageBottom, Statics.color1); ListView list = (ListView) findViewById(R.id.grouped_contacts_details_list_view); list.setDivider(null); ContactDetailsAdapter adapter = new ContactDetailsAdapter(ContactDetailsActivity.this, R.layout.grouped_contacts_details_item, neededContacts, isChemeDark(Statics.color1)); list.setAdapter(adapter); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int position, long id) { listViewItemClick(position); } }); } if (widget.hasParameter("add_contact")) { HashMap<String, String> hm = new HashMap<>(); for (int i = 0; i < contacts.size(); i++) { switch (contacts.get(i).getType()) { case 0: { hm.put("contactName", contacts.get(i).getDescription()); } break; case 1: { hm.put("contactNumber", contacts.get(i).getDescription()); } break; case 2: { hm.put("contactEmail", contacts.get(i).getDescription()); } break; case 3: { hm.put("contactSite", contacts.get(i).getDescription()); } break; } } addNativeFeature(NATIVE_FEATURES.ADD_CONTACT, null, hm); } if (widget.hasParameter("send_sms")) { HashMap<String, String> hm = new HashMap<>(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < contacts.size(); i++) { sb.append(contacts.get(i).getDescription()); if (i < contacts.size() - 1) { sb.append(", "); } } hm.put("text", sb.toString()); addNativeFeature(NATIVE_FEATURES.SMS, null, hm); } if (widget.hasParameter("send_mail")) { HashMap<String, CharSequence> hm = new HashMap<>(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < contacts.size(); i++) { switch (contacts.get(i).getType()) { case 0: { sb.append("Name: "); } break; case 1: { sb.append("Phone: "); } break; case 2: { sb.append("Email: "); } break; case 3: { sb.append("Site: "); } break; case 4: { sb.append("Address: "); } break; } sb.append(contacts.get(i).getDescription()); sb.append("<br/>"); } if (widget.isHaveAdvertisement()) { sb.append("<br>\n (sent from <a href=\"http://ibuildapp.com\">iBuildApp</a>)"); } hm.put("text", sb.toString()); hm.put("subject", "Contacts"); addNativeFeature(NATIVE_FEATURES.EMAIL, null, hm); } } catch (Exception e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); } }
From source file:com.amaze.carbonfilemanager.utils.files.Futils.java
public void openunknown(DocumentFile f, Context c, boolean forcechooser) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); String type = f.getType();//w w w .ja va 2 s. c o m if (type != null && type.trim().length() != 0 && !type.equals("*/*")) { intent.setDataAndType(f.getUri(), type); Intent startintent; if (forcechooser) startintent = Intent.createChooser(intent, c.getResources().getString(R.string.openwith)); else startintent = intent; try { c.startActivity(startintent); } catch (ActivityNotFoundException e) { e.printStackTrace(); Toast.makeText(c, R.string.noappfound, Toast.LENGTH_SHORT).show(); openWith(f, c); } } else { openWith(f, c); } }
From source file:org.geometerplus.android.fbreader.FBReader.java
@Override public void processException(Exception exception) { exception.printStackTrace();/*ww w . j a v a2 s.c om*/ final Intent intent = new Intent(FBReaderIntents.Action.ERROR, new Uri.Builder().scheme(exception.getClass().getSimpleName()).build()); intent.setPackage(FBReaderIntents.DEFAULT_PACKAGE); intent.putExtra(ErrorKeys.MESSAGE, exception.getMessage()); final StringWriter stackTrace = new StringWriter(); exception.printStackTrace(new PrintWriter(stackTrace)); intent.putExtra(ErrorKeys.STACKTRACE, stackTrace.toString()); /* if (exception instanceof BookReadingException) { final ZLFile file = ((BookReadingException)exception).File; if (file != null) { intent.putExtra("file", file.getPath()); } } */ try { startActivity(intent); } catch (ActivityNotFoundException e) { // ignore e.printStackTrace(); } }
From source file:org.geometerplus.android.fbreader.FBReader.java
@Override protected void onNewIntent(final Intent intent) { final String action = intent.getAction(); final Uri data = intent.getData(); if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) { super.onNewIntent(intent); } else if (Intent.ACTION_VIEW.equals(action) && data != null && "fbreader-action".equals(data.getScheme())) { myFBReaderApp.runAction(data.getEncodedSchemeSpecificPart(), data.getFragment()); } else if (Intent.ACTION_VIEW.equals(action) || FBReaderIntents.Action.VIEW.equals(action)) { myOpenBookIntent = intent;/*from w w w . j a v a 2 s. c o m*/ if (myFBReaderApp.Model == null && myFBReaderApp.ExternalBook != null) { final ExternalFormatPlugin plugin = (ExternalFormatPlugin) myFBReaderApp.ExternalBook .getPluginOrNull(); try { startActivity(PluginUtil.createIntent(plugin, PluginUtil.ACTION_KILL)); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } } else if (FBReaderIntents.Action.PLUGIN.equals(action)) { new RunPluginAction(this, myFBReaderApp, data).run(); } else if (Intent.ACTION_SEARCH.equals(action)) { final String pattern = intent.getStringExtra(SearchManager.QUERY); final Runnable runnable = new Runnable() { public void run() { final TextSearchPopup popup = (TextSearchPopup) myFBReaderApp.getPopupById(TextSearchPopup.ID); popup.initPosition(); myFBReaderApp.MiscOptions.TextSearchPattern.setValue(pattern); if (myFBReaderApp.getTextView().search(pattern, true, false, false, false) != 0) { runOnUiThread(new Runnable() { public void run() { myFBReaderApp.showPopup(popup.getId()); } }); } else { runOnUiThread(new Runnable() { public void run() { UIUtil.showErrorMessage(FBReader.this, "textNotFound"); popup.StartPosition = null; } }); } } }; UIUtil.wait("search", runnable, this); } else if (FBReaderIntents.Action.CLOSE.equals(intent.getAction())) { myCancelIntent = intent; myOpenBookIntent = null; } else if (FBReaderIntents.Action.PLUGIN_CRASH.equals(intent.getAction())) { final Book book = FBReaderIntents.getBookExtra(intent); myFBReaderApp.ExternalBook = null; myOpenBookIntent = null; getCollection().bindToService(this, new Runnable() { public void run() { Book b = myFBReaderApp.Collection.getRecentBook(0); if (b.equals(book)) { b = myFBReaderApp.Collection.getRecentBook(1); } myFBReaderApp.openBook(b, null, null, FBReader.this); } }); } else { super.onNewIntent(intent); } }
From source file:com.gmail.boiledorange73.ut.map.MapActivityBase.java
private void onLocationServiceTimedout(boolean onlyPassive) { if (onlyPassive) { AlertDialogHelper.showConfirmationDialog(this, Messages.getString("P_LOCATION_PROVIDER_ERROR"), Messages.getString("P_CONFIRM_OPEN_LOACTIONPROVIDER_SETTINGS_ONLYPASSIVE"), android.R.drawable.ic_dialog_info, new DialogInterface.OnClickListener() { @Override// w ww . java2 s . c o m public void onClick(final DialogInterface dialog, final int which) { try { startActivity(new Intent("android.settings.LOCATION_SOURCE_SETTINGS")); } catch (final ActivityNotFoundException e) { // DOES NOTHING e.printStackTrace(); } } }); } else { Toast.makeText(this, Messages.getString("P_MYLOCATION_NOTFOUND"), Toast.LENGTH_LONG).show(); } MapActivityBase.this.stopLocationService(); }
From source file:de.geeksfactory.opacclient.frontend.AccountEditActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayoutResource()); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); etLabel = (EditText) findViewById(R.id.etLabel); etName = (EditText) findViewById(R.id.etName); etPassword = (EditText) findViewById(R.id.etPassword); AccountDataSource data = new AccountDataSource(this); data.open();//from www . jav a 2 s.co m account = data.getAccount(getIntent().getLongExtra(EXTRA_ACCOUNT_ID, -1)); if (account == null) { finish(); return; } data.close(); if (account.getLabel().equals(getString(R.string.default_account_name))) { etLabel.setText(""); } else { etLabel.setText(account.getLabel()); } etName.setText(account.getName()); etPassword.setText(account.getPassword()); try { lib = ((OpacClient) getApplication()).getLibrary(account.getLibrary()); if (findViewById(R.id.tvCity) != null) { TextView tvCity = (TextView) findViewById(R.id.tvCity); tvCity.setText(lib.getDisplayName()); } if (lib.getReplacedBy() != null && findViewById(R.id.rlReplaced) != null) { findViewById(R.id.rlReplaced).setVisibility(View.VISIBLE); findViewById(R.id.ivReplacedStore).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + lib.getReplacedBy())); startActivity(i); } catch (ActivityNotFoundException e) { Log.i("play", "no market installed"); } } }); } else if (findViewById(R.id.rlReplaced) != null) { findViewById(R.id.rlReplaced).setVisibility(View.GONE); } try { if (!lib.getData().getString("baseurl").contains("https") && findViewById(R.id.no_ssl) != null && lib.isAccountSupported()) { findViewById(R.id.no_ssl).setVisibility(View.VISIBLE); } else if (findViewById(R.id.no_ssl) != null) { findViewById(R.id.no_ssl).setVisibility(View.GONE); } } catch (Exception e) { } } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { ErrorReporter.handleException(e); e.printStackTrace(); } }
From source file:com.gmail.boiledorange73.ut.map.MapActivityBase.java
/** * Starts location services and timer to stop after specfied time. * /* w w w . j a v a2s . c o m*/ * @see http://d.hatena.ne.jp/orangesignal/20101223/1293079002 */ private void startLocationService(boolean highaccuracy) { // this.stopLocationService(); this.mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (this.mLocationManager == null) { // this device has no location service. DOES NOTHING. return; } // gets active location providers. // if requires high accuracy, creates filtered provider list. List<String> providerList = this.mLocationManager.getProviders(true); if (highaccuracy) { ArrayList<String> candidateList = new ArrayList<String>(); if (providerList != null) { for (String providerName : providerList) { if (providerName != null) { LocationProvider provider = this.mLocationManager.getProvider(providerName); if (provider != null && provider.getAccuracy() == Criteria.ACCURACY_FINE) { candidateList.add(providerName); } } } } providerList = candidateList; } // checks whether at least one location provider is available. if (providerList == null || !(providerList.size() > 0)) { // Shows the dialog which let user to open system preference. AlertDialogHelper.showConfirmationDialog(this, Messages.getString("P_LOCATION_PROVIDER_ERROR"), Messages.getString("P_CONFIRM_OPEN_LOACTIONPROVIDER_SETTINGS"), android.R.drawable.ic_dialog_info, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { try { startActivity(new Intent("android.settings.LOCATION_SOURCE_SETTINGS")); } catch (final ActivityNotFoundException e) { // DOES NOTHING e.printStackTrace(); } } }); this.stopLocationService(); return; } // Starts timer. Checks whether timed out frequently, // and stops location services when specified time comes. final boolean onlyPassive = (providerList.size() == 1 && "passive".equals(providerList.get(0))); this.mLocationTimer = new Timer(true); this.mTimedOut = System.currentTimeMillis() + 30000L; final Handler handler = new Handler(); this.mToast = Toast.makeText(this, Messages.getString("P_MYLOCATION_FINDING"), Toast.LENGTH_SHORT); this.mToast.show(); this.mLocationTimer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { // Sends the procedure checks whether timed out. handler.post(new Runnable() { @Override public void run() { long current = System.currentTimeMillis(); if (current >= MapActivityBase.this.mTimedOut) { // timed out. MapActivityBase.this.onLocationServiceTimedout(onlyPassive); } else { // NOT timed out. Shows the TOAST. MapActivityBase.this.mToast.show(); } } }); } }, 0L, 1000L); // starts this.mLocationListener = new LocationListener() { @Override public void onLocationChanged(final Location location) { // New location got. Sends it to JS. setLocation(location, true); } @Override public void onProviderDisabled(final String provider) { // DOES NOTHING. } @Override public void onProviderEnabled(final String provider) { // DOES NOTHING. } @Override public void onStatusChanged(final String provider, final int status, final Bundle extras) { // DOES NOTHING. } }; for (String provider : providerList) { this.mLocationManager.requestLocationUpdates(provider, 0, 0, this.mLocationListener); } }
From source file:com.nbplus.vbroadlauncher.fragment.LauncherFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View v = inflater.inflate(R.layout.fragment_launcher, container, false); mMainViewLayout = (LinearLayout) v.findViewById(R.id.main_view_layout); // push agent ??. mPushServiceStatus = (ImageView) v.findViewById(R.id.ic_nav_wifi); if (((BaseActivity) getActivity()).isPushServiceConnected()) { mPushServiceStatus.setImageResource(R.drawable.ic_nav_wifi_on); } else {//from w w w . ja v a 2 s . c o m mPushServiceStatus.setImageResource(R.drawable.ic_nav_wifi_off); } mVillageName = (TextView) v.findViewById(R.id.launcher_village_name); mVillageName.setText(LauncherSettings.getInstance(getActivity()).getVillageName()); mApplicationsView = (LinearLayout) v.findViewById(R.id.ic_nav_apps); mApplicationsView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getActivity(), ShowApplicationActivity.class); startActivity(intent); getActivity().overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } }); mServiceTreeMap = (LinearLayout) v.findViewById(R.id.ic_nav_show_map); mServiceTreeMap.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!NetworkUtils.isConnected(getActivity())) { ((BaseActivity) getActivity()).showNetworkConnectionAlertDialog(); return; } Intent intent = new Intent(getActivity(), BroadcastWebViewActivity.class); ShortcutData data = new ShortcutData(Constants.SHORTCUT_TYPE_WEB_DOCUMENT_SERVER, R.string.btn_show_map, getActivity().getResources().getString(R.string.addr_show_map), R.drawable.ic_menu_04, R.drawable.ic_menu_shortcut_02_selector, 0, null); VBroadcastServer serverInfo = LauncherSettings.getInstance(getActivity()).getServerInformation(); data.setDomain(serverInfo.getDocServer()); intent.putExtra(Constants.EXTRA_NAME_SHORTCUT_DATA, data); startActivity(intent); } }); mOutdoorMode = (LinearLayout) v.findViewById(R.id.ic_nav_outdoor); mOutdoorText = (TextView) v.findViewById(R.id.tv_outdoor); if (LauncherSettings.getInstance(getActivity()).isOutdoorMode()) { mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_on)); mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_on, 0, 0, 0); } else { mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_off)); mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_off, 0, 0, 0); } mOutdoorMode.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast toast; boolean mode = false; if (LauncherSettings.getInstance(getActivity()).isOutdoorMode()) { LauncherSettings.getInstance(getActivity()).setIsOutdoorMode(false); mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_off, 0, 0, 0); mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_off)); toast = Toast.makeText(getActivity(), R.string.outdoor_mode_off, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.show(); } else { mode = true; LauncherSettings.getInstance(getActivity()).setIsOutdoorMode(true); mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_on)); mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_on, 0, 0, 0); toast = Toast.makeText(getActivity(), R.string.outdoor_mode_on, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.show(); } HomeLauncherApplication application = (HomeLauncherApplication) getActivity() .getApplicationContext(); if (application != null) { application.outdoorModeChanged(mode); } } }); // ?? ? mIoTDataSync = (LinearLayout) v.findViewById(R.id.ic_iot_data_sync); mIoTDataSyncText = (TextView) v.findViewById(R.id.tv_iot_data_sync); mIoTDataSync.setOnClickListener(mIoTSyncClickListener); mIoTDataSync.setClickable(true); mIoTDataSync.setEnabled(true); mTextClock = (TextClock) v.findViewById(R.id.text_clock); if (mTextClock != null) { mTextClock.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_APP_CALENDAR); startActivity(intent); getActivity().overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } catch (ActivityNotFoundException e) { e.printStackTrace(); AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setPositiveButton(R.string.alert_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent i = new Intent( android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS); i.addCategory(Intent.CATEGORY_DEFAULT); startActivity(i); } }); alert.setMessage(R.string.alert_calendar_not_found); alert.show(); } } }); } mWeatherView = (WeatherView) v.findViewById(R.id.weather_view); mMainViewLeftPanel = (LinearLayout) v.findViewById(R.id.main_view_left_panel); mMainViewRightPanel = (LinearLayout) v.findViewById(R.id.main_view_right_panel); LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // add main shortcut. ArrayList<ShortcutData> mainShortcutDatas = LauncherSettings.getInstance(getActivity()) .getLauncherMainShortcuts(); mMainShortcutGridLayout = (GridLayout) v.findViewById(R.id.main_shortcut_grid); float dp;// = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_width); // float widthPx = DisplayUtils.pxFromDp(getActivity(), dp); // // dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_height); // float heightPx = DisplayUtils.pxFromDp(getActivity(), dp); dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_font_size); float mainShortcutFontPx = DisplayUtils.pxFromDp(getActivity(), dp); for (int i = 0; i < mMainShortcutGridLayout.getColumnCount(); i++) { /** * right shortcut panel */ ShortcutData data = mainShortcutDatas.get(i); FrameLayout btnLayout = (FrameLayout) layoutInflater.inflate(R.layout.launcher_menu_top_item, mMainShortcutGridLayout, false);//new Button(getActivity()); mMainShortcutGridLayout.addView(btnLayout); if (data.getPushType() != null && data.getPushType().length > 0) { data.setLauncherButton(btnLayout); mPushNotifiableShorcuts.add(data); } btnLayout.setBackgroundResource(data.getIconBackResId()); // GridLayout.LayoutParams lp = (GridLayout.LayoutParams)btnLayout.getLayoutParams(); // lp.width = (int)widthPx; // lp.height = (int)heightPx; // btnLayout.setLayoutParams(lp); TextView label = (TextView) btnLayout.findViewById(R.id.menu_item_label); label.setText(data.getName()); label.setTextSize(TypedValue.COMPLEX_UNIT_PX, mainShortcutFontPx); label.setTextColor(getResources().getColor(R.color.white)); label.setTypeface(null, Typeface.BOLD); label.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); ImageView icon = (ImageView) btnLayout.findViewById(R.id.menu_item_image); icon.setImageResource(data.getIconResId()); btnLayout.setTag(data); btnLayout.setOnClickListener(this); } // add other shortcuts. mShorcutGridLayout = (GridLayout) v.findViewById(R.id.shortcut_grid); ArrayList<ShortcutData> shortcutDatas = LauncherSettings.getInstance(getActivity()).getLauncherShortcuts(); int columnNum = mShorcutGridLayout.getColumnCount(); final int MAX_ROW_NUM = 3; int shortcutNum = shortcutDatas.size() > (columnNum * MAX_ROW_NUM) ? (columnNum * MAX_ROW_NUM) : shortcutDatas.size(); dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_shortcut_font_size); float btnFontPx = DisplayUtils.pxFromDp(getActivity(), dp); for (int i = 0; i < shortcutNum; i++) { /** * right shortcut panel */ ShortcutData data = shortcutDatas.get(i); FrameLayout btnLayout = (FrameLayout) layoutInflater.inflate(R.layout.launcher_menu_item, mShorcutGridLayout, false);//new Button(getActivity()); mShorcutGridLayout.addView(btnLayout); if (data.getPushType() != null && data.getPushType().length > 0) { data.setLauncherButton(btnLayout); mPushNotifiableShorcuts.add(data); } btnLayout.setBackgroundResource(data.getIconBackResId()); TextView label = (TextView) btnLayout.findViewById(R.id.menu_item_label); label.setText(data.getName()); label.setTextSize(TypedValue.COMPLEX_UNIT_PX, btnFontPx); label.setTextColor(getResources().getColor(R.color.white)); label.setTypeface(null, Typeface.BOLD); label.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); ImageView icon = (ImageView) btnLayout.findViewById(R.id.menu_item_image); icon.setImageResource(data.getIconResId()); btnLayout.setTag(data); btnLayout.setOnClickListener(this); } setContentViewByOrientation(); return v; }