Skip to content

Commit

Permalink
bug fix, gradle update, translation update
Browse files Browse the repository at this point in the history
Signed-off-by: nuclearfog <sufianbekziz@protonmail.com>
  • Loading branch information
nuclearfog committed Mar 29, 2024
1 parent 93244b6 commit 7cb3cf2
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 27 deletions.
1 change: 0 additions & 1 deletion app/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.github.nuclearfog.nitterify"
minSdkVersion 11
targetSdkVersion 34
versionCode 3
versionName "2.0"
versionCode 4
versionName "2.1"
resConfigs 'en', 'de'
}

Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/com/github/nuclearfog/nitterify/AppSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,20 @@ private AppSettings(Context context) {
mode = settings.getInt(SETTINGS_MODE, MODE_DEFAULT);
}


/**
* get redirect mode
*
* @return {@link #MODE_DEFAULT,#MODE_CUSTOM}
*/
public int getMode() {
return mode;
}


/**
* set redirect mode
*
* @param mode redirect mode {@link #MODE_DEFAULT,#MODE_CUSTOM}
*/
public void setMode(int mode) {
this.mode = mode;
settings.edit().putInt(SETTINGS_MODE, mode).apply();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,7 @@ public void onClick(View v) {
if (v.getId() == R.id.network_confirm) {
String url = urlInput.getText().toString();
if (Patterns.WEB_URL.matcher(url).matches()) {
// reformat url
if (url.startsWith("http://"))
url = "https://" + url.substring(7);
else if (!url.startsWith("https://"))
url = "https://" + url;
int index = url.indexOf("/", 8);
if (index >= 8)
url = url.substring(0, index);
urlInput.setText(url);
// save url
settings.setDomain(url);
settings.setMode(AppSettings.MODE_CUSTOM);
Toast.makeText(getApplicationContext(), R.string.info_instance_set, Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
*/
public class NetworkAdapter extends BaseAdapter {

/**
* item index of the "default nitter instance" entry
*/
public static final int INDEX_DEFAULT = 0;

/**
* item index of the "custom nitter instance" entry
*/
public static final int INDEX_CUSTOM = 1;

private int[] itemRes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,32 @@
import android.widget.Toast;

/**
* Activity used to redirect Twitter/X links
* Activity used to redirect to nitter instance
*
* @author nuclearfog
*/
public class RedirectActivity extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppSettings settings = AppSettings.get(getApplicationContext());

// fetch url to redirect
if (getIntent().getData() != null) {
String url;
Uri redirectUrl;
String path = getIntent().getData().getPath();
if (settings.getMode() == AppSettings.MODE_CUSTOM) {
url = settings.getDomain() + getIntent().getData().getPath();
redirectUrl = Uri.parse(settings.getDomain() + path);
if (redirectUrl.getScheme() == null) {
redirectUrl = Uri.parse("https://" + settings.getDomain() + path);
}
} else {
url = "https://nitter.net" + getIntent().getData().getPath();
redirectUrl = Uri.parse("https://nitter.net" + path);
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse(url));
intent.setData(redirectUrl);
try {
getApplicationContext().startActivity(intent);
} catch (ActivityNotFoundException exception) {
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Nitterify</string>
<string name="label_network_selector">Nitter-Instanz auswählen</string>
<string name="label_network_selector">Nitter-Instanz auswählen</string>
<string name="error_open_link">Link konnte nicht geöffnet werden!</string>
<string name="hint_url">Nitter-URL z.B. https://nitter.net</string>
<string name="error_wrong_url">Falsches URL-Format!</string>
<string name="error_wrong_url">Ungültige URL!</string>
<string name="description_button">Instanz-URL sichern</string>
<string name="info_instance_set">Instanz-URL gesichert</string>
<string name="custom_instance">Benutzerdefinierte Instanz</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Nitterify</string>
<string name="app_name" translatable="false">Nitterify</string>
<string name="label_network_selector">Select Nitter instance</string>
<string name="error_open_link">could not open link!</string>
<string name="hint_url">Nitter url e.g. https://nitter.net</string>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.2.0'
classpath 'com.android.tools.build:gradle:8.2.2'
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=9d926787066a081739e8200858338b4a69e837c3a821a33aca9db09dd4a41026
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionSha256Sum=9631d53cf3e74bfa726893aee1f8994fee4e060c401335946dba2156f440f24c
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=600
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Expand Down

0 comments on commit 7cb3cf2

Please sign in to comment.