From 521bee0f7fe20a1a607fa014040f4820fc4d2c9f Mon Sep 17 00:00:00 2001 From: Rick Date: Sun, 5 Feb 2023 15:07:51 -0800 Subject: [PATCH] First commit --- .gitignore | 15 ++ .idea/.gitignore | 3 + .idea/compiler.xml | 6 + .idea/gradle.xml | 20 ++ .idea/misc.xml | 10 + app/.gitignore | 1 + app/build.gradle | 48 +++++ app/proguard-rules.pro | 21 ++ .../indexthis/ExampleInstrumentedTest.java | 26 +++ app/src/main/AndroidManifest.xml | 30 +++ .../com/example/indexthis/MainActivity.java | 57 +++++ .../indexthis/ui/home/HomeFragment.java | 202 ++++++++++++++++++ .../indexthis/ui/home/HomeViewModel.java | 19 ++ .../indexthis/ui/options/OptionsFragment.java | 125 +++++++++++ .../ui/options/OptionsViewModel.java | 19 ++ .../drawable-v24/ic_launcher_foreground.xml | 30 +++ .../res/drawable/ic_dashboard_black_24dp.xml | 9 + .../main/res/drawable/ic_home_black_24dp.xml | 9 + .../res/drawable/ic_launcher_background.xml | 170 +++++++++++++++ .../drawable/ic_notifications_black_24dp.xml | 9 + app/src/main/res/layout/activity_main.xml | 33 +++ app/src/main/res/layout/fragment_home.xml | 89 ++++++++ app/src/main/res/layout/fragment_options.xml | 86 ++++++++ app/src/main/res/menu/bottom_nav_menu.xml | 14 ++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + .../res/mipmap-anydpi-v33/ic_launcher.xml | 6 + app/src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes app/src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes .../main/res/navigation/mobile_navigation.xml | 20 ++ app/src/main/res/values-night/themes.xml | 16 ++ app/src/main/res/values/colors.xml | 10 + app/src/main/res/values/dimens.xml | 5 + app/src/main/res/values/strings.xml | 7 + app/src/main/res/values/themes.xml | 16 ++ app/src/main/res/xml/backup_rules.xml | 13 ++ .../main/res/xml/data_extraction_rules.xml | 19 ++ .../example/indexthis/ExampleUnitTest.java | 17 ++ build.gradle | 5 + gradle.properties | 21 ++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59203 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 185 ++++++++++++++++ gradlew.bat | 89 ++++++++ settings.gradle | 16 ++ 53 files changed, 1512 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/misc.xml create mode 100644 app/.gitignore create mode 100644 app/build.gradle create mode 100644 app/proguard-rules.pro create mode 100644 app/src/androidTest/java/com/example/indexthis/ExampleInstrumentedTest.java create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/java/com/example/indexthis/MainActivity.java create mode 100644 app/src/main/java/com/example/indexthis/ui/home/HomeFragment.java create mode 100644 app/src/main/java/com/example/indexthis/ui/home/HomeViewModel.java create mode 100644 app/src/main/java/com/example/indexthis/ui/options/OptionsFragment.java create mode 100644 app/src/main/java/com/example/indexthis/ui/options/OptionsViewModel.java create mode 100644 app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 app/src/main/res/drawable/ic_dashboard_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_home_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/src/main/res/drawable/ic_notifications_black_24dp.xml create mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/layout/fragment_home.xml create mode 100644 app/src/main/res/layout/fragment_options.xml create mode 100644 app/src/main/res/menu/bottom_nav_menu.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/navigation/mobile_navigation.xml create mode 100644 app/src/main/res/values-night/themes.xml create mode 100644 app/src/main/res/values/colors.xml create mode 100644 app/src/main/res/values/dimens.xml create mode 100644 app/src/main/res/values/strings.xml create mode 100644 app/src/main/res/values/themes.xml create mode 100644 app/src/main/res/xml/backup_rules.xml create mode 100644 app/src/main/res/xml/data_extraction_rules.xml create mode 100644 app/src/test/java/com/example/indexthis/ExampleUnitTest.java create mode 100644 build.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..a0de2a1 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..54d5acd --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..c67b314 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,48 @@ +plugins { + id 'com.android.application' +} + +android { + namespace 'com.example.indexthis' + compileSdk 33 + + defaultConfig { + applicationId "com.example.indexthis" + minSdk 26 + targetSdk 33 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + buildFeatures { + viewBinding true + } +} + +dependencies { + + implementation 'androidx.appcompat:appcompat:1.4.1' + implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1' + implementation 'androidx.navigation:navigation-fragment:2.4.1' + implementation 'androidx.navigation:navigation-ui:2.4.1' + implementation 'com.squareup.okhttp3:okhttp:3.0.1' + implementation 'io.github.rburgst:okhttp-digest:2.5' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/example/indexthis/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/indexthis/ExampleInstrumentedTest.java new file mode 100644 index 0000000..ab01231 --- /dev/null +++ b/app/src/androidTest/java/com/example/indexthis/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.indexthis; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.example.indexthis", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c7b1ea4 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/indexthis/MainActivity.java b/app/src/main/java/com/example/indexthis/MainActivity.java new file mode 100644 index 0000000..ab534ab --- /dev/null +++ b/app/src/main/java/com/example/indexthis/MainActivity.java @@ -0,0 +1,57 @@ +package com.example.indexthis; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; + +import com.google.android.material.bottomnavigation.BottomNavigationView; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.navigation.NavController; +import androidx.navigation.Navigation; +import androidx.navigation.ui.AppBarConfiguration; +import androidx.navigation.ui.NavigationUI; + +import com.example.indexthis.databinding.ActivityMainBinding; + +public class MainActivity extends AppCompatActivity { + + // Home Screen + private ActivityMainBinding binding; + + // Other vars + public String yacyHost; + public String yacyUser; + public String yacyPassword; + public SharedPreferences sharedPref; + public String incomingUrl = ""; + + private String TAG = "IndexThis"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + binding = ActivityMainBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + + BottomNavigationView navView = findViewById(R.id.nav_view); + // Passing each menu ID as a set of Ids because each + // menu should be considered as top level destinations. + AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder( + R.id.navigation_home, R.id.navigation_options) + .build(); + NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main); + NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); + NavigationUI.setupWithNavController(binding.navView, navController); + + sharedPref = getPreferences(Context.MODE_PRIVATE); + loadPreferences(); + } + + void loadPreferences() { + yacyHost = sharedPref.getString("host", ""); + yacyUser = sharedPref.getString("user", "admin"); + yacyPassword = sharedPref.getString("password", ""); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/indexthis/ui/home/HomeFragment.java b/app/src/main/java/com/example/indexthis/ui/home/HomeFragment.java new file mode 100644 index 0000000..2c130a8 --- /dev/null +++ b/app/src/main/java/com/example/indexthis/ui/home/HomeFragment.java @@ -0,0 +1,202 @@ +package com.example.indexthis.ui.home; + +import static android.content.Intent.getIntent; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.net.Uri; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.SeekBar; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.lifecycle.ViewModelProvider; + +import com.burgstaller.okhttp.AuthenticationCacheInterceptor; +import com.burgstaller.okhttp.CachingAuthenticatorDecorator; +import com.burgstaller.okhttp.digest.CachingAuthenticator; +import com.burgstaller.okhttp.digest.Credentials; +import com.burgstaller.okhttp.digest.DigestAuthenticator; +import com.example.indexthis.MainActivity; +import com.example.indexthis.R; +import com.example.indexthis.databinding.ActivityMainBinding; +import com.example.indexthis.databinding.FragmentHomeBinding; +import com.google.android.material.snackbar.Snackbar; + +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; + +public class HomeFragment extends Fragment { + + private FragmentHomeBinding binding; + private String TAG = "IndexThis"; + + // Home Screen + private Button bIndexThis; + private SeekBar sbDepth; + public EditText etIndexUrl; + private EditText etDepth; + private String yacyHost; + private String yacyUser; + private String yacyPassword; + private SharedPreferences sharedPref; + + private OkHttpClient client; + + + + public View onCreateView(@NonNull LayoutInflater inflater, + ViewGroup container, Bundle savedInstanceState) { + HomeViewModel homeViewModel = + new ViewModelProvider(this).get(HomeViewModel.class); + + binding = FragmentHomeBinding.inflate(inflater, container, false); + View root = binding.getRoot(); + + //final TextView textView = binding.textHome; + //homeViewModel.getText().observe(getViewLifecycleOwner(), textView::setText); + + // Main Screen + sbDepth = binding.sbDepth; + etIndexUrl = binding.etUrl; + bIndexThis = binding.bIndexThis; + etDepth = binding.etDepth; + + MainActivity ma = (MainActivity) getActivity(); + sharedPref = ma.getPreferences(Context.MODE_PRIVATE); + loadPreferences(); + + // Process incoming data shared from other apps + Intent intent = ma.getIntent(); + String action = intent.getAction(); + String type = intent.getType(); + + if (Intent.ACTION_SEND.equals(action) && type != null) { + if ("text/plain".equals(type)) { + etIndexUrl.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); + } + } + + // + // Main Screen actions + // + // Depth slider action + sbDepth.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + etDepth.setText(String.format("%d", progress)); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + + } + }); + + bIndexThis.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + if (!yacyHost.toLowerCase().startsWith("http://")) { + if (!yacyHost.toLowerCase().startsWith("https://")) { + Log.e(TAG, "Unsupported scheme. Must be http:// or https://"); + return; + } + } + + HttpUrl.Builder urlBuilder = HttpUrl.parse(yacyHost + "/Crawler_p.html").newBuilder(); + urlBuilder.addQueryParameter("crawlingstart", "") + .addQueryParameter("crawlingMode", "url") + .addQueryParameter("crawlingURL", etIndexUrl.getText().toString()) + .addQueryParameter("crawlingDepth", etDepth.getText().toString()) + .addQueryParameter("range", "width") + .addQueryParameter("deleteOld", "off") + .addQueryParameter("recrawl", "reload") + .addQueryParameter("reloadIfOlderNumber", "7") + .addQueryParameter("reloadIfOlderUnit", "day") + .addQueryParameter("indexText", "on") + .addQueryParameter("indexMedia", "on"); + + Log.d(TAG, "URL: " + urlBuilder.toString()); + + String url = urlBuilder.build().toString(); + Request request = new Request.Builder() + .url(url) + .build(); + + final Map authCache = new ConcurrentHashMap<>(); + DigestAuthenticator authenticator = new DigestAuthenticator(new Credentials(yacyUser, yacyPassword)); + client = new OkHttpClient.Builder() + .authenticator(new CachingAuthenticatorDecorator(authenticator, authCache)) + .addInterceptor(new AuthenticationCacheInterceptor(authCache)) + .build(); + + client.newCall(request).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + call.cancel(); + Log.e(TAG, "Error making request"); + Snackbar.make(getActivity().findViewById(android.R.id.content), "Request failed!", Snackbar.LENGTH_SHORT) + .show(); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + final String myResponse = response.body().string(); + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + showSnackbar(response.code()); + if (response.code() == 200) { + Log.d(TAG, "HTTP 200 Response"); + } else { + Log.e(TAG, "Bad HTTP response: Code " + response.code()); + } + } + }); + } + }); + } + }); + + return root; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } + + void loadPreferences() { + yacyHost = sharedPref.getString("host", ""); + yacyUser = sharedPref.getString("user", "admin"); + yacyPassword = sharedPref.getString("password", ""); + } + + void showSnackbar(int statusCode) { + Snackbar.make(getActivity().findViewById(android.R.id.content), "Response: HTTP " + statusCode, Snackbar.LENGTH_SHORT) + .show(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/indexthis/ui/home/HomeViewModel.java b/app/src/main/java/com/example/indexthis/ui/home/HomeViewModel.java new file mode 100644 index 0000000..3dcdd36 --- /dev/null +++ b/app/src/main/java/com/example/indexthis/ui/home/HomeViewModel.java @@ -0,0 +1,19 @@ +package com.example.indexthis.ui.home; + +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +public class HomeViewModel extends ViewModel { + + private final MutableLiveData mText; + + public HomeViewModel() { + mText = new MutableLiveData<>(); + mText.setValue("This is home fragment"); + } + + public LiveData getText() { + return mText; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/indexthis/ui/options/OptionsFragment.java b/app/src/main/java/com/example/indexthis/ui/options/OptionsFragment.java new file mode 100644 index 0000000..ca0157c --- /dev/null +++ b/app/src/main/java/com/example/indexthis/ui/options/OptionsFragment.java @@ -0,0 +1,125 @@ +package com.example.indexthis.ui.options; + +import android.content.SharedPreferences; +import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.lifecycle.ViewModelProvider; + +import com.example.indexthis.MainActivity; +import com.example.indexthis.databinding.FragmentOptionsBinding; + +public class OptionsFragment extends Fragment { + + private EditText etYacyHost; + private EditText etYacyUser; + private EditText etYacyPassword; + private SharedPreferences sharedPref; + + private FragmentOptionsBinding binding; + + public View onCreateView(@NonNull LayoutInflater inflater, + ViewGroup container, Bundle savedInstanceState) { + OptionsViewModel dashboardViewModel = + new ViewModelProvider(this).get(OptionsViewModel.class); + + binding = FragmentOptionsBinding.inflate(inflater, container, false); + View root = binding.getRoot(); + + //final TextView textView = binding.textDashboard; + //dashboardViewModel.getText().observe(getViewLifecycleOwner(), textView::setText); + + // Options Screen + etYacyHost = binding.etYacyHost; + etYacyUser = binding.etYacyUser; + etYacyPassword = binding.etYacyPassword; + + MainActivity ma = (MainActivity)getActivity(); + sharedPref = ma.sharedPref; + + loadPreferences(); + + // + // Options Screen actions + // + + etYacyHost.addTextChangedListener(new TextWatcher() { + @Override + public void afterTextChanged(Editable s) {} + + @Override + public void beforeTextChanged(CharSequence s, int start, + int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, + int before, int count) { + sharedPref.edit().putString("host", etYacyHost.getText().toString()).commit(); + } + }); + + etYacyUser.addTextChangedListener(new TextWatcher() { + @Override + public void afterTextChanged(Editable s) {} + + @Override + public void beforeTextChanged(CharSequence s, int start, + int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, + int before, int count) { + sharedPref.edit().putString("user", etYacyUser.getText().toString()).commit(); + } + }); + + etYacyPassword.addTextChangedListener(new TextWatcher() { + @Override + public void afterTextChanged(Editable s) {} + + @Override + public void beforeTextChanged(CharSequence s, int start, + int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, + int before, int count) { + sharedPref.edit().putString("password", etYacyPassword.getText().toString()).commit(); + } + }); + + return root; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } + + private void loadPreferences() { + String yacyHost = sharedPref.getString("host", ""); + String yacyUser = sharedPref.getString("user", "admin"); + String yacyPassword = sharedPref.getString("password", ""); + + if (yacyHost != null) { + etYacyHost.setText(yacyHost); + } + if (yacyUser != null) { + etYacyUser.setText(yacyUser); + } + if (yacyPassword != null) { + etYacyPassword.setText("********"); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/indexthis/ui/options/OptionsViewModel.java b/app/src/main/java/com/example/indexthis/ui/options/OptionsViewModel.java new file mode 100644 index 0000000..47fb0aa --- /dev/null +++ b/app/src/main/java/com/example/indexthis/ui/options/OptionsViewModel.java @@ -0,0 +1,19 @@ +package com.example.indexthis.ui.options; + +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +public class OptionsViewModel extends ViewModel { + + private final MutableLiveData mText; + + public OptionsViewModel() { + mText = new MutableLiveData<>(); + mText.setValue("This is dashboard fragment"); + } + + public LiveData getText() { + return mText; + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_dashboard_black_24dp.xml b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml new file mode 100644 index 0000000..46fc8de --- /dev/null +++ b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_home_black_24dp.xml b/app/src/main/res/drawable/ic_home_black_24dp.xml new file mode 100644 index 0000000..f8bb0b5 --- /dev/null +++ b/app/src/main/res/drawable/ic_home_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_notifications_black_24dp.xml b/app/src/main/res/drawable/ic_notifications_black_24dp.xml new file mode 100644 index 0000000..78b75c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_notifications_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..06ea6ca --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,33 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml new file mode 100644 index 0000000..fa47008 --- /dev/null +++ b/app/src/main/res/layout/fragment_home.xml @@ -0,0 +1,89 @@ + + + + + + +