Skip to content

Commit

Permalink
Merge pull request #618 from ooni/issues/1709/final
Browse files Browse the repository at this point in the history
Chore: Remove remaining references to `butterknife`
  • Loading branch information
aanorbel authored Oct 6, 2023
2 parents eca92d2 + c82bad7 commit 1972bf1
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 55 deletions.
1 change: 0 additions & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Terms: https://firebase.google.com/terms/

- easypermissions
- LocalhostToolkit
- butterknife
- DBFlow
- LocalhostToolkit
- MarkdownView
3 changes: 0 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ dependencies {
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'


implementation 'com.jakewharton:butterknife:10.2.3'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'

implementation 'com.github.xanscale.LocalhostToolkit:app:19.05.01'
implementation 'com.airbnb.android:lottie:3.0.7'
implementation 'com.google.code.gson:gson:2.8.9'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.content.ContextCompat;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.snackbar.Snackbar;

import org.openobservatory.ooniprobe.R;
Expand All @@ -38,8 +37,6 @@

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import localhost.toolkit.app.fragment.ConfirmDialogFragment;

public class MainActivity extends AbstractActivity implements ConfirmDialogFragment.OnConfirmedListener {
Expand Down Expand Up @@ -71,7 +68,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
finish();
}
else {
ButterKnife.bind(this);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
binding.bottomNavigation.setOnItemSelectedListener(item -> {
Expand Down
18 changes: 7 additions & 11 deletions app/src/main/java/org/openobservatory/ooniprobe/item/DateItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@

import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import org.openobservatory.ooniprobe.R;
import org.openobservatory.ooniprobe.databinding.ItemDateBinding;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import butterknife.BindView;
import butterknife.ButterKnife;
import localhost.toolkit.widget.recyclerview.HeterogeneousRecyclerItem;

public class DateItem extends HeterogeneousRecyclerItem<Date, DateItem.ViewHolder> {
Expand All @@ -27,19 +23,19 @@ public DateItem(Date extra) {
}

@Override public ViewHolder onCreateViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new ViewHolder(layoutInflater.inflate(R.layout.item_date, viewGroup, false));
return new ViewHolder(ItemDateBinding.inflate(layoutInflater, viewGroup, false));
}

@Override public void onBindViewHolder(ViewHolder viewHolder) {
viewHolder.textView.setText(SDF.format(extra));
viewHolder.binding.textView.setText(SDF.format(extra));
}

class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.textView) TextView textView;
ItemDateBinding binding;

ViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
ViewHolder(ItemDateBinding binding) {
super(binding.getRoot());
this.binding = binding;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;

import org.openobservatory.ooniprobe.R;
import org.openobservatory.ooniprobe.databinding.ItemFailedBinding;
import org.openobservatory.ooniprobe.model.database.Result;

import java.util.Locale;

import butterknife.BindView;
import butterknife.ButterKnife;
import localhost.toolkit.widget.recyclerview.HeterogeneousRecyclerItem;

public class FailedItem extends HeterogeneousRecyclerItem<Result, FailedItem.ViewHolder> {
Expand All @@ -30,33 +27,30 @@ public FailedItem(Result extra, View.OnClickListener onClickListener, View.OnLon
}

@Override public ViewHolder onCreateViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new ViewHolder(layoutInflater.inflate(R.layout.item_failed, viewGroup, false));
return new ViewHolder(ItemFailedBinding.inflate(layoutInflater, viewGroup, false));
}

@Override public void onBindViewHolder(ViewHolder viewHolder) {
viewHolder.itemView.setTag(extra);
viewHolder.itemView.setOnClickListener(onClickListener);
viewHolder.itemView.setOnLongClickListener(onLongClickListener);
viewHolder.itemView.setBackgroundColor(ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.color_gray2));
viewHolder.testName.setTextColor(ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.color_gray6));
viewHolder.icon.setImageResource(extra.getTestSuite().getIcon());
viewHolder.testName.setText(extra.getTestSuite().getTitle());
viewHolder.binding.testName.setTextColor(ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.color_gray6));
viewHolder.binding.icon.setImageResource(extra.getTestSuite().getIcon());
viewHolder.binding.testName.setText(extra.getTestSuite().getTitle());
String failure_msg = viewHolder.itemView.getContext().getString(R.string.TestResults_Overview_Error);
if (extra.failure_msg != null)
failure_msg += " - " + extra.failure_msg;
viewHolder.subtitle.setText(failure_msg);
viewHolder.startTime.setText(DateFormat.format(DateFormat.getBestDateTimePattern(Locale.getDefault(), "yMdHm"), extra.start_time));
viewHolder.binding.subtitle.setText(failure_msg);
viewHolder.binding.startTime.setText(DateFormat.format(DateFormat.getBestDateTimePattern(Locale.getDefault(), "yMdHm"), extra.start_time));
}

class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.testName) TextView testName;
@BindView(R.id.subtitle) TextView subtitle;
@BindView(R.id.startTime) TextView startTime;
@BindView(R.id.icon) ImageView icon;

ViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
ItemFailedBinding binding;

ViewHolder(ItemFailedBinding binding) {
super(binding.getRoot());
this.binding = binding;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package org.openobservatory.ooniprobe.item;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.RecyclerView;

import org.openobservatory.ooniprobe.R;
import org.openobservatory.ooniprobe.databinding.ItemSeperatorBinding;

import butterknife.ButterKnife;
import localhost.toolkit.widget.recyclerview.HeterogeneousRecyclerItem;

public class SeperatorItem extends HeterogeneousRecyclerItem<String, SeperatorItem.ViewHolderImpl> {
Expand All @@ -18,15 +16,14 @@ public SeperatorItem() {
}

@Override public ViewHolderImpl onCreateViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new ViewHolderImpl(layoutInflater.inflate(R.layout.item_seperator, viewGroup, false));
return new ViewHolderImpl(ItemSeperatorBinding.inflate(layoutInflater, viewGroup, false));
}

@Override public void onBindViewHolder(ViewHolderImpl holder) {}

static class ViewHolderImpl extends RecyclerView.ViewHolder {
ViewHolderImpl(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
ViewHolderImpl(ItemSeperatorBinding binding) {
super(binding.getRoot());
}
}
}
Expand Down
18 changes: 7 additions & 11 deletions app/src/main/java/org/openobservatory/ooniprobe/item/TextItem.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package org.openobservatory.ooniprobe.item;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import org.openobservatory.ooniprobe.R;
import org.openobservatory.ooniprobe.databinding.ItemTextBinding;

import butterknife.BindView;
import butterknife.ButterKnife;
import localhost.toolkit.widget.recyclerview.HeterogeneousRecyclerItem;

public class TextItem extends HeterogeneousRecyclerItem<String, TextItem.ViewHolder> {
Expand All @@ -19,19 +15,19 @@ public TextItem(String extra) {
}

@Override public ViewHolder onCreateViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new ViewHolder(layoutInflater.inflate(R.layout.item_text, viewGroup, false));
return new ViewHolder(ItemTextBinding.inflate(layoutInflater, viewGroup, false));
}

@Override public void onBindViewHolder(ViewHolder viewHolder) {
viewHolder.textView.setText(extra);
viewHolder.binding.textView.setText(extra);
}

class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.textView) TextView textView;
ItemTextBinding binding;

ViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
ViewHolder(ItemTextBinding binding) {
super(binding.getRoot());
this.binding = binding;
}
}
}

0 comments on commit 1972bf1

Please sign in to comment.