mirror of
https://github.com/gsantner/dandelion
synced 2025-12-08 21:31:10 +01:00
Link to profile; Move menu actions; Refactoring part1
This commit is contained in:
parent
901faf94cb
commit
5f3b07e973
25 changed files with 531 additions and 650 deletions
32
app/src/main/java/de/baumann/diaspora/AppSettings.java
Normal file
32
app/src/main/java/de/baumann/diaspora/AppSettings.java
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package de.baumann.diaspora;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
/**
|
||||
* Created by de-live-gdev on 20.03.16.
|
||||
*/
|
||||
public class AppSettings {
|
||||
private Context context;
|
||||
private SharedPreferences pref;
|
||||
|
||||
public AppSettings(Context context){
|
||||
this.context = context.getApplicationContext();
|
||||
pref = this.context.getSharedPreferences("app", Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
private void setString(String key, String value){
|
||||
pref.edit().putString(key,value).apply();
|
||||
}
|
||||
|
||||
/*
|
||||
// Setters & Getters
|
||||
*/
|
||||
private static final String PREF_PROFILE_ID = "profileID";
|
||||
public String getProfileId(){
|
||||
return pref.getString(PREF_PROFILE_ID, "");
|
||||
}
|
||||
public void setProfileId(String profileId){
|
||||
setString(PREF_PROFILE_ID, profileId);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -241,7 +241,7 @@ public class PodsActivity extends ActionBarActivity {
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.reload) {
|
||||
if (id == R.id.action_reload) {
|
||||
if (Helpers.isOnline(PodsActivity.this)) {
|
||||
progressDialog.show();
|
||||
Intent i= new Intent(PodsActivity.this, GetPodsService.class);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ 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;
|
||||
|
|
@ -333,7 +332,7 @@ public class ShareActivity extends MainActivity {
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.reload) {
|
||||
if (id == R.id.action_reload) {
|
||||
if (Helpers.isOnline(ShareActivity.this)) {
|
||||
webView.reload();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ public class ShareActivity2 extends MainActivity {
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.reload) {
|
||||
if (id == R.id.action_reload) {
|
||||
if (Helpers.isOnline(ShareActivity2.this)) {
|
||||
webView.reload();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class Helpers {
|
|||
return ni != null && ni.isConnectedOrConnecting();
|
||||
}
|
||||
|
||||
public static void hideTopBar(WebView wv) {
|
||||
public static void hideTopBar(final WebView wv) {
|
||||
wv.loadUrl("javascript: ( function() {" +
|
||||
" if(document.getElementById('main_nav')) {" +
|
||||
" document.getElementById('main_nav').parentNode.removeChild(" +
|
||||
|
|
@ -45,20 +45,29 @@ public class Helpers {
|
|||
"})();");
|
||||
}
|
||||
|
||||
public static void getNotificationCount(WebView wv) {
|
||||
public static void getNotificationCount(final WebView wv) {
|
||||
wv.loadUrl("javascript: ( function() {" +
|
||||
" if (document.getElementById('notification')) {" +
|
||||
"if (document.getElementById('notification')) {" +
|
||||
" var count = document.getElementById('notification').innerHTML;" +
|
||||
" NotificationCounter.setNotificationCount(count.replace(/(\\r\\n|\\n|\\r)/gm, \"\"));" +
|
||||
" AndroidBridge.setNotificationCount(count.replace(/(\\r\\n|\\n|\\r)/gm, \"\"));" +
|
||||
" } else {" +
|
||||
" NotificationCounter.setNotificationCount('0');" +
|
||||
" AndroidBridge.setNotificationCount('0');" +
|
||||
" }" +
|
||||
" if (document.getElementById('conversation')) {" +
|
||||
" var count = document.getElementById('conversation').innerHTML;" +
|
||||
" NotificationCounter.setConversationCount(count.replace(/(\\r\\n|\\n|\\r)/gm, \"\"));" +
|
||||
" AndroidBridge.setConversationCount(count.replace(/(\\r\\n|\\n|\\r)/gm, \"\"));" +
|
||||
" } else {" +
|
||||
" NotificationCounter.setConversationCount('0');" +
|
||||
" AndroidBridge.setConversationCount('0');" +
|
||||
" }" +
|
||||
"})();");
|
||||
}
|
||||
|
||||
public static void getProfileId(final WebView wv) {
|
||||
wv.loadUrl("javascript: ( function() {" +
|
||||
" if (typeof gon !== 'undefined' && typeof gon.user !== 'undefined' && typeof gon.user.guid !== 'undefined') {" +
|
||||
" var guid = gon.user.guid;" +
|
||||
" AndroidBridge.setProfileId(guid.toString());" +
|
||||
" } " +
|
||||
"})();");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue