Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android studio 3 compatibility and dependencies updated #247

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,21 @@ android {
}

dependencies {
compile 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.jakewharton:butterknife:5.1.2'
// dagger 2 for dependency injection
annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.ext.daggerVersion"
compile "com.google.dagger:dagger:$rootProject.ext.daggerVersion"
provided 'javax.annotation:jsr250-api:1.0'

// butterknife for view binding
compile "com.jakewharton:butterknife:$rootProject.ext.butterknifeVersion"
annotationProcessor "com.jakewharton:butterknife-compiler:$rootProject.ext.butterknifeVersion"

compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile 'com.squareup.assertj:assertj-android:1.0.0'
compile project(':FFmpegAndroid')

// app compat and design support library
compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:support-v13:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:design:$rootProject.ext.supportLibraryVersion"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@
import com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteResponseHandler;
import com.github.hiteshsondhi88.libffmpeg.FFmpegLoadBinaryResponseHandler;
import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException;
import com.github.hiteshsondhi88.sampleffmpeg.screens.home.HomeActivity;

import static org.assertj.core.api.Assertions.assertThat;

public class FFmpegInstrumentationTest extends ActivityInstrumentationTestCase2<Home> {
public class FFmpegInstrumentationTest extends ActivityInstrumentationTestCase2<HomeActivity> {

private static final String TAG = FFmpegInstrumentationTest.class.getSimpleName();

@Inject
FFmpeg ffmpeg;

public FFmpegInstrumentationTest() {
super(Home.class);
super(HomeActivity.class);
}

@Override
Expand Down Expand Up @@ -123,21 +124,22 @@ public void testFFmpegAVItoMP4Usingx264() {

public void testLibass() {
File outass = new File(getFFmpegFilesDir(), "output.ass");
checkFFmpegCommon("-y -i "+getSrtSampleFile()+" "+outass.getAbsolutePath(), outass);
checkFFmpegCommon("-y -i " + getSrtSampleFile() + " " + outass.getAbsolutePath(), outass);
}

private void checkFFmpegConvertUsingx264(File inputFile, File outputFile) {
checkFFmpegCommon("-y -i "+inputFile.getAbsolutePath()+" -c:v libx264 -preset ultrafast "+outputFile.getAbsolutePath(), outputFile);
checkFFmpegCommon("-y -i " + inputFile.getAbsolutePath() + " -c:v libx264 -preset ultrafast " + outputFile.getAbsolutePath(), outputFile);
}

private void checkFFmpegConvertCommon(File inputFile, File outputFile) {
checkFFmpegCommon("-y -i "+inputFile.getAbsolutePath()+" "+outputFile.getAbsolutePath(), outputFile);
checkFFmpegCommon("-y -i " + inputFile.getAbsolutePath() + " " + outputFile.getAbsolutePath(), outputFile);
}

private void checkFFmpegCommon(final String cmd, final File outputFile) {
Log.d(TAG, "start : "+outputFile.getAbsolutePath());
Log.d(TAG, "start : " + outputFile.getAbsolutePath());
try {
ffmpeg.execute(cmd, new FFmpegExecuteResponseHandler() {
String[] cmdArray = {cmd};
ffmpeg.execute(cmdArray, new FFmpegExecuteResponseHandler() {

@Override
public void onStart() {
Expand All @@ -146,7 +148,7 @@ public void onStart() {

@Override
public void onProgress(String message) {
Log.d(TAG, "progress : "+message);
Log.d(TAG, "progress : " + message);
}

@Override
Expand All @@ -161,7 +163,7 @@ public void onSuccess(String message) {

@Override
public void onFinish() {
Log.d(TAG, "done : "+outputFile.getAbsolutePath());
Log.d(TAG, "done : " + outputFile.getAbsolutePath());
synchronized (FFmpegInstrumentationTest.this) {
FFmpegInstrumentationTest.this.notify();
}
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.hiteshsondhi88.sampleffmpeg" >
package="com.github.hiteshsondhi88.sampleffmpeg">

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

<application
android:name=".core.BaseApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme">
<activity
android:name=".Home"
android:label="@string/app_name" >
android:name=".screens.home.HomeActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.github.hiteshsondhi88.sampleffmpeg.core;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;

import com.github.hiteshsondhi88.sampleffmpeg.R;

import javax.inject.Inject;

import butterknife.BindView;

/**
* Created by sd2_rails on 4/18/17.
*/

public abstract class BaseActivity extends AppCompatActivity {

@Nullable
@BindView(R.id.toolbar)
public Toolbar toolbar;

public void setToolbar(String title) {
setToolbar(title, true);
}

public void setToolbar(String title, boolean showBackButton) {
if (toolbar != null) {
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(showBackButton);
getSupportActionBar().setDisplayShowHomeEnabled(showBackButton);
getSupportActionBar().setTitle(title);
}
}
}

public void setToolbarText(String title) {
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(title);
}
}

public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
}
return super.onOptionsItemSelected(item);
}

public Context getContext() {
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.github.hiteshsondhi88.sampleffmpeg.core;

import android.app.Application;

import com.github.hiteshsondhi88.sampleffmpeg.di.component.ApplicationComponent;
import com.github.hiteshsondhi88.sampleffmpeg.di.component.DaggerApplicationComponent;
import com.github.hiteshsondhi88.sampleffmpeg.di.module.DaggerDependencyModule;

/**
* Created by bedi on 01/03/17.
*/

public class BaseApplication extends Application {

private static BaseApplication sInstance;

private ApplicationComponent applicationComponent;

public static BaseApplication getInstance() {
return sInstance;
}

@Override
public void onCreate() {
super.onCreate();
sInstance = this;
}

public ApplicationComponent getApplicationComponent() {
if (applicationComponent == null) {
applicationComponent = DaggerApplicationComponent.builder()
.daggerDependencyModule(new DaggerDependencyModule(this))
.build();
}
return applicationComponent;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.github.hiteshsondhi88.sampleffmpeg.di.component;

/**
* Created by navjotsinghbedi on 3/28/16.
*/


import com.github.hiteshsondhi88.sampleffmpeg.di.module.DaggerDependencyModule;
import com.github.hiteshsondhi88.sampleffmpeg.screens.home.HomeActivity;

import javax.inject.Singleton;

import dagger.Component;

@Singleton
@Component(modules = {DaggerDependencyModule.class})
public interface ApplicationComponent {

void inject(HomeActivity homeActivity);
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
package com.github.hiteshsondhi88.sampleffmpeg;
package com.github.hiteshsondhi88.sampleffmpeg.di.module;

import android.content.Context;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

import com.github.hiteshsondhi88.libffmpeg.FFmpeg;

@Module(
injects = Home.class
)
@Module
@SuppressWarnings("unused")
public class DaggerDependencyModule {

private final Context context;

DaggerDependencyModule(Context context) {
public DaggerDependencyModule(Context context) {
this.context = context;
}

@Provides @Singleton
@Provides
@Singleton
FFmpeg provideFFmpeg() {
return FFmpeg.getInstance(context.getApplicationContext());
}

}
Loading