forked from mirrors/Fedilab
Fix issue #27 - Enable custom tabs from settings to support autofill with password managers
This commit is contained in:
parent
cdeb2eb2db
commit
6d77ad0faf
3 changed files with 59 additions and 87 deletions
|
@ -150,8 +150,6 @@ public class LoginActivity extends BaseActivity {
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(LoginActivity.this);
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(LoginActivity.this);
|
||||||
boolean embedded_browser = sharedpreferences.getBoolean(getString(R.string.SET_EMBEDDED_BROWSER), true);
|
boolean embedded_browser = sharedpreferences.getBoolean(getString(R.string.SET_EMBEDDED_BROWSER), true);
|
||||||
menu.findItem(R.id.action_custom_tabs).setChecked(!embedded_browser);
|
menu.findItem(R.id.action_custom_tabs).setChecked(!embedded_browser);
|
||||||
/* boolean security_provider = sharedpreferences.getBoolean(getString(R.string.SET_SECURITY_PROVIDER), true);
|
|
||||||
menu.findItem(R.id.action_provider).setChecked(security_provider);*/
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,45 +160,17 @@ public class LoginActivity extends BaseActivity {
|
||||||
// as you specify a parent activity in AndroidManifest.xml.
|
// as you specify a parent activity in AndroidManifest.xml.
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
//noinspection SimplifiableIfStatement
|
if (id == R.id.action_proxy) {
|
||||||
if (id == R.id.action_about) {
|
Intent intent = new Intent(LoginActivity.this, ProxyActivity.class);
|
||||||
// Intent intent = new Intent(LoginActivity.this, AboutActivity.class);
|
startActivity(intent);
|
||||||
// startActivity(intent);
|
} else if (id == R.id.action_custom_tabs) {
|
||||||
} else if (id == R.id.action_privacy) {
|
item.setChecked(!item.isChecked());
|
||||||
// Intent intent = new Intent(LoginActivity.this, PrivacyActivity.class);
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(LoginActivity.this);
|
||||||
// startActivity(intent);
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
} else if (id == R.id.action_proxy) {
|
editor.putBoolean(getString(R.string.SET_EMBEDDED_BROWSER), !item.isChecked());
|
||||||
Intent intent = new Intent(LoginActivity.this, ProxyActivity.class);
|
editor.apply();
|
||||||
startActivity(intent);
|
return false;
|
||||||
} else if (id == R.id.action_custom_tabs) {
|
}
|
||||||
item.setChecked(!item.isChecked());
|
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(LoginActivity.this);
|
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
||||||
editor.putBoolean(getString(R.string.SET_EMBEDDED_BROWSER), !item.isChecked());
|
|
||||||
editor.apply();
|
|
||||||
return false;
|
|
||||||
} else if (id == R.id.action_provider) {
|
|
||||||
/* item.setChecked(!item.isChecked());
|
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
||||||
editor.putBoolean(getString(R.string.SET_SECURITY_PROVIDER), item.isChecked());
|
|
||||||
editor.apply();*/
|
|
||||||
return false;
|
|
||||||
} else if (id == R.id.action_import_data) {
|
|
||||||
/* if (ContextCompat.checkSelfPermission(LoginActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
|
|
||||||
PackageManager.PERMISSION_GRANTED) {
|
|
||||||
ActivityCompat.requestPermissions(LoginActivity.this,
|
|
||||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
|
||||||
TootActivity.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
||||||
intent.setType("*/*");
|
|
||||||
String[] mimetypes = {"*/*"};
|
|
||||||
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
|
|
||||||
startActivityForResult(intent, PICK_IMPORT);
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ import java.net.URLEncoder;
|
||||||
|
|
||||||
import app.fedilab.android.BaseMainActivity;
|
import app.fedilab.android.BaseMainActivity;
|
||||||
import app.fedilab.android.R;
|
import app.fedilab.android.R;
|
||||||
|
import app.fedilab.android.activities.ProxyActivity;
|
||||||
import app.fedilab.android.activities.WebviewConnectActivity;
|
import app.fedilab.android.activities.WebviewConnectActivity;
|
||||||
import app.fedilab.android.client.entities.Account;
|
import app.fedilab.android.client.entities.Account;
|
||||||
import app.fedilab.android.client.entities.InstanceSocial;
|
import app.fedilab.android.client.entities.InstanceSocial;
|
||||||
|
@ -175,44 +176,40 @@ public class FragmentLoginMain extends Fragment {
|
||||||
PopupMenu popupMenu = new PopupMenu(new ContextThemeWrapper(requireActivity(), Helper.popupStyle()), binding.menuIcon);
|
PopupMenu popupMenu = new PopupMenu(new ContextThemeWrapper(requireActivity(), Helper.popupStyle()), binding.menuIcon);
|
||||||
MenuInflater menuInflater = popupMenu.getMenuInflater();
|
MenuInflater menuInflater = popupMenu.getMenuInflater();
|
||||||
menuInflater.inflate(R.menu.main_login, popupMenu.getMenu());
|
menuInflater.inflate(R.menu.main_login, popupMenu.getMenu());
|
||||||
|
MenuItem customTabItem = popupMenu.getMenu().findItem(R.id.action_custom_tabs);
|
||||||
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||||
|
boolean embedded_browser = sharedpreferences.getBoolean(getString(R.string.SET_EMBEDDED_BROWSER), true);
|
||||||
|
customTabItem.setChecked(!embedded_browser);
|
||||||
popupMenu.setOnMenuItemClickListener(item -> {
|
popupMenu.setOnMenuItemClickListener(item -> {
|
||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
if (itemId == R.id.action_about) {
|
if (itemId == R.id.action_proxy) {
|
||||||
/* Todo: Open about page */
|
Intent intent = new Intent(requireActivity(), ProxyActivity.class);
|
||||||
} else if (itemId == R.id.action_privacy) {
|
startActivity(intent);
|
||||||
/* Todo: Open privacy page */
|
|
||||||
} else if (itemId == R.id.action_proxy) {
|
|
||||||
/* Todo: Open proxy settings */
|
|
||||||
} else if (itemId == R.id.action_custom_tabs) {
|
} else if (itemId == R.id.action_custom_tabs) {
|
||||||
setMenuItemKeepOpen(item);
|
boolean checked = !embedded_browser;
|
||||||
/* Todo: Toggle custom tabs */
|
item.setChecked(!item.isChecked());
|
||||||
} else if (itemId == R.id.action_import_data) {
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
/* Todo: Import data */
|
editor.putBoolean(getString(R.string.SET_EMBEDDED_BROWSER), checked);
|
||||||
} else if (itemId == R.id.action_provider) {
|
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||||
setMenuItemKeepOpen(item);
|
item.setActionView(new View(requireContext()));
|
||||||
/* Todo: Toggle security provider */
|
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
editor.apply();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
popupMenu.show();
|
popupMenu.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMenuItemKeepOpen(MenuItem item) {
|
|
||||||
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
|
||||||
item.setActionView(new View(requireContext()));
|
|
||||||
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
<item
|
<!--
|
||||||
android:id="@+id/action_about"
|
<item
|
||||||
android:title="@string/action_about"
|
android:id="@+id/action_about"
|
||||||
app:showAsAction="never" />
|
android:title="@string/action_about"
|
||||||
<item
|
app:showAsAction="never" />
|
||||||
android:id="@+id/action_privacy"
|
|
||||||
android:title="@string/action_privacy"
|
<item
|
||||||
app:showAsAction="never" />
|
android:id="@+id/action_privacy"
|
||||||
|
android:title="@string/action_privacy"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
-->
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_proxy"
|
android:id="@+id/action_proxy"
|
||||||
android:title="@string/proxy_set"
|
android:title="@string/proxy_set"
|
||||||
|
@ -18,13 +21,15 @@
|
||||||
android:checkable="true"
|
android:checkable="true"
|
||||||
android:title="@string/custom_tabs"
|
android:title="@string/custom_tabs"
|
||||||
app:actionViewClass="android.widget.CheckBox" />
|
app:actionViewClass="android.widget.CheckBox" />
|
||||||
<item
|
<!--
|
||||||
android:id="@+id/action_import_data"
|
<item
|
||||||
android:title="@string/import_data"
|
android:id="@+id/action_import_data"
|
||||||
app:showAsAction="never" />
|
android:title="@string/import_data"
|
||||||
<item
|
app:showAsAction="never" />
|
||||||
android:id="@+id/action_provider"
|
<item
|
||||||
android:checkable="true"
|
android:id="@+id/action_provider"
|
||||||
android:title="@string/set_security_provider"
|
android:checkable="true"
|
||||||
app:actionViewClass="android.widget.CheckBox" />
|
android:title="@string/set_security_provider"
|
||||||
|
app:actionViewClass="android.widget.CheckBox" />
|
||||||
|
-->
|
||||||
</menu>
|
</menu>
|
||||||
|
|
Loading…
Reference in a new issue