Skip to content

Commit

Permalink
Remove Deprecated Methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Falcosc committed May 27, 2021
1 parent 335e874 commit 1433b01
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 42 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ android {
dependencies {

implementation 'androidx.appcompat:appcompat:1.3.0'
implementation "androidx.preference:preference:1.1.1"

implementation 'com.asamm:locus-api-android:0.9.36'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,7 @@ private ArrayList<Parcelable> getFileUris(Uri folderUri) {
}

private NotificationCompat.Builder createNotificationBuilder() {
NotificationCompat.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder = new NotificationCompat.Builder(getApplicationContext(), Const.NOTIFICATION_CHANNEL_ID);
} else {
//noinspection deprecation
builder = new NotificationCompat.Builder(getApplicationContext());
}

return builder
return new NotificationCompat.Builder(getApplicationContext(), ReportingHelper.createDefaultNotificationChannel(this))
.setSmallIcon(R.drawable.ic_camera_alt)
.setContentTitle(getString(R.string.geotag_title))
.setPriority(NotificationCompat.PRIORITY_HIGH)
Expand All @@ -173,10 +165,6 @@ private NotificationCompat.Builder createNotificationBuilder() {

@Override
protected void onHandleWork(@NonNull Intent workIntent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
new ReportingHelper(this).createDefaultNotificationChannel();
}

mNoMediaStoreAccess = ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED;
mNotificationBuilder = createNotificationBuilder();
Expand Down Expand Up @@ -430,7 +418,7 @@ private PendingExifChange createPendingExifChange(@NonNull ParcelFileDescriptor
Location loc = findNearestLocation(time);
long timeDiff = Math.abs(loc.getTime() - time);
if (timeDiff > DateUtils.HOUR_IN_MILLIS) {
//noinspection NumericCastThatLosesPrecision
//noinspection NumericCastThatLosesPrecision because we don't need it
int hoursAway = (int) (timeDiff / DateUtils.HOUR_IN_MILLIS);
if (reportNonMatchingFiles) {
incrementProgressWithError(uri, getResources().getQuantityString(R.plurals.err_geotag_x_hours_away, hoursAway, hoursAway), hoursAway);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog.Builder;

import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
Expand All @@ -24,9 +19,19 @@
import android.widget.ListView;
import android.widget.TextView;

import com.twofortyfouram.locale.api.Intent;

import java.lang.reflect.Field;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog.Builder;
import falcosc.locus.addon.tasker.R;
import falcosc.locus.addon.tasker.intent.LocusActionType;
import falcosc.locus.addon.tasker.utils.Const;
Expand All @@ -48,7 +53,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {

if (savedInstanceState == null) {

Bundle taskerBundle = getIntent().getBundleExtra(com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE);
Bundle taskerBundle = getIntent().getBundleExtra(Intent.EXTRA_BUNDLE);
if (taskerBundle != null) {
String[] savedSelectedFieldsArray = taskerBundle.getStringArray(Const.INTENT_EXTRA_FIELD_LIST);
if (savedSelectedFieldsArray != null) {
Expand All @@ -66,8 +71,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) {

WindowManager.LayoutParams params = getWindow().getAttributes();
params.width = getResources().getDimensionPixelSize(R.dimen.edit_list_dialog_width);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

DisplayMetrics metrics = getResources().getDisplayMetrics();
if(params.width > metrics.widthPixels){
params.width = metrics.widthPixels;
}
Expand Down Expand Up @@ -133,9 +138,9 @@ public TaskerFieldSelection(TaskerField field, boolean isChecked){
}

public Spannable getHelpText(Context context) {
if(!mIsChecked){
return null;
}
//TODO if(!mIsChecked){
// return null;
//}
if(mHelpText != null){
return mHelpText;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.format.DateUtils;
import android.widget.Toast;

import androidx.preference.PreferenceManager;
import falcosc.locus.addon.tasker.R;
import locus.api.android.ActionBasics;
import locus.api.android.objects.LocusInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.util.Log;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import falcosc.locus.addon.tasker.BuildConfig;
import falcosc.locus.addon.tasker.R;
Expand All @@ -31,13 +29,7 @@ public void sendErrorNotification(@NonNull String tag, @NonNull String message,
Log.e(tag, message, throwable);

try {
NotificationCompat.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder = new NotificationCompat.Builder(mContext, createDefaultNotificationChannel());
} else {
//noinspection deprecation
builder = new NotificationCompat.Builder(mContext);
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext, createDefaultNotificationChannel(mContext));

Intent emailIntent = new Intent(Intent.ACTION_SENDTO)
.setData(Uri.fromParts(Const.SCHEMA_MAIL, BuildConfig.CONTACT_EMAIL, null))
Expand Down Expand Up @@ -65,12 +57,15 @@ public void sendErrorNotification(@NonNull String tag, @NonNull String message,

}

@RequiresApi(api = Build.VERSION_CODES.O)
public String createDefaultNotificationChannel() {
@NonNull
public static String createDefaultNotificationChannel(Context context) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
return Const.NOTIFICATION_CHANNEL_ID;
}
NotificationChannel channel = new NotificationChannel(Const.NOTIFICATION_CHANNEL_ID,
mContext.getString(R.string.app_name), NotificationManager.IMPORTANCE_HIGH);
channel.setDescription(mContext.getString(R.string.notification_channel_desc));
NotificationManager notificationManager = mContext.getSystemService(NotificationManager.class);
context.getString(R.string.app_name), NotificationManager.IMPORTANCE_HIGH);
channel.setDescription(context.getString(R.string.notification_channel_desc));
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ allprojects {
}

task clean(type: Delete) {
//noinspection GroovyAssignabilityCheck
delete rootProject.buildDir
}

Expand Down

0 comments on commit 1433b01

Please sign in to comment.