2525import android .content .Context ;
2626import android .content .Intent ;
2727import android .content .pm .PackageManager ;
28- import android .graphics .Bitmap ;
29- import android .graphics .BitmapFactory ;
30- import android .graphics .Color ;
3128import android .graphics .drawable .AnimationDrawable ;
3229import android .net .Uri ;
3330import android .nfc .NfcAdapter ;
4845import android .view .View ;
4946import android .view .ViewGroup ;
5047import android .widget .Button ;
51- import android .widget .ImageView ;
5248import android .widget .ProgressBar ;
5349import android .widget .TextView ;
5450import android .widget .Toast ;
7975import net .grandcentrix .tray .AppPreferences ;
8076import net .grandcentrix .tray .core .ItemNotFoundException ;
8177
82- import java .io .File ;
83- import java .io .FileOutputStream ;
84- import java .io .IOException ;
8578import java .util .ArrayList ;
8679import java .util .Collections ;
87- import java .util .Comparator ;
88- import java .util .HashMap ;
8980import java .util .LinkedHashSet ;
9081import java .util .List ;
9182import java .util .Locale ;
@@ -109,8 +100,6 @@ public MainActivity() {
109100
110101 public static final String INTENT_EXTRA_PREVENT_AUTO_START = "com.psiphon3.MainActivity.PREVENT_AUTO_START" ;
111102 private static final String CURRENT_TAB = "currentTab" ;
112- private static final String BANNER_FILE_NAME = "bannerImage" ;
113-
114103 private final CompositeDisposable compositeDisposable = new CompositeDisposable ();
115104 private Button toggleButton ;
116105 private ProgressBar connectionProgressBar ;
@@ -121,7 +110,6 @@ public MainActivity() {
121110 private AppPreferences multiProcessPreferences ;
122111 private ViewPager viewPager ;
123112 private PsiphonTabLayout tabLayout ;
124- private ImageView banner ;
125113 private boolean isFirstRun = true ;
126114 private AlertDialog upstreamProxyErrorAlertDialog ;
127115 private MenuItem psiphonBumpHelpItem ;
@@ -226,10 +214,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
226214 // Schedule db maintenance
227215 LogsMaintenanceWorker .schedule (getApplicationContext ());
228216
229- // Banner removed in Shir o Khorshid rebrand
230- // banner = findViewById(R.id.banner);
231- // setUpBanner();
232-
233217 // Set up custom Toolbar as ActionBar
234218 Toolbar toolbar = findViewById (R .id .main_toolbar );
235219 setSupportActionBar (toolbar );
@@ -954,80 +938,6 @@ public static boolean shouldLoadInEmbeddedWebView(String url) {
954938 return true ;
955939 }
956940
957- private void setUpBanner () {
958- // Play Store Build instances should use existing banner from previously installed APK
959- // (if present). To enable this, non-Play Store Build instances write their banner to
960- // a private file.
961- try {
962- Bitmap bitmap = getBannerBitmap ();
963- if (!EmbeddedValues .IS_PLAY_STORE_BUILD ) {
964- saveBanner (bitmap );
965- }
966-
967- // If we successfully got the banner image set it and it's background
968- if (bitmap != null ) {
969- banner .setImageBitmap (bitmap );
970- banner .setBackgroundColor (getMostCommonColor (bitmap ));
971- }
972- } catch (IOException e ) {
973- // Ignore failure
974- }
975- }
976-
977- private void saveBanner (Bitmap bitmap ) throws IOException {
978- if (bitmap == null ) {
979- return ;
980- }
981-
982- FileOutputStream out = openFileOutput (BANNER_FILE_NAME , Context .MODE_PRIVATE );
983- bitmap .compress (Bitmap .CompressFormat .PNG , 100 , out );
984- out .close ();
985- }
986-
987- private Bitmap getBannerBitmap () {
988- if (EmbeddedValues .IS_PLAY_STORE_BUILD ) {
989- File bannerImageFile = new File (getFilesDir (), BANNER_FILE_NAME );
990- if (bannerImageFile .exists ()) {
991- return BitmapFactory .decodeFile (bannerImageFile .getAbsolutePath ());
992- }
993- }
994-
995- return BitmapFactory .decodeResource (getResources (), R .drawable .banner );
996- }
997-
998- private int getMostCommonColor (Bitmap bitmap ) {
999- if (bitmap == null ) {
1000- return Color .WHITE ;
1001- }
1002-
1003- int width = bitmap .getWidth ();
1004- int height = bitmap .getHeight ();
1005- int size = width * height ;
1006- int pixels [] = new int [size ];
1007-
1008- bitmap .getPixels (pixels , 0 , width , 0 , 0 , width , height );
1009-
1010- HashMap <Integer , Integer > colorMap = new HashMap <>();
1011-
1012- for (int i = 0 ; i < pixels .length ; i ++) {
1013- int color = pixels [i ];
1014- if (colorMap .containsKey (color )) {
1015- colorMap .put (color , colorMap .get (color ) + 1 );
1016- } else {
1017- colorMap .put (color , 1 );
1018- }
1019- }
1020-
1021- ArrayList <Map .Entry <Integer , Integer >> entries = new ArrayList <>(colorMap .entrySet ());
1022- Collections .sort (entries , new Comparator <Map .Entry <Integer , Integer >>() {
1023- @ Override
1024- public int compare (Map .Entry <Integer , Integer > o1 , Map .Entry <Integer , Integer > o2 ) {
1025- return o2 .getValue ().compareTo (o1 .getValue ());
1026- }
1027- });
1028- return entries .get (0 ).getKey ();
1029- }
1030-
1031941 public void selectTabByTag (@ NonNull Object tag ) {
1032942 viewPager .post (() -> {
1033943 for (int i = 0 ; i < tabLayout .getTabCount (); i ++) {
0 commit comments