Skip to content

Commit

Permalink
Migracja do AndroidX. Podniesiono target na wersję 32 android sdk.
Browse files Browse the repository at this point in the history
  • Loading branch information
rutkowskit committed Aug 26, 2022
1 parent 1c36c6d commit d724358
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 118 deletions.
17 changes: 0 additions & 17 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
compileSdkVersion 32
defaultConfig {
applicationId "vrt.inpost.qr"
minSdkVersion 19
targetSdkVersion 27
targetSdkVersion 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionName "1.2"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
vectorDrawables.useSupportLibrary = true
}
buildTypes {
Expand All @@ -21,13 +21,13 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.zxing:core:3.2.1'
}
6 changes: 3 additions & 3 deletions app/src/main/java/vrt/inpost/qr/AppPrefsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;
import android.support.design.widget.TextInputLayout;
import androidx.annotation.NonNull;
import com.google.android.material.textfield.TextInputLayout;
import android.os.Bundle;
import android.text.InputType;
import android.text.method.DigitsKeyListener;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void onStopTrackingTouch(SeekBar seekBar) {}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
getMenuInflater().inflate(R.menu.menu_settings, menu);
return true;
}
Expand Down
107 changes: 43 additions & 64 deletions app/src/main/java/vrt/inpost/qr/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.telephony.TelephonyManager;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
Expand Down Expand Up @@ -87,13 +87,7 @@ private boolean hasPermission(String permission) {

private void registerSwipeRefresh() {
if (null != _swipe) {
_swipe.setOnRefreshListener(
new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
onRefreshSmsList(true);
}
}
_swipe.setOnRefreshListener(() -> onRefreshSmsList(true)
);
}
}
Expand All @@ -108,7 +102,7 @@ private void onRefreshSmsList(boolean forceRefresh) {
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
Expand Down Expand Up @@ -148,6 +142,7 @@ public void onRequestPermissionsResult(int requestCode,
Notify.Error(this, getString(R.string.msgAccessDeniedSmsRead));
}
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}

private void updateListView(List<SmsData> data) {
Expand All @@ -156,14 +151,10 @@ private void updateListView(List<SmsData> data) {
final SmsListAdapter adapter = new SmsListAdapter(this,data);
listview.setAdapter(adapter);

listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, final View view,
int position, long id) {
SmsData item = (SmsData) parent.getItemAtPosition(position);
String phoneNumber = getPhoneNumber(item);
showQrCode(phoneNumber, item.ReceptionCode);
}
listview.setOnItemClickListener((parent, view, position, id) -> {
SmsData item = (SmsData) parent.getItemAtPosition(position);
String phoneNumber = getPhoneNumber(item);
showQrCode(phoneNumber, item.ReceptionCode);
});
}

Expand Down Expand Up @@ -202,22 +193,19 @@ private void onGenerateManual() {
phoneField.setAdapter(adapter);
phoneField.setImeOptions(EditorInfo.IME_ACTION_NEXT);

createAlertDialog(promptsView, new OnAlertDialogClickListener() {
@Override
public boolean onOK(DialogInterface dialog) {
String phone = phoneField.getText().toString();
String code = codeField.getText().toString();
if(phone.length()!=9) {
Notify.Error(_context, getString(R.string.msgPhoneNumberTooShort));
return false;
}
if(code.length()!=6) {
Notify.Error(_context, getString(R.string.msgReceptionCodeTooShort));
return false;
}
showQrCode(phone, code);
return true;
createAlertDialog(promptsView, dialog -> {
String phone = phoneField.getText().toString();
String code = codeField.getText().toString();
if(phone.length()!=9) {
Notify.Error(_context, getString(R.string.msgPhoneNumberTooShort));
return false;
}
if(code.length()!=6) {
Notify.Error(_context, getString(R.string.msgReceptionCodeTooShort));
return false;
}
showQrCode(phone, code);
return true;
}).show();
}

Expand Down Expand Up @@ -251,20 +239,17 @@ private String getPhoneNumber(final SmsData sms) {
phoneField.setHint(String.format(_locale,
getString(R.string.formatEnterPhoneForSimInSlot), sms.SimSlot+1));

createAlertDialog(promptsView, new OnAlertDialogClickListener() {
@Override
public boolean onOK(DialogInterface dialog) {
String phone = phoneField.getText().toString();
if(phone.length()!=9) {
Notify.Error(_context, getString(R.string.msgPhoneNumberTooShort));
return false;
}
SharedPreferences.Editor editor = _prefPhones.edit();
editor.putString(key,phone );
editor.apply();
showQrCode(phone,sms.ReceptionCode);
return true;
createAlertDialog(promptsView, dialog -> {
String phone = phoneField.getText().toString();
if(phone.length()!=9) {
Notify.Error(_context, getString(R.string.msgPhoneNumberTooShort));
return false;
}
SharedPreferences.Editor editor = _prefPhones.edit();
editor.putString(key,phone );
editor.apply();
showQrCode(phone,sms.ReceptionCode);
return true;
}).show();

return null;
Expand All @@ -277,19 +262,13 @@ private AlertDialog createAlertDialog(View promptsView, final OnAlertDialogClick
.setNegativeButton(R.string.cancelLabel, null)
.create();

alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(final DialogInterface dialog) {

Button b = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(okListener.onOK(dialog))
dialog.dismiss();
}
});
}
alertDialog.setOnShowListener(dialog -> {

Button b = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
b.setOnClickListener(view -> {
if(okListener.onOK(dialog))
dialog.dismiss();
});
});
return alertDialog;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import android.util.AttributeSet;
import android.view.MotionEvent;

public class MyAutoCompleteTextView extends android.support.v7.widget.AppCompatAutoCompleteTextView {
public class MyAutoCompleteTextView extends androidx.appcompat.widget.AppCompatAutoCompleteTextView {

public MyAutoCompleteTextView(Context context) {
super(context);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/vrt/inpost/qr/Notify.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.support.design.widget.Snackbar;
import com.google.android.material.snackbar.Snackbar;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/vrt/inpost/qr/SmsListAdapter.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package vrt.inpost.qr;

import android.content.Context;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package vrt.inpost.qr;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.view.GestureDetector;
import android.view.MotionEvent;

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout-land/content_main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand Down Expand Up @@ -34,4 +34,4 @@
tools:layout_width="0dp" />


</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_app_prefs.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand Down Expand Up @@ -55,4 +55,4 @@
app:layout_constraintTop_toTopOf="parent" />


</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
9 changes: 4 additions & 5 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="vrt.inpost.qr.MainActivity">

<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand All @@ -22,5 +21,5 @@
android:listSelector="#fe0"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_qr_display.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand All @@ -24,4 +24,4 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand Down Expand Up @@ -30,4 +30,4 @@
tools:layout_width="0dp" />


</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/phone_number_field.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.TextInputLayout
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
Expand All @@ -16,5 +16,5 @@
android:digits="0123456789"
/>

</android.support.design.widget.TextInputLayout>
</com.google.android.material.textfield.TextInputLayout>

Loading

0 comments on commit d724358

Please sign in to comment.