1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2025-09-09 10:19:42 +02:00

Update paths

This commit is contained in:
Gregor Santner 2018-05-13 12:08:27 +02:00
parent 099eb9ca78
commit 65ba10712f
10 changed files with 82 additions and 28 deletions

View file

@ -337,7 +337,7 @@ public class MainActivity extends ThemedActivity
// This URL seems to be called somehow, but it doesn't make sense ;)
toolbarTop.postDelayed(() -> {
Intent i = new Intent(ACTION_OPEN_EXTERNAL_URL);
i.putExtra(EXTRA_URL, "https://github.com/Diaspora-for-Android/dandelion/blob/master/README.md");
i.putExtra(EXTRA_URL, "https://github.com/gsantner/dandelion/blob/master/README.md");
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(i);
}, 1000);
return;

View file

@ -59,7 +59,7 @@ public class FetchPodsService extends Service {
}
class GetPodsTask extends AsyncTask<Void, Void, DiasporaPodList> {
private static final String PODDY_PODLIST_URL = "https://raw.githubusercontent.com/Diaspora-for-Android/dandelion/master/app/src/main/res/raw/podlist.json";
private static final String PODDY_PODLIST_URL = "https://raw.githubusercontent.com/gsantner/dandelion/master/app/src/main/res/raw/podlist.json";
private final Service service;

View file

@ -166,7 +166,7 @@ public class ContextUtils {
public String getAppVersionName() {
try {
PackageManager manager = _context.getPackageManager();
PackageInfo info = manager.getPackageInfo(_context.getPackageName(), 0);
PackageInfo info = manager.getPackageInfo(getPackageName(), 0);
return info.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
@ -174,6 +174,39 @@ public class ContextUtils {
}
}
public String getAppInstallationSource() {
String src = null;
try {
src = _context.getPackageManager().getInstallerPackageName(getPackageName());
} catch (Exception ignored) {
}
if (TextUtils.isEmpty(src)) {
return "Sideloaded";
} else if (src.toLowerCase().contains(".amazon.")) {
return "Amazon Appstore";
}
switch (src) {
case "com.android.vending":
case "com.google.android.feedback": {
return "Google Play Store";
}
case "org.fdroid.fdroid.privileged":
case "org.fdroid.fdroid": {
return "F-Droid";
}
case "com.github.yeriomin.yalpstore": {
return "Yalp Store";
}
case "cm.aptoide.pt": {
return "Aptoide";
}
case "com.android.packageinstaller": {
return "Package Installer";
}
}
return src;
}
/**
* Send a {@link Intent#ACTION_VIEW} Intent with given paramter
* If the parameter is an string a browser will get triggered
@ -189,6 +222,14 @@ public class ContextUtils {
}
}
/**
* Get this apps package name. The builtin method may fail when used with flavors
*/
public String getPackageName() {
String pkg = rstr("manifest_package_id");
return pkg != null ? pkg : _context.getPackageName();
}
/**
* Get field from ${applicationId}.BuildConfig
* May be helpful in libraries, where a access to
@ -198,8 +239,7 @@ public class ContextUtils {
* Falls back to applicationId of the app which may differ from manifest.
*/
public Object getBuildConfigValue(String fieldName) {
String pkg = rstr("manifest_package_id");
pkg = (pkg != null ? pkg : _context.getPackageName()) + ".BuildConfig";
String pkg = getPackageName() + ".BuildConfig";
try {
Class<?> c = Class.forName(pkg);
return c.getField(fieldName).get(null);
@ -231,6 +271,17 @@ public class ContextUtils {
return defaultValue;
}
/**
* Get a BuildConfig string value
*/
public Integer bcint(String fieldName, int defaultValue) {
Object field = getBuildConfigValue(fieldName);
if (field != null && field instanceof Integer) {
return (Integer) field;
}
return defaultValue;
}
/**
* Check if this is a gplay build (requires BuildConfig field)
*/

View file

@ -21,9 +21,9 @@ import java.io.File;
@SuppressWarnings({"unused", "WeakerAccess"})
public class PermissionChecker {
private static final int CODE_PERMISSION_EXTERNAL_STORAGE = 4000;
protected static final int CODE_PERMISSION_EXTERNAL_STORAGE = 4000;
private Activity _activity;
protected Activity _activity;
public PermissionChecker(Activity activity) {
_activity = activity;

View file

@ -54,6 +54,7 @@ public class ShareUtil {
public final static String EXTRA_FILEPATH = "real_file_path_2";
public final static SimpleDateFormat SDF_RFC3339_ISH = new SimpleDateFormat("yyyy-MM-dd'T'HH-mm", Locale.getDefault());
public final static SimpleDateFormat SDF_SHORT = new SimpleDateFormat("yyMMdd-HHmm", Locale.getDefault());
public final static String MIME_TEXT_PLAIN = "text/plain";
protected Context _context;
@ -162,7 +163,7 @@ public class ShareUtil {
public void shareText(String text, @Nullable String mimeType) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, text);
intent.setType(mimeType != null ? mimeType : "text/plain");
intent.setType(mimeType != null ? mimeType : MIME_TEXT_PLAIN);
showChooser(intent, null);
}
@ -419,7 +420,7 @@ public class ShareUtil {
fileStr = "/" + fileStr;
}
// Some do add some custom prefix
for (String prefix : new String[]{"file", "document", "root_files"}) {
for (String prefix : new String[]{"file", "document", "root_files", "name"}) {
if (fileStr.startsWith(prefix)) {
fileStr = fileStr.substring(prefix.length());
}
@ -443,6 +444,8 @@ public class ShareUtil {
tmpf = new File(Uri.decode(fileStr));
if (tmpf.exists()) {
return tmpf;
} else if ((tmpf = new File(fileStr)).exists()) {
return tmpf;
}
}
}

View file

@ -6,7 +6,7 @@
<string name="shared_via_app" translatable="false">
\n\n\n_________________________\n
**Tags:** #dandelíon \n\n
*via [dandelion*](/people?q=dandelion00%40diasp.org) client [(Source)](https://github.com/Diaspora-for-Android/dandelion)*</string>
*via [dandelion*](/people?q=dandelion00%40diasp.org) client [(Source)](https://github.com/gsantner/dandelion)*</string>
<string name="tor" translatable="false">Tor</string>
@ -29,9 +29,9 @@
<string name="fragment_licesen__misc_leafpic_link" translatable="false">https://github.com/HoraApps/LeafPic</string>
<string name="fragment_about__fdroid_link" translatable="false">https://f-droid.org/repository/browse/?fdid=com.github.dfa.diaspora_android</string>
<string name="fragment_about__about" translatable="false">@string/app_name</string>
<string name="fragment_about__contribute_link" translatable="false">https://github.com/Diaspora-for-Android/dandelion</string>
<string name="fragment_about__translate_link" translatable="false">https://crowdin.com/project/diaspora-for-android/invite</string>
<string name="fragment_About__feedback_link" translatable="false">https://github.com/Diaspora-for-Android/dandelion/issues</string>
<string name="fragment_about__contribute_link" translatable="false">https://github.com/gsantner/dandelion</string>
<string name="fragment_about__translate_link" translatable="false">https://crowdin.com/project/gsantner/invite</string>
<string name="fragment_About__feedback_link" translatable="false">https://github.com/gsantner/dandelion/issues</string>