Initial commit
8
.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
1
.idea/.name
Normal file
|
@ -0,0 +1 @@
|
|||
Diaspora
|
22
.idea/compiler.xml
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
3
.idea/copyright/profiles_settings.xml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
19
.idea/gradle.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="LOCAL" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.8" />
|
||||
<option name="gradleJvm" value="1.8" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
46
.idea/misc.xml
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="true" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
9
.idea/modules.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Diaspora.iml" filepath="$PROJECT_DIR$/Diaspora.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
12
.idea/runConfigurations.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="" />
|
||||
</component>
|
||||
</project>
|
1
app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
29
app/build.gradle
Normal file
|
@ -0,0 +1,29 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.2"
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "de.baumann.diaspora"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 23
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.1.1'
|
||||
compile 'com.android.support:design:23.1.1'
|
||||
compile 'com.getbase:floatingactionbutton:1.9.1'
|
||||
}
|
17
app/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /home/juergen/Android/Sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
|
@ -0,0 +1,13 @@
|
|||
package de.baumann.diaspora;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
64
app/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.baumann.diaspora">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name=".SplashActivity"
|
||||
android:launchMode="singleInstance"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".PodsActivity"
|
||||
android:launchMode="singleInstance"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:label="@string/title_activity_pods"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:launchMode="singleInstance"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:label="@string/diaspora">
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ShareActivity"
|
||||
android:launchMode="singleInstance"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:label="@string/new_post"
|
||||
android:screenOrientation="portrait" >
|
||||
<intent-filter android:label="@string/diaspora"
|
||||
android:icon="@drawable/ic_launcher">
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".services.GetPodsService"
|
||||
android:enabled="true"
|
||||
android:exported="false" >
|
||||
</service>
|
||||
|
||||
</application>
|
||||
</manifest>
|
|
@ -0,0 +1,31 @@
|
|||
package de.baumann.diaspora;
|
||||
|
||||
/**
|
||||
* Created by juergen on 29.02.16.
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.design.widget.Snackbar.SnackbarLayout;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.getbase.floatingactionbutton.FloatingActionButton;
|
||||
import com.getbase.floatingactionbutton.FloatingActionsMenu;
|
||||
|
||||
public class FloatingActionsMenuBehavior extends CoordinatorLayout.Behavior<FloatingActionsMenu> {
|
||||
|
||||
public FloatingActionsMenuBehavior(Context context, AttributeSet attrs) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean layoutDependsOn(CoordinatorLayout parent, FloatingActionsMenu child, View dependency) {
|
||||
return dependency instanceof SnackbarLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionsMenu child, View dependency) {
|
||||
float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
|
||||
child.setTranslationY(translationY);
|
||||
return true;
|
||||
}
|
||||
}
|
1149
app/src/main/java/de/baumann/diaspora/MainActivity.java
Normal file
262
app/src/main/java/de/baumann/diaspora/PodsActivity.java
Normal file
|
@ -0,0 +1,262 @@
|
|||
/*
|
||||
This file is part of the Diaspora Native WebApp.
|
||||
|
||||
Diaspora Native WebApp 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.
|
||||
|
||||
Diaspora Native WebApp 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 the Diaspora Native WebApp.
|
||||
|
||||
If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.baumann.diaspora;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.CookieManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import de.baumann.diaspora.services.GetPodsService;
|
||||
import de.baumann.diaspora.utils.Helpers;
|
||||
|
||||
|
||||
public class PodsActivity extends ActionBarActivity {
|
||||
|
||||
BroadcastReceiver podListReceiver;
|
||||
EditText filter;
|
||||
ListView lv;
|
||||
ImageView imgSelectPod;
|
||||
ProgressDialog progressDialog;
|
||||
private static final String TAG = "Diaspora Pods";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_pods);
|
||||
|
||||
filter = (EditText) findViewById(R.id.edtFilter);
|
||||
lv = (ListView) findViewById(R.id.lstPods);
|
||||
lv.setTextFilterEnabled(true);
|
||||
|
||||
imgSelectPod = (ImageView) findViewById(R.id.imgSelectPod);
|
||||
imgSelectPod.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (filter.getText().length() > 4 && filter.getText().toString().contains("."))
|
||||
askConfirmation(filter.getText().toString());
|
||||
else
|
||||
Snackbar.make(lv, R.string.valid_pod, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
podListReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.hasExtra("pods")) {
|
||||
Bundle extras = intent.getExtras();
|
||||
String[] pods = extras.getStringArray("pods");
|
||||
|
||||
if (progressDialog != null)
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (pods != null && pods.length>0)
|
||||
updateListview(pods);
|
||||
else {
|
||||
Snackbar.make(lv, R.string.podlist_error, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
} else {
|
||||
// List of pods empty
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
registerReceiver(podListReceiver, new IntentFilter(GetPodsService.MESSAGE));
|
||||
|
||||
progressDialog = new ProgressDialog(PodsActivity.this);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setIndeterminate(true);
|
||||
progressDialog.setMessage(getString(R.string.loading_podlist));
|
||||
|
||||
if (Helpers.isOnline(PodsActivity.this)) {
|
||||
progressDialog.show();
|
||||
} else {
|
||||
Snackbar.make(lv, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Intent i= new Intent(PodsActivity.this, GetPodsService.class);
|
||||
startService(i);
|
||||
}
|
||||
|
||||
|
||||
private void updateListview(String[] source) {
|
||||
final ArrayList<String> podList = new ArrayList<>();
|
||||
|
||||
for (int i = 0 ; i < source.length ; i++) {
|
||||
podList.add(source[i].toLowerCase());
|
||||
}
|
||||
Collections.sort(podList);
|
||||
|
||||
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(
|
||||
PodsActivity.this,
|
||||
android.R.layout.simple_list_item_1,
|
||||
podList);
|
||||
lv.setAdapter(adapter);
|
||||
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
askConfirmation(((TextView) view).getText().toString());
|
||||
}
|
||||
});
|
||||
|
||||
adapter.getFilter().filter(filter.getText());
|
||||
filter.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
(adapter).getFilter().filter(s.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void askConfirmation(final String podDomain) {
|
||||
if (Helpers.isOnline(PodsActivity.this)) {
|
||||
new AlertDialog.Builder(PodsActivity.this)
|
||||
.setTitle(getString(R.string.confirmation))
|
||||
.setMessage(getString(R.string.confirm_pod)+podDomain+"?")
|
||||
.setPositiveButton("YES",
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
SharedPreferences sp = getSharedPreferences("PodSettings", MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putString("podDomain", podDomain);
|
||||
editor.apply();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
try {
|
||||
CookieManager.getInstance().removeAllCookies(null);
|
||||
CookieManager.getInstance().removeSessionCookies(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
CookieManager.getInstance().removeAllCookie();
|
||||
CookieManager.getInstance().removeSessionCookie();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Intent i = new Intent(PodsActivity.this, MainActivity.class);
|
||||
dialog.cancel();
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton("NO", new DialogInterface.OnClickListener() {
|
||||
@TargetApi(11)
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
}).show();
|
||||
|
||||
} else {
|
||||
Snackbar.make(lv, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
Snackbar snackbar = Snackbar
|
||||
.make(lv, R.string.confirm_exit, Snackbar.LENGTH_LONG)
|
||||
.setAction(R.string.yes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
moveTaskToBack(true);
|
||||
}
|
||||
});
|
||||
snackbar.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
unregisterReceiver(podListReceiver);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_pods, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.reload) {
|
||||
if (Helpers.isOnline(PodsActivity.this)) {
|
||||
progressDialog.show();
|
||||
Intent i= new Intent(PodsActivity.this, GetPodsService.class);
|
||||
startService(i);
|
||||
return true;
|
||||
} else {
|
||||
Snackbar.make(lv, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
307
app/src/main/java/de/baumann/diaspora/ShareActivity.java
Normal file
|
@ -0,0 +1,307 @@
|
|||
/*
|
||||
This file is part of the Diaspora Native WebApp.
|
||||
|
||||
Diaspora Native WebApp 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.
|
||||
|
||||
Diaspora Native WebApp 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 the Diaspora Native WebApp.
|
||||
|
||||
If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.baumann.diaspora;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.JsResult;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import de.baumann.diaspora.utils.Helpers;
|
||||
|
||||
|
||||
public class ShareActivity extends MainActivity {
|
||||
|
||||
private WebView webView;
|
||||
private static final String TAG = "Diaspora Share";
|
||||
private String podDomain;
|
||||
private ValueCallback<Uri[]> mFilePathCallback;
|
||||
private String mCameraPhotoPath;
|
||||
private com.getbase.floatingactionbutton.FloatingActionsMenu fab;
|
||||
private TextView txtTitle;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
progressBar = (ProgressBar)findViewById(R.id.progressBar);
|
||||
|
||||
txtTitle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (Helpers.isOnline(ShareActivity.this)) {
|
||||
txtTitle.setText(R.string.jb_stream);
|
||||
Intent i = new Intent(ShareActivity.this, MainActivity.class);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(i);
|
||||
finish();
|
||||
} else {
|
||||
Snackbar.make(v, R.string.no_internet, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
SharedPreferences config = getSharedPreferences("PodSettings", MODE_PRIVATE);
|
||||
podDomain = config.getString("podDomain", null);
|
||||
|
||||
fab = (com.getbase.floatingactionbutton.FloatingActionsMenu) findViewById(R.id.multiple_actions);
|
||||
fab.setVisibility(View.GONE);
|
||||
|
||||
webView = (WebView)findViewById(R.id.webView);
|
||||
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
|
||||
|
||||
WebSettings wSettings = webView.getSettings();
|
||||
wSettings.setJavaScriptEnabled(true);
|
||||
wSettings.setBuiltInZoomControls(true);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 21)
|
||||
wSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
|
||||
/*
|
||||
* WebViewClient
|
||||
*/
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
Log.d(TAG, url);
|
||||
if (!url.contains(podDomain)) {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
startActivity(i);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
Log.i(TAG, "Finished loading URL: " + url);
|
||||
}
|
||||
|
||||
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
||||
Log.e(TAG, "Error: " + description);
|
||||
|
||||
new AlertDialog.Builder(ShareActivity.this)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setMessage(description)
|
||||
.setPositiveButton("CLOSE", null)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* WebChromeClient
|
||||
*/
|
||||
webView.setWebChromeClient(new WebChromeClient() {
|
||||
|
||||
public void onProgressChanged(WebView wv, int progress) {
|
||||
progressBar.setProgress(progress);
|
||||
|
||||
if (progress > 0 && progress <= 60) {
|
||||
Helpers.getNotificationCount(wv);
|
||||
}
|
||||
|
||||
if (progress > 60) {
|
||||
Helpers.hideTopBar(wv);
|
||||
}
|
||||
|
||||
if (progress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
|
||||
if (mFilePathCallback != null) mFilePathCallback.onReceiveValue(null);
|
||||
|
||||
mFilePathCallback = filePathCallback;
|
||||
|
||||
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
|
||||
// Create the File where the photo should go
|
||||
File photoFile = null;
|
||||
try {
|
||||
photoFile = createImageFile();
|
||||
takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
|
||||
} catch (IOException ex) {
|
||||
// Error occurred while creating the File
|
||||
Snackbar.make(getWindow().findViewById(R.id.drawer_layout), "Unable to get image", Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
// Continue only if the File was successfully created
|
||||
if (photoFile != null) {
|
||||
mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
|
||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
|
||||
Uri.fromFile(photoFile));
|
||||
} else {
|
||||
takePictureIntent = null;
|
||||
}
|
||||
}
|
||||
|
||||
Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
contentSelectionIntent.setType("image/*");
|
||||
|
||||
Intent[] intentArray;
|
||||
if (takePictureIntent != null) {
|
||||
intentArray = new Intent[]{takePictureIntent};
|
||||
} else {
|
||||
intentArray = new Intent[0];
|
||||
}
|
||||
|
||||
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
|
||||
chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
|
||||
chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
|
||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
|
||||
|
||||
startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
|
||||
return super.onJsAlert(view, url, message, result);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
Intent intent = getIntent();
|
||||
final Bundle extras = intent.getExtras();
|
||||
String action = intent.getAction();
|
||||
|
||||
if (Intent.ACTION_SEND.equals(action)) {
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
|
||||
if (extras.containsKey(Intent.EXTRA_TEXT) && extras.containsKey(Intent.EXTRA_SUBJECT)) {
|
||||
final String extraText = (String) extras.get(Intent.EXTRA_TEXT);
|
||||
final String extraSubject = (String) extras.get(Intent.EXTRA_SUBJECT);
|
||||
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
|
||||
finish();
|
||||
|
||||
Snackbar.make(webView, R.string.please_reload, Snackbar.LENGTH_LONG).show();
|
||||
|
||||
Intent i = new Intent(ShareActivity.this, MainActivity.class);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(i);
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
webView.loadUrl("javascript:(function() { " +
|
||||
"document.getElementsByTagName('textarea')[0].style.height='110px'; " +
|
||||
"document.getElementsByTagName('textarea')[0].innerHTML = '[" + extraSubject + "](" + extraText + ") #ViaDiasporaNativeWebApp'; " +
|
||||
" if(document.getElementById(\"main_nav\")) {" +
|
||||
" document.getElementById(\"main_nav\").parentNode.removeChild(" +
|
||||
" document.getElementById(\"main_nav\"));" +
|
||||
" } else if (document.getElementById(\"main-nav\")) {" +
|
||||
" document.getElementById(\"main-nav\").parentNode.removeChild(" +
|
||||
" document.getElementById(\"main-nav\"));" +
|
||||
" }" +
|
||||
"})();");
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
if (Helpers.isOnline(ShareActivity.this)) {
|
||||
webView.loadUrl("https://"+podDomain+"/status_messages/new");
|
||||
} else {
|
||||
Snackbar.make(getWindow().findViewById(R.id.drawer_layout), R.string.no_internet, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private File createImageFile() throws IOException {
|
||||
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
||||
String imageFileName = "JPEG_" + timeStamp + "_";
|
||||
File storageDir = Environment.getExternalStoragePublicDirectory(
|
||||
Environment.DIRECTORY_PICTURES);
|
||||
return File.createTempFile(
|
||||
imageFileName, /* prefix */
|
||||
".jpg", /* suffix */
|
||||
storageDir /* directory */
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_compose, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.reload) {
|
||||
if (Helpers.isOnline(ShareActivity.this)) {
|
||||
webView.reload();
|
||||
return true;
|
||||
} else {
|
||||
Snackbar.make(getWindow().findViewById(R.id.drawer_layout), R.string.no_internet, Snackbar.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
71
app/src/main/java/de/baumann/diaspora/SplashActivity.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
This file is part of the Diaspora Native WebApp.
|
||||
|
||||
Diaspora Native WebApp 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.
|
||||
|
||||
Diaspora Native WebApp 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 the Diaspora Native WebApp.
|
||||
|
||||
If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.baumann.diaspora;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
ImageView imgSplash;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_splash);
|
||||
|
||||
imgSplash = (ImageView) findViewById(R.id.imgSplash);
|
||||
|
||||
TypedArray images = getResources().obtainTypedArray(R.array.splash_images);
|
||||
int choice = (int) (Math.random() * images.length());
|
||||
imgSplash.setImageResource(images.getResourceId(choice, R.drawable.splashscreen1));
|
||||
images.recycle();
|
||||
|
||||
final SharedPreferences config = getSharedPreferences("PodSettings", MODE_PRIVATE);
|
||||
|
||||
Timer timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent i;
|
||||
if (config.getString("podDomain", null) != null) {
|
||||
i = new Intent(SplashActivity.this, MainActivity.class);
|
||||
} else {
|
||||
i = new Intent(SplashActivity.this, PodsActivity.class);
|
||||
}
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
This file is part of the Diaspora Native WebApp.
|
||||
|
||||
Diaspora Native WebApp 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.
|
||||
|
||||
Diaspora Native WebApp 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 the Diaspora Native WebApp.
|
||||
|
||||
If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.baumann.diaspora.services;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.StatusLine;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GetPodsService extends Service {
|
||||
public static final String MESSAGE = "de.baumann.diaspora.podsreceived";
|
||||
|
||||
private static final String TAG = "Diaspora Pod Service";
|
||||
|
||||
public GetPodsService() { }
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
getPods();
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
private void getPods() {
|
||||
/*
|
||||
* Most of the code in this AsyncTask is from the file getPodlistTask.java
|
||||
* from the app "Diaspora Webclient".
|
||||
* A few modifications and adaptations were made by me.
|
||||
* Source:
|
||||
* https://github.com/voidcode/Diaspora-Webclient/blob/master/src/com/voidcode/diasporawebclient/getPodlistTask.java
|
||||
* Thanks to Terkel Sørensen
|
||||
*/
|
||||
AsyncTask<Void, Void, String[]> getPodsAsync = new AsyncTask<Void, Void, String[]>() {
|
||||
@Override
|
||||
protected String[] doInBackground(Void... params) {
|
||||
|
||||
// TODO: Update deprecated code
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
HttpClient client = new DefaultHttpClient();
|
||||
List<String> list = null;
|
||||
try {
|
||||
HttpGet httpGet = new HttpGet("http://podupti.me/api.php?key=4r45tg&format=json");
|
||||
HttpResponse response = client.execute(httpGet);
|
||||
StatusLine statusLine = response.getStatusLine();
|
||||
int statusCode = statusLine.getStatusCode();
|
||||
if (statusCode == 200) {
|
||||
HttpEntity entity = response.getEntity();
|
||||
InputStream content = entity.getContent();
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(content));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
} else {
|
||||
//TODO Notify User about failure
|
||||
Log.e(TAG, "Failed to download list of pods");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
//TODO handle json buggy feed
|
||||
e.printStackTrace();
|
||||
}
|
||||
//Parse the JSON Data
|
||||
try {
|
||||
JSONObject j = new JSONObject(builder.toString());
|
||||
JSONArray jr = j.getJSONArray("pods");
|
||||
Log.d(TAG, "Number of entries " + jr.length());
|
||||
list = new ArrayList<String>();
|
||||
for (int i = 0; i < jr.length(); i++) {
|
||||
JSONObject jo = jr.getJSONObject(i);
|
||||
Log.d(TAG, jo.getString("domain"));
|
||||
String secure = jo.getString("secure");
|
||||
if (secure.equals("true"))
|
||||
list.add(jo.getString("domain"));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
//TODO Handle Parsing errors here
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (list != null)
|
||||
return list.toArray(new String[list.size()]);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String[] strings) {
|
||||
Intent broadcastIntent = new Intent(MESSAGE);
|
||||
if (strings != null)
|
||||
broadcastIntent.putExtra("pods", strings);
|
||||
sendBroadcast(broadcastIntent);
|
||||
stopSelf();
|
||||
}
|
||||
};
|
||||
getPodsAsync.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
// TODO: Return the communication channel to the service.
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
}
|
||||
|
||||
}
|
64
app/src/main/java/de/baumann/diaspora/utils/Helpers.java
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
This file is part of the Diaspora Native WebApp.
|
||||
|
||||
Diaspora Native WebApp 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.
|
||||
|
||||
Diaspora Native WebApp 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 the Diaspora Native WebApp.
|
||||
|
||||
If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.baumann.diaspora.utils;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.webkit.WebView;
|
||||
|
||||
public class Helpers {
|
||||
|
||||
public static boolean isOnline(Context context){
|
||||
ConnectivityManager cnm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo ni = cnm.getActiveNetworkInfo();
|
||||
return ni != null && ni.isConnectedOrConnecting();
|
||||
}
|
||||
|
||||
public static void hideTopBar(WebView wv) {
|
||||
wv.loadUrl("javascript: ( function() {" +
|
||||
" if(document.getElementById('main_nav')) {" +
|
||||
" document.getElementById('main_nav').parentNode.removeChild(" +
|
||||
" document.getElementById('main_nav'));" +
|
||||
" } else if (document.getElementById('main-nav')) {" +
|
||||
" document.getElementById('main-nav').parentNode.removeChild(" +
|
||||
" document.getElementById('main-nav'));" +
|
||||
" }" +
|
||||
"})();");
|
||||
}
|
||||
|
||||
public static void getNotificationCount(WebView wv) {
|
||||
wv.loadUrl("javascript: ( function() {" +
|
||||
" if (document.getElementById('notification')) {" +
|
||||
" var count = document.getElementById('notification').innerHTML;" +
|
||||
" NotificationCounter.setNotificationCount(count.replace(/(\\r\\n|\\n|\\r)/gm, \"\"));" +
|
||||
" } else {" +
|
||||
" NotificationCounter.setNotificationCount('0');" +
|
||||
" }" +
|
||||
" if (document.getElementById('conversation')) {" +
|
||||
" var count = document.getElementById('conversation').innerHTML;" +
|
||||
" NotificationCounter.setConversationCount(count.replace(/(\\r\\n|\\n|\\r)/gm, \"\"));" +
|
||||
" } else {" +
|
||||
" NotificationCounter.setConversationCount('0');" +
|
||||
" }" +
|
||||
"})();");
|
||||
}
|
||||
}
|
52
app/src/main/java/de/baumann/diaspora/utils/PrefManager.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package de.baumann.diaspora.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
public class PrefManager {
|
||||
|
||||
private final Context context;
|
||||
private boolean loadImages = true;
|
||||
private int minimumFontSize = 0;
|
||||
|
||||
public PrefManager(Context ctx) {
|
||||
SharedPreferences sp = null;
|
||||
this.context = ctx;
|
||||
try {
|
||||
sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (sp != null) {
|
||||
loadImages = sp.getBoolean("loadImages", true);
|
||||
minimumFontSize = sp.getInt("minimumFontSize", 8);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getLoadImages() {
|
||||
return loadImages;
|
||||
}
|
||||
|
||||
public void setLoadImages(boolean loadImages) {
|
||||
this.loadImages = loadImages;
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
Editor edit = sp.edit();
|
||||
edit.putBoolean("loadImages", loadImages);
|
||||
edit.commit();
|
||||
}
|
||||
|
||||
public int getMinimumFontSize() {
|
||||
return minimumFontSize;
|
||||
}
|
||||
|
||||
public void setMinimumFontSize(int minimumFontSize) {
|
||||
this.minimumFontSize = minimumFontSize;
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
Editor edit = sp.edit();
|
||||
edit.putInt("minimumFontSize", minimumFontSize);
|
||||
edit.commit();
|
||||
}
|
||||
}
|
BIN
app/src/main/res/drawable-hdpi/ic_bell_outline_white_24dp.png
Normal file
After Width: | Height: | Size: 490 B |
BIN
app/src/main/res/drawable-hdpi/ic_bell_ring_white_24dp.png
Normal file
After Width: | Height: | Size: 600 B |
BIN
app/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 354 B |
BIN
app/src/main/res/drawable-hdpi/ic_message_text_white_24dp.png
Normal file
After Width: | Height: | Size: 346 B |
BIN
app/src/main/res/drawable-hdpi/ic_sync_white_24dp.png
Normal file
After Width: | Height: | Size: 565 B |
BIN
app/src/main/res/drawable-mdpi/ic_bell_outline_white_24dp.png
Normal file
After Width: | Height: | Size: 311 B |
BIN
app/src/main/res/drawable-mdpi/ic_bell_ring_white_24dp.png
Normal file
After Width: | Height: | Size: 400 B |
BIN
app/src/main/res/drawable-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 250 B |
BIN
app/src/main/res/drawable-mdpi/ic_message_text_white_24dp.png
Normal file
After Width: | Height: | Size: 244 B |
BIN
app/src/main/res/drawable-mdpi/ic_sync_white_24dp.png
Normal file
After Width: | Height: | Size: 406 B |
BIN
app/src/main/res/drawable-xhdpi/ic_bell_outline_white_24dp.png
Normal file
After Width: | Height: | Size: 540 B |
BIN
app/src/main/res/drawable-xhdpi/ic_bell_ring_white_24dp.png
Normal file
After Width: | Height: | Size: 706 B |