Skip to content

Commit

Permalink
Fixed forward button behavior and improved initial navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehasawii committed Apr 19, 2023
1 parent 3585107 commit 17a6ecc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId "com.txtnet.txtnetbrowser"
//minSdk 19
targetSdk 33
versionCode 211
versionName "2.1.1"
versionCode 213
versionName "2.1.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.debug
Expand Down
17 changes: 13 additions & 4 deletions app/src/main/java/com/txtnet/txtnetbrowser/MainBrowserScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,29 @@ public void onClick(View v) {
public void onClick(View v) {
if (webView.canGoBack()) {
webView.goBack();
urlEditText.setText(webView.getUrl());
}
}
});
forward.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//if (webView.canGoForward()) {
// webView.goForward();
//}
if (webView.canGoForward()) {

/*
WebBackForwardList mWebBackForwardList = myWebView.copyBackForwardList();
if (mWebBackForwardList.getCurrentIndex() > 0)
historyUrl = mWebBackForwardList.getItemAtIndex(mWebBackForwardList.getCurrentIndex()-1).getUrl();
*/
webView.goForward();
urlEditText.setText(webView.getUrl());
}


// mGetContent.launch("encoded.br");
Brotli4jLoader.ensureAvailability();
Log.e("hereswhatsup", "e: " + String.valueOf(Brotli4jLoader.isAvailable()));
Log.e("IsBrotliAvailable", "e: " + String.valueOf(Brotli4jLoader.isAvailable()));
//UseBrotliTest test = new UseBrotliTest();
// Log.e("shizukualive", String.valueOf(Shizuku.pingBinder())); // "Normal apps should use listeners rather calling this method everytime"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.DividerItemDecoration;
Expand All @@ -26,6 +27,7 @@
import android.view.ViewGroup;
import android.widget.Toast;

import com.txtnet.txtnetbrowser.MainBrowserScreen;
import com.txtnet.txtnetbrowser.R;
import com.txtnet.txtnetbrowser.database.DBInstance;
import com.txtnet.txtnetbrowser.database.Server;
Expand All @@ -41,7 +43,7 @@ public class ServerPickerActivity extends AppCompatActivity {

private ServerPickerModel mViewModel;
public static final int NEW_SERVER_ACTIVITY_REQUEST_CODE = 1;

private boolean NEEDS_DEFAULT = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -60,8 +62,12 @@ protected void onCreate(Bundle savedInstanceState) {
boolean needsDefault = intent.getBooleanExtra("needDefault", false);
if(needsDefault){
ViewGroup view = (ViewGroup) findViewById(android.R.id.content);
Snackbar.make(view.getRootView(), "Please enter a phone number and select it as default!", Snackbar.LENGTH_LONG).setAction("OK", null).show();
Snackbar snackbar = Snackbar.make(view.getRootView(), "Please enter a phone number and select it as default!", Snackbar.LENGTH_LONG).setAction("OK", null);
//snackbar.setAnchorView(getWindow().getDecorView());
snackbar.show();
}
NEEDS_DEFAULT = needsDefault;



// FloatingActionButton fab = binding.fab;
Expand Down Expand Up @@ -115,7 +121,7 @@ protected void onCreate(Bundle savedInstanceState) {
public void instantiateUnderlayButton(RecyclerView.ViewHolder viewHolder, List<UnderlayButton> underlayButtons) {
ServerViewHolder holder = (ServerViewHolder) viewHolder;
underlayButtons.add(new SwipeHelper.UnderlayButton(
"Delete",
"DELETE",
0,
Color.parseColor("#FF3C30"),
new SwipeHelper.UnderlayButtonClickListener() {
Expand All @@ -137,6 +143,19 @@ public void onClick(int pos) {
};
}

@Override
public void onBackPressed() {
SharedPreferences prefs = getSharedPreferences(getPackageName() + "_preferences", MODE_PRIVATE);
String phoneNumber = prefs.getString(getResources().getString(R.string.phone_number), null);
if(NEEDS_DEFAULT && (phoneNumber != null)) {
Intent intent = new Intent(this, MainBrowserScreen.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
ActivityCompat.finishAffinity(ServerPickerActivity.this);
}else{
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
Expand Down

0 comments on commit 17a6ecc

Please sign in to comment.