Skip to content

Commit

Permalink
さよならCPUSpeed
Browse files Browse the repository at this point in the history
応援してくれてありがとうございました。
  • Loading branch information
HenryQuan committed Jun 16, 2020
1 parent 4d83a89 commit e4d18ae
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 145 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ logo/AppIcon
/build
/captures
.externalNativeBuild
*.zip
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CPU Speed
# CPU Speed (Deprecated)
Set cpu speed easily for rooted android phones.

I am changing to Samsung A70 soon and I will sell my OnePlus 5 after this app is completed.
**I changed to Samsung A70 and flushed official rom to OnePLus 5 so I don't have any rooted devices anymore. Therefore, this app is no longer under development.** Back then, I saw an app that costed 1 dollar just to update your cpu speed. That's why I wrote this app because it should be free.

## Motivation
This is my first ever native Android app written in Java. I am using React Native a lot and learning Flutter recently. Is native development gonna die? I don't think so. React Native and Flutter are sure great and faster. However, you need to know native. Otherwise, what's different from a website (web app) if you only want to cross multiple platforms? I should do more and know more about native development as well. Time to slow down. What makes IOS IOS and what makes Android Android? What is an app?
Expand Down
23 changes: 11 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
compileSdkVersion 30
defaultConfig {
applicationId "com.yihengquan.cpuspeed"
minSdkVersion 16
targetSdkVersion 28
versionCode 1050
versionName "1.0.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
targetSdkVersion 30
versionCode 1070
versionName "1.0.7"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
Expand All @@ -20,12 +20,11 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0' // Required Dependency by Audience Network SDK
implementation 'com.facebook.android:audience-network-sdk:5.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.yihengquan.cpuspeed;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package="com.yihengquan.cpuspeed">

<application
android:name=".CPUSpeed"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
Expand Down
14 changes: 0 additions & 14 deletions app/src/main/java/com/yihengquan/cpuspeed/CPUSpeed.java

This file was deleted.

104 changes: 9 additions & 95 deletions app/src/main/java/com/yihengquan/cpuspeed/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
package com.yihengquan.cpuspeed;

import android.app.Application;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.Uri;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import androidx.appcompat.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;

import com.facebook.ads.*;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
Expand All @@ -40,10 +36,8 @@ public class MainActivity extends AppCompatActivity {
private int currMaxFreq = 0;
private int currMinFreq = 0;

private final String appVersion = "1.0.5";
private final String appVersion = "1.0.7";

// banner
private AdView banner;
private Menu menu;

@Override
Expand All @@ -57,17 +51,11 @@ public boolean onCreateOptionsMenu(Menu menu) {
m.inflate(R.menu.menu_main, menu);
this.menu = menu;

// Set ads state
boolean showAds = getAds();
MenuItem ads = this.menu.findItem(R.id.menu_ads);
ads.setChecked(showAds);

return true;
}

@Override
protected void onDestroy() {
if (banner != null) banner.destroy();
super.onDestroy();
}

Expand Down Expand Up @@ -205,14 +193,6 @@ public void onStopTrackingTouch(SeekBar seekBar) { }
Toast.makeText(this, "Please contact me for more info", Toast.LENGTH_LONG).show();
}
}

// Setup banner
if (getAds()) {
banner = new AdView(this, "889645368038871_889649694705105", AdSize.BANNER_HEIGHT_50);
banner.loadAd();
LinearLayout adBanner = findViewById(R.id.ads_banner);
adBanner.addView(banner);
}
}

/**
Expand All @@ -222,7 +202,7 @@ public void onStopTrackingTouch(SeekBar seekBar) { }
public void showAbout(MenuItem item) {
new AlertDialog.Builder(this)
.setTitle("CPUSpeed")
.setMessage("It aims to help you set CPUSpeed easily for rooted android devices. Please visit my Github repository for more info and support me on Patreon.")
.setMessage("It aims to help you set CPUSpeed easily for rooted android devices. Please visit my Github repository for more info.")

// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
Expand Down Expand Up @@ -257,68 +237,10 @@ public void shareApp(MenuItem item) {
* Show or hide ads
* @param item
*/
public void toggleAds(MenuItem item) {
MenuItem ads = this.menu.findItem(R.id.menu_ads);
boolean newState = !ads.isChecked();
ads.setChecked(newState);
this.setAds(newState);
}

/**
* Get current state of ads
* @return whether show or hide ads
*/
private boolean getAds() {
SharedPreferences pref = getSharedPreferences("CPUSpeed", MODE_PRIVATE);
boolean ADS = pref.getBoolean("ADS", true);
return ADS;
}

/**
* Set state for ads
* @param state true of false
*/
private void setAds(final Boolean state) {
SharedPreferences pref = getSharedPreferences("CPUSpeed", MODE_PRIVATE);
final SharedPreferences.Editor editor = pref.edit();
if (!state) {
final MenuItem ads = this.menu.findItem(R.id.menu_ads);
new AlertDialog.Builder(this)
.setTitle("CPUSpeed")
.setMessage("Do you want to keep supporting CPUSpeed with ads?")
.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// update state
editor.putBoolean("ADS", true);
editor.apply();
ads.setChecked(true);
}
})
.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// update state
editor.putBoolean("ADS", state);
editor.apply();
ads.setChecked(state);
finish();
startActivity(getIntent());
}
})
.setCancelable(false)
.show();
} else {
// update state
editor.putBoolean("ADS", state);
editor.apply();

finish();
startActivity(getIntent());
}
public void downloadKernelEditor(MenuItem item) {
openLink("https://github.com/HenryQuan/CPUSpeed/blob/master/Privacy%20Policy.md");
}


/**
* Email me with feed back
* @param item
Expand All @@ -327,14 +249,6 @@ public void emailMe(MenuItem item) {
this.openLink(String.format("mailto:[email protected]?subject=[CPUSpeed %s] ", appVersion));
}

/**
* Visit my patreon page
* @param item
*/
public void gotoPatreon(MenuItem item) {
this.openLink("https://www.patreon.com/henryquan");
}

/**
* Open certain links
* @param url
Expand All @@ -359,7 +273,7 @@ private boolean showWelcomeDialog() {
if (first) {
new AlertDialog.Builder(this)
.setTitle("CPUSpeed")
.setMessage("Thank you for downloading this app.\n\nPlease note that if you underclock your device, it might freeze or even shutdown in the worst case. If you overclock your device, it might become warm and battery will run out quickly.")
.setMessage("Thank you for downloading this app.\n\nPlease note that if you under clock your device, it might freeze or even shutdown in the worst case. If you overclock your device, it might become warm and battery will run out quickly.\n\nThis app might not work on your device. In this case, you can use other apps.")

// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
Expand All @@ -385,7 +299,7 @@ private void showWhatsNewDialog() {
if (whatsnew) {
new AlertDialog.Builder(this)
.setTitle(String.format("Version %s", appVersion))
.setMessage("- Added Privacy Policy")
.setMessage("Thank you for 25k downloads. This app was written because other apps weren't working for me and paid.\nNow, I do not have any rooted devices and this app will not be developed anymore unless I need it again. Thank you for all your support and all your suggestions.\n- Updated to androidx\n- Removed ads")

// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_height="match_parent"
tools:context=".MainActivity">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -73,13 +73,12 @@


<LinearLayout
android:id="@+id/ads_banner"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/updateBtn"
android:onClick="setSpeed"
android:layout_width="wrap_content"
Expand Down
15 changes: 2 additions & 13 deletions app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:id="@+id/menu_ads"
android:title="Support CPUSpeed"
android:checkable="true"
android:checked="true"
android:onClick="toggleAds"/>

<item
android:id="@+id/menu_support"
android:title="Patreon"
android:onClick="gotoPatreon"/>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:id="@+id/menu_feedback"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:4.0.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 21 21:36:47 AEST 2019
#Tue Jun 16 14:50:39 AEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

0 comments on commit e4d18ae

Please sign in to comment.