Skip to content

Commit

Permalink
MatLog: switch to androidx
Browse files Browse the repository at this point in the history
Change-Id: Ibd3756c208964b37a3460bf66da619cf031ce312
  • Loading branch information
maxwen committed May 26, 2020
1 parent 2af9ee8 commit ea0c5d6
Show file tree
Hide file tree
Showing 46 changed files with 479 additions and 836 deletions.
Binary file added Matlog.zip
Binary file not shown.
67 changes: 14 additions & 53 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,79 +1,40 @@
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
classpath 'io.fabric.tools:gradle:1.22.2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
}

android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
compileSdkVersion 29

defaultConfig {
applicationId "org.omnirom.logcat"
minSdkVersion 16
targetSdkVersion 26
minSdkVersion 26
targetSdkVersion 29
versionName '1.1.1'
versionCode 6

testApplicationId "com.pluscubed.matlog.test"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

manifestPlaceholders = [appName: "@string/app_name"]

vectorDrawables.useSupportLibrary = true
}

if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfigs {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS_MATLOG
keyPassword RELEASE_KEY_PASSWORD_MATLOG
}
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
} else {
signingConfig signingConfigs.debug
}
}
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
manifestPlaceholders = [appName: "MatLog DEBUG"]
ext.enableCrashlytics = false
}
}
}

def supportLibrariesVersion = "26.0.0-beta2"
lintOptions {
checkReleaseBuilds false
}
}

dependencies {
compile "com.android.support:appcompat-v7:$supportLibrariesVersion"
compile "com.android.support:recyclerview-v7:$supportLibrariesVersion"
compile "com.android.support:support-annotations:$supportLibrariesVersion"
compile "com.android.support:design:$supportLibrariesVersion"
compile "com.android.support:support-v13:$supportLibrariesVersion"

compile 'com.afollestad.material-dialogs:commons:0.9.4.5'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.annotation:annotation:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.preference:preference:1.0.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
}
34 changes: 0 additions & 34 deletions app/src/main/Android.bp

This file was deleted.

18 changes: 6 additions & 12 deletions app/src/main/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@ LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_STATIC_ANDROID_LIBRARIES := \
$(ANDROID_SUPPORT_DESIGN_TARGETS) \
android-support-v4 \
android-support-v7-appcompat \
android-support-v7-recyclerview \
android-support-v13 \
android-support-annotations

# AAR libraries
LOCAL_STATIC_ANDROID_LIBRARIES += material-dialogs-core-matlog-target \
material-dialogs-commons-matlog-target \
material-progressbar-library-matlog-target
LOCAL_STATIC_ANDROID_LIBRARIES := androidx.core_core \
androidx.annotation_annotation \
androidx.appcompat_appcompat \
androidx.recyclerview_recyclerview \
androidx.preference_preference \
com.google.android.material_material

LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res

Expand Down
15 changes: 5 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
android:versionCode="6"
android:versionName="1.1.1" >

<uses-sdk android:minSdkVersion='25'
android:targetSdkVersion='25' />

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:name=".OmniApp"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/Theme.MatLog">
android:theme="@style/Theme.MatLog"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true" >

<!--TODO: REMOVE THIS CONFIGCHANGES ATROCITY-->
<activity
Expand All @@ -40,11 +40,6 @@
android:resource="@xml/shortcuts"/>
</activity>

<activity
android:name="com.pluscubed.logcat.ui.AboutDialogActivity"
android:theme="@style/Theme.MatLog.AlertDialog"/>


<activity
android:name="com.pluscubed.logcat.ui.RecordLogDialogActivity"
android:theme="@style/Theme.MatLog.AlertDialog"/>
Expand Down Expand Up @@ -79,7 +74,7 @@
</receiver>

<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="org.omnirom.logcat.provider"
android:exported="false"
android:grantUriPermissions="true">
Expand Down
20 changes: 17 additions & 3 deletions app/src/main/java/com/pluscubed/logcat/LogcatRecordingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
Expand All @@ -10,7 +12,6 @@
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.app.NotificationCompat;
import android.widget.Toast;

import com.pluscubed.logcat.data.LogLine;
Expand All @@ -31,6 +32,8 @@
import java.io.IOException;
import java.util.Random;

import androidx.core.app.NotificationCompat;

/**
* Reads logs.
*
Expand All @@ -44,6 +47,8 @@ public class LogcatRecordingService extends IntentService {
public static final String EXTRA_QUERY_FILTER = "filter";
public static final String EXTRA_LEVEL = "level";
private static final String ACTION_STOP_RECORDING = "com.pluscubed.catlog.action.STOP_RECORDING";
private static final String NOTIFICATION_CHANNEL_ID = "com.pluscubed.logcat.notification";

private static UtilLogger log = new UtilLogger(LogcatRecordingService.class);
private final Object lock = new Object();
private LogcatReader mReader;
Expand All @@ -60,7 +65,7 @@ public void onReceive(Context context, Intent intent) {
};

private Handler handler;

private NotificationChannel mNotificationChannel;

public LogcatRecordingService() {
super("AppTrackerService");
Expand All @@ -72,6 +77,8 @@ public void onCreate() {
super.onCreate();
log.d("onCreate()");

createNotificationChannel();

IntentFilter intentFilter = new IntentFilter(ACTION_STOP_RECORDING);
intentFilter.addDataScheme(URI_SCHEME);

Expand Down Expand Up @@ -141,7 +148,7 @@ private void handleCommand() {
0 /* no requestCode */, stopRecordingIntent, PendingIntent.FLAG_ONE_SHOT);

// Set the icon, scrolling text and timestamp
Notification notification = new NotificationCompat.Builder(getApplicationContext())
Notification notification = new Notification.Builder(getApplicationContext(),NOTIFICATION_CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_launcher)
.setTicker(tickerText)
.setWhen(System.currentTimeMillis())
Expand Down Expand Up @@ -262,4 +269,11 @@ private void killProcess() {
}
}

private void createNotificationChannel() {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence name = getString(R.string.channel_name);
int importance = NotificationManager.IMPORTANCE_LOW;
mNotificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, importance);
notificationManager.createNotificationChannel(mNotificationChannel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;

import com.pluscubed.logcat.helper.DialogHelper;
import com.pluscubed.logcat.helper.PreferenceHelper;
Expand All @@ -15,6 +14,8 @@

import java.util.Arrays;

import androidx.annotation.NonNull;

public class RecordingWidgetProvider extends AppWidgetProvider {

public static final String ACTION_RECORD_OR_STOP = "com.pluscubed.logcat.action.RECORD_OR_STOP";
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/pluscubed/logcat/data/ColorScheme.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.pluscubed.logcat.data;

import android.content.Context;
import android.support.v4.content.ContextCompat;

import org.omnirom.logcat.R;
import com.pluscubed.logcat.util.ArrayUtil;

import org.omnirom.logcat.R;

import java.util.HashMap;
import java.util.Map;

import androidx.core.content.ContextCompat;

public enum ColorScheme {
Dark(R.string.pref_theme_choice_dark_value, R.color.main_background_dark,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.pluscubed.logcat.data;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
Expand All @@ -17,6 +16,8 @@

import java.util.List;

import androidx.annotation.NonNull;

public class FilterAdapter extends ArrayAdapter<FilterItem> {

public FilterAdapter(Context context, List<FilterItem> items) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.pluscubed.logcat.data;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -17,6 +16,8 @@
import java.util.Date;
import java.util.List;

import androidx.annotation.NonNull;

public class LogFileAdapter extends ArrayAdapter<CharSequence> {
private List<CharSequence> objects;
private int checked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
package com.pluscubed.logcat.data;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -41,6 +39,9 @@
import java.util.Comparator;
import java.util.List;

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

public class LogLineAdapter extends RecyclerView.Adapter<LogLineViewHolder> implements Filterable {

private static UtilLogger log = new UtilLogger(LogLineAdapter.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.pluscubed.logcat.data;

import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import android.view.View;
import android.widget.PopupMenu;

import org.omnirom.logcat.R;

import androidx.recyclerview.widget.RecyclerView;


/**
* ViewHolder to show log entries
Expand All @@ -17,6 +18,8 @@ public class LogLineViewHolder extends RecyclerView.ViewHolder implements PopupM
// id for context menu entry
public static final int CONTEXT_MENU_FILTER_ID = 0;
public static final int CONTEXT_MENU_COPY_ID = 1;
public static final int CONTEXT_MENU_EXPAND_ALL = 2;
public static final int CONTEXT_MENU_CLEAR = 3;

LogLine logLine;

Expand All @@ -41,7 +44,10 @@ public boolean onLongClick(View v) {
PopupMenu menu = new PopupMenu(v.getContext(), v);
menu.getMenu().add(0, CONTEXT_MENU_FILTER_ID, 0, R.string.filter_choice);
menu.getMenu().add(0, CONTEXT_MENU_COPY_ID, 0, R.string.copy_to_clipboard);
menu.getMenu().add(1, CONTEXT_MENU_CLEAR, 0, R.string.clear);
menu.getMenu().add(1, CONTEXT_MENU_EXPAND_ALL, 0, R.string.expand_or_collapse_all);
menu.setOnMenuItemClickListener(LogLineViewHolder.this);
menu.getMenu().setGroupDividerEnabled(true);
menu.show();
return true;
}
Expand Down
Loading

0 comments on commit ea0c5d6

Please sign in to comment.