Skip to content

Commit

Permalink
List of included changes:
Browse files Browse the repository at this point in the history
  - Internal change
  - Update all mlkit_samples and tests' target version to 30 to catch bugs caused by potential framework changes.

PiperOrigin-RevId: 363307017
Change-Id: I66cbf30abab22ff99da561682177d697209b6975
  • Loading branch information
Google ML Kit authored and jackqdyulei committed Mar 17, 2021
1 parent ed3d39c commit 6a4f10c
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 87 deletions.
13 changes: 9 additions & 4 deletions android/internal/chooserx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {

defaultConfig {
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"

Expand All @@ -14,6 +14,11 @@ android {
}

buildTypes {
proguard {
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard.cfg'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Expand All @@ -23,7 +28,7 @@ android {
}

dependencies {
api 'com.google.android.material:material:1.2.0'
api 'androidx.recyclerview:recyclerview:1.1.0'
api 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}
15 changes: 0 additions & 15 deletions android/internal/chooserx/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2020 Google LLC. All rights reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<manifest package="com.mlkit.example.internal">
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,22 @@
package com.mlkit.example.internal;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public abstract class BaseEntryChoiceActivity extends AppCompatActivity {

private RecyclerView mRecycler;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_entry_choice);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_entry_choice);

mRecycler = findViewById(R.id.choices_recycler);
mRecycler.setLayoutManager(new LinearLayoutManager(this));
mRecycler.setAdapter(new ChoiceAdapter(this, getChoices()));
}
RecyclerView recyclerView = findViewById(R.id.choices_recycler);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(new ChoiceAdapter(this, getChoices()));
}

protected abstract List<Choice> getChoices();
protected abstract List<Choice> getChoices();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@

public class Choice {

public final String title;
public final String description;
public final Intent launchIntent;

public Choice(String title, String description, Intent launchIntent) {
this.title = title;
this.description = description;
this.launchIntent = launchIntent;
}
public final String title;
public final String description;
public final Intent launchIntent;

public Choice(String title, String description, Intent launchIntent) {
this.title = title;
this.description = description;
this.launchIntent = launchIntent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,69 +17,67 @@
package com.mlkit.example.internal;

import android.app.Activity;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class ChoiceAdapter extends RecyclerView.Adapter<ChoiceAdapter.ViewHolder> {

private final Activity activity;
private List<Choice> choices;

public ChoiceAdapter(Activity activity, List<Choice> choices) {
this.activity = activity;
this.choices = choices;
}
private final Activity activity;
private final List<Choice> choices;

@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_choice, parent, false);
return new ViewHolder(view);
}
public ChoiceAdapter(Activity activity, List<Choice> choices) {
this.activity = activity;
this.choices = choices;
}

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
Choice choice = choices.get(position);
holder.bind(choice);
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_choice, parent, false);
return new ViewHolder(view);
}

@Override
public int getItemCount() {
return choices.size();
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
Choice choice = choices.get(position);
holder.bind(choice);
}

public class ViewHolder extends RecyclerView.ViewHolder {
@Override
public int getItemCount() {
return choices.size();
}

private final TextView titleText;
private final TextView descText;
private final Button launchButton;
public class ViewHolder extends RecyclerView.ViewHolder {

public ViewHolder(View itemView) {
super(itemView);
titleText = itemView.findViewById(R.id.item_title);
descText = itemView.findViewById(R.id.item_description);
launchButton = itemView.findViewById(R.id.item_launch_button);
}
private final TextView titleText;
private final TextView descText;
private final Button launchButton;

public void bind(final Choice choice) {
titleText.setText(choice.title);
descText.setText(choice.description);
launchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.startActivity(choice.launchIntent);
}
});
}
public ViewHolder(View itemView) {
super(itemView);
titleText = itemView.findViewById(R.id.item_title);
descText = itemView.findViewById(R.id.item_description);
launchButton = itemView.findViewById(R.id.item_launch_button);
}

public void bind(final Choice choice) {
titleText.setText(choice.title);
descText.setText(choice.description);
launchButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.startActivity(choice.launchIntent);
}
});
}
}
}

0 comments on commit 6a4f10c

Please sign in to comment.