Skip to content

Commit

Permalink
🎨
Browse files Browse the repository at this point in the history
  • Loading branch information
ejaz4 committed Dec 31, 2021
1 parent 500e43a commit c20ee1f
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 49 deletions.
3 changes: 2 additions & 1 deletion .idea/misc.xml

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

3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.DotBrowser">
<activity
android:name=".subactivities.AddressBar"
android:exported="false" />
<activity
android:name=".WelcomeActivity"
android:exported="false" />
Expand Down
39 changes: 30 additions & 9 deletions app/src/main/java/co/dothq/browser/BrowserActivity.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package co.dothq.browser

import android.content.Context
import android.content.SharedPreferences
import android.graphics.Color
import android.os.Build
import android.app.Activity
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
import android.widget.LinearLayout
import android.widget.Toast
import androidx.activity.result.ActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import org.mozilla.geckoview.GeckoRuntime;
import org.mozilla.geckoview.GeckoSession;
import org.mozilla.geckoview.GeckoView;
import co.dothq.browser.PreferencesManager;
import co.dothq.browser.BrowserDelegates

import co.dothq.browser.managers.ApplicationManager
import co.dothq.browser.managers.PreferencesManager
import co.dothq.browser.managers.StorageManager
import co.dothq.browser.subactivities.AddressBar


class BrowserActivity : AppCompatActivity() {
Expand All @@ -37,9 +37,30 @@ class BrowserActivity : AppCompatActivity() {
val session = GeckoSession()
val runtime = GeckoRuntime.create(this)


session.open(runtime)
view.setSession(session)
session.navigationDelegate = BrowserDelegates().createNavigationDelegate("main", this, applicationContext);

val addressBar = findViewById<LinearLayout>(R.id.addressBarContainer);

addressBar.setOnClickListener {
val addressBarIntent = Intent(this, AddressBar::class.java);

addressBarIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

var launchAddressBar = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
val data: Intent? = result.data
if (data != null) {
session.loadUri(data.toString());
}
}
}

launchAddressBar.launch(addressBarIntent)
}

session.loadUri("https://ddg.gg")
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/co/dothq/browser/BrowserDelegates.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package co.dothq.browser
import android.app.Activity
import android.content.Context
import android.widget.TextView
import co.dothq.browser.managers.StorageManager
import org.mozilla.geckoview.AllowOrDeny
import org.mozilla.geckoview.GeckoResult
import org.mozilla.geckoview.GeckoSession
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/java/co/dothq/browser/ExtensionManager.kt

This file was deleted.

5 changes: 3 additions & 2 deletions app/src/main/java/co/dothq/browser/WelcomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package co.dothq.browser
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.LinearLayout
import android.widget.TextView
import co.dothq.browser.managers.StorageManager
import co.dothq.browser.util.defaultProfile
import java.util.*

Expand All @@ -25,8 +25,9 @@ class WelcomeActivity : AppCompatActivity() {
defaultProfile().applyDefaultPreferences(applicationContext);
StorageManager().set(applicationContext, "setup", true, "appValues");
val browserIntent = Intent(this, BrowserActivity::class.java);
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(browserIntent)
overridePendingTransition(0, 0);
this.finish()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
package co.dothq.browser
package co.dothq.browser.managers

import android.content.Context
import android.content.Intent
import android.util.Log
import android.widget.Toast
import androidx.core.content.ContextCompat.startActivity
import co.dothq.browser.util.defaultProfile
import android.app.Activity


import co.dothq.browser.WelcomeActivity


class ApplicationManager {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package co.dothq.browser.managers

class ExtensionManager {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package co.dothq.browser
package co.dothq.browser.managers

import android.content.Context
import co.dothq.browser.managers.StorageManager

fun pref(id: String, value: Any, context: Context) {
PreferencesManager().set(context, id, value)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package co.dothq.browser
package co.dothq.browser.managers

import android.app.Application
import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package co.dothq.browser
package co.dothq.browser.managers

import android.R.attr
import android.content.Context
import android.util.Log
import android.R.attr.button


import co.dothq.browser.managers.PreferencesManager;


class ThemeManager {
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/co/dothq/browser/subactivities/AddressBar.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package co.dothq.browser.subactivities

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import co.dothq.browser.R

class AddressBar : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_address_bar)
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/co/dothq/browser/util/defaultProfile.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package co.dothq.browser.util

import android.content.Context
import co.dothq.browser.pref
import co.dothq.browser.managers.pref

class defaultProfile {
fun applyDefaultPreferences(context: Context) {
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/layout/activity_address_bar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".subactivities.AddressBar">

</androidx.constraintlayout.widget.ConstraintLayout>
20 changes: 5 additions & 15 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,24 @@
android:paddingBottom="6dp">

<LinearLayout
android:id="@+id/addressBarContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/input_layout_normal"
android:orientation="horizontal">

<TextView
android:id="@+id/addressBarUri"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:lines="1"
android:text="hostname/"
android:textColor="?colorSecondary"
android:visibility="visible"
app:autoSizeTextType="none"
/>

<TextView
android:id="@+id/addressBarPath"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:lines="1"
android:text="hostname/"
android:textAlignment="inherit"
android:textAlignment="viewStart"
android:textColor="?colorSecondary"
android:visibility="visible" />

</LinearLayout>
</LinearLayout>

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_welcome.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
android:foregroundGravity="bottom"
android:gravity="center"
android:orientation="vertical"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="1dp">
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="-60dp">

<TextView
android:id="@+id/textView"
Expand All @@ -38,7 +38,7 @@
android:text="The privacy-centric, modern web browser that fights for your privacy when browsing the internet."
android:textAlignment="center"
android:textColor="?colorSecondary"
android:textSize="16sp" />
android:textSize="14sp" />

<LinearLayout
android:id="@+id/startButton"
Expand Down

0 comments on commit c20ee1f

Please sign in to comment.