diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeController.java index b246c167..7e883401 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeController.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeController.java @@ -146,6 +146,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba private FragmentContainerView mTabFragment; private LinearLayout mTopBarContainer; private View mPopupLoadNewTab; + private ImageView mTopBarHider; /*Redirection Objects*/ private GeckoResult mRenderedBitmap = null; @@ -397,13 +398,14 @@ public class homeController extends AppCompatActivity implements ComponentCallba mProgressBarIndeterminate = findViewById(R.id.pProgressBarIndeterminate); mTabFragment = findViewById(R.id.mTabFragment); mPopupLoadNewTab = findViewById(R.id.pPopupLoadNewTab); + mTopBarHider = findViewById(R.id.pTopBarHider); mGeckoView.setSaveEnabled(false); mGeckoView.setSaveFromParentEnabled(false); mGeckoView.setAutofillEnabled(true); mGeckoClient = new geckoClients(); - mHomeViewController.initialization(new homeViewCallback(),this,mNewTab, mWebViewContainer, mLoadingText, mProgressBar, mSearchbar, mSplashScreen, mLoadingIcon, mBannerAds, mGatewaySplash, mTopBar, mGeckoView, mBackSplash, mConnectButton, mFindBar, mFindText, mFindCount, mTopLayout, mVoiceInput, mMenu, mNestedScroll, mBlocker, mBlockerFullSceen, mSearchEngineBar, mCopyright, mHintListView, mAppBar, mOrbotLogManager, mInfoLandscape, mInfoPortrait, mProgressBarIndeterminate, mTabFragment, mTopBarContainer, mSearchLock, mPopupLoadNewTab); + mHomeViewController.initialization(new homeViewCallback(),this,mNewTab, mWebViewContainer, mLoadingText, mProgressBar, mSearchbar, mSplashScreen, mLoadingIcon, mBannerAds, mGatewaySplash, mTopBar, mGeckoView, mBackSplash, mConnectButton, mFindBar, mFindText, mFindCount, mTopLayout, mVoiceInput, mMenu, mNestedScroll, mBlocker, mBlockerFullSceen, mSearchEngineBar, mCopyright, mHintListView, mAppBar, mOrbotLogManager, mInfoLandscape, mInfoPortrait, mProgressBarIndeterminate, mTabFragment, mTopBarContainer, mSearchLock, mPopupLoadNewTab, mTopBarHider); mGeckoView.onSetHomeEvent(new nestedGeckoViewCallback()); mGeckoClient.initialize(mGeckoView, new geckoViewCallback(), this,false); mGeckoClient.onValidateInitializeFromStartup(); @@ -498,7 +500,6 @@ public class homeController extends AppCompatActivity implements ComponentCallba } } - public void initRuntimeSettings() { mGeckoClient.updateSetting(); @@ -510,6 +511,11 @@ public class homeController extends AppCompatActivity implements ComponentCallba } public void onLoadURL(String url){ + + if(mGeckoView!=null && mGeckoView.getSession()!=null && !mGeckoView.getSession().isOpen()){ + mGeckoView.getSession().open(mGeckoClient.getmRuntime()); + } + mAppBar.animate().cancel(); mHomeViewController.onClearSelections(true); Objects.requireNonNull(mGeckoView.getSession()).stop(); @@ -646,7 +652,6 @@ public class homeController extends AppCompatActivity implements ComponentCallba return false; }); - mFindText.addTextChangedListener(new TextWatcher() { @Override @@ -1005,6 +1010,13 @@ public class homeController extends AppCompatActivity implements ComponentCallba helperMethod.hideKeyboard(this); mHomeViewController.onOpenMenu(view,mGeckoClient.canGoForward(),!(mProgressBar.getAlpha()<=0 || mProgressBar.getVisibility() ==View.INVISIBLE),mGeckoClient.getUserAgent()); + + view.setClickable(false); + new Handler().postDelayed(() -> + { + view.setClickable(true); + }, 500); + } public void onFullScreenSettingChanged(){ @@ -1013,7 +1025,6 @@ public class homeController extends AppCompatActivity implements ComponentCallba public void onDisableTabViewController(){ onResumeDump(); - mHomeViewController.onUpdateStatusBarTheme(mGeckoClient.getSession().getTheme(), true); mHomeViewController.onHideTabContainer(); activityContextManager.getInstance().getTabController().onExitAndClearBackup(); activityContextManager.getInstance().getTabController().onPostExit(); @@ -1023,7 +1034,6 @@ public class homeController extends AppCompatActivity implements ComponentCallba public void onBackPressed(){ if(mTabFragment.getVisibility()==View.VISIBLE){ onResumeDump(); - mHomeViewController.onUpdateStatusBarTheme(mGeckoClient.getSession().getTheme(), false); mHomeViewController.onHideTabContainer(); activityContextManager.getInstance().getTabController().onPostExit(); activityContextManager.getInstance().getTabController().onBackPressed(); @@ -1155,9 +1165,6 @@ public class homeController extends AppCompatActivity implements ComponentCallba if(mGeckoView!=null && mGeckoView.getSession()!=null && !mGeckoView.getSession().isOpen()){ onReDrawGeckoview(); onLoadURL(model.getSession().getCurrentURL()); - }else if(mGeckoView != null){ - mGeckoView.requestFocus(); - mGeckoView.setSession(model.getSession()); } } } @@ -1197,7 +1204,6 @@ public class homeController extends AppCompatActivity implements ComponentCallba } if(status.sSettingIsAppStarted && mAppRestarted) { - onUpdateStatusBarTheme(); activityContextManager.getInstance().onClearStack(); tabRowModel model = (tabRowModel)dataController.getInstance().invokeTab(dataEnums.eTabCommands.GET_CURRENT_TAB, null); @@ -1305,7 +1311,10 @@ public class homeController extends AppCompatActivity implements ComponentCallba } public void onSaveCurrentTab(geckoSession session,boolean isHardCopy){ - dataController.getInstance().invokeTab(dataEnums.eTabCommands.M_ADD_TAB, Arrays.asList(session,isHardCopy)); + int mStatus = (Integer) dataController.getInstance().invokeTab(dataEnums.eTabCommands.M_ADD_TAB, Arrays.asList(session,isHardCopy)); + if(mStatus == enums.AddTabCallback.TAB_FULL){ + pluginController.getInstance().onMessageManagerInvoke(Collections.singletonList(this), M_MAX_TAB_REACHED); + } } public boolean onCloseCurrentTab(geckoSession session){ @@ -1503,6 +1512,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba } public void onReInitTheme(){ + mHomeViewController.onUpdateStatusBarTheme(mGeckoClient.getSession().getTheme(), true); } public void onOrbotLog(View view) { @@ -1537,7 +1547,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba } else if(e_type.equals(enums.etype.M_UPDATE_THEME)) { - mHomeViewController.onUpdateStatusBarTheme(mGeckoClient.getSession().getTheme(), false); + mHomeViewController.onUpdateStatusBarTheme(mGeckoClient.getSession().getTheme(), true); } else if(e_type.equals(enums.etype.ON_UPDATE_THEME)){ mHomeViewController.onUpdateStatusBarTheme(mGeckoClient.getSession().getTheme(),false); diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeViewController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeViewController.java index deeb627d..493d2282 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeViewController.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/homeController/homeViewController.java @@ -108,14 +108,17 @@ class homeViewController private LinearLayout mTopBarContainer; private ImageView mSearchLock; private View mPopupLoadNewTab; + private ImageView mTopBarHider; /*Local Variables*/ private Callable mLogs = null; private boolean isLandscape = false; private boolean isFullScreen = false; private MovementMethod mSearchBarMovementMethod = null; + private Handler mTabDialogHandler = null; + private Runnable mTabDialogRunnable = null; - void initialization(eventObserver.eventListener event, AppCompatActivity context, Button mNewTab, ConstraintLayout webviewContainer, TextView loadingText, AnimatedProgressBar progressBar, editTextManager searchbar, ConstraintLayout splashScreen, ImageView loading, AdView banner_ads, ImageButton gateway_splash, LinearLayout top_bar, GeckoView gecko_view, ImageView backsplash, Button connect_button, View pFindBar, EditText pFindText, TextView pFindCount, androidx.constraintlayout.widget.ConstraintLayout pTopLayout, ImageButton pVoiceInput, ImageButton pMenu, androidx.core.widget.NestedScrollView pNestedScroll, ImageView pBlocker, ImageView pBlockerFullSceen, View mSearchEngineBar, TextView pCopyright, RecyclerView pHistListView, com.google.android.material.appbar.AppBarLayout pAppBar, ImageButton pOrbotLogManager, ConstraintLayout pInfoLandscape, ConstraintLayout pInfoPortrait, ProgressBar pProgressBarIndeterminate, FragmentContainerView pTabFragment, LinearLayout pTopBarContainer, ImageView pSearchLock, View pPopupLoadNewTab){ + void initialization(eventObserver.eventListener event, AppCompatActivity context, Button mNewTab, ConstraintLayout webviewContainer, TextView loadingText, AnimatedProgressBar progressBar, editTextManager searchbar, ConstraintLayout splashScreen, ImageView loading, AdView banner_ads, ImageButton gateway_splash, LinearLayout top_bar, GeckoView gecko_view, ImageView backsplash, Button connect_button, View pFindBar, EditText pFindText, TextView pFindCount, androidx.constraintlayout.widget.ConstraintLayout pTopLayout, ImageButton pVoiceInput, ImageButton pMenu, androidx.core.widget.NestedScrollView pNestedScroll, ImageView pBlocker, ImageView pBlockerFullSceen, View mSearchEngineBar, TextView pCopyright, RecyclerView pHistListView, com.google.android.material.appbar.AppBarLayout pAppBar, ImageButton pOrbotLogManager, ConstraintLayout pInfoLandscape, ConstraintLayout pInfoPortrait, ProgressBar pProgressBarIndeterminate, FragmentContainerView pTabFragment, LinearLayout pTopBarContainer, ImageView pSearchLock, View pPopupLoadNewTab, ImageView pTopBarHider){ this.mContext = context; this.mProgressBar = progressBar; this.mSearchbar = searchbar; @@ -150,6 +153,7 @@ class homeViewController this.mTopBarContainer = pTopBarContainer; this.mSearchLock = pSearchLock; this.mPopupLoadNewTab = pPopupLoadNewTab; + this.mTopBarHider = pTopBarHider; initSplashScreen(); createUpdateUiHandler(); @@ -209,13 +213,19 @@ class homeViewController mPopupLoadNewTab.setVisibility(View.VISIBLE); mPopupLoadNewTab.animate().setDuration(350).alpha(1); - final Handler handler = new Handler(); - handler.postDelayed(this::onHideLoadTabDialog, 2500); + if(mTabDialogHandler!=null){ + mTabDialogHandler.removeCallbacksAndMessages(null); + } + + mTabDialogHandler = new Handler(); + mTabDialogRunnable = this::onHideLoadTabDialog; + mTabDialogHandler.postDelayed(mTabDialogRunnable, 7500); } public void onHideLoadTabDialog() { mPopupLoadNewTab.findViewById(R.id.pBlockerUndo).setVisibility(View.VISIBLE); mPopupLoadNewTab.animate().cancel(); + mPopupLoadNewTab.animate().setDuration(350).alpha(0).withEndAction(() -> { mPopupLoadNewTab.setVisibility(View.GONE); }); @@ -225,10 +235,13 @@ class homeViewController if(mTabFragment.getAlpha()==0 || mTabFragment.getAlpha()==1){ onUpdateStatusBarTheme(null, false); + mTabFragment.setAlpha(0); mTabFragment.setTranslationY(0); mTabFragment.setVisibility(View.VISIBLE); mTabFragment.setTranslationY(-1 * helperMethod.pxFromDp(15)); + mTopBarHider.setVisibility(View.VISIBLE); + mTopBarHider.animate().alpha(1).setDuration(0); new Handler().postDelayed(() -> { @@ -248,12 +261,14 @@ class homeViewController public void onHideTabContainer(){ if(mTabFragment.getAlpha()==1){ - mEvent.invokeObserver(null, enums.etype.M_UPDATE_THEME); - mTabFragment.animate() - .setDuration(150) - .alpha(0f).withEndAction(() -> mTabFragment.setVisibility(View.GONE)); + new Handler().postDelayed(() -> + { + mTopBarHider.animate().alpha(0).setDuration(0).setStartDelay(0).withEndAction(() -> mTopBarHider.setVisibility(View.GONE)); + mEvent.invokeObserver(null, enums.etype.M_UPDATE_THEME); + }, 150); + + mTabFragment.animate() .setDuration(150).alpha(0f).withEndAction(() -> mTabFragment.setVisibility(View.GONE)); mEvent.invokeObserver(Collections.singletonList(status.sSettingSearchStatus), enums.etype.M_INIT_TAB_COUNT); - mEvent.invokeObserver(null, enums.etype.M_UPDATE_THEME); } } @@ -652,6 +667,7 @@ class homeViewController ImageButton back = popupView.findViewById(R.id.menu22); ImageButton close = popupView.findViewById(R.id.menu20); CheckBox desktop = popupView.findViewById(R.id.menu27); + LinearLayout newTab = popupView.findViewById(R.id.menu11); desktop.setChecked(userAgent==USER_AGENT_MODE_DESKTOP); if(!canGoForward){ @@ -663,6 +679,14 @@ class homeViewController close.setColorFilter(Color.argb(255, 191, 191, 191)); } + newTab.setClickable(false); + close.setClickable(false); + new Handler().postDelayed(() -> + { + newTab.setClickable(true); + close.setClickable(true); + }, 300); + } void downloadNotification(String message, enums.etype e_type){ @@ -804,7 +828,7 @@ class homeViewController public void onUpdateStatusBarTheme(String pTheme, boolean mForced) { if(mSplashScreen.getAlpha()<=0 && (status.sTheme != enums.Theme.THEME_DARK && !status.sDefaultNightMode) && mTabFragment.getAlpha()<=0 || mForced){ - int mColor = -1; + int mColor; try{ mColor = Color.parseColor(pTheme); }catch (Exception ex){ @@ -822,9 +846,13 @@ class homeViewController mGradientDrawable.setCornerRadius(helperMethod.pxFromDp(7)); GradientDrawable gradientDrawable1 = new GradientDrawable(); - gradientDrawable1.setColor(ColorUtils.blendARGB(helperMethod.invertedShadeColor(mColor,0.90f), Color.BLACK, 0.2f)); + gradientDrawable1.setColor(ColorUtils.blendARGB(helperMethod.invertedShadeColor(mColor,0.50f), Color.BLACK, 0.2f)); gradientDrawable1.setCornerRadius(helperMethod.pxFromDp(4)); - gradientDrawable1.setStroke(helperMethod.pxFromDp(2), mColor); + + GradientDrawable gradientDrawable3 = new GradientDrawable(); + gradientDrawable3.setColor(ColorUtils.blendARGB(helperMethod.invertedShadeColor(mColor,0.50f), Color.BLACK, 0.2f)); + gradientDrawable3.setCornerRadius(helperMethod.pxFromDp(4)); + gradientDrawable3.setStroke(helperMethod.pxFromDp(2), helperMethod.invertedGrayColor(mColor)); GradientDrawable gradientDrawable2 = new GradientDrawable(); gradientDrawable2.setColor(ColorUtils.blendARGB(helperMethod.invertedShadeColor(mColor,0.90f), Color.BLACK, 0.2f)); @@ -832,7 +860,7 @@ class homeViewController gradientDrawable2.setStroke(helperMethod.pxFromDp(2), helperMethod.invertedGrayColor(mColor)); StateListDrawable states = new StateListDrawable(); - InsetDrawable mInsetDrawable1 = new InsetDrawable(gradientDrawable1, helperMethod.pxFromDp(8), helperMethod.pxFromDp(8), helperMethod.pxFromDp(8), helperMethod.pxFromDp(8)); + InsetDrawable mInsetDrawable1 = new InsetDrawable(gradientDrawable3, helperMethod.pxFromDp(8), helperMethod.pxFromDp(8), helperMethod.pxFromDp(8), helperMethod.pxFromDp(8)); InsetDrawable mInsetDrawable2 = new InsetDrawable(gradientDrawable2, helperMethod.pxFromDp(8), helperMethod.pxFromDp(8), helperMethod.pxFromDp(8), helperMethod.pxFromDp(8)); states.addState(new int[] {android.R.attr.state_pressed}, mInsetDrawable1); @@ -846,6 +874,8 @@ class homeViewController mSearchLock.setColorFilter(helperMethod.invertedGrayColor(mColor)); mSearchLock.setTag(R.id.themed,true); gradientDrawable1.setCornerRadius(helperMethod.pxFromDp(7)); + gradientDrawable1.setStroke(helperMethod.pxFromDp(2), mColor); + gradientDrawable1.setColor(ColorUtils.blendARGB(helperMethod.invertedShadeColor(mColor,0.90f), Color.BLACK, 0.2f)); mSearchbar.setBackground(gradientDrawable1); mSearchbar.setHintTextColor(ColorUtils.blendARGB(helperMethod.invertedShadeColor(mColor,0.10f), Color.BLACK, 0.2f)); @@ -895,7 +925,10 @@ class homeViewController mVoiceInput.setColorFilter(ContextCompat.getColor(mContext, R.color.c_navigation_tint)); mSearchbar.setTextColor(ContextCompat.getColor(mContext, R.color.c_text_v1)); mSearchbar.setHintTextColor(ContextCompat.getColor(mContext, R.color.c_text_v2)); - onUpdateSearchIcon(1); + + if(!mSearchbar.isFocused()){ + onUpdateSearchIcon(1); + } if(status.sTheme != enums.Theme.THEME_DARK && !status.sDefaultNightMode){ mContext.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceController.java index 68c21fd9..e7ce3b73 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceController.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceController.java @@ -35,7 +35,9 @@ public class settingAdvanceController extends AppCompatActivity { private SwitchMaterial mRestoreTabs; private SwitchMaterial mShowWebFonts; private SwitchMaterial mToolbarTheme; + private ArrayList mImageOption = new ArrayList<>(); + private ArrayList mTabLayoutOption = new ArrayList<>(); private boolean mIsChanged = false; /* Initializations */ @@ -64,9 +66,11 @@ public class settingAdvanceController extends AppCompatActivity { mToolbarTheme = findViewById(R.id.pToolbarTheme); mImageOption.add(findViewById(R.id.pAdvanceImageOption1)); mImageOption.add(findViewById(R.id.pAdvanceImageOption2)); + mTabLayoutOption.add(findViewById(R.id.pAdvanceGridOption1)); + mTabLayoutOption.add(findViewById(R.id.pAdvanceGridOption2)); activityContextManager.getInstance().onStack(this); - mSettingAdvanceViewController = new settingAdvanceViewController(this, new settingAdvanceViewCallback(), mRestoreTabs, mShowWebFonts, mToolbarTheme, mImageOption); + mSettingAdvanceViewController = new settingAdvanceViewController(this, new settingAdvanceViewCallback(), mRestoreTabs, mShowWebFonts, mToolbarTheme, mImageOption, mTabLayoutOption); mSettingAdvanceModel = new settingAdvanceModel(new settingAdvanceModelCallback()); } @@ -153,6 +157,13 @@ public class settingAdvanceController extends AppCompatActivity { dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_SET_INT, Arrays.asList(keys.SETTING_SHOW_IMAGES,status.sShowImages)); } + public void onGridView(View view) { + mSettingAdvanceViewController.onTrigger(settingAdvanceEnums.eAdvanceViewController.M_CLEAR_GRID, Collections.singletonList(null)); + mSettingAdvanceModel.onTrigger(settingAdvanceEnums.eAdvanceModel.M_SHOW_TAB_GRID, Collections.singletonList(view)); + mSettingAdvanceViewController.onTrigger(settingAdvanceEnums.eAdvanceViewController.M_SET_GRID, Collections.singletonList(view)); + dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_SET_BOOL, Arrays.asList(keys.SETTING_SHOW_TAB_GRID,status.sTabGridLayoutEnabled)); + } + public void onShowWebFonts(View view) { mIsChanged = true; mSettingAdvanceModel.onTrigger(settingAdvanceEnums.eAdvanceModel.M_SHOW_WEB_FONTS, Collections.singletonList(!mShowWebFonts.isChecked())); diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceEnums.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceEnums.java index 6a0f1591..c2bdcdb9 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceEnums.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceEnums.java @@ -4,11 +4,11 @@ class settingAdvanceEnums { /*History Manager*/ public enum eAdvanceModel { - M_RESTORE_TAB, M_SHOW_IMAGE, M_SHOW_WEB_FONTS, M_TOOLBAR_THEME + M_RESTORE_TAB, M_SHOW_IMAGE, M_SHOW_TAB_GRID, M_SHOW_WEB_FONTS, M_TOOLBAR_THEME } public enum eAdvanceViewController { - M_CLEAR_IMAGE, M_SET_IMAGE + M_CLEAR_IMAGE, M_SET_IMAGE, M_CLEAR_GRID, M_SET_GRID } } \ No newline at end of file diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceModel.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceModel.java index f92d328f..c63af967 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceModel.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceModel.java @@ -36,6 +36,16 @@ class settingAdvanceModel } } + private void onShowTabGrid(View pView) { + + if(pView.getId() == R.id.pGridOption1){ + status.sTabGridLayoutEnabled = true; + } + else if(pView.getId() == R.id.pGridOption2){ + status.sTabGridLayoutEnabled = false; + } + } + private void onShowWebFonts(boolean pStatus) { status.sShowWebFonts = pStatus; } @@ -57,6 +67,9 @@ class settingAdvanceModel else if(pCommands.equals(settingAdvanceEnums.eAdvanceModel.M_TOOLBAR_THEME)){ onToolbarThemeChange((boolean)pData.get(0)); } + else if(pCommands.equals(settingAdvanceEnums.eAdvanceModel.M_SHOW_TAB_GRID)){ + onShowTabGrid((View)pData.get(0)); + } return null; } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceViewController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceViewController.java index 0c7d4534..f9f9e7db 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceViewController.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/advanceManager/settingAdvanceViewController.java @@ -27,10 +27,11 @@ class settingAdvanceViewController private SwitchMaterial mShowWebFonts; private SwitchMaterial mToolbarTheme; private ArrayList mImageOption; + private ArrayList mTabLayoutOption; /*Initializations*/ - settingAdvanceViewController(settingAdvanceController pContext, eventObserver.eventListener pEvent, SwitchMaterial pRestoreTabs, SwitchMaterial pShowWebFonts, SwitchMaterial pToolbarTheme, ArrayList pImageOption) + settingAdvanceViewController(settingAdvanceController pContext, eventObserver.eventListener pEvent, SwitchMaterial pRestoreTabs, SwitchMaterial pShowWebFonts, SwitchMaterial pToolbarTheme, ArrayList pImageOption, ArrayList pTabLayoutOption) { this.mEvent = pEvent; this.mContext = pContext; @@ -38,6 +39,7 @@ class settingAdvanceViewController this.mShowWebFonts = pShowWebFonts; this.mToolbarTheme = pToolbarTheme; this.mImageOption = pImageOption; + this.mTabLayoutOption = pTabLayoutOption; initViews(); initPostUI(); @@ -72,6 +74,16 @@ class settingAdvanceViewController mImageOption.get(1).setButtonTintList(ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.c_radio_tint))); mImageOption.get(1).setChecked(true); } + + if(status.sTabGridLayoutEnabled){ + mTabLayoutOption.get(0).setButtonTintList(ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.c_radio_tint))); + mTabLayoutOption.get(0).setChecked(true); + } + else{ + mTabLayoutOption.get(1).setButtonTintList(ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.c_radio_tint))); + mTabLayoutOption.get(1).setChecked(true); + } + } private void initPostUI(){ @@ -98,6 +110,13 @@ class settingAdvanceViewController mImageOption.get(1).setButtonTintList(ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.c_radio_tint_default))); } + private void clearGridOptions(){ + mTabLayoutOption.get(0).setChecked(false); + mTabLayoutOption.get(1).setChecked(false); + mTabLayoutOption.get(0).setButtonTintList(ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.c_radio_tint_default))); + mTabLayoutOption.get(1).setButtonTintList(ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.c_radio_tint_default))); + } + private void setImageOptions(View pView){ clearImageOptions(); if(pView.getId() == R.id.pAdvanceOption1){ @@ -110,13 +129,32 @@ class settingAdvanceViewController } } + private void setGridOptions(View pView){ + clearGridOptions(); + if(pView.getId() == R.id.pGridOption1){ + mTabLayoutOption.get(0).setButtonTintList(ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.c_radio_tint))); + mTabLayoutOption.get(0).setChecked(true); + } + else if(pView.getId() == R.id.pGridOption2){ + mTabLayoutOption.get(1).setButtonTintList(ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.c_radio_tint))); + mTabLayoutOption.get(1).setChecked(true); + } + } + public Object onTrigger(settingAdvanceEnums.eAdvanceViewController pCommands, List pData){ if(pCommands.equals(settingAdvanceEnums.eAdvanceViewController.M_CLEAR_IMAGE)){ clearImageOptions(); } + else if(pCommands.equals(settingAdvanceEnums.eAdvanceViewController.M_CLEAR_GRID)){ + clearGridOptions(); + } + else if(pCommands.equals(settingAdvanceEnums.eAdvanceViewController.M_SET_IMAGE)){ setImageOptions((View) pData.get(0)); } + else if(pCommands.equals(settingAdvanceEnums.eAdvanceViewController.M_SET_GRID)){ + setGridOptions((View) pData.get(0)); + } return null; } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/generalManager/settingGeneralController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/generalManager/settingGeneralController.java index 5380a8ed..c61e227b 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/generalManager/settingGeneralController.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/settingManager/generalManager/settingGeneralController.java @@ -138,7 +138,6 @@ public class settingGeneralController extends AppCompatActivity { onBackPressed(); overridePendingTransition(R.anim.fade_in_lang, R.anim.fade_out_lang); activityContextManager.getInstance().getSettingController().onReInitTheme(); - activityContextManager.getInstance().getHomeController().onReInitTheme(); helperMethod.openActivity(settingGeneralController.class, constants.CONST_LIST_HISTORY, settingGeneralController.this,true); } } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabAdapter.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabAdapter.java index de4eb707..a6699d2c 100755 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabAdapter.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabAdapter.java @@ -16,9 +16,12 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.darkweb.genesissearchengine.appManager.activityContextManager; import com.darkweb.genesissearchengine.constants.enums; +import com.darkweb.genesissearchengine.constants.status; import com.darkweb.genesissearchengine.helperManager.TopCropImageView; import com.darkweb.genesissearchengine.helperManager.eventObserver; import com.darkweb.genesissearchengine.helperManager.helperMethod; @@ -68,8 +71,13 @@ public class tabAdapter extends RecyclerView.Adapter @NonNull @Override public listViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.tab_row_view, parent, false); - return new listViewHolder(view); + if(status.sTabGridLayoutEnabled){ + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.tab_grid_view, parent, false); + return new listViewHolder(view); + }else { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.tab_row_view, parent, false); + return new listViewHolder(view); + } } @Override public void onBindViewHolder(@NonNull tabAdapter.listViewHolder holder, int position) @@ -250,7 +258,7 @@ public class tabAdapter extends RecyclerView.Adapter mItemSelectionMenuButton.setOnClickListener(this); }else { if(model.getSession().getTheme()==null){ - mBorder.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), R.color.c_border_background_divider)); + mBorder.setBackgroundColor(ContextCompat.getColor(itemView.getContext(), R.color.c_ripple_v2)); }else { try{ mBorder.setBackgroundColor(Color.parseColor(model.getSession().getTheme())); @@ -271,12 +279,17 @@ public class tabAdapter extends RecyclerView.Adapter }else { mHeader.setText(model.getSession().getTitle()); } - mDescription.setText(mURL); + + if(status.sTabGridLayoutEnabled){ + mDescription.setText(helperMethod.getDomainName(mURL)); + }else { + mDescription.setText(mURL); + } mDate.setText(model.getDate()); mWebThumbnail.setImageBitmap(model.getBitmap()); if(getLayoutPosition()==0){ - mEvent.invokeObserver(Arrays.asList(mWebThumbnail, mURL), enums.etype.fetch_thumbnail); + // mEvent.invokeObserver(Arrays.asList(mWebThumbnail, mURL), enums.etype.fetch_thumbnail); } if(mSelectedList.contains(model.getSession().getSessionID())){ @@ -286,7 +299,9 @@ public class tabAdapter extends RecyclerView.Adapter } if(model.getSession().equals(mModelList.get(0).getSession())){ - itemView.setBackgroundColor(ContextCompat.getColor(activityContextManager.getInstance().getHomeController(), R.color.c_list_item_current)); + if(!status.sTabGridLayoutEnabled){ + itemView.setBackgroundColor(ContextCompat.getColor(activityContextManager.getInstance().getHomeController(), R.color.c_list_item_current)); + } }else { Drawable mDrawable; Resources res = itemView.getContext().getResources(); @@ -319,6 +334,7 @@ public class tabAdapter extends RecyclerView.Adapter mLongPressMenuEnabled = false; mItemSelectionMenuButton.animate().setDuration(250).alpha(1); } + mRemoveRow.bringToFront(); } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabController.java index f071c25f..35b45bfd 100755 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabController.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabController.java @@ -1,22 +1,22 @@ package com.darkweb.genesissearchengine.appManager.tabManager; import android.annotation.SuppressLint; -import android.content.Context; -import android.content.pm.ActivityInfo; import android.graphics.Canvas; import android.os.Bundle; import android.os.Handler; +import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.core.widget.NestedScrollView; import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -24,6 +24,7 @@ import androidx.recyclerview.widget.SimpleItemAnimator; import com.darkweb.genesissearchengine.appManager.activityContextManager; import com.darkweb.genesissearchengine.appManager.homeManager.geckoManager.geckoSession; import com.darkweb.genesissearchengine.appManager.homeManager.homeController.homeController; +import com.darkweb.genesissearchengine.appManager.settingManager.advanceManager.settingAdvanceController; import com.darkweb.genesissearchengine.appManager.settingManager.settingHomePage.settingHomeController; import com.darkweb.genesissearchengine.constants.constants; import com.darkweb.genesissearchengine.constants.status; @@ -49,6 +50,7 @@ public class tabController extends Fragment private TextView mSelectionCount; private ImageView mBlocker; private View mRootView; + private NestedScrollView mNestedScrollView; /*Private Variables*/ @@ -58,6 +60,10 @@ public class tabController extends Fragment private tabViewController mtabViewController; private RecyclerView mRecycleView; private tabAdapter mTabAdapter; + private Handler mScrollHandler = null; + private Runnable mScrollRunnable = null; + int minScroll = 0; + int maxScroll = 0; /*Initializations*/ @@ -100,8 +106,9 @@ public class tabController extends Fragment mPopupUndo = mRootView.findViewById(R.id.pPopupUndo); mSelectionCount = mRootView.findViewById(R.id.pSelectionCount); mBlocker = mRootView.findViewById(R.id.pBlocker); + mNestedScrollView = mRootView.findViewById(R.id.pNestedScroll); - mtabViewController = new tabViewController(this, mTabs, mRemoveSelection, mMenuButton, mClearSelection, mPopupUndo, mSelectionCount, mBlocker, mRecycleView); + mtabViewController = new tabViewController(this, mTabs, mRemoveSelection, mMenuButton, mClearSelection, mPopupUndo, mSelectionCount, mBlocker, mRecycleView, mNestedScrollView); } @SuppressLint("ClickableViewAccessibility") @@ -112,24 +119,65 @@ public class tabController extends Fragment } return false; }); + + mNestedScrollView.setOnTouchListener((v, event) -> { + if (event.getAction() == MotionEvent.ACTION_UP) { + onSwipeBounce(0); + } + + return false; + }); + + mNestedScrollView.getViewTreeObserver().addOnScrollChangedListener(() -> { + int scrollY = mNestedScrollView.getScrollY(); + + minScroll = scrollY; + maxScroll = mRecycleView.computeVerticalScrollRange() - helperMethod.pxFromDp(500); + onSwipeBounce(300); + }); + + mNestedScrollView.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> { + if (mRecycleView.getChildAt(mRecycleView.getChildCount() - 1) != null) { + if ((scrollY >= (mRecycleView.getChildAt(mRecycleView.getChildCount() - 1).getMeasuredHeight() - mRecycleView.getMeasuredHeight())) && scrollY > oldScrollY) { + Log.i("FUCK2:::::::",scrollY+""); + onSwipeBounce(0); + } + } + }); + } + + public void onSwipeBounce(int mDuration){ + if(minScroll > maxScroll){ + if(mScrollHandler!=null){ + mScrollHandler.removeCallbacksAndMessages(null); + } + + mScrollHandler = new Handler(); + mScrollRunnable = () -> { + mNestedScrollView.clearFocus(); + mRecycleView.clearFocus(); + mNestedScrollView.smoothScrollTo(0, maxScroll); + }; + mScrollHandler.postDelayed(mScrollRunnable, mDuration); + } } public void initializeList(){ - LinearLayoutManager layoutManager = new LinearLayoutManager(this.getContext()); tabAdapter adapter = new tabAdapter(mListModel.getList(),new adapterCallback()); mTabAdapter = adapter; - layoutManager.setReverseLayout(true); ((SimpleItemAnimator) Objects.requireNonNull(mRecycleView.getItemAnimator())).setSupportsChangeAnimations(false); mRecycleView.setAdapter(adapter); - mRecycleView.setItemViewCacheSize(100); mRecycleView.setNestedScrollingEnabled(false); - mRecycleView.setHasFixedSize(true); - mRecycleView.setItemViewCacheSize(100); - mRecycleView.setDrawingCacheEnabled(true); - mRecycleView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); - mRecycleView.setLayoutManager(new LinearLayoutManager(this.getContext())); + mRecycleView.setHasFixedSize(false); + + if(status.sTabGridLayoutEnabled){ + mRecycleView.setLayoutManager(new GridLayoutManager(this.getContext(), 2)); + }else { + mRecycleView.setLayoutManager(new LinearLayoutManager(this.getContext())); + } + initTabCount(0); } @@ -174,20 +222,18 @@ public class tabController extends Fragment mTabAdapter.onTrigger(tabEnums.eTabAdapterCommands.NOTIFY_SWIPE, Collections.singletonList(position)); } onShowUndoDialog(); - - final Handler handler = new Handler(); - handler.postDelayed(() -> - { - ViewGroup.LayoutParams params = mRecycleView.getLayoutParams(); - params.height = helperMethod.pxFromDp((mTabAdapter.getItemCount()) * 90); - mRecycleView.setLayoutParams(params); - }, 400); - + viewHolder.itemView.animate().alpha(0); } @Override public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { + float alpha = 1 - (Math.abs(dX) / recyclerView.getWidth())*1.75f; + if(alpha <0.35){ + alpha = 0.35f; + } + viewHolder.itemView.setAlpha(alpha); + Canvas mCanvas = (Canvas) mtabViewController.onTrigger(tabEnums.eTabViewCommands.ON_GENERATE_SWIPABLE_BACKGROUND, Arrays.asList(c, viewHolder, dX, actionState)); super.onChildDraw(mCanvas, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); } @@ -210,35 +256,27 @@ public class tabController extends Fragment initTabCount(400); activityContextManager.getInstance().getHomeController().onLoadTabFromTabController(); mTabAdapter.onTrigger(tabEnums.eTabAdapterCommands.INIT_FIRST_ROW, null); + onSwipeBounce(0); } public boolean onInitRemoveView(int pIndex, boolean pCreateBackup){ mListModel.onTrigger(tabEnums.eModelCallback.M_REMOVE_TAB,Collections.singletonList(pIndex)); mListModel.getList().remove(pIndex); if(mListModel.getList().size()<1){ - mRecycleView.animate().setDuration(350).alpha(0).withEndAction(() -> { - mTabAdapter.notifyDataSetChanged(); - }); + mRecycleView.animate().setDuration(350).alpha(0).withEndAction(() -> mTabAdapter.notifyDataSetChanged()); activityContextManager.getInstance().getHomeController().onLoadTabFromTabController(); + new Handler().postDelayed(() -> onSwipeBounce(0), 400); return false; }else{ mTabAdapter.notifyItemRangeChanged(pIndex, mTabAdapter.getItemCount() - pIndex); activityContextManager.getInstance().getHomeController().onLoadTabFromTabController(); + new Handler().postDelayed(() -> onSwipeBounce(0), 400); return true; } } public void initTabCount(int pDelay) { - final Handler handler = new Handler(); - handler.postDelayed(() -> - { - if(mListModel.getList().size()>0){ - ViewGroup.LayoutParams params = mRecycleView.getLayoutParams(); - params.height = helperMethod.pxFromDp((mTabAdapter.getItemCount()) * 90); - mRecycleView.setLayoutParams(params); - } - }, pDelay); activityContextManager.getInstance().getHomeController().initTabCountForced(); } @@ -247,8 +285,7 @@ public class tabController extends Fragment } public void onNewTabInvoked(){ - int mBackupList = ((ArrayList)mListModel.onTrigger(tabEnums.eModelCallback.M_GET_BACKUP,null)).size(); - if(mListModel.getList().size()-mBackupList>=1){ + if(mListModel.getList().size()>=1){ mHomeController.onNewTabBackground(true,false); } onClose(); @@ -258,9 +295,6 @@ public class tabController extends Fragment public void onRestoreTab(View view){ ArrayList mBackup = (ArrayList)mListModel.onTrigger(tabEnums.eModelCallback.M_LOAD_BACKUP,null); - ViewGroup.LayoutParams params = mRecycleView.getLayoutParams(); - params.height = helperMethod.pxFromDp((mTabAdapter.getItemCount()+mBackup.size()) * 90); - mRecycleView.setLayoutParams(params); final Handler handler = new Handler(); handler.postDelayed(() -> @@ -328,10 +362,15 @@ public class tabController extends Fragment mtabViewController.onTrigger(tabEnums.eTabViewCommands.ON_SHOW_SELECTION_MENU, Arrays.asList(false,0)); mtabViewController.onTrigger(tabEnums.eTabViewCommands.ON_HIDE_SELECTION, null); activityContextManager.getInstance().getHomeController().onLoadTabFromTabController(); + + // mTabAdapter.notifyDataSetChanged(); + initTabCount(400); + } public void onClearSelection(View view) { mTabAdapter.onTrigger(tabEnums.eTabAdapterCommands.M_CLEAR_ALL_SELECTION, null); + mNestedScrollView.smoothScrollTo(0,0); } public void onTriggerSelected(View view){ @@ -353,11 +392,10 @@ public class tabController extends Fragment mRecycleView.animate().setDuration(350).alpha(0).withEndAction(() -> { onClearTabBackup(); mTabAdapter.onTrigger(tabEnums.eTabAdapterCommands.REMOVE_ALL, null); - initTabCount(400); }); } else if(pView.getId() == R.id.pOpenSetting){ - helperMethod.openActivity(settingHomeController.class, constants.CONST_LIST_HISTORY, activityContextManager.getInstance().getHomeController(),true); + helperMethod.openActivity(settingAdvanceController.class, constants.CONST_LIST_HISTORY, activityContextManager.getInstance().getHomeController(),true); } mtabViewController.onTrigger(tabEnums.eTabViewCommands.M_DISMISS_MENU, null); } @@ -371,7 +409,6 @@ public class tabController extends Fragment @Override public void onStop() { - // onBackPressed(); super.onStop(); } @@ -379,7 +416,6 @@ public class tabController extends Fragment public void onPause() { status.sSettingIsAppPaused = true; - // onBackPressed(); super.onPause(); } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabViewController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabViewController.java index a1a4ae3e..c237b77f 100755 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabViewController.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/tabManager/tabViewController.java @@ -12,6 +12,7 @@ import android.os.Build; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.ActionMenuView; @@ -19,10 +20,12 @@ import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.PopupWindow; +import android.widget.RelativeLayout; import android.widget.TextView; import androidx.appcompat.app.AppCompatDelegate; import androidx.core.content.ContextCompat; +import androidx.core.widget.NestedScrollView; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; @@ -47,6 +50,7 @@ class tabViewController private TextView mSelectionCount; private ImageView mBlocker; private RecyclerView mRecycleView; + private NestedScrollView mNestedScrollView; /*Private Local Variables*/ private Handler mDelayHandler = new Handler(); @@ -54,7 +58,7 @@ class tabViewController /*Initializations*/ - tabViewController(Fragment mContext, Button pTabs, ImageView pRemoveSelection, ImageButton pMenuButton, ImageButton pClearSelection, View pToastLayoutRoot, TextView pSelectionCount, ImageView pBlocker, RecyclerView pRecycleView) + tabViewController(Fragment mContext, Button pTabs, ImageView pRemoveSelection, ImageButton pMenuButton, ImageButton pClearSelection, View pToastLayoutRoot, TextView pSelectionCount, ImageView pBlocker, RecyclerView pRecycleView, NestedScrollView pNestedScrollView) { this.mContext = mContext; this.mTabs = pTabs; @@ -65,6 +69,7 @@ class tabViewController this.mSelectionCount = pSelectionCount; this.mBlocker = pBlocker; this.mRecycleView = pRecycleView; + this.mNestedScrollView = pNestedScrollView; initUI(); initPostUI(); @@ -86,6 +91,10 @@ class tabViewController mMenuButton.animate().setStartDelay(200).setDuration(350).alpha(1); mMenuButton.setVisibility(View.VISIBLE); + if(!status.sTabGridLayoutEnabled){ + mNestedScrollView.setPadding(0,0,0,0); + } + onHideUndoDialogInit(); } @@ -214,22 +223,26 @@ class tabViewController if(pDX > 0){ if(status.sTheme == enums.Theme.THEME_DARK){ - pCanvas.drawARGB(150, 59, 57, 70); + pCanvas.drawARGB(255,28, 27, 33); }else { - pCanvas.drawARGB(150, 230, 230, 230); + pCanvas.drawARGB(255, 255, 255, 255); + } + if(!status.sTabGridLayoutEnabled){ + icon = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.dustbin); + RectF icon_dest = new RectF((float) itemView.getLeft() + width ,(float) itemView.getTop() + width,(float) itemView.getLeft()+ 2*width,(float)itemView.getBottom() - width); + pCanvas.drawBitmap(icon,null,icon_dest, mPainter); } - icon = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.dustbin); - RectF icon_dest = new RectF((float) itemView.getLeft() + width ,(float) itemView.getTop() + width,(float) itemView.getLeft()+ 2*width,(float)itemView.getBottom() - width); - pCanvas.drawBitmap(icon,null,icon_dest, mPainter); } else { if(status.sTheme == enums.Theme.THEME_DARK){ - pCanvas.drawARGB(150, 59, 57, 70); + pCanvas.drawARGB(255,28, 27, 33); }else { - pCanvas.drawARGB(150, 230, 230, 230); + pCanvas.drawARGB(255, 255, 255, 255); + } + if(!status.sTabGridLayoutEnabled){ + icon = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.dustbin); + RectF icon_dest = new RectF((float) itemView.getRight() - 2*width ,(float) itemView.getTop() + width,(float) itemView.getRight() - width,(float)itemView.getBottom() - width); + pCanvas.drawBitmap(icon,null,icon_dest, mPainter); } - icon = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.dustbin); - RectF icon_dest = new RectF((float) itemView.getRight() - 2*width ,(float) itemView.getTop() + width,(float) itemView.getRight() - width,(float)itemView.getBottom() - width); - pCanvas.drawBitmap(icon,null,icon_dest, mPainter); } } } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/constants/enums.java b/app/src/main/java/com/darkweb/genesissearchengine/constants/enums.java index 083fd78a..a791ffb1 100755 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/enums.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/enums.java @@ -13,6 +13,11 @@ public class enums /*General Enums*/ + public static class AddTabCallback { + public static final int TAB_ADDED = 0; + public static final int TAB_FULL = 1; + } + public static class Theme { public static final int THEME_LIGHT = 0; public static final int THEME_DARK = 1; diff --git a/app/src/main/java/com/darkweb/genesissearchengine/constants/keys.java b/app/src/main/java/com/darkweb/genesissearchengine/constants/keys.java index dd2aa2b4..a22ee7da 100755 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/keys.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/keys.java @@ -49,12 +49,14 @@ public class keys public static final String SETTING_RESTORE_TAB = "SETTING_RESTORE_TAB"; public static final String SETTING_CHARACTER_ENCODING = "SETTING_CHARACTER_ENCODING"; public static final String SETTING_SHOW_IMAGES = "SETTING_SHOW_IMAGES"; + public static final String SETTING_SHOW_TAB_GRID = "SETTING_SHOW_TAB_GRID"; public static final String SETTING_SHOW_FONTS = "SETTING_SHOW_FONTS"; public static final String SETTING_TOOLBAR_THEME = "SETTING_TOOLBAR_THEME"; public static final String SETTING_THEME = "SETTING_THEME_LIGHT"; public static final String SETTING_FULL_SCREEN_BROWSIING = "SETTING_FULL_SCREEN_BROWSIING"; public static final String SETTING_OPEN_URL_IN_NEW_TAB = "SETTING_OPEN_URL_IN_NEW_TAB"; public static final String SETTING_LIST_VIEW = "SETTING_LIST_VIEW"; + public static final String SETTING_TOOLBAR_THEME_ALLOWED = "SETTING_TOOLBAR_THEME_ALLOWED"; /*Bridge Settings*/ diff --git a/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java b/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java index 07bdde3d..55af2f81 100755 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java @@ -24,6 +24,7 @@ public class status public static String sSettingLanguage = "en"; public static String sSettingLanguageRegion = "Us"; public static String mReferenceWebsites; + public static String sBridgeCustomBridge = strings.GENERIC_EMPTY_STR; public static boolean sSettingEnableZoom = true; public static boolean sSettingEnableVoiceInput = true; @@ -40,9 +41,8 @@ public class status public static boolean sSettingIsAppRated = false; public static boolean sSettingFontAdjustable = true; public static boolean sSettingFirstStart = true; - public static int sSettingTrackingProtection = 0; public static boolean mThemeApplying = false; - + public static boolean sTabGridLayoutEnabled = true; public static boolean sStatusDoNotTrack = true; public static boolean sRestoreTabs = false; public static boolean sCharacterEncoding = false; @@ -52,23 +52,19 @@ public class status public static boolean sOpenURLInNewTab = true; public static boolean sDefaultNightMode; public static boolean sLogListView; - - public static float sSettingFontSize = 1; + public static boolean sBridgeGatewayAuto = false; + public static boolean sBridgeGatewayManual = false; + public static boolean sVPNStatus = false; + public static boolean sBridgeStatus = false; public static int sTheme = enums.Theme.THEME_DEFAULT; public static int sSettingCookieStatus = ContentBlocking.AntiTracking.DEFAULT; public static int sShowImages = -1; public static int sWidgetResponse = enums.WidgetResponse.NONE; - - /*Bridge Status*/ - - public static String sBridgeCustomBridge = strings.GENERIC_EMPTY_STR; - public static boolean sBridgeGatewayAuto = false; - public static boolean sBridgeGatewayManual = false; - public static boolean sVPNStatus = false; - public static boolean sBridgeStatus = false; public static int sBridgeNotificationManual = 0; + public static int sSettingTrackingProtection = 0; + public static float sSettingFontSize = 1; public static void initStatus() { @@ -92,13 +88,11 @@ public class status status.sSettingCookieStatus = (int)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_INT, Arrays.asList(keys.SETTING_COOKIE_ADJUSTABLE,ACCEPT_FIRST_PARTY)); status.sSettingFontSize = (int)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_FLOAT, Arrays.asList(keys.SETTING_FONT_SIZE,100)); status.sSettingLanguage = (String)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_STRING, Arrays.asList(keys.SETTING_LANGUAGE,strings.SETTING_DEFAULT_LANGUAGE)); - status.mReferenceWebsites = (String)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_STRING, Arrays.asList(keys.HOME_REFERENCE_WEBSITES,strings.HOME_REFERENCE_WEBSITES_DEFAULT)); status.sSettingLanguageRegion = (String)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_STRING, Arrays.asList(keys.SETTING_LANGUAGE_REGION,strings.SETTING_DEFAULT_LANGUAGE_REGION)); status.sSettingSearchStatus = (String)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_STRING, Arrays.asList(keys.SETTING_SEARCH_ENGINE,constants.CONST_BACKEND_GENESIS_URL)); status.sBridgeCustomBridge = (String)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_STRING, Arrays.asList(keys.BRIDGE_CUSTOM_BRIDGE_1,strings.BRIDGE_CUSTOM_BRIDGE_OBFS4)); status.sBridgeNotificationManual = (int)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_INT, Arrays.asList(keys.SETTING_NOTIFICATION_STATUS,0)); - status.sRestoreTabs = (boolean)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_BOOL, Arrays.asList(keys.SETTING_RESTORE_TAB,false)); status.sCharacterEncoding = (boolean)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_BOOL, Arrays.asList(keys.SETTING_CHARACTER_ENCODING,false)); status.sShowImages = (int)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_INT, Arrays.asList(keys.SETTING_SHOW_IMAGES,0)); @@ -108,6 +102,7 @@ public class status status.sTheme = (int)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_INT, Arrays.asList(keys.SETTING_THEME,enums.Theme.THEME_DEFAULT)); status.sOpenURLInNewTab = (boolean)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_BOOL, Arrays.asList(keys.SETTING_OPEN_URL_IN_NEW_TAB,true)); status.sLogListView = (boolean)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_BOOL, Arrays.asList(keys.SETTING_LIST_VIEW,true)); + status.sTabGridLayoutEnabled = (boolean)dataController.getInstance().invokePrefs(dataEnums.ePreferencesCommands.M_GET_BOOL, Arrays.asList(keys.SETTING_SHOW_TAB_GRID,true)); } } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/dataManager/tabDataModel.java b/app/src/main/java/com/darkweb/genesissearchengine/dataManager/tabDataModel.java index f419995a..a990c27e 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/dataManager/tabDataModel.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/dataManager/tabDataModel.java @@ -2,32 +2,26 @@ package com.darkweb.genesissearchengine.dataManager; import android.annotation.SuppressLint; import android.content.ContentValues; -import android.content.pm.ActivityInfo; import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.os.Handler; import android.os.Message; import android.util.Log; import android.widget.ImageView; - import androidx.annotation.NonNull; - import com.darkweb.genesissearchengine.appManager.activityContextManager; import com.darkweb.genesissearchengine.appManager.databaseManager.databaseController; import com.darkweb.genesissearchengine.appManager.homeManager.geckoManager.NestedGeckoView; import com.darkweb.genesissearchengine.appManager.homeManager.geckoManager.geckoSession; import com.darkweb.genesissearchengine.appManager.tabManager.tabRowModel; import com.darkweb.genesissearchengine.constants.enums; -import com.darkweb.genesissearchengine.constants.messages; -import com.darkweb.genesissearchengine.constants.status; import com.darkweb.genesissearchengine.constants.strings; -import com.darkweb.genesissearchengine.helperManager.helperMethod; - import org.mozilla.geckoview.GeckoResult; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; -import java.util.Collections; import java.util.List; import java.util.Locale; @@ -53,12 +47,13 @@ class tabDataModel } } - void addTabs(geckoSession mSession,boolean pIsDataSavable){ + int addTabs(geckoSession mSession,boolean pIsDataSavable){ tabRowModel mTabModel = new tabRowModel(mSession); mTabs.add(0,mTabModel); if(mTabs.size()>20){ closeTab(mTabs.get(mTabs.size()-1).getSession(), mTabs.get(mTabs.size()-1).getmId()); + return enums.AddTabCallback.TAB_FULL; } if(pIsDataSavable){ @@ -70,6 +65,7 @@ class tabDataModel databaseController.getInstance().execSQL("REPLACE INTO tab(mid,date,title,url,theme) VALUES('"+ mTabModel.getmId() +"','" + m_date + "',?,?,?);",params); } + return enums.AddTabCallback.TAB_ADDED; } void clearTab() { @@ -139,7 +135,6 @@ class tabDataModel boolean updateTab(String mSessionID, geckoSession pSession) { - boolean mSessionUpdated = false; for(int counter = 0; counter< mTabs.size(); counter++){ if(mTabs.get(counter).getSession().getSessionID().equals(mSessionID)) @@ -148,16 +143,12 @@ class tabDataModel params[0] = mTabs.get(counter).getSession().getTitle(); params[1] = mTabs.get(counter).getSession().getCurrentURL(); params[2] = mTabs.get(counter).getSession().getTheme(); - mSessionUpdated = true; - String m_date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.ENGLISH).format(Calendar.getInstance().getTime()); databaseController.getInstance().execSQL("UPDATE tab SET date = '" + m_date + "' , url = ? , title = ?, theme = ? WHERE mid='"+mTabs.get(counter).getmId() + "'",params); return true; } } - if(!mSessionUpdated){ - addTabs(pSession, true); - } + addTabs(pSession, true); return false; } @@ -231,8 +222,11 @@ class tabDataModel if (mTabs.get(counter).getSession().getSessionID().equals(pSessionID)) { GeckoResult mResult = pBitmapManager.withHandler(handler); Bitmap mBitmap = pBitmapManager.poll(4000); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + mBitmap.compress(Bitmap.CompressFormat.PNG, 20, out); + Bitmap decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray())); - mTabs.get(finalCounter).setmBitmap(mBitmap); + mTabs.get(finalCounter).setmBitmap(decoded); if(pImageView!=null){ activityContextManager.getInstance().getHomeController().runOnUiThread(() -> pImageView.setImageBitmap(mBitmap)); } @@ -298,7 +292,7 @@ class tabDataModel clearTab(); } else if(pCommands == dataEnums.eTabCommands.M_ADD_TAB){ - addTabs((geckoSession)pData.get(0), (boolean)pData.get(1)); + return addTabs((geckoSession)pData.get(0), (boolean)pData.get(1)); } else if(pCommands == dataEnums.eTabCommands.M_UPDATE_TAB){ updateTab((String) pData.get(1), (geckoSession) pData.get(5)); diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/messageManager.java b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/messageManager.java index 82c22bf7..3f78ab4e 100755 --- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/messageManager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/messageManager.java @@ -1,7 +1,6 @@ package com.darkweb.genesissearchengine.pluginManager; import android.app.Dialog; -import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; import android.graphics.Color; @@ -10,7 +9,6 @@ import android.graphics.drawable.Drawable; import android.graphics.drawable.InsetDrawable; import android.net.Uri; import android.os.Handler; -import android.util.Log; import android.view.Gravity; import android.view.Window; import android.view.WindowManager; @@ -152,15 +150,15 @@ class messageManager private void newIdentityCreated() { + final Handler handler = new Handler(); + Runnable runnable = () -> mDialog.dismiss(); + initializeDialog(R.layout.popup_new_circuit, Gravity.BOTTOM); mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss()); - final Handler handler = new Handler(); - Runnable runnable = () -> { - mDialog.dismiss(); - }; - handler.postDelayed(runnable, 1500); + mDialog.setOnDismissListener(dialog -> handler.removeCallbacks(runnable)); + handler.postDelayed(runnable, 1500); } private void popupBlocked() @@ -183,6 +181,26 @@ class messageManager } + private void maxTabReached() + { + final Handler handler = new Handler(); + Runnable runnable = () -> { + mDialog.dismiss(); + }; + + initializeDialog(R.layout.popup_max_tab, Gravity.BOTTOM); + mDialog.getWindow().setDimAmount(0); + mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> { + mDialog.dismiss(); + handler.removeCallbacks(runnable); + }); + + mDialog.setOnDismissListener(dialog -> handler.removeCallbacks(runnable)); + + handler.postDelayed(runnable, 1500); + + } + private void notSupportMessage() { initializeDialog(R.layout.popup_not_supported, Gravity.BOTTOM); @@ -611,6 +629,11 @@ class messageManager /*VERIFIED*/ popupBlocked(); break; + + case M_MAX_TAB_REACHED: + /*VERIFIED*/ + maxTabReached(); + break; } } } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/pluginEnums.java b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/pluginEnums.java index aa1e59dc..be94047a 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/pluginEnums.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/pluginEnums.java @@ -28,7 +28,7 @@ public class pluginEnums /*Message Manager*/ public enum eMessageManager{ - M_RESET, M_DATA_CLEARED, M_SECURE_CONNECTION, M_POPUP_BLOCKED,M_DOWNLOAD_SINGLE, M_UPDATE_BRIDGES, M_NEW_IDENTITY, M_NOT_SUPPORTED, M_BRIDGE_MAIL, M_LONG_PRESS_WITH_LINK, M_LONG_PRESS_URL, M_LONG_PRESS_DOWNLOAD, M_START_ORBOT, M_DOWNLOAD_FILE, M_RATE_APP, M_REPORT_URL, M_CLEAR_BOOKMARK, M_CLEAR_HISTORY, M_BOOKMARK, M_RATE_SUCCESS, M_RATE_FAILURE, M_LANGUAGE_SUPPORT_FAILURE, M_WELCOME + M_RESET, M_DATA_CLEARED, M_SECURE_CONNECTION, M_POPUP_BLOCKED, M_MAX_TAB_REACHED,M_DOWNLOAD_SINGLE, M_UPDATE_BRIDGES, M_NEW_IDENTITY, M_NOT_SUPPORTED, M_BRIDGE_MAIL, M_LONG_PRESS_WITH_LINK, M_LONG_PRESS_URL, M_LONG_PRESS_DOWNLOAD, M_START_ORBOT, M_DOWNLOAD_FILE, M_RATE_APP, M_REPORT_URL, M_CLEAR_BOOKMARK, M_CLEAR_HISTORY, M_BOOKMARK, M_RATE_SUCCESS, M_RATE_FAILURE, M_LANGUAGE_SUPPORT_FAILURE, M_WELCOME } public enum eMessageManagerCallbacks{ M_CANCEL_WELCOME, M_APP_RATED, M_DOWNLOAD_FILE_MANUAL, M_OPEN_LINK_CURRENT_TAB, M_COPY_LINK, M_REQUEST_BRIDGES, M_SET_BRIDGES, M_OPEN_LINK_NEW_TAB, M_CLEAR_TAB, M_RATE_APPLICATION, M_OPEN_PRIVACY diff --git a/app/src/main/res/custom-xml/tab/xml/tx_border.xml b/app/src/main/res/custom-xml/tab/xml/tx_border.xml new file mode 100644 index 00000000..51c1f8ef --- /dev/null +++ b/app/src/main/res/custom-xml/tab/xml/tx_border.xml @@ -0,0 +1,17 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/custom-xml/tab/xml/tx_border_image_dark_no_corner.xml b/app/src/main/res/custom-xml/tab/xml/tx_border_image_dark_no_corner.xml new file mode 100644 index 00000000..5b9b4d00 --- /dev/null +++ b/app/src/main/res/custom-xml/tab/xml/tx_border_image_dark_no_corner.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/app/src/main/res/custom-xml/tab/xml/tx_ripple_light.xml b/app/src/main/res/custom-xml/tab/xml/tx_ripple_light.xml new file mode 100644 index 00000000..30e269bb --- /dev/null +++ b/app/src/main/res/custom-xml/tab/xml/tx_ripple_light.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-hdpi/tick_recycler_view.png b/app/src/main/res/drawable-hdpi/tick_recycler_view.png index 69e28ce2..3526b49c 100644 Binary files a/app/src/main/res/drawable-hdpi/tick_recycler_view.png and b/app/src/main/res/drawable-hdpi/tick_recycler_view.png differ diff --git a/app/src/main/res/layouts/alert/layout/popup_max_tab.xml b/app/src/main/res/layouts/alert/layout/popup_max_tab.xml new file mode 100644 index 00000000..b836f0f8 --- /dev/null +++ b/app/src/main/res/layouts/alert/layout/popup_max_tab.xml @@ -0,0 +1,74 @@ + + + + + + + +