Skip to content

Commit

Permalink
Merge pull request #4 from arunkumar9t2/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
arunkumar9t2 authored Oct 17, 2016
2 parents 05ac7e9 + 837a6d0 commit 589f82e
Show file tree
Hide file tree
Showing 36 changed files with 462 additions and 189 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "arun.com.chromer"
minSdkVersion 16
targetSdkVersion 24
versionCode 24
versionName "1.6"
versionCode 25
versionName "1.6.1"

buildConfigField "String", "BASE_64", getBase64()
}
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<receiver android:name=".customtabs.callbacks.SecondaryBrowserReceiver"/>
<receiver android:name=".customtabs.callbacks.OpenInChromeReceiver"/>
<receiver android:name=".customtabs.callbacks.OpenInNewTabReceiver"/>
<receiver android:name=".customtabs.callbacks.MinimizeBroadcastReceiver"/>

<activity
android:name=".MainActivity"
Expand All @@ -74,7 +75,7 @@
<activity
android:name=".activities.CustomTabActivity"
android:label="@string/app_name"
android:theme="@style/Transparent"/>
android:theme="@style/Theme.AppCompat.Translucent"/>
<activity
android:name=".activities.intro.ChromerIntro"
android:label="Intro"
Expand Down Expand Up @@ -105,7 +106,7 @@
<activity
android:name=".activities.BrowserInterceptActivity"
android:label="@string/app_name"
android:theme="@style/Transparent">
android:theme="@style/Theme.AppCompat.Translucent">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>

Expand Down Expand Up @@ -140,7 +141,7 @@
android:name=".webheads.helper.ProxyActivity"
android:excludeFromRecents="true"
android:noHistory="true"
android:theme="@style/Transparent"/>
android:theme="@style/Theme.AppCompat.Translucent"/>

<service
android:name=".webheads.qs.WebHeadTile"
Expand Down
29 changes: 27 additions & 2 deletions app/src/main/java/arun/com/chromer/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package arun.com.chromer;

import android.app.ActivityOptions;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
Expand Down Expand Up @@ -81,6 +84,7 @@ public class MainActivity extends AppCompatActivity implements ColorChooserDialo

private CustomTabManager mCustomTabManager;
private Drawer mDrawer;
private BroadcastReceiver closeReceiver;

@Override
protected void onStart() {
Expand Down Expand Up @@ -121,6 +125,27 @@ protected void onCreate(Bundle savedInstanceState) {
checkAndEducateUser(false);

ServiceUtil.takeCareOfServices(getApplicationContext());

registerCloseReceiver();
}

@Override
protected void onDestroy() {
super.onDestroy();
LocalBroadcastManager.getInstance(this).unregisterReceiver(closeReceiver);
}

private void registerCloseReceiver() {
closeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Timber.d("Finished from receiver");
MainActivity.this.finish();
}
};
LocalBroadcastManager.getInstance(this).registerReceiver(
closeReceiver,
new IntentFilter(Constants.ACTION_CLOSE_MAIN));
}

private void setUpAppBarLayout() {
Expand Down Expand Up @@ -367,7 +392,7 @@ public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int s
}

private void checkAndEducateUser(boolean forceShow) {
List packages;
final List packages;
if (!forceShow) {
packages = CustomTabs.getCustomTabSupportingPackages(this);
} else {
Expand Down Expand Up @@ -504,7 +529,7 @@ public class PagerAdapter extends FragmentPagerAdapter {
getString(R.string.customize)
};

public PagerAdapter(FragmentManager fm) {
PagerAdapter(FragmentManager fm) {
super(fm);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

Expand Down Expand Up @@ -39,6 +40,8 @@ protected void onCreate(Bundle savedInstanceState) {
return;
}

signalMainFinish();

final boolean isFromNewTab = getIntent().getBooleanExtra(Constants.EXTRA_KEY_FROM_NEW_TAB, false);

// Check if we should blacklist the launching app
Expand Down Expand Up @@ -83,9 +86,6 @@ protected void onCreate(Bundle savedInstanceState) {
if (isFromNewTab || Preferences.mergeTabs(this)) {
customTabActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
customTabActivity.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
} else {
customTabActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
customTabActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
}
customTabActivity.putExtra(Constants.EXTRA_KEY_FROM_NEW_TAB, isFromNewTab);
startActivity(customTabActivity);
Expand All @@ -94,6 +94,11 @@ protected void onCreate(Bundle savedInstanceState) {
finish();
}

private void signalMainFinish() {
LocalBroadcastManager.getInstance(this)
.sendBroadcast(new Intent(Constants.ACTION_CLOSE_MAIN));
}

private void performBlacklistAction() {
String componentFlatten = Preferences.secondaryBrowserComponent(this);
if (componentFlatten != null && Util.isPackageInstalled(this, Preferences.secondaryBrowserPackage(this))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.graphics.Palette;
import android.widget.Toast;
Expand All @@ -34,6 +39,8 @@
public class CustomTabActivity extends AppCompatActivity {
private boolean isLoaded = false;
private ExtractionTask mExtractionTask;
private String mBaseUrl = "";
private BroadcastReceiver mMinimizeReceiver;

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
Expand All @@ -46,26 +53,45 @@ protected void onCreate(Bundle savedInstanceState) {
return;
}

final String url = getIntent().getDataString();
mBaseUrl = getIntent().getDataString();
final boolean isWebhead = getIntent().getBooleanExtra(Constants.EXTRA_KEY_FROM_WEBHEAD, false);

final WebSite webSite = getIntent().getParcelableExtra(Constants.EXTRA_KEY_WEBSITE);
final int color = webSite != null ? webSite.color : Constants.NO_COLOR;

Benchmark.start("Custom tab launching in CTA");
CustomTabs.from(this)
.forUrl(url)
.forUrl(mBaseUrl)
.forWebHead(isWebhead)
.overrideToolbarColor(color)
// .noAnimations(Preferences.aggressiveLoading(this))
.prepare()
.launch();
Benchmark.end();

dispatchDescriptionTask(webSite);

if (Preferences.aggressiveLoading(this)) {
delayedGoToBack();
}

dispatchDescriptionTask(webSite);

registerMinimizeReceiver();
}

private void registerMinimizeReceiver() {
mMinimizeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Timber.d("Minimize called with %s : %s", mBaseUrl, intent.toString());
if (intent.getAction().equalsIgnoreCase(Constants.ACTION_MINIMIZE) && intent.hasExtra(Intent.EXTRA_TEXT)) {
if (mBaseUrl.equalsIgnoreCase(intent.getStringExtra(Intent.EXTRA_TEXT))) {
Timber.d("Minimized %s", intent.getStringExtra(Intent.EXTRA_TEXT));
moveTaskToBack(true);
}
}
}
};
LocalBroadcastManager.getInstance(this).registerReceiver(mMinimizeReceiver, new IntentFilter(Constants.ACTION_MINIMIZE));
}

private void delayedGoToBack() {
Expand Down Expand Up @@ -94,7 +120,7 @@ public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glid
}
});
} else {
mExtractionTask = new ExtractionTask(getIntent().getDataString());
mExtractionTask = new ExtractionTask(mBaseUrl);
mExtractionTask.execute();
}
}
Expand All @@ -115,6 +141,7 @@ protected void onDestroy() {
mExtractionTask.cancel(true);
}
mExtractionTask = null;
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMinimizeReceiver);
}

@Override
Expand Down Expand Up @@ -183,6 +210,9 @@ protected void onPostExecute(Void aVoid) {
label = mUrl.toUpperCase();
}
Timber.d("Setting task description %s", label);
if (mIcon != null && mIcon.getWidth() < 0) {
mIcon = null;
}
if (color != Constants.NO_COLOR) {
setTaskDescription(new ActivityManager.TaskDescription(label, mIcon, color));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import java.util.ArrayList;
import java.util.List;

import timber.log.Timber;


/**
* Provides convenience methods for in-app billing. You can create one instance of this
Expand Down Expand Up @@ -770,6 +772,10 @@ void flagEndAsync() {

int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException {
// Query purchases
if (mContext == null) {
Timber.d("User cancelled");
return BILLING_RESPONSE_RESULT_USER_CANCELED;
}
logDebug("Querying owned items, item type: " + itemType);
logDebug("Package name: " + mContext.getPackageName());
boolean verificationFailed = false;
Expand Down
Loading

0 comments on commit 589f82e

Please sign in to comment.