Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit 0720353

Browse files
committed
after androidx
1 parent 324584a commit 0720353

File tree

12 files changed

+64
-62
lines changed

12 files changed

+64
-62
lines changed

.idea/kotlinc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'kotlin-android'
44

55
android {
66
compileSdkVersion 29
7-
buildToolsVersion "29.0.0"
7+
buildToolsVersion "29.0.2"
88
defaultConfig {
99
applicationId "co.huggingface.android_transformers"
1010
minSdkVersion 26
@@ -26,6 +26,9 @@ android {
2626
sourceCompatibility JavaVersion.VERSION_1_8
2727
targetCompatibility JavaVersion.VERSION_1_8
2828
}
29+
kotlinOptions {
30+
jvmTarget = JavaVersion.VERSION_1_8
31+
}
2932
// If you find lint problem like:
3033
// * What went wrong:
3134
// A problem was found with the configuration of task ':app:lint'.
@@ -44,12 +47,12 @@ apply from: 'download.gradle'
4447
dependencies {
4548
implementation fileTree(dir: 'libs', include: ['*.jar'])
4649

47-
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
48-
implementation 'com.android.support:appcompat-v7:28.0.0'
49-
implementation 'com.android.support:support-annotations:28.0.0'
50-
implementation 'com.android.support:support-v4:28.0.0'
51-
implementation 'com.android.support:recyclerview-v7:28.0.0'
52-
implementation 'com.android.support:design:28.0.0'
50+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
51+
implementation 'androidx.appcompat:appcompat:1.1.0'
52+
implementation 'androidx.annotation:annotation:1.1.0'
53+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
54+
implementation 'androidx.recyclerview:recyclerview:1.1.0'
55+
implementation 'com.google.android.material:material:1.0.0'
5356

5457
implementation 'com.google.code.gson:gson:2.8.5'
5558
implementation 'com.google.guava:guava:28.1-android'

app/src/main/java/co/huggingface/android_transformers/bertqa/ml/QaClient.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import android.content.Context;
1818
import android.content.res.AssetFileDescriptor;
1919
import android.content.res.AssetManager;
20-
import android.support.annotation.WorkerThread;
20+
import androidx.annotation.WorkerThread;
2121
import android.util.Log;
2222
import com.google.common.base.Joiner;
2323
import java.io.BufferedReader;
@@ -35,8 +35,6 @@
3535
import java.util.Map;
3636
import org.tensorflow.lite.Interpreter;
3737

38-
import co.huggingface.android_transformers.gpt2.tokenization.GPT2Tokenizer;
39-
4038
/** Interface to load TfLite model and provide predictions. */
4139
public class QaClient {
4240
private static final String TAG = "BertDemo";
@@ -63,7 +61,6 @@ public class QaClient {
6361
public QaClient(Context context) {
6462
this.context = context;
6563
this.featureConverter = new FeatureConverter(dic, DO_LOWER_CASE, MAX_QUERY_LEN, MAX_SEQ_LEN);
66-
GPT2Tokenizer t = new GPT2Tokenizer(context);
6764
}
6865

6966
@WorkerThread

app/src/main/java/co/huggingface/android_transformers/bertqa/ui/DatasetListActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package co.huggingface.android_transformers.bertqa.ui;
1616

1717
import android.os.Bundle;
18-
import android.support.v7.app.AppCompatActivity;
18+
import androidx.appcompat.app.AppCompatActivity;
1919
import android.widget.ArrayAdapter;
2020
import android.widget.ListView;
2121
import co.huggingface.android_transformers.R;

app/src/main/java/co/huggingface/android_transformers/bertqa/ui/QaActivity.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import android.os.Handler;
2121
import android.os.HandlerThread;
2222
import android.speech.tts.TextToSpeech;
23-
import android.support.v7.app.AppCompatActivity;
24-
import android.support.v7.widget.LinearLayoutManager;
25-
import android.support.v7.widget.RecyclerView;
23+
import androidx.appcompat.app.AppCompatActivity;
24+
import androidx.recyclerview.widget.LinearLayoutManager;
25+
import androidx.recyclerview.widget.RecyclerView;
2626
import android.text.Editable;
2727
import android.text.Spannable;
2828
import android.text.SpannableString;
@@ -35,8 +35,8 @@
3535
import android.view.inputmethod.InputMethodManager;
3636
import android.widget.ImageButton;
3737
import android.widget.TextView;
38-
import android.support.design.widget.Snackbar;
39-
import android.support.design.widget.TextInputEditText;
38+
import com.google.android.material.snackbar.Snackbar;
39+
import com.google.android.material.textfield.TextInputEditText;
4040
import java.util.List;
4141
import java.util.Locale;
4242
import co.huggingface.android_transformers.R;
@@ -210,7 +210,7 @@ private void answerQuestion(String question) {
210210
questionAnswered = false;
211211

212212
Snackbar runningSnackbar =
213-
Snackbar.make(contentTextView, "Looking up answer...", Integer.MAX_VALUE);
213+
Snackbar.make(contentTextView, "Looking up answer...", Snackbar.LENGTH_INDEFINITE);
214214
runningSnackbar.show();
215215

216216
// Run TF Lite model to get the answer.

app/src/main/java/co/huggingface/android_transformers/bertqa/ui/QuestionAdapter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
package co.huggingface.android_transformers.bertqa.ui;
1616

1717
import android.content.Context;
18-
import android.support.annotation.NonNull;
19-
import android.support.v7.widget.RecyclerView;
18+
import androidx.annotation.NonNull;
19+
import androidx.recyclerview.widget.RecyclerView;
2020
import android.view.LayoutInflater;
2121
import android.view.View;
2222
import android.view.ViewGroup;
23-
import android.support.design.chip.Chip;
23+
import com.google.android.material.chip.Chip;
2424
import co.huggingface.android_transformers.R;
2525

2626
/** Adapter class to show question suggestion chips. */

app/src/main/res/layout/activity_dataset_list.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.design.widget.CoordinatorLayout
2+
<androidx.coordinatorlayout.widget.CoordinatorLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:tools="http://schemas.android.com/tools"
55
xmlns:app="http://schemas.android.com/apk/res-auto"
66
android:layout_width="match_parent"
77
android:layout_height="match_parent">
88

9-
<android.support.design.widget.AppBarLayout
9+
<com.google.android.material.appbar.AppBarLayout
1010
android:layout_width="match_parent"
1111
android:layout_height="80dp">
1212

@@ -38,14 +38,14 @@
3838

3939
</LinearLayout>
4040

41-
</android.support.design.widget.AppBarLayout>
41+
</com.google.android.material.appbar.AppBarLayout>
4242

43-
<android.support.constraint.ConstraintLayout
43+
<androidx.constraintlayout.widget.ConstraintLayout
4444
android:layout_width="match_parent"
4545
android:layout_height="match_parent"
46-
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">
46+
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
4747

48-
<android.support.constraint.ConstraintLayout
48+
<androidx.constraintlayout.widget.ConstraintLayout
4949
android:layout_width="0dp"
5050
android:layout_height="0dp"
5151
android:fitsSystemWindows="true"
@@ -81,8 +81,8 @@
8181
app:layout_constraintTop_toBottomOf="@+id/hint_text_view"
8282
app:layout_constraintVertical_bias="0.0" />
8383

84-
</android.support.constraint.ConstraintLayout>
84+
</androidx.constraintlayout.widget.ConstraintLayout>
8585

86-
</android.support.constraint.ConstraintLayout>
86+
</androidx.constraintlayout.widget.ConstraintLayout>
8787

88-
</android.support.design.widget.CoordinatorLayout>
88+
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
77
tools:context=".gpt2.ui.GPT2Activity">
88

9-
<android.support.design.widget.AppBarLayout
9+
<com.google.android.material.appbar.AppBarLayout
1010
android:layout_width="match_parent"
1111
android:layout_height="wrap_content"
1212
android:theme="@style/AppTheme.AppBarOverlay">
1313

14-
<android.support.v7.widget.Toolbar
14+
<androidx.appcompat.widget.Toolbar
1515
android:id="@+id/toolbar"
1616
android:layout_width="match_parent"
1717
android:layout_height="?attr/actionBarSize"
1818
android:background="?attr/colorPrimary"
1919
app:popupTheme="@style/AppTheme.PopupOverlay" />
2020

21-
</android.support.design.widget.AppBarLayout>
21+
</com.google.android.material.appbar.AppBarLayout>
2222

2323
<include layout="@layout/content_gpt2" />
2424

25-
<android.support.design.widget.FloatingActionButton
25+
<com.google.android.material.floatingactionbutton.FloatingActionButton
2626
android:id="@+id/fab"
2727
android:layout_width="wrap_content"
2828
android:layout_height="wrap_content"
2929
android:layout_gravity="bottom|end"
3030
android:layout_margin="@dimen/fab_margin"
3131
app:srcCompat="@android:drawable/ic_dialog_email" />
3232

33-
</android.support.design.widget.CoordinatorLayout>
33+
</androidx.coordinatorlayout.widget.CoordinatorLayout>

app/src/main/res/layout/activity_qa.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.constraint.ConstraintLayout
2+
<androidx.constraintlayout.widget.ConstraintLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:tools="http://schemas.android.com/tools"
55
xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -16,7 +16,7 @@
1616
android:text="Here is the title of article"
1717
android:textStyle="bold"/>
1818

19-
<android.support.design.widget.CoordinatorLayout
19+
<androidx.coordinatorlayout.widget.CoordinatorLayout
2020
android:layout_width="match_parent"
2121
android:layout_height="0dp"
2222
app:layout_constraintTop_toBottomOf="@id/title_text"
@@ -28,9 +28,9 @@
2828
android:padding="@dimen/standard_margin"
2929
android:scrollbars="vertical"
3030
android:text="This is the content of the article."/>
31-
</android.support.design.widget.CoordinatorLayout>
31+
</androidx.coordinatorlayout.widget.CoordinatorLayout>
3232

33-
<android.support.constraint.ConstraintLayout
33+
<androidx.constraintlayout.widget.ConstraintLayout
3434
android:id="@+id/footer_view"
3535
android:layout_width="match_parent"
3636
android:layout_height="wrap_content"
@@ -46,13 +46,13 @@
4646
app:layout_constraintTop_toTopOf="parent"
4747
android:text="@string/you_might_want_to_ask"/>
4848

49-
<android.support.v7.widget.RecyclerView
49+
<androidx.recyclerview.widget.RecyclerView
5050
android:id="@+id/suggestion_list"
5151
android:layout_width="match_parent"
5252
android:layout_height="wrap_content"
5353
app:layout_constraintTop_toBottomOf="@id/suggestion_text"/>
5454

55-
<android.support.design.widget.TextInputLayout
55+
<com.google.android.material.textfield.TextInputLayout
5656
android:id="@+id/text_input_layout"
5757
android:layout_width="0dp"
5858
android:layout_height="wrap_content"
@@ -62,14 +62,14 @@
6262
app:layout_constraintLeft_toLeftOf="parent"
6363
android:hint="@string/text_query">
6464

65-
<android.support.design.widget.TextInputEditText
65+
<com.google.android.material.textfield.TextInputEditText
6666
android:id="@+id/question_edit_text"
6767
android:layout_width="match_parent"
6868
android:layout_height="wrap_content"
6969
android:inputType="text"
7070
android:maxLines="3"/>
7171

72-
</android.support.design.widget.TextInputLayout>
72+
</com.google.android.material.textfield.TextInputLayout>
7373

7474
<ImageButton
7575
android:id="@+id/ask_button"
@@ -84,6 +84,6 @@
8484
android:background="?attr/selectableItemBackgroundBorderless"
8585
android:contentDescription="@string/ask_question" />
8686

87-
</android.support.constraint.ConstraintLayout>
87+
</androidx.constraintlayout.widget.ConstraintLayout>
8888

89-
</android.support.constraint.ConstraintLayout>
89+
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
@@ -8,4 +8,4 @@
88
tools:context=".gpt2.ui.GPT2Activity"
99
tools:showIn="@layout/activity_gpt2">
1010

11-
</android.support.constraint.ConstraintLayout>
11+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)