Skip to content

Commit

Permalink
Fixed Android 4.4 compatibility and updated TOS popup
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehasawii committed Apr 16, 2023
1 parent 80bb334 commit 9125a56
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 177 deletions.
54 changes: 44 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,61 @@ android {

defaultConfig {
applicationId "com.txtnet.txtnetbrowser"
minSdk 19
//minSdk 19
targetSdk 33
versionCode 4
versionName "2.0.2"
versionCode 210
versionName "2.1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.debug
//vectorDrawables.useSupportLibrary = true

javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}

}
flavorDimensions "version"
productFlavors {
dev {
// Enable pre-dexing to produce an APK that can be tested on
// Android 5.0+ without the time-consuming DEX build processes.
//noinspection DevModeObsolete
minSdkVersion 21
dimension "version"
// applicationIdSuffix ".demo"
// versionNameSuffix "-demo"

}
prod {
// The actual minSdkVersion for the production version.
minSdkVersion 19
dimension "version"
buildTypes{
debug{
multiDexEnabled true // We are able to avoid multidex in release builds due to resource shrinking and minifying.
dependencies {
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
}
}
}
}
}
buildTypes {
release {
//minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
minifyEnabled true
shrinkResources true
}
debug {
//multiDexEnabled true // We are able to avoid multidex in release builds due to resource shrinking and minifying.
defaultConfig.minSdkVersion 21 // Allows android to automatically handle dex management with ART
defaultConfig.vectorDrawables.useSupportLibrary = true
defaultConfig.multiDexEnabled = true
}
// debug {
// //multiDexEnabled true // We are able to avoid multidex in release builds due to resource shrinking and minifying.
// //defaultConfig.minSdkVersion 21 // Allows android to automatically handle dex management with ART
// defaultConfig.multiDexEnabled = true
// }
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -115,6 +142,13 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-livedata:2.6.1"
implementation "androidx.lifecycle:lifecycle-common-java8:2.6.1"


constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}

}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- <uses-permission
android:name="android.permission.WRITE_SETTINGS"
tools:ignore="ProtectedPermissions" /> Even though it says only system apps can get this permission, that isn't true. -->
<!-- TODO: We may not need WRITE_SETTINGS since we already have WRITE_SECURE_SETTINGS -->
<!-- It turns out, we do not need WRITE_SETTINGS since we already have WRITE_SECURE_SETTINGS -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<application
Expand Down
35 changes: 23 additions & 12 deletions app/src/main/assets/welcome.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
<h1 id="welcome-to-txtnet-browser">Welcome to TxtNet Browser!</h1>
<p>With this app, you can view web pages and submit web forms without an internet connection.<br>
To begin, enter a URL in the above address bar and press the magnifying glass icon or enter button to proceed.</p>
<h1 id="options">Options</h1>
<p>The options section of this app houses 2 major functions. Primarily, you can delete message history with the server once a large amount of web data has been stored. Secondly, you can choose to block incoming message notifications from the server to improve your experience with the app. We recommend that first-time users block the number that they wish to use in the app. To accomplish this, press the three dots in the top right of your screen and choose “Options.”</p>
<p><strong>IMPORTANT: In order to Block, Unblock, or Delete Message History, Android requires that this app be registered as the default SMS app beginning with Android 4.4. To accomplish this, choose “Set Default SMS” in Options. When you are done, press the button again to revert to your previous Messaging app.</strong></p>
<p>Or, select a link from the list below.</p>

<h2 id="quick-links">Quick Links</h2>
<p>Below is a list of links that will be useful to you in your web browsing experience.</p>

Expand All @@ -47,19 +46,19 @@ <h2 id="quick-links">Quick Links</h2>
<td><a href="http://lite.cnn.com">http://lite.cnn.com</a></td>
<td>The official text-only page of CNN.</td>
</tr>
<!-- <tr>-->
<!-- <td><a href="https://www.google.com">http://wap.google.com/wml/</a></td>-->
<!-- &lt;!&ndash; EDIT: As of 9/2022, this page directs towards the regular Google site due to support for wap dropped by Google. The original link was confirmed working on 4/2022. Unsure if support will be added back in the future. &ndash;&gt;-->
<!-- <td>A basic version of the Google homepage.</td>-->
<!-- </tr>-->
<!-- <tr>-->
<!-- <td><a href="https://www.google.com">http://wap.google.com/wml/</a></td>-->
<!-- &lt;!&ndash; EDIT: As of 9/2022, this page directs towards the regular Google site due to support for wap dropped by Google. The original link was confirmed working on 4/2022. Unsure if support will be added back in the future. &ndash;&gt;-->
<!-- <td>A basic version of the Google homepage.</td>-->
<!-- </tr>-->
<tr>
<td><a href="http://decapi.me/twitter/latest?name=USER_HERE">http://decapi.me/twitter/latest?name=USER_HERE</a></td>
<td>Displays the latest Tweet for any user you specify by replacing “USER_HERE”.</td>
</tr>
<!-- <tr>-->
<!-- <td><a href="https://www.reddit.com/.mobile?keep_extension=True">https://www.reddit.com/.mobile?keep_extension=True</a></td>-->
<!-- <td>The front page of Reddit.com</td>-->
<!-- </tr>-->
<!-- <tr>-->
<!-- <td><a href="https://www.reddit.com/.mobile?keep_extension=True">https://www.reddit.com/.mobile?keep_extension=True</a></td>-->
<!-- <td>The front page of Reddit.com</td>-->
<!-- </tr>-->
<tr>
<td><a href="https://teddit.net/">https://teddit.net/</a></td>
<td>The front page of Reddit.com</td>
Expand Down Expand Up @@ -102,4 +101,16 @@ <h2 id="quick-links">Quick Links</h2>
</tr>
</tbody>
</table>

<h1>Other App Features:</h1>
<h2 id="options">Options</h2>
<p>The options section of this app houses 2 major functions. Primarily, you can delete message history with the server once a large amount of web data has been stored. Secondly, you can choose to block incoming message notifications from the server to improve your experience with the app. We recommend that first-time users block the number that they wish to use in the app. To accomplish this, press the three dots in the top right of your screen and choose “Options.”</p>
<p><strong>IMPORTANT: In order to Block, Unblock, or Delete Message History, Android requires that this app be registered as the default SMS app beginning with Android 4.4. To accomplish this, choose “Set Default SMS” in Options. When you are done, press the button again to revert to your previous Messaging app.</strong></p>

<h2 id="selectPhoneNum">Select Server Phone Number</h2>
<p>The server phone number selection screen can be found from the overflow menu (3 dots) to the right of the search bar. In this menu, you can add new server phone numbers by pressing on the plus (+) icon, select a default phone number by tapping it, and delete a phone number by swiping left on the number's cell and selecting "Delete".</p>

<h2 id="serverHost">TxtNet Server Hosting</h2>
<p>TxtNet Browser empowers users to utilize their own Wi-Fi or Cellular Data connection to act as a server to other users who can connect to you through the phone number associated with your default SIM. To enable this functionality, users on Android 4.4-10 must run two adb commands once by connecting their phone to a computer over USB. On Android 11+, users may opt instead to install the Shizuku app through the Google Play store. The "Number of Webviews" refers to the amount of concurrent web requests allowed from multiple users. "Max outgoing SMS per request" specifies how many SMS messages are allowed to be sent resulting from a single web page request. A website with lots of text can exceed this limit, in which case a failure message will be sent instead.</p>

</body>
17 changes: 10 additions & 7 deletions app/src/main/java/com/txtnet/txtnetbrowser/MainBrowserScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.app.ActivityCompat;
Expand Down Expand Up @@ -76,9 +77,9 @@ public class MainBrowserScreen extends AppCompatActivity {
* TODO: Add database query view depending on country code, by contacting a master list number to return a list of known active server phone numbers for the country code
* TODO: In phone number selector, make a FrameLayout with the textview, ping button, and checkmark icon (maybe the checkmark or x icon pushes the textview to the right?)
*
* TODO Before beta launch:
* - Add a CDMA network compatibility mode to remove all Greek symbols. How to communicate this?
* -- make a database of CDMA-only numbers and use an initial request text: "TxtNet vXXX charset basic"/"TxtNet vXXX charset full"
* TODO: Add a CDMA network compatibility mode to remove all Greek symbols.
* Q: How to communicate this?
* A: make a database of CDMA-only numbers and use an initial request text: "TxtNet vXXX charset basic"/"TxtNet vXXX charset full"
*
*/

Expand Down Expand Up @@ -108,17 +109,21 @@ void showIntroActivity() {

}

static {
if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.KITKAT) {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
}

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


// if (savedInstanceState == null) { TODO: See if we should replace this null check?

preferences = getSharedPreferences(getPackageName() + "_preferences", MODE_PRIVATE);
mContext = this;


boolean isAccessed = preferences.getBoolean(getString(R.string.is_accessed), false);
if (!isAccessed) {
SharedPreferences.Editor edit = preferences.edit();
Expand All @@ -128,7 +133,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
return;
}


setContentView(R.layout.activity_main);

//Instantiate database
Expand Down Expand Up @@ -159,7 +163,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
ActivityCompat.finishAffinity(MainBrowserScreen.this);
}


boolean isTosAccepted = preferences.getBoolean(getString(R.string.is_tosaccepted), false);
if (!isTosAccepted) {
TermsConditionsDialogFragment dialogFragment = new TermsConditionsDialogFragment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import com.txtnet.txtnetbrowser.R;

public class MyWebView extends WebView {
//private static final String TAG = "CosmosWebView";


private static final String TAG = "MyWebView";

private WebViewClient webViewClient;

Expand Down
127 changes: 66 additions & 61 deletions app/src/main/res/layout/unsupported_block.xml
Original file line number Diff line number Diff line change
@@ -1,71 +1,76 @@
<?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"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imageView"
android:layout_width="206dp"
android:layout_height="210dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline4"
app:srcCompat="@drawable/ic_baseline_error_24" />
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="30dp"
android:paddingEnd="30dp"
android:text="Sorry, but your device is not compatible with blocking numbers automatically. (Requires Android 7+)"
android:textAlignment="center"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imageView"
android:layout_width="206dp"
android:layout_height="210dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline4"
app:srcCompat="@drawable/ic_baseline_error_24" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.25" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="30dp"
android:paddingEnd="30dp"
android:text="Sorry, but your device is not compatible with blocking numbers automatically. (Requires Android 7+)"
android:textAlignment="center"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.19" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.25" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="30dp"
android:paddingEnd="30dp"
android:text="To hide notifications, open your phone's settings and find notification settings for your default SMS app. "
android:textAlignment="center"
android:textSize="32sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.19" />

/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="30dp"
android:paddingEnd="30dp"
android:text="To hide notifications, open your phone's settings and find notification settings for your default SMS app. "
android:textAlignment="center"
android:textSize="32sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"

<Button
android:id="@+id/revertSMSbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Revert Default SMS App"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3"
android:textSize="20dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
/>

<Button
android:id="@+id/revertSMSbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Revert Default SMS App"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3"
android:textSize="20dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Loading

0 comments on commit 9125a56

Please sign in to comment.