Skip to content

Commit

Permalink
Refactored the sunbird-mobile android code structure
Browse files Browse the repository at this point in the history
  • Loading branch information
souvikmondal committed Nov 9, 2017
1 parent 367c3c3 commit 08c393b
Show file tree
Hide file tree
Showing 213 changed files with 33 additions and 4,192 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ dui-demo/gradle.properties
.idea/vcs.xml
build/
*.iml
/.idea/
/.gradle/
3 changes: 3 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
4 changes: 3 additions & 1 deletion dui-demo/build.gradle → app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://platform.ekstep.in/downloads/content/repositories/production" }
maven { url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2' }
maven { url "https://jp-sunbird.s3.ap-south-1.amazonaws.com/dui/" }

flatDir {
dirs 'libs'
Expand Down Expand Up @@ -134,7 +135,8 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name: 'CordovaLib', ext: 'aar')
compile(name: 'geniecanvas', ext: 'aar')
compile project(':mystique')

compile 'in.juspay:mystique:0.1.0'

compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:support-v4:$SUPPORT_LIBRARY_VERSION"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void onCreate() {
super.onCreate();

instance = this;
GenieService.init(this, "org.sunbird");
GenieService.init(this, this.getClass().getPackage().getName());
initPreferenceWrapper();
setParams();
registerActivityLifecycleCallbacks(ForegroundService.getInstance());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
import org.sunbird.BuildConfig;
import org.sunbird.GlobalApplication;
import org.sunbird.R;
import org.sunbird.analytics.Logger;
import org.sunbird.models.ApiResponse;
import org.sunbird.telemetry.TelemetryAction;
import org.sunbird.telemetry.TelemetryBuilder;
Expand Down Expand Up @@ -393,7 +392,7 @@ public void run() {
if (view != null) {
view.setBackgroundResource(outValue.resourceId);
} else {
Logger.e(LOG_TAG, "Unable to find view with resID - " + res + " : " + resInt);
Log.e(LOG_TAG, "Unable to find view with resID - " + res + " : " + resInt);
}
} catch (Exception e) {
//No op
Expand Down Expand Up @@ -1311,7 +1310,7 @@ public void callAPI(final String method, final String url, String dat, String he
@Override
protected void onPostExecute(Object o) {
if (o == null) {
// Logger.e(LOG_TAG,"Please check if HTTP method (GET, POST, ..) is supported");
// Log.e(LOG_TAG,"Please check if HTTP method (GET, POST, ..) is supported");
}
ApiResponse apiResponse = (ApiResponse) o;
// Log.e("callAPI", "Response of API: "+ ((ApiResponse) o).getData());
Expand Down Expand Up @@ -1412,7 +1411,7 @@ public void run() {
String javascript = String.format("window.callJSCallback('%s','%s');", callbackImage, "" + path[0]);
dynamicUI.addJsToWebView(javascript);
} catch (Exception e) {
Logger.e(LOG_TAG, "Exception", e);
Log.e(LOG_TAG, "Exception", e);
}
}
});
Expand Down Expand Up @@ -1457,7 +1456,7 @@ private byte[] gunzipContent(byte[] compressed) {
os.close();
return output;
} catch (IOException e) {
Logger.e(LOG_TAG, "Exception while gunzipping - ", e);
Log.e(LOG_TAG, "Exception while gunzipping - ", e);

return null;
}
Expand Down Expand Up @@ -1493,7 +1492,7 @@ private String decryptJSFile(byte[] fileData) {
}
return new String(gunzipContent(encryptedWithoutKey));
} catch (Exception e) {
Logger.e(LOG_TAG, "Exception while decrypting - ", e);
Log.e(LOG_TAG, "Exception while decrypting - ", e);
return null;
}
}
Expand All @@ -1510,7 +1509,7 @@ public String getKey(String payload, String defaultValue) {

@JavascriptInterface
public String decryptAndloadFile(String fileName) {
Logger.d(LOG_TAG, "Processing File - " + fileName);
Log.d(LOG_TAG, "Processing File - " + fileName);
//Converting byte data to string is messing the gunzipping of file
String data = null;
byte[] fileData = null;
Expand Down Expand Up @@ -1894,7 +1893,7 @@ public void run() {
listView.setAdapter(listViewAdapter);
listView.setDividerHeight(0);
}catch (Exception e){
Logger.d(LOG_TAG, "Error in rendering listview");
Log.d(LOG_TAG, "Error in rendering listview");
}
}
});
Expand Down Expand Up @@ -1943,7 +1942,7 @@ public void run() {
adapter.addItemsToList(itemCount, valueArrayList, viewJSXArrayList, viewTypeArrayList);
adapter.notifyDataSetChanged();
}catch (Exception e){
Logger.d(LOG_TAG, "Error in adding item to listview");
Log.d(LOG_TAG, "Error in adding item to listview");
}
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.sunbird.utils;

import android.content.Context;

import org.sunbird.analytics.Logger;
import android.util.Log;

import java.io.ByteArrayOutputStream;
import java.io.File;
Expand Down Expand Up @@ -30,7 +29,7 @@ public static byte[] getFileFromInternalStorageOrAssets(Context context, String
data = getFileFromAssets(context, assetsFolder + "/" + fileName);
}
} catch (Exception e) {
Logger.e(TAG, "not found in internal storage.", e);
Log.e(TAG, "not found in internal storage.", e);
data = getFileFromAssets(context, assetsFolder + "/" + fileName);
}
return data;
Expand All @@ -46,7 +45,7 @@ public static byte[] getFileFromInternalStorage(Context context, String fileName
FileInputStream fileInputStream = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bos = readFromInputStream(bos, fileInputStream);
Logger.d(TAG, fileName + " found in internal storage.");
Log.d(TAG, fileName + " found in internal storage.");
return bos.toByteArray();
} else {
return null;
Expand All @@ -61,7 +60,7 @@ public static byte[] getFileFromAssets(Context context, String fileName) throws
InputStream inputStream = context.getAssets().open(fileName, Context.MODE_PRIVATE);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bos = readFromInputStream(bos, inputStream);
Logger.d(TAG, fileName + " found in assets.");
Log.d(TAG, fileName + " found in assets.");
return bos.toByteArray();
}

Expand Down Expand Up @@ -99,15 +98,14 @@ public static void saveFileToInternalStorage(Context context, String fileName, b
outputStream = new FileOutputStream(new File(context.getDir(INTERNAL_STORAGE_DIR, Context.MODE_PRIVATE), fileName));
outputStream.write(data);
} catch (Exception ex) {
Logger.e(TAG, "Exception while writing stream", ex);
Logger.exception(ex);
Log.e(TAG, "Exception while writing stream", ex);
} finally {
try {
if (outputStream != null) {
outputStream.close();
}
} catch (IOException ex) {
Logger.e(TAG, "Exception while closing stream", ex);
Log.e(TAG, "Exception while closing stream", ex);
}

}
Expand All @@ -121,14 +119,14 @@ public static byte[] getInternalStorageFileAsByte(String fileName, Context conte
ous = readFromInputStream(ous, ios);
return ous.toByteArray();
} catch (FileNotFoundException e) {
Logger.e(TAG, "Could not read " + fileName, e);
Log.e(TAG, "Could not read " + fileName, e);
throw new RuntimeException(e);
} catch (IOException e) {
Logger.e(TAG, "Could not read " + fileName, e);
Log.e(TAG, "Could not read " + fileName, e);
deleteFileFromInternalStorage(fileName, context);
throw new RuntimeException(e);
} catch (Exception e) {
Logger.e(TAG, "Could not read " + fileName, e);
Log.e(TAG, "Could not read " + fileName, e);
deleteFileFromInternalStorage(fileName, context);
throw new RuntimeException(e);
}
Expand All @@ -137,10 +135,10 @@ public static byte[] getInternalStorageFileAsByte(String fileName, Context conte
public static boolean deleteFileFromInternalStorage(String fileName, Context context) {
File corruptedFile = getFileFromInternalStorage(fileName, context);
if (corruptedFile.exists()) {
Logger.e(TAG, "FILE CORRUPTED. DISABLING GODEL");
Log.e(TAG, "FILE CORRUPTED. DISABLING GODEL");
return corruptedFile.delete();
} else {
Logger.d(TAG, fileName + " not found");
Log.d(TAG, fileName + " not found");
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import android.content.Context;
import android.util.Base64;
import android.util.Log;

import org.sunbird.analytics.Logger;
import org.sunbird.models.ApiResponse;

import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -123,15 +123,15 @@ private static byte[] downloadFileIfNotModified(Context context, String url, boo
}

} catch (Exception e) {
Logger.e(TAG, "Exception while checking digital signature of asset", e);
Log.e(TAG, "Exception while checking digital signature of asset", e);
} finally {
if (keyIn != null) keyIn.close();
}
} catch (OutOfMemoryError e) {
Logger.e(TAG, "Got Out of Memory Error", e);
Log.e(TAG, "Got Out of Memory Error", e);
response = null;
} catch (Exception e) {
Logger.e(TAG, "Exception while checking digital signature of asset", e);
Log.e(TAG, "Exception while checking digital signature of asset", e);
}
}
//Completes Handling ZIP files
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 0 additions & 46 deletions dui-demo/src/main/java/org/sunbird/analytics/Logger.java

This file was deleted.

12 changes: 0 additions & 12 deletions local.properties.example

This file was deleted.

1 change: 0 additions & 1 deletion mystique/.gitignore

This file was deleted.

Loading

0 comments on commit 08c393b

Please sign in to comment.