Skip to content

Commit 589f82e

Browse files
authored
Merge pull request #4 from arunkumar9t2/develop
Develop
2 parents 05ac7e9 + 837a6d0 commit 589f82e

36 files changed

+462
-189
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ android {
99
applicationId "arun.com.chromer"
1010
minSdkVersion 16
1111
targetSdkVersion 24
12-
versionCode 24
13-
versionName "1.6"
12+
versionCode 25
13+
versionName "1.6.1"
1414

1515
buildConfigField "String", "BASE_64", getBase64()
1616
}

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<receiver android:name=".customtabs.callbacks.SecondaryBrowserReceiver"/>
6161
<receiver android:name=".customtabs.callbacks.OpenInChromeReceiver"/>
6262
<receiver android:name=".customtabs.callbacks.OpenInNewTabReceiver"/>
63+
<receiver android:name=".customtabs.callbacks.MinimizeBroadcastReceiver"/>
6364

6465
<activity
6566
android:name=".MainActivity"
@@ -74,7 +75,7 @@
7475
<activity
7576
android:name=".activities.CustomTabActivity"
7677
android:label="@string/app_name"
77-
android:theme="@style/Transparent"/>
78+
android:theme="@style/Theme.AppCompat.Translucent"/>
7879
<activity
7980
android:name=".activities.intro.ChromerIntro"
8081
android:label="Intro"
@@ -105,7 +106,7 @@
105106
<activity
106107
android:name=".activities.BrowserInterceptActivity"
107108
android:label="@string/app_name"
108-
android:theme="@style/Transparent">
109+
android:theme="@style/Theme.AppCompat.Translucent">
109110
<intent-filter>
110111
<action android:name="android.intent.action.VIEW"/>
111112

@@ -140,7 +141,7 @@
140141
android:name=".webheads.helper.ProxyActivity"
141142
android:excludeFromRecents="true"
142143
android:noHistory="true"
143-
android:theme="@style/Transparent"/>
144+
android:theme="@style/Theme.AppCompat.Translucent"/>
144145

145146
<service
146147
android:name=".webheads.qs.WebHeadTile"

app/src/main/java/arun/com/chromer/MainActivity.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package arun.com.chromer;
22

33
import android.app.ActivityOptions;
4+
import android.content.BroadcastReceiver;
5+
import android.content.Context;
46
import android.content.Intent;
7+
import android.content.IntentFilter;
58
import android.net.Uri;
69
import android.os.Bundle;
710
import android.os.Handler;
@@ -81,6 +84,7 @@ public class MainActivity extends AppCompatActivity implements ColorChooserDialo
8184

8285
private CustomTabManager mCustomTabManager;
8386
private Drawer mDrawer;
87+
private BroadcastReceiver closeReceiver;
8488

8589
@Override
8690
protected void onStart() {
@@ -121,6 +125,27 @@ protected void onCreate(Bundle savedInstanceState) {
121125
checkAndEducateUser(false);
122126

123127
ServiceUtil.takeCareOfServices(getApplicationContext());
128+
129+
registerCloseReceiver();
130+
}
131+
132+
@Override
133+
protected void onDestroy() {
134+
super.onDestroy();
135+
LocalBroadcastManager.getInstance(this).unregisterReceiver(closeReceiver);
136+
}
137+
138+
private void registerCloseReceiver() {
139+
closeReceiver = new BroadcastReceiver() {
140+
@Override
141+
public void onReceive(Context context, Intent intent) {
142+
Timber.d("Finished from receiver");
143+
MainActivity.this.finish();
144+
}
145+
};
146+
LocalBroadcastManager.getInstance(this).registerReceiver(
147+
closeReceiver,
148+
new IntentFilter(Constants.ACTION_CLOSE_MAIN));
124149
}
125150

126151
private void setUpAppBarLayout() {
@@ -367,7 +392,7 @@ public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int s
367392
}
368393

369394
private void checkAndEducateUser(boolean forceShow) {
370-
List packages;
395+
final List packages;
371396
if (!forceShow) {
372397
packages = CustomTabs.getCustomTabSupportingPackages(this);
373398
} else {
@@ -504,7 +529,7 @@ public class PagerAdapter extends FragmentPagerAdapter {
504529
getString(R.string.customize)
505530
};
506531

507-
public PagerAdapter(FragmentManager fm) {
532+
PagerAdapter(FragmentManager fm) {
508533
super(fm);
509534
}
510535

app/src/main/java/arun/com/chromer/activities/BrowserInterceptActivity.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.os.Bundle;
1313
import android.provider.Settings;
1414
import android.support.annotation.NonNull;
15+
import android.support.v4.content.LocalBroadcastManager;
1516
import android.support.v7.app.AppCompatActivity;
1617
import android.widget.Toast;
1718

@@ -39,6 +40,8 @@ protected void onCreate(Bundle savedInstanceState) {
3940
return;
4041
}
4142

43+
signalMainFinish();
44+
4245
final boolean isFromNewTab = getIntent().getBooleanExtra(Constants.EXTRA_KEY_FROM_NEW_TAB, false);
4346

4447
// Check if we should blacklist the launching app
@@ -83,9 +86,6 @@ protected void onCreate(Bundle savedInstanceState) {
8386
if (isFromNewTab || Preferences.mergeTabs(this)) {
8487
customTabActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
8588
customTabActivity.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
86-
} else {
87-
customTabActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
88-
customTabActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
8989
}
9090
customTabActivity.putExtra(Constants.EXTRA_KEY_FROM_NEW_TAB, isFromNewTab);
9191
startActivity(customTabActivity);
@@ -94,6 +94,11 @@ protected void onCreate(Bundle savedInstanceState) {
9494
finish();
9595
}
9696

97+
private void signalMainFinish() {
98+
LocalBroadcastManager.getInstance(this)
99+
.sendBroadcast(new Intent(Constants.ACTION_CLOSE_MAIN));
100+
}
101+
97102
private void performBlacklistAction() {
98103
String componentFlatten = Preferences.secondaryBrowserComponent(this);
99104
if (componentFlatten != null && Util.isPackageInstalled(this, Preferences.secondaryBrowserPackage(this))) {

app/src/main/java/arun/com/chromer/activities/CustomTabActivity.java

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
import android.annotation.TargetApi;
44
import android.app.ActivityManager;
5+
import android.content.BroadcastReceiver;
6+
import android.content.Context;
7+
import android.content.Intent;
8+
import android.content.IntentFilter;
59
import android.graphics.Bitmap;
610
import android.os.AsyncTask;
711
import android.os.Build;
812
import android.os.Bundle;
913
import android.os.Handler;
1014
import android.support.annotation.Nullable;
15+
import android.support.v4.content.LocalBroadcastManager;
1116
import android.support.v7.app.AppCompatActivity;
1217
import android.support.v7.graphics.Palette;
1318
import android.widget.Toast;
@@ -34,6 +39,8 @@
3439
public class CustomTabActivity extends AppCompatActivity {
3540
private boolean isLoaded = false;
3641
private ExtractionTask mExtractionTask;
42+
private String mBaseUrl = "";
43+
private BroadcastReceiver mMinimizeReceiver;
3744

3845
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
3946
@Override
@@ -46,26 +53,45 @@ protected void onCreate(Bundle savedInstanceState) {
4653
return;
4754
}
4855

49-
final String url = getIntent().getDataString();
56+
mBaseUrl = getIntent().getDataString();
5057
final boolean isWebhead = getIntent().getBooleanExtra(Constants.EXTRA_KEY_FROM_WEBHEAD, false);
5158

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

5562
Benchmark.start("Custom tab launching in CTA");
5663
CustomTabs.from(this)
57-
.forUrl(url)
64+
.forUrl(mBaseUrl)
5865
.forWebHead(isWebhead)
5966
.overrideToolbarColor(color)
67+
// .noAnimations(Preferences.aggressiveLoading(this))
6068
.prepare()
6169
.launch();
6270
Benchmark.end();
6371

64-
dispatchDescriptionTask(webSite);
65-
6672
if (Preferences.aggressiveLoading(this)) {
6773
delayedGoToBack();
6874
}
75+
76+
dispatchDescriptionTask(webSite);
77+
78+
registerMinimizeReceiver();
79+
}
80+
81+
private void registerMinimizeReceiver() {
82+
mMinimizeReceiver = new BroadcastReceiver() {
83+
@Override
84+
public void onReceive(Context context, Intent intent) {
85+
Timber.d("Minimize called with %s : %s", mBaseUrl, intent.toString());
86+
if (intent.getAction().equalsIgnoreCase(Constants.ACTION_MINIMIZE) && intent.hasExtra(Intent.EXTRA_TEXT)) {
87+
if (mBaseUrl.equalsIgnoreCase(intent.getStringExtra(Intent.EXTRA_TEXT))) {
88+
Timber.d("Minimized %s", intent.getStringExtra(Intent.EXTRA_TEXT));
89+
moveTaskToBack(true);
90+
}
91+
}
92+
}
93+
};
94+
LocalBroadcastManager.getInstance(this).registerReceiver(mMinimizeReceiver, new IntentFilter(Constants.ACTION_MINIMIZE));
6995
}
7096

7197
private void delayedGoToBack() {
@@ -94,7 +120,7 @@ public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glid
94120
}
95121
});
96122
} else {
97-
mExtractionTask = new ExtractionTask(getIntent().getDataString());
123+
mExtractionTask = new ExtractionTask(mBaseUrl);
98124
mExtractionTask.execute();
99125
}
100126
}
@@ -115,6 +141,7 @@ protected void onDestroy() {
115141
mExtractionTask.cancel(true);
116142
}
117143
mExtractionTask = null;
144+
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMinimizeReceiver);
118145
}
119146

120147
@Override
@@ -183,6 +210,9 @@ protected void onPostExecute(Void aVoid) {
183210
label = mUrl.toUpperCase();
184211
}
185212
Timber.d("Setting task description %s", label);
213+
if (mIcon != null && mIcon.getWidth() < 0) {
214+
mIcon = null;
215+
}
186216
if (color != Constants.NO_COLOR) {
187217
setTaskDescription(new ActivityManager.TaskDescription(label, mIcon, color));
188218
} else {

app/src/main/java/arun/com/chromer/activities/payments/util/IabHelper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import java.util.ArrayList;
3737
import java.util.List;
3838

39+
import timber.log.Timber;
40+
3941

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

771773
int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException {
772774
// Query purchases
775+
if (mContext == null) {
776+
Timber.d("User cancelled");
777+
return BILLING_RESPONSE_RESULT_USER_CANCELED;
778+
}
773779
logDebug("Querying owned items, item type: " + itemType);
774780
logDebug("Package name: " + mContext.getPackageName());
775781
boolean verificationFailed = false;

0 commit comments

Comments
 (0)