Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #152 from d4rken/dev
Browse files Browse the repository at this point in the history
v0.8.0 release.
  • Loading branch information
d4rken authored Sep 6, 2017
2 parents 6d48c0d + 7c9939b commit 1bf998b
Show file tree
Hide file tree
Showing 64 changed files with 1,467 additions and 481 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ notifications:

env:
matrix:
- API=android-21 ABI=armeabi-v7a
- API=android-22 ABI=armeabi-v7a

language: android
jdk:
Expand All @@ -13,10 +13,11 @@ android:
- platform-tools
- tools
- build-tools-25.0.3
- android-22
- android-25
- extra-google-m2repository
- extra-android-m2repository
- sys-img-armeabi-v7a-android-21
- sys-img-armeabi-v7a-android-22
licenses:
- 'android-sdk-preview-license-.+'
- 'android-sdk-license-.+'
Expand All @@ -32,4 +33,4 @@ before_script:
- adb shell input keyevent 82 &

script:
- ./gradlew clean assemble test connectedAndroidTest coveralls
- ./gradlew clean assemble jacocoTestReport coveralls
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# /r/Android App Store
[![Project License](https://img.shields.io/badge/license-Apache--2.0-blue.svg?style=flat-square)](LICENSE)
[![Build Status](https://travis-ci.org/d4rken/reddit-android-appstore.svg?branch=dev)](https://travis-ci.org/d4rken/reddit-android-appstore) [![Coverage Status](https://coveralls.io/repos/github/d4rken/reddit-android-appstore/badge.svg)](https://coveralls.io/github/d4rken/reddit-android-appstore)
[![Build Status](https://travis-ci.org/d4rken/reddit-android-appstore.svg?branch=dev)](https://travis-ci.org/d4rken/reddit-android-appstore)
[![Coverage Status](https://coveralls.io/repos/github/d4rken/reddit-android-appstore/badge.svg)](https://coveralls.io/github/d4rken/reddit-android-appstore)

App inspired by [this reddit post](https://redd.it/50rafp)

Pulls the curated app list from the [/r/Android wiki](https://www.reddit.com/r/android/wiki/apps) and displays.
Displays the curated app list from the [/r/Android wiki](https://www.reddit.com/r/android/wiki/apps).

## Features
* Filter by category (Apps, Games, etc.) and traits (New, Free, Phone, Wear, etc.)
* Search through the apps list
* View screenshots and read brief summaries of each app
* Go straight to each app's download page
* Night and AMOLED themes
* ...and more!

## Screenshots
From commit [269d4fa](https://github.com/d4rken/reddit-android-appstore/commit/269d4fab0fd2a4553c7d51dcaaf5da82de3883a3)
![](art/preview-v080.png)

## How to Contribute
* Make sure there is an issue for what you are working on __(create one if necessary)__
Expand All @@ -15,12 +28,8 @@ Pulls the curated app list from the [/r/Android wiki](https://www.reddit.com/r/a

## Questions?
[Create an issue](https://github.com/d4rken/reddit-android-appstore/issues/new)
[Submit your App](https://androidflair.github.io/wikiapps/)

## Screenshots
From commit [36e4daa](https://github.com/d4rken/reddit-android-appstore/commit/36e4daaa4a1f9969917c3fc3833213d68c684bf4)

![](art/preview.png)
[Submit your App](https://androidflair.github.io/wikiapps/)

## License
```
Expand Down
69 changes: 55 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'realm-android'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: "jacoco"
apply plugin: 'jacoco'

def gitSha() {
def p = 'git rev-parse --short HEAD'.execute([], project.rootDir)
Expand All @@ -15,7 +14,8 @@ def gitSha() {
}

android {
if (new File(System.properties['user.home'], ".signing/reddit-android-appstore/signing.properties").canRead()) {
def signingPropFile = new File(System.properties['user.home'], ".signing/reddit-android-appstore/signing.properties")
if (signingPropFile.canRead()) {
def Properties signingProps = new Properties()
signingProps.load(new FileInputStream(signingPropFile))
signingConfigs {
Expand All @@ -32,8 +32,8 @@ android {
buildToolsVersion "25.0.3"

def versionMajor = 0
def versionMinor = 7
def versionPatch = 1
def versionMinor = 8
def versionPatch = 0
def versionBuild = 0


Expand Down Expand Up @@ -96,6 +96,10 @@ android {
outputs.upToDateWhen { false }
showStandardStreams = true
}

jacoco {
includeNoLocationClasses = true
}
}

compileOptions {
Expand All @@ -104,14 +108,42 @@ android {
}
}

task jacocoTestReport(type: JacocoReport, dependsOn: ['testProdDebugUnitTest' , 'createProdDebugCoverageReport']) {

reports {
xml.enabled = true
html.enabled = true
}

def fileFilter = ['**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'android/**/*.*',
'**/*_MembersInjector.class',
'**/Dagger*Component.class',
'**/Dagger*Component$Builder.class',
'**/*Module_*Factory.class']
def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/prod/debug", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"

sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: "$buildDir", includes: [
"jacoco/testProdDebugUnitTest.exec",
"outputs/code-coverage/connected/flavors/PROD/*coverage.ec"
])
}

coveralls {
sourceDirs = fileTree(dir: "${project.projectDir}/java", excludes: [
'**/*_MembersInjector.class',
'**/Dagger*Component.class',
'**/Dagger*Component$Builder.class',
'**/*Module_*Factory.class'
]).flatten()
jacocoReportPath = "${buildDir}/reports/coverage/prod/debug/report.xml"
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml"
}

tasks.coveralls {
Expand All @@ -123,7 +155,7 @@ tasks.withType(Test) {
systemProperty "robolectric.logging", "stdout"
}
ext {
supportLibVersion = '25.1.0'
supportLibVersion = '25.3.1'
}
//noinspection GroovyAssignabilityCheck
configurations.all {
Expand All @@ -136,7 +168,11 @@ configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: ['*.jar'], dir: 'libs')

// jUnit
testCompile 'junit:junit:4.12'

// Support libs
compile "com.android.support:support-annotations:${supportLibVersion}"
compile "com.android.support:appcompat-v7:${supportLibVersion}"
Expand All @@ -147,6 +183,9 @@ dependencies {
compile "com.android.support:preference-v14:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"

// JavaPoet
compile 'com.squareup:javapoet:1.9.0'

// Recyclerview fast scroller
compile 'com.futuremind.recyclerfastscroll:fastscroll:0.2.4'

Expand All @@ -160,7 +199,8 @@ dependencies {
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0-RC2'

// Glide
compile 'com.github.bumptech.glide:glide:4.0.0-SNAPSHOT'
compile 'com.github.bumptech.glide:glide:4.0.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'

// Flow layout for tags
compile 'com.wefika:flowlayout:0.4.0'
Expand All @@ -173,19 +213,20 @@ dependencies {
compile 'com.google.code.gson:gson:2.7'

//Dagger
apt 'com.google.dagger:dagger-compiler:2.2'
compile 'com.google.dagger:dagger:2.2'
compile 'com.google.dagger:dagger:2.9'
annotationProcessor "com.google.dagger:dagger-compiler:2.9"
provided 'javax.annotation:jsr250-api:1.0'

//Butterknife
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1'

//Timber
compile 'com.jakewharton.timber:timber:4.1.2'

// jUnit
testCompile 'junit:junit:4.12'
// Hamcrest
testCompile 'org.hamcrest:hamcrest-library:1.3'

// Mockito
testCompile 'org.mockito:mockito-core:2.8.9'

Expand Down
11 changes: 10 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@

# Glide
# https://github.com/bumptech/glide/wiki/Configuration#keeping-a-glidemodule
-keep public class * implements com.bumptech.glide.module.GlideModule
# http://bumptech.github.io/glide/doc/download-setup.html#proguard
#
# Note: class com.bumptech.glide.module.LibraryGlideModule is not kept.
# Not sure if this is intentional, or if Glide devs forgot it.
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
4 changes: 0 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
android:name=".screens.settings.SettingsActivity"
android:label="@string/settings"
android:parentActivityName=".screens.MainActivity"/>

<meta-data
android:name="subreddit.android.appstore.util.ui.glide.GlideConfigModule"
android:value="GlideModule"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import subreddit.android.appstore.backend.reddit.wiki.WikiRepositoryModule;
import subreddit.android.appstore.backend.scrapers.MediaScraper;
import subreddit.android.appstore.backend.scrapers.ScraperModule;
import subreddit.android.appstore.backend.HttpModule;
import subreddit.android.appstore.util.dagger.ApplicationScope;


Expand All @@ -17,7 +18,8 @@
AndroidModule.class,
WikiRepositoryModule.class,
ScraperModule.class,
GithubRepositoryModule.class
GithubRepositoryModule.class,
HttpModule.class
})
public interface AppComponent {
SharedPreferences providePreferences();
Expand All @@ -26,5 +28,5 @@ public interface AppComponent {

MediaScraper mediaScraper();

GithubRepository selfUpdater();
GithubRepository githubRepository();
}
44 changes: 42 additions & 2 deletions app/src/main/java/subreddit/android/appstore/AppStoreApp.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
package subreddit.android.appstore;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.preference.PreferenceManager;

import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.security.MessageDigest;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;

import io.realm.Realm;
import io.realm.RealmConfiguration;
import timber.log.Timber;


public class AppStoreApp extends Application {
public static final String LOGPREFIX = "RAS:";
public static final String GITHUB_SIGNATURE = "FC4E2523E3509BA56E6AFDC36004958E2E94EAB2";
private static RefWatcher refWatcher;
private int theme = 0;

Expand Down Expand Up @@ -45,7 +57,10 @@ private void clearCache() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.getInt("APP_VERSION",0)<BuildConfig.VERSION_CODE) {
Timber.e("New release on %s, clearing cache database", BuildConfig.VERSION_NAME);
Realm.deleteRealm(new RealmConfiguration.Builder(this, getCacheDir()).build());
Realm.init(getApplicationContext());
Realm realm = Realm.getDefaultInstance();
realm.close();
Realm.deleteRealm(new RealmConfiguration.Builder().build());
prefs.edit().putInt("APP_VERSION",BuildConfig.VERSION_CODE).commit();
}
}
Expand Down Expand Up @@ -78,7 +93,8 @@ public enum Injector {
}

void init(AppStoreApp app) {
RealmConfiguration realmConfig = new RealmConfiguration.Builder(app, app.getCacheDir())
Realm.init(app);
RealmConfiguration realmConfig = new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.build();
Realm.setDefaultConfiguration(realmConfig);
Expand All @@ -91,4 +107,28 @@ public AppComponent getAppComponent() {
return appComponent;
}
}

public static List<String> getSignatures(Context context, String packageName) {
List<String> foundSignatures = new ArrayList<>();
try {
final Signature[] signatures = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES).signatures;
for (final Signature sig : signatures) {
final byte[] rawCert = sig.toByteArray();
InputStream certStream = new ByteArrayInputStream(rawCert);
CertificateFactory certFactory = CertificateFactory.getInstance("X509");
X509Certificate x509Cert = (X509Certificate) certFactory.generateCertificate(certStream);

MessageDigest md = MessageDigest.getInstance("SHA1");
byte[] publicKey = md.digest(x509Cert.getEncoded());
foundSignatures.add(bytesToHex(publicKey).toUpperCase());
}
} catch (Exception e) { e.printStackTrace(); }
return foundSignatures;
}

private static String bytesToHex(byte[] in) {
final StringBuilder out = new StringBuilder();
for (byte b : in) out.append(String.format("%02x", b));
return out.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package subreddit.android.appstore.backend;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import subreddit.android.appstore.BuildConfig;
import subreddit.android.appstore.util.dagger.ApplicationScope;

@Module
public class HttpModule {

@Provides
@ApplicationScope
Gson provideGson() {
return new GsonBuilder().create();
}

@Provides
@ApplicationScope
OkHttpClient provideOkHttpClient(UserAgentInterceptor userAgent) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
builder.addInterceptor(interceptor);
}
builder.addInterceptor(userAgent);
return builder.build();
}

}
Loading

0 comments on commit 1bf998b

Please sign in to comment.