This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (1) Defer to the support actionbar | |
// Set the toolbar to be the support actionbar of an AppCompatActivity | |
// ... | |
setSupportActionBar(find(R.id.toolbar)) | |
with(supportActionBar!!) { | |
setDisplayHomeAsUpEnabled(true) | |
setDisplayShowHomeEnabled(true) | |
} | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface ClickHandler { | |
static void handleClick(@NonNull View view, View.OnClickListener listener) { | |
view.setOnClickListener(listener); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; |
NewerOlder