Merge branch 'app_picker' into develop

# Conflicts:
#	app/build.gradle
#	fastlane/metadata/android/en-US/changelogs/15.txt
This commit is contained in:
Thomas 2020-04-20 18:55:57 +02:00
commit 19bd8b455a
29 changed files with 1434 additions and 180 deletions

View File

@ -97,6 +97,7 @@
<data android:host="bibliogram.dsrev.ru" />
<data android:host="bibliogram.pussthecat.org" />
<data android:host="*" />
<data android:pathPattern=".*" />
<data android:scheme="https" />
<data android:scheme="http" />
@ -135,10 +136,13 @@
<data android:host="youtu.be" />
<data android:host="youtube-nocookie.com" />
<data android:host="*" />
<data android:mimeType="text/plain" />
</intent-filter>
<!-- MAPS URLs -->
<!-- /maps/ -->
<intent-filter>
@ -185,7 +189,11 @@
</activity>
<activity
android:name="app.fedilab.nitterizeme.activities.InstanceActivity"
android:name=".activities.AppsPickerActivity"
android:noHistory="true"
android:theme="@style/Theme.AppCompat.Translucent"/>
<activity
android:name=".activities.InstanceActivity"
android:excludeFromRecents="true"
android:theme="@style/AppThemeDialog" />
<activity
@ -199,7 +207,12 @@
android:label="@string/app_name"
android:theme="@style/AppTheme" />
<activity
android:name="app.fedilab.nitterizeme.activities.WebviewPlayerActivity"
android:name=".activities.DefaultAppActivity"
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
android:theme="@style/AppTheme" />
<activity
android:name=".activities.WebviewPlayerActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask"

View File

@ -0,0 +1,171 @@
package app.fedilab.nitterizeme.activities;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* UntrackMe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.GridView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.constraintlayout.widget.ConstraintLayout;
import java.util.ArrayList;
import java.util.List;
import app.fedilab.nitterizeme.R;
import app.fedilab.nitterizeme.adapters.AppPickerAdapter;
import app.fedilab.nitterizeme.entities.AppPicker;
import app.fedilab.nitterizeme.helpers.Utils;
import app.fedilab.nitterizeme.sqlite.DefaultAppDAO;
import app.fedilab.nitterizeme.sqlite.Sqlite;
import static app.fedilab.nitterizeme.helpers.Utils.KILL_ACTIVITY;
import static app.fedilab.nitterizeme.helpers.Utils.URL_APP_PICKER;
public class AppsPickerActivity extends Activity {
private String url;
private String appToUse;
private String appName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pickup_app);
if (getIntent() == null) {
finish();
}
Bundle b = getIntent().getExtras();
if (b == null) {
finish();
}
if (b != null) {
url = b.getString(URL_APP_PICKER, null);
}
if (url == null) {
finish();
}
//At this point we are sure that url is not null
Intent stopMainActivity = new Intent(KILL_ACTIVITY);
sendBroadcast(stopMainActivity);
Intent delegate = new Intent(Intent.ACTION_VIEW);
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
delegate.setData(Uri.parse(url));
List<ResolveInfo> activities = getPackageManager().queryIntentActivities(delegate, PackageManager.MATCH_DEFAULT_ONLY);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
RelativeLayout blank = findViewById(R.id.blank);
blank.setOnClickListener(v -> finish());
String thisPackageName = getApplicationContext().getPackageName();
ArrayList<String> packages = new ArrayList<>();
List<AppPicker> appPickers = new ArrayList<>();
int i = 0;
for (ResolveInfo currentInfo : activities) {
String packageName = currentInfo.activityInfo.packageName;
if (!thisPackageName.equals(packageName) && !packages.contains(packageName)) {
AppPicker appPicker = new AppPicker();
appPicker.setIcon(currentInfo.activityInfo.loadIcon(getPackageManager()));
appPicker.setName(String.valueOf(currentInfo.loadLabel(getPackageManager())));
appPicker.setPackageName(packageName);
if (i == 0) {
appPicker.setSelected(true);
appToUse = packageName;
appName = String.valueOf(currentInfo.loadLabel(getPackageManager()));
}
appPickers.add(appPicker);
packages.add(packageName);
i++;
}
}
String defaultApp = new DefaultAppDAO(AppsPickerActivity.this, db).getDefault(packages);
TextView urlText = findViewById(R.id.url);
urlText.setText(url);
if (defaultApp != null) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setPackage(defaultApp);
startActivity(intent);
finish();
} else {
ConstraintLayout app_container = findViewById(R.id.app_container);
app_container.setVisibility(View.VISIBLE);
GridView gridView = findViewById(R.id.app_list);
AppPickerAdapter appPickerAdapter = new AppPickerAdapter(appPickers);
gridView.setAdapter(appPickerAdapter);
gridView.setNumColumns(3);
gridView.setOnItemClickListener((parent, view1, position, id) -> {
for (AppPicker ap : appPickers) {
ap.setSelected(false);
}
appPickers.get(position).setSelected(true);
appToUse = appPickers.get(position).getPackageName();
appName = appPickers.get(position).getName();
appPickerAdapter.notifyDataSetChanged();
});
Button always = findViewById(R.id.always);
Button once = findViewById(R.id.once);
always.setOnClickListener(v -> {
boolean isPresent = new DefaultAppDAO(AppsPickerActivity.this, db).isPresent(appToUse);
long val = -1;
if (isPresent) {
ArrayList<String> oldConcurrent = new DefaultAppDAO(AppsPickerActivity.this, db).getConcurrent(appToUse);
ArrayList<String> newConcurrent = Utils.union(oldConcurrent, packages);
new DefaultAppDAO(AppsPickerActivity.this, db).update(appToUse, newConcurrent);
} else {
val = new DefaultAppDAO(AppsPickerActivity.this, db).insert(appToUse, packages);
}
if (val > 0) {
Toast.makeText(AppsPickerActivity.this, getString(R.string.default_app_indication, appName), Toast.LENGTH_LONG).show();
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setPackage(appToUse);
startActivity(intent);
finish();
});
once.setOnClickListener(v -> {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setPackage(appToUse);
startActivity(intent);
finish();
});
}
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}

View File

@ -0,0 +1,90 @@
package app.fedilab.nitterizeme.activities;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* UntrackMe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.MenuItem;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import app.fedilab.nitterizeme.R;
import app.fedilab.nitterizeme.adapters.DefaultAppAdapter;
import app.fedilab.nitterizeme.entities.DefaultApp;
import app.fedilab.nitterizeme.helpers.Utils;
import app.fedilab.nitterizeme.sqlite.DefaultAppDAO;
import app.fedilab.nitterizeme.sqlite.Sqlite;
public class DefaultAppActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_default_app);
setTitle(R.string.default_apps);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
RecyclerView list_apps = findViewById(R.id.list_apps);
final LinearLayoutManager mLayoutManager;
mLayoutManager = new LinearLayoutManager(DefaultAppActivity.this);
list_apps.setLayoutManager(mLayoutManager);
list_apps.setNestedScrollingEnabled(false);
ArrayList<DefaultApp> appInfos = getAppInfo();
DefaultAppAdapter defaultAppAdapter = new DefaultAppAdapter(appInfos);
list_apps.setAdapter(defaultAppAdapter);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* Get default app set inside the application for opening links
*
* @return ArrayList<DefaultApp>
*/
private ArrayList<DefaultApp> getAppInfo() {
ArrayList<DefaultApp> appInfos = new ArrayList<>();
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
ArrayList<String> packageName = new DefaultAppDAO(DefaultAppActivity.this, db).getDefault();
for (String p : packageName) {
DefaultApp defaultApp = new DefaultApp();
defaultApp.setApplicationInfo(Utils.getPackageInfo(DefaultAppActivity.this, p).applicationInfo);
appInfos.add(defaultApp);
}
return appInfos;
}
}

View File

@ -19,6 +19,8 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
@ -33,11 +35,13 @@ import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SwitchCompat;
import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Group;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.textfield.TextInputEditText;
import java.util.List;
import java.util.Objects;
import app.fedilab.nitterizeme.R;
@ -88,7 +92,6 @@ public class MainActivity extends AppCompatActivity {
Objects.requireNonNull(getSupportActionBar()).setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
SharedPreferences sharedpreferences = getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE);
TextView current_instance_nitter = findViewById(R.id.current_instance_nitter);
@ -138,7 +141,6 @@ public class MainActivity extends AppCompatActivity {
enable_invidious.setChecked(invidious_enabled);
enable_bibliogram.setChecked(bibliogram_enabled);
enable_osm.setChecked(osm_enabled);
ImageButton save_instance_nitter = findViewById(R.id.button_save_instance_nitter);
ImageButton save_instance_invidious = findViewById(R.id.button_save_instance_invidious);
ImageButton save_instance_bibliogram = findViewById(R.id.button_save_instance_bibliogram);
@ -462,6 +464,10 @@ public class MainActivity extends AppCompatActivity {
Intent intent = new Intent(MainActivity.this, AboutActivity.class);
startActivity(intent);
return true;
} else if (id == R.id.action_settings) {
Intent intent = new Intent(MainActivity.this, DefaultAppActivity.class);
startActivity(intent);
return true;
} else if (id == android.R.id.home) {
finish();
}
@ -504,5 +510,14 @@ public class MainActivity extends AppCompatActivity {
bibliogram_instance.setText(bibliogramHost);
current_instance_bibliogram.setText(bibliogramHost);
}
List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(new Intent(Intent.ACTION_VIEW, Uri.parse("https://fedilab.app")), PackageManager.MATCH_DEFAULT_ONLY);
String thisPackageName = getApplicationContext().getPackageName();
ConstraintLayout display_indications = findViewById(R.id.display_indications);
if (resolveInfos.size() == 1 && resolveInfos.get(0).activityInfo.packageName.compareTo(thisPackageName) == 0) {
display_indications.setVisibility(View.VISIBLE);
} else {
display_indications.setVisibility(View.GONE);
}
}
}

View File

@ -15,18 +15,14 @@ package app.fedilab.nitterizeme.activities;
* see <http://www.gnu.org/licenses>. */
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Parcelable;
import android.util.Patterns;
import android.view.View;
import android.widget.Button;
@ -35,7 +31,6 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
@ -43,7 +38,6 @@ import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -59,15 +53,16 @@ import static app.fedilab.nitterizeme.activities.CheckAppActivity.shortener_doma
import static app.fedilab.nitterizeme.activities.CheckAppActivity.twitter_domains;
import static app.fedilab.nitterizeme.activities.CheckAppActivity.youtube_domains;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_BIBLIOGRAM_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_EMBEDDED_PLAYER;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_INVIDIOUS_ENABLED;
import static app.fedilab.nitterizeme.activities.MainActivity.SET_NITTER_ENABLED;
import static app.fedilab.nitterizeme.helpers.Utils.KILL_ACTIVITY;
import static app.fedilab.nitterizeme.helpers.Utils.URL_APP_PICKER;
import static app.fedilab.nitterizeme.helpers.Utils.ampExtract;
import static app.fedilab.nitterizeme.helpers.Utils.bibliogramAccountPattern;
import static app.fedilab.nitterizeme.helpers.Utils.bibliogramPostPattern;
import static app.fedilab.nitterizeme.helpers.Utils.maps;
import static app.fedilab.nitterizeme.helpers.Utils.nitterPattern;
import static app.fedilab.nitterizeme.helpers.Utils.remove_tracking_param;
import static app.fedilab.nitterizeme.helpers.Utils.transformUrl;
import static app.fedilab.nitterizeme.helpers.Utils.youtubePattern;
@ -116,9 +111,7 @@ public class TransformActivity extends Activity {
Intent delegate = new Intent(Intent.ACTION_VIEW);
delegate.setData(Uri.parse(notShortnedURLDialog.get(notShortnedURLDialog.size() - 1)));
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (delegate.resolveActivity(getPackageManager()) != null) {
startActivity(delegate);
}
forwardToBrowser(delegate);
}
dialog.dismiss();
finish();
@ -171,10 +164,7 @@ public class TransformActivity extends Activity {
if (transformedURL != null) {
delegate.setData(Uri.parse(transformUrl(TransformActivity.this, url)));
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (delegate.resolveActivity(getPackageManager()) != null) {
startActivity(delegate);
finish();
}
forwardToBrowser(delegate);
} else {
forwardToBrowser(intent);
}
@ -190,10 +180,7 @@ public class TransformActivity extends Activity {
if (transformedURL != null) {
delegate.setData(Uri.parse(transformUrl(TransformActivity.this, url)));
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (delegate.resolveActivity(getPackageManager()) != null) {
startActivity(delegate);
finish();
}
forwardToBrowser(delegate);
} else {
forwardToBrowser(intent);
}
@ -210,10 +197,7 @@ public class TransformActivity extends Activity {
if (transformedURL != null) {
delegate.setData(Uri.parse(transformUrl(TransformActivity.this, url)));
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (delegate.resolveActivity(getPackageManager()) != null) {
startActivity(delegate);
finish();
}
forwardToBrowser(delegate);
} else {
forwardToBrowser(intent);
}
@ -232,10 +216,7 @@ public class TransformActivity extends Activity {
if (transformedURL != null) {
delegate.setData(Uri.parse(transformedURL));
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (delegate.resolveActivity(getPackageManager()) != null) {
startActivity(delegate);
finish();
}
forwardToBrowser(delegate);
} else {
forwardToBrowser(intent);
}
@ -249,10 +230,7 @@ public class TransformActivity extends Activity {
if (transformedURL != null) {
delegate.setData(Uri.parse(transformUrl(TransformActivity.this, url)));
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (delegate.resolveActivity(getPackageManager()) != null) {
startActivity(delegate);
finish();
}
forwardToBrowser(delegate);
} else {
forwardToBrowser(intent);
}
@ -304,6 +282,10 @@ public class TransformActivity extends Activity {
} else {
forwardToBrowser(intent);
}
} else {
String newUrl = remove_tracking_param(url);
intent.setData(Uri.parse(newUrl));
forwardToBrowser(intent);
}
}
@ -327,64 +309,12 @@ public class TransformActivity extends Activity {
* @param i original intent
*/
private void forwardToBrowser(Intent i) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
String type = i.getType();
if (type == null) {
type = "text/html";
}
intent.setDataAndType(i.getData(), type);
List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0);
ArrayList<Intent> targetIntents = new ArrayList<>();
String thisPackageName = getApplicationContext().getPackageName();
ArrayList<String> packages = new ArrayList<>();
for (ResolveInfo currentInfo : activities) {
String packageName = currentInfo.activityInfo.packageName;
if (!thisPackageName.equals(packageName) && !packages.contains(packageName)) {
Intent targetIntent = new Intent(Intent.ACTION_VIEW);
targetIntent.setDataAndType(intent.getData(), intent.getType());
targetIntent.setPackage(intent.getPackage());
targetIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
targetIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
targetIntent.setComponent(new ComponentName(packageName, currentInfo.activityInfo.name));
targetIntents.add(targetIntent);
packages.add(packageName);
}
}
//NewPipe has to be manually added
if (isNewPipeInstalled() && Arrays.asList(invidious_instances).contains(Objects.requireNonNull(i.getData()).getHost()) && !packages.contains("org.schabi.newpipe")) {
Intent targetIntent = new Intent(Intent.ACTION_VIEW);
targetIntent.setDataAndType(intent.getData(), intent.getType());
targetIntent.setPackage(intent.getPackage());
targetIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
targetIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
targetIntent.setComponent(new ComponentName("org.schabi.newpipe", "org.schabi.newpipe.RouterActivity"));
targetIntents.add(0, targetIntent);
}
SharedPreferences sharedpreferences = getSharedPreferences(MainActivity.APP_PREFS, Context.MODE_PRIVATE);
boolean embedded_player = sharedpreferences.getBoolean(SET_EMBEDDED_PLAYER, false);
if (Arrays.asList(invidious_instances).contains(Objects.requireNonNull(i.getData()).getHost()) && embedded_player) {
if (!i.getData().toString().contains("videoplayback") && !i.getData().toString().contains("/channel/")) {
Intent intentPlayer = new Intent(TransformActivity.this, WebviewPlayerActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
intentPlayer.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
}
intentPlayer.putExtra("url", i.getData().toString());
startActivity(intentPlayer);
} else {
Intent intentStreamingUrl = new Intent(Utils.RECEIVE_STREAMING_URL);
Bundle b = new Bundle();
b.putString("streaming_url", i.getData().toString());
intentStreamingUrl.putExtras(b);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentStreamingUrl);
}
} else if (targetIntents.size() > 0) {
Intent chooserIntent = Intent.createChooser(targetIntents.get(0), getString(R.string.open_with));
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetIntents.toArray(new Parcelable[]{}));
startActivity(chooserIntent);
}
Intent app_picker = new Intent(TransformActivity.this, AppsPickerActivity.class);
Bundle b = new Bundle();
b.putString(URL_APP_PICKER, i.getDataString());
app_picker.putExtras(b);
startActivity(app_picker);
finish();
}
@ -429,6 +359,13 @@ public class TransformActivity extends Activity {
startActivity(sendIntent);
return;
}
Uri url_r = Uri.parse(url);
String scheme = url_r.getScheme();
if (scheme == null) {
scheme = "https://";
} else {
scheme += "://";
}
if (Arrays.asList(twitter_domains).contains(host)) {
boolean nitter_enabled = sharedpreferences.getBoolean(SET_NITTER_ENABLED, true);
@ -438,9 +375,9 @@ public class TransformActivity extends Activity {
assert host != null;
if (host.compareTo("pbs.twimg.com") == 0 || host.compareTo("pic.twitter.com") == 0) {
try {
newUrl = "https://" + nitterHost + "/pic/" + URLEncoder.encode(url, "utf-8");
newUrl = scheme + nitterHost + "/pic/" + URLEncoder.encode(url, "utf-8");
} catch (UnsupportedEncodingException e) {
newUrl = "https://" + nitterHost + "/pic/" + url;
newUrl = scheme + nitterHost + "/pic/" + url;
}
} else if (url.contains("/search?")) {
newUrl = url.replace(host, nitterHost);
@ -448,7 +385,7 @@ public class TransformActivity extends Activity {
Matcher matcher = nitterPattern.matcher(url);
while (matcher.find()) {
final String nitter_directory = matcher.group(2);
newUrl = "https://" + nitterHost + nitter_directory;
newUrl = scheme + nitterHost + nitter_directory;
}
}
}
@ -459,16 +396,16 @@ public class TransformActivity extends Activity {
while (matcher.find()) {
final String bibliogram_directory = matcher.group(2);
String bibliogramHost = sharedpreferences.getString(MainActivity.SET_BIBLIOGRAM_HOST, MainActivity.DEFAULT_BIBLIOGRAM_HOST).toLowerCase();
newUrl = "https://" + bibliogramHost + bibliogram_directory;
newUrl = scheme + bibliogramHost + bibliogram_directory;
}
matcher = bibliogramAccountPattern.matcher(url);
while (matcher.find()) {
final String bibliogram_directory = matcher.group(2);
String bibliogramHost = sharedpreferences.getString(MainActivity.SET_BIBLIOGRAM_HOST, MainActivity.DEFAULT_BIBLIOGRAM_HOST).toLowerCase();
if (bibliogram_directory != null && bibliogram_directory.compareTo("privacy") != 0) {
newUrl = "https://" + bibliogramHost + "/u" + bibliogram_directory;
newUrl = scheme + bibliogramHost + "/u" + bibliogram_directory;
} else {
newUrl = "https://" + bibliogramHost + bibliogram_directory;
newUrl = scheme + bibliogramHost + bibliogram_directory;
}
}
}
@ -489,14 +426,14 @@ public class TransformActivity extends Activity {
zoom = data[2];
}
String osmHost = sharedpreferences.getString(MainActivity.SET_OSM_HOST, MainActivity.DEFAULT_OSM_HOST).toLowerCase();
newUrl = "https://" + osmHost + "/#map=" + zoom + "/" + data[0] + "/" + data[1];
newUrl = scheme + osmHost + "/#map=" + zoom + "/" + data[0] + "/" + data[1];
}
}
}
} else if (url.contains("/amp/s/")) {
Matcher matcher = ampExtract.matcher(url);
while (matcher.find()) {
newUrl = "https://" + matcher.group(1);
newUrl = scheme + matcher.group(1);
}
} else if (Arrays.asList(youtube_domains).contains(host)) { //Youtube URL
boolean invidious_enabled = sharedpreferences.getBoolean(SET_INVIDIOUS_ENABLED, true);
@ -506,15 +443,16 @@ public class TransformActivity extends Activity {
final String youtubeId = matcher.group(3);
String invidiousHost = sharedpreferences.getString(MainActivity.SET_INVIDIOUS_HOST, MainActivity.DEFAULT_INVIDIOUS_HOST).toLowerCase();
if (Objects.requireNonNull(matcher.group(2)).compareTo("youtu.be") == 0) {
newUrl = "https://" + invidiousHost + "/watch?v=" + youtubeId + "&local=true";
newUrl = scheme + invidiousHost + "/watch?v=" + youtubeId + "&local=true";
} else {
newUrl = "https://" + invidiousHost + "/" + youtubeId + "&local=true";
newUrl = scheme + invidiousHost + "/" + youtubeId + "&local=true";
}
}
}
} else if (Arrays.asList(shortener_domains).contains(host)) {
String finalUrl = url;
String finalExtraText = extraText;
String finalScheme = scheme;
Thread thread = new Thread() {
@Override
public void run() {
@ -539,7 +477,7 @@ public class TransformActivity extends Activity {
while (matcher.find()) {
final String nitter_directory = matcher.group(2);
String nitterHost = sharedpreferences.getString(MainActivity.SET_NITTER_HOST, MainActivity.DEFAULT_NITTER_HOST).toLowerCase();
newUrlFinal = "https://" + nitterHost + nitter_directory;
newUrlFinal = finalScheme + nitterHost + nitter_directory;
}
String newExtraText = finalExtraText.replaceAll(Pattern.quote(finalUrl), Matcher.quoteReplacement(newUrlFinal));
Intent sendIntent = new Intent();
@ -554,9 +492,9 @@ public class TransformActivity extends Activity {
final String youtubeId = matcher.group(3);
String invidiousHost = sharedpreferences.getString(MainActivity.SET_INVIDIOUS_HOST, MainActivity.DEFAULT_INVIDIOUS_HOST).toLowerCase();
if (Objects.requireNonNull(matcher.group(2)).compareTo("youtu.be") == 0) {
newUrlFinal = "https://" + invidiousHost + "/watch?v=" + youtubeId + "&local=true";
newUrlFinal = finalScheme + invidiousHost + "/watch?v=" + youtubeId + "&local=true";
} else {
newUrlFinal = "https://" + invidiousHost + "/" + youtubeId + "&local=true";
newUrlFinal = finalScheme + invidiousHost + "/" + youtubeId + "&local=true";
}
}
String newExtraText = finalExtraText.replaceAll(Pattern.quote(finalUrl), Matcher.quoteReplacement(newUrlFinal));
@ -581,7 +519,7 @@ public class TransformActivity extends Activity {
zoom = data[2];
}
String osmHost = sharedpreferences.getString(MainActivity.SET_OSM_HOST, MainActivity.DEFAULT_OSM_HOST).toLowerCase();
newUrlFinal = "https://" + osmHost + "/#map=" + zoom + "/" + data[0] + "/" + data[1];
newUrlFinal = finalScheme + osmHost + "/#map=" + zoom + "/" + data[0] + "/" + data[1];
}
}
String newExtraText = finalExtraText.replaceAll(Pattern.quote(finalUrl), Matcher.quoteReplacement(newUrlFinal));
@ -602,6 +540,8 @@ public class TransformActivity extends Activity {
};
thread.start();
return;
} else {
newUrl = remove_tracking_param(url);
}
if (newUrl != null) {
extraText = extraText.replaceAll(Pattern.quote(url), Matcher.quoteReplacement(newUrl));
@ -613,17 +553,5 @@ public class TransformActivity extends Activity {
startActivity(sendIntent);
}
/**
* Check if NewPipe is installed
*
* @return boolean
*/
private boolean isNewPipeInstalled() {
try {
getPackageManager().getPackageInfo("org.schabi.newpipe", 0);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
}

View File

@ -0,0 +1,100 @@
package app.fedilab.nitterizeme.adapters;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* UntrackMe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.res.Resources;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import java.util.List;
import app.fedilab.nitterizeme.R;
import app.fedilab.nitterizeme.entities.AppPicker;
public class AppPickerAdapter extends BaseAdapter {
private List<AppPicker> appPickers;
public AppPickerAdapter(List<AppPicker> appPickers) {
this.appPickers = appPickers;
}
@Override
public int getCount() {
return appPickers.size();
}
@Override
public AppPicker getItem(int position) {
return appPickers.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
AppPicker appPicker = appPickers.get(position);
if (convertView == null) {
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
convertView = layoutInflater.inflate(R.layout.drawer_app_picker, parent, false);
holder = new ViewHolder();
holder.app_icon = convertView.findViewById(R.id.app_icon);
holder.app_name = convertView.findViewById(R.id.app_name);
holder.app_container = convertView.findViewById(R.id.app_container);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
try {
holder.app_icon.setImageDrawable(appPicker.getIcon());
} catch (Resources.NotFoundException e) {
holder.app_icon.setImageResource(R.drawable.ic_android);
}
holder.app_name.setText(appPicker.getName());
if (appPicker.isSelected()) {
holder.app_container.setBackgroundResource(R.drawable.rounded_selector);
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
holder.app_container.setBackground(null);
}
}
return convertView;
}
private static class ViewHolder {
ImageView app_icon;
TextView app_name;
ConstraintLayout app_container;
}
}

View File

@ -0,0 +1,120 @@
package app.fedilab.nitterizeme.adapters;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* UntrackMe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.Context;
import android.content.res.Resources;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
import app.fedilab.nitterizeme.R;
import app.fedilab.nitterizeme.entities.DefaultApp;
import app.fedilab.nitterizeme.sqlite.DefaultAppDAO;
import app.fedilab.nitterizeme.sqlite.Sqlite;
public class DefaultAppAdapter extends RecyclerView.Adapter {
private List<DefaultApp> defaultApps;
public DefaultAppAdapter(List<DefaultApp> packageNames) {
this.defaultApps = packageNames;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int position) {
Context context = parent.getContext();
LayoutInflater layoutInflater = LayoutInflater.from(context);
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_default_app, parent, false));
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
DefaultApp defaultApp = defaultApps.get(viewHolder.getAdapterPosition());
ViewHolder holder = (ViewHolder) viewHolder;
Context context = holder.itemView.getContext();
if (defaultApp.getApplicationInfo() != null) {
Drawable icon = defaultApp.getApplicationInfo().loadIcon(context.getPackageManager());
try {
holder.app_icon.setImageDrawable(icon);
} catch (Resources.NotFoundException e) {
holder.app_icon.setImageResource(R.drawable.ic_android);
}
String app_name = context.getPackageManager().getApplicationLabel(defaultApp.getApplicationInfo()).toString();
String app_package = defaultApp.getApplicationInfo().packageName;
holder.app_name.setText(app_name);
holder.app_package.setText(app_package);
holder.delete.setOnClickListener(v -> {
AlertDialog.Builder confirmDialog = new AlertDialog.Builder(context, R.style.AppThemeDialogDelete);
confirmDialog.setMessage(context.getString(R.string.delete_app_from_default, app_name));
confirmDialog.setIcon(R.mipmap.ic_launcher);
confirmDialog.setPositiveButton(R.string.delete, (dialog, id) -> {
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
new DefaultAppDAO(context, db).removeApp(app_package);
defaultApps.remove(defaultApp);
notifyItemRemoved(i);
dialog.dismiss();
});
confirmDialog.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
AlertDialog alertDialog = confirmDialog.create();
alertDialog.show();
});
} else {
holder.app_icon.setImageResource(R.drawable.ic_android);
}
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public int getItemCount() {
return defaultApps.size();
}
static class ViewHolder extends RecyclerView.ViewHolder {
ImageView app_icon, delete;
TextView app_name, app_package;
ConstraintLayout main_container;
ViewHolder(@NonNull View itemView) {
super(itemView);
app_icon = itemView.findViewById(R.id.app_icon);
delete = itemView.findViewById(R.id.delete);
app_name = itemView.findViewById(R.id.app_name);
app_package = itemView.findViewById(R.id.app_package);
main_container = itemView.findViewById(R.id.main_container);
}
}
}

View File

@ -0,0 +1,57 @@
package app.fedilab.nitterizeme.entities;
import android.graphics.drawable.Drawable;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* UntrackMe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
public class AppPicker {
private Drawable icon;
private String name;
private String packageName;
private boolean selected = false;
public Drawable getIcon() {
return icon;
}
public void setIcon(Drawable icon) {
this.icon = icon;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
}

View File

@ -0,0 +1,29 @@
package app.fedilab.nitterizeme.entities;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* UntrackMe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
public class DefaultApp {
private android.content.pm.ApplicationInfo ApplicationInfo;
public android.content.pm.ApplicationInfo getApplicationInfo() {
return ApplicationInfo;
}
public void setApplicationInfo(android.content.pm.ApplicationInfo applicationInfo) {
ApplicationInfo = applicationInfo;
}
}

View File

@ -18,11 +18,14 @@ package app.fedilab.nitterizeme.helpers;
import android.app.DownloadManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Environment;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
@ -31,10 +34,12 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -54,6 +59,7 @@ import static app.fedilab.nitterizeme.activities.MainActivity.SET_NITTER_ENABLED
public class Utils {
public static final String KILL_ACTIVITY = "kill_activity";
public static final String URL_APP_PICKER = "url_app_picker";
public static final Pattern youtubePattern = Pattern.compile("(www\\.|m\\.)?(youtube\\.com|youtu\\.be|youtube-nocookie\\.com)/(((?!([\"'<])).)*)");
public static final Pattern nitterPattern = Pattern.compile("(mobile\\.|www\\.)?twitter.com([\\w-/]+)");
public static final Pattern bibliogramPostPattern = Pattern.compile("(m\\.|www\\.)?instagram.com(/p/[\\w-/]+)");
@ -107,27 +113,44 @@ public class Utils {
try {
comingURl = urls.get(urls.size() - 1);
if (comingURl.startsWith("http://")) {
comingURl = comingURl.replace("http://", "https://");
}
url = new URL(comingURl);
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setRequestProperty("http.keepAlive", "false");
httpsURLConnection.setInstanceFollowRedirects(false);
httpsURLConnection.setRequestMethod("HEAD");
if (httpsURLConnection.getResponseCode() == 301) {
Map<String, List<String>> map = httpsURLConnection.getHeaderFields();
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
if (entry.toString().toLowerCase().startsWith("location")) {
Matcher matcher = urlPattern.matcher(entry.toString());
if (matcher.find()) {
newURL = remove_tracking_param(matcher.group(1));
urls.add(transformUrl(context, newURL));
if (comingURl.startsWith("https")) {
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setRequestProperty("http.keepAlive", "false");
httpsURLConnection.setInstanceFollowRedirects(false);
httpsURLConnection.setRequestMethod("HEAD");
if (httpsURLConnection.getResponseCode() == 301) {
Map<String, List<String>> map = httpsURLConnection.getHeaderFields();
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
if (entry.toString().toLowerCase().startsWith("location")) {
Matcher matcher = urlPattern.matcher(entry.toString());
if (matcher.find()) {
newURL = remove_tracking_param(matcher.group(1));
urls.add(transformUrl(context, newURL));
}
}
}
}
httpsURLConnection.getInputStream().close();
} else {
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestProperty("http.keepAlive", "false");
httpURLConnection.setInstanceFollowRedirects(false);
httpURLConnection.setRequestMethod("HEAD");
if (httpURLConnection.getResponseCode() == 301) {
Map<String, List<String>> map = httpURLConnection.getHeaderFields();
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
if (entry.toString().toLowerCase().startsWith("location")) {
Matcher matcher = urlPattern.matcher(entry.toString());
if (matcher.find()) {
newURL = remove_tracking_param(matcher.group(1));
urls.add(transformUrl(context, newURL));
}
}
}
}
httpURLConnection.getInputStream().close();
}
httpsURLConnection.getInputStream().close();
if (newURL != null && newURL.compareTo(comingURl) != 0) {
URL redirectURL = new URL(newURL);
String host = redirectURL.getHost();
@ -161,6 +184,14 @@ public class Utils {
} catch (MalformedURLException e) {
e.printStackTrace();
}
Uri url_r = Uri.parse(url);
String scheme = url_r.getScheme();
if (scheme == null) {
scheme = "https://";
} else {
scheme += "://";
}
if (Arrays.asList(twitter_domains).contains(host)) {
boolean nitter_enabled = sharedpreferences.getBoolean(SET_NITTER_ENABLED, true);
if (nitter_enabled) {
@ -168,9 +199,9 @@ public class Utils {
assert host != null;
if (host.compareTo("pbs.twimg.com") == 0 || host.compareTo("pic.twitter.com") == 0) {
try {
newUrl = "https://" + nitterHost + "/pic/" + URLEncoder.encode(url, "utf-8");
newUrl = scheme + nitterHost + "/pic/" + URLEncoder.encode(url, "utf-8");
} catch (UnsupportedEncodingException e) {
newUrl = "https://" + nitterHost + "/pic/" + url;
newUrl = scheme + nitterHost + "/pic/" + url;
}
} else if (url.contains("/search?")) {
newUrl = url.replace(host, nitterHost);
@ -178,7 +209,7 @@ public class Utils {
Matcher matcher = nitterPattern.matcher(url);
while (matcher.find()) {
final String nitter_directory = matcher.group(2);
newUrl = "https://" + nitterHost + nitter_directory;
newUrl = scheme + nitterHost + nitter_directory;
}
}
return newUrl;
@ -192,16 +223,16 @@ public class Utils {
while (matcher.find()) {
final String bibliogram_directory = matcher.group(2);
String bibliogramHost = sharedpreferences.getString(MainActivity.SET_BIBLIOGRAM_HOST, MainActivity.DEFAULT_BIBLIOGRAM_HOST).toLowerCase();
newUrl = "https://" + bibliogramHost + bibliogram_directory;
newUrl = scheme + bibliogramHost + bibliogram_directory;
}
matcher = bibliogramAccountPattern.matcher(url);
while (matcher.find()) {
final String bibliogram_directory = matcher.group(2);
String bibliogramHost = sharedpreferences.getString(MainActivity.SET_BIBLIOGRAM_HOST, MainActivity.DEFAULT_BIBLIOGRAM_HOST).toLowerCase();
if (bibliogram_directory != null && bibliogram_directory.compareTo("privacy") != 0) {
newUrl = "https://" + bibliogramHost + "/u" + bibliogram_directory;
newUrl = scheme + bibliogramHost + "/u" + bibliogram_directory;
} else {
newUrl = "https://" + bibliogramHost + bibliogram_directory;
newUrl = scheme + bibliogramHost + bibliogram_directory;
}
}
return newUrl;
@ -228,7 +259,7 @@ public class Utils {
String osmHost = sharedpreferences.getString(MainActivity.SET_OSM_HOST, MainActivity.DEFAULT_OSM_HOST).toLowerCase();
boolean geo_uri_enabled = sharedpreferences.getBoolean(MainActivity.SET_GEO_URIS, false);
if (!geo_uri_enabled) {
newUrl = "https://" + osmHost + "/#map=" + zoom + "/" + data[0] + "/" + data[1];
newUrl = scheme + osmHost + "/#map=" + zoom + "/" + data[0] + "/" + data[1];
} else {
newUrl = "geo:0,0?q=" + data[0] + "," + data[1] + ",z=" + zoom;
}
@ -253,9 +284,9 @@ public class Utils {
final String youtubeId = matcher.group(3);
String invidiousHost = sharedpreferences.getString(MainActivity.SET_INVIDIOUS_HOST, MainActivity.DEFAULT_INVIDIOUS_HOST).toLowerCase();
if (Objects.requireNonNull(matcher.group(2)).compareTo("youtu.be") == 0) {
newUrl = "https://" + invidiousHost + "/watch?v=" + youtubeId + "&local=true";
newUrl = scheme + invidiousHost + "/watch?v=" + youtubeId + "&local=true";
} else {
newUrl = "https://" + invidiousHost + "/" + youtubeId + "&local=true";
newUrl = scheme + invidiousHost + "/" + youtubeId + "&local=true";
}
}
return newUrl;
@ -291,7 +322,7 @@ public class Utils {
* @param url String URL
* @return cleaned URL String
*/
private static String remove_tracking_param(String url) {
public static String remove_tracking_param(String url) {
if (url != null) {
for (String utm : UTM_PARAMS) {
url = url.replaceAll("&amp;" + utm + "=[0-9a-zA-Z._-]*", "");
@ -336,4 +367,93 @@ public class Utils {
e.printStackTrace();
}
}
/**
* Check if an app is installed
*
* @return boolean
*/
@SuppressWarnings("unused")
public static boolean isAppInstalled(Context context, String packageName) {
try {
context.getPackageManager().getPackageInfo(packageName, 0);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
/**
* Get PackageInfo for an app
*
* @return PackageInfo
*/
@SuppressWarnings("unused")
public static PackageInfo getPackageInfo(Context context, String packageName) {
PackageInfo packageInfo = null;
try {
packageInfo = context.getPackageManager().getPackageInfo(packageName, 0);
} catch (Exception ignored) {
}
return packageInfo;
}
/**
* Convert an ArrayList to a string using coma
*
* @param arrayList ArrayList<String>
* @return String
*/
public static String arrayToString(ArrayList<String> arrayList) {
if (arrayList == null || arrayList.size() == 0) {
return null;
}
StringBuilder result = new StringBuilder();
for (String item : arrayList) {
result.append(item).append(",");
}
return result.substring(0, result.length() - 1);
}
/**
* Convert an ArrayList to a string using coma
*
* @param arrayList ArrayList<String>
* @return String
*/
public static String arrayToStringQuery(ArrayList<String> arrayList) {
if (arrayList == null || arrayList.size() == 0) {
return null;
}
StringBuilder result = new StringBuilder();
for (String item : arrayList) {
result.append("'").append(item).append("'").append(",");
}
return result.substring(0, result.length() - 1);
}
/**
* Convert String items to Array
*
* @param items String
* @return ArrayList<String>
*/
public static ArrayList<String> stringToArray(String items) {
if (items == null) {
return null;
}
String[] result = items.split(",");
return new ArrayList<>(Arrays.asList(result));
}
public static <T> ArrayList<T> union(ArrayList<T> list1, ArrayList<T> list2) {
Set<T> set = new HashSet<>();
set.addAll(list1);
set.addAll(list2);
return new ArrayList<>(set);
}
}

View File

@ -0,0 +1,154 @@
package app.fedilab.nitterizeme.sqlite;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* UntrackMe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import java.util.ArrayList;
import app.fedilab.nitterizeme.helpers.Utils;
public class DefaultAppDAO {
public Context context;
private SQLiteDatabase db;
public DefaultAppDAO(Context context, SQLiteDatabase db) {
this.context = context;
this.db = db;
}
public long insert(String packageName, ArrayList<String> concurrentPackages) {
ContentValues values = new ContentValues();
values.put(Sqlite.COL_DEFAULT_PACKAGE, packageName.trim());
concurrentPackages.remove(packageName);
values.put(Sqlite.COL_CONCURRENT_PACKAGES, Utils.arrayToString(concurrentPackages));
try {
return db.insert(Sqlite.TABLE_DEFAULT_APPS, null, values);
} catch (Exception ignored) {
return -1;
}
}
public void update(String packageName, ArrayList<String> concurrentPackages) {
ContentValues values = new ContentValues();
values.put(Sqlite.COL_CONCURRENT_PACKAGES, Utils.arrayToString(concurrentPackages));
try {
db.update(Sqlite.TABLE_DEFAULT_APPS, values, Sqlite.COL_DEFAULT_PACKAGE + " = ? ", new String[]{packageName});
} catch (Exception ignored) {
}
}
public int removeApp(String packageName) {
return db.delete(Sqlite.TABLE_DEFAULT_APPS, Sqlite.COL_DEFAULT_PACKAGE + " = \"" + packageName + "\"", null);
}
public int removeAll() {
return db.delete(Sqlite.TABLE_DEFAULT_APPS, null, null);
}
public ArrayList<String> getConcurrent(String packageName) {
try {
Cursor c = db.query(Sqlite.TABLE_DEFAULT_APPS, null, Sqlite.COL_DEFAULT_PACKAGE + " = '" + packageName + "'", null, null, null, null, null);
return cursorGetConcurrent(c);
} catch (Exception e) {
return null;
}
}
public ArrayList<String> getDefault() {
try {
Cursor c = db.query(Sqlite.TABLE_DEFAULT_APPS, null, null, null, null, null, null, null);
return cursorGetDefaults(c);
} catch (Exception e) {
return null;
}
}
public String getDefault(ArrayList<String> packageNames) {
try {
Cursor c = db.query(Sqlite.TABLE_DEFAULT_APPS, null, Sqlite.COL_DEFAULT_PACKAGE + " IN ( " + Utils.arrayToStringQuery(packageNames) + ")", null, null, null, null, null);
return getBestMatchIfExists(c, packageNames);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public boolean isPresent(String packageName) {
Cursor mCount = db.rawQuery("select count(*) from " + Sqlite.TABLE_DEFAULT_APPS
+ " where " + Sqlite.COL_DEFAULT_PACKAGE + " = '" + packageName + "'", null);
mCount.moveToFirst();
int count = mCount.getInt(0);
mCount.close();
return count > 0;
}
private ArrayList<String> cursorGetConcurrent(Cursor c) {
if (c.getCount() == 0) {
c.close();
return null;
}
ArrayList<String> items = null;
if (c.moveToFirst()) {
String concurrentStr = c.getString(c.getColumnIndex(Sqlite.COL_CONCURRENT_PACKAGES));
items = Utils.stringToArray(concurrentStr);
}
c.close();
return items;
}
private ArrayList<String> cursorGetDefaults(Cursor c) {
if (c.getCount() == 0) {
c.close();
return null;
}
ArrayList<String> items = new ArrayList<>();
while (c.moveToNext()) {
String packageName = c.getString(c.getColumnIndex(Sqlite.COL_DEFAULT_PACKAGE));
items.add(packageName);
}
c.close();
return items;
}
private String getBestMatchIfExists(Cursor c, ArrayList<String> allPackages) {
if (c.getCount() == 0) {
c.close();
return null;
}
ArrayList<String> concurrent = new ArrayList<>();
while (c.moveToNext()) {
String packageName = c.getString(c.getColumnIndex(Sqlite.COL_CONCURRENT_PACKAGES));
concurrent.addAll(Utils.stringToArray(packageName));
}
for (String conc : concurrent) {
allPackages.remove(conc);
}
c.close();
//Items will only returns concurrent for default apps.
//The winner will be the one not in concurrent
if (allPackages.size() == 1) {
return allPackages.get(0);
} else return null;
}
}

View File

@ -0,0 +1,67 @@
package app.fedilab.nitterizeme.sqlite;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* UntrackMe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class Sqlite extends SQLiteOpenHelper {
public static final int DB_VERSION = 1;
public static final String DB_NAME = "untrackme_db";
static final String TABLE_DEFAULT_APPS = "DEFAULT_APPS";
static final String COL_DEFAULT_PACKAGE = "DEFAULT_PACKAGE";
static final String COL_CONCURRENT_PACKAGES = "CONCURRENT_PACKAGES";
private static final String COL_ID = "ID";
private static final String CREATE_TABLE_DEFAULT_APPS = "CREATE TABLE " + TABLE_DEFAULT_APPS + " ("
+ COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ COL_DEFAULT_PACKAGE + " TEXT NOT NULL UNIQUE, " + COL_CONCURRENT_PACKAGES + " TEXT)";
private static SQLiteDatabase db;
private static Sqlite sInstance;
private Sqlite(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}
public static synchronized Sqlite getInstance(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
if (sInstance == null) {
sInstance = new Sqlite(context, name, factory, version);
}
return sInstance;
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_DEFAULT_APPS);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
public SQLiteDatabase open() {
db = getWritableDatabase();
return db;
}
public void close() {
if (db != null && db.isOpen()) {
db.close();
}
}
}

View File

@ -1,34 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="34.79452"
android:viewportHeight="34.79452">
<group
android:translateX="4.6972604"
android:translateY="4.6972604">
<path
android:fillColor="#c4302b"
android:pathData="m4.8102,7.35s5.9145,-2.289 7.9671,-3.4741c2.0527,1.1851 7.8124,3.4741 7.8124,3.4741 0,11.419 -7.8124,14.22 -7.8124,14.22s-7.9671,-2.8007 -7.9671,-14.22z"
android:strokeWidth="1.0583"
android:strokeColor="#1da1f2" />
<path
android:fillColor="#FF000000"
android:pathData="m13.468,11.36v-1.5362l2.6883,2.6883 -2.6883,2.6883v-1.5746c-1.9202,0 -3.2644,0.6145 -4.2245,1.9586 0.384,-1.9202 1.5362,-3.8404 4.2245,-4.2245z"
android:strokeWidth=".26458" />
</group>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/red" />
<corners android:radius="10dp" />
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
</shape>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/colorAccent" />
<corners android:radius="10dp" />
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
</shape>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?><!--
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* UntrackMe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
-->
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.DefaultAppActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_apps"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?><!--
/* Copyright 2020 Thomas Schneider
*
* This file is a part of UntrackMe
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* UntrackMe is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with UntrackMe; if not,
* see <http://www.gnu.org/licenses>. */
-->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.AppsPickerActivity">
<RelativeLayout
android:id="@+id/blank"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/app_container"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/app_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:padding="2dp"
android:id="@+id/url"
android:textSize="12sp"
android:singleLine="true"
android:textColor="@color/colorAccent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
android:ellipsize="end"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/indication"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:drawableStart="@drawable/ic_app_logo"
android:drawableLeft="@drawable/ic_app_logo"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:paddingTop="5dp"
android:text="@string/continue_with"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/url" />
<GridView
android:id="@+id/app_list"
android:layout_width="match_parent"
android:layout_height="200dp"
android:gravity="center"
android:paddingTop="10dp"
android:stretchMode="columnWidth"
app:layout_constraintBottom_toTopOf="@+id/once"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/indication" />
<Button
android:id="@+id/once"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/just_once"
android:textColor="@color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/always"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/always"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/always"
android:textColor="@color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/once"
app:layout_constraintTop_toBottomOf="@+id/app_list" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -638,7 +638,7 @@
style="@style/containerCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@+id/display_indications"
app:layout_constraintTop_toBottomOf="@id/osm_container">
<Button
@ -688,6 +688,106 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/display_indications"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_error"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buttons_container">
<TextView
android:id="@+id/display_indications_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingBottom="10dp"
android:text="@string/indication_error_title"
android:textColor="@color/red"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/display_indications_0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:text="@string/open_configure"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/display_indications_title" />
<TextView
android:id="@+id/display_indications_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:text="@string/supported_url_indication_1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/display_indications_0" />
<ImageView
android:id="@+id/display_indications_img_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/display_indications_1_description"
android:paddingBottom="5dp"
android:src="@drawable/img1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/display_indications_1" />
<TextView
android:id="@+id/display_indications_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:text="@string/supported_url_indication_2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/display_indications_img_1" />
<ImageView
android:id="@+id/display_indications_img_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/display_indications_1_description"
android:paddingBottom="5dp"
android:src="@drawable/img2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/display_indications_2" />
<TextView
android:id="@+id/display_indications_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:text="@string/supported_url_indication_3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/display_indications_img_2" />
<ImageView
android:id="@+id/display_indications_img_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/display_indications_3_description"
android:paddingBottom="5dp"
android:src="@drawable/img3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/display_indications_3" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/app_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/app_icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:contentDescription="@string/icon_of_the_app"
android:paddingTop="5dp"
app:layout_constraintBottom_toTopOf="@+id/app_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/app_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:paddingBottom="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/app_icon" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="10dp">
<ImageView
android:id="@+id/app_icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:contentDescription="@string/icon_of_the_app"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/app_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:ellipsize="end"
android:maxLines="1"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/app_package"
app:layout_constraintEnd_toStartOf="@id/delete"
app:layout_constraintStart_toEndOf="@id/app_icon"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/app_package"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:ellipsize="end"
android:maxLines="1"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/delete"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/app_icon"
app:layout_constraintTop_toBottomOf="@id/app_name"
app:layout_constraintWidth_default="wrap" />
<ImageView
android:id="@+id/delete"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="@string/remove_from_default_app"
android:src="@drawable/ic_delete"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -8,4 +8,10 @@
android:orderInCategory="100"
android:title="@string/action_about"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_settings"
android:icon="@drawable/ic_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="ifRoom" />
</menu>

View File

@ -6,4 +6,5 @@
<color name="topBar">#212121</color>
<color name="containerCard">#272727</color>
<color name="textColor">#EFEFEF</color>
<color name="red">#D50000</color>
</resources>

View File

@ -57,4 +57,21 @@
<string name="share_with">Share with</string>
<string name="check_apps">Check apps</string>
<string name="select_instances">Select instances</string>
<string name="continue_with">Continue with…</string>
<string name="just_once">Just once</string>
<string name="always">Always</string>
<string name="default_app_indication">%1$s has been set as a default app.\nYou can remove this behavior from the app settings.</string>
<string name="indication_error_title">There is something wrong with the configuration of the app. Please, follow these indications to fix that issue.</string>
<string name="open_configure">1 - Tap on the \"CONFIGURE\" button above.</string>
<string name="supported_url_indication_1">2 - You are now in app settings from your device. Tap on \"Set as default\".</string>
<string name="display_indications_1_description">Screenshot showing app settings for the app. You have to Tap on \"Set as default\"</string>
<string name="supported_url_indication_2">2 - Then tap on \"Go to supported URLs\".</string>
<string name="display_indications_2_description">Screenshot showing app settings for the app. You have to Tap on \"Go to supported URLs\"</string>
<string name="supported_url_indication_3">3 - In suggestions make sure to pickup \"Always ask\"</string>
<string name="display_indications_3_description">Screenshot showing app settings to define the behavior for opening URLs</string>
<string name="default_apps">Default apps</string>
<string name="remove_from_default_app">Remove from default apps</string>
<string name="delete">Delete</string>
<string name="cancel">Cancel</string>
<string name="delete_app_from_default">Delete %1$s from default apps?</string>
</resources>

View File

@ -24,6 +24,20 @@
<item name="buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
</style>
<!-- Base application theme. -->
<style name="AppThemeDialogDelete" parent="Theme.AppCompat.Dialog">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@color/containerCard</item>
<item name="android:colorBackground">@color/containerCard</item>
<item name="android:textColor">@color/textColor</item>
<item name="buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
<item name="buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
</style>
<style name="NegativeButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
<item name="android:textColor">@color/colorAccent</item>
</style>
@ -44,6 +58,7 @@
<style name="Theme.AppCompat.Translucent">
<item name="colorAccent">@color/colorAccent</item>
<item name="colorPrimaryDark">@android:color/transparent</item>
<item name="android:textColor">@color/textColor</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>