Skip to content

Commit

Permalink
java packages and inheritance, fix some warnings/lints
Browse files Browse the repository at this point in the history
  • Loading branch information
pazos committed Aug 4, 2019
1 parent f3c03a5 commit 31a07c6
Show file tree
Hide file tree
Showing 29 changed files with 904 additions and 671 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Expand Up @@ -5,7 +5,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:3.4.2'
}
}

Expand All @@ -17,7 +17,8 @@ allprojects {
}

ext {
sdkVersion = 28
minSdk = 14
targetSdk = 28
}


Expand Down
8 changes: 7 additions & 1 deletion eink-test/AndroidManifest.xml
@@ -1,17 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.koreader.test.eink" >

<application
android:label="@string/app_name" >
android:label="@string/app_name"
android:allowBackup="false"
android:fullBackupContent="false" >

<activity
android:name="org.koreader.test.eink.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:launchMode="singleInstance">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
</application>
</manifest>
32 changes: 11 additions & 21 deletions eink-test/build.gradle
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion rootProject.ext.sdkVersion
compileSdkVersion rootProject.ext.targetSdk

defaultConfig {
applicationId "org.koreader.einktest"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
minSdkVersion rootProject.ext.minSdk
targetSdkVersion rootProject.ext.targetSdk
versionCode 10
versionName "1.2"
}

sourceSets {
Expand All @@ -19,18 +19,6 @@ android {
}
}

flavorDimensions "abi"
productFlavors {
arm {
ndk { abiFilters "armeabi-v7a" }
dimension = 'abi'
}
x86 {
ndk { abiFilters "x86" }
dimension = 'abi'
}
}

variantFilter { variant ->
if (variant.buildType.name == 'debug') {
setIgnore(true)
Expand All @@ -39,23 +27,25 @@ android {

applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "einkTest-${variant.getFlavorName()}.apk"
outputFileName = "einkTest.apk"
}
}

lintOptions {
checkReleaseBuilds true
abortOnError false
disable 'SetTextI18n'
disable 'PrivateApi'
disable 'GoogleAppIndexingWarning'
disable 'MissingApplicationIcon'
}
}

// copy EPD abstract classes from the main module before the build
task copyEPDFiles(type: Copy) {
from '../launcher/src/org/koreader/device/rockchip/RK30xxEPDController.java'
from '../launcher/src/org/koreader/device/rockchip/RK33xxEPDController.java'
from '../launcher/src/org/koreader/device/freescale/NTXEPDController.java'
from '../launcher/src/org/koreader/launcher/device/rockchip/RK30xxEPDController.java'
from '../launcher/src/org/koreader/launcher/device/rockchip/RK33xxEPDController.java'
from '../launcher/src/org/koreader/launcher/device/freescale/NTXEPDController.java'
into 'src/org/koreader/test/eink/'
}

Expand Down
7 changes: 4 additions & 3 deletions eink-test/res/layout/main.xml
Expand Up @@ -2,13 +2,15 @@

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
android:fillViewport="true"
tools:ignore="HardcodedText, ContentDescription" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<TextView
Expand Down Expand Up @@ -89,7 +91,6 @@
android:layout_height="12dp" />

<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@android:drawable/divider_horizontal_dark"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
Expand Down
71 changes: 39 additions & 32 deletions eink-test/src/org/koreader/test/eink/MainActivity.java
@@ -1,5 +1,6 @@
package org.koreader.test.eink;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Point;
import android.util.Log;
Expand All @@ -8,59 +9,62 @@
import android.widget.Button;
import android.widget.TextView;

import org.koreader.device.freescale.NTXEPDController;
import org.koreader.device.rockchip.RK30xxEPDController;
import org.koreader.device.rockchip.RK33xxEPDController;
import org.koreader.launcher.device.freescale.NTXEPDController;
import org.koreader.launcher.device.rockchip.RK30xxEPDController;
import org.koreader.launcher.device.rockchip.RK33xxEPDController;

public class MainActivity extends android.app.Activity {

// tests
private static final int RK30xx = 1;
private static final int RK33xx = 2;
private static final int NTX_NEW= 3;

// device id
private static final String MANUFACTURER = android.os.Build.MANUFACTURER;
private static final String BRAND = android.os.Build.BRAND;
private static final String MODEL = android.os.Build.MODEL;
private static final String PRODUCT = android.os.Build.PRODUCT;
private static final String HARDWARE = android.os.Build.HARDWARE;

// text view with device info
private TextView info;

@Override
public void onCreate(android.os.Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

info = (TextView) findViewById(R.id.info);
TextView readmeReport = (TextView) findViewById(R.id.readmeReport);
info = findViewById(R.id.info);
TextView readmeReport = findViewById(R.id.readmeReport);

TextView rk30xx_description = (TextView) findViewById(R.id.rk30xxText);
TextView rk33xx_description = (TextView) findViewById(R.id.rk33xxText);
TextView ntx_new_description = (TextView) findViewById(R.id.ntxNewText);
TextView rk30xx_description = findViewById(R.id.rk30xxText);
TextView rk33xx_description = findViewById(R.id.rk33xxText);
TextView ntx_new_description = findViewById(R.id.ntxNewText);

Button rk30xx_button = (Button) findViewById(R.id.rk30xxButton);
Button rk33xx_button = (Button) findViewById(R.id.rk33xxButton);
Button ntx_new_button = (Button) findViewById(R.id.ntxNewButton);
Button share_button = (Button) findViewById(R.id.shareButton);
Button rk30xx_button = findViewById(R.id.rk30xxButton);
Button rk33xx_button = findViewById(R.id.rk33xxButton);
Button ntx_new_button = findViewById(R.id.ntxNewButton);
Button share_button = findViewById(R.id.shareButton);

/** current device info */
/* current device info */
info.append("Manufacturer: " + MANUFACTURER + "\n");
info.append("Brand: " + BRAND + "\n");
info.append("Model: " + MODEL + "\n");
info.append("Product: " + PRODUCT + "\n");
info.append("Hardware: " + HARDWARE + "\n");

/** add platform if available */
/* add platform if available */
String platform = getBuildProperty("ro.board.platform");
if (!("".equals(platform) && (platform == null))) {
if (platform != null) {
info.append("Platform: " + platform + "\n");
}

readmeReport.setText("Did you see a flashing black to white eink update? Cool\n\n");
readmeReport.append("Go to github.com/koreader/koreader/issues/4551 ");
readmeReport.append("and share the following information with us");

/** rockchip rk30xx */
/* rockchip rk30xx */
rk30xx_description.setText("This button should invoke a full refresh of Boyue T61/T62 clones.");

rk30xx_button.setOnClickListener(new View.OnClickListener() {
Expand All @@ -70,7 +74,7 @@ public void onClick(View view) {
}
});

/** rockchip rk33xx */
/* rockchip rk33xx */
rk33xx_description.setText("This button should work on boyue rk3368 clones.");

rk33xx_button.setOnClickListener(new View.OnClickListener() {
Expand All @@ -80,7 +84,7 @@ public void onClick(View view) {
}
});

/** freescale/ntx - Newer Tolino/Nook devices */
/* freescale/ntx - Newer Tolino/Nook devices */
ntx_new_description.setText("This button should work on modern Tolinos/Nooks and other ntx boards");

ntx_new_button.setOnClickListener(new View.OnClickListener() {
Expand All @@ -90,7 +94,7 @@ public void onClick(View view) {
}
});

/** share button */
/* share button */
share_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand All @@ -99,6 +103,20 @@ public void onClick(View view) {
});
}

@SuppressWarnings("SameParameterValue")
private String getBuildProperty(String key) {
String value;
try {
value = (String) Class.forName("android.os.SystemProperties").getMethod(
"get", String.class).invoke(null, key);
if (value.length() < 2) value = "unknown";
} catch (Exception e) {
value = "unknown";
}
return value;
}

@SuppressLint("DefaultLocale")
private void runEinkTest(int test) {
boolean success = false;
info.append(String.format("run test #%d -> ", test));
Expand Down Expand Up @@ -127,6 +145,7 @@ private void runEinkTest(int test) {
success = true;
}
} catch (Exception e) {
Log.e("einkTest", "error running test:" + e.toString());
}

if (success)
Expand All @@ -139,19 +158,7 @@ private void shareText(String text) {
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_TEXT, text);
i.setType("text/plain");
startActivity(Intent.createChooser(i, "einkTest results"));
}

private String getBuildProperty(String key) {
String value;
try {
value = (String) Class.forName("android.os.SystemProperties").getMethod(
"get", String.class).invoke(null, key);
if (value.length() < 2) value = "unknown";
} catch (Exception e) {
value = "unknown";
}
return value;
startActivity(Intent.createChooser(i, "e-ink test results"));
}
}

35 changes: 24 additions & 11 deletions launcher/AndroidManifest.xml
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.koreader.launcher" >
xmlns:tools="http://schemas.android.com/tools"
package="org.koreader.launcher"
tools:ignore="UnpackedNativeCode">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand All @@ -9,21 +11,30 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:largeHeap="true" android:vmSafeMode="true">

<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:largeHeap="true"
android:vmSafeMode="true"
android:allowBackup="false"
android:fullBackupContent="false" >
<meta-data android:name="android.max_aspect" android:value="3.1" />
<activity android:name="org.koreader.launcher.MainActivity"
android:label="@string/app_name"
android:screenOrientation="sensorPortrait"
android:resizeableActivity="false"
android:launchMode="singleInstance"
android:theme="@style/Fullscreen">
<meta-data android:name="android.app.lib_name"
android:value="luajit" />

<activity
android:name="org.koreader.launcher.MainActivity"
android:label="@string/app_name"
android:screenOrientation="sensorPortrait"
android:resizeableActivity="false"
android:launchMode="singleInstance"
android:theme="@style/Fullscreen">
<meta-data android:name="android.app.lib_name" android:value="luajit" />

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
Expand All @@ -40,6 +51,7 @@
<data android:mimeType="application/x-chm" />
<data android:mimeType="text/plain" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
Expand Down Expand Up @@ -87,6 +99,7 @@
<data android:pathPattern=".*\\..*\\.rtf" />
<data android:pathPattern=".*\\..*\\..*\\.rtf" />
</intent-filter>

</activity>
</application>
</manifest>
10 changes: 7 additions & 3 deletions launcher/build.gradle
@@ -1,12 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion rootProject.ext.sdkVersion
compileSdkVersion rootProject.ext.targetSdk

defaultConfig {
applicationId "org.koreader.launcher"
minSdkVersion 14
targetSdkVersion 28

minSdkVersion rootProject.ext.minSdk
targetSdkVersion rootProject.ext.targetSdk

versionCode versCode as Integer
versionName versName
Expand Down Expand Up @@ -59,6 +60,9 @@ android {
abortOnError false
disable 'DefaultLocale'
disable 'GoogleAppIndexingWarning'
disable 'PrivateApi'
disable 'ProtectedPermissions'
disable 'UnusedAttribute'
}

aaptOptions {
Expand Down

0 comments on commit 31a07c6

Please sign in to comment.