Commit 6d3d271e authored by Alexandre Lision's avatar Alexandre Lision Committed by Romain B.
Browse files

butterknife

Integrating Butterknife to avoid boiler plate code due to views
munipulations such as findViewById or setOnClickListener. This integration
could be done across the entire application in the futur.

Change-Id: I918af7e9de848c46dc99cb39bd6f5ff0574f35b1
Tuleap: #816
parent 73ddf2f7
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
repositories {
jcenter()
......@@ -19,6 +20,8 @@ dependencies {
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'com.google.zxing:core:3.2.1'
compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
compile 'com.jakewharton:butterknife:8.1.0'
apt 'com.jakewharton:butterknife-compiler:8.1.0'
}
android {
......
......@@ -32,12 +32,21 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cx.ring.BuildConfig;
import cx.ring.R;
import cx.ring.client.HomeActivity;
public class AboutFragment extends Fragment {
@BindView(R.id.app_release)
TextView mRelease;
@BindView(R.id.licence)
TextView mLicence;
@Override
public void onResume() {
super.onResume();
......@@ -47,31 +56,32 @@ public class AboutFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
final View inflatedView = inflater.inflate(R.layout.frag_about, parent, false);
ButterKnife.bind(this, inflatedView);
TextView release = (TextView) inflatedView.findViewById(R.id.app_release);
release.setText(getString(R.string.app_release, BuildConfig.VERSION_NAME));
mRelease.setText(getString(R.string.app_release, BuildConfig.VERSION_NAME));
mLicence.setMovementMethod(LinkMovementMethod.getInstance());
TextView licence = (TextView) inflatedView.findViewById(R.id.licence);
licence.setMovementMethod(LinkMovementMethod.getInstance());
return inflatedView;
}
inflatedView.findViewById(R.id.email_report_container).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + "mobile@lists.savoirfairelinux.net"));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "[Ring Android - " + BuildConfig.VERSION_NAME + "]");
@OnClick(R.id.email_report_container)
@SuppressWarnings("unused")
public void sendFeedbackEmail() {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + "mobile@lists.savoirfairelinux.net"));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "[Ring Android - " + BuildConfig.VERSION_NAME + "]");
// Check if an app can handle this intent
boolean isResolvable = getActivity().getPackageManager().queryIntentActivities(emailIntent,
PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
// Check if an app can handle this intent
boolean isResolvable = getActivity().getPackageManager().queryIntentActivities(emailIntent,
PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
if (isResolvable)
startActivity(Intent.createChooser(emailIntent, getString(R.string.email_chooser_title)));
else
Snackbar.make(inflatedView, R.string.no_email_app_installed, Snackbar.LENGTH_SHORT).show();
if (isResolvable) {
startActivity(Intent.createChooser(emailIntent, getString(R.string.email_chooser_title)));
} else {
View view = getView();
if (view != null) {
Snackbar.make(view, R.string.no_email_app_installed, Snackbar.LENGTH_SHORT)
.show();
}
});
return inflatedView;
}
}
}
......@@ -4,7 +4,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment