Commit bf298ac3 by HABI SHAIK

added webview screen for catalogue item selection, handled getnotification in push notifs

parent f2f40f22
......@@ -104,7 +104,7 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation ('com.google.android.gms:play-services-analytics:15.0.2') {
implementation ('com.google.android.gms:play-services-analytics:16.0.8') {
exclude group: 'com.google.firebase', module: 'firebase-iid'
}
......@@ -121,10 +121,10 @@ dependencies {
implementation 'com.android.support:animated-vector-drawable:27.1.1'
implementation 'com.android.support:support-media-compat:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation ('com.google.firebase:firebase-messaging:15.0.2') {
implementation ('com.google.firebase:firebase-messaging:17.6.0') {
exclude group: 'com.google.firebase', module: 'firebase-iid'
}
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
......
......@@ -10,12 +10,13 @@
<application
android:name="com.vsoft.servicenow.CatalogueApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:allowBackup="false"
android:fullBackupContent="false"
tools:replace="allowBackup"
android:theme="@style/AppTheme">
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme"
tools:replace="allowBackup">
<activity
android:name="com.vsoft.servicenow.ui.SplashScreen"
android:label="@string/app_name"
......@@ -29,7 +30,7 @@
<activity
android:name="com.vsoft.servicenow.ui.LoginScreen"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden"/>
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name="com.vsoft.servicenow.ui.HomeScreen"
android:screenOrientation="portrait" />
......@@ -40,19 +41,22 @@
android:name="com.vsoft.servicenow.ui.CatalogueItemScreen"
android:screenOrientation="portrait" />
<activity
android:name="com.vsoft.servicenow.CatalogueWebViewScreen"
android:screenOrientation="portrait" />
<activity
android:name="com.vsoft.servicenow.ui.CatalogueVariableScreen"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize" />
<activity
android:name="com.vsoft.servicenow.ui.ReportIncidentScreen"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize"/>
android:windowSoftInputMode="stateHidden|adjustResize" />
<activity
android:name="com.vsoft.servicenow.ui.MyRequestActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.vsoft.servicenow.ui.MyIncidentScreen"
android:screenOrientation="portrait"/>
android:screenOrientation="portrait" />
<service android:name=".service.SyncService" />
......
package com.vsoft.servicenow;
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.vsoft.servicenow.utils.Constants;
import com.vsoft.servicenow.utils.PrefManager;
import java.util.HashMap;
import java.util.Map;
/**
* Created by habi on 5/24/2019.
*/
public class CatalogueWebViewScreen extends AppCompatActivity {
private WebView wv;
private ProgressDialog progressBar;
String url = "http://vsoftconsultingdev.service-now.com/sp?id=sc_cat_item&sys_id=";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_catalogue_web_view);
wv = (WebView) findViewById(R.id.webview);
Bundle extras = getIntent().getExtras();
String catalogueItemSysId = null;
if (extras != null) {
catalogueItemSysId = extras.getString(Constants.DATA_KEY_SYS_ID);
}
url = url + catalogueItemSysId;
progressBar = new ProgressDialog(CatalogueWebViewScreen.this);
progressBar.setMessage("Loading...");
progressBar.show();
WebSettings webSettings = wv.getSettings();
webSettings.setLoadWithOverviewMode(true);
webSettings.setUseWideViewPort(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setPluginState(WebSettings.PluginState.ON);
webSettings.setDomStorageEnabled(true);
webSettings.setJavaScriptEnabled(true);
wv.setWebViewClient(new myWebClient());
wv.loadUrl(url);
}
public class myWebClient extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url, getCustomHeaders());
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
if (progressBar.isShowing()) {
progressBar.dismiss();
}
}
}
private Map<String, String> getCustomHeaders() {
String authHeader = "Bearer " + PrefManager.getSharedPref(this, PrefManager.PREFERENCE_ACCESS_TOKEN);
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", authHeader);
return headers;
}
}
......@@ -7,7 +7,6 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
......@@ -19,6 +18,7 @@ import android.widget.TextView;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.servicenow.CatalogueApplication;
import com.vsoft.servicenow.CatalogueWebViewScreen;
import com.vsoft.servicenow.R;
import com.vsoft.servicenow.adapters.CatalogueCategoryItemAdapter;
import com.vsoft.servicenow.api.listeners.get.GetCatalogueItemApiListener;
......@@ -191,11 +191,11 @@ public class CatalogueItemScreen extends HandleNotificationActivity {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
CatalogueItem catalogueItem = catalogueItemList.get(position);
Intent intent = new Intent(CatalogueItemScreen.this, CatalogueVariableScreen.class);
Intent intent = new Intent(CatalogueItemScreen.this, CatalogueWebViewScreen.class);
intent.putExtra(Constants.DATA_KEY_SYS_ID, catalogueItem.getSysId());
intent.putExtra(Constants.DATA_KEY_CATALOGUE_ITEM_DESCRIPTION, catalogueItem.getDescription());
/*intent.putExtra(Constants.DATA_KEY_CATALOGUE_ITEM_DESCRIPTION, catalogueItem.getDescription());
intent.putExtra(Constants.DATA_KEY_CATALOGUE_ITEM_SHORT_DESCRIPTION, catalogueItem.getShortDescription());
intent.putExtra(Constants.DATA_KEY_CATALOGUE_TITLE, catalogueItem.getName());
intent.putExtra(Constants.DATA_KEY_CATALOGUE_TITLE, catalogueItem.getName());*/
startActivity(intent);
}
});
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment