mirror of
https://github.com/TrianguloY/UrlChecker.git
synced 2024-09-20 04:12:14 +02:00
parent
c6b7bc8011
commit
2c24f4553a
@ -115,7 +115,8 @@ public class ConfigActivity extends Activity {
|
|||||||
title.setOnClickListener(v -> {
|
title.setOnClickListener(v -> {
|
||||||
boolean checked = child.getVisibility() == View.GONE;
|
boolean checked = child.getVisibility() == View.GONE;
|
||||||
child.setVisibility(checked ? View.VISIBLE : View.GONE);
|
child.setVisibility(checked ? View.VISIBLE : View.GONE);
|
||||||
title.setCompoundDrawablesWithIntrinsicBounds(checked ? R.drawable.arrow_down : R.drawable.arrow_right, 0, 0, 0);
|
AndroidUtils.setStartDrawables(title,
|
||||||
|
checked ? R.drawable.arrow_down : R.drawable.arrow_right);
|
||||||
});
|
});
|
||||||
title.performClick(); // initial hide
|
title.performClick(); // initial hide
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.trianguloy.urlchecker.activities;
|
package com.trianguloy.urlchecker.activities;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -55,7 +54,7 @@ public class MainActivity extends Activity {
|
|||||||
break;
|
break;
|
||||||
case R.id.m_img_icon:
|
case R.id.m_img_icon:
|
||||||
// click on the app icon
|
// click on the app icon
|
||||||
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (BuildConfig.DEBUG) {
|
||||||
chooseLocaleDebug();
|
chooseLocaleDebug();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -71,13 +70,16 @@ public class MainActivity extends Activity {
|
|||||||
* To be replaced with a proper implementation with issue
|
* To be replaced with a proper implementation with issue
|
||||||
* https://github.com/TrianguloY/UrlChecker/issues/45
|
* https://github.com/TrianguloY/UrlChecker/issues/45
|
||||||
*/
|
*/
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
private void chooseLocaleDebug() {
|
private void chooseLocaleDebug() {
|
||||||
String[] locales = new String[]{"en", "es", "fr-FR", "iw", "pt-PT", "tr", "uk"};
|
String[] locales = new String[]{"en", "es", "fr-FR", "iw", "pt-PT", "tr", "uk"};
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setItems(locales, (dialog, which) -> {
|
.setItems(locales, (dialog, which) -> {
|
||||||
Configuration config = new Configuration();
|
Configuration config = new Configuration();
|
||||||
config.setLocale(Locale.forLanguageTag(locales[which]));
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
config.setLocale(Locale.forLanguageTag(locales[which]));
|
||||||
|
}else{
|
||||||
|
config.locale = new Locale(locales[which]);
|
||||||
|
}
|
||||||
getBaseContext().getResources()
|
getBaseContext().getResources()
|
||||||
.updateConfiguration(config, null);
|
.updateConfiguration(config, null);
|
||||||
recreate();
|
recreate();
|
||||||
|
@ -152,11 +152,10 @@ class RemoveQueriesDialog extends AModuleDialog implements View.OnClickListener
|
|||||||
* Sets the 'more' indicator.
|
* Sets the 'more' indicator.
|
||||||
*/
|
*/
|
||||||
private void updateMoreIndicator() {
|
private void updateMoreIndicator() {
|
||||||
info.setCompoundDrawablesWithIntrinsicBounds(
|
AndroidUtils.setStartDrawables(info,
|
||||||
box.getChildCount() == 0 ? 0
|
box.getChildCount() == 0 ? 0
|
||||||
: box.getVisibility() == View.VISIBLE ? R.drawable.arrow_down
|
: box.getVisibility() == View.VISIBLE ? R.drawable.arrow_down
|
||||||
: R.drawable.arrow_right,
|
: R.drawable.arrow_right);
|
||||||
0, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.style.ClickableSpan;
|
import android.text.style.ClickableSpan;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -30,6 +31,26 @@ public class AndroidUtils {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the start drawable of a textview
|
||||||
|
* Wrapped for android compatibility
|
||||||
|
*/
|
||||||
|
public static void setStartDrawables(TextView txt, int start) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||||
|
// we can use the function directly!
|
||||||
|
txt.setCompoundDrawablesRelativeWithIntrinsicBounds(start, 0, 0, 0);
|
||||||
|
} else {
|
||||||
|
// we need to manually adjust
|
||||||
|
if ((txt.getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_LAYOUTDIR_MASK) == Configuration.SCREENLAYOUT_LAYOUTDIR_RTL) {
|
||||||
|
// rtl
|
||||||
|
txt.setCompoundDrawablesWithIntrinsicBounds(0, 0, start, 0);
|
||||||
|
} else {
|
||||||
|
// ltr
|
||||||
|
txt.setCompoundDrawablesWithIntrinsicBounds(start, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In debug mode, throws an AssertionError, in production just logs it and continues.
|
* In debug mode, throws an AssertionError, in production just logs it and continues.
|
||||||
*/
|
*/
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
android:drawableStart="@drawable/arrow_right"
|
android:drawableStart="@drawable/arrow_right"
|
||||||
android:drawableLeft="@drawable/arrow_right"
|
android:drawableLeft="@drawable/arrow_right"
|
||||||
android:drawableTint="?attr/colorAccent"
|
android:drawableTint="?attr/colorAccent"
|
||||||
android:gravity="center_vertical"
|
android:textAlignment="viewStart"
|
||||||
|
android:gravity="center_vertical|start"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
Loading…
Reference in New Issue
Block a user