Permalink
Browse files

delegation of Activity/ContextThemeWrapper methods in InternalContext

  • Loading branch information...
1 parent e5a3b59 commit dd3afc4d67a6a712b3360511404fb2b798fead9f @Zhuinden committed Aug 3, 2016
View
@@ -1,6 +1,10 @@
Change Log
==========
+Flowless Version 1.0-alpha1.11 *(2016-08-04)*
+---------------------------------------------
+* Removed `InternalContextThemeWrapper` because it wasn't needed
+* Added delegation of `Activity` and `ContextThemeWrapper` methods to the inner Activity
Flowless Version 1.0-alpha1.9 *(2016-07-31)*
--------------------------------------------
View
@@ -45,7 +45,7 @@ In order to use Flow(less), you need to add jitpack to your project root gradle:
and add the compile dependency to your module level gradle.
- compile 'com.github.Zhuinden:flowless:1.0-alpha1.9'
+ compile 'com.github.Zhuinden:flowless:1.0-alpha1.11'
Then, install Flow into your Activity:
View
@@ -8,7 +8,7 @@ buildscript {
maven { url "https://jitpack.io" }
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.0'
+ classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
// NOTE: Do not place your application dependencies here; they belong
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 23
- buildToolsVersion "23.0.2"
+ compileSdkVersion 24
+ buildToolsVersion "24.0.1"
defaultConfig {
applicationId "flow.sample.basic"
minSdkVersion 14
- targetSdkVersion 23
+ targetSdkVersion 24
versionCode 1
versionName "1.0"
}
@@ -22,6 +22,6 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
- compile 'com.android.support:appcompat-v7:23.4.0'
+ compile 'com.android.support:appcompat-v7:24.1.1'
compile project(':flowless-library')
}
@@ -4,20 +4,20 @@ apply plugin: 'com.github.dcendents.android-maven'
group='com.github.Zhuinden'
android {
- compileSdkVersion 23
- buildToolsVersion "23.0.2"
+ compileSdkVersion 24
+ buildToolsVersion "24.0.1"
defaultConfig {
minSdkVersion 14
- targetSdkVersion 23
+ targetSdkVersion 24
versionCode 1
- versionName "1.0-alpha1.7"
+ versionName "1.0-alpha1.11"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:support-annotations:23.4.0'
+ compile 'com.android.support:support-annotations:24.1.1'
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:1.7.1'
@@ -21,10 +21,6 @@
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.view.ContextThemeWrapper;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
public final class Installer {
@@ -80,37 +76,6 @@ public Context install() {
final KeyManager keyManager = new KeyManager();
InternalLifecycleIntegration.install(app, activity, parceler, defaultHistory, dispatcher, keyManager);
- int themeResource = -1;
- obtainThemeResourceV1(activity);
- if(themeResource == -1) {
- themeResource = obtainThemeResourceV2(activity);
- }
- if(themeResource >= 0) {
- return new InternalContextThemeWrapper(baseContext, activity, themeResource);
- } else {
- return new InternalContextWrapper(baseContext, activity);
- }
- }
-
- private int obtainThemeResourceV1(Activity activity) {
- try {
- Class<?> wrapper = Context.class;
- Method method = wrapper.getDeclaredMethod("getThemeResId");
- method.setAccessible(true);
- return (Integer) method.invoke(activity);
- } catch(Throwable e) {
- }
- return -1;
- }
-
- private int obtainThemeResourceV2(Activity activity) {
- try {
- Class<?> wrapper = ContextThemeWrapper.class;
- Field field = wrapper.getDeclaredField("mThemeResource");
- field.setAccessible(true);
- return (Integer) field.get(activity);
- } catch(Throwable e) {
- }
- return -1;
+ return new InternalContextWrapper(baseContext, activity);
}
}
@@ -1,47 +0,0 @@
-package flowless;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.res.Resources;
-import android.view.ContextThemeWrapper;
-
-/**
- * Created by Zhuinden on 2016.07.31..
- */
-final class InternalContextThemeWrapper
- extends ContextThemeWrapper
- implements InternalContext {
-
- private final Activity activity;
- private Flow flow;
- private KeyManager keyManager;
-
- InternalContextThemeWrapper(Context baseContext, Activity activity, int themeResource) {
- super(baseContext, themeResource);
- this.activity = activity;
- }
-
- @Override
- public Resources.Theme getTheme() {
- return activity.getTheme();
- }
-
- @Override
- public Object getSystemService(String name) {
- if(FLOW_SERVICE.equals(name)) {
- if(flow == null) {
- flow = InternalLifecycleIntegration.find(activity).flow;
- }
- return flow;
- } else if(CONTEXT_MANAGER_SERVICE.equals(name)) {
- if(keyManager == null) {
- keyManager = InternalLifecycleIntegration.find(activity).keyManager;
- }
- return keyManager;
- } else if(ACTIVITY.equals(name)) {
- return activity;
- } else {
- return super.getSystemService(name);
- }
- }
-}
@@ -16,10 +16,14 @@
package flowless;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
+import android.content.Intent;
+import android.content.IntentSender;
import android.content.res.Resources;
+import android.os.Bundle;
final class InternalContextWrapper
extends ContextWrapper
@@ -34,11 +38,6 @@
}
@Override
- public Resources.Theme getTheme() {
- return activity.getTheme();
- }
-
- @Override
public Object getSystemService(String name) {
if(FLOW_SERVICE.equals(name)) {
if(flow == null) {
@@ -56,4 +55,50 @@ public Object getSystemService(String name) {
return super.getSystemService(name);
}
}
+
+ @Override
+ public void startActivity(Intent intent) {
+ activity.startActivity(intent);
+ }
+
+ @TargetApi(16)
+ @Override
+ public void startActivity(Intent intent, Bundle options) {
+ activity.startActivity(intent, options);
+ }
+
+
+ @Override
+ public void startActivities(Intent[] intents) {
+ activity.startActivities(intents);
+ }
+
+ @TargetApi(16)
+ @Override
+ public void startActivities(Intent[] intents, Bundle options) {
+ activity.startActivities(intents, options);
+ }
+
+ @Override
+ public void startIntentSender(IntentSender intent, Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
+ throws IntentSender.SendIntentException {
+ activity.startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags);
+ }
+
+ @TargetApi(16)
+ @Override
+ public void startIntentSender(IntentSender intent, Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options)
+ throws IntentSender.SendIntentException {
+ activity.startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags, options);
+ }
+
+ @Override
+ public void setTheme(int resid) {
+ activity.setTheme(resid);
+ }
+
+ @Override
+ public Resources.Theme getTheme() {
+ return activity.getTheme();
+ }
}
@@ -2,13 +2,13 @@ apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
- compileSdkVersion 23
- buildToolsVersion "23.0.2"
+ compileSdkVersion 24
+ buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.zhuinden.flow_alpha_master_detail"
minSdkVersion 15
- targetSdkVersion 23
+ targetSdkVersion 24
versionCode 1
versionName "1.0"
}
@@ -37,7 +37,7 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':flowless-library')
testCompile 'junit:junit:4.12'
- compile 'com.android.support:appcompat-v7:23.2.1'
+ compile 'com.android.support:appcompat-v7:24.1.1'
//compile 'com.squareup.flow:flow:1.0.0-alpha'
apt 'frankiesardo:auto-parcel:1.0.1'
@@ -2,13 +2,13 @@ apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
- compileSdkVersion 23
- buildToolsVersion "23.0.2"
+ compileSdkVersion 24
+ buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.zhuinden.flowless_dispatcher_sample"
minSdkVersion 15
- targetSdkVersion 23
+ targetSdkVersion 24
versionCode 1
versionName "1.0"
}
@@ -37,7 +37,7 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':flowless-library')
testCompile 'junit:junit:4.12'
- compile 'com.android.support:appcompat-v7:23.4.0'
+ compile 'com.android.support:appcompat-v7:24.1.1'
apt 'frankiesardo:auto-parcel:1.0.1'
@@ -3,13 +3,13 @@ apply plugin: 'com.neenbedankt.android-apt'
android {
- compileSdkVersion 23
- buildToolsVersion "23.0.3"
+ compileSdkVersion 24
+ buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.zhuinden.flowless_viewpager_example"
minSdkVersion 14
- targetSdkVersion 23
+ targetSdkVersion 24
versionCode 1
versionName "1.0"
}
@@ -38,7 +38,7 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':flowless-library')
testCompile 'junit:junit:4.12'
- compile 'com.android.support:appcompat-v7:23.4.0'
+ compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
apt 'frankiesardo:auto-parcel:1.0.1'

0 comments on commit dd3afc4

Please sign in to comment.