mirror of
https://framagit.org/tom79/nitterizeme
synced 2025-02-20 21:50:50 +01:00
comment #3 - Prepare layouts
This commit is contained in:
parent
78a44c1862
commit
5b07f5edc0
@ -59,6 +59,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
public static String SET_OSM_ENABLED = "set_osm_enabled";
|
||||
public static String SET_OSM_HOST = "set_osm_host";
|
||||
public static String DEFAULT_OSM_HOST = "www.openstreetmap.org";
|
||||
public static String SET_BIBLIOGRAM_ENABLED = "set_bibliogram_enabled";
|
||||
public static String SET_BIBLIOGRAM_HOST = "set_bibliogram_host";
|
||||
public static String DEFAULT_BIBLIOGRAM_HOST = "bibliogram.art";
|
||||
public static String SET_GEO_URIS = "set_geo_uris";
|
||||
//Supported domains
|
||||
public static String[] twitter_domains = {
|
||||
@ -66,6 +69,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
"mobile.twitter.com",
|
||||
"www.twitter.com",
|
||||
};
|
||||
public static String[] instagram_domains = {
|
||||
"instagram.com",
|
||||
"www.instagram.com",
|
||||
"m.instagram.com",
|
||||
};
|
||||
public static String[] youtube_domains = {
|
||||
"www.youtube.com",
|
||||
"youtube.com",
|
||||
@ -107,29 +115,38 @@ public class MainActivity extends AppCompatActivity {
|
||||
domains[i] = host;
|
||||
i++;
|
||||
}
|
||||
for (String host : instagram_domains) {
|
||||
domains[i] = host;
|
||||
i++;
|
||||
}
|
||||
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
||||
TextInputEditText nitter_instance = findViewById(R.id.nitter_instance);
|
||||
TextInputEditText invidious_instance = findViewById(R.id.invidious_instance);
|
||||
TextInputEditText bibliogram_instance = findViewById(R.id.bibliogram_instance);
|
||||
TextInputEditText osm_instance = findViewById(R.id.osm_instance);
|
||||
|
||||
SwitchCompat enable_nitter = findViewById(R.id.enable_nitter);
|
||||
SwitchCompat enable_invidious = findViewById(R.id.enable_invidious);
|
||||
SwitchCompat enable_bibliogram = findViewById(R.id.enable_bibliogram);
|
||||
SwitchCompat enable_osm = findViewById(R.id.enable_osm);
|
||||
|
||||
boolean nitter_enabled = sharedpreferences.getBoolean(SET_NITTER_ENABLED, true);
|
||||
boolean invidious_enabled = sharedpreferences.getBoolean(SET_INVIDIOUS_ENABLED, true);
|
||||
boolean osm_enabled = sharedpreferences.getBoolean(SET_OSM_ENABLED, true);
|
||||
boolean bibliogram_enabled = sharedpreferences.getBoolean(SET_BIBLIOGRAM_ENABLED, true);
|
||||
|
||||
enable_nitter.setChecked(nitter_enabled);
|
||||
enable_invidious.setChecked(invidious_enabled);
|
||||
enable_bibliogram.setChecked(bibliogram_enabled);
|
||||
enable_osm.setChecked(osm_enabled);
|
||||
|
||||
Button button_save = findViewById(R.id.button_save);
|
||||
list_apps = findViewById(R.id.list_apps);
|
||||
String nitterHost = sharedpreferences.getString(SET_NITTER_HOST, null);
|
||||
String invidiousHost = sharedpreferences.getString(SET_INVIDIOUS_HOST, null);
|
||||
String bibliogramHost = sharedpreferences.getString(SET_BIBLIOGRAM_HOST, null);
|
||||
String osmHost = sharedpreferences.getString(SET_OSM_HOST, null);
|
||||
|
||||
enable_invidious.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
@ -142,6 +159,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
editor.putBoolean(SET_NITTER_ENABLED, isChecked);
|
||||
editor.apply();
|
||||
});
|
||||
enable_bibliogram.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(SET_BIBLIOGRAM_ENABLED, isChecked);
|
||||
editor.apply();
|
||||
});
|
||||
enable_osm.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(SET_OSM_ENABLED, isChecked);
|
||||
@ -154,6 +176,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (invidiousHost != null) {
|
||||
invidious_instance.setText(invidiousHost);
|
||||
}
|
||||
if (bibliogramHost != null) {
|
||||
bibliogram_instance.setText(bibliogramHost);
|
||||
}
|
||||
if (osmHost != null) {
|
||||
osm_instance.setText(osmHost);
|
||||
}
|
||||
@ -169,6 +194,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
} else {
|
||||
editor.putString(SET_INVIDIOUS_HOST, null);
|
||||
}
|
||||
if (bibliogram_instance.getText() != null && bibliogram_instance.getText().toString().trim().length() > 0) {
|
||||
editor.putString(SET_BIBLIOGRAM_HOST, bibliogram_instance.getText().toString().toLowerCase().trim());
|
||||
} else {
|
||||
editor.putString(SET_BIBLIOGRAM_HOST, null);
|
||||
}
|
||||
if (osm_instance.getText() != null && osm_instance.getText().toString().trim().length() > 0) {
|
||||
editor.putString(SET_OSM_HOST, osm_instance.getText().toString().toLowerCase().trim());
|
||||
} else {
|
||||
|
@ -125,6 +125,47 @@
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bibliogram_indications"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="@string/redirect_instagram_to_bibliogram"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/invidious_container" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/bibliogram_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bibliogram_indications">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/bibliogram_instance"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/custom_bibliogram"
|
||||
android:inputType="textUri"
|
||||
android:maxLines="1" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/enable_bibliogram"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="5dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/osm_indications"
|
||||
android:layout_width="0dp"
|
||||
@ -133,7 +174,7 @@
|
||||
android:text="@string/redirect_gm_to_osm"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/invidious_container" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/bibliogram_container" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/osm_container"
|
||||
|
@ -25,6 +25,8 @@
|
||||
<string name="custom_osm">Custom OSM hostname</string>
|
||||
<string name="redirect_youtube_to_invidious">Redirect YouTube to Invidious</string>
|
||||
<string name="redirect_twitter_to_nitter">Redirect Twitter to Nitter</string>
|
||||
<string name="redirect_instagram_to_bibliogram">Redirect Instagram to Bibliogram</string>
|
||||
<string name="custom_bibliogram">Custom Bibliogram instance</string>
|
||||
<string name="redirect_gm_to_geo_uri">Redirect Google Map to Geo URI</string>
|
||||
<string name="configure">Configure</string>
|
||||
<string name="display_supported_links">Display supported links</string>
|
||||
@ -42,4 +44,5 @@
|
||||
<string name="donation_unavailable_title">This button should have redirected you to my %1$s donation page but Google does not allow it.\n\nThe best place for using and supporting FOSS apps is <a href='https://f-droid.org/'>https://f-droid.org/</a></string>
|
||||
<string name="get_fdroid">Get it on F-Droid</string>
|
||||
<string name="download_with_fdroid">Get the app on F-Droid</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user