Srisec
Great! Since it’s working now, let’s clean up the UI:
Remove the debug TextView and ScrollView
Replace progress bar + debug with a simple splash loading screen
Make the WebView fill the screen and look smooth
Add basic error handling UI inside WebView if loading fails
Here’s a polished version of your MainActivity.java with a splash screen loading and fullscreen WebView:
package com.ram.srisec;
import android.app.Activity; import android.os.Bundle; import android.os.AsyncTask; import android.webkit.WebView; import android.webkit.WebViewClient; import android.webkit.WebSettings; import android.view.ViewGroup; import android.view.Gravity; import android.widget.FrameLayout; import android.widget.ProgressBar; import android.graphics.Color; import android.widget.TextView; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.content.Context;
import java.io.File; import java.io.FileWriter; import java.io.IOException;
import org.eclipse.jgit.api.Git;
public class MainActivity extends Activity {
private static final String TAG = "MainActivity";
private static final String GIT_REMOTE_URL = "https://github.com/sriramreddydwarampudi/sriramreddydwarampudi.github.io";
private static final String GIT_LOCAL_FOLDER = "repo";
private WebView webView;
private ProgressBar progressBar;
private FrameLayout rootLayout;
private File gitRepoDir;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Root layout
rootLayout = new FrameLayout(this);
rootLayout.setBackgroundColor(Color.WHITE);
// ProgressBar - splash loader
progressBar = new ProgressBar(this);
FrameLayout.LayoutParams pbParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
);
pbParams.gravity = Gravity.CENTER;
progressBar.setLayoutParams(pbParams);
rootLayout.addView(progressBar);
// WebView setup
webView = new WebView(this);
FrameLayout.LayoutParams wvParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
);
webView.setLayoutParams(wvParams);
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setAllowContentAccess(true);
settings.setAllowFileAccess(true);
settings.setAllowFileAccessFromFileURLs(true);
settings.setAllowUniversalAccessFromFileURLs(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
// Hide loader once page loaded
progressBar.setVisibility(ProgressBar.GONE);
webView.setVisibility(WebView.VISIBLE);
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
// Show a friendly error message inside WebView
String errorHtml = "<html><body style='text-align:center; font-family:sans-serif;'>" +
"<h2>Oops! Unable to load page.</h2>" +
"<p>" + description + "</p></body></html>";
view.loadData(errorHtml, "text/html", "UTF-8");
}
});
webView.setVisibility(WebView.GONE); // Hide initially until loaded
rootLayout.addView(webView);
setContentView(rootLayout);
gitRepoDir = new File(getFilesDir(), GIT_LOCAL_FOLDER);
if (isConnected()) {
new GitSyncTask().execute();
} else {
// No internet: load local content immediately
loadSiteOrFallback();
}
}
private boolean isConnected() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm != null) {
NetworkInfo ni = cm.getActiveNetworkInfo();
return ni != null && ni.isConnected();
}
return false;
}
private void loadSiteOrFallback() {
File indexFile = new File(gitRepoDir, "index.html");
if (!indexFile.exists()) {
try {
FileWriter fw = new FileWriter(indexFile);
fw.write("<h1>Fallback: index.html not found</h1>");
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (indexFile.exists()) {
webView.loadUrl("file://" + indexFile.getAbsolutePath());
} else {
webView.loadData("<h1>Error: index.html not found</h1>", "text/html", "UTF-8");
}
}
private class GitSyncTask extends AsyncTask<Void, Void, Boolean> {
@Override
protected void onPreExecute() {
progressBar.setVisibility(ProgressBar.VISIBLE);
webView.setVisibility(WebView.GONE);
}
@Override
protected Boolean doInBackground(Void... voids) {
try {
if (gitRepoDir.exists()) {
Git.open(gitRepoDir).pull().call();
} else {
Git.cloneRepository()
.setURI(GIT_REMOTE_URL)
.setDirectory(gitRepoDir)
.call();
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
@Override
protected void onPostExecute(Boolean success) {
loadSiteOrFallback();
}
}
}
What this does:
Shows a centered spinner on a white background while cloning/pulling your repo.
WebView fills the entire screen, hidden behind the spinner initially.
Once the local index.html loads, the spinner disappears and WebView is shown.
Simple friendly HTML error message inside WebView if loading fails.
Clean, minimal UI — perfect as a splash/loading experience.
If you want, I can help with styling the splash further (custom image, animations, etc.). But this is a solid base for a clean, professional look.
Would you like that?
<uses-permission android:name="android.permission.INTERNET"/>
<application android:allowBackup="true"
android:usesCleartextTraffic="true"
android:label="SriSec"
android:theme="@android:style/Theme.Holo.Light.NoActionBar">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
📦 Required .jar Libraries
Place these in your AIDE libs/ folder:
-
org.eclipse.jgit.jar
-
slf4j-android.jar
-
javaewah.jar
add android manifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
activityxml
<!-- Add UI elements here -->
To include all .jar files from the libs/ folder in your Android project using build.gradle, here's what you need to do:
✅ Step-by-Step: Add .jar Dependencies from libs/
- Put Your JARs in libs/ Folder
Place your JAR (e.g., org.eclipse.jgit-6.0.0.jar) inside:
app/libs/
If the libs/ folder doesn’t exist, create it.
- Modify build.gradle
Open your app/build.gradle (module-level file), and make sure the following is added inside dependencies:
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) // other dependencies... }
This line tells Gradle to include all .jar files in the libs/ folder.
- Sync Gradle
In Android Studio:
Click “Sync Now” when prompted.
Or run: ./gradlew build
In AIDE:
This step is automatic if project.properties points to the correct libs/ folder.
- ✅ Verify Success
If the .jar file is correctly referenced, your IDE should resolve org.eclipse.jgit.* classes like:
import org.eclipse.jgit.api.Git;
Bonus: AIDE Users
If you're using AIDE, also check that project.properties includes:
android.library.reference.1=libs
Or just manually link the JAR from the Project Explorer (long press → "Add to Build Path").
Let me know if you also want to add .aar libraries, or convert to using Maven-style dependencies.