Skip to content

Commit

Permalink
Version 11 with better sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
volker committed Oct 21, 2022
1 parent dc8ba60 commit 0324180
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 24 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ zur zugehörigen Android-App. Bisher ist dies eine einfache Webview mit Import-F
alt="Get it on Google Play"
height="80">](https://play.google.com/store/apps/details?id=de.cyberit.wasgeht)

TODO:
- Share-Funktion für beliebige Ziele

Als langfristiges Ziel wäre auch eine native App denkbar, JSON-Apis sind weitestgehend bereits vorhanden.
20 changes: 10 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:7.3.0'
}
}
apply plugin: 'com.android.application'
Expand All @@ -19,22 +18,23 @@ repositories {
}

android {
compileSdkVersion 26
namespace 'de.cyberit.wasgeht'
compileSdk 33
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 10
versionName '1.9'
targetSdk 33
versionCode 11
versionName '1.10'
}
productFlavors {
}
buildTypes {
}
buildToolsVersion '26.0.2'
buildToolsVersion '33.0.0'
}

dependencies {
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:support-annotations:27.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.annotation:annotation:1.5.0'
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
android.enableJetifier=true
android.useAndroidX=true
18 changes: 9 additions & 9 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.cyberit.wasgeht">
>
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
android:allowBackup="true"
Expand All @@ -9,20 +15,14 @@
android:hardwareAccelerated="true"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
android:exported="true"
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

</manifest>
19 changes: 19 additions & 0 deletions src/main/java/de/cyberit/wasgeht/JSObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.CalendarContract;
import android.provider.CalendarContract.Events;
Expand All @@ -17,6 +18,24 @@ public class JSObject {
mContext = c;
}

@JavascriptInterface
public void share(String title, String url) {
try {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setData(Uri.parse(url));
intent.putExtra(Intent.EXTRA_SUBJECT, title);
intent.putExtra(Intent.EXTRA_TITLE, title);
intent.putExtra(Intent.EXTRA_TEXT, title + ":\n" + url);
intent.setType("text/plain");

Intent shareIntent = Intent.createChooser(intent, "Veranstaltung teilen");
mContext.startActivity(shareIntent);
} catch (Exception e) {
e.printStackTrace();
}
}

@JavascriptInterface
public void addEvent(String eventJson) {
try {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/de/cyberit/wasgeht/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.webkit.ConsoleMessage;
Expand Down Expand Up @@ -119,6 +119,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
super.onRequestPermissionsResult(requestCode,permissions,grantResults);
switch (requestCode) {
case MY_PERMISSIONS_ACCESS_FINE_LOCATION: {
// If request is cancelled, the result arrays are empty.
Expand Down

0 comments on commit 0324180

Please sign in to comment.