Skip to content

Instantly share code, notes, and snippets.

@imjeevandeshmukh
Created February 5, 2017 12:19
Show Gist options
  • Save imjeevandeshmukh/88764601e455fb42935a5f1a60022d85 to your computer and use it in GitHub Desktop.
Save imjeevandeshmukh/88764601e455fb42935a5f1a60022d85 to your computer and use it in GitHub Desktop.
Demo
package arun.com.chromer;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.a.ag;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.ImageView.ScaleType;
import android.widget.Toast;
import arun.com.chromer.c.g;
import arun.com.chromer.chrometabutilites.a;
import arun.com.chromer.intro.AppIntroMy;
import com.afollestad.materialdialogs.color.b;
import com.afollestad.materialdialogs.color.j;
import com.afollestad.materialdialogs.m;
import com.mikepenz.materialdrawer.d.l;
import com.mikepenz.materialdrawer.d.p;
import com.mikepenz.materialdrawer.d.s;
import com.mikepenz.materialdrawer.f;
import com.mikepenz.materialdrawer.t;
import com.mikepenz.materialize.e;
public class MainActivity extends ag implements j {
private static final String i = MainActivity.class.getSimpleName();
private a j;
private SharedPreferences k;
private View l;
private void a(String str) {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
if (c(intent)) {
Toast.makeText(this, "Already set!", 0).show();
} else if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
private void b(Toolbar toolbar) {
new t().a((Activity) this).a(toolbar).a(new f().a((Activity) this).a(2130837575).a(ScaleType.CENTER_CROP).a(true).a()).a((com.mikepenz.materialdrawer.d.a.a) ((p) ((p) ((p) new p().a("Intro")).a(4)).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.af)).b(false), (com.mikepenz.materialdrawer.d.a.a) ((p) ((p) ((p) new p().a("Feedback")).a(2)).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.eq)).b(false), (com.mikepenz.materialdrawer.d.a.a) ((p) ((p) ((p) new p().a("Rate on Playstore")).a(3)).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.lz)).b(false), new l(), (com.mikepenz.materialdrawer.d.a.a) ((s) ((s) ((s) new s().a("More on custom tabs")).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.jN)).a(5)).b(false), (com.mikepenz.materialdrawer.d.a.a) ((s) ((s) ((s) ((s) new s().a("Share")).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.mQ)).b("Help Chromer grow!")).a(7)).b(false), (com.mikepenz.materialdrawer.d.a.a) ((s) ((s) ((s) new s().a("Licenses")).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.bK)).a(6)).b(false), (com.mikepenz.materialdrawer.d.a.a) ((s) ((s) ((s) new s().a("About")).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.gP)).a(8)).b(false)).a(new l(this)).b().b(-1);
}
private void b(String str) {
a.a(this, arun.com.chromer.e.f.a(getApplicationContext(), str), Uri.parse(str), TabActivity.i);
}
private boolean c(Intent intent) {
ResolveInfo resolveActivity = getPackageManager().resolveActivity(intent, 0);
String str = null;
if (resolveActivity != null) {
str = resolveActivity.activityInfo.packageName;
}
if (str == null || !str.trim().equalsIgnoreCase(getPackageName())) {
return false;
}
Log.d(i, "Chromer defaulted");
return true;
}
private boolean l() {
if (!this.k.getBoolean("firstrun", true)) {
return false;
}
this.k.edit().putBoolean("firstrun", false).apply();
return true;
}
private void m() {
findViewById(2131689596).setOnClickListener(new h(this));
}
private void n() {
((FloatingActionButton) findViewById(2131689594)).setOnClickListener(new j(this));
}
private void o() {
int i = PreferenceManager.getDefaultSharedPreferences(this).getInt("toolbar_color", android.support.v4.c.a.b(this, e.primary));
findViewById(2131689597).setOnClickListener(new k(this, i));
this.l = findViewById(2131689598);
this.l.setBackgroundColor(i);
}
private void p() {
this.j = new a();
this.j.a(new m(this));
}
private void q() {
if (arun.com.chromer.chrometabutilites.e.b(this).size() == 0) {
new m(this).a((CharSequence) "Compatible custom tab provider not found").b((CharSequence) "Chromer requires you to have any Custom tab compatible browser on your phone. Currently there are no browsers on your phone that supports it. Would you like to install Google Chrome (Free) from play store? If you already have it, then please update it to latest version.").c((CharSequence) "Install").e("No").a(new n(this)).c();
}
}
public void a(b bVar, int i) {
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
this.l.setBackgroundColor(i);
defaultSharedPreferences.edit().putInt("toolbar_color", i).apply();
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(2130968604);
Toolbar toolbar = (Toolbar) findViewById(2131689591);
a(toolbar);
this.k = getSharedPreferences(getPackageName(), 0);
if (l()) {
startActivity(new Intent(this, AppIntroMy.class));
}
if (arun.com.chromer.e.a.a((Context) this)) {
arun.com.chromer.e.a.a((Activity) this);
}
b(toolbar);
n();
p();
o();
findViewById(2131689595).setOnClickListener(new g(this));
m();
f().a().a(2131689599, new g()).a();
q();
}
protected void onStart() {
super.onStart();
this.j.b(this);
}
protected void onStop() {
super.onStop();
this.j.a((Activity) this);
}
}
package arun.com.chromer;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.a.ag;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.ImageView.ScaleType;
import android.widget.Toast;
import arun.com.chromer.c.g;
import arun.com.chromer.chrometabutilites.a;
import arun.com.chromer.intro.AppIntroMy;
import com.afollestad.materialdialogs.color.b;
import com.afollestad.materialdialogs.color.j;
import com.afollestad.materialdialogs.m;
import com.mikepenz.materialdrawer.d.l;
import com.mikepenz.materialdrawer.d.p;
import com.mikepenz.materialdrawer.d.s;
import com.mikepenz.materialdrawer.f;
import com.mikepenz.materialdrawer.t;
import com.mikepenz.materialize.e;
public class MainActivity extends ag implements j {
private static final String i = MainActivity.class.getSimpleName();
private a j;
private SharedPreferences k;
private View l;
private void a(String str) {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
if (c(intent)) {
Toast.makeText(this, "Already set!", 0).show();
} else if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
private void b(Toolbar toolbar) {
new t().a((Activity) this).a(toolbar).a(new f().a((Activity) this).a(2130837575).a(ScaleType.CENTER_CROP).a(true).a()).a((com.mikepenz.materialdrawer.d.a.a) ((p) ((p) ((p) new p().a("Intro")).a(4)).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.af)).b(false), (com.mikepenz.materialdrawer.d.a.a) ((p) ((p) ((p) new p().a("Feedback")).a(2)).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.eq)).b(false), (com.mikepenz.materialdrawer.d.a.a) ((p) ((p) ((p) new p().a("Rate on Playstore")).a(3)).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.lz)).b(false), new l(), (com.mikepenz.materialdrawer.d.a.a) ((s) ((s) ((s) new s().a("More on custom tabs")).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.jN)).a(5)).b(false), (com.mikepenz.materialdrawer.d.a.a) ((s) ((s) ((s) ((s) new s().a("Share")).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.mQ)).b("Help Chromer grow!")).a(7)).b(false), (com.mikepenz.materialdrawer.d.a.a) ((s) ((s) ((s) new s().a("Licenses")).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.bK)).a(6)).b(false), (com.mikepenz.materialdrawer.d.a.a) ((s) ((s) ((s) new s().a("About")).a((com.mikepenz.a.a.a) com.mikepenz.google_material_typeface_library.a.gP)).a(8)).b(false)).a(new l(this)).b().b(-1);
}
private void b(String str) {
a.a(this, arun.com.chromer.e.f.a(getApplicationContext(), str), Uri.parse(str), TabActivity.i);
}
private boolean c(Intent intent) {
ResolveInfo resolveActivity = getPackageManager().resolveActivity(intent, 0);
String str = null;
if (resolveActivity != null) {
str = resolveActivity.activityInfo.packageName;
}
if (str == null || !str.trim().equalsIgnoreCase(getPackageName())) {
return false;
}
Log.d(i, "Chromer defaulted");
return true;
}
private boolean l() {
if (!this.k.getBoolean("firstrun", true)) {
return false;
}
this.k.edit().putBoolean("firstrun", false).apply();
return true;
}
private void m() {
findViewById(2131689596).setOnClickListener(new h(this));
}
private void n() {
((FloatingActionButton) findViewById(2131689594)).setOnClickListener(new j(this));
}
private void o() {
int i = PreferenceManager.getDefaultSharedPreferences(this).getInt("toolbar_color", android.support.v4.c.a.b(this, e.primary));
findViewById(2131689597).setOnClickListener(new k(this, i));
this.l = findViewById(2131689598);
this.l.setBackgroundColor(i);
}
private void p() {
this.j = new a();
this.j.a(new m(this));
}
private void q() {
if (arun.com.chromer.chrometabutilites.e.b(this).size() == 0) {
new m(this).a((CharSequence) "Compatible custom tab provider not found").b((CharSequence) "Chromer requires you to have any Custom tab compatible browser on your phone. Currently there are no browsers on your phone that supports it. Would you like to install Google Chrome (Free) from play store? If you already have it, then please update it to latest version.").c((CharSequence) "Install").e("No").a(new n(this)).c();
}
}
public void a(b bVar, int i) {
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
this.l.setBackgroundColor(i);
defaultSharedPreferences.edit().putInt("toolbar_color", i).apply();
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(2130968604);
Toolbar toolbar = (Toolbar) findViewById(2131689591);
a(toolbar);
this.k = getSharedPreferences(getPackageName(), 0);
if (l()) {
startActivity(new Intent(this, AppIntroMy.class));
}
if (arun.com.chromer.e.a.a((Context) this)) {
arun.com.chromer.e.a.a((Activity) this);
}
b(toolbar);
n();
p();
o();
findViewById(2131689595).setOnClickListener(new g(this));
m();
f().a().a(2131689599, new g()).a();
q();
}
protected void onStart() {
super.onStart();
this.j.b(this);
}
protected void onStop() {
super.onStop();
this.j.a((Activity) this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment