Bug Fixes

Bug Fixes
master
msmannan00 2021-04-25 02:26:22 +05:00
parent 0556f3e072
commit dce1daf69b
15 changed files with 367 additions and 88 deletions

View File

@ -97,6 +97,7 @@ dependencies {
implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0' implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
implementation 'com.google.firebase:firebase-messaging:21.1.0' implementation 'com.google.firebase:firebase-messaging:21.1.0'
implementation 'com.android.support:support-core-utils:28.0.0'
/* Default Libraries */ /* Default Libraries */

View File

@ -14,6 +14,7 @@
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" /> <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<application <application
android:requestLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"
@ -216,14 +217,15 @@
android:resource="@xml/provider_paths" /> android:resource="@xml/provider_paths" />
</provider> </provider>
<receiver <provider
android:name="org.torproject.android.proxy.StartTorReceiver" android:name="androidx.core.content.FileProvider"
android:exported="true" android:authorities="${applicationId}.fileprovider"
tools:ignore="ExportedReceiver"> android:exported="false"
<intent-filter> android:grantUriPermissions="true">
<action android:name="org.torproject.android.intent.action.START" /> <meta-data
</intent-filter> android:name="android.support.FILE_PROVIDER_PATHS"
</receiver> android:resource="@xml/file_path" />
</provider>
<service <service
android:name="org.torproject.android.proxy.OrbotService" android:name="org.torproject.android.proxy.OrbotService"
@ -235,6 +237,11 @@
</intent-filter> </intent-filter>
</service> </service>
<provider
android:authorities="com.darkweb.genesissearchengine.provider"
android:name="com.darkweb.genesissearchengine.clientauth.ClientAuthContentProvider"
android:exported="false"/>
</application> </application>
</manifest> </manifest>

View File

@ -1,5 +1,6 @@
package com.darkweb.genesissearchengine.appManager.historyManager; package com.darkweb.genesissearchengine.appManager.historyManager;
import android.os.Handler;
import android.widget.ImageView; import android.widget.ImageView;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;

View File

@ -760,7 +760,7 @@ public class geckoSession extends GeckoSession implements GeckoSession.MediaDele
PendingIntent pIntent = PendingIntent.getActivity(mContext.get().getApplicationContext(), 0, intent, 0); PendingIntent pIntent = PendingIntent.getActivity(mContext.get().getApplicationContext(), 0, intent, 0);
String channel_id = createNotificationChannel(mContext.get().getApplicationContext()); String channel_id = createNotificationChannel(mContext.get().getApplicationContext());
assert channel_id != null;
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mContext.get().getApplicationContext(), channel_id) NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mContext.get().getApplicationContext(), channel_id)
.setSmallIcon(R.drawable.ic_download) .setSmallIcon(R.drawable.ic_download)
.setContentTitle(filename) .setContentTitle(filename)

View File

@ -5,6 +5,7 @@ import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -22,7 +23,10 @@ import androidx.room.Ignore;
import com.darkweb.genesissearchengine.appManager.historyManager.historyRowModel; import com.darkweb.genesissearchengine.appManager.historyManager.historyRowModel;
import com.darkweb.genesissearchengine.appManager.tabManager.tabEnums; import com.darkweb.genesissearchengine.appManager.tabManager.tabEnums;
import com.darkweb.genesissearchengine.constants.enums; import com.darkweb.genesissearchengine.constants.enums;
import com.darkweb.genesissearchengine.constants.status;
import com.darkweb.genesissearchengine.constants.strings; import com.darkweb.genesissearchengine.constants.strings;
import com.darkweb.genesissearchengine.dataManager.dataController;
import com.darkweb.genesissearchengine.dataManager.dataEnums;
import com.darkweb.genesissearchengine.helperManager.eventObserver; import com.darkweb.genesissearchengine.helperManager.eventObserver;
import com.darkweb.genesissearchengine.helperManager.helperMethod; import com.darkweb.genesissearchengine.helperManager.helperMethod;
import com.example.myapplication.R; import com.example.myapplication.R;
@ -43,6 +47,10 @@ public class hintAdapter extends RecyclerView.Adapter<hintAdapter.listViewHolder
private AppCompatActivity mContext; private AppCompatActivity mContext;
private eventObserver.eventListener mEvent; private eventObserver.eventListener mEvent;
private Map<String, Drawable> mWebIcon = new HashMap<>(); private Map<String, Drawable> mWebIcon = new HashMap<>();
private ArrayList<String> mKeys = new ArrayList<>();
private Map<Integer,Handler> mHandlers = new HashMap<>();
private Map<Integer, Drawable> mPastWebIcon = new HashMap<>();
private Map<Integer, String> mPastIconFlicker = new HashMap<>();
public hintAdapter(ArrayList<historyRowModel> pHintList, eventObserver.eventListener pEvent, AppCompatActivity pContext, String pSearch) { public hintAdapter(ArrayList<historyRowModel> pHintList, eventObserver.eventListener pEvent, AppCompatActivity pContext, String pSearch) {
this.mHintList = new ArrayList(); this.mHintList = new ArrayList();
@ -62,7 +70,9 @@ public class hintAdapter extends RecyclerView.Adapter<hintAdapter.listViewHolder
} }
public void onClearAdapter(){ public void onClearAdapter(){
mWebIcon.clear(); // mHandlers.clear();
// mPastIconFlicker.clear();
// mWebIcon.clear();
} }
/*Initializations*/ /*Initializations*/
@ -131,13 +141,6 @@ public class hintAdapter extends RecyclerView.Adapter<hintAdapter.listViewHolder
mHindTypeIcon.setVisibility(View.GONE); mHindTypeIcon.setVisibility(View.GONE);
} }
if(mWebIcon.containsKey(mURLLink)){
mHintWebIcon.setColorFilter(null);
mHintWebIcon.clearColorFilter();
mHintWebIcon.setImageTintList(null);
mHintWebIcon.setClipToOutline(true);
}
mHeader.setText(model.getHeader()); mHeader.setText(model.getHeader());
if(model.getDescription().equals(strings.GENERIC_EMPTY_STR)){ if(model.getDescription().equals(strings.GENERIC_EMPTY_STR)){
mMoveURL.setTag(model.getHeader()); mMoveURL.setTag(model.getHeader());
@ -166,8 +169,33 @@ public class hintAdapter extends RecyclerView.Adapter<hintAdapter.listViewHolder
mpHintListener.setOnTouchListener(listViewHolder.this); mpHintListener.setOnTouchListener(listViewHolder.this);
String mURLPast = mURLLink;
mPastIconFlicker.put(getLayoutPosition(),mURLPast);
if(mWebIcon.containsKey(mURLLink)){ if(mWebIcon.containsKey(mURLLink)){
mHintWebIcon.setImageDrawable(mWebIcon.get(mURLLink)); mHintWebIcon.setColorFilter(null);
mHintWebIcon.clearColorFilter();
mHintWebIcon.setImageTintList(null);
mHintWebIcon.setClipToOutline(true);
mHintWebIcon.setImageDrawable(mPastWebIcon.get(getLayoutPosition()));
}else if(mHandlers.containsKey(getLayoutPosition())){
if(mPastWebIcon.containsKey(getLayoutPosition())){
mHintWebIcon.setColorFilter(null);
mHintWebIcon.clearColorFilter();
mHintWebIcon.setImageTintList(null);
mHintWebIcon.setClipToOutline(true);
mHintWebIcon.setImageDrawable(mPastWebIcon.get(getLayoutPosition()));
Log.i("FUSSSS1111","FUSSSS3333");
}else {
Resources res1 = itemView.getContext().getResources();
try {
mHintWebIcon.setImageDrawable(Drawable.createFromXml(res1, res1.getXml(R.xml.ic_baseline_browser)));
mPastWebIcon.put(getLayoutPosition(),mHintWebIcon.getDrawable());
} catch (Exception ignored) {
}
}
} }
if(!mWebIcon.containsKey(mURLLink)){ if(!mWebIcon.containsKey(mURLLink)){
@ -177,6 +205,7 @@ public class hintAdapter extends RecyclerView.Adapter<hintAdapter.listViewHolder
mHintWebIcon.setImageTintList(null); mHintWebIcon.setImageTintList(null);
mHintWebIcon.setClipToOutline(true); mHintWebIcon.setClipToOutline(true);
mHintWebIcon.setImageDrawable(itemView.getResources().getDrawable(R.drawable.genesis)); mHintWebIcon.setImageDrawable(itemView.getResources().getDrawable(R.drawable.genesis));
mPastWebIcon.put(getLayoutPosition(),mHintWebIcon.getDrawable());
}else }else
{ {
new Thread(){ new Thread(){
@ -187,10 +216,9 @@ public class hintAdapter extends RecyclerView.Adapter<hintAdapter.listViewHolder
while (true){ while (true){
int mCounter=0; int mCounter=0;
if(mHindTypeIconTemp.isAttachedToWindow() || mHindTypeIconTemp.getDrawable()==null){ if(mHindTypeIconTemp.isAttachedToWindow() || mHindTypeIconTemp.getDrawable()==null){
sleep(10); sleep(50);
mCounter+=1; mCounter+=1;
}else { }else {
Log.i("BREAK","");
break; break;
} }
if(mCounter>6){ if(mCounter>6){
@ -199,20 +227,51 @@ public class hintAdapter extends RecyclerView.Adapter<hintAdapter.listViewHolder
} }
mContext.runOnUiThread(() -> { mContext.runOnUiThread(() -> {
mWebIcon.put(mURLLink,mHindTypeIconTemp.getDrawable());
mKeys.add(mURLLink);
if(mKeys.size()>5){
mWebIcon.remove(mKeys.get(0));
mKeys.remove(0);
}
if(mHindTypeIconTemp.getDrawable() != null){
if(mHandlers.containsKey(getLayoutPosition())){
mHandlers.get(getLayoutPosition()).removeCallbacksAndMessages(null);
if(getLayoutPosition()==1){
Log.i("SUPERFUCK1","SUPERFUCK1");
}
}else {
mHandlers.put(getLayoutPosition(), new Handler());
}
if(mURLPast.equals(mPastIconFlicker.get(getLayoutPosition()))){
Runnable mRunnable = () -> {
mHintWebIcon.setColorFilter(null); mHintWebIcon.setColorFilter(null);
mHintWebIcon.clearColorFilter(); mHintWebIcon.clearColorFilter();
mHintWebIcon.setImageTintList(null); mHintWebIcon.setImageTintList(null);
mHintWebIcon.setClipToOutline(true); mHintWebIcon.setClipToOutline(true);
mWebIcon.put(mURLLink,mHindTypeIconTemp.getDrawable());
if(mHindTypeIconTemp.getDrawable() != null){
mHintWebIcon.setImageDrawable(mHindTypeIconTemp.getDrawable()); mHintWebIcon.setImageDrawable(mHindTypeIconTemp.getDrawable());
mPastWebIcon.put(getLayoutPosition(),mHindTypeIconTemp.getDrawable());
if(getLayoutPosition() == 1){
Log.i("FUSSSS1111","FUSSSS1111");
}
};
mHandlers.get(getLayoutPosition()).postDelayed(mRunnable, 200);
}
}else { }else {
if(mURLPast.equals(mPastIconFlicker.get(getLayoutPosition()))){
Resources res = itemView.getContext().getResources(); Resources res = itemView.getContext().getResources();
try { try {
Log.i("FUSSSS1111","FUSSSS2222");
mHintWebIcon.setImageDrawable(Drawable.createFromXml(res, res.getXml(R.xml.ic_baseline_browser))); mHintWebIcon.setImageDrawable(Drawable.createFromXml(res, res.getXml(R.xml.ic_baseline_browser)));
} catch (Exception ignored) { } catch (Exception ignored) {
} }
} }
}
}); });

View File

@ -108,7 +108,6 @@ import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessage
import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManagerCallbacks.M_RATE_APPLICATION; import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManagerCallbacks.M_RATE_APPLICATION;
import static java.lang.Character.isLetter; import static java.lang.Character.isLetter;
import static org.mozilla.geckoview.ContentBlocking.CookieBehavior.ACCEPT_FIRST_PARTY; import static org.mozilla.geckoview.ContentBlocking.CookieBehavior.ACCEPT_FIRST_PARTY;
import static org.torproject.android.proxy.TorServiceConstants.REQUEST_VPN;
public class homeController extends AppCompatActivity implements ComponentCallbacks2 public class homeController extends AppCompatActivity implements ComponentCallbacks2
{ {
@ -964,6 +963,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba
if ((scrollY >= (v.getChildAt(v.getChildCount() - 1).getMeasuredHeight() - v.getMeasuredHeight())) && scrollY > oldScrollY) { if ((scrollY >= (v.getChildAt(v.getChildCount() - 1).getMeasuredHeight() - v.getMeasuredHeight())) && scrollY > oldScrollY) {
} }
} }
onInvokePixelGenerator();
}); });
} }
@ -1323,6 +1323,8 @@ public class homeController extends AppCompatActivity implements ComponentCallba
mHomeViewController.onClearSelections(true); mHomeViewController.onClearSelections(true);
} }
pluginController.getInstance().onLanguageInvoke(Collections.singletonList(this), pluginEnums.eLangManager.M_RESUME); pluginController.getInstance().onLanguageInvoke(Collections.singletonList(this), pluginEnums.eLangManager.M_RESUME);
mHomeViewController.onClearSelections(true);
mHomeViewController.onUpdateSearchBar(mGeckoClient.getSession().getCurrentURL(),false,true, true);
} }
@Override @Override
@ -1383,6 +1385,10 @@ public class homeController extends AppCompatActivity implements ComponentCallba
} }
} }
if(status.sSettingIsAppStarted){
mHomeViewController.onClearSelections(isKeyboardOpened);
}
if(mAppBar!=null){ if(mAppBar!=null){
mHomeViewController.expandTopBar(); mHomeViewController.expandTopBar();
@ -2055,10 +2061,10 @@ public class homeController extends AppCompatActivity implements ComponentCallba
dataController.getInstance().invokeTab(dataEnums.eTabCommands.M_UPDATE_PIXEL, Arrays.asList(mGeckoClient.getSession().getSessionID(), mRenderedBitmap, null, mGeckoView, true)); dataController.getInstance().invokeTab(dataEnums.eTabCommands.M_UPDATE_PIXEL, Arrays.asList(mGeckoClient.getSession().getSessionID(), mRenderedBitmap, null, mGeckoView, true));
} }
} }
}, 150); }, 400);
}; };
mScrollHandler.postDelayed(mScrollRunnable, 250); mScrollHandler.postDelayed(mScrollRunnable, 450);
} }
public class geckoViewCallback implements eventObserver.eventListener{ public class geckoViewCallback implements eventObserver.eventListener{

View File

@ -0,0 +1,104 @@
package com.darkweb.genesissearchengine.clientauth;
import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.provider.BaseColumns;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class ClientAuthContentProvider extends ContentProvider {
public static final String[] PROJECTION = {
V3ClientAuth._ID,
V3ClientAuth.DOMAIN,
V3ClientAuth.HASH,
V3ClientAuth.ENABLED,
};
private static final String AUTH = "com.darkweb.genesissearchengine.clientauth.ClientAuthContentProvider";
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTH + "/v3auth");
private static final int V3AUTHS = 1, V3AUTH_ID = 2;
private static final UriMatcher uriMatcher;
static {
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
uriMatcher.addURI(AUTH, "v3auth", V3AUTHS);
uriMatcher.addURI(AUTH, "v3auth/#", V3AUTH_ID);
}
private ClientAuthDatabase mDatabase;
@Override
public boolean onCreate() {
mDatabase = new ClientAuthDatabase(getContext());
return true;
}
@Nullable
@Override
public String getType(@NonNull Uri uri) {
int match = uriMatcher.match(uri);
switch (match) {
case V3AUTHS:
return "vnd.android.cursor.dir/vnd.torproject.v3auths";
case V3AUTH_ID:
return "vnd.android.cursor.item/vnd.torproject.v3auth";
default:
return null;
}
}
@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
if (uriMatcher.match(uri) == V3AUTH_ID)
selection = "_id=" + uri.getLastPathSegment();
SQLiteDatabase db = mDatabase.getReadableDatabase();
return db.query(ClientAuthDatabase.DATABASE_NAME, projection, selection, selectionArgs, null, null, sortOrder);
}
@Nullable
@Override
public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
SQLiteDatabase db = mDatabase.getWritableDatabase();
long regId = db.insert(ClientAuthDatabase.DATABASE_NAME, null, values);
getContext().getContentResolver().notifyChange(CONTENT_URI, null);
return ContentUris.withAppendedId(CONTENT_URI, regId);
}
@Override
public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
if (uriMatcher.match(uri) == V3AUTH_ID)
selection = "_id=" + uri.getLastPathSegment();
SQLiteDatabase db = mDatabase.getWritableDatabase();
int rows = db.delete(ClientAuthDatabase.DATABASE_NAME, selection, selectionArgs);
getContext().getContentResolver().notifyChange(CONTENT_URI, null);
return rows;
}
@Override
public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
SQLiteDatabase db = mDatabase.getWritableDatabase();
if (uriMatcher.match(uri) == V3AUTH_ID)
selection = "id_=" + uri.getLastPathSegment();
int rows = db.update(ClientAuthDatabase.DATABASE_NAME, values, selection, null);
getContext().getContentResolver().notifyChange(CONTENT_URI, null);
return rows;
}
public static final class V3ClientAuth implements BaseColumns {
private V3ClientAuth() {
} // no-op
public static final String
DOMAIN = "domain",
HASH = "hash",
ENABLED = "enabled";
}
}

View File

@ -0,0 +1,30 @@
package com.darkweb.genesissearchengine.clientauth;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class ClientAuthDatabase extends SQLiteOpenHelper {
static final String DATABASE_NAME = "v3_client_auths";
private static final int DATABASE_VERSION = 1;
private static final String V3_AUTHS_CREATE_SQL =
"CREATE TABLE " + DATABASE_NAME + " (" +
"_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"domain TEXT, " +
"hash TEXT, " +
"enabled INTEGER DEFAULT 1);";
ClientAuthDatabase(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(V3_AUTHS_CREATE_SQL);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}

View File

@ -37,6 +37,9 @@ public class suggestionDataModel implements SpellCheckerSession.SpellCheckerSess
private ArrayList<historyRowModel> getDefaultSuggestionsOnStart(String pQuery, int mSize, ArrayList<String> mDuplicationHandler, boolean pDefaultHostChaned){ private ArrayList<historyRowModel> getDefaultSuggestionsOnStart(String pQuery, int mSize, ArrayList<String> mDuplicationHandler, boolean pDefaultHostChaned){
if(pQuery.equals(strings.GENERIC_EMPTY_STR)){
pQuery = "hidden web";
}
mCurrentList.clear(); mCurrentList.clear();
if(!pQuery.equals(strings.GENERIC_EMPTY_STR) && !pQuery.equals("about:blank") && !pQuery.contains("?") && !pQuery.contains("/") && !pQuery.contains(" ") && !pQuery.contains(" ") && !pQuery.contains("\n")){ if(!pQuery.equals(strings.GENERIC_EMPTY_STR) && !pQuery.equals("about:blank") && !pQuery.contains("?") && !pQuery.contains("/") && !pQuery.contains(" ") && !pQuery.contains(" ") && !pQuery.contains("\n")){
mCurrentList.size(); mCurrentList.size();

View File

@ -7,7 +7,7 @@ import ch.boye.httpclientandroidlib.HttpHost;
public class ProxySettings { public class ProxySettings {
private static final String TOR_PROXY_ADDRESS = "127.0.0.1"; private static final String TOR_PROXY_ADDRESS = "127.0.0.1";
private static final int TOR_PROXY_PORT = 1080; private static final int TOR_PROXY_PORT = 8118;
public static Proxy getProxy() { public static Proxy getProxy() {
// TODO make configurable // TODO make configurable

View File

@ -12,7 +12,7 @@ public class downloadNotification extends BroadcastReceiver {
int mCommand = intent.getExtras().getInt("N_COMMAND"); int mCommand = intent.getExtras().getInt("N_COMMAND");
if(mCommand==1){ if(mCommand==1){
pluginController.getInstance().onDownloadInvoke(Collections.singletonList(intent.getExtras().getInt("N_ID")), pluginEnums.eDownloadManager.M_TRIGGER); pluginController.getInstance().onDownloadInvoke(Collections.singletonList(intent.getExtras().getInt("N_ID")), pluginEnums.eDownloadManager.M_TRIGGER);
}else if(mCommand==0) { }else if(mCommand==0 || mCommand==2) {
pluginController.getInstance().onDownloadInvoke(Collections.singletonList(intent.getExtras().getInt("N_ID")), pluginEnums.eDownloadManager.M_CANCEL); pluginController.getInstance().onDownloadInvoke(Collections.singletonList(intent.getExtras().getInt("N_ID")), pluginEnums.eDownloadManager.M_CANCEL);
} }
} }

View File

@ -9,6 +9,7 @@ import android.content.ActivityNotFoundException;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -632,13 +633,17 @@ public class helperMethod
transitionDrawable.startTransition(duration); transitionDrawable.startTransition(duration);
} }
public static String getMimeType(String url) { public static String getMimeType(String url, Context pContext) {
String type = null; String mimeType;
String extension = MimeTypeMap.getFileExtensionFromUrl(url); Uri myUri = Uri.parse(url);
if (extension != null) { if (ContentResolver.SCHEME_CONTENT.equals(myUri.getScheme())) {
type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); ContentResolver cr = pContext.getContentResolver();
mimeType = cr.getType(myUri);
} else {
String fileExtension = MimeTypeMap.getFileExtensionFromUrl(myUri.toString());
mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension.toLowerCase());
} }
return type; return mimeType;
} }
public static void openFile(File url, Context context) { public static void openFile(File url, Context context) {
@ -650,9 +655,18 @@ public class helperMethod
intent.setDataAndType(uri, Uri.parse(url.toString()).getScheme()); intent.setDataAndType(uri, Uri.parse(url.toString()).getScheme());
context.startActivity(intent); context.startActivity(intent);
} catch (ActivityNotFoundException e) { } catch (ActivityNotFoundException e) {
try {
Uri uri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", url);
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(url.toString()));
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.fromFile(url), getMimeType(uri.toString(),context));
context.startActivity(intent);
} catch (ActivityNotFoundException ex) {
Toast.makeText(context, "No application found which can open the file", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "No application found which can open the file", Toast.LENGTH_SHORT).show();
} }
} }
}
public static void copyURL(String url,Context context){ public static void copyURL(String url,Context context){
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);

View File

@ -15,30 +15,34 @@ import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Environment; import android.os.Environment;
import android.os.Handler;
import android.os.StrictMode; import android.os.StrictMode;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.widget.Toast;
import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import com.darkweb.genesissearchengine.netcipher.client.StrongHttpsClient; import com.darkweb.genesissearchengine.netcipher.client.StrongHttpsClient;
import com.example.myapplication.R; import com.example.myapplication.R;
import org.mozilla.thirdparty.com.google.android.exoplayer2.util.Log; import org.mozilla.thirdparty.com.google.android.exoplayer2.util.Log;
import org.torproject.android.proxy.util.Prefs; import org.torproject.android.proxy.util.Prefs;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Proxy; import java.net.Proxy;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.net.URLEncoder; import java.text.DecimalFormat;
import ch.boye.httpclientandroidlib.HttpHost;
import ch.boye.httpclientandroidlib.HttpResponse; import ch.boye.httpclientandroidlib.HttpResponse;
import ch.boye.httpclientandroidlib.client.methods.HttpGet; import ch.boye.httpclientandroidlib.client.methods.HttpGet;
import ch.boye.httpclientandroidlib.conn.params.ConnRoutePNames;
import static java.lang.Thread.sleep; import static java.lang.Thread.sleep;
@ -50,6 +54,7 @@ public class localFileDownloader extends AsyncTask<String, Integer, String> {
private NotificationCompat.Builder build; private NotificationCompat.Builder build;
private OutputStream output; private OutputStream output;
private InputStream mStream; private InputStream mStream;
private Boolean mIsCanceled = false;
private String PROXY_ADDRESS = "localhost"; private String PROXY_ADDRESS = "localhost";
private int PROXY_PORT = 9050; private int PROXY_PORT = 9050;
@ -117,21 +122,39 @@ public class localFileDownloader extends AsyncTask<String, Integer, String> {
mNotifyManager.notify(mID, build.build()); mNotifyManager.notify(mID, build.build());
} }
public static String getFileSize(long size) {
if (size <= 0)
return "0";
final String[] units = new String[] { "B Downloaded", "KB ⇣", "MB ⇣", "GB ⇣", "TB ⇣" };
int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
}
@Override @Override
protected String doInBackground(String... f_url) { protected String doInBackground(String... f_url) {
int count; int count;
int mRequestCode = 0;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
try { try {
URL url = new URL(f_url[0]); URL url = new URL(f_url[0]);
Proxy proxy = new Proxy(Proxy.Type.SOCKS, InetSocketAddress.createUnresolved(PROXY_ADDRESS, PROXY_PORT)); HttpURLConnection conection;
URLConnection conection; Proxy proxy;
if(helperMethod.getDomainName(f_url[0]).contains(".onion")){
proxy = new Proxy(Proxy.Type.SOCKS, InetSocketAddress.createUnresolved(PROXY_ADDRESS, 9050));
conection = (HttpURLConnection) url.openConnection(proxy);
}else {
conection = (HttpURLConnection) ProxySelector.openConnectionWithProxy(new URI(f_url[0]));;
}
conection = url.openConnection(proxy); conection.setRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0");
//conection = (HttpsURLConnection)ProxySelector.openConnectionWithProxy(new URI(f_url[0])); conection.setRequestProperty("Accept","*/*");
conection.connect(); conection.connect();
int lenghtOfFile = conection.getContentLength(); int lenghtOfFile = conection.getContentLength();
mRequestCode = conection.getResponseCode();
mStream = conection.getInputStream(); mStream = conection.getInputStream();
// Output stream // Output stream
output = new FileOutputStream(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString()+"/"+mFileName)); output = new FileOutputStream(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString()+"/"+mFileName));
@ -143,7 +166,12 @@ public class localFileDownloader extends AsyncTask<String, Integer, String> {
while ((count = mStream.read(data)) != -1) { while ((count = mStream.read(data)) != -1) {
total += count; total += count;
int cur = (int) ((total * 100) / lenghtOfFile); int cur = (int) ((total * 100) / lenghtOfFile);
if(lenghtOfFile<0){
cur = (int)total;
mDownloadByte = cur * -1;
}else {
mDownloadByte = cur; mDownloadByte = cur;
}
publishProgress(Math.min(cur, 100)); publishProgress(Math.min(cur, 100));
if (Math.min(cur, 100) > 98) { if (Math.min(cur, 100) > 98) {
sleep(500); sleep(500);
@ -163,6 +191,10 @@ public class localFileDownloader extends AsyncTask<String, Integer, String> {
mStream.close(); mStream.close();
} catch (Exception ex) { } catch (Exception ex) {
Log.i("FIZZAHFUCK", ex.getMessage());
if(mRequestCode>300){
//Toast.makeText(context,"Request Forbidden Error Code : ",mRequestCode).show();
}
onCancel(); onCancel();
} }
}else { }else {
@ -172,7 +204,11 @@ public class localFileDownloader extends AsyncTask<String, Integer, String> {
StrongHttpsClient httpclient = new StrongHttpsClient(context); StrongHttpsClient httpclient = new StrongHttpsClient(context);
if(helperMethod.getDomainName(f_url[0]).contains(".onion")){
httpclient.useProxy(true, "SOCKS", "127.0.0.1", 9050); httpclient.useProxy(true, "SOCKS", "127.0.0.1", 9050);
}else {
httpclient.useProxy(true, "SOCKS", "127.0.0.1", 9050);
}
HttpGet httpget = new HttpGet(urlEncoded); HttpGet httpget = new HttpGet(urlEncoded);
HttpResponse response = httpclient.execute(httpget); HttpResponse response = httpclient.execute(httpget);
@ -182,17 +218,26 @@ public class localFileDownloader extends AsyncTask<String, Integer, String> {
InputStream mStream = response.getEntity().getContent(); InputStream mStream = response.getEntity().getContent();
mRequestCode = response.getStatusLine().getStatusCode();
output = new FileOutputStream(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString()+"/"+mFileName)); output = new FileOutputStream(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString()+"/"+mFileName));
byte[] data = new byte[100000]; byte[] data = new byte[100000];
long total = 0; long total = 0;
mTotalByte = response.getEntity().getContentLength(); float lenghtOfFile = response.getEntity().getContentLength();
mTotalByte = lenghtOfFile;
int read; int read;
while ((read = mStream.read(data)) != -1) { while ((read = mStream.read(data)) != -1) {
total += read; total += read;
int cur = (int) ((total * 100) / response.getEntity().getContentLength()); int cur = (int) ((total * 100) / response.getEntity().getContentLength());
mDownloadByte = cur; mDownloadByte = cur;
if(lenghtOfFile<0){
cur = (int)total;
mDownloadByte = total * -1;
}else {
mDownloadByte = cur;
}
publishProgress(Math.min(cur, 100)); publishProgress(Math.min(cur, 100));
if (Math.min(cur, 100) > 98) { if (Math.min(cur, 100) > 98) {
sleep(500); sleep(500);
@ -210,19 +255,24 @@ public class localFileDownloader extends AsyncTask<String, Integer, String> {
output.close(); output.close();
mStream.close(); mStream.close();
}catch (Exception ex){ }catch (Exception ex){
Log.d("sda", "dsa"); if(mRequestCode>300){
//Toast.makeText(context,"Request Forbidden Error Code : ",mRequestCode).show();
}
onCancel();
} }
} }
return null; return null;
} }
protected void onProgressUpdate(Integer... progress) { protected void onProgressUpdate(Integer... progress) {
build.setProgress(100, progress[0], false);
int mPercentage = (int)(mDownloadByte); int mPercentage = (int)(mDownloadByte);
if(mPercentage<0){ if(mPercentage<0){
mPercentage = 0; build.setProgress(100, progress[0], true);
} build.setContentText(getFileSize(mPercentage * -1));
}else {
build.setProgress(100, progress[0], false);
build.setContentText(mPercentage+"%"); build.setContentText(mPercentage+"%");
}
mNotifyManager.notify(mID, build.build()); mNotifyManager.notify(mID, build.build());
super.onProgressUpdate(progress); super.onProgressUpdate(progress);
} }
@ -230,19 +280,27 @@ public class localFileDownloader extends AsyncTask<String, Integer, String> {
@Override @Override
protected void onPostExecute(String file_url) { protected void onPostExecute(String file_url) {
Intent snoozeIntentPost = new Intent(context, downloadNotification.class); Intent snoozeIntentPost = new Intent(context, downloadNotification.class);
snoozeIntentPost.setAction("Download_Cancelled"); snoozeIntentPost.setAction("Download_Open");
snoozeIntentPost.putExtra("N_ID", mID); snoozeIntentPost.putExtra("N_ID", mID);
snoozeIntentPost.putExtra("N_COMMAND", 1); snoozeIntentPost.putExtra("N_COMMAND", 1);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, mID, snoozeIntentPost, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, mID, snoozeIntentPost, PendingIntent.FLAG_UPDATE_CURRENT);
Intent snoozeIntentPost1 = new Intent(context, downloadNotification.class);
snoozeIntentPost1.setAction("Download_Cancelled");
snoozeIntentPost1.putExtra("N_ID", mID);
snoozeIntentPost1.putExtra("N_COMMAND", 2);
PendingIntent pendingIntent1 = PendingIntent.getBroadcast(context, mID, snoozeIntentPost1, PendingIntent.FLAG_UPDATE_CURRENT);
build.addAction(0, null, null);
build.setContentIntent(pendingIntent); build.setContentIntent(pendingIntent);
build.addAction(android.R.drawable.stat_sys_download, "Open",pendingIntent);
build.setContentText("Download complete"); build.setContentText("Download complete");
build.setSmallIcon(R.xml.ic_check); build.setSmallIcon(R.xml.ic_check);
build.setColor(Color.parseColor("#84989f"));
build.setProgress(0, 0, false); build.setProgress(0, 0, false);
build.setAutoCancel(true); build.setAutoCancel(true);
build.setColor(Color.parseColor("#212d45"));
build.setOngoing(false); build.setOngoing(false);
build.addAction(android.R.drawable.stat_sys_download, "Open",pendingIntent);
build.addAction(R.drawable.ic_download, "Cancel",pendingIntent1);
build.setPriority(Notification.PRIORITY_LOW); build.setPriority(Notification.PRIORITY_LOW);
mNotifyManager.notify(mID, build.build()); mNotifyManager.notify(mID, build.build());
@ -258,7 +316,7 @@ public class localFileDownloader extends AsyncTask<String, Integer, String> {
contentValues.put(MediaStore.Downloads.TITLE, mFileName); contentValues.put(MediaStore.Downloads.TITLE, mFileName);
contentValues.put(MediaStore.Downloads.DISPLAY_NAME, mFileName); contentValues.put(MediaStore.Downloads.DISPLAY_NAME, mFileName);
contentValues.put(MediaStore.Downloads.SIZE, mDownloadByte); contentValues.put(MediaStore.Downloads.SIZE, mDownloadByte);
contentValues.put(MediaStore.Downloads.MIME_TYPE, helperMethod.getMimeType(uri.toString())); contentValues.put(MediaStore.Downloads.MIME_TYPE, helperMethod.getMimeType(uri.toString(), context));
contentValues.put(MediaStore.Downloads.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS + File.separator + "Temp"); contentValues.put(MediaStore.Downloads.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS + File.separator + "Temp");
@ -266,21 +324,28 @@ public class localFileDownloader extends AsyncTask<String, Integer, String> {
database.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, contentValues); database.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, contentValues);
} else { } else {
Uri uri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", mFile); Uri uri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", mFile);
dm.addCompletedDownload(mFileName, mURL, false, helperMethod.getMimeType(uri.toString()), mFile.getAbsolutePath(), mFile.length(), false); String mime = helperMethod.getMimeType(uri.toString(), context);
if(mime!=null){
dm.addCompletedDownload(mFileName, mURL, false, mime, mFile.getAbsolutePath(), mFile.length(), false);
}
} }
} }
public void onCancel(){ public void onCancel(){
mIsCanceled = true;
mNotifyManager.cancel(mID); mNotifyManager.cancel(mID);
cancel(true); cancel(true);
} }
public void onTrigger(){ public void onTrigger(){
if(!mIsCanceled){
mNotifyManager.cancel(mID); mNotifyManager.cancel(mID);
String mPath = (Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() + File.separator + mFileName).replace("File//","content://"); String mPath = (Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() + File.separator + mFileName).replace("File//","content://");
File mFile = new File(mPath); File mFile = new File(mPath);
helperMethod.openFile(mFile, context);
new Handler().postDelayed(() -> helperMethod.openFile(mFile, context), 500);
}
} }
} }

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_download" path="Download"/>
</paths>

View File

@ -73,8 +73,6 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.Reader;
import java.io.StringReader;
import java.net.Socket; import java.net.Socket;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -93,22 +91,21 @@ import java.util.concurrent.TimeoutException;
import IPtProxy.IPtProxy; import IPtProxy.IPtProxy;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static org.torproject.android.proxy.wrapper.orbotLocalConstants.mBridgesDefault;
public class OrbotService extends VpnService implements TorServiceConstants, OrbotConstants { public class OrbotService extends VpnService implements TorServiceConstants, OrbotConstants {
public final static String BINARY_TOR_VERSION = org.torproject.android.binary.TorServiceConstants.BINARY_TOR_VERSION; public final static String BINARY_TOR_VERSION = org.torproject.android.binary.TorServiceConstants.BINARY_TOR_VERSION;
static final int NOTIFY_ID = 11; static final int NOTIFY_ID = 1;
private final static int CONTROL_SOCKET_TIMEOUT = 60000; private final static int CONTROL_SOCKET_TIMEOUT = 60000;
private boolean mConnectivity = true; private boolean mConnectivity = true;
private static final int ERROR_NOTIFY_ID = 31; private static final int ERROR_NOTIFY_ID = 3;
private static final int HS_NOTIFY_ID = 41; private static final int HS_NOTIFY_ID = 4;
private Notification mNotification; private Notification mNotification;
private static final Uri V2_HS_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hiddenservices.providers/hs"); private static final Uri V2_HS_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hiddenservices.providers/hs");
private static final Uri V3_ONION_SERVICES_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.v3onionservice/v3"); private static final Uri V3_ONION_SERVICES_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.v3onionservice/v3");
private static final Uri COOKIE_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hiddenservices.providers.cookie/cookie"); private static final Uri COOKIE_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hiddenservices.providers.cookie/cookie");
private static final Uri V3_CLIENT_AUTH_URI = Uri.parse("content://org.torproject.android.ui.v3onionservice.clientauth/v3auth"); private static final Uri V3_CLIENT_AUTH_URI = Uri.parse("content://com.darkweb.genesissearchengine.clientauth.ClientAuthContentProvider/v3auth");
private final static String NOTIFICATION_CHANNEL_ID = "genesis_channel_1"; private final static String NOTIFICATION_CHANNEL_ID = "orbot_channel_1";
private static final String[] LEGACY_V2_ONION_SERVICE_PROJECTION = new String[]{ private static final String[] LEGACY_V2_ONION_SERVICE_PROJECTION = new String[]{
OnionService._ID, OnionService._ID,
OnionService.NAME, OnionService.NAME,
@ -237,9 +234,6 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
@RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O)
private void createNotificationChannel() { private void createNotificationChannel() {
if(1==1){
return;
}
if(orbotLocalConstants.mNotificationStatus==1) { if(orbotLocalConstants.mNotificationStatus==1) {
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
@ -258,9 +252,6 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
@SuppressLint({"NewApi", "RestrictedApi"}) @SuppressLint({"NewApi", "RestrictedApi"})
protected void showToolbarNotification(String notifyMsg, int notifyType, int icon) { protected void showToolbarNotification(String notifyMsg, int notifyType, int icon) {
if(1==1){
return;
}
//if(orbotLocalConstants.mNotificationStatus==1){ //if(orbotLocalConstants.mNotificationStatus==1){
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage(getPackageName()); Intent intent = pm.getLaunchIntentForPackage(getPackageName());
@ -981,12 +972,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
} }
protected void exec(Runnable runn) { protected void exec(Runnable runn) {
try { mExecutor.execute(runn);
new Thread(runn).start();
}catch (Exception ex){
ex.printStackTrace();
Log.i("","");
}
} }
private int exec(String cmd, boolean wait) throws Exception { private int exec(String cmd, boolean wait) throws Exception {
@ -1635,8 +1621,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
alBridges = new ArrayList<>(); alBridges = new ArrayList<>();
try { try {
Reader inputString = new StringReader(mBridgesDefault); BufferedReader in = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.bridges), "UTF-8"));
BufferedReader in = new BufferedReader(inputString);
String str; String str;
while ((str = in.readLine()) != null) { while ((str = in.readLine()) != null) {