- Why does this org exist?
- Why not shut down, cash out and sell off assets?
- Start with the end in mind
- States the purpose of the org's existence
- Narrow focus
- Clear and to the point
- Realistic, feasible and achievable
| package com.automattic.simplenote; | |
| import android.content.ActivityNotFoundException; | |
| import android.content.Context; | |
| import android.content.Intent; | |
| import android.net.Uri; | |
| import android.os.Bundle; | |
| import android.os.Handler; | |
| import android.text.Html; | |
| import android.text.method.LinkMovementMethod; |
| private void handleViewClicks(View view) { | |
| ClickHandler.handleClick(view.findViewById(R.id.about_blog), v -> | |
| browseOrToastOnError(view.getContext(), SIMPLENOTE_BLOG_URL)); | |
| ClickHandler.handleClick(view.findViewById(R.id.about_help), v -> | |
| browseOrToastOnError(view.getContext(), SIMPLENOTE_HELP_URL)); | |
| ClickHandler.handleClick(view.findViewById(R.id.about_contribute), v -> | |
| browseOrToastOnError(view.getContext(), URL_CONTRIBUTE)); |
| @Nullable | |
| @Override | |
| public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |
| View view = inflater.inflate(R.layout.fragment_about, container, false); | |
| return setupViews(view); | |
| } | |
| private View setupViews(View view) { | |
| setVersionAndCopyrightText(view); | |
| handleViewClicks(view); |
| ClickHandler.handleClick( | |
| view.findViewById(R.id.about_privacy), | |
| Html.fromHtml(String.format( | |
| getResources().getString(R.string.link_privacy), | |
| "<u><span style=\"color:#", | |
| colorLink, | |
| "\">", | |
| "</span></u>")), | |
| v -> browseOrToastOnError(view.getContext(), URL_PRIVACY) | |
| ); |
| interface ClickHandler { | |
| static void handleClick(@NonNull View view, View.OnClickListener listener) { | |
| view.setOnClickListener(listener); | |
| } | |
| static void handleClick(@NonNull TextView view, CharSequence text, View.OnClickListener listener) { | |
| view.setText(text); | |
| view.setOnClickListener(listener); | |
| } | |
| } |
| ClickHandler.handleClick(view.findViewById(R.id.about_blog), v -> | |
| browseOrToastOnError(view.getContext(), SIMPLENOTE_BLOG_URL)); | |
| private void browseOrToastOnError(Context context, String url) { | |
| browseOrToastOnError(context, url, R.string.no_browser_available); | |
| } | |
| private void browseOrToastOnError(Context context, String url, @StringRes int stringRes) { | |
| try { | |
| BrowserUtils.launchBrowserOrShowError(requireContext(), url); |
| ClickHandler.handleClick(view.findViewById(R.id.about_blog), v -> { | |
| try { | |
| BrowserUtils.launchBrowserOrShowError(requireContext(), SIMPLENOTE_BLOG_URL); | |
| } catch (Exception e) { | |
| Toast.makeText(getActivity(), R.string.no_browser_available, Toast.LENGTH_LONG).show(); | |
| } | |
| }); |
| interface ClickHandler { | |
| static void handleClick(@NonNull View view, View.OnClickListener listener) { | |
| view.setOnClickListener(listener); | |
| } | |
| } |
| @Override | |
| public void track(AnalyticsTracker.Stat stat, String category, String label, Map<String, ?> properties) { | |
| if (mNosaraClient == null) { | |
| return; | |
| } | |
| String eventName = stat.name().toLowerCase(); | |
| final String user; | |
| final TracksClient.NosaraUserType userType; |